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"
24 #include "ubusd_acl.h"
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
;
38 struct ubus_msg_buf_list
{
39 struct list_head list
;
40 struct ubus_msg_buf
*msg
;
53 struct list_head objects
;
55 struct list_head tx_queue
;
58 struct ubus_msg_buf
*pending_msg
;
59 struct ubus_msg_buf
*retmsg
;
60 int pending_msg_offset
;
63 struct ubus_msghdr hdr
;
64 struct blob_attr data
;
69 struct list_head list
;
73 extern const char *ubusd_acl_dir
;
75 struct ubus_msg_buf
*ubus_msg_new(void *data
, int len
, bool shared
);
76 void ubus_msg_send(struct ubus_client
*cl
, struct ubus_msg_buf
*ub
);
77 ssize_t
ubus_msg_writev(int fd
, struct ubus_msg_buf
*ub
, size_t offset
);
78 void ubus_msg_free(struct ubus_msg_buf
*ub
);
79 void ubus_msg_list_free(struct ubus_msg_buf_list
*ubl
);
80 struct blob_attr
**ubus_parse_msg(struct blob_attr
*msg
, size_t len
);
82 struct ubus_client
*ubusd_proto_new_client(int fd
, uloop_fd_handler cb
);
83 void ubusd_proto_receive_message(struct ubus_client
*cl
, struct ubus_msg_buf
*ub
);
84 void ubusd_proto_free_client(struct ubus_client
*cl
);
85 void ubus_proto_send_msg_from_blob(struct ubus_client
*cl
, struct ubus_msg_buf
*ub
,
88 typedef struct ubus_msg_buf
*(*event_fill_cb
)(void *priv
, const char *id
);
89 void ubusd_event_init(void);
90 void ubusd_event_cleanup_object(struct ubus_object
*obj
);
91 void ubusd_send_obj_event(struct ubus_object
*obj
, bool add
);
92 int ubusd_send_event(struct ubus_client
*cl
, const char *id
,
93 event_fill_cb fill_cb
, void *cb_priv
);
95 void ubusd_acl_init(void);
97 void ubusd_monitor_init(void);
98 void ubusd_monitor_message(struct ubus_client
*cl
, struct ubus_msg_buf
*ub
, bool send
);
99 void ubusd_monitor_disconnect(struct ubus_client
*cl
);