1 #include <sys/socket.h>
4 #include <linux/netlink.h>
5 #include <linux/rtnetlink.h>
22 static int netlink_send(int s
, struct cn_msg
*msg
)
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("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
);
55 ulog("performing request\n");
57 ulog("request done\n");
64 int main(int argc
, char *argv
[])
69 struct nlmsghdr
*reply
;
70 struct sockaddr_nl l_local
;
75 i
= open("/dev/tty1", O_RDWR
);
80 s
= socket(PF_NETLINK
, SOCK_DGRAM
, NETLINK_CONNECTOR
);
86 l_local
.nl_family
= AF_NETLINK
;
87 l_local
.nl_groups
= 1 << (CN_IDX_UVESAFB
-1); /* bitmask of requested groups */
90 if (bind(s
, (struct sockaddr
*)&l_local
, sizeof(struct sockaddr_nl
)) == -1) {
107 ulog("it's alive %d!\n", s
);
108 memset(buf
, 0, sizeof(buf
));
110 /* data = (struct cn_msg *)buf;
111 data->id.idx = CN_IDX_UVESAFB;
112 data->id.val = CN_VAL_UVESAFB;
116 netlink_send(s, data);
123 switch (poll(&pfd
, 1, -1)) {
128 if (errno
!= EINTR
) {
135 memset(buf
, 0, sizeof(buf
));
136 len
= recv(s
, buf
, sizeof(buf
), 0);
143 reply
= (struct nlmsghdr
*)buf
;
145 switch (reply
->nlmsg_type
) {
147 ulog("Error message received.\n");
151 data
= (struct cn_msg
*)NLMSG_DATA(reply
);