struct ubus_context *ubus_ctx = NULL;
static struct blob_buf b;
static const char *ubus_path;
+static struct udebug_ubus udebug;
/* global object */
HR_TARGET,
HR_V6,
HR_INTERFACE,
+ HR_EXCLUDE,
__HR_MAX
};
[HR_TARGET] = { .name = "target", .type = BLOBMSG_TYPE_STRING },
[HR_V6] = { .name = "v6", .type = BLOBMSG_TYPE_BOOL },
[HR_INTERFACE] = { .name = "interface", .type = BLOBMSG_TYPE_STRING },
+ [HR_EXCLUDE] = { .name = "exclude", .type = BLOBMSG_TYPE_BOOL },
};
static int
struct interface *iface = NULL;
union if_addr a;
bool v6 = false;
+ bool exclude = false;
blobmsg_parse(route_policy, __HR_MAX, tb, blob_data(msg), blob_len(msg));
if (!tb[HR_TARGET])
if (tb[HR_V6])
v6 = blobmsg_get_bool(tb[HR_V6]);
+ if (tb[HR_EXCLUDE])
+ exclude = blobmsg_get_bool(tb[HR_EXCLUDE]);
+
if (tb[HR_INTERFACE])
iface = vlist_find(&interfaces, blobmsg_data(tb[HR_INTERFACE]), iface, node);
if (!inet_pton(v6 ? AF_INET6 : AF_INET, blobmsg_data(tb[HR_TARGET]), &a))
return UBUS_STATUS_INVALID_ARGUMENT;
-
- iface = interface_ip_add_target_route(&a, v6, iface);
+ iface = interface_ip_add_target_route(&a, v6, iface, exclude);
if (!iface)
return UBUS_STATUS_NOT_FOUND;
struct device *dev = NULL;
struct blob_attr *tb[__ALIAS_ATTR_MAX];
struct blob_attr *cur;
- int rem;
+ size_t rem;
blobmsg_parse(alias_attrs, __ALIAS_ATTR_MAX, tb, blob_data(msg), blob_len(msg));
DEV_STATE_NAME,
DEV_STATE_DEFER,
DEV_STATE_AUTH_STATUS,
+ DEV_STATE_AUTH_VLANS,
__DEV_STATE_MAX,
};
[DEV_STATE_NAME] = { .name = "name", .type = BLOBMSG_TYPE_STRING },
[DEV_STATE_DEFER] = { .name = "defer", .type = BLOBMSG_TYPE_BOOL },
[DEV_STATE_AUTH_STATUS] = { .name = "auth_status", .type = BLOBMSG_TYPE_BOOL },
+ [DEV_STATE_AUTH_VLANS] = { .name = "auth_vlans", BLOBMSG_TYPE_ARRAY },
};
static int
struct device *dev = NULL;
struct blob_attr *tb[__DEV_STATE_MAX];
struct blob_attr *cur;
+ bool auth_status;
blobmsg_parse(dev_state_policy, __DEV_STATE_MAX, tb, blob_data(msg), blob_len(msg));
if (cur)
device_set_deferred(dev, !!blobmsg_get_u8(cur));
- cur = tb[DEV_STATE_AUTH_STATUS];
- if (cur)
- device_set_auth_status(dev, !!blobmsg_get_u8(cur));
+ if ((cur = tb[DEV_STATE_AUTH_STATUS]) != NULL)
+ auth_status = blobmsg_get_bool(cur);
+ else
+ auth_status = dev->auth_status;
+ if (tb[DEV_STATE_AUTH_STATUS] || tb[DEV_STATE_AUTH_VLANS])
+ device_set_auth_status(dev, auth_status, tb[DEV_STATE_AUTH_VLANS]);
return 0;
}
int t = 2;
if (ubus_reconnect(ubus_ctx, ubus_path) != 0) {
- DPRINTF("failed to reconnect, trying again in %d seconds\n", t);
+ D(SYSTEM, "failed to reconnect, trying again in %d seconds", t);
uloop_timeout_set(&retry, t * 1000);
return;
}
- DPRINTF("reconnected to ubus, new id: %08x\n", ubus_ctx->local_id);
+ D(SYSTEM, "reconnected to ubus, new id: %08x", ubus_ctx->local_id);
netifd_ubus_add_fd();
}
}
a = blobmsg_open_table(&b, "data");
+
+ if (iface->zone)
+ blobmsg_add_string(&b, "zone", iface->zone);
avl_for_each_element(&iface->data, data, node)
blobmsg_add_blob(&b, data->data);
{
struct interface *iface;
struct blob_attr *tb;
- int i;
+ size_t i;
blobmsg_parse(&iface_policy, 1, &tb, blob_data(msg), blob_len(msg));
if (!tb)
static void netifd_add_iface_object(void)
{
struct ubus_method *methods;
- int i;
+ size_t i;
methods = calloc(1, sizeof(iface_object_methods));
if (!methods)
int
netifd_ubus_init(const char *path)
{
- uloop_init();
ubus_path = path;
ubus_ctx = ubus_connect(path);
if (!ubus_ctx)
return -EIO;
- DPRINTF("connected as %08x\n", ubus_ctx->local_id);
+ D(SYSTEM, "connected as %08x", ubus_ctx->local_id);
ubus_ctx->connection_lost = netifd_ubus_connection_lost;
netifd_ubus_add_fd();
netifd_add_object(&wireless_object);
netifd_add_iface_object();
+ udebug_ubus_init(&udebug, ubus_ctx, "netifd", netifd_udebug_config);
+
return 0;
}
void
netifd_ubus_done(void)
{
+ udebug_ubus_free(&udebug);
ubus_free(ubus_ctx);
}
obj->methods = iface_object_methods;
obj->n_methods = ARRAY_SIZE(iface_object_methods);
if (ubus_add_object(ubus_ctx, &iface->ubus)) {
- DPRINTF("failed to publish ubus object for interface '%s'\n", iface->name);
+ D(SYSTEM, "failed to publish ubus object for interface '%s'", iface->name);
free(name);
obj->name = NULL;
}