I believe I have found the answer after a lot of searching. I finally found the source to Darwin's netstat, and it led me to this function. Type:
man getifmaddrs
Looks like it's the one. Also looks like it's the one for other BSDs.
Here is some sample code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <net/if_dl.h>
#include <ifaddrs.h>
int main(int argc,char **argv)
{
struct ifmaddrs *ifmap = (struct ifmaddrs *)0;
struct ifmaddrs *p;
char name[32];
unsigned char mac[6];
if (!getifmaddrs(&ifmap)) {
p = ifmap;
while (p) {
if (p->ifma_addr->sa_family == AF_LINK) {
struct sockaddr_dl *in = (struct sockaddr_dl *)p->ifma_name;
struct sockaddr_dl *la = (struct sockaddr_dl *)p->ifma_addr;
if (la->sdl_alen == 6) {
memcpy(name,in->sdl_data,in->sdl_nlen);
name[in->sdl_nlen] = 0;
memcpy(mac,la->sdl_data + la->sdl_nlen,6);
printf("%s %.2x:%.2x:%.2x:%.2x:%.2x:%.2x\n",name,mac[0],mac[1],mac[2],mac[3],mac[4],mac[5]);
}
}
p = p->ifma_next;
}
freeifmaddrs(ifmap);
}
}