summaryrefslogtreecommitdiff
path: root/accel-pppd
diff options
context:
space:
mode:
authorDmitry Kozlov <xeb@mail.ru>2014-09-04 10:18:42 +0400
committerDmitry Kozlov <xeb@mail.ru>2014-09-04 10:18:42 +0400
commit6bed2a5a27ec36bddf0d1041bb25926899a8e3cd (patch)
treeae67cc881b0ee10efa8dd95e3015ba68af9191af /accel-pppd
parentec9968885ed2f273c4d2c18297986c463fb9cf9b (diff)
downloadaccel-ppp-6bed2a5a27ec36bddf0d1041bb25926899a8e3cd.tar.gz
accel-ppp-6bed2a5a27ec36bddf0d1041bb25926899a8e3cd.zip
ipoe: send option 82 from DHCP request to radius
To enable this specify attr-opt82 option in [ipoe] section. Attribute must be octet type.
Diffstat (limited to 'accel-pppd')
-rw-r--r--accel-pppd/accel-ppp.conf1
-rw-r--r--accel-pppd/ctrl/ipoe/ipoe.c27
-rw-r--r--accel-pppd/ctrl/ipoe/ipoe.h7
3 files changed, 32 insertions, 3 deletions
diff --git a/accel-pppd/accel-ppp.conf b/accel-pppd/accel-ppp.conf
index af10c447..e4e7b0b7 100644
--- a/accel-pppd/accel-ppp.conf
+++ b/accel-pppd/accel-ppp.conf
@@ -117,6 +117,7 @@ start=dhcpv4
#attr-dhcp-router-ip=DHCP-Router-IP-Address
#attr-dhcp-mask=DHCP-Mask
#attr-dhcp-lease-time=DHCP-Lease-Time
+#attr-dhcp-opt82=DHCP-Option82
#attr-l4-redirect=L4-Redirect
#local-net=192.168.0.0/16
#lua-file=/etc/accel-ppp.lua
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c
index 5ee2d414..9c6075e1 100644
--- a/accel-pppd/ctrl/ipoe/ipoe.c
+++ b/accel-pppd/ctrl/ipoe/ipoe.c
@@ -33,9 +33,6 @@
#include "ipset.h"
#include "connlimit.h"
-#ifdef RADIUS
-#include "radius.h"
-#endif
#include "ipoe.h"
@@ -119,6 +116,7 @@ static int conf_attr_dhcp_router_ip;
static int conf_attr_dhcp_mask;
static int conf_attr_dhcp_lease_time;
static int conf_attr_l4_redirect;
+static const char *conf_attr_dhcp_opt82;
#endif
static int conf_l4_redirect_table;
static int conf_l4_redirect_on_reject;
@@ -155,6 +153,7 @@ static mempool_t disc_item_pool;
static mempool_t req_item_pool;
static int connlimit_loaded;
+static int radius_loaded;
static LIST_HEAD(serv_list);
static pthread_mutex_t serv_lock = PTHREAD_MUTEX_INITIALIZER;
@@ -179,6 +178,7 @@ static void ipoe_session_keepalive(struct dhcpv4_packet *pack);
static void add_interface(const char *ifname, int ifindex, const char *opt, int parent_ifindex, int vid);
static int get_offer_delay();
static void __ipoe_session_start(struct ipoe_session *ses);
+static int ipoe_rad_send_request(struct rad_plugin_t *rad, struct rad_packet_t *pack);
static struct ipoe_session *ipoe_session_lookup(struct ipoe_serv *serv, struct dhcpv4_packet *pack, struct ipoe_session **opt82_ses)
{
@@ -528,6 +528,14 @@ static void ipoe_session_start(struct ipoe_session *ses)
if (ses->serv->opt_shared && ipoe_create_interface(ses))
return;
+#ifdef RADIUS
+ if (conf_attr_dhcp_opt82 && ses->relay_agent && radius_loaded) {
+ ses->radius.send_access_request = ipoe_rad_send_request;
+ ses->radius.send_accounting_request = ipoe_rad_send_request;
+ rad_register_plugin(&ses->ses, &ses->radius);
+ }
+#endif
+
r = pwdb_check(&ses->ses, username, PPP_PAP, conf_password ? conf_password : username);
if (r == PWDB_NO_IMPL) {
passwd = pwdb_get_passwd(&ses->ses, ses->ses.username);
@@ -1743,6 +1751,17 @@ static void ev_radius_coa(struct ev_radius_t *ev)
if (l4_redirect != ses->l4_redirect && ev->ses->state == AP_STATE_ACTIVE)
ipoe_change_l4_redirect(ses, l4_redirect);
}
+
+static int ipoe_rad_send_request(struct rad_plugin_t *rad, struct rad_packet_t *pack)
+{
+ struct ipoe_session *ses = container_of(rad, typeof(*ses), radius);
+
+ if (!ses->relay_agent)
+ return 0;
+
+ return rad_packet_add_octets(pack, NULL, conf_attr_dhcp_opt82, ses->relay_agent->data, ses->relay_agent->len);
+}
+
#endif
static void ipoe_serv_release(struct ipoe_serv *serv)
@@ -2541,6 +2560,7 @@ static void load_radius_attrs(void)
parse_conf_rad_attr("attr-dhcp-mask", &conf_attr_dhcp_mask);
parse_conf_rad_attr("attr-dhcp-lease-time", &conf_attr_dhcp_lease_time);
parse_conf_rad_attr("attr-l4-redirect", &conf_attr_l4_redirect);
+ conf_attr_dhcp_opt82 = conf_get_opt("ipoe", "attr-dhcp-opt82");
}
#endif
@@ -3061,6 +3081,7 @@ static void ipoe_init(void)
#endif
connlimit_loaded = triton_module_loaded("connlimit");
+ radius_loaded = triton_module_loaded("radius");
}
DEFINE_INIT(52, ipoe_init);
diff --git a/accel-pppd/ctrl/ipoe/ipoe.h b/accel-pppd/ctrl/ipoe/ipoe.h
index 44c8b99f..7b572c71 100644
--- a/accel-pppd/ctrl/ipoe/ipoe.h
+++ b/accel-pppd/ctrl/ipoe/ipoe.h
@@ -9,6 +9,10 @@
#include "ipdb.h"
#include "dhcpv4.h"
+#ifdef RADIUS
+#include "radius.h"
+#endif
+
#ifndef ETH_ALEN
#define ETH_ALEN 6
#endif
@@ -77,6 +81,9 @@ struct ipoe_session {
int relay_retransmit;
int ifindex;
struct ipv4db_item_t ipv4;
+#ifdef RADIUS
+ struct rad_plugin_t radius;
+#endif
int ifcfg:1;
int started:1;
int terminating:1;