- /* Init the given net_descr_t struct */
- p_net_descr->i_if_number = 0;
- p_net_descr->a_if = NULL;
-
- /* Iterate through the entries of the a_ifr_ifconf table */
- p_ifr_current_if = ifc_netconf.ifc_req;
- for( i_remaining = ifc_netconf.ifc_len / sizeof (struct ifreq);
- i_remaining-- > 0; p_ifr_current_if++ )
- {
- intf_DbgMsg("Found interface %s\n", p_ifr_current_if->ifr_name);
-
- /* Don't use an interface devoted to an address family other than IP */
- if(p_ifr_current_if->ifr_addr.sa_family != AF_INET)
- continue;
-
- /* Read the status of this interface */
- if( ioctl(i_sockfd, SIOCGIFFLAGS, (byte_t *)p_ifr_current_if) < 0 )
- {
- intf_ErrMsg("Cannot access interface %s: %s\n",
- p_ifr_current_if->ifr_name, strerror(errno));
- i_rc = -1;
- break;
- }
- else
- {
- /* Skip this interface if it is not up or if this is a loopback one */
- if( !p_ifr_current_if->ifr_flags & IFF_UP ||
- p_ifr_current_if->ifr_flags & IFF_LOOPBACK )
- continue;
-
- /* Add an entry to the net_descr struct to store the description of
- that interface */
- p_net_descr->i_if_number++;
- p_net_descr->a_if = realloc(p_net_descr->a_if,
- p_net_descr->i_if_number*sizeof(if_descr_t));
- /* Read the info ??? */
- i_rc = ReadIfConf(i_sockfd, &p_net_descr->a_if[p_net_descr->i_if_number-1],
- p_ifr_current_if->ifr_name);
- }
- }