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.
17 #include <libubox/list.h>
18 #include <libubox/uloop.h>
19 #include <libubox/blobmsg.h>
20 #include "ubus_common.h"
22 #include "ubusd_obj.h"
25 #define UBUSD_CLIENT_BACKLOG 32
26 #define UBUS_OBJ_HASH_BITS 4
28 extern struct blob_buf b
;
31 uint32_t refcount
; /* ~0: uses external data buffer */
32 struct ubus_msghdr hdr
;
33 struct blob_attr
*data
;
41 struct list_head objects
;
43 struct ubus_msg_buf
*tx_queue
[UBUSD_CLIENT_BACKLOG
];
44 unsigned int txq_cur
, txq_tail
, txq_ofs
;
46 struct ubus_msg_buf
*pending_msg
;
47 int pending_msg_offset
;
49 struct ubus_msghdr hdr
;
50 struct blob_attr data
;
55 struct list_head list
;
59 struct ubus_msg_buf
*ubus_msg_new(void *data
, int len
, bool shared
);
60 void ubus_msg_send(struct ubus_client
*cl
, struct ubus_msg_buf
*ub
, bool free
);
61 void ubus_msg_free(struct ubus_msg_buf
*ub
);
63 struct ubus_client
*ubusd_proto_new_client(int fd
, uloop_fd_handler cb
);
64 void ubusd_proto_receive_message(struct ubus_client
*cl
, struct ubus_msg_buf
*ub
);
65 void ubusd_proto_free_client(struct ubus_client
*cl
);
67 void ubusd_event_init(void);
68 void ubusd_event_cleanup_object(struct ubus_object
*obj
);
69 void ubusd_send_obj_event(struct ubus_object
*obj
, bool add
);