Get index of network interface
问题 I'm writing simple sniffer for OS X on C So, I have a problem, I can't get index of network interface. I use this code: int sockfd=socket(PF_INET, SOCK_DGRAM, 0); if(sockfd<0) { printf("create socket"); fprintf(stderr, "%s\n",strerror(errno)); exit(EXIT_FAILURE); } sprintf( ifreq.ifr_name, "%s", "en0"); if(ioctl(sockfd, SIOCGIFINDEX, &ifreq)<0) { fprintf(stderr, "%s\n",strerror(errno)); exit(EXIT_FAILURE); } Problem that identifier 'SIOCGIFINDEX' is undeclared. Index of network interface need