On Sun, 2009-10-04 at 16:40 -0700, Guy Harris wrote: > > 3. The identification of the device index is quite a hack. I'm > > "parsing" > > the device name for an int before $. Any Ideas how to improve? > > That's what pcap-usb-linux.c does, so I'm not sure any improvement is > needed, other than having having the format be "can%d" rather than "%s > %d" - the string preceding the number will be "can".
Think instead of that stopgap solution, the usage of the ioctl SIOCGIFINDEX might be a better option. Thus I've added to static int can_activate(pcap_t* handle): /* get interface index */ memset(&ifr, 0, sizeof(ifr)); strncpy(ifr.ifr_name, handle->opt.source, sizeof(ifr.ifr_name)); if ((handle->fd, SIOCGIFINDEX, &ifr) < 0) { snprintf(handle->errbuf, PCAP_ERRBUF_SIZE, "Unable to get interface index: %s", pcap_strerror(errno)); pcap_cleanup_live_common(handle); return PCAP_ERROR; } handle->md.ifindex = ifr.ifr_ifindex; Felix - This is the tcpdump-workers list. Visit https://cod.sandelman.ca/ to unsubscribe.