summaryrefslogtreecommitdiff
path: root/accel-pptpd/radius
diff options
context:
space:
mode:
authorKozlov Dmitry <dima@server>2010-11-09 10:34:42 +0300
committerKozlov Dmitry <dima@server>2010-11-09 10:34:42 +0300
commit1396b7c22bbd319fc22ee420c14cdb69f8d5203c (patch)
treeb4fd2adf4ed9de0ce355b26ca8211880a539e97f /accel-pptpd/radius
parent0791b410d7465e2ef70345261d45340e3504381d (diff)
downloadaccel-ppp-xebd-1396b7c22bbd319fc22ee420c14cdb69f8d5203c.tar.gz
accel-ppp-xebd-1396b7c22bbd319fc22ee420c14cdb69f8d5203c.zip
radius: DM/CoA nas identification by NAS-Identifier or NAS-IP-Address or both
Diffstat (limited to 'accel-pptpd/radius')
-rw-r--r--accel-pptpd/radius/dm_coa.c2
-rw-r--r--accel-pptpd/radius/radius.c19
-rw-r--r--accel-pptpd/radius/radius_p.h4
-rw-r--r--accel-pptpd/radius/req.c2
4 files changed, 15 insertions, 12 deletions
diff --git a/accel-pptpd/radius/dm_coa.c b/accel-pptpd/radius/dm_coa.c
index 16b1f88..e66a3b3 100644
--- a/accel-pptpd/radius/dm_coa.c
+++ b/accel-pptpd/radius/dm_coa.c
@@ -263,7 +263,7 @@ static void __init init(void)
addr.sin_family = AF_INET;
addr.sin_port = htons (PD_COA_PORT);
if (conf_nas_ip_address)
- addr.sin_addr.s_addr = inet_addr(conf_nas_ip_address);
+ addr.sin_addr.s_addr = conf_nas_ip_address;
else
addr.sin_addr.s_addr = htonl (INADDR_ANY);
if (bind (serv.hnd.fd, (struct sockaddr *) &addr, sizeof (addr)) < 0) {
diff --git a/accel-pptpd/radius/radius.c b/accel-pptpd/radius/radius.c
index e6a13e9..bb8e216 100644
--- a/accel-pptpd/radius/radius.c
+++ b/accel-pptpd/radius/radius.c
@@ -25,8 +25,8 @@
int conf_max_try = 3;
int conf_timeout = 3;
char *conf_nas_identifier = "accel-pptpd";
-char *conf_nas_ip_address;
-char *conf_gw_ip_address;
+in_addr_t conf_nas_ip_address;
+in_addr_t conf_gw_ip_address;
in_addr_t conf_bind = 0;
int conf_verbose = 0;
@@ -62,7 +62,7 @@ int rad_proc_attrs(struct rad_req_t *req)
else {
req->rpd->ipaddr.owner = &ipdb;
req->rpd->ipaddr.peer_addr = attr->val.ipaddr;
- req->rpd->ipaddr.addr = inet_addr(conf_gw_ip_address);
+ req->rpd->ipaddr.addr = conf_gw_ip_address;
}
break;
case Acct_Interim_Interval:
@@ -306,9 +306,12 @@ int rad_check_nas_pack(struct rad_packet_t *pack)
ipaddr = attr->val.ipaddr;
}
- if (conf_nas_identifier && (!ident || strcmp(conf_nas_identifier, ident)))
+ if (!ident && !ipaddr)
return -1;
- if (conf_nas_ip_address && inet_addr(conf_nas_ip_address) != ipaddr)
+
+ if (conf_nas_identifier && ident && strcmp(conf_nas_identifier, ident))
+ return -1;
+ if (conf_nas_ip_address && ipaddr && conf_nas_ip_address != ipaddr)
return -1;
return 0;
@@ -369,7 +372,7 @@ static void __init radius_init(void)
opt = conf_get_opt("radius", "nas-ip-address");
if (opt)
- conf_nas_ip_address = opt;
+ conf_nas_ip_address = inet_addr(opt);
opt = conf_get_opt("radius", "nas-identifier");
if (opt)
@@ -377,13 +380,13 @@ static void __init radius_init(void)
opt = conf_get_opt("radius", "gw-ip-address");
if (opt)
- conf_gw_ip_address = opt;
+ conf_gw_ip_address = inet_addr(opt);
opt = conf_get_opt("radius", "bind");
if (opt)
conf_bind = inet_addr(opt);
else if (conf_nas_ip_address)
- conf_bind = inet_addr(conf_nas_ip_address);
+ conf_bind = conf_nas_ip_address;
opt = conf_get_opt("radius", "auth_server");
if (!opt) {
diff --git a/accel-pptpd/radius/radius_p.h b/accel-pptpd/radius/radius_p.h
index efcd9b8..c8a0658 100644
--- a/accel-pptpd/radius/radius_p.h
+++ b/accel-pptpd/radius/radius_p.h
@@ -58,9 +58,9 @@ extern int conf_max_try;
extern int conf_timeout;
extern int conf_verbose;
extern char *conf_nas_identifier;
-extern char *conf_nas_ip_address;
+extern in_addr_t conf_nas_ip_address;
extern in_addr_t conf_bind;
-extern char *conf_gw_ip_address;
+extern in_addr_t conf_gw_ip_address;
extern char *conf_auth_server;
extern char *conf_auth_secret;
extern int conf_auth_server_port;
diff --git a/accel-pptpd/radius/req.c b/accel-pptpd/radius/req.c
index 7526a92..9ac741d 100644
--- a/accel-pptpd/radius/req.c
+++ b/accel-pptpd/radius/req.c
@@ -54,7 +54,7 @@ struct rad_req_t *rad_req_alloc(struct radius_pd_t *rpd, int code, const char *u
if (rad_packet_add_str(req->pack, "NAS-Identifier", conf_nas_identifier, strlen(conf_nas_identifier)))
goto out_err;
if (conf_nas_ip_address)
- if (rad_packet_add_ipaddr(req->pack, "NAS-IP-Address", inet_addr(conf_nas_ip_address)))
+ if (rad_packet_add_ipaddr(req->pack, "NAS-IP-Address", conf_nas_ip_address))
goto out_err;
if (rad_packet_add_int(req->pack, "NAS-Port", rpd->ppp->unit_idx))
goto out_err;