make ubus_msg_ref static
[project/ubus.git] / ubusd_obj.h
1 #ifndef __UBUSD_OBJ_H
2 #define __UBUSD_OBJ_H
3
4 #include "ubusd_id.h"
5
6 extern struct avl_tree obj_types;
7 extern struct avl_tree objects;
8 extern struct avl_tree path;
9
10 struct ubus_client;
11 struct ubus_msg_buf;
12
13 struct ubus_object_type {
14         struct ubus_id id;
15         int refcount;
16         struct list_head methods;
17 };
18
19 struct ubus_method {
20         struct list_head list;
21         const char *name;
22         struct blob_attr data[];
23 };
24
25 struct ubus_object {
26         struct ubus_id id;
27         struct list_head list;
28
29         struct list_head events;
30
31         struct ubus_object_type *type;
32         struct avl_node path;
33
34         struct ubus_client *client;
35         int (*recv_msg)(struct ubus_client *client, const char *method, struct blob_attr *msg);
36 };
37
38 struct ubus_object *ubusd_create_object(struct ubus_client *cl, struct blob_attr **attr);
39 struct ubus_object *ubusd_create_object_internal(struct ubus_object_type *type, uint32_t id);
40 void ubusd_free_object(struct ubus_object *obj);
41
42 static inline struct ubus_object *ubusd_find_object(uint32_t objid)
43 {
44         struct ubus_object *obj;
45         struct ubus_id *id;
46
47         id = ubus_find_id(&objects, objid);
48         if (!id)
49                 return NULL;
50
51         obj = container_of(id, struct ubus_object, id);
52         return obj;
53 }
54
55 #endif