Hallo everybody, I have a serious problem. Could someone help me how to use netlink socket? I write a small program (attached) that might read data from the netlink socket. But it still for me impossible to read anything in that socket. I don't know what i'm doing wrong. If you a sample program to do that please send it to me, i would be very greatful. PS: I've also used libipq but it wasn't help. My code: #include <stdio.h> #include <sys/socket.h> #include <sys/types.h> #include <string.h> #include <asm/types.h> #include <linux/netlink.h> #include <linux/socket.h> #include <linux/uio.h> int main(int argc, char** argv) { int sockfd, addrlen, len; unsigned char *buffer; struct cmsghdr cmsg; struct iovec iov; struct sockaddr_nl peer; struct sockaddr_nl nladdr={ nl_family:AF_NETLINK, nl_pid : getpid(), nl_groups: 0 }; struct msghdr msg = { (void *)&nladdr, sizeof(nladdr), &iov, 1, NULL, 1024, 0}; memset(&peer, 0, sizeof(struct sockaddr_nl)); peer.nl_family = AF_NETLINK; peer.nl_pid = 0; peer.nl_groups = 0; if ((sockfd = socket(PF_NETLINK, SOCK_RAW,NETLINK_FIREWALL)) < 0) { perror("netlink socket"); return -1; } if (bind(sockfd, (struct sockaddr *)&nladdr, sizeof(nladdr))<0){ perror("bind"); return -1; } len = sizeof(nladdr); if (getsockname(sockfd, (struct sockaddr *)&nladdr,(socklen_t *)&len)<0){ perror("getsockname"); return -1; } addrlen = sizeof(peer); if (recvfrom(sockfd,buffer,1024,0,(struct sockaddr *)&peer, (socklen_t *)&addrlen) < 0) { perror("recvfrom"); return -1; } /* if (recvmsg(sockfd, &msg, 0) < 0) { perror("recvmsg"); return -1; } */ close(sockfd); return 0; } [root@heghta sebro]# lsmod Module Size Used by iptable_nat 18112 0 (unused) ip_conntrack 20288 1 [iptable_nat] iptable_mangle 1888 0 (unused) iptable_filter 1856 0 (unused) ip_queue 4672 0 (unused) ip_tables 12800 5 [iptable_nat iptable_mangle iptable_filter] 3c509 6992 1 (autoclean) [root@heghta sebro]# iptables -L -t mangle Chain PREROUTING (policy ACCEPT) target prot opt source destination QUEUE icmp -- anywhere anywhere Thank you for the help. __________________________________________________________________ Do You Yahoo!? Gesendet von Yahoo! Mail - http://mail.yahoo.de - : send the line "unsubscribe linux-net" in the body of a message to majordomo@vger.kernel.org