X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=blobdiff_plain;f=ubus.c;h=c47f459be47a50ebb1cd143ed592f9820417cb40;hp=8c237c3376f4643a698c6747689ad852b30de093;hb=6b3f6f4466e5584f2bdefc55b3ca34186b65acb9;hpb=d64c608820ddb4817ef7dff1f993a5801ff99ca2 diff --git a/ubus.c b/ubus.c index 8c237c3..c47f459 100644 --- a/ubus.c +++ b/ubus.c @@ -1,4 +1,7 @@ +#define _GNU_SOURCE + #include +#include #include "netifd.h" #include "interface.h" @@ -8,6 +11,7 @@ static struct ubus_context *ctx = NULL; static struct blob_buf b; +static struct netifd_fd ubus_fd; /* global object */ @@ -102,6 +106,8 @@ netifd_ubus_init(const char *path) DPRINTF("connected as %08x\n", ctx->local_id); uloop_init(); ubus_add_uloop(ctx); + ubus_fd.fd = ctx->sock.fd; + netifd_fd_add(&ubus_fd); ret = ubus_add_object(ctx, &main_object); if (ret) @@ -336,13 +342,12 @@ void netifd_ubus_add_interface(struct interface *iface) { struct ubus_object *obj = &iface->ubus; - char *name; + char *name = NULL; - name = malloc(strlen(main_object.name) + strlen(iface->name) + 2); + asprintf(&name, "%s.interface.%s", main_object.name, iface->name); if (!name) return; - sprintf(name, "%s.%s", main_object.name, iface->name); obj->name = name; obj->type = &iface_object_type; obj->methods = iface_object_methods;