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);
}
static void
-netifd_dump_status(struct interface *iface)
+netifd_dump_status(struct interface *iface, bool up)
{
struct interface_data *data;
struct device *dev;
void *a, *inactive;
- blobmsg_add_u8(&b, "up", iface->state == IFS_UP);
+ blobmsg_add_u8(&b, "up", up && iface->state == IFS_UP);
blobmsg_add_u8(&b, "pending", iface->state == IFS_SETUP);
blobmsg_add_u8(&b, "available", iface->available);
blobmsg_add_u8(&b, "autostart", iface->autostart);
struct interface *iface = container_of(obj, struct interface, ubus);
blob_buf_init(&b, 0);
- netifd_dump_status(iface);
+ netifd_dump_status(iface, true);
ubus_send_reply(ctx, req, b.head);
return 0;
vlist_for_each_element(&interfaces, iface, node) {
void *i = blobmsg_open_table(&b, NULL);
blobmsg_add_string(&b, "interface", iface->name);
- netifd_dump_status(iface);
+ netifd_dump_status(iface, true);
blobmsg_close_table(&b, i);
}
}
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 =
const char *event = (up) ? "update" : "down";
blob_buf_init(&b, 0);
blobmsg_add_string(&b, "interface", iface->name);
- netifd_dump_status(iface);
+ netifd_dump_status(iface, up);
ubus_notify(ubus_ctx, &iface_object, event, b.head, -1);
ubus_notify(ubus_ctx, &iface->ubus, event, b.head, -1);
}