make ubus_msg_ref static
[project/ubus.git] / ubusd.h
1 #ifndef __UBUSD_H
2 #define __UBUSD_H
3
4 #include <libubox/list.h>
5 #include <libubox/uloop.h>
6 #include <libubox/blobmsg.h>
7 #include "ubus_common.h"
8 #include "ubusd_id.h"
9 #include "ubusd_obj.h"
10 #include "ubusmsg.h"
11
12 #define UBUSD_CLIENT_BACKLOG 32
13 #define UBUS_OBJ_HASH_BITS 4
14
15 extern struct blob_buf b;
16 extern struct avl_tree clients;
17
18 struct ubus_msg_buf {
19 uint32_t refcount; /* ~0: uses external data buffer */
20 struct ubus_msghdr hdr;
21 struct blob_attr *data;
22 int len;
23 };
24
25 struct ubus_client {
26 struct ubus_id id;
27 struct uloop_fd sock;
28
29 struct list_head objects;
30
31 struct ubus_msg_buf *tx_queue[UBUSD_CLIENT_BACKLOG];
32 unsigned int txq_cur, txq_tail, txq_ofs;
33
34 struct ubus_msg_buf *pending_msg;
35 int pending_msg_offset;
36 struct {
37 struct ubus_msghdr hdr;
38 struct blob_attr data;
39 } hdrbuf;
40 };
41
42 struct ubus_path {
43 struct list_head list;
44 const char name[];
45 };
46
47 struct ubus_msg_buf *ubus_msg_new(void *data, int len, bool shared);
48 void ubus_msg_send(struct ubus_client *cl, struct ubus_msg_buf *ub, bool free);
49 void ubus_msg_free(struct ubus_msg_buf *ub);
50
51 void ubusd_receive_message(struct ubus_client *cl, struct ubus_msg_buf *ub);
52 bool ubusd_send_hello(struct ubus_client *cl);
53
54 void ubusd_event_init(void);
55 void ubusd_event_cleanup_object(struct ubus_object *obj);
56
57
58 #endif