version 1.1.1.2, 2013/07/22 08:44:29
|
version 1.1.1.4.2.1, 2023/09/27 11:08:01
|
Line 5
|
Line 5
|
* Written by Alexander Motin <mav@FreeBSD.org> |
* Written by Alexander Motin <mav@FreeBSD.org> |
*/ |
*/ |
|
|
|
#define RADSRV |
|
|
#include "ppp.h" |
#include "ppp.h" |
#include "radsrv.h" |
#include "radsrv.h" |
#include "util.h" |
#include "util.h" |
|
|
|
#include <stdint.h> |
#include <radlib.h> |
#include <radlib.h> |
#include <radlib_vs.h> |
#include <radlib_vs.h> |
|
|
Line 32
|
Line 36
|
* INTERNAL FUNCTIONS |
* INTERNAL FUNCTIONS |
*/ |
*/ |
|
|
static int RadsrvSetCommand(Context ctx, int ac, char *av[], void *arg); | static int RadsrvSetCommand(Context ctx, int ac, const char *const av[], const void *arg); |
|
|
/* |
/* |
* GLOBAL VARIABLES |
* GLOBAL VARIABLES |
Line 51
|
Line 55
|
RadsrvSetCommand, NULL, 2, (void *) SET_ENABLE }, |
RadsrvSetCommand, NULL, 2, (void *) SET_ENABLE }, |
{ "disable [opt ...]", "Disable radsrv option" , |
{ "disable [opt ...]", "Disable radsrv option" , |
RadsrvSetCommand, NULL, 2, (void *) SET_DISABLE }, |
RadsrvSetCommand, NULL, 2, (void *) SET_DISABLE }, |
{ NULL }, | { NULL, NULL, NULL, NULL, 0, NULL }, |
}; |
}; |
|
|
|
|
Line 97 RadsrvEvent(int type, void *cookie)
|
Line 101 RadsrvEvent(int type, void *cookie)
|
char *username = NULL, *called = NULL, *calling = NULL, *sesid = NULL; |
char *username = NULL, *called = NULL, *calling = NULL, *sesid = NULL; |
char *msesid = NULL, *link = NULL, *bundle = NULL, *iface = NULL; |
char *msesid = NULL, *link = NULL, *bundle = NULL, *iface = NULL; |
int nasport = -1, serv_type = 0, ifindex = -1, i; |
int nasport = -1, serv_type = 0, ifindex = -1, i; |
u_int session_timeout = -1, idle_timeout = -1, acct_update = -1; | u_int session_timeout = UINT_MAX, idle_timeout = UINT_MAX; |
struct in_addr ip = { -1 }; | u_int acct_update = UINT_MAX; |
struct in_addr nas_ip = { -1 }; | struct in_addr ip = { INADDR_BROADCAST }; |
| struct in_addr nas_ip = { INADDR_BROADCAST }; |
char buf[64]; |
char buf[64]; |
u_int32_t vendor; |
u_int32_t vendor; |
u_char *state = NULL, *rad_class = NULL; |
u_char *state = NULL, *rad_class = NULL; |
Line 121 RadsrvEvent(int type, void *cookie)
|
Line 126 RadsrvEvent(int type, void *cookie)
|
struct acl *acl_limits[ACL_DIRS]; /* traffic limits based on mpd's filters */ |
struct acl *acl_limits[ACL_DIRS]; /* traffic limits based on mpd's filters */ |
char std_acct[ACL_DIRS][ACL_NAME_LEN]; /* Names of ACL returned in standard accounting */ |
char std_acct[ACL_DIRS][ACL_NAME_LEN]; /* Names of ACL returned in standard accounting */ |
|
|
|
(void)type; |
bzero(acl_filters, sizeof(acl_filters)); |
bzero(acl_filters, sizeof(acl_filters)); |
bzero(acl_limits, sizeof(acl_limits)); |
bzero(acl_limits, sizeof(acl_limits)); |
bzero(std_acct, sizeof(std_acct)); |
bzero(std_acct, sizeof(std_acct)); |
Line 230 RadsrvEvent(int type, void *cookie)
|
Line 236 RadsrvEvent(int type, void *cookie)
|
ip = rad_cvt_addr(data); |
ip = rad_cvt_addr(data); |
Log(LG_RADIUS2, ("radsrv: Got RAD_FRAMED_IP_ADDRESS: %s", |
Log(LG_RADIUS2, ("radsrv: Got RAD_FRAMED_IP_ADDRESS: %s", |
inet_ntoa(ip))); |
inet_ntoa(ip))); |
|
if (ip.s_addr == INADDR_BROADCAST) |
|
Log(LG_ERR, ("radsrv: incorrect Framed-IP-Address")); |
break; |
break; |
case RAD_NAS_PORT: |
case RAD_NAS_PORT: |
anysesid = 1; |
anysesid = 1; |
Line 439 RadsrvEvent(int type, void *cookie)
|
Line 447 RadsrvEvent(int type, void *cookie)
|
} |
} |
} |
} |
err = 0; |
err = 0; |
if (w->addr.u.ip4.s_addr != 0 && nas_ip.s_addr != -1 && w->addr.u.ip4.s_addr != nas_ip.s_addr) { | if (w->addr.u.ip4.s_addr != 0 && nas_ip.s_addr != INADDR_BROADCAST |
| && w->addr.u.ip4.s_addr != nas_ip.s_addr) { |
Log(LG_ERR, ("radsrv: incorrect NAS-IP-Address")); |
Log(LG_ERR, ("radsrv: incorrect NAS-IP-Address")); |
err = 403; |
err = 403; |
} else if (anysesid == 0) { |
} else if (anysesid == 0) { |
Line 487 RadsrvEvent(int type, void *cookie)
|
Line 496 RadsrvEvent(int type, void *cookie)
|
continue; |
continue; |
if (iface && (!B || strcmp(iface, B->iface.ifname))) |
if (iface && (!B || strcmp(iface, B->iface.ifname))) |
continue; |
continue; |
if (ifindex >= 0 && (!B || ifindex != B->iface.ifindex)) | if (ifindex >= 0 && (!B || (uint)ifindex != B->iface.ifindex)) |
continue; |
continue; |
if (ip.s_addr != -1 && (!B || | if (ip.s_addr != INADDR_BROADCAST && (!B || |
ip.s_addr != B->iface.peer_addr.u.ip4.s_addr)) |
ip.s_addr != B->iface.peer_addr.u.ip4.s_addr)) |
continue; |
continue; |
|
|
Line 546 RadsrvEvent(int type, void *cookie)
|
Line 555 RadsrvEvent(int type, void *cookie)
|
strcpy(L->lcp.auth.params.std_acct[0], std_acct[0]); |
strcpy(L->lcp.auth.params.std_acct[0], std_acct[0]); |
strcpy(L->lcp.auth.params.std_acct[1], std_acct[1]); |
strcpy(L->lcp.auth.params.std_acct[1], std_acct[1]); |
#endif |
#endif |
if (session_timeout != -1) | if (session_timeout != UINT_MAX) |
L->lcp.auth.params.session_timeout = session_timeout; |
L->lcp.auth.params.session_timeout = session_timeout; |
if (idle_timeout != -1) | if (idle_timeout != UINT_MAX) |
L->lcp.auth.params.idle_timeout = idle_timeout; |
L->lcp.auth.params.idle_timeout = idle_timeout; |
if (acct_update != -1) { | if (acct_update != UINT_MAX) { |
L->lcp.auth.params.acct_update = acct_update; |
L->lcp.auth.params.acct_update = acct_update; |
/* Stop accounting update timer if running. */ |
/* Stop accounting update timer if running. */ |
TimerStop(&L->lcp.auth.acct_timer); |
TimerStop(&L->lcp.auth.acct_timer); |
Line 652 RadsrvOpen(Radsrv w)
|
Line 661 RadsrvOpen(Radsrv w)
|
return (-1); |
return (-1); |
} |
} |
|
|
if ((w->fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP)) == -1) { | if ((w->fd = socket(PF_INET, socktype(SOCK_DGRAM), IPPROTO_UDP)) == -1) { |
Perror("%s: Cannot create socket", __FUNCTION__); |
Perror("%s: Cannot create socket", __FUNCTION__); |
return (-1); |
return (-1); |
} |
} |
Line 720 RadsrvClose(Radsrv w)
|
Line 729 RadsrvClose(Radsrv w)
|
*/ |
*/ |
|
|
int |
int |
RadsrvStat(Context ctx, int ac, char *av[], void *arg) | RadsrvStat(Context ctx, int ac, const char *const av[], const void *arg) |
{ |
{ |
Radsrv w = &gRadsrv; |
Radsrv w = &gRadsrv; |
char addrstr[64]; |
char addrstr[64]; |
struct radiusclient_conf *client; |
struct radiusclient_conf *client; |
|
|
|
(void)ac; |
|
(void)av; |
|
(void)arg; |
|
|
Printf("Radsrv configuration:\r\n"); |
Printf("Radsrv configuration:\r\n"); |
Printf("\tState : %s\r\n", w->handle ? "OPENED" : "CLOSED"); |
Printf("\tState : %s\r\n", w->handle ? "OPENED" : "CLOSED"); |
Printf("\tSelf : %s %d\r\n", |
Printf("\tSelf : %s %d\r\n", |
Line 747 RadsrvStat(Context ctx, int ac, char *av[], void *arg)
|
Line 760 RadsrvStat(Context ctx, int ac, char *av[], void *arg)
|
*/ |
*/ |
|
|
static int |
static int |
RadsrvSetCommand(Context ctx, int ac, char *av[], void *arg) | RadsrvSetCommand(Context ctx, int ac, const char *const av[], const void *arg) |
{ |
{ |
Radsrv w = &gRadsrv; |
Radsrv w = &gRadsrv; |
int port, count; |
int port, count; |