+#define _GNU_SOURCE
+
#include <string.h>
+#include <stdio.h>
#include "netifd.h"
#include "interface.h"
static struct ubus_context *ctx = NULL;
static struct blob_buf b;
+static struct netifd_fd ubus_fd;
/* global object */
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)
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;