int stack_depth;
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;
uint32_t msgbuf_data_len;
struct blob_attr *signature;
};
+struct ubus_acl_key {
+ const char *user;
+ const char *group;
+ const char *object;
+};
+
struct ubus_request_data {
uint32_t object;
uint32_t peer;
uint16_t seq;
+ struct ubus_acl_key acl;
+
/* internal use */
bool deferred;
int fd;
/* call this only for struct ubus_context pointers initialised by ubus_connect_ctx() */
void ubus_shutdown(struct ubus_context *ctx);
+static inline void ubus_auto_shutdown(struct ubus_auto_conn *conn)
+{
+ uloop_timeout_cancel(&conn->timer);
+ ubus_shutdown(&conn->ctx);
+}
+
const char *ubus_strerror(int error);
static inline void ubus_add_uloop(struct ubus_context *ctx)
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 */
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;
}