struct ubus_auto_conn conn;
struct blob_buf b;
static struct ubus_object udebug_object;
+static struct blob_attr *service_config;
enum {
LIST_ATTR_PROCNAME,
return 0;
}
+enum {
+ CFG_ATTR_SERVICE,
+ __CFG_ATTR_MAX
+};
+static const struct blobmsg_policy config_policy[__CFG_ATTR_MAX] = {
+ [CFG_ATTR_SERVICE] = { "service", BLOBMSG_TYPE_TABLE },
+};
+
+static struct blob_attr *
+udebug_fill_config(void)
+{
+ blob_buf_init(&b, 0);
+ if (service_config)
+ blobmsg_add_blob(&b, service_config);
+ else
+ blobmsg_close_table(&b, blobmsg_open_table(&b, "service"));
+
+ return b.head;
+}
+
+static int
+udebug_set_config(struct ubus_context *ctx, struct ubus_object *obj,
+ struct ubus_request_data *req, const char *method,
+ struct blob_attr *msg)
+{
+ struct blob_attr *tb[__CFG_ATTR_MAX], *cur;
+
+ blobmsg_parse_attr(config_policy, __CFG_ATTR_MAX, tb, msg);
+ if ((cur = tb[CFG_ATTR_SERVICE]) != NULL) {
+ free(service_config);
+ service_config = blob_memdup(cur);
+ ubus_notify(ctx, obj, "config", udebug_fill_config(), -1);
+ }
+
+ return 0;
+}
+
+static int
+udebug_get_config(struct ubus_context *ctx, struct ubus_object *obj,
+ struct ubus_request_data *req, const char *method,
+ struct blob_attr *msg)
+{
+ ubus_send_reply(ctx, req, udebug_fill_config());
+ return 0;
+}
+
static const struct ubus_method udebug_methods[] = {
UBUS_METHOD("list", udebug_list, list_policy),
+ UBUS_METHOD("set_config", udebug_set_config, config_policy),
+ UBUS_METHOD_NOARG("get_config", udebug_get_config),
};
static struct ubus_object_type udebug_object_type =