#include <sys/socket.h>
#include "ubusd.h"
Go to the source code of this file.
◆ USES_EXTERNAL_BUFFER
#define USES_EXTERNAL_BUFFER ~0U |
◆ ubus_msg_enqueue()
Definition at line 143 of file ubusd.c.
154 INIT_LIST_HEAD(&ubl->
list);
struct list_head tx_queue
struct ubus_msg_buf * msg
static struct ubus_msg_buf * ubus_msg_ref(struct ubus_msg_buf *ub)
#define UBUS_CLIENT_MAX_TXQ_LEN
◆ ubus_msg_free()
Definition at line 67 of file ubusd.c.
#define USES_EXTERNAL_BUFFER
◆ ubus_msg_list_free()
Definition at line 136 of file ubusd.c.
138 list_del_init(&ubl->
list);
void ubus_msg_free(struct ubus_msg_buf *ub)
◆ ubus_msg_new()
struct ubus_msg_buf* ubus_msg_new |
( |
void * |
data, |
|
|
int |
len, |
|
|
bool |
shared |
|
) |
| |
Definition at line 39 of file ubusd.c.
42 int buflen =
sizeof(*ub);
47 ub = calloc(1, buflen);
58 ub->
data = (
void *) (ub + 1);
◆ ubus_msg_ref()
Definition at line 23 of file ubusd.c.
struct ubus_msg_buf * ubus_msg_new(void *data, int len, bool shared)
◆ ubus_msg_send()
Definition at line 162 of file ubusd.c.
175 if (written >= (ssize_t) (ub->
len +
sizeof(ub->
hdr)))
182 uloop_fd_add(&cl->
sock, ULOOP_READ | ULOOP_WRITE | ULOOP_EDGE_TRIGGER);
static void ubus_msg_enqueue(struct ubus_client *cl, struct ubus_msg_buf *ub)
ssize_t ubus_msg_writev(int fd, struct ubus_msg_buf *ub, size_t offset)
void ubusd_monitor_message(struct ubus_client *cl, struct ubus_msg_buf *ub, bool send)
◆ ubus_msg_writev()
ssize_t ubus_msg_writev |
( |
int |
fd, |
|
|
struct ubus_msg_buf * |
ub, |
|
|
size_t |
offset |
|
) |
| |
Definition at line 83 of file ubusd.c.
85 uint8_t fd_buf[CMSG_SPACE(
sizeof(
int))] = { 0 };
86 static struct iovec iov[2];
87 struct msghdr msghdr = { 0 };
94 msghdr.msg_iovlen = ARRAY_SIZE(iov);
95 msghdr.msg_control = fd_buf;
96 msghdr.msg_controllen =
sizeof(fd_buf);
98 cmsg = CMSG_FIRSTHDR(&msghdr);
99 cmsg->cmsg_type = SCM_RIGHTS;
100 cmsg->cmsg_level = SOL_SOCKET;
101 cmsg->cmsg_len = CMSG_LEN(
sizeof(
int));
103 pfd = (
int *) CMSG_DATA(cmsg);
104 msghdr.msg_controllen = cmsg->cmsg_len;
107 if (ub->
fd < 0 || offset) {
108 msghdr.msg_control = NULL;
109 msghdr.msg_controllen = 0;
112 if (offset <
sizeof(ub->
hdr)) {
115 hdr.seq = cpu_to_be16(ub->
hdr.
seq);
116 hdr.peer = cpu_to_be32(ub->
hdr.
peer);
118 iov[0].iov_base = ((
char *) &hdr) + offset;
119 iov[0].iov_len =
sizeof(hdr) - offset;
120 iov[1].iov_base = (
char *) ub->
data;
121 iov[1].iov_len = ub->
len;
123 offset -=
sizeof(ub->
hdr);
124 iov[0].iov_base = ((
char *) ub->
data) + offset;
125 iov[0].iov_len = ub->
len - offset;
126 msghdr.msg_iovlen = 1;
130 ret = sendmsg(fd, &msghdr, 0);
131 }
while (ret < 0 && errno == EINTR);