changing hwaddr to sigar_net_address_t
This commit is contained in:
parent
a2597443b7
commit
287af5e947
|
@ -659,7 +659,7 @@ my %classes = (
|
||||||
plat => '*'
|
plat => '*'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name => 'hwaddr', type => 'String',
|
name => 'hwaddr', type => 'NetAddress',
|
||||||
desc => '',
|
desc => '',
|
||||||
plat => '*'
|
plat => '*'
|
||||||
},
|
},
|
||||||
|
|
|
@ -395,11 +395,13 @@ typedef struct {
|
||||||
enum {
|
enum {
|
||||||
SIGAR_AF_UNSPEC,
|
SIGAR_AF_UNSPEC,
|
||||||
SIGAR_AF_INET,
|
SIGAR_AF_INET,
|
||||||
SIGAR_AF_INET6
|
SIGAR_AF_INET6,
|
||||||
|
SIGAR_AF_LINK
|
||||||
} family;
|
} family;
|
||||||
union {
|
union {
|
||||||
sigar_uint32_t in;
|
sigar_uint32_t in;
|
||||||
sigar_uint32_t in6[4];
|
sigar_uint32_t in6[4];
|
||||||
|
unsigned char mac[8];
|
||||||
} addr;
|
} addr;
|
||||||
} sigar_net_address_t;
|
} sigar_net_address_t;
|
||||||
|
|
||||||
|
@ -478,9 +480,9 @@ SIGAR_DECLARE(int) sigar_net_route_list_destroy(sigar_t *sigar,
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
char name[16];
|
char name[16];
|
||||||
char hwaddr[64];
|
|
||||||
char type[64];
|
char type[64];
|
||||||
char description[256];
|
char description[256];
|
||||||
|
sigar_net_address_t hwaddr;
|
||||||
sigar_net_address_t address;
|
sigar_net_address_t address;
|
||||||
sigar_net_address_t destination;
|
sigar_net_address_t destination;
|
||||||
sigar_net_address_t broadcast;
|
sigar_net_address_t broadcast;
|
||||||
|
|
|
@ -196,10 +196,15 @@ int sigar_net_connection_list_grow(sigar_net_connection_list_t *connlist);
|
||||||
(a).addr.in = val; \
|
(a).addr.in = val; \
|
||||||
(a).family = SIGAR_AF_INET
|
(a).family = SIGAR_AF_INET
|
||||||
|
|
||||||
#define sigar_net_address6_set(addr, val) \
|
#define sigar_net_address6_set(a, val) \
|
||||||
memcpy(&((a).addr.in6), val, sizeof((a).addr.in6)); \
|
memcpy(&((a).addr.in6), val, sizeof((a).addr.in6)); \
|
||||||
(a).family = SIGAR_AF_INET6
|
(a).family = SIGAR_AF_INET6
|
||||||
|
|
||||||
|
#define sigar_net_address_mac_set(a, val, len) \
|
||||||
|
if (len == 0) SIGAR_ZERO(&((a).addr.mac); \
|
||||||
|
else memcpy(&((a).addr.mac), val, len); \
|
||||||
|
(a).family = SIGAR_AF_LINK
|
||||||
|
|
||||||
int sigar_who_list_create(sigar_who_list_t *wholist);
|
int sigar_who_list_create(sigar_who_list_t *wholist);
|
||||||
|
|
||||||
int sigar_who_list_grow(sigar_who_list_t *wholist);
|
int sigar_who_list_grow(sigar_who_list_t *wholist);
|
||||||
|
@ -209,7 +214,7 @@ int sigar_who_list_grow(sigar_who_list_t *wholist);
|
||||||
sigar_who_list_grow(wholist); \
|
sigar_who_list_grow(wholist); \
|
||||||
}
|
}
|
||||||
|
|
||||||
void sigar_hwaddr_format(char *buff, unsigned char *ptr);
|
int sigar_hwaddr_format(char *buff, unsigned char *ptr);
|
||||||
|
|
||||||
#define sigar_hwaddr_set_null(ifconfig) \
|
#define sigar_hwaddr_set_null(ifconfig) \
|
||||||
memcpy(ifconfig->hwaddr, SIGAR_NULL_HWADDR, sizeof(SIGAR_NULL_HWADDR))
|
memcpy(ifconfig->hwaddr, SIGAR_NULL_HWADDR, sizeof(SIGAR_NULL_HWADDR))
|
||||||
|
|
|
@ -1617,8 +1617,10 @@ int sigar_net_interface_config_get(sigar_t *sigar, const char *name,
|
||||||
SIGAR_SSTRCPY(ifconfig->name, name);
|
SIGAR_SSTRCPY(ifconfig->name, name);
|
||||||
|
|
||||||
sdl = (struct sockaddr_dl *)(ifm + 1);
|
sdl = (struct sockaddr_dl *)(ifm + 1);
|
||||||
sigar_hwaddr_format(ifconfig->hwaddr,
|
|
||||||
(unsigned char *)LLADDR(sdl));
|
sigar_net_address_mac_set(ifconfig->hwaddr,
|
||||||
|
LLADDR(sdl),
|
||||||
|
sdl->sdl_alen);
|
||||||
|
|
||||||
ifconfig->flags = ifm->ifm_flags;
|
ifconfig->flags = ifm->ifm_flags;
|
||||||
ifconfig->mtu = ifm->ifm_data.ifi_mtu;
|
ifconfig->mtu = ifm->ifm_data.ifi_mtu;
|
||||||
|
|
|
@ -1210,11 +1210,12 @@ int sigar_resource_limit_get(sigar_t *sigar,
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void sigar_hwaddr_format(char *buff, unsigned char *ptr)
|
int sigar_hwaddr_format(char *buff, unsigned char *ptr)
|
||||||
{
|
{
|
||||||
sprintf(buff, "%02X:%02X:%02X:%02X:%02X:%02X",
|
sprintf(buff, "%02X:%02X:%02X:%02X:%02X:%02X",
|
||||||
(ptr[0] & 0377), (ptr[1] & 0377), (ptr[2] & 0377),
|
(ptr[0] & 0377), (ptr[1] & 0377), (ptr[2] & 0377),
|
||||||
(ptr[3] & 0377), (ptr[4] & 0377), (ptr[5] & 0377));
|
(ptr[3] & 0377), (ptr[4] & 0377), (ptr[5] & 0377));
|
||||||
|
return SIGAR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if !defined(WIN32) && !defined(DARWIN) && !defined(__FreeBSD__) && !defined(NETWARE)
|
#if !defined(WIN32) && !defined(DARWIN) && !defined(__FreeBSD__) && !defined(NETWARE)
|
||||||
|
@ -1657,6 +1658,8 @@ SIGAR_DECLARE(int) sigar_net_address_to_string(sigar_t *sigar,
|
||||||
return sigar_inet_ntoa(sigar, address->addr.in, addr_str);
|
return sigar_inet_ntoa(sigar, address->addr.in, addr_str);
|
||||||
case SIGAR_AF_UNSPEC:
|
case SIGAR_AF_UNSPEC:
|
||||||
return sigar_inet_ntoa(sigar, 0, addr_str); /*XXX*/
|
return sigar_inet_ntoa(sigar, 0, addr_str); /*XXX*/
|
||||||
|
case SIGAR_AF_LINK:
|
||||||
|
return sigar_hwaddr_format(addr_str, &address->addr.mac[0]);
|
||||||
default:
|
default:
|
||||||
return EINVAL;
|
return EINVAL;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue