提交 4e7ed294 编写于 作者: K Kozlov Dmitry

ipoe: insert option 82 to relay request

上级 e5e85219
......@@ -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;
}
......
......@@ -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 *);
......
......@@ -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;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册