Lines 35-40
Link Here
|
35 |
#include <sys/sysctl.h> |
35 |
#include <sys/sysctl.h> |
36 |
#include <sys/ioctl.h> |
36 |
#include <sys/ioctl.h> |
37 |
#include <net/if.h> |
37 |
#include <net/if.h> |
|
|
38 |
#include <net/if_media.h> |
38 |
#include <net/if_types.h> |
39 |
#include <net/if_types.h> |
39 |
#include <net/ethernet.h> |
40 |
#include <net/ethernet.h> |
40 |
#include <ifaddrs.h> |
41 |
#include <ifaddrs.h> |
Lines 203-208
Link Here
|
203 |
return (ifr.ifr_flags); |
204 |
return (ifr.ifr_flags); |
204 |
} |
205 |
} |
205 |
|
206 |
|
|
|
207 |
/* get interface media status */ |
208 |
int |
209 |
if_getifmstatus(char *name) |
210 |
{ |
211 |
struct ifmediareq ifmr; |
212 |
int s; |
213 |
|
214 |
if ((s = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) { |
215 |
syslog(LOG_ERR, "<%s> socket: %s", __func__, |
216 |
strerror(errno)); |
217 |
return (~IFM_AVALID); |
218 |
} |
219 |
|
220 |
(void) memset(&ifmr, 0, sizeof(ifmr)); |
221 |
(void) strncpy(ifmr.ifm_name, name, sizeof(ifmr.ifm_name)); |
222 |
if (ioctl(s, SIOCGIFMEDIA, (caddr_t)&ifmr) < 0) { |
223 |
syslog(LOG_ERR, "<%s> ioctl:SIOCGIFMEDIA: failed for %s", |
224 |
__func__, ifmr.ifm_name); |
225 |
close(s); |
226 |
return (~IFM_AVALID); |
227 |
} |
228 |
close(s); |
229 |
return (ifmr.ifm_status); |
230 |
} |
231 |
|
206 |
#define ROUNDUP8(a) (1 + (((a) - 1) | 7)) |
232 |
#define ROUNDUP8(a) (1 + (((a) - 1) | 7)) |
207 |
int |
233 |
int |
208 |
lladdropt_length(struct sockaddr_dl *sdl) |
234 |
lladdropt_length(struct sockaddr_dl *sdl) |
Lines 503-509
Link Here
|
503 |
|
529 |
|
504 |
/* |
530 |
/* |
505 |
* alloc buffer and parse if_msghdrs block passed as arg, |
531 |
* alloc buffer and parse if_msghdrs block passed as arg, |
506 |
* and init the buffer as list of pointers ot each of the if_msghdr. |
532 |
* and init the buffer as list of pointers to each of the if_msghdr. |
507 |
*/ |
533 |
*/ |
508 |
static void |
534 |
static void |
509 |
parse_iflist(struct if_msghdr ***ifmlist_p, char *buf, size_t bufsize) |
535 |
parse_iflist(struct if_msghdr ***ifmlist_p, char *buf, size_t bufsize) |