start net_info impl for windows

This commit is contained in:
Doug MacEachern 2005-07-11 22:40:31 +00:00
parent 9e98a05fc7
commit 62188b3ee0
3 changed files with 69 additions and 6 deletions

View File

@ -43,6 +43,39 @@ static __inline sigar_uint64_t FileTimeToTime(FILETIME *ft)
lpw, -1, (LPSTR)lpa, chars, \ lpw, -1, (LPSTR)lpa, chars, \
NULL, NULL)) 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> #include <iprtrmib.h>
/* undocumented structures */ /* undocumented structures */
@ -87,6 +120,8 @@ typedef DWORD (CALLBACK *LPGETTCPEXTABLE)(PMIB_TCPEXTABLE *, BOOL, HANDLE,
typedef DWORD (CALLBACK *LPGETUDPEXTABLE)(PMIB_UDPEXTABLE *, BOOL, HANDLE, typedef DWORD (CALLBACK *LPGETUDPEXTABLE)(PMIB_UDPEXTABLE *, BOOL, HANDLE,
DWORD, DWORD); DWORD, DWORD);
typedef DWORD (CALLBACK *LPNETPARAMS)(PFIXED_INFO, PULONG);
typedef DWORD (CALLBACK *LPSYSINFO)(DWORD, PVOID, ULONG, PULONG); typedef DWORD (CALLBACK *LPSYSINFO)(DWORD, PVOID, ULONG, PULONG);
typedef BOOL (CALLBACK *LPENUMMODULES)(HANDLE, HMODULE*, typedef BOOL (CALLBACK *LPENUMMODULES)(HANDLE, HMODULE*,
@ -135,6 +170,7 @@ struct sigar_t {
LPGETTCPEXTABLE get_tcpx_table; LPGETTCPEXTABLE get_tcpx_table;
LPGETUDPTABLE get_udp_table; LPGETUDPTABLE get_udp_table;
LPGETUDPEXTABLE get_udpx_table; LPGETUDPEXTABLE get_udpx_table;
LPNETPARAMS get_net_params;
LPSYSINFO get_ntsys_info; LPSYSINFO get_ntsys_info;
LPENUMMODULES enum_modules; LPENUMMODULES enum_modules;
LPGETMODULENAME get_module_name; LPGETMODULENAME get_module_name;

View File

@ -225,6 +225,8 @@ int sigar_os_open(sigar_t **sigar)
(LPGETUDPEXTABLE)GetProcAddress(h, (LPGETUDPEXTABLE)GetProcAddress(h,
"AllocateAndGet" "AllocateAndGet"
"UdpExTableFromStack"); "UdpExTableFromStack");
(*sigar)->get_net_params =
(LPNETPARAMS)GetProcAddress(h, "GetNetworkParams");
(*sigar)->ip_handle = h; (*sigar)->ip_handle = h;
} }
else { else {
@ -1602,6 +1604,37 @@ SIGAR_DECLARE(int) sigar_cpu_info_list_get(sigar_t *sigar,
return SIGAR_OK; 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_DECLARE(int) sigar_net_route_list_get(sigar_t *sigar,
sigar_net_route_list_t *routelist) sigar_net_route_list_t *routelist)
{ {

View File

@ -750,12 +750,6 @@ SIGAR_DECLARE(int) sigar_who_list_get(sigar_t *sigar,
return SIGAR_ENOTIMPL; 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_DECLARE(int) sigar_resource_limit_get(sigar_t *sigar,
sigar_resource_limit_t *rlimit) sigar_resource_limit_t *rlimit)
{ {