summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Crispin <john@phrozen.org>2017-11-01 22:14:42 +0100
committerJohn Crispin <john@phrozen.org>2017-11-06 08:23:08 +0100
commit24ffe9b582b492054aebb59ac7a175fd65eef5d8 (patch)
tree25595e2d8d78c192099921270754674e961dd999
parent34c6e818e431cc53478a0f7c7c1eca07d194d692 (diff)
downloadubus-24ffe9b582b492054aebb59ac7a175fd65eef5d8.tar.gz
libubus-req: add data_cb callback handling for ubus notifications
Signed-off-by: John Crispin <john@phrozen.org>
-rw-r--r--libubus-req.c13
-rw-r--r--libubus.h3
2 files changed, 16 insertions, 0 deletions
diff --git a/libubus-req.c b/libubus-req.c
index 0c7d589..92f80fa 100644
--- a/libubus-req.c
+++ b/libubus-req.c
@@ -253,6 +253,18 @@ ubus_notify_complete_cb(struct ubus_request *req, int ret)
nreq->complete_cb(nreq, 0, 0);
}
+static void
+ubus_notify_data_cb(struct ubus_request *req, int type, struct blob_attr *msg)
+{
+ struct ubus_notify_request *nreq;
+
+ nreq = container_of(req, struct ubus_notify_request, req);
+ if (!nreq->data_cb)
+ return;
+
+ nreq->data_cb(nreq, type, msg);
+}
+
static int
__ubus_notify_async(struct ubus_context *ctx, struct ubus_object *obj,
const char *type, struct blob_attr *msg,
@@ -278,6 +290,7 @@ __ubus_notify_async(struct ubus_context *ctx, struct ubus_object *obj,
req->pending = 1;
req->id[0] = obj->id;
req->req.complete_cb = ubus_notify_complete_cb;
+ req->req.data_cb = ubus_notify_data_cb;
return 0;
}
diff --git a/libubus.h b/libubus.h
index 4e45cb6..dc42ea7 100644
--- a/libubus.h
+++ b/libubus.h
@@ -56,6 +56,8 @@ typedef void (*ubus_fd_handler_t)(struct ubus_request *req, int fd);
typedef void (*ubus_complete_handler_t)(struct ubus_request *req, int ret);
typedef void (*ubus_notify_complete_handler_t)(struct ubus_notify_request *req,
int idx, int ret);
+typedef void (*ubus_notify_data_handler_t)(struct ubus_notify_request *req,
+ int type, struct blob_attr *msg);
typedef void (*ubus_connect_handler_t)(struct ubus_context *ctx);
#define UBUS_OBJECT_TYPE(_name, _methods) \
@@ -221,6 +223,7 @@ struct ubus_notify_request {
ubus_notify_complete_handler_t status_cb;
ubus_notify_complete_handler_t complete_cb;
+ ubus_notify_data_handler_t data_cb;
uint32_t pending;
uint32_t id[UBUS_MAX_NOTIFY_PEERS + 1];