Matias Freytes wrote: > 1) I've been using "Unix Network Programming" by R. Stevens > (1990). Is there any updated Linux Network Programming? I'd like > to have an updated ioctl tutorial/handbook. By the time a Linux book reaches the shelves, it's usually out of date. Particularly with regard to networking, which is probably the most intensively developed subsystem in the kernel. There is a list of ioctl() requests in the ioctl_list(2) manpage. The only documentation for most of these is the source code. > 2)I'm working on a network application and need to fill a menu > with the available network interfaces (up). How can I get this > info? I think this is quite related to my first question. To get a list of interfaces, use ioctl(SIOCGIFCONF), e.g. struct ifconf ifc; struct ifreq ifrs[100]; int sk; int i; sk = socket(PF_INET, SOCK_DGRAM, 0); ifc.ifc_len = sizeof(ifrs); ifc.ifc_req = ifrs; ioctl(sk, SIOCGIFCONF, &ifc); for (i = 0; i < ifc.ifc_len / sizeof(struct ifreq); i++) { struct ifreq *ifr = &ifrs[i]; struct sockaddr_in *addr = (struct sockaddr_in *) &ifr->ifr_addr; printf("%2d %-8s %-15s\n", i, ifr->ifr_name, inet_ntoa(addr->sin_addr)); } close(sk); [error handling removed for brevity.] To find out if a given interface is up, use ioctl(SIOCGIFFLAGS), e.g. const char *if_name = /* interface name, e.g. ifr->ifr_name */; int fd; struct ifreq ifr; fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP); strcpy(ifr.ifr_name, if_name); ioctl(fd, SIOCGIFFLAGS, &ifr); printf("%s is %s\n", if_name, (ifr.ifr_flags & IFF_UP) ? "up" : "down"); > 3) I also need to "capture" full 802.3 encapsulated IP frames > from my LAN and save them to a file. I' ve read about ether taps > and packet sockets. What should I use? This is for a group of > students who want to play a little bit with "frame decoding". I'd > like to get You can use "tcpdump -i eth0 -s 1518 -w <filename> ...". If you want to do it yourself, you can use libpcap (as used by tcpdump), or create a PF_PACKET socket (as used by libpcap); see the packet(7) manpage. -- Glynn Clements <glynn.clements@virgin.net> - : send the line "unsubscribe linux-net" in the body of a message to majordomo@vger.kernel.org