add GetIpAddrTable wrapper
This commit is contained in:
		
							parent
							
								
									d6eb75c282
								
							
						
					
					
						commit
						6c21782915
					
				@ -319,6 +319,10 @@ typedef DWORD (CALLBACK *iphlpapi_get_ipforward_table)(PMIB_IPFORWARDTABLE,
 | 
				
			|||||||
                                                       PULONG,
 | 
					                                                       PULONG,
 | 
				
			||||||
                                                       BOOL);
 | 
					                                                       BOOL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					typedef DWORD (CALLBACK *iphlpapi_get_ipaddr_table)(PMIB_IPADDRTABLE,
 | 
				
			||||||
 | 
					                                                    PULONG,
 | 
				
			||||||
 | 
					                                                    BOOL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
typedef DWORD (CALLBACK *iphlpapi_get_if_table)(PMIB_IFTABLE,
 | 
					typedef DWORD (CALLBACK *iphlpapi_get_if_table)(PMIB_IFTABLE,
 | 
				
			||||||
                                                PULONG,
 | 
					                                                PULONG,
 | 
				
			||||||
                                                BOOL);
 | 
					                                                BOOL);
 | 
				
			||||||
@ -413,6 +417,7 @@ typedef struct {
 | 
				
			|||||||
    sigar_dll_handle_t handle;
 | 
					    sigar_dll_handle_t handle;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    SIGAR_DLLFUNC(iphlpapi, get_ipforward_table);
 | 
					    SIGAR_DLLFUNC(iphlpapi, get_ipforward_table);
 | 
				
			||||||
 | 
					    SIGAR_DLLFUNC(iphlpapi, get_ipaddr_table);
 | 
				
			||||||
    SIGAR_DLLFUNC(iphlpapi, get_if_table);
 | 
					    SIGAR_DLLFUNC(iphlpapi, get_if_table);
 | 
				
			||||||
    SIGAR_DLLFUNC(iphlpapi, get_if_entry);
 | 
					    SIGAR_DLLFUNC(iphlpapi, get_if_entry);
 | 
				
			||||||
    SIGAR_DLLFUNC(iphlpapi, get_tcp_table);
 | 
					    SIGAR_DLLFUNC(iphlpapi, get_tcp_table);
 | 
				
			||||||
 | 
				
			|||||||
@ -216,6 +216,7 @@ static sigar_iphlpapi_t sigar_iphlpapi = {
 | 
				
			|||||||
    "iphlpapi.dll",
 | 
					    "iphlpapi.dll",
 | 
				
			||||||
    NULL,
 | 
					    NULL,
 | 
				
			||||||
    { "GetIpForwardTable", NULL },
 | 
					    { "GetIpForwardTable", NULL },
 | 
				
			||||||
 | 
					    { "GetIpAddrTable", NULL },
 | 
				
			||||||
    { "GetIfTable", NULL },
 | 
					    { "GetIfTable", NULL },
 | 
				
			||||||
    { "GetIfEntry", NULL },
 | 
					    { "GetIfEntry", NULL },
 | 
				
			||||||
    { "GetTcpTable", NULL },
 | 
					    { "GetTcpTable", NULL },
 | 
				
			||||||
@ -1945,6 +1946,45 @@ static int sigar_get_adapter_info(sigar_t *sigar,
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define sigar_GetIpAddrTable \
 | 
				
			||||||
 | 
					    sigar->iphlpapi.get_ipaddr_table.func
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					static int sigar_get_ipaddr_table(sigar_t *sigar,
 | 
				
			||||||
 | 
					                                  PMIB_IPADDRTABLE *ipaddr)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    ULONG size = sigar->ifconf_len;
 | 
				
			||||||
 | 
					    DWORD rc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    DLLMOD_INIT(iphlpapi, FALSE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (!sigar_GetIpAddrTable) {
 | 
				
			||||||
 | 
					        return SIGAR_ENOTIMPL;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    *ipaddr = (PMIB_IPADDRTABLE)sigar->ifconf_buf;
 | 
				
			||||||
 | 
					    rc = sigar_GetIpAddrTable(*ipaddr, &size, FALSE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (rc == ERROR_INSUFFICIENT_BUFFER) {
 | 
				
			||||||
 | 
					        sigar_log_printf(sigar, SIGAR_LOG_DEBUG,
 | 
				
			||||||
 | 
					                         "GetIpAddrTable "
 | 
				
			||||||
 | 
					                         "realloc ifconf_buf old=%d, new=%d",
 | 
				
			||||||
 | 
					                         sigar->ifconf_len, size);
 | 
				
			||||||
 | 
					        sigar->ifconf_len = size;
 | 
				
			||||||
 | 
					        sigar->ifconf_buf = realloc(sigar->ifconf_buf,
 | 
				
			||||||
 | 
					                                    sigar->ifconf_len);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        *ipaddr = (PMIB_IPADDRTABLE)sigar->ifconf_buf;
 | 
				
			||||||
 | 
					        rc = sigar_GetIpAddrTable(*ipaddr, &size, FALSE);
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    if (rc != NO_ERROR) {
 | 
				
			||||||
 | 
					        return rc;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					    else {
 | 
				
			||||||
 | 
					        return SIGAR_OK;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SIGAR_DECLARE(int) sigar_net_info_get(sigar_t *sigar,
 | 
					SIGAR_DECLARE(int) sigar_net_info_get(sigar_t *sigar,
 | 
				
			||||||
                                      sigar_net_info_t *netinfo)
 | 
					                                      sigar_net_info_t *netinfo)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user