summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Crispin <blogic@openwrt.org>2013-06-29 22:19:04 +0200
committerJohn Crispin <blogic@openwrt.org>2013-06-29 22:26:50 +0200
commitd2f216cddaf4ee73117bb2693fc53b77f67517ad (patch)
treeb40113c7e88413af1c5ef6aa417560c92bce1a8e
parent0d44f0de9eacf687182ebebfcb1f9496dbf3bc32 (diff)
downloadunitd-d2f216cddaf4ee73117bb2693fc53b77f67517ad.tar
unitd-d2f216cddaf4ee73117bb2693fc53b77f67517ad.zip
add support for the system.event node
Signed-off-by: John Crispin <blogic@openwrt.org>
-rw-r--r--system.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/system.c b/system.c
index c96cb63..e1f4a64 100644
--- a/system.c
+++ b/system.c
@@ -259,11 +259,41 @@ static int watchdog_set(struct ubus_context *ctx, struct ubus_object *obj,
return 0;
}
+enum {
+ EVENT_TYPE,
+ EVENT_DATA,
+ __EVENT_MAX
+};
+
+static const struct blobmsg_policy event_policy[__WDT_MAX] = {
+ [EVENT_TYPE] = { .name = "frequency", .type = BLOBMSG_TYPE_INT32 },
+ [EVENT_DATA] = { .name = "timeout", .type = BLOBMSG_TYPE_INT32 },
+};
+
+static int system_event(struct ubus_context *ctx, struct ubus_object *obj,
+ struct ubus_request_data *req, const char *method,
+ struct blob_attr *msg)
+{
+ struct blob_attr *tb[__EVENT_MAX];
+
+ if (!msg)
+ return UBUS_STATUS_INVALID_ARGUMENT;
+
+ blobmsg_parse(event_policy, __EVENT_MAX, tb, blob_data(msg), blob_len(msg));
+ if (!tb[EVENT_TYPE])
+ return UBUS_STATUS_INVALID_ARGUMENT;
+
+ fprintf(stderr, "%s\n", blobmsg_get_string(tb[EVENT_TYPE]));
+
+ return 0;
+}
+
static const struct ubus_method system_methods[] = {
UBUS_METHOD_NOARG("board", system_board),
UBUS_METHOD_NOARG("info", system_info),
UBUS_METHOD_NOARG("upgrade", system_upgrade),
UBUS_METHOD("watchdog", watchdog_set, watchdog_policy),
+ UBUS_METHOD("event", system_event, event_policy),
};
static struct ubus_object_type system_object_type =