if (!iface)
return UBUS_STATUS_UNKNOWN_ERROR;
- interface_set_dynamic(iface);
iface->device_config = true;
config = blob_memdup(msg);
interface_add(iface, config);
- // need to look up the interface name again, in case of config update,
+ // need to look up the interface name again, in case of config update
+ // the pointer will have changed
iface = vlist_find(&interfaces, name, iface, node);
if (!iface)
return UBUS_STATUS_UNKNOWN_ERROR;
+ // Set interface as dynamic
+ interface_set_dynamic(iface);
+
dev = iface->main_dev.dev;
if (!dev || !dev->default_config)
return UBUS_STATUS_UNKNOWN_ERROR;
if (route->enabled != enabled)
continue;
+ if ((ip->no_defaultroute == enabled) && !route->mask)
+ continue;
+
if ((route->flags & DEVADDR_FAMILY) == DEVADDR_INET4)
af = AF_INET;
else
buf = blobmsg_alloc_string_buffer(&b, "source", buflen);
inet_ntop(af, &route->source, buf, buflen);
- snprintf(buf + strlen(buf), 4, "/%u", route->sourcemask);
+ snprintf(buf + strlen(buf), buflen - strlen(buf), "/%u", route->sourcemask);
blobmsg_add_string_buffer(&b);
blobmsg_close_table(&b, r);
if (iface->state == IFS_UP) {
time_t cur = system_get_rtime();
blobmsg_add_u32(&b, "uptime", cur - iface->start_time);
- blobmsg_add_string(&b, "l3_device", iface->l3_dev.dev->ifname);
+ if (iface->l3_dev.dev)
+ blobmsg_add_string(&b, "l3_device", iface->l3_dev.dev->ifname);
}
if (iface->proto_handler)
blobmsg_add_string(&b, "device", dev->ifname);
if (iface->state == IFS_UP) {
+ if (iface->updated) {
+ a = blobmsg_open_array(&b, "updated");
+
+ if (iface->updated & IUF_ADDRESS)
+ blobmsg_add_string(&b, NULL, "addresses");
+ if (iface->updated & IUF_ROUTE)
+ blobmsg_add_string(&b, NULL, "routes");
+ if (iface->updated & IUF_PREFIX)
+ blobmsg_add_string(&b, NULL, "prefixes");
+ if (iface->updated & IUF_DATA)
+ blobmsg_add_string(&b, NULL, "data");
+
+ blobmsg_close_array(&b, a);
+ }
+
if (iface->ip4table)
blobmsg_add_u32(&b, "ip4table", iface->ip4table);
if (iface->ip6table)
a = blobmsg_open_table(&b, "data");
avl_for_each_element(&iface->data, data, node)
- blob_put(&b, blob_id(data->data), blob_data(data->data), blob_len(data->data));
+ blobmsg_add_blob(&b, data->data);
blobmsg_close_table(&b, a);
- if (!list_is_empty(&iface->errors))
+ if (!list_empty(&iface->errors))
netifd_add_interface_errors(&b, iface);
}
}
static int
+netifd_handle_wdev_get_validate(struct ubus_context *ctx, struct ubus_object *obj,
+ struct ubus_request_data *req, const char *method,
+ struct blob_attr *msg)
+{
+ struct wireless_device *wdev;
+ int ret;
+
+ wdev = get_wdev(msg, &ret);
+ if (ret == UBUS_STATUS_NOT_FOUND)
+ return ret;
+
+ blob_buf_init(&b, 0);
+ if (wdev) {
+ wireless_device_get_validate(wdev, &b);
+ } else {
+ vlist_for_each_element(&wireless_devices, wdev, node)
+ wireless_device_get_validate(wdev, &b);
+ }
+ ubus_send_reply(ctx, req, b.head);
+ return 0;
+}
+
+static int
netifd_handle_wdev_notify(struct ubus_context *ctx, struct ubus_object *obj,
struct ubus_request_data *req, const char *method,
struct blob_attr *msg)
{ .name = "down", .handler = netifd_handle_wdev_down },
{ .name = "status", .handler = netifd_handle_wdev_status },
{ .name = "notify", .handler = netifd_handle_wdev_notify },
+ { .name = "get_validate", .handler = netifd_handle_wdev_get_validate },
};
static struct ubus_object_type wireless_object_type =
void
netifd_ubus_interface_notify(struct interface *iface, bool up)
{
- const char *event = (up) ? "update" : "down";
+ const char *event = (up) ? "interface.update" : "interface.down";
blob_buf_init(&b, 0);
blobmsg_add_string(&b, "interface", iface->name);
netifd_dump_status(iface);