/* Each interface is indexed by the 'ifindex'. As opposed to interface names, 'ifindex' are never reused (even if you reactivate the same hardware), so the data we cache will never apply to the wrong interface. Because of that, we are pretty lazy when it come to purging the cache... Get name of interface based on interface index...  */
static int index2name(int skfd, int ifindex, char *name)
/* Each interface is indexed by the 'ifindex'. As opposed to interface names, 'ifindex' are never reused (even if you reactivate the same hardware), so the data we cache will never apply to the wrong interface. Because of that, we are pretty lazy when it come to purging the cache... Get name of interface based on interface index...  */
static int index2name(int skfd, int ifindex, char *name)
{
  struct ifreq	irq;
  int		ret = 0;
  memset(name, 0, IFNAMSIZ + 1);
  irq.ifr_ifindex = ifindex;
  if(ioctl(skfd, SIOCGIFNAME, &irq) < 0)
    ret = -1;
  else
    strncpy(name, irq.ifr_name, IFNAMSIZ);
  return(ret);
}