/* Steal interface name from another interface. This enable interface name swapping. This will work : 1) with kernel 2.6.X 2) if other interface is down Because of (2), it won't work with hotplug, but we don't need it with hotplug, only with static ifaces...  */
static int if_takeover_name(int skfd, const char *victimname)
/* Steal interface name from another interface. This enable interface name swapping. This will work : 1) with kernel 2.6.X 2) if other interface is down Because of (2), it won't work with hotplug, but we don't need it with hotplug, only with static ifaces...  */
static int if_takeover_name(int skfd, const char *victimname)
{
  char		autoname[IFNAMSIZ+1];
  int		len;
  struct ifreq	ifr;
  int		ret;
  len = strlen(victimname);
  memcpy(autoname, victimname, len + 1);
  if(len > (IFNAMSIZ - 2))
    len = IFNAMSIZ - 2;
  len--;
  while(isdigit(autoname[len]))
    len--;
  strcpy(autoname + len + 1, "%d");
  if(verbose)
    fprintf(stderr, "Takeover : moving interface `%s' to `%s'.\n",
	    victimname, autoname);
  bzero(&ifr, sizeof(struct ifreq));
  strncpy(ifr.ifr_name, victimname, IFNAMSIZ); 
  strncpy(ifr.ifr_newname, autoname, IFNAMSIZ);
  ret = ioctl(skfd, SIOCSIFNAME, &ifr);
  if(!ret)
    num_takeover++;
  return(ret);
}