9 #include <sys/socket.h>
12 #include <linux/netlink.h>
13 #include <linux/rtnetlink.h>
15 #include <arpa/inet.h>
22 static int netlink_send(int s, struct cn_msg *msg)
27 char buf[CONNECTOR_MAX_MSG_SIZE];
30 size = NLMSG_SPACE(sizeof(struct cn_msg) + msg->len);
32 nlh = (struct nlmsghdr *)buf;
33 nlh->nlmsg_seq = seq++;
34 nlh->nlmsg_pid = getpid();
35 nlh->nlmsg_type = NLMSG_DONE;
36 nlh->nlmsg_len = NLMSG_LENGTH(size - sizeof(*nlh));
40 memcpy(m, msg, sizeof(*m) + msg->len);
42 err = send(s, nlh, size, 0);
44 ulog(LOG_ERR, "Failed to send: %s [%d].\n", strerror(errno), errno);
49 int req_exec(int s, struct cn_msg *msg)
51 struct uvesafb_task *tsk = (struct uvesafb_task*)(msg + 1);
52 u8 *buf = (u8*)tsk + sizeof(struct uvesafb_task);
54 if (tsk->flags & TF_EXIT)
57 if (v86_task(tsk, buf))
66 int main(int argc, char *argv[])
68 char buf[CONNECTOR_MAX_MSG_SIZE];
69 int len, i, err = 0, s;
70 struct nlmsghdr *reply;
71 struct sockaddr_nl l_local;
75 s = socket(PF_NETLINK, SOCK_DGRAM, NETLINK_CONNECTOR);
81 l_local.nl_family = AF_NETLINK;
82 l_local.nl_groups = 1 << (CN_IDX_V86D-1); /* bitmask of requested groups */
85 if (bind(s, (struct sockaddr *)&l_local, sizeof(struct sockaddr_nl)) == -1) {
99 openlog("v86d", 0, LOG_KERN);
104 memset(buf, 0, sizeof(buf));
110 switch (poll(&pfd, 1, -1)) {
115 if (errno != EINTR) {
122 memset(buf, 0, sizeof(buf));
123 len = recv(s, buf, sizeof(buf), 0);
130 reply = (struct nlmsghdr *)buf;
132 /* Ignore requests coming from outside the kernel. */
133 if (reply->nlmsg_pid != 0) {
137 switch (reply->nlmsg_type) {
139 ulog(LOG_ERR, "Error message received.\n");
143 data = (struct cn_msg *)NLMSG_DATA(reply);
144 if (req_exec(s, data))