diff options
author | John Crispin <blogic@openwrt.org> | 2014-02-17 12:12:26 +0000 |
---|---|---|
committer | Felix Fietkau <nbd@openwrt.org> | 2014-02-17 15:12:50 +0100 |
commit | b5cfcfe34e6b44f2be90bf24e879dc25f0f07b9e (patch) | |
tree | e6e48509c03565a6402e66d5a3c7f32d1ddde04c | |
parent | 0244609f376d6b11b98c9488b964fa9133e250fa (diff) |
wireless: add a "get_validate" methode to ubus
Signed-off-by: John Crispin <blogic@openwrt.org>
-rw-r--r-- | ubus.c | 24 | ||||
-rw-r--r-- | wireless.c | 24 | ||||
-rw-r--r-- | wireless.h | 1 |
3 files changed, 49 insertions, 0 deletions
@@ -1064,6 +1064,29 @@ netifd_handle_wdev_status(struct ubus_context *ctx, struct ubus_object *obj, } 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) @@ -1083,6 +1106,7 @@ static struct ubus_method wireless_object_methods[] = { { .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 = @@ -701,6 +701,30 @@ wireless_device_status(struct wireless_device *wdev, struct blob_buf *b) blobmsg_close_table(b, c); } +void +wireless_device_get_validate(struct wireless_device *wdev, struct blob_buf *b) +{ + struct uci_blob_param_list *p; + void *c, *d; + int i; + + c = blobmsg_open_table(b, wdev->name); + + d = blobmsg_open_table(b, "device"); + p = wdev->drv->device.config; + for (i = 0; i < p->n_params; i++) + blobmsg_add_string(b, p->params[i].name, uci_get_validate_string(p, i)); + blobmsg_close_table(b, d); + + d = blobmsg_open_table(b, "interface"); + p = wdev->drv->interface.config; + for (i = 0; i < p->n_params; i++) + blobmsg_add_string(b, p->params[i].name, uci_get_validate_string(p, i)); + blobmsg_close_table(b, d); + + blobmsg_close_table(b, c); +} + static void wireless_interface_set_data(struct wireless_interface *vif) { @@ -91,6 +91,7 @@ void wireless_device_create(struct wireless_driver *drv, const char *name, struc void wireless_device_set_up(struct wireless_device *wdev); void wireless_device_set_down(struct wireless_device *wdev); void wireless_device_status(struct wireless_device *wdev, struct blob_buf *b); +void wireless_device_get_validate(struct wireless_device *wdev, struct blob_buf *b); void wireless_interface_create(struct wireless_device *wdev, struct blob_attr *data, const char *section); int wireless_device_notify(struct wireless_device *wdev, struct blob_attr *data, struct ubus_request_data *req); |