libubus: add monitor support
Signed-off-by: Felix Fietkau <nbd@openwrt.org>
This commit is contained in:
parent
47d75dd84a
commit
44a62711e0
3 changed files with 23 additions and 0 deletions
|
@ -466,3 +466,9 @@ void __hidden ubus_process_req_msg(struct ubus_context *ctx, struct ubus_msghdr_
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int __ubus_monitor(struct ubus_context *ctx, const char *type)
|
||||||
|
{
|
||||||
|
blob_buf_init(&b, 0);
|
||||||
|
return ubus_invoke(ctx, UBUS_SYSTEM_OBJECT_MONITOR, type, b.head, NULL, NULL, 1000);
|
||||||
|
}
|
||||||
|
|
|
@ -105,6 +105,10 @@ ubus_process_msg(struct ubus_context *ctx, struct ubus_msghdr_buf *buf, int fd)
|
||||||
|
|
||||||
ubus_process_obj_msg(ctx, buf);
|
ubus_process_obj_msg(ctx, buf);
|
||||||
break;
|
break;
|
||||||
|
case UBUS_MSG_MONITOR:
|
||||||
|
if (ctx->monitor_cb)
|
||||||
|
ctx->monitor_cb(ctx, buf->hdr.seq, buf->data);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
13
libubus.h
13
libubus.h
|
@ -158,6 +158,7 @@ struct ubus_context {
|
||||||
int stack_depth;
|
int stack_depth;
|
||||||
|
|
||||||
void (*connection_lost)(struct ubus_context *ctx);
|
void (*connection_lost)(struct ubus_context *ctx);
|
||||||
|
void (*monitor_cb)(struct ubus_context *ctx, uint32_t seq, struct blob_attr *data);
|
||||||
|
|
||||||
struct ubus_msghdr_buf msgbuf;
|
struct ubus_msghdr_buf msgbuf;
|
||||||
uint32_t msgbuf_data_len;
|
uint32_t msgbuf_data_len;
|
||||||
|
@ -290,6 +291,18 @@ ubus_unregister_subscriber(struct ubus_context *ctx, struct ubus_subscriber *obj
|
||||||
int ubus_subscribe(struct ubus_context *ctx, struct ubus_subscriber *obj, uint32_t id);
|
int ubus_subscribe(struct ubus_context *ctx, struct ubus_subscriber *obj, uint32_t id);
|
||||||
int ubus_unsubscribe(struct ubus_context *ctx, struct ubus_subscriber *obj, uint32_t id);
|
int ubus_unsubscribe(struct ubus_context *ctx, struct ubus_subscriber *obj, uint32_t id);
|
||||||
|
|
||||||
|
int __ubus_monitor(struct ubus_context *ctx, const char *type);
|
||||||
|
|
||||||
|
static inline int ubus_monitor_start(struct ubus_context *ctx)
|
||||||
|
{
|
||||||
|
return __ubus_monitor(ctx, "add");
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline int ubus_monitor_stop(struct ubus_context *ctx)
|
||||||
|
{
|
||||||
|
return __ubus_monitor(ctx, "remove");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------- acl ----------- */
|
/* ----------- acl ----------- */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue