14 #include <arpa/inet.h>
23 struct list_head
list;
52 [
EVREG_PATTERN] = { .name =
"pattern", .type = BLOBMSG_TYPE_STRING },
53 [
EVREG_OBJECT] = { .name =
"object", .type = BLOBMSG_TYPE_INT32 },
86 len = strlen(pattern);
87 if (pattern[len - 1] ==
'*') {
96 ev = calloc(1,
sizeof(*ev) + len + 1);
103 name = (
char *) (ev + 1);
104 strcpy(
name, pattern);
128 *ub = fill_cb(cb_priv,
id);
133 objid_ptr = blob_data(blob_data((*ub)->data));
134 *objid_ptr = htonl(obj->
id.id);
158 const char *key = ev->
avl.key;
163 if (cur_match_len < match_len)
166 match_len = cur_match_len;
172 if (match_len != (
int) strlen(key))
191 static struct blobmsg_policy
ev_policy[] = {
192 [
EVMSG_ID] = { .name =
"id", .type = BLOBMSG_TYPE_STRING },
193 [
EVMSG_DATA] = { .name =
"data", .type = BLOBMSG_TYPE_TABLE },
199 struct blob_attr *msg = priv;
201 blob_buf_init(&
b, 0);
204 blob_put(&
b,
UBUS_ATTR_DATA, blobmsg_data(msg), blobmsg_data_len(msg));
211 struct blob_attr *data;
225 if (!strncmp(
id,
"ubus.", 5))
233 if (!strcmp(method,
"register"))
236 if (!strcmp(method,
"send"))
248 blob_buf_init(&
b, 0);
252 blobmsg_add_u32(&
b,
"id", obj->
id.id);
253 blobmsg_add_string(&
b,
"path", obj->
path.key);
254 blob_nest_end(&
b, s);
261 const char *
id = add ?
"ubus.object.add" :
"ubus.object.remove";
struct ubus_client * client
int(* recv_msg)(struct ubus_client *client, struct ubus_msg_buf *ub, const char *method, struct blob_attr *msg)
static bool ubus_strmatch_len(const char *s1, const char *s2, int *len)
void ubus_msg_free(struct ubus_msg_buf *ub)
struct ubus_msg_buf * ubus_msg_new(void *data, int len, bool shared)
void ubus_msg_send(struct ubus_client *cl, struct ubus_msg_buf *ub)
struct ubus_msg_buf *(* event_fill_cb)(void *priv, const char *id)
int ubusd_acl_check(struct ubus_client *cl, const char *obj, const char *method, enum ubusd_acl_type type)
static void ubusd_delete_event_source(struct event_source *evs)
void ubusd_event_init(void)
static struct ubus_msg_buf * ubusd_create_event_from_msg(void *priv, const char *id)
static struct ubus_object * event_obj
void ubusd_send_obj_event(struct ubus_object *obj, bool add)
static int ubusd_forward_event(struct ubus_client *cl, struct blob_attr *msg)
static int ubusd_event_recv(struct ubus_client *cl, struct ubus_msg_buf *ub, const char *method, struct blob_attr *msg)
int ubusd_send_event(struct ubus_client *cl, const char *id, event_fill_cb fill_cb, void *cb_priv)
static struct ubus_msg_buf * ubusd_create_object_event_msg(void *priv, const char *id)
static int ubusd_alloc_event_pattern(struct ubus_client *cl, struct blob_attr *msg)
static void ubusd_send_event_msg(struct ubus_msg_buf **ub, struct ubus_client *cl, struct ubus_object *obj, const char *id, event_fill_cb fill_cb, void *cb_priv)
void ubusd_event_cleanup_object(struct ubus_object *obj)
static struct blobmsg_policy ev_policy[]
static struct blobmsg_policy evr_policy[]
static struct avl_tree patterns
void ubus_init_string_tree(struct avl_tree *tree, bool dup)
struct ubus_object * ubusd_create_object_internal(struct ubus_object_type *type, uint32_t id)
static struct ubus_object * ubusd_find_object(uint32_t objid)
#define UBUS_SYSTEM_OBJECT_EVENT
@ UBUS_STATUS_INVALID_ARGUMENT
@ UBUS_STATUS_INVALID_COMMAND
@ UBUS_STATUS_PERMISSION_DENIED
#define UBUS_SYSTEM_OBJECT_MAX