|
Lines 42-47
Link Here
|
| 42 |
#include <stdlib.h> |
42 |
#include <stdlib.h> |
| 43 |
#include <string.h> |
43 |
#include <string.h> |
| 44 |
#include <ifaddrs.h> |
44 |
#include <ifaddrs.h> |
|
|
45 |
#include <unistd.h> |
| 45 |
|
46 |
|
| 46 |
#include <net/if_dl.h> |
47 |
#include <net/if_dl.h> |
| 47 |
#include <net/if_types.h> |
48 |
#include <net/if_types.h> |
|
Lines 61-69
Link Here
|
| 61 |
if ((sdl->sdl_type == IFT_ETHER || |
62 |
if ((sdl->sdl_type == IFT_ETHER || |
| 62 |
sdl->sdl_type == IFT_L2VLAN || |
63 |
sdl->sdl_type == IFT_L2VLAN || |
| 63 |
sdl->sdl_type == IFT_BRIDGE) && |
64 |
sdl->sdl_type == IFT_BRIDGE) && |
| 64 |
sdl->sdl_alen == ETHER_ADDR_LEN) |
65 |
sdl->sdl_alen == ETHER_ADDR_LEN) { |
|
|
66 |
struct ifreq ifr; |
| 67 |
int s_hw; |
| 65 |
printf("\tether %s\n", |
68 |
printf("\tether %s\n", |
| 66 |
ether_ntoa((struct ether_addr *)LLADDR(sdl))); |
69 |
ether_ntoa((struct ether_addr *)LLADDR(sdl))); |
|
|
70 |
strncpy(ifr.ifr_name, ifa->ifa_name, |
| 71 |
sizeof(ifr.ifr_name)); |
| 72 |
memcpy(&ifr.ifr_addr, ifa->ifa_addr, |
| 73 |
sizeof(ifa->ifa_addr->sa_len)); |
| 74 |
ifr.ifr_addr.sa_family = AF_LOCAL; |
| 75 |
if ((s_hw = socket(AF_LOCAL, SOCK_DGRAM, 0)) < 0) { |
| 76 |
warn("socket(AF_LOCAL,SOCK_DGRAM)"); |
| 77 |
return; |
| 78 |
} |
| 79 |
if (ioctl(s_hw, SIOCGHWLLADDR, &ifr) < 0) { |
| 80 |
warn("SIOCGHWLLADDR"); |
| 81 |
close(s_hw); |
| 82 |
return; |
| 83 |
} |
| 84 |
printf("\thwaddr %s\n", |
| 85 |
ether_ntoa((const struct ether_addr *) |
| 86 |
&ifr.ifr_addr.sa_data)); |
| 87 |
close(s_hw); |
| 88 |
} |
| 67 |
else { |
89 |
else { |
| 68 |
int n = sdl->sdl_nlen > 0 ? sdl->sdl_nlen + 1 : 0; |
90 |
int n = sdl->sdl_nlen > 0 ? sdl->sdl_nlen + 1 : 0; |
| 69 |
|
91 |
|