Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This snippet can help you, it's a more complicated rather I supposed:</p> <pre><code>if (getifaddrs(&amp;ifaddrs) &lt; 0) { my_loge(CRIT, "address detection failed"); return(0); } // zero count = 0; // unset all but CAP_HOST and CAP_ROUTER sysinfo-&gt;cap &amp;= (CAP_HOST|CAP_ROUTER); sysinfo-&gt;cap_active &amp;= (CAP_HOST|CAP_ROUTER); // reset counter sysinfo-&gt;physif_count = 0; // mark all interfaces TAILQ_FOREACH(netif, netifs, entries) { netif-&gt;type = NETIF_OLD; } for (ifaddr = ifaddrs; ifaddr != NULL; ifaddr = ifaddr-&gt;ifa_next) { // skip interfaces without addresses if (ifaddr-&gt;ifa_addr == NULL) { my_log(INFO, "skipping interface %s", ifaddr-&gt;ifa_name); continue; } // only handle datalink addresses if (ifaddr-&gt;ifa_addr-&gt;sa_family != NETIF_AF) continue; // prepare ifr struct memset(&amp;ifr, 0, sizeof(ifr)); strlcpy(ifr.ifr_name, ifaddr-&gt;ifa_name, sizeof(ifr.ifr_name)); // skip non-ethernet interfaces memcpy(&amp;saddrll, ifaddr-&gt;ifa_addr, sizeof(saddrll)); if (saddrll.sll_hatype != ARPHRD_ETHER) { my_log(INFO, "skipping interface %s", ifaddr-&gt;ifa_name); continue; } index = saddrll.sll_ifindex; memcpy(&amp;saddrdl, ifaddr-&gt;ifa_addr, sizeof(saddrdl)); if ((saddrdl.sdl_type != IFT_BRIDGE) &amp;&amp; (saddrdl.sdl_type != IFT_ETHER)) { if (saddrdl.sdl_type != IFT_ETHER) { my_log(INFO, "skipping interface %s", ifaddr-&gt;ifa_name); continue; } index = saddrdl.sdl_index; // check for interfaces that are down enabled = 0; if (ioctl(sockfd, SIOCGIFFLAGS, (caddr_t)&amp;ifr) &gt;= 0) enabled = (ifr.ifr_flags &amp; IFF_UP); // detect interface type type = netif_type(sockfd, index, ifaddr, &amp;ifr); if (type == NETIF_REGULAR) { my_log(INFO, "found ethernet interface %s", ifaddr-&gt;ifa_name); sysinfo-&gt;physif_count++; } else if (type == NETIF_WIRELESS) { my_log(INFO, "found wireless interface %s", ifaddr-&gt;ifa_name); sysinfo-&gt;cap |= CAP_WLAN; sysinfo-&gt;cap_active |= (enabled == 1) ? CAP_WLAN : 0; } else if (type == NETIF_TAP) { my_log(INFO, "found tun/tap interface %s", ifaddr-&gt;ifa_name); } else if (type == NETIF_BONDING) { my_log(INFO, "found bond interface %s", ifaddr-&gt;ifa_name); } else if (type == NETIF_BRIDGE) { my_log(INFO, "found bridge interface %s", ifaddr-&gt;ifa_name); sysinfo-&gt;cap |= CAP_BRIDGE; sysinfo-&gt;cap_active |= (enabled == 1) ? CAP_BRIDGE : 0; } else if (type == NETIF_VLAN) { my_log(INFO, "found vlan interface %s", ifaddr-&gt;ifa_name); } else if (type == NETIF_INVALID) { my_log(INFO, "skipping interface %s", ifaddr-&gt;ifa_name); continue; } </code></pre> <p>Complete file is located here: <a href="https://www.google.it/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=5&amp;ved=0CE8QFjAE&amp;url=https://ladvd.googlecode.com/hg-history/default/src/netif.c&amp;ei=EuePUL-fOcqP4gSov4HQBg&amp;usg=AFQjCNFYAVRMLs_rrQF2DfYD5BEWFmTlUg&amp;sig2=lTlohgdq9rvY6m6Wy-ixHA" rel="nofollow">here</a></p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload