diff options
-rw-r--r-- | accel-pppd/ctrl/ipoe/dhcpv4.c | 18 | ||||
-rw-r--r-- | accel-pppd/ctrl/ipoe/dhcpv4.h | 6 | ||||
-rw-r--r-- | accel-pppd/ctrl/ipoe/ipoe.c | 17 |
3 files changed, 17 insertions, 24 deletions
diff --git a/accel-pppd/ctrl/ipoe/dhcpv4.c b/accel-pppd/ctrl/ipoe/dhcpv4.c index 8bcc2e02..0c43b944 100644 --- a/accel-pppd/ctrl/ipoe/dhcpv4.c +++ b/accel-pppd/ctrl/ipoe/dhcpv4.c @@ -891,7 +891,7 @@ void dhcpv4_relay_free(struct dhcpv4_relay *r, struct triton_context_t *ctx) } } -int dhcpv4_relay_send(struct dhcpv4_relay *relay, struct dhcpv4_packet *request, uint32_t server_id, const char *agent_circuit_id, const char *agent_remote_id) +int dhcpv4_relay_send(struct dhcpv4_relay *relay, struct dhcpv4_packet *request, uint32_t server_id) { int n; int len = request->ptr - request->data; @@ -899,9 +899,6 @@ int dhcpv4_relay_send(struct dhcpv4_relay *relay, struct dhcpv4_packet *request, struct dhcpv4_option *opt = NULL; uint32_t _server_id; - if (!request->relay_agent && dhcpv4_packet_insert_opt82(request, agent_circuit_id, agent_remote_id)) - return -1; - request->hdr->giaddr = relay->giaddr; if (server_id) { @@ -931,8 +928,7 @@ int dhcpv4_relay_send(struct dhcpv4_relay *relay, struct dhcpv4_packet *request, } int dhcpv4_relay_send_release(struct dhcpv4_relay *relay, uint8_t *chaddr, uint32_t xid, uint32_t ciaddr, - struct dhcpv4_option *client_id, struct dhcpv4_option *relay_agent, - const char *agent_circuit_id, const char *agent_remote_id) + struct dhcpv4_option *client_id, struct dhcpv4_option *relay_agent) { struct dhcpv4_packet *pack; int n, len; @@ -963,14 +959,8 @@ int dhcpv4_relay_send_release(struct dhcpv4_relay *relay, uint8_t *chaddr, uint3 if (relay_agent && dhcpv4_packet_add_opt(pack, 82, relay_agent->data, relay_agent->len)) goto out_err; - else if (!relay_agent) { - pack->ptr++; - if (dhcpv4_packet_insert_opt82(pack, agent_circuit_id, agent_remote_id)) - goto out_err; - pack->ptr--; - } - - *pack->ptr++ = 255; + + *pack->ptr = 255; pack->ptr++; len = pack->ptr - pack->data; diff --git a/accel-pppd/ctrl/ipoe/dhcpv4.h b/accel-pppd/ctrl/ipoe/dhcpv4.h index cea0934c..a6a445b3 100644 --- a/accel-pppd/ctrl/ipoe/dhcpv4.h +++ b/accel-pppd/ctrl/ipoe/dhcpv4.h @@ -105,11 +105,9 @@ void dhcpv4_free(struct dhcpv4_serv *); struct dhcpv4_relay *dhcpv4_relay_create(const char *addr, const char *giaddr, struct triton_context_t *ctx, triton_event_func recv); void dhcpv4_relay_free(struct dhcpv4_relay *, struct triton_context_t *); -int dhcpv4_relay_send(struct dhcpv4_relay *relay, struct dhcpv4_packet *request, uint32_t server_id, - const char *agent_circuit_id, const char *agent_remote_id); +int dhcpv4_relay_send(struct dhcpv4_relay *relay, struct dhcpv4_packet *request, uint32_t server_id); int dhcpv4_relay_send_release(struct dhcpv4_relay *relay, uint8_t *chaddr, uint32_t xid, uint32_t ciaddr, - struct dhcpv4_option *client_id, struct dhcpv4_option *relay_agent, - const char *agent_circuit_id, const char *agent_remote_id); + struct dhcpv4_option *client_id, struct dhcpv4_option *relay_agent); int dhcpv4_send_reply(int msg_type, struct dhcpv4_serv *serv, struct dhcpv4_packet *req, uint32_t yiaddr, uint32_t siaddr, uint32_t mask, int lease_time, struct dhcpv4_packet *relay_reply); int dhcpv4_send_nak(struct dhcpv4_serv *serv, struct dhcpv4_packet *req); diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c index 6ba069bf..7c74e565 100644 --- a/accel-pppd/ctrl/ipoe/ipoe.c +++ b/accel-pppd/ctrl/ipoe/ipoe.c @@ -401,7 +401,12 @@ static void ipoe_session_start(struct ipoe_session *ses) } if (ses->dhcpv4_request && ses->serv->dhcpv4_relay) { - dhcpv4_relay_send(ses->serv->dhcpv4_relay, ses->dhcpv4_request, ses->relay_server_id, ses->serv->ifname, conf_agent_remote_id); + 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; ses->timer.expire_tv.tv_sec = conf_offer_timeout; @@ -583,7 +588,7 @@ static void __ipoe_session_activate(struct ipoe_session *ses) static void ipoe_session_activate(struct ipoe_session *ses) { if (ses->serv->dhcpv4_relay) - dhcpv4_relay_send(ses->serv->dhcpv4_relay, ses->dhcpv4_request, ses->relay_server_id, ses->serv->ifname, conf_agent_remote_id); + dhcpv4_relay_send(ses->serv->dhcpv4_relay, ses->dhcpv4_request, ses->relay_server_id); else __ipoe_session_activate(ses); } @@ -603,7 +608,7 @@ static void ipoe_session_keepalive(struct dhcpv4_packet *pack) ses->xid = ses->dhcpv4_request->hdr->xid; if (ses->ses.state == AP_STATE_ACTIVE && ses->serv->dhcpv4_relay) { - dhcpv4_relay_send(ses->serv->dhcpv4_relay, ses->dhcpv4_request, ses->relay_server_id, ses->serv->ifname, conf_agent_remote_id); + dhcpv4_relay_send(ses->serv->dhcpv4_relay, ses->dhcpv4_request, ses->relay_server_id); return; } @@ -680,7 +685,7 @@ static void ipoe_session_finished(struct ap_session *s) dhcpv4_put_ip(ses->serv->dhcpv4, ses->yiaddr); if (ses->relay_addr && ses->serv->dhcpv4_relay) - dhcpv4_relay_send_release(ses->serv->dhcpv4_relay, ses->hwaddr, ses->xid, ses->yiaddr, ses->client_id, ses->relay_agent, ses->serv->ifname, conf_agent_remote_id); + dhcpv4_relay_send_release(ses->serv->dhcpv4_relay, ses->hwaddr, ses->xid, ses->yiaddr, ses->client_id, ses->relay_agent); if (ses->ifcfg) ipoe_ifcfg_del(ses); @@ -857,7 +862,7 @@ static void ipoe_recv_dhcpv4(struct dhcpv4_serv *dhcpv4, struct dhcpv4_packet *p if (pack->server_id == ses->siaddr) dhcpv4_send_nak(dhcpv4, pack); else if (ses->serv->dhcpv4_relay) - dhcpv4_relay_send(ses->serv->dhcpv4_relay, pack, 0, ses->serv->ifname, conf_agent_remote_id); + dhcpv4_relay_send(ses->serv->dhcpv4_relay, pack, 0); ap_session_terminate(&ses->ses, TERM_USER_REQUEST, 0); } else { @@ -890,7 +895,7 @@ static void ipoe_recv_dhcpv4(struct dhcpv4_serv *dhcpv4, struct dhcpv4_packet *p } if (pack->msg_type == DHCPDECLINE && ses->serv->dhcpv4_relay) - dhcpv4_relay_send(ses->serv->dhcpv4_relay, pack, 0, ses->serv->ifname, conf_agent_remote_id); + dhcpv4_relay_send(ses->serv->dhcpv4_relay, pack, 0); ap_session_terminate(&ses->ses, TERM_USER_REQUEST, 0); } |