From b58e8523333ffea1b05024640d7318abb314a0f2 Mon Sep 17 00:00:00 2001 From: PolynomialDivision Date: Tue, 19 Sep 2017 13:04:55 +0200 Subject: [PATCH] Add umdns call --- src/include/ubus.h | 2 ++ src/utils/ubus.c | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/include/ubus.h b/src/include/ubus.h index e251000..e2356bd 100644 --- a/src/include/ubus.h +++ b/src/include/ubus.h @@ -26,4 +26,6 @@ void *kick_clients_thread(void *arg); char *hostapd_dir_glob; +int ubus_call_umdns(); + #endif diff --git a/src/utils/ubus.c b/src/utils/ubus.c index 6951b84..2c46de6 100644 --- a/src/utils/ubus.c +++ b/src/utils/ubus.c @@ -362,6 +362,8 @@ int dawn_init_ubus(const char *ubus_socket, char *hostapd_dir) { subscribe_to_hostapd_interfaces(hostapd_dir); + ubus_call_umdns(); + uloop_run(); close_socket(); @@ -591,4 +593,27 @@ void del_client_interface(uint32_t id, const uint8_t *client_addr, uint32_t reas int timeout = 1; ubus_invoke(ctx_clients, id, "del_client", b.head, NULL, NULL, timeout * 1000); +} + +static void ubus_umdns_cb(struct ubus_request *req, int type, struct blob_attr *msg) { + + if (!msg) + return; + + char *str = blobmsg_format_json(msg, true); + printf("UMDNS:\n%s", str); +} + + +int ubus_call_umdns() +{ + u_int32_t id; + if (ubus_lookup_id(ctx, "umdns", &id)) { + fprintf(stderr, "Failed to look up test object for %s\n", "umdns"); + return -1; + } + + int timeout = 1; + ubus_invoke(ctx_clients, id, "browse", NULL, ubus_umdns_cb, NULL, timeout * 1000); + return 0; } \ No newline at end of file