}
}
+void hotplug_ubus_event(struct blob_attr *data)
+{
+ static const struct blobmsg_policy policy =
+ { "SUBSYSTEM", BLOBMSG_TYPE_STRING };
+ struct hotplug_subsys *h;
+ struct blob_attr *attr;
+ const char *subsys;
+
+ blobmsg_parse_attr(&policy, 1, &attr, data);
+ if (!attr)
+ return;
+
+ subsys = blobmsg_get_string(attr);
+ h = avl_find_element(&subsystems, subsys, h, node);
+ if (!h)
+ return;
+
+ ubus_notify(ctx, &h->ubus, "event", data, -1);
+}
+
void ubus_init_hotplug(struct ubus_context *newctx)
{
ctx = newctx;
int i = 0;
static char buf[4096];
int len = recv(u->fd, buf, sizeof(buf) - 1, MSG_DONTWAIT);
- void *index;
if (len < 1)
return;
buf[len] = '\0';
blob_buf_init(&b, 0);
- index = blobmsg_open_table(&b, NULL);
while (i < len) {
int l = strlen(buf + i) + 1;
char *e = strstr(&buf[i], "=");
}
i += l;
}
- blobmsg_close_table(&b, index);
+ hotplug_ubus_event(b.head);
hotplug_handler_debug(b.head);
- json_script_run(&jctx, rule_file, blob_data(b.head));
+ json_script_run(&jctx, rule_file, b.head);
}
static struct uloop_fd hotplug_fd = {
void ubus_init_hotplug(struct ubus_context *ctx);
void ubus_init_service(struct ubus_context *ctx);
void ubus_init_system(struct ubus_context *ctx);
+#ifndef DISABLE_INIT
+void hotplug_ubus_event(struct blob_attr *data);
+#else
+static inline void hotplug_ubus_event(struct blob_attr *data)
+{
+}
+#endif
void procd_state_next(void);
void procd_state_ubus_connect(void);