diff options
Diffstat (limited to 'src/dhcpv4.c')
-rw-r--r-- | src/dhcpv4.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/src/dhcpv4.c b/src/dhcpv4.c index 3191ff2..77f669c 100644 --- a/src/dhcpv4.c +++ b/src/dhcpv4.c @@ -53,7 +53,8 @@ static struct dhcp_assignment* dhcpv4_lease(struct interface *iface, enum dhcpv4_msg msg, const uint8_t *mac, const uint32_t reqaddr, uint32_t *leasetime, const char *hostname, const size_t hostname_len, const bool accept_fr_nonce, bool *incl_fr_opt, uint32_t *fr_serverid, - const char *reqopts, const size_t reqopts_len); + const char *reqopts, const size_t reqopts_len, + const struct in6_addr *peer_4o6); static struct netevent_handler dhcpv4_netevent_handler = { .cb = dhcpv4_netevent_cb, }; static struct uloop_timeout valid_until_timeout = {.cb = valid_until_cb}; @@ -604,12 +605,14 @@ static void handle_dhcpv4(void *addr, void *data, size_t len, { int sock = iface->dhcpv4_event.uloop.fd; - dhcpv4_handle_msg(addr, data, len, iface, dest_addr, dhcpv4_send_reply, &sock); + dhcpv4_handle_msg(addr, data, len, iface, dest_addr, dhcpv4_send_reply, &sock, + NULL); } 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) + send_reply_cb_t send_reply, void *opaque, + const struct in6_addr *peer_4o6) { struct dhcpv4_message *req = data; @@ -713,7 +716,7 @@ void dhcpv4_handle_msg(void *addr, void *data, size_t len, a = dhcpv4_lease(iface, reqmsg, req->chaddr, reqaddr, &leasetime, hostname, hostname_len, accept_fr_nonce, &incl_fr_opt, &fr_serverid, - reqopts, reqopts_len); + reqopts, reqopts_len, peer_4o6); if (!a) { if (reqmsg == DHCPV4_MSG_REQUEST) @@ -759,7 +762,7 @@ void dhcpv4_handle_msg(void *addr, void *data, size_t len, #ifdef WITH_UBUS if (reqmsg == DHCPV4_MSG_RELEASE) ubus_bcast_dhcp_event("dhcp.release", req->chaddr, req->hlen, - &req->ciaddr, a ? a->hostname : NULL, iface->ifname); + &req->ciaddr, a ? a->hostname : NULL, iface->ifname, peer_4o6); #endif if (reqmsg == DHCPV4_MSG_DECLINE || reqmsg == DHCPV4_MSG_RELEASE) return; @@ -926,7 +929,7 @@ void dhcpv4_handle_msg(void *addr, void *data, size_t len, #ifdef WITH_UBUS if (msg == DHCPV4_MSG_ACK) ubus_bcast_dhcp_event("dhcp.ack", req->chaddr, req->hlen, &reply.yiaddr, - a ? a->hostname : NULL, iface->ifname); + a ? a->hostname : NULL, iface->ifname, peer_4o6); #endif } @@ -1035,7 +1038,8 @@ static struct dhcp_assignment* dhcpv4_lease(struct interface *iface, enum dhcpv4_msg msg, const uint8_t *mac, const uint32_t reqaddr, uint32_t *leasetime, const char *hostname, const size_t hostname_len, const bool accept_fr_nonce, bool *incl_fr_opt, - uint32_t *fr_serverid, const char* reqopts, const size_t reqopts_len) + uint32_t *fr_serverid, const char* reqopts, const size_t reqopts_len, + const struct in6_addr *peer_4o6) { struct dhcp_assignment *a = find_assignment_by_hwaddr(iface, mac); struct lease *l = config_find_lease_by_mac(mac); @@ -1071,6 +1075,10 @@ dhcpv4_lease(struct interface *iface, enum dhcpv4_msg msg, const uint8_t *mac, a->iface = iface; a->flags = OAF_DHCPV4; a->addr = l ? l->ipaddr : INADDR_ANY; + if (peer_4o6) { + a->peer.sin6_family = AF_INET6; + a->peer.sin6_addr = *peer_4o6; + } assigned = dhcpv4_assign(iface, a, reqaddr); |