diff options
-rw-r--r-- | accel-pppd/radius/radius.c | 20 | ||||
-rw-r--r-- | accel-pppd/radius/radius_p.h | 2 | ||||
-rw-r--r-- | accel-pppd/radius/req.c | 3 |
3 files changed, 17 insertions, 8 deletions
diff --git a/accel-pppd/radius/radius.c b/accel-pppd/radius/radius.c index 3d206839..d6d7de07 100644 --- a/accel-pppd/radius/radius.c +++ b/accel-pppd/radius/radius.c @@ -401,7 +401,7 @@ struct radius_pd_t *find_pd(struct ap_session *ses) } -struct radius_pd_t *rad_find_session(const char *sessionid, const char *username, int port_id, in_addr_t ipaddr, const char *csid) +struct radius_pd_t *rad_find_session(const char *sessionid, const char *username, const char *port_id, int port, in_addr_t ipaddr, const char *csid) { struct radius_pd_t *rpd; @@ -413,7 +413,9 @@ struct radius_pd_t *rad_find_session(const char *sessionid, const char *username continue; if (username && strcmp(username, rpd->ses->username)) continue; - if (port_id >= 0 && port_id != rpd->ses->unit_idx) + if (port >= 0 && port != rpd->ses->unit_idx) + continue; + if (port_id && strcmp(port_id, rpd->ses->ifname)) continue; if (ipaddr && rpd->ses->ipv4 && ipaddr != rpd->ses->ipv4->peer_addr) continue; @@ -433,7 +435,8 @@ struct radius_pd_t *rad_find_session_pack(struct rad_packet_t *pack) const char *sessionid = NULL; const char *username = NULL; const char *csid = NULL; - int port_id = -1; + int port = -1; + const char *port_id = NULL; in_addr_t ipaddr = 0; list_for_each_entry(attr, &pack->attrs, entry) { @@ -447,7 +450,10 @@ struct radius_pd_t *rad_find_session_pack(struct rad_packet_t *pack) username = attr->val.string; break; case NAS_Port: - port_id = attr->val.integer; + port = attr->val.integer; + break; + case NAS_Port_Id: + port_id = attr->val.string; break; case Framed_IP_Address: ipaddr = attr->val.ipaddr; @@ -458,13 +464,13 @@ struct radius_pd_t *rad_find_session_pack(struct rad_packet_t *pack) } } - if (!sessionid && !username && port_id == -1 && ipaddr == 0 && !csid) + if (!sessionid && !username && !port_id && port == -1 && ipaddr == 0 && !csid) return NULL; - if (username && !sessionid && port_id == -1 && ipaddr == 0) + if (username && !sessionid && port == -1 && ipaddr == 0 && !port_id) return NULL; - return rad_find_session(sessionid, username, port_id, ipaddr, csid); + return rad_find_session(sessionid, username, port_id, port, ipaddr, csid); } int rad_check_nas_pack(struct rad_packet_t *pack) diff --git a/accel-pppd/radius/radius_p.h b/accel-pppd/radius/radius_p.h index 29a971fb..4654c78d 100644 --- a/accel-pppd/radius/radius_p.h +++ b/accel-pppd/radius/radius_p.h @@ -138,7 +138,7 @@ extern int conf_fail_time; extern int conf_req_limit; int rad_check_nas_pack(struct rad_packet_t *pack); -struct radius_pd_t *rad_find_session(const char *sessionid, const char *username, int port_id, in_addr_t ipaddr, const char *csid); +struct radius_pd_t *rad_find_session(const char *sessionid, const char *username, const char *port_id, int port, in_addr_t ipaddr, const char *csid); struct radius_pd_t *rad_find_session_pack(struct rad_packet_t *pack); int rad_dict_load(const char *fname); diff --git a/accel-pppd/radius/req.c b/accel-pppd/radius/req.c index 2b789ad7..818252ee 100644 --- a/accel-pppd/radius/req.c +++ b/accel-pppd/radius/req.c @@ -81,6 +81,9 @@ static struct rad_req_t *__rad_req_alloc(struct radius_pd_t *rpd, int code, cons if (rad_packet_add_int(req->pack, NULL, "NAS-Port", rpd->ses->unit_idx)) goto out_err; + if (rad_packet_add_str(req->pack, NULL, "NAS-Port-Id", rpd->ses->ifname)) + goto out_err; + if (req->rpd->ses->ctrl->type == CTRL_TYPE_IPOE) { if (rad_packet_add_val(req->pack, NULL, "NAS-Port-Type", "Ethernet")) goto out_err; |