#include #include #include #include #include #include main() { int s,i; struct rt_msghdr *msghdr; char buf[2048]; char buf2[2048]; s = socket(PF_ROUTE, SOCK_RAW, AF_UNSPEC); if(s < 0 ) perror("socket"); bzero(&buf, 2048); bzero(&buf2, 2048); msghdr = (struct rt_msghdr*)buf; msghdr->rtm_msglen = 2048; msghdr->rtm_pid = (int)getpid(); msghdr->rtm_version = 5; msghdr->rtm_type = LABEL_GET; i = write(s, (caddr_t)msghdr, (size_t)msghdr->rtm_msglen); if(i < 0) perror("Write error !!"); i = read(s, (caddr_t)msghdr, (size_t)(2048)); if(i < 0) perror("read error !!"); close(s); strcpy(buf2,((char *)msghdr+ sizeof(struct rt_msghdr))); printf("%s \n",(buf2)); return(0); }