4 #include <sys/socket.h>
7 #include <linux/netlink.h>
8 #include <linux/rtnetlink.h>
10 #include <arpa/inet.h>
20 #include <linux/connector.h>
29 #include "kernel/uvesafb.h"
31 //#define ulog(args...) do {} while (0)
32 #define ulog(args...) fprintf(stdout, ##args)
37 static int netlink_send(int s
, struct cn_msg
*msg
)
45 size
= NLMSG_SPACE(sizeof(struct cn_msg
) + msg
->len
);
47 nlh
= (struct nlmsghdr
*)buf
;
48 nlh
->nlmsg_seq
= seq
++;
49 nlh
->nlmsg_pid
= getpid();
50 nlh
->nlmsg_type
= NLMSG_DONE
;
51 nlh
->nlmsg_len
= NLMSG_LENGTH(size
- sizeof(*nlh
));
55 memcpy(m
, msg
, sizeof(*m
) + msg
->len
);
57 err
= send(s
, nlh
, size
, 0);
59 ulog("Failed to send: %s [%d].\n", strerror(errno
), errno
);
64 int req_exec(int s
, struct cn_msg
*msg
)
66 struct uvesafb_task
*tsk
= (struct uvesafb_task
*)(msg
+ 1);
69 // for (i = 0; i < msg->len + sizeof(struct cn_msg); i++) {
70 // ulog("%x ", blah[i]);
73 ulog("got %d | %d\n", tsk
->flags
, msg
->len
);
75 if (tsk
->flags
& TF_VBEIB
) {
83 int main(int argc
, char *argv
[])
88 struct nlmsghdr
*reply
;
89 struct sockaddr_nl l_local
;
94 i
= open("/dev/tty1", O_RDWR
);
99 s
= socket(PF_NETLINK
, SOCK_DGRAM
, NETLINK_CONNECTOR
);
105 l_local
.nl_family
= AF_NETLINK
;
106 l_local
.nl_groups
= 1 << (CN_IDX_UVESAFB
-1); /* bitmask of requested groups */
109 if (bind(s
, (struct sockaddr
*)&l_local
, sizeof(struct sockaddr_nl
)) == -1) {
123 ulog("it's alive %d!\n", s
);
125 memset(buf
, 0, sizeof(buf
));
127 /* data = (struct cn_msg *)buf;
128 data->id.idx = CN_IDX_UVESAFB;
129 data->id.val = CN_VAL_UVESAFB;
133 netlink_send(s, data);
140 switch (poll(&pfd
, 1, -1)) {
145 if (errno
!= EINTR
) {
152 memset(buf
, 0, sizeof(buf
));
153 len
= recv(s
, buf
, sizeof(buf
), 0);
160 reply
= (struct nlmsghdr
*)buf
;
162 switch (reply
->nlmsg_type
) {
164 ulog("Error message received.\n");
168 data
= (struct cn_msg
*)NLMSG_DATA(reply
);