title: MAC address with getifaddrs
body: <p>Is there a way to get interface's MAC address via <code>getifaddrs()</code> ?</p>
  
  <p>I already have this, to get IP addresses, but I have kinda missed <code>MAC</code>. Ive tried to look for the information in <code>getifaddrs()</code>, but there is nothing about <code>MAC</code> addresses</p>
  
  <pre><code>struct ifaddrs *iflist, *iface;
  
    if (getifaddrs(&amp;iflist) &lt; 0) 
    {
        perror("getifaddrs");
    }
  
    char addrp[INET6_ADDRSTRLEN];
    char macp[INET6_ADDRSTRLEN];
    int i=0;
  
    for (iface = iflist; iface; iface = iface-&gt;ifa_next) 
    {
      int af = iface-&gt;ifa_addr-&gt;sa_family;
      const void *addr;
      const void *mac;
  
        switch (af) 
        {
          case AF_INET:
            addr = &amp;((struct sockaddr_in *)iface-&gt;ifa_addr)-&gt;sin_addr;
            break;
        //get mac address somehow?
          default:
            addr = NULL;
        }
  
        if (addr) 
        {
          if (inet_ntop(af, addr, addrp, sizeof addrp) == NULL)
          {
             perror("inet_ntop");
             continue;
          }
      if (inet_ntop(af, mac, macp, sizeof macp) == NULL) // this is already for MAC add
          {
             perror("inet_ntop");
             continue;
          }
      if (strcmp(addrp, "127.0.0.1") != 0) 
      {
         strcat(tableO[i].IPaddr, addrp);
         strcat(tableO[i].MACaddr, macp);
         i++;
      }
        }
  </code></pre>
  
  <p>Thanks</p>