summaryrefslogtreecommitdiffhomepage
path: root/src/ubus.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/ubus.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/ubus.c')
-rw-r--r--src/ubus.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/ubus.c b/src/ubus.c
index 95eeff7..19b14be 100644
--- a/src/ubus.c
+++ b/src/ubus.c
@@ -311,6 +311,25 @@ static const struct blobmsg_policy obj_attrs[OBJ_ATTR_MAX] = {
[OBJ_ATTR_PATH] = { .name = "path", .type = BLOBMSG_TYPE_STRING },
};
+void ubus_bcast_dhcp_event(const char *type, const uint8_t *mac,
+ const size_t mlen, const struct in_addr *addr, const char *name,
+ const char *interface)
+{
+ if (!ubus || !main_object.has_subscribers)
+ return;
+
+ blob_buf_init(&b, 0);
+ if (mac)
+ blobmsg_add_string(&b, "mac", odhcpd_print_mac(mac, mlen));
+ if (addr)
+ blobmsg_add_string(&b, "ip", inet_ntoa(*addr));
+ if (name)
+ blobmsg_add_string(&b, "name", name);
+ if (interface)
+ blobmsg_add_string(&b, "interface", interface);
+
+ ubus_notify(ubus, &main_object, type, b.head, -1);
+}
static void handle_event(_unused struct ubus_context *ctx, _unused struct ubus_event_handler *ev,
_unused const char *type, struct blob_attr *msg)