+static inline int
+ubus_unregister_subscriber(struct ubus_context *ctx, struct ubus_subscriber *obj)
+{
+ return ubus_remove_object(ctx, &obj->obj);
+}
+
+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_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 ----------- */
+
+struct acl_object {
+ struct ubus_acl_key key;
+ struct avl_node avl;
+ struct blob_attr *acl;
+};
+
+extern struct avl_tree acl_objects;
+int ubus_register_acl(struct ubus_context *ctx);
+
+#define acl_for_each(o, m) \
+ if ((m)->object && (m)->user && (m)->group) \
+ avl_for_element_range(avl_find_ge_element(&acl_objects, m, o, avl), avl_find_le_element(&acl_objects, m, o, avl), o, avl)
+
+/* ----------- rpc ----------- */
+
+/* invoke a method on a specific object */
+int ubus_invoke(struct ubus_context *ctx, uint32_t obj, const char *method,
+ struct blob_attr *msg, ubus_data_handler_t cb, void *priv,
+ int timeout);
+
+/* asynchronous version of ubus_invoke() */
+int ubus_invoke_async(struct ubus_context *ctx, uint32_t obj, const char *method,
+ struct blob_attr *msg, struct ubus_request *req);
+
+/* send a reply to an incoming object method call */
+int ubus_send_reply(struct ubus_context *ctx, struct ubus_request_data *req,
+ struct blob_attr *msg);
+
+static inline void ubus_defer_request(struct ubus_context *ctx,
+ struct ubus_request_data *req,
+ struct ubus_request_data *new_req)
+{
+ (void) ctx;
+ memcpy(new_req, req, sizeof(*req));
+ req->deferred = true;
+}
+
+static inline void ubus_request_set_fd(struct ubus_context *ctx,
+ struct ubus_request_data *req, int fd)
+{
+ (void) ctx;
+ req->fd = fd;
+}
+
+void ubus_complete_deferred_request(struct ubus_context *ctx,
+ struct ubus_request_data *req, int ret);
+
+/*
+ * send a notification to all subscribers of an object
+ * if timeout < 0, no reply is expected from subscribers
+ */
+int ubus_notify(struct ubus_context *ctx, struct ubus_object *obj,
+ const char *type, struct blob_attr *msg, int timeout);
+
+int ubus_notify_async(struct ubus_context *ctx, struct ubus_object *obj,
+ const char *type, struct blob_attr *msg,
+ struct ubus_notify_request *req);
+
+
+/* ----------- events ----------- */
+
+int ubus_send_event(struct ubus_context *ctx, const char *id,
+ struct blob_attr *data);
+
+int ubus_register_event_handler(struct ubus_context *ctx,
+ struct ubus_event_handler *ev,
+ const char *pattern);
+
+static inline int ubus_unregister_event_handler(struct ubus_context *ctx,
+ struct ubus_event_handler *ev)
+{
+ return ubus_remove_object(ctx, &ev->obj);
+}
+
+#endif