2 * Copyright (C) 2011 Felix Fietkau <nbd@openwrt.org>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License version 2.1
6 * as published by the Free Software Foundation
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
19 extern struct avl_tree obj_types
;
20 extern struct avl_tree objects
;
21 extern struct avl_tree path
;
26 struct ubus_object_type
{
29 struct list_head methods
;
33 struct list_head list
;
35 struct blob_attr data
[];
38 struct ubus_subscription
{
39 struct list_head list
, target_list
;
40 struct ubus_object
*subscriber
, *target
;
45 struct list_head list
;
47 struct list_head events
;
49 struct list_head subscribers
, target_list
;
51 struct ubus_object_type
*type
;
54 struct ubus_client
*client
;
55 int (*recv_msg
)(struct ubus_client
*client
, const char *method
, struct blob_attr
*msg
);
58 unsigned int invoke_seq
;
61 struct ubus_object
*ubusd_create_object(struct ubus_client
*cl
, struct blob_attr
**attr
);
62 struct ubus_object
*ubusd_create_object_internal(struct ubus_object_type
*type
, uint32_t id
);
63 void ubusd_free_object(struct ubus_object
*obj
);
65 static inline struct ubus_object
*ubusd_find_object(uint32_t objid
)
67 struct ubus_object
*obj
;
70 id
= ubus_find_id(&objects
, objid
);
74 obj
= container_of(id
, struct ubus_object
, id
);
78 void ubus_subscribe(struct ubus_object
*obj
, struct ubus_object
*target
);
79 void ubus_unsubscribe(struct ubus_subscription
*s
);
80 void ubus_notify_unsubscribe(struct ubus_subscription
*s
);
81 void ubus_notify_subscription(struct ubus_object
*obj
);