summaryrefslogtreecommitdiffhomepage
path: root/src/dhcpv4.c
diff options
context:
space:
mode:
authorHans Dedecker <dedeckeh@gmail.com>2017-11-28 15:08:27 +0100
committerHans Dedecker <dedeckeh@gmail.com>2017-12-06 10:30:33 +0100
commitc516801e3dbb992ce1ea5274439b9b30888d9fb1 (patch)
tree057186b8a30ff591ed296e015cf5f8464a9cc06f /src/dhcpv4.c
parent92e205df59af022e0cfe6e0243b3ef572fc38f5c (diff)
dhcpv4: notify DHCP ACK and RELEASE via ubus
If the ubus object has any subscription notify DHCP ACK and DHCP RELEASE events using ubus notifications. Signed-off-by: Borja Salazar <borja.salazar@fon.com> Signed-off-by: Hans Dedecker <dedeckeh@gmail.com>
Diffstat (limited to 'src/dhcpv4.c')
-rw-r--r--src/dhcpv4.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/dhcpv4.c b/src/dhcpv4.c
index 166582e..c367507 100644
--- a/src/dhcpv4.c
+++ b/src/dhcpv4.c
@@ -723,6 +723,11 @@ static void handle_dhcpv4(void *addr, void *data, size_t len,
req->chaddr[0],req->chaddr[1],req->chaddr[2],
req->chaddr[3],req->chaddr[4],req->chaddr[5]);
+#ifdef WITH_UBUS
+ if (reqmsg == DHCPV4_MSG_RELEASE)
+ ubus_bcast_dhcp_event("dhcp.release", req->chaddr, req->hlen,
+ &req->ciaddr, hostname, iface->ifname);
+#endif
if (reqmsg == DHCPV4_MSG_DECLINE || reqmsg == DHCPV4_MSG_RELEASE)
return;
@@ -872,6 +877,12 @@ static void handle_dhcpv4(void *addr, void *data, size_t len,
sendto(sock, &reply, sizeof(reply), MSG_DONTWAIT,
(struct sockaddr*)&dest, sizeof(dest));
+
+#ifdef WITH_UBUS
+ if (msg == DHCPV4_MSG_ACK)
+ ubus_bcast_dhcp_event("dhcp.ack", req->chaddr, req->hlen, &reply.yiaddr,
+ hostname, iface->ifname);
+#endif
}
static bool dhcpv4_assign(struct interface *iface,