start net_info impl for windows
This commit is contained in:
parent
9e98a05fc7
commit
62188b3ee0
|
@ -43,6 +43,39 @@ static __inline sigar_uint64_t FileTimeToTime(FILETIME *ft)
|
|||
lpw, -1, (LPSTR)lpa, chars, \
|
||||
NULL, NULL))
|
||||
|
||||
/* from iptypes.h not in vs6.0 */
|
||||
#define MAX_ADAPTER_DESCRIPTION_LENGTH 128
|
||||
#define MAX_ADAPTER_NAME_LENGTH 256
|
||||
#define MAX_ADAPTER_ADDRESS_LENGTH 8
|
||||
#define MAX_HOSTNAME_LEN 128
|
||||
#define MAX_DOMAIN_NAME_LEN 128
|
||||
#define MAX_SCOPE_ID_LEN 256
|
||||
|
||||
typedef struct {
|
||||
char String[4 * 4];
|
||||
} IP_ADDRESS_STRING, *PIP_ADDRESS_STRING, IP_MASK_STRING, *PIP_MASK_STRING;
|
||||
|
||||
typedef struct _IP_ADDR_STRING {
|
||||
struct _IP_ADDR_STRING* Next;
|
||||
IP_ADDRESS_STRING IpAddress;
|
||||
IP_MASK_STRING IpMask;
|
||||
DWORD Context;
|
||||
} IP_ADDR_STRING, *PIP_ADDR_STRING;
|
||||
|
||||
typedef struct {
|
||||
char HostName[MAX_HOSTNAME_LEN + 4];
|
||||
char DomainName[MAX_DOMAIN_NAME_LEN + 4];
|
||||
PIP_ADDR_STRING CurrentDnsServer;
|
||||
IP_ADDR_STRING DnsServerList;
|
||||
UINT NodeType;
|
||||
char ScopeId[MAX_SCOPE_ID_LEN + 4];
|
||||
UINT EnableRouting;
|
||||
UINT EnableProxy;
|
||||
UINT EnableDns;
|
||||
} FIXED_INFO, *PFIXED_INFO;
|
||||
|
||||
/* end iptypes.h */
|
||||
|
||||
#include <iprtrmib.h>
|
||||
|
||||
/* undocumented structures */
|
||||
|
@ -87,6 +120,8 @@ typedef DWORD (CALLBACK *LPGETTCPEXTABLE)(PMIB_TCPEXTABLE *, BOOL, HANDLE,
|
|||
typedef DWORD (CALLBACK *LPGETUDPEXTABLE)(PMIB_UDPEXTABLE *, BOOL, HANDLE,
|
||||
DWORD, DWORD);
|
||||
|
||||
typedef DWORD (CALLBACK *LPNETPARAMS)(PFIXED_INFO, PULONG);
|
||||
|
||||
typedef DWORD (CALLBACK *LPSYSINFO)(DWORD, PVOID, ULONG, PULONG);
|
||||
|
||||
typedef BOOL (CALLBACK *LPENUMMODULES)(HANDLE, HMODULE*,
|
||||
|
@ -135,6 +170,7 @@ struct sigar_t {
|
|||
LPGETTCPEXTABLE get_tcpx_table;
|
||||
LPGETUDPTABLE get_udp_table;
|
||||
LPGETUDPEXTABLE get_udpx_table;
|
||||
LPNETPARAMS get_net_params;
|
||||
LPSYSINFO get_ntsys_info;
|
||||
LPENUMMODULES enum_modules;
|
||||
LPGETMODULENAME get_module_name;
|
||||
|
|
|
@ -225,6 +225,8 @@ int sigar_os_open(sigar_t **sigar)
|
|||
(LPGETUDPEXTABLE)GetProcAddress(h,
|
||||
"AllocateAndGet"
|
||||
"UdpExTableFromStack");
|
||||
(*sigar)->get_net_params =
|
||||
(LPNETPARAMS)GetProcAddress(h, "GetNetworkParams");
|
||||
(*sigar)->ip_handle = h;
|
||||
}
|
||||
else {
|
||||
|
@ -1602,6 +1604,37 @@ SIGAR_DECLARE(int) sigar_cpu_info_list_get(sigar_t *sigar,
|
|||
return SIGAR_OK;
|
||||
}
|
||||
|
||||
SIGAR_DECLARE(int) sigar_net_info_get(sigar_t *sigar,
|
||||
sigar_net_info_t *netinfo)
|
||||
{
|
||||
FIXED_INFO info;
|
||||
ULONG len;
|
||||
IP_ADDR_STRING *ip;
|
||||
|
||||
if (!sigar->get_net_params) {
|
||||
return SIGAR_ENOTIMPL;
|
||||
}
|
||||
|
||||
SIGAR_ZERO(netinfo);
|
||||
|
||||
len = sizeof(info);
|
||||
|
||||
if (sigar->get_net_params(&info, &len) != ERROR_SUCCESS) {
|
||||
return GetLastError();
|
||||
}
|
||||
|
||||
SIGAR_SSTRCPY(netinfo->domain_name, info.DomainName);
|
||||
SIGAR_SSTRCPY(netinfo->primary_dns,
|
||||
info.DnsServerList.IpAddress.String);
|
||||
|
||||
if ((ip = info.DnsServerList.Next)) {
|
||||
SIGAR_SSTRCPY(netinfo->secondary_dns,
|
||||
ip->IpAddress.String);
|
||||
}
|
||||
|
||||
return SIGAR_OK;
|
||||
}
|
||||
|
||||
SIGAR_DECLARE(int) sigar_net_route_list_get(sigar_t *sigar,
|
||||
sigar_net_route_list_t *routelist)
|
||||
{
|
||||
|
|
|
@ -750,12 +750,6 @@ SIGAR_DECLARE(int) sigar_who_list_get(sigar_t *sigar,
|
|||
return SIGAR_ENOTIMPL;
|
||||
}
|
||||
|
||||
SIGAR_DECLARE(int) sigar_net_info_get(sigar_t *sigar,
|
||||
sigar_net_info_t *netinfo)
|
||||
{
|
||||
return SIGAR_ENOTIMPL;
|
||||
}
|
||||
|
||||
SIGAR_DECLARE(int) sigar_resource_limit_get(sigar_t *sigar,
|
||||
sigar_resource_limit_t *rlimit)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue