summaryrefslogtreecommitdiff
path: root/accel-pppd
diff options
context:
space:
mode:
authorKozlov Dmitry <xeb@mail.ru>2013-01-25 11:41:00 +0400
committerKozlov Dmitry <xeb@mail.ru>2013-01-25 11:41:00 +0400
commit4e7ed29422fa958ebba78774f6a7745a303eb997 (patch)
tree12e424266420a8bc967d8cc1ae7e85b1e9d790d2 /accel-pppd
parente5e85219bb6a64d80a962866c9ba993b9562c7d3 (diff)
downloadaccel-ppp-4e7ed29422fa958ebba78774f6a7745a303eb997.tar.gz
accel-ppp-4e7ed29422fa958ebba78774f6a7745a303eb997.zip
ipoe: insert option 82 to relay request
Diffstat (limited to 'accel-pppd')
-rw-r--r--accel-pppd/ctrl/ipoe/dhcpv4.c25
-rw-r--r--accel-pppd/ctrl/ipoe/dhcpv4.h1
-rw-r--r--accel-pppd/ctrl/ipoe/ipoe.c12
3 files changed, 38 insertions, 0 deletions
diff --git a/accel-pppd/ctrl/ipoe/dhcpv4.c b/accel-pppd/ctrl/ipoe/dhcpv4.c
index 86aba87..e842f38 100644
--- a/accel-pppd/ctrl/ipoe/dhcpv4.c
+++ b/accel-pppd/ctrl/ipoe/dhcpv4.c
@@ -44,6 +44,7 @@ static mempool_t opt_pool;
static LIST_HEAD(relay_list);
static int dhcpv4_read(struct triton_md_handler_t *h);
+int dhcpv4_packet_add_opt(struct dhcpv4_packet *pack, int type, const void *data, int len);
static struct dhcpv4_iprange *parse_range(const char *str)
{
@@ -433,6 +434,27 @@ int dhcpv4_parse_opt82(struct dhcpv4_option *opt, uint8_t **agent_circuit_id, ui
return 0;
}
+int dhcpv4_packet_insert_opt82(struct dhcpv4_packet *pack, const char *agent_circuit_id, const char *agent_remote_id)
+{
+ int len1 = strlen(agent_circuit_id);
+ int len2 = strlen(agent_remote_id);
+ uint8_t *data = _malloc(4 + len1 + len2);
+ uint8_t *ptr = data;
+ int r;
+
+ *ptr++ = 1;
+ *ptr++ = len1;
+ memcpy(ptr, agent_circuit_id, len1); ptr += len1;
+
+ *ptr++ = 2;
+ *ptr++ = len2;
+ memcpy(ptr, agent_remote_id, len2); ptr += len2;
+
+ r = dhcpv4_packet_add_opt(pack, 82, data, 4 + len1 + len2);
+ _free(data);
+
+ return r;
+}
static int dhcpv4_read(struct triton_md_handler_t *h)
{
@@ -629,6 +651,9 @@ int dhcpv4_packet_add_opt(struct dhcpv4_packet *pack, int type, const void *data
list_add_tail(&opt->entry, &pack->options);
+ if (type == 82)
+ pack->relay_agent = opt;
+
return 0;
}
diff --git a/accel-pppd/ctrl/ipoe/dhcpv4.h b/accel-pppd/ctrl/ipoe/dhcpv4.h
index 67f7e61..a6a445b 100644
--- a/accel-pppd/ctrl/ipoe/dhcpv4.h
+++ b/accel-pppd/ctrl/ipoe/dhcpv4.h
@@ -114,6 +114,7 @@ int dhcpv4_send_nak(struct dhcpv4_serv *serv, struct dhcpv4_packet *req);
void dhcpv4_packet_ref(struct dhcpv4_packet *pack);
struct dhcpv4_option *dhcpv4_packet_find_opt(struct dhcpv4_packet *pack, int type);
+int dhcpv4_packet_insert_opt82(struct dhcpv4_packet *pack, const char *agent_circuit_id, const char *agent_remote_id);
void dhcpv4_packet_free(struct dhcpv4_packet *pack);
int dhcpv4_check_options(struct dhcpv4_packet *);
diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c
index a830240..74d2f90 100644
--- a/accel-pppd/ctrl/ipoe/ipoe.c
+++ b/accel-pppd/ctrl/ipoe/ipoe.c
@@ -72,6 +72,7 @@ static int conf_netmask = 24;
static int conf_lease_time = 600;
static int conf_lease_timeout = 660;
static int conf_verbose;
+static const char *conf_agent_remote_id;
static unsigned int stat_starting;
static unsigned int stat_active;
@@ -400,6 +401,11 @@ static void ipoe_session_start(struct ipoe_session *ses)
}
if (ses->dhcpv4_request && ses->serv->dhcpv4_relay) {
+ if (!ses->dhcpv4_request->relay_agent && dhcpv4_packet_insert_opt82(ses->dhcpv4_request, ses->serv->ifname, conf_agent_remote_id)) {
+ ap_session_terminate(&ses->ses, TERM_NAS_ERROR, 0);
+ return;
+ }
+
dhcpv4_relay_send(ses->serv->dhcpv4_relay, ses->dhcpv4_request, ses->relay_server_id);
ses->timer.expire = ipoe_session_timeout;
@@ -1695,6 +1701,12 @@ static void load_config(void)
conf_mode = MODE_L2;
conf_relay = conf_get_opt("ipoe", "relay");
+
+ opt = conf_get_opt("ipoe", "agent-remote-id");
+ if (opt)
+ conf_agent_remote_id = opt;
+ else
+ conf_agent_remote_id = "accel-pppd";
conf_dhcpv4 = 0;
conf_up = 0;