diff options
author | Mikael Magnusson <mikma@users.sourceforge.net> | 2020-10-26 22:52:17 +0100 |
---|---|---|
committer | Hans Dedecker <dedeckeh@gmail.com> | 2020-10-31 20:54:03 +0100 |
commit | e4f4e620488cbda1c2e93316f952fc4454746d76 (patch) | |
tree | 751c6ff59be80ab8d25ad564126820ba459a1fe6 /src/dhcpv4.c | |
parent | aff290bfee0b35a53bafb906aed107cc0b63a922 (diff) |
dhcpv6: add DHCPv4-over-DHCPv6 support
Add support for DHCPv4-over-DHCPv6 (DHCP 4o6) Transport (RFC 7341).
Signed-off-by: Mikael Magnusson <mikma@users.sourceforge.net>
Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'src/dhcpv4.c')
-rw-r--r-- | src/dhcpv4.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/dhcpv4.c b/src/dhcpv4.c index 51236d2..25a4c77 100644 --- a/src/dhcpv4.c +++ b/src/dhcpv4.c @@ -588,10 +588,28 @@ static void dhcpv4_fr_stop(struct dhcp_assignment *a) a->fr_timer.cb = NULL; } +static int dhcpv4_send_reply(const void *buf, size_t len, + const struct sockaddr *dest, socklen_t dest_len, + void *opaque) +{ + int *sock = opaque; + + return sendto(*sock, buf, len, MSG_DONTWAIT, dest, dest_len); +} + /* Handler for DHCPv4 messages */ static void handle_dhcpv4(void *addr, void *data, size_t len, struct interface *iface, _unused void *dest_addr) { + int sock = iface->dhcpv4_event.uloop.fd; + + dhcpv4_handle_msg(addr, data, len, iface, dest_addr, dhcpv4_send_reply, &sock); +} + +void dhcpv4_handle_msg(void *addr, void *data, size_t len, + struct interface *iface, _unused void *dest_addr, + send_reply_cb_t send_reply, void *opaque) +{ struct dhcpv4_message *req = data; if (iface->dhcpv4 == MODE_DISABLED) @@ -878,8 +896,8 @@ static void handle_dhcpv4(void *addr, void *data, size_t len, syslog(LOG_ERR, "ioctl(SIOCSARP): %m"); } - if (sendto(sock, &reply, PACKET_SIZE(&reply, cookie), MSG_DONTWAIT, - (struct sockaddr*)&dest, sizeof(dest)) < 0) + if (send_reply(&reply, PACKET_SIZE(&reply, cookie), + (struct sockaddr*)&dest, sizeof(dest), opaque) < 0) syslog(LOG_ERR, "Failed to send %s to %s - %s: %m", dhcpv4_msg_to_string(msg), dest.sin_addr.s_addr == INADDR_BROADCAST ? |