diff options
Diffstat (limited to 'accel-pppd/ctrl/ipoe/dhcpv4.c')
-rw-r--r-- | accel-pppd/ctrl/ipoe/dhcpv4.c | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/accel-pppd/ctrl/ipoe/dhcpv4.c b/accel-pppd/ctrl/ipoe/dhcpv4.c index 0c43b944..e5a8731e 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) +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 n; int len = request->ptr - request->data; @@ -899,6 +899,9 @@ 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) { @@ -914,6 +917,7 @@ int dhcpv4_relay_send(struct dhcpv4_relay *relay, struct dhcpv4_packet *request, dhcpv4_print_packet(request, 1, log_ppp_info2); } + len = request->ptr - request->data; n = write(relay->hnd.fd, request->data, len); request->hdr->giaddr = giaddr; @@ -928,7 +932,8 @@ 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) + struct dhcpv4_option *client_id, struct dhcpv4_option *relay_agent, + const char *agent_circuit_id, const char *agent_remote_id) { struct dhcpv4_packet *pack; int n, len; @@ -959,8 +964,14 @@ 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; - - *pack->ptr = 255; pack->ptr++; + 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; len = pack->ptr - pack->data; |