close (fd);
__close (fd);
if_nameindex (void){#ifndef SIOGIFINDEX  __set_errno (ENOSYS);  return NULL;#else  int fd = opensock ();  struct ifconf ifc;  unsigned int nifs, i;  int rq_len;  struct if_nameindex *idx = NULL;  static int new_siocgifconf = 1;#define RQ_IFS	4  if (fd < 0)    return NULL;  ifc.ifc_buf = NULL;  /* We may be able to get the needed buffer size directly, rather than     guessing.  */  if (new_siocgifconf)    {      ifc.ifc_buf = NULL;      ifc.ifc_len = 0;      if (ioctl (fd, SIOCGIFCONF, &ifc) < 0 || ifc.ifc_len == 0)	{	  new_siocgifconf = 0;	  rq_len = RQ_IFS * sizeof (struct ifreq);	}      else	rq_len = ifc.ifc_len;    }  else    rq_len = RQ_IFS * sizeof (struct ifreq);  /* Read all the interfaces out of the kernel.  */  do    {      ifc.ifc_buf = alloca (ifc.ifc_len = rq_len);      if ((ifc.ifc_buf == NULL) || (ioctl (fd, SIOCGIFCONF, &ifc) < 0))	{	  close (fd);	  return NULL;	}      rq_len *= 2;    }  while (ifc.ifc_len == rq_len && new_siocgifconf == 0);  nifs = ifc.ifc_len / sizeof (struct ifreq);  idx = malloc ((nifs + 1) * sizeof (struct if_nameindex));  if (idx == NULL)    {      close (fd);      return NULL;    }  for (i = 0; i < nifs; ++i)    {      struct ifreq *ifr = &ifc.ifc_req[i];      idx[i].if_name = __strdup (ifr->ifr_name);      if (idx[i].if_name == NULL	  || ioctl (fd, SIOGIFINDEX, ifr) < 0)	{	  int saved_errno = errno;	  unsigned int j;	  for (j =  0; j < i; ++j)	    free (idx[j].if_name);	  free (idx);	  close (fd);	  if (saved_errno == EINVAL)	    __set_errno (ENOSYS);	  return NULL;	}      idx[i].if_index = ifr->ifr_ifindex;    }  idx[i].if_index = 0;  idx[i].if_name = NULL;  close (fd);  return idx;#endif}