21 #include <libubox/avl.h>
22 #include <libubox/list.h>
23 #include <libubox/blobmsg.h>
24 #include <libubox/uloop.h>
29 #define UBUS_MAX_NOTIFY_PEERS 16
51 const char *method,
struct blob_attr *msg);
56 const char *
type,
struct blob_attr *msg);
58 int type,
struct blob_attr *msg);
64 int type,
struct blob_attr *msg);
68 #define UBUS_OBJECT_TYPE(_name, _methods) \
72 .n_methods = ARRAY_SIZE(_methods), \
76 #define __UBUS_METHOD_NOARG(_name, _handler, _tags) \
78 .handler = _handler, \
81 #define __UBUS_METHOD(_name, _handler, _policy, _tags) \
82 __UBUS_METHOD_NOARG(_name, _handler, _tags), \
84 .n_policy = ARRAY_SIZE(_policy)
86 #define UBUS_METHOD(_name, _handler, _policy) \
87 { __UBUS_METHOD(_name, _handler, _policy, 0) }
89 #define UBUS_METHOD_TAG(_name, _handler, _policy, _tags)\
90 { __UBUS_METHOD(_name, _handler, _policy, _tags) }
92 #define UBUS_METHOD_MASK(_name, _handler, _policy, _mask) \
94 __UBUS_METHOD(_name, _handler, _policy, 0),\
98 #define UBUS_METHOD_NOARG(_name, _handler) \
99 { __UBUS_METHOD_NOARG(_name, _handler, 0) }
101 #define UBUS_METHOD_TAG_NOARG(_name, _handler, _tags) \
102 { __UBUS_METHOD_NOARG(_name, _handler, _tags) }
104 #define UBUS_TAG_STATUS BIT(0)
105 #define UBUS_TAG_ADMIN BIT(1)
106 #define UBUS_TAG_PRIVATE BIT(2)
143 struct list_head
list;
162 struct uloop_fd
sock;
208 struct list_head
list;
244 struct uloop_timeout
timer;
262 uloop_timeout_cancel(&conn->
timer);
270 uloop_fd_add(&
ctx->
sock, ULOOP_BLOCKING | ULOOP_READ);
311 if (!list_empty(&obj->
list))
312 list_del_init(&obj->
list);
343 #define acl_for_each(o, m) \
344 if ((m)->object && (m)->user && (m)->group) \
345 avl_for_element_range(avl_find_ge_element(&acl_objects, m, o, avl), avl_find_le_element(&acl_objects, m, o, avl), o, avl)
363 struct blob_attr *msg,
struct ubus_request *req,
int fd);
373 struct blob_attr *msg);
380 memcpy(new_req, req,
sizeof(*req));
407 const char *
type,
struct blob_attr *msg,
int timeout);
410 const char *
type,
struct blob_attr *msg,
417 struct blob_attr *data);
421 const char *pattern);
int(* cb)(struct ubus_context *ctx, int argc, char **argv)
static struct ubus_context * ctx
struct ubus_context * ubus_connect(const char *path)
void ubus_complete_deferred_request(struct ubus_context *ctx, struct ubus_request_data *req, int ret)
void ubus_auto_connect(struct ubus_auto_conn *conn)
void(* ubus_remove_handler_t)(struct ubus_context *ctx, struct ubus_subscriber *obj, uint32_t id)
int ubus_lookup(struct ubus_context *ctx, const char *path, ubus_lookup_handler_t cb, void *priv)
int ubus_subscribe(struct ubus_context *ctx, struct ubus_subscriber *obj, uint32_t id)
int ubus_notify(struct ubus_context *ctx, struct ubus_object *obj, const char *type, struct blob_attr *msg, int timeout)
static void ubus_defer_request(struct ubus_context *ctx, struct ubus_request_data *req, struct ubus_request_data *new_req)
static int ubus_request_get_caller_fd(struct ubus_request_data *req)
void(* ubus_complete_handler_t)(struct ubus_request *req, int ret)
static void ubus_auto_shutdown(struct ubus_auto_conn *conn)
int ubus_register_subscriber(struct ubus_context *ctx, struct ubus_subscriber *obj)
int ubus_invoke_async_fd(struct ubus_context *ctx, uint32_t obj, const char *method, struct blob_attr *msg, struct ubus_request *req, int fd)
int ubus_invoke_fd(struct ubus_context *ctx, uint32_t obj, const char *method, struct blob_attr *msg, ubus_data_handler_t cb, void *priv, int timeout, int fd)
struct avl_tree acl_objects
bool(* ubus_new_object_handler_t)(struct ubus_context *ctx, struct ubus_subscriber *sub, const char *path)
int ubus_send_event(struct ubus_context *ctx, const char *id, struct blob_attr *data)
void(* ubus_fd_handler_t)(struct ubus_request *req, int fd)
#define UBUS_MAX_NOTIFY_PEERS
void ubus_free(struct ubus_context *ctx)
void ubus_shutdown(struct ubus_context *ctx)
int ubus_register_acl(struct ubus_context *ctx)
void(* ubus_state_handler_t)(struct ubus_context *ctx, struct ubus_object *obj)
static void ubus_request_set_fd(struct ubus_context *ctx, struct ubus_request_data *req, int fd)
int ubus_connect_ctx(struct ubus_context *ctx, const char *path)
void ubus_abort_request(struct ubus_context *ctx, struct ubus_request *req)
int ubus_lookup_id(struct ubus_context *ctx, const char *path, uint32_t *id)
int ubus_remove_object(struct ubus_context *ctx, struct ubus_object *obj)
static int ubus_monitor_start(struct ubus_context *ctx)
static void ubus_add_uloop(struct ubus_context *ctx)
int ubus_add_object(struct ubus_context *ctx, struct ubus_object *obj)
const char * ubus_strerror(int error)
static int ubus_invoke_async(struct ubus_context *ctx, uint32_t obj, const char *method, struct blob_attr *msg, struct ubus_request *req)
void(* ubus_notify_data_handler_t)(struct ubus_notify_request *req, int type, struct blob_attr *msg)
void(* ubus_data_handler_t)(struct ubus_request *req, int type, struct blob_attr *msg)
static int ubus_unregister_subscriber(struct ubus_context *ctx, struct ubus_subscriber *obj)
int ubus_send_reply(struct ubus_context *ctx, struct ubus_request_data *req, struct blob_attr *msg)
int ubus_complete_request(struct ubus_context *ctx, struct ubus_request *req, int timeout)
static int ubus_unregister_event_handler(struct ubus_context *ctx, struct ubus_event_handler *ev)
int ubus_notify_async(struct ubus_context *ctx, struct ubus_object *obj, const char *type, struct blob_attr *msg, struct ubus_notify_request *req)
int ubus_unsubscribe(struct ubus_context *ctx, struct ubus_subscriber *obj, uint32_t id)
static void ubus_handle_event(struct ubus_context *ctx)
int ubus_reconnect(struct ubus_context *ctx, const char *path)
void ubus_complete_request_async(struct ubus_context *ctx, struct ubus_request *req)
void(* ubus_lookup_handler_t)(struct ubus_context *ctx, struct ubus_object_data *obj, void *priv)
int ubus_register_event_handler(struct ubus_context *ctx, struct ubus_event_handler *ev, const char *pattern)
int __ubus_monitor(struct ubus_context *ctx, const char *type)
static int ubus_monitor_stop(struct ubus_context *ctx)
static 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)
void(* ubus_event_handler_t)(struct ubus_context *ctx, struct ubus_event_handler *ev, const char *type, struct blob_attr *msg)
int(* ubus_handler_t)(struct ubus_context *ctx, struct ubus_object *obj, struct ubus_request_data *req, const char *method, struct blob_attr *msg)
void(* ubus_connect_handler_t)(struct ubus_context *ctx)
void(* ubus_notify_complete_handler_t)(struct ubus_notify_request *req, int idx, int ret)
struct uloop_timeout timer
ubus_connect_handler_t cb
struct uloop_timeout pending_timer
int msgbuf_reduction_counter
struct list_head requests
struct ubus_msghdr_buf msgbuf
void(* connection_lost)(struct ubus_context *ctx)
void(* monitor_cb)(struct ubus_context *ctx, uint32_t seq, struct blob_attr *data)
struct list_head auto_subscribers
struct ubus_event_handler auto_subscribe_event_handler
const struct blobmsg_policy * policy
ubus_notify_complete_handler_t complete_cb
ubus_notify_complete_handler_t status_cb
ubus_notify_data_handler_t data_cb
struct blob_attr * signature
const struct ubus_method * methods
struct ubus_object_type * type
const struct ubus_method * methods
ubus_state_handler_t subscribe_cb
ubus_data_handler_t raw_data_cb
ubus_complete_handler_t complete_cb
ubus_data_handler_t data_cb
struct ubus_context * ctx
ubus_remove_handler_t remove_cb
ubus_new_object_handler_t new_obj_cb