2 * Copyright (C) 2011-2014 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;
42 struct list_head objects;
44 struct ubus_msg_buf *tx_queue[UBUSD_CLIENT_BACKLOG];
45 unsigned int txq_cur, txq_tail, txq_ofs;
47 struct ubus_msg_buf *pending_msg;
48 int pending_msg_offset;
51 struct ubus_msghdr hdr;
52 struct blob_attr data;
57 struct list_head list;
61 struct ubus_msg_buf *ubus_msg_new(void *data, int len, bool shared);
62 void ubus_msg_send(struct ubus_client *cl, struct ubus_msg_buf *ub, bool free);
63 void ubus_msg_free(struct ubus_msg_buf *ub);
65 struct ubus_client *ubusd_proto_new_client(int fd, uloop_fd_handler cb);
66 void ubusd_proto_receive_message(struct ubus_client *cl, struct ubus_msg_buf *ub);
67 void ubusd_proto_free_client(struct ubus_client *cl);
69 void ubusd_event_init(void);
70 void ubusd_event_cleanup_object(struct ubus_object *obj);
71 void ubusd_send_obj_event(struct ubus_object *obj, bool add);