X-Git-Url: http://git.archive.openwrt.org/?p=project%2Fnetifd.git;a=blobdiff_plain;f=ubus.c;h=02becf22c8a37b894fba22aad87488f64c036845;hp=d8768241d2f614aeb789d1affe90cc8ba5a68793;hb=a0f359bf861f060d563dd0424d51dac1bf96340c;hpb=8495bc0176185ca77eae770a33b3463ca2bc0f25 diff --git a/ubus.c b/ubus.c index d876824..02becf2 100644 --- a/ubus.c +++ b/ubus.c @@ -147,13 +147,16 @@ netifd_add_dynamic(struct ubus_context *ctx, struct ubus_object *obj, goto error; interface_add(iface, config); - interface_set_dynamic(iface); - // 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; @@ -650,7 +653,8 @@ netifd_dump_status(struct interface *iface) 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) @@ -737,11 +741,11 @@ netifd_dump_status(struct interface *iface) 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); } @@ -1064,6 +1068,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 +1110,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 =