/* test netlink using RAW socket stuff for web100 */ #include #include #include #include main() { int sd,lth; double buff[1024]; struct sockaddr_nl nl; struct Msg { int type; int cid; } *msg; sd = socket(PF_NETLINK,SOCK_RAW,NETLINK_WEB100); if (sd < 0) { perror("socket"); exit(1); } bzero(&nl,sizeof(nl)); nl.nl_family = AF_NETLINK; nl.nl_groups = ~0; /* all groups */ if (bind(sd,(struct sockaddr *) &nl,sizeof(nl)) < 0) { perror("bind"); exit(1); } msg = (struct Msg *)buff; while (1) { lth = read(sd,buff,sizeof(buff)); if (lth < 0) { perror("read"); exit(1); } printf("lth %d type %d cid %d\n",lth,msg->type,msg->cid); } }