summaryrefslogtreecommitdiffhomepage
path: root/ubus.c
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2014-07-28 21:48:26 +0200
committerSteven Barth <steven@midlink.org>2014-07-28 21:48:26 +0200
commit7b81300f7329a7c815dc8543c1a50febddfa6632 (patch)
tree02bc92669bf691868375e22b8318f2f700782dc6 /ubus.c
parent75e73ab3714e324bf98140dbbf740d3e4c40f044 (diff)
ubus: add del_dynamic as complement to add_dynamic
Signed-off-by: Steven Barth <steven@midlink.org>
Diffstat (limited to 'ubus.c')
-rw-r--r--ubus.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/ubus.c b/ubus.c
index 6c42aa1..bed1fa4 100644
--- a/ubus.c
+++ b/ubus.c
@@ -173,12 +173,38 @@ error:
return UBUS_STATUS_UNKNOWN_ERROR;
}
+static int
+netifd_del_dynamic(struct ubus_context *ctx, struct ubus_object *obj,
+ struct ubus_request_data *req, const char *method,
+ struct blob_attr *msg)
+{
+ struct blob_attr *tb[__DI_MAX];
+ struct interface *iface;
+
+ blobmsg_parse(dynamic_policy, __DI_MAX, tb, blob_data(msg), blob_len(msg));
+
+ if (!tb[DI_NAME])
+ return UBUS_STATUS_INVALID_ARGUMENT;
+
+ const char *name = blobmsg_get_string(tb[DI_NAME]);
+ iface = vlist_find(&interfaces, name, iface, node);
+
+ if (!iface)
+ return UBUS_STATUS_NOT_FOUND;
+ else if (!iface->dynamic)
+ return UBUS_STATUS_INVALID_COMMAND;
+
+ vlist_delete(&interfaces, &iface->node);
+ return UBUS_STATUS_OK;
+}
+
static struct ubus_method main_object_methods[] = {
{ .name = "restart", .handler = netifd_handle_restart },
{ .name = "reload", .handler = netifd_handle_reload },
UBUS_METHOD("add_host_route", netifd_add_host_route, route_policy),
{ .name = "get_proto_handlers", .handler = netifd_get_proto_handlers },
UBUS_METHOD("add_dynamic", netifd_add_dynamic, dynamic_policy),
+ UBUS_METHOD("del_dynamic", netifd_del_dynamic, dynamic_policy),
};
static struct ubus_object_type main_object_type =