ReactOS  0.4.15-dev-3297-g037c744
iphlpapi_main.c File Reference
#include <config.h>
#include "iphlpapi_private.h"
#include <strsafe.h>
#include <psapi.h>
Include dependency graph for iphlpapi_main.c:

Go to the source code of this file.

Classes

struct  _NAME_SERVER_LIST_CONTEXT
 

Macros

#define DEBUG
 

Typedefs

typedef struct _NAME_SERVER_LIST_CONTEXT NAME_SERVER_LIST_CONTEXT
 
typedef struct _NAME_SERVER_LIST_CONTEXTPNAME_SERVER_LIST_CONTEXT
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (iphlpapi)
 
BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
 
DWORD WINAPI AddIPAddress (IPAddr Address, IPMask Netmask, DWORD IfIndex, PULONG NteContext, PULONG NteInstance)
 
DWORD getInterfaceGatewayByIndex (DWORD index)
 
DWORD WINAPI AllocateAndGetIfTableFromStack (PMIB_IFTABLE *ppIfTable, BOOL bOrder, HANDLE heap, DWORD flags)
 
DWORD WINAPI AllocateAndGetIpAddrTableFromStack (PMIB_IPADDRTABLE *ppIpAddrTable, BOOL bOrder, HANDLE heap, DWORD flags)
 
DWORD WINAPI AllocateAndGetIpForwardTableFromStack (PMIB_IPFORWARDTABLE *ppIpForwardTable, BOOL bOrder, HANDLE heap, DWORD flags)
 
DWORD WINAPI AllocateAndGetIpNetTableFromStack (PMIB_IPNETTABLE *ppIpNetTable, BOOL bOrder, HANDLE heap, DWORD flags)
 
DWORD WINAPI AllocateAndGetTcpTableFromStack (PMIB_TCPTABLE *ppTcpTable, BOOL bOrder, HANDLE heap, DWORD flags)
 
DWORD WINAPI AllocateAndGetTcpExTableFromStack (PVOID *ppTcpTable, BOOL bOrder, HANDLE heap, DWORD flags, DWORD family)
 
DWORD WINAPI AllocateAndGetTcpExTable2FromStack (PVOID *ppTcpTable, BOOL bOrder, HANDLE heap, DWORD flags, DWORD family, TCP_TABLE_CLASS class)
 
DWORD WINAPI AllocateAndGetUdpTableFromStack (PMIB_UDPTABLE *ppUdpTable, BOOL bOrder, HANDLE heap, DWORD flags)
 
DWORD WINAPI AllocateAndGetUdpExTableFromStack (PVOID *ppUdpTable, BOOL bOrder, HANDLE heap, DWORD flags, DWORD family)
 
DWORD WINAPI AllocateAndGetUdpExTable2FromStack (PVOID *ppUdpTable, BOOL bOrder, HANDLE heap, DWORD flags, DWORD family, UDP_TABLE_CLASS class)
 
DWORD WINAPI CreateIpForwardEntry (PMIB_IPFORWARDROW pRoute)
 
DWORD WINAPI CreateIpNetEntry (PMIB_IPNETROW pArpEntry)
 
DWORD WINAPI CreateProxyArpEntry (DWORD dwAddress, DWORD dwMask, DWORD dwIfIndex)
 
DWORD WINAPI DeleteIPAddress (ULONG NTEContext)
 
DWORD WINAPI DeleteIpForwardEntry (PMIB_IPFORWARDROW pRoute)
 
DWORD WINAPI DeleteIpNetEntry (PMIB_IPNETROW pArpEntry)
 
DWORD WINAPI DeleteProxyArpEntry (DWORD dwAddress, DWORD dwMask, DWORD dwIfIndex)
 
DWORD WINAPI EnableRouter (HANDLE *pHandle, OVERLAPPED *pOverlapped)
 
DWORD WINAPI FlushIpNetTable (DWORD dwIfIndex)
 
DWORD WINAPI GetAdapterIndex (LPWSTR AdapterName, PULONG IfIndex)
 
DWORD WINAPI GetAdaptersInfo (PIP_ADAPTER_INFO pAdapterInfo, PULONG pOutBufLen)
 
DWORD WINAPI GetBestInterface (IPAddr dwDestAddr, PDWORD pdwBestIfIndex)
 
DWORD WINAPI GetBestRoute (DWORD dwDestAddr, DWORD dwSourceAddr, PMIB_IPFORWARDROW pBestRoute)
 
static int TcpTableSorter (const void *a, const void *b)
 
DWORD WINAPI GetExtendedTcpTable (PVOID pTcpTable, PDWORD pdwSize, BOOL bOrder, ULONG ulAf, TCP_TABLE_CLASS TableClass, ULONG Reserved)
 
static int UdpTableSorter (const void *a, const void *b)
 
DWORD WINAPI GetExtendedUdpTable (PVOID pUdpTable, PDWORD pdwSize, BOOL bOrder, ULONG ulAf, UDP_TABLE_CLASS TableClass, ULONG Reserved)
 
DWORD WINAPI GetFriendlyIfIndex (DWORD IfIndex)
 
DWORD WINAPI GetIcmpStatistics (PMIB_ICMP pStats)
 
DWORD WINAPI GetIfEntry (PMIB_IFROW pIfRow)
 
static int IfTableSorter (const void *a, const void *b)
 
DWORD WINAPI GetIfTable (PMIB_IFTABLE pIfTable, PULONG pdwSize, BOOL bOrder)
 
DWORD WINAPI GetInterfaceInfo (PIP_INTERFACE_INFO pIfTable, PULONG dwOutBufLen)
 
static int IpAddrTableSorter (const void *a, const void *b)
 
DWORD WINAPI GetIpAddrTable (PMIB_IPADDRTABLE pIpAddrTable, PULONG pdwSize, BOOL bOrder)
 
static int IpForwardTableSorter (const void *a, const void *b)
 
DWORD WINAPI GetIpForwardTable (PMIB_IPFORWARDTABLE pIpForwardTable, PULONG pdwSize, BOOL bOrder)
 
static int IpNetTableSorter (const void *a, const void *b)
 
DWORD WINAPI GetIpNetTable (PMIB_IPNETTABLE pIpNetTable, PULONG pdwSize, BOOL bOrder)
 
DWORD WINAPI GetIpStatistics (PMIB_IPSTATS pStats)
 
DWORD WINAPI GetIpStatisticsEx (PMIB_IPSTATS pStats, DWORD dwFamily)
 
DWORD WINAPI GetNetworkParams (PFIXED_INFO pFixedInfo, PULONG pOutBufLen)
 
DWORD WINAPI GetNumberOfInterfaces (PDWORD pdwNumIf)
 
static DWORD GetOwnerModuleFromPidEntry (DWORD OwningPid, TCPIP_OWNER_MODULE_INFO_CLASS Class, PVOID Buffer, PDWORD pdwSize)
 
static DWORD GetOwnerModuleFromTagEntry (DWORD OwningPid, DWORD OwningTag, TCPIP_OWNER_MODULE_INFO_CLASS Class, PVOID Buffer, PDWORD pdwSize)
 
DWORD WINAPI GetOwnerModuleFromTcpEntry (PMIB_TCPROW_OWNER_MODULE pTcpEntry, TCPIP_OWNER_MODULE_INFO_CLASS Class, PVOID Buffer, PDWORD pdwSize)
 
DWORD WINAPI GetOwnerModuleFromUdpEntry (PMIB_UDPROW_OWNER_MODULE pUdpEntry, TCPIP_OWNER_MODULE_INFO_CLASS Class, PVOID Buffer, PDWORD pdwSize)
 
static void CreateNameServerListEnumNamesFunc (PWCHAR Interface, PWCHAR Server, PVOID Data)
 
DWORD WINAPI GetPerAdapterInfo (ULONG IfIndex, PIP_PER_ADAPTER_INFO pPerAdapterInfo, PULONG pOutBufLen)
 
BOOL WINAPI GetRTTAndHopCount (IPAddr DestIpAddress, PULONG HopCount, ULONG MaxHops, PULONG RTT)
 
DWORD WINAPI GetTcpStatisticsEx (PMIB_TCPSTATS pStats, DWORD dwFamily)
 
DWORD WINAPI GetTcpStatistics (PMIB_TCPSTATS pStats)
 
DWORD WINAPI GetTcpTable (PMIB_TCPTABLE pTcpTable, PDWORD pdwSize, BOOL bOrder)
 
DWORD WINAPI GetUdpStatisticsEx (PMIB_UDPSTATS pStats, DWORD dwFamily)
 
DWORD WINAPI GetUdpStatistics (PMIB_UDPSTATS pStats)
 
DWORD WINAPI GetUdpTable (PMIB_UDPTABLE pUdpTable, PDWORD pdwSize, BOOL bOrder)
 
DWORD WINAPI GetUniDirectionalAdapterInfo (PIP_UNIDIRECTIONAL_ADAPTER_ADDRESS pIPIfInfo, PULONG dwOutBufLen)
 
DWORD WINAPI IpReleaseAddress (PIP_ADAPTER_INDEX_MAP AdapterInfo)
 
DWORD WINAPI IpRenewAddress (PIP_ADAPTER_INDEX_MAP AdapterInfo)
 
DWORD WINAPI NotifyAddrChange (PHANDLE Handle, LPOVERLAPPED overlapped)
 
DWORD WINAPI NotifyRouteChange (PHANDLE Handle, LPOVERLAPPED overlapped)
 
DWORD WINAPI SendARP (IPAddr DestIP, IPAddr SrcIP, PULONG pMacAddr, PULONG PhyAddrLen)
 
DWORD WINAPI SetIfEntry (PMIB_IFROW pIfRow)
 
DWORD WINAPI SetIpForwardEntry (PMIB_IPFORWARDROW pRoute)
 
DWORD WINAPI SetIpNetEntry (PMIB_IPNETROW pArpEntry)
 
DWORD WINAPI SetIpStatistics (PMIB_IPSTATS pIpStats)
 
DWORD WINAPI SetIpTTL (UINT nTTL)
 
DWORD WINAPI SetTcpEntry (PMIB_TCPROW pTcpRow)
 
DWORD WINAPI UnenableRouter (OVERLAPPED *pOverlapped, LPDWORD lpdwEnableCount)
 
DWORD WINAPI GetIpErrorString (IP_STATUS ErrorCode, PWCHAR Buffer, PDWORD Size)
 
PIP_ADAPTER_ORDER_MAP WINAPI GetAdapterOrderMap (VOID)
 
BOOL WINAPI CancelIPChangeNotify (LPOVERLAPPED notifyOverlapped)
 
DWORD WINAPI GetBestInterfaceEx (struct sockaddr *pDestAddr, PDWORD pdwBestIfIndex)
 
DWORD WINAPI NhpAllocateAndGetInterfaceInfoFromStack (IP_INTERFACE_NAME_INFO **ppTable, PDWORD pdwCount, BOOL bOrder, HANDLE hHeap, DWORD dwFlags)
 
DWORD WINAPI GetIcmpStatisticsEx (PMIB_ICMP_EX pStats, DWORD dwFamily)
 
DWORD WINAPI SetIpForwardEntryToStack (PMIB_IPFORWARDROW pRoute)
 
DWORD GetInterfaceNameInternal (_In_ const GUID *pInterfaceGUID, _Out_writes_bytes_to_(*pOutBufLen, *pOutBufLen) PWCHAR pInterfaceName, _Inout_ PULONG pOutBufLen)
 
DWORD WINAPI NhGetInterfaceNameFromDeviceGuid (_In_ const GUID *pInterfaceGUID, _Out_writes_bytes_to_(*pOutBufLen, *pOutBufLen) PWCHAR pInterfaceName, _Inout_ PULONG pOutBufLen, DWORD dwUnknown4, DWORD dwUnknown5)
 
DWORD WINAPI NhGetInterfaceNameFromGuid (_In_ const GUID *pInterfaceGUID, _Out_writes_bytes_to_(*pOutBufLen, *pOutBufLen) PWCHAR pInterfaceName, _Inout_ PULONG pOutBufLen, DWORD dwUnknown4, DWORD dwUnknown5)
 

Macro Definition Documentation

◆ DEBUG

#define DEBUG

Definition at line 22 of file iphlpapi_main.c.

Typedef Documentation

◆ NAME_SERVER_LIST_CONTEXT

◆ PNAME_SERVER_LIST_CONTEXT

Function Documentation

◆ AddIPAddress()

DWORD WINAPI AddIPAddress ( IPAddr  Address,
IPMask  Netmask,
DWORD  IfIndex,
PULONG  NteContext,
PULONG  NteInstance 
)

Definition at line 71 of file iphlpapi_main.c.

72 {
73  return RtlNtStatusToDosError(addIPAddress(Address, Netmask, IfIndex, NteContext, NteInstance));
74 }
NTSTATUS addIPAddress(IPAddr Address, IPMask Mask, DWORD IfIndex, PULONG NteContext, PULONG NteInstance)
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
static WCHAR Address[46]
Definition: ping.c:68

Referenced by DSStaticRefreshParams(), INetCfgComponentControl_fnApplyRegistryChanges(), setup_adapter(), and state_panic().

◆ AllocateAndGetIfTableFromStack()

DWORD WINAPI AllocateAndGetIfTableFromStack ( PMIB_IFTABLE ppIfTable,
BOOL  bOrder,
HANDLE  heap,
DWORD  flags 
)

Definition at line 107 of file iphlpapi_main.c.

109 {
110  DWORD ret;
111 
112  TRACE("ppIfTable %p, bOrder %ld, heap 0x%p, flags 0x%08lx\n", ppIfTable,
113  (DWORD)bOrder, heap, flags);
114  if (!ppIfTable)
116  else {
117  DWORD dwSize = 0;
118 
119  *ppIfTable = NULL;
120  ret = GetIfTable(*ppIfTable, &dwSize, bOrder);
122  *ppIfTable = (PMIB_IFTABLE)HeapAlloc(heap, flags, dwSize);
123  ret = GetIfTable(*ppIfTable, &dwSize, bOrder);
124  if (ret != NO_ERROR) {
125  HeapFree(heap, flags, *ppIfTable);
126  *ppIfTable = NULL;
127  }
128  }
129  }
130  TRACE("returning %ld\n", ret);
131  return ret;
132 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define NO_ERROR
Definition: dderror.h:5
DWORD WINAPI GetIfTable(PMIB_IFTABLE pIfTable, PULONG pdwSize, BOOL bOrder)
#define TRACE(s)
Definition: solgame.cpp:4
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
int ret
struct _MIB_IFTABLE * PMIB_IFTABLE
#define NULL
Definition: types.h:112
#define HeapFree(x, y, z)
Definition: compat.h:594
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ AllocateAndGetIpAddrTableFromStack()

DWORD WINAPI AllocateAndGetIpAddrTableFromStack ( PMIB_IPADDRTABLE ppIpAddrTable,
BOOL  bOrder,
HANDLE  heap,
DWORD  flags 
)

Definition at line 151 of file iphlpapi_main.c.

153 {
154  DWORD ret;
155 
156  TRACE("ppIpAddrTable %p, bOrder %ld, heap 0x%p, flags 0x%08lx\n",
157  ppIpAddrTable, (DWORD)bOrder, heap, flags);
158  if (!ppIpAddrTable)
160  else {
161  DWORD dwSize = 0;
162 
163  *ppIpAddrTable = NULL;
164  ret = GetIpAddrTable(*ppIpAddrTable, &dwSize, bOrder);
166  *ppIpAddrTable = (PMIB_IPADDRTABLE)HeapAlloc(heap, flags, dwSize);
167  ret = GetIpAddrTable(*ppIpAddrTable, &dwSize, bOrder);
168  if (ret != NO_ERROR) {
169  HeapFree(heap, flags, *ppIpAddrTable);
170  *ppIpAddrTable = NULL;
171  }
172  }
173  }
174  TRACE("returning %ld\n", ret);
175  return ret;
176 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define NO_ERROR
Definition: dderror.h:5
DWORD WINAPI GetIpAddrTable(PMIB_IPADDRTABLE pIpAddrTable, PULONG pdwSize, BOOL bOrder)
#define TRACE(s)
Definition: solgame.cpp:4
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
int ret
struct _MIB_IPADDRTABLE * PMIB_IPADDRTABLE
#define NULL
Definition: types.h:112
#define HeapFree(x, y, z)
Definition: compat.h:594
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ AllocateAndGetIpForwardTableFromStack()

DWORD WINAPI AllocateAndGetIpForwardTableFromStack ( PMIB_IPFORWARDTABLE ppIpForwardTable,
BOOL  bOrder,
HANDLE  heap,
DWORD  flags 
)

Definition at line 193 of file iphlpapi_main.c.

195 {
196  DWORD ret;
197 
198  TRACE("ppIpForwardTable %p, bOrder %ld, heap 0x%p, flags 0x%08lx\n",
199  ppIpForwardTable, (DWORD)bOrder, heap, flags);
200  if (!ppIpForwardTable)
202  else {
203  DWORD dwSize = 0;
204 
205  *ppIpForwardTable = NULL;
206  ret = GetIpForwardTable(*ppIpForwardTable, &dwSize, bOrder);
208  *ppIpForwardTable = (PMIB_IPFORWARDTABLE)HeapAlloc(heap, flags, dwSize);
209  ret = GetIpForwardTable(*ppIpForwardTable, &dwSize, bOrder);
210  if (ret != NO_ERROR) {
211  HeapFree(heap, flags, *ppIpForwardTable);
212  *ppIpForwardTable = NULL;
213  }
214  }
215  }
216  TRACE("returning %ld\n", ret);
217  return ret;
218 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define NO_ERROR
Definition: dderror.h:5
#define TRACE(s)
Definition: solgame.cpp:4
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
int ret
struct _MIB_IPFORWARDTABLE * PMIB_IPFORWARDTABLE
DWORD WINAPI GetIpForwardTable(PMIB_IPFORWARDTABLE pIpForwardTable, PULONG pdwSize, BOOL bOrder)
#define NULL
Definition: types.h:112
#define HeapFree(x, y, z)
Definition: compat.h:594
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by GetBestRoute().

◆ AllocateAndGetIpNetTableFromStack()

DWORD WINAPI AllocateAndGetIpNetTableFromStack ( PMIB_IPNETTABLE ppIpNetTable,
BOOL  bOrder,
HANDLE  heap,
DWORD  flags 
)

Definition at line 237 of file iphlpapi_main.c.

239 {
240  DWORD ret;
241 
242  TRACE("ppIpNetTable %p, bOrder %ld, heap 0x%p, flags 0x%08lx\n",
243  ppIpNetTable, (DWORD)bOrder, heap, flags);
244  if (!ppIpNetTable)
246  else {
247  DWORD dwSize = 0;
248 
249  *ppIpNetTable = NULL;
250  ret = GetIpNetTable(*ppIpNetTable, &dwSize, bOrder);
252  *ppIpNetTable = (PMIB_IPNETTABLE)HeapAlloc(heap, flags, dwSize);
253  ret = GetIpNetTable(*ppIpNetTable, &dwSize, bOrder);
254  if (ret != NO_ERROR) {
255  HeapFree(heap, flags, *ppIpNetTable);
256  *ppIpNetTable = NULL;
257  }
258  }
259  }
260  TRACE("returning %ld\n", ret);
261  return ret;
262 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
DWORD WINAPI GetIpNetTable(PMIB_IPNETTABLE pIpNetTable, PULONG pdwSize, BOOL bOrder)
#define NO_ERROR
Definition: dderror.h:5
struct _MIB_IPNETTABLE * PMIB_IPNETTABLE
#define TRACE(s)
Definition: solgame.cpp:4
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
int ret
#define NULL
Definition: types.h:112
#define HeapFree(x, y, z)
Definition: compat.h:594
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ AllocateAndGetTcpExTable2FromStack()

DWORD WINAPI AllocateAndGetTcpExTable2FromStack ( PVOID ppTcpTable,
BOOL  bOrder,
HANDLE  heap,
DWORD  flags,
DWORD  family,
TCP_TABLE_CLASS  class 
)

Definition at line 372 of file iphlpapi_main.c.

374 {
375  DWORD ret;
376 
377  TRACE("ppTcpTable %p, bOrder %ld, heap 0x%p, flags 0x%08lx, family %ld, class %ld\n",
378  ppTcpTable, (DWORD)bOrder, heap, flags, family, class);
379  if (!ppTcpTable)
381  else {
382  DWORD dwSize = 0;
383 
384  *ppTcpTable = NULL;
385  ret = GetExtendedTcpTable(*ppTcpTable, &dwSize, bOrder, family, class, 0);
387  *ppTcpTable = HeapAlloc(heap, flags, dwSize);
388  ret = GetExtendedTcpTable(*ppTcpTable, &dwSize, bOrder, family, class, 0);
389  if (ret != NO_ERROR) {
390  HeapFree(heap, flags, *ppTcpTable);
391  *ppTcpTable = NULL;
392  }
393  }
394  }
395  TRACE("returning %ld\n", ret);
396  return ret;
397 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define NO_ERROR
Definition: dderror.h:5
#define TRACE(s)
Definition: solgame.cpp:4
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
int ret
#define NULL
Definition: types.h:112
DWORD WINAPI GetExtendedTcpTable(PVOID pTcpTable, PDWORD pdwSize, BOOL bOrder, ULONG ulAf, TCP_TABLE_CLASS TableClass, ULONG Reserved)
#define HeapFree(x, y, z)
Definition: compat.h:594
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ AllocateAndGetTcpExTableFromStack()

DWORD WINAPI AllocateAndGetTcpExTableFromStack ( PVOID ppTcpTable,
BOOL  bOrder,
HANDLE  heap,
DWORD  flags,
DWORD  family 
)

Definition at line 326 of file iphlpapi_main.c.

328 {
329  DWORD ret;
330 
331  TRACE("ppTcpTable %p, bOrder %ld, heap 0x%p, flags 0x%08lx, family 0x%08lx\n",
332  ppTcpTable, (DWORD)bOrder, heap, flags, family);
333  if (!ppTcpTable)
335  else {
336  DWORD dwSize = 0;
337 
338  *ppTcpTable = NULL;
339  ret = GetExtendedTcpTable(*ppTcpTable, &dwSize, bOrder, family, TCP_TABLE_OWNER_PID_ALL, 0);
341  *ppTcpTable = (PMIB_TCPTABLE_OWNER_PID)HeapAlloc(heap, flags, dwSize);
342  ret = GetExtendedTcpTable(*ppTcpTable, &dwSize, bOrder, family, TCP_TABLE_OWNER_PID_ALL, 0);
343  if (ret != NO_ERROR) {
344  HeapFree(heap, flags, *ppTcpTable);
345  *ppTcpTable = NULL;
346  }
347  }
348  }
349  TRACE("returning %ld\n", ret);
350  return ret;
351 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define NO_ERROR
Definition: dderror.h:5
#define TRACE(s)
Definition: solgame.cpp:4
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
int ret
struct _MIB_TCPTABLE_OWNER_PID * PMIB_TCPTABLE_OWNER_PID
#define NULL
Definition: types.h:112
DWORD WINAPI GetExtendedTcpTable(PVOID pTcpTable, PDWORD pdwSize, BOOL bOrder, ULONG ulAf, TCP_TABLE_CLASS TableClass, ULONG Reserved)
#define HeapFree(x, y, z)
Definition: compat.h:594
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ AllocateAndGetTcpTableFromStack()

DWORD WINAPI AllocateAndGetTcpTableFromStack ( PMIB_TCPTABLE ppTcpTable,
BOOL  bOrder,
HANDLE  heap,
DWORD  flags 
)

Definition at line 281 of file iphlpapi_main.c.

283 {
284  DWORD ret;
285 
286  TRACE("ppTcpTable %p, bOrder %ld, heap 0x%p, flags 0x%08lx\n",
287  ppTcpTable, (DWORD)bOrder, heap, flags);
288  if (!ppTcpTable)
290  else {
291  DWORD dwSize = 0;
292 
293  *ppTcpTable = NULL;
294  ret = GetTcpTable(*ppTcpTable, &dwSize, bOrder);
296  *ppTcpTable = (PMIB_TCPTABLE)HeapAlloc(heap, flags, dwSize);
297  ret = GetTcpTable(*ppTcpTable, &dwSize, bOrder);
298  if (ret != NO_ERROR) {
299  HeapFree(heap, flags, *ppTcpTable);
300  *ppTcpTable = NULL;
301  }
302  }
303  }
304  TRACE("returning %ld\n", ret);
305  return ret;
306 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define NO_ERROR
Definition: dderror.h:5
#define TRACE(s)
Definition: solgame.cpp:4
DWORD WINAPI GetTcpTable(PMIB_TCPTABLE pTcpTable, PDWORD pdwSize, BOOL bOrder)
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
int ret
struct _MIB_TCPTABLE * PMIB_TCPTABLE
#define NULL
Definition: types.h:112
#define HeapFree(x, y, z)
Definition: compat.h:594
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ AllocateAndGetUdpExTable2FromStack()

DWORD WINAPI AllocateAndGetUdpExTable2FromStack ( PVOID ppUdpTable,
BOOL  bOrder,
HANDLE  heap,
DWORD  flags,
DWORD  family,
UDP_TABLE_CLASS  class 
)

Definition at line 507 of file iphlpapi_main.c.

509 {
510  DWORD ret;
511 
512  TRACE("ppUdpTable %p, bOrder %ld, heap 0x%p, flags 0x%08lx, family %ld, class %ld\n",
513  ppUdpTable, (DWORD)bOrder, heap, flags, family, class);
514  if (!ppUdpTable)
516  else {
517  DWORD dwSize = 0;
518 
519  *ppUdpTable = NULL;
520  ret = GetExtendedUdpTable(*ppUdpTable, &dwSize, bOrder, family, class, 0);
522  *ppUdpTable = HeapAlloc(heap, flags, dwSize);
523  ret = GetExtendedUdpTable(*ppUdpTable, &dwSize, bOrder, family, class, 0);
524  if (ret != NO_ERROR) {
525  HeapFree(heap, flags, *ppUdpTable);
526  *ppUdpTable = NULL;
527  }
528  }
529  }
530  TRACE("returning %ld\n", ret);
531  return ret;
532 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define NO_ERROR
Definition: dderror.h:5
#define TRACE(s)
Definition: solgame.cpp:4
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
int ret
DWORD WINAPI GetExtendedUdpTable(PVOID pUdpTable, PDWORD pdwSize, BOOL bOrder, ULONG ulAf, UDP_TABLE_CLASS TableClass, ULONG Reserved)
#define NULL
Definition: types.h:112
#define HeapFree(x, y, z)
Definition: compat.h:594
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ AllocateAndGetUdpExTableFromStack()

DWORD WINAPI AllocateAndGetUdpExTableFromStack ( PVOID ppUdpTable,
BOOL  bOrder,
HANDLE  heap,
DWORD  flags,
DWORD  family 
)

Definition at line 461 of file iphlpapi_main.c.

463 {
464  DWORD ret;
465 
466  TRACE("ppUdpTable %p, bOrder %ld, heap 0x%p, flags 0x%08lx, family 0x%08lx\n",
467  ppUdpTable, (DWORD)bOrder, heap, flags, family);
468  if (!ppUdpTable)
470  else {
471  DWORD dwSize = 0;
472 
473  *ppUdpTable = NULL;
474  ret = GetExtendedUdpTable(*ppUdpTable, &dwSize, bOrder, family, UDP_TABLE_OWNER_PID, 0);
476  *ppUdpTable = (PMIB_UDPTABLE_OWNER_PID)HeapAlloc(heap, flags, dwSize);
477  ret = GetExtendedUdpTable(*ppUdpTable, &dwSize, bOrder, family, UDP_TABLE_OWNER_PID, 0);
478  if (ret != NO_ERROR) {
479  HeapFree(heap, flags, *ppUdpTable);
480  *ppUdpTable = NULL;
481  }
482  }
483  }
484  TRACE("returning %ld\n", ret);
485  return ret;
486 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define NO_ERROR
Definition: dderror.h:5
struct _MIB_UDPTABLE_OWNER_PID * PMIB_UDPTABLE_OWNER_PID
#define TRACE(s)
Definition: solgame.cpp:4
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
int ret
DWORD WINAPI GetExtendedUdpTable(PVOID pUdpTable, PDWORD pdwSize, BOOL bOrder, ULONG ulAf, UDP_TABLE_CLASS TableClass, ULONG Reserved)
#define NULL
Definition: types.h:112
#define HeapFree(x, y, z)
Definition: compat.h:594
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ AllocateAndGetUdpTableFromStack()

DWORD WINAPI AllocateAndGetUdpTableFromStack ( PMIB_UDPTABLE ppUdpTable,
BOOL  bOrder,
HANDLE  heap,
DWORD  flags 
)

Definition at line 416 of file iphlpapi_main.c.

418 {
419  DWORD ret;
420 
421  TRACE("ppUdpTable %p, bOrder %ld, heap 0x%p, flags 0x%08lx\n",
422  ppUdpTable, (DWORD)bOrder, heap, flags);
423  if (!ppUdpTable)
425  else {
426  DWORD dwSize = 0;
427 
428  *ppUdpTable = NULL;
429  ret = GetUdpTable(*ppUdpTable, &dwSize, bOrder);
431  *ppUdpTable = (PMIB_UDPTABLE)HeapAlloc(heap, flags, dwSize);
432  ret = GetUdpTable(*ppUdpTable, &dwSize, bOrder);
433  if (ret != NO_ERROR) {
434  HeapFree(heap, flags, *ppUdpTable);
435  *ppUdpTable = NULL;
436  }
437  }
438  }
439  TRACE("returning %ld\n", ret);
440  return ret;
441 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
DWORD WINAPI GetUdpTable(PMIB_UDPTABLE pUdpTable, PDWORD pdwSize, BOOL bOrder)
struct _MIB_UDPTABLE * PMIB_UDPTABLE
#define NO_ERROR
Definition: dderror.h:5
#define TRACE(s)
Definition: solgame.cpp:4
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
GLbitfield flags
Definition: glext.h:7161
int ret
#define NULL
Definition: types.h:112
#define HeapFree(x, y, z)
Definition: compat.h:594
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ CancelIPChangeNotify()

BOOL WINAPI CancelIPChangeNotify ( LPOVERLAPPED  notifyOverlapped)

Definition at line 3369 of file iphlpapi_main.c.

3370 {
3371  FIXME(":stub\n");
3372  return 0L;
3373 }
#define FIXME(fmt,...)
Definition: debug.h:111
static const WCHAR L[]
Definition: oid.c:1250

◆ CreateIpForwardEntry()

DWORD WINAPI CreateIpForwardEntry ( PMIB_IPFORWARDROW  pRoute)

Definition at line 548 of file iphlpapi_main.c.

549 {
550  return createIpForwardEntry( pRoute );
551 }
DWORD createIpForwardEntry(PMIB_IPFORWARDROW pRoute)
Definition: route.c:52

Referenced by add_route(), INetCfgComponentControl_fnApplyRegistryChanges(), and setup_adapter().

◆ CreateIpNetEntry()

DWORD WINAPI CreateIpNetEntry ( PMIB_IPNETROW  pArpEntry)

Definition at line 567 of file iphlpapi_main.c.

568 {
569  TRACE("pArpEntry %p\n", pArpEntry);
570  /* could use SIOCSARP on systems that support it, not sure I want to */
571  FIXME(":stub\n");
572  return (DWORD) 0;
573 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95

◆ CreateNameServerListEnumNamesFunc()

static void CreateNameServerListEnumNamesFunc ( PWCHAR  Interface,
PWCHAR  Server,
PVOID  Data 
)
static

Definition at line 2513 of file iphlpapi_main.c.

2514 {
2515  IP_ADDR_STRING *pNext;
2517 
2518  if (!Context->NumServers)
2519  {
2520  if (Context->uSizeAvailable >= Context->uSizeRequired)
2521  {
2522  WideCharToMultiByte(CP_ACP, 0, Server, -1, Context->pData->DnsServerList.IpAddress.String, 16, NULL, NULL);
2523  Context->pData->DnsServerList.IpAddress.String[15] = '\0';
2524  Context->pLastAddr = &Context->pData->DnsServerList;
2525  }
2526  }
2527  else
2528  {
2529  Context->uSizeRequired += sizeof(IP_ADDR_STRING);
2530  if (Context->uSizeAvailable >= Context->uSizeRequired)
2531  {
2532  pNext = (IP_ADDR_STRING*)(((char*)Context->pLastAddr) + sizeof(IP_ADDR_STRING));
2533  WideCharToMultiByte(CP_ACP, 0, Server, -1, pNext->IpAddress.String, 16, NULL, NULL);
2534  pNext->IpAddress.String[15] = '\0';
2535  Context->pLastAddr->Next = pNext;
2536  Context->pLastAddr = pNext;
2537  pNext->Next = NULL;
2538  }
2539  }
2540  Context->NumServers++;
2541 }
#define WideCharToMultiByte
Definition: compat.h:111
#define CP_ACP
Definition: compat.h:109
IP_ADDRESS_STRING IpAddress
Definition: iptypes.h:47
struct _IP_ADDR_STRING * Next
Definition: iptypes.h:46
char String[4 *4]
Definition: iptypes.h:42
static void Server(int port)
Definition: srltest.c:69
struct _NAME_SERVER_LIST_CONTEXT * PNAME_SERVER_LIST_CONTEXT
#define NULL
Definition: types.h:112
struct _IP_ADDR_STRING IP_ADDR_STRING

Referenced by GetPerAdapterInfo().

◆ CreateProxyArpEntry()

DWORD WINAPI CreateProxyArpEntry ( DWORD  dwAddress,
DWORD  dwMask,
DWORD  dwIfIndex 
)

Definition at line 591 of file iphlpapi_main.c.

592 {
593  TRACE("dwAddress 0x%08lx, dwMask 0x%08lx, dwIfIndex 0x%08lx\n", dwAddress,
594  dwMask, dwIfIndex);
595  FIXME(":stub\n");
596  /* marking Win2K+ functions not supported */
597  return ERROR_NOT_SUPPORTED;
598 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define TRACE(s)
Definition: solgame.cpp:4
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100

◆ DeleteIPAddress()

DWORD WINAPI DeleteIPAddress ( ULONG  NTEContext)

Definition at line 614 of file iphlpapi_main.c.

615 {
616  TRACE("NTEContext %ld\n", NTEContext);
617  return RtlNtStatusToDosError(deleteIpAddress(NTEContext));
618 }
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
NTSTATUS deleteIpAddress(ULONG NteContext)
#define TRACE(s)
Definition: solgame.cpp:4

Referenced by DSReleaseIpAddressLease(), DSStaticRefreshParams(), INetCfgComponentControl_fnApplyRegistryChanges(), send_request(), and setup_adapter().

◆ DeleteIpForwardEntry()

DWORD WINAPI DeleteIpForwardEntry ( PMIB_IPFORWARDROW  pRoute)

Definition at line 634 of file iphlpapi_main.c.

635 {
636  return deleteIpForwardEntry( pRoute );
637 }
DWORD deleteIpForwardEntry(PMIB_IPFORWARDROW pRoute)
Definition: route.c:64

Referenced by del_route(), DSReleaseIpAddressLease(), DSStaticRefreshParams(), INetCfgComponentControl_fnApplyRegistryChanges(), and setup_adapter().

◆ DeleteIpNetEntry()

DWORD WINAPI DeleteIpNetEntry ( PMIB_IPNETROW  pArpEntry)

Definition at line 653 of file iphlpapi_main.c.

654 {
655  TRACE("pArpEntry %p\n", pArpEntry);
656  /* could use SIOCDARP on systems that support it, not sure I want to */
657  FIXME(":stub\n");
658  return (DWORD) 0;
659 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95

Referenced by Deletehost().

◆ DeleteProxyArpEntry()

DWORD WINAPI DeleteProxyArpEntry ( DWORD  dwAddress,
DWORD  dwMask,
DWORD  dwIfIndex 
)

Definition at line 677 of file iphlpapi_main.c.

678 {
679  TRACE("dwAddress 0x%08lx, dwMask 0x%08lx, dwIfIndex 0x%08lx\n", dwAddress,
680  dwMask, dwIfIndex);
681  FIXME(":stub\n");
682  /* marking Win2K+ functions not supported */
683  return ERROR_NOT_SUPPORTED;
684 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define TRACE(s)
Definition: solgame.cpp:4
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100

◆ DllMain()

BOOL WINAPI DllMain ( HINSTANCE  hinstDLL,
DWORD  fdwReason,
LPVOID  lpvReserved 
)

Definition at line 39 of file iphlpapi_main.c.

40 {
41  switch (fdwReason) {
42  case DLL_PROCESS_ATTACH:
43  DisableThreadLibraryCalls( hinstDLL );
45  break;
46 
47  case DLL_PROCESS_DETACH:
49  break;
50  }
51  return TRUE;
52 }
#define TRUE
Definition: types.h:120
BOOL WINAPI DisableThreadLibraryCalls(IN HMODULE hLibModule)
Definition: loader.c:85
void interfaceMapInit(void)
#define DLL_PROCESS_ATTACH
Definition: compat.h:131
#define DLL_PROCESS_DETACH
Definition: compat.h:130
void interfaceMapFree(void)

◆ EnableRouter()

DWORD WINAPI EnableRouter ( HANDLE pHandle,
OVERLAPPED pOverlapped 
)

Definition at line 700 of file iphlpapi_main.c.

701 {
702  TRACE("pHandle %p, pOverlapped %p\n", pHandle, pOverlapped);
703  FIXME(":stub\n");
704  /* could echo "1" > /proc/net/sys/net/ipv4/ip_forward, not sure I want to
705  could map EACCESS to ERROR_ACCESS_DENIED, I suppose
706  marking Win2K+ functions not supported */
707  return ERROR_NOT_SUPPORTED;
708 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define TRACE(s)
Definition: solgame.cpp:4
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100

◆ FlushIpNetTable()

DWORD WINAPI FlushIpNetTable ( DWORD  dwIfIndex)

Definition at line 724 of file iphlpapi_main.c.

725 {
726  TRACE("dwIfIndex 0x%08lx\n", dwIfIndex);
727  FIXME(":stub\n");
728  /* this flushes the arp cache of the given index
729  marking Win2K+ functions not supported */
730  return ERROR_NOT_SUPPORTED;
731 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define TRACE(s)
Definition: solgame.cpp:4
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100

Referenced by Deletehost().

◆ GetAdapterIndex()

DWORD WINAPI GetAdapterIndex ( LPWSTR  AdapterName,
PULONG  IfIndex 
)

Definition at line 748 of file iphlpapi_main.c.

749 {
750  TRACE("AdapterName %p, IfIndex %p\n", AdapterName, IfIndex);
751  FIXME(":stub\n");
752  /* marking Win2K+ functions not supported */
753  return ERROR_NOT_SUPPORTED;
754 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define TRACE(s)
Definition: solgame.cpp:4
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100
_Must_inspect_result_ _Out_ PNDIS_STATUS _Out_ PNDIS_STATUS _Out_ PNDIS_HANDLE _Out_ PUINT _In_ UINT _In_ NDIS_HANDLE _In_ NDIS_HANDLE _In_ PNDIS_STRING AdapterName
Definition: ndis.h:6013

◆ GetAdapterOrderMap()

PIP_ADAPTER_ORDER_MAP WINAPI GetAdapterOrderMap ( VOID  )

Definition at line 3159 of file iphlpapi_main.c.

3160 {
3161  FIXME(":stub\n");
3162  return 0L;
3163 }
#define FIXME(fmt,...)
Definition: debug.h:111
static const WCHAR L[]
Definition: oid.c:1250

◆ GetAdaptersInfo()

DWORD WINAPI GetAdaptersInfo ( PIP_ADAPTER_INFO  pAdapterInfo,
PULONG  pOutBufLen 
)

Definition at line 771 of file iphlpapi_main.c.

772 {
773  DWORD ret;
774  BOOL dhcpEnabled;
775  DWORD dhcpServer;
776 
777  TRACE("pAdapterInfo %p, pOutBufLen %p\n", pAdapterInfo, pOutBufLen);
778  if (!pOutBufLen)
780  else {
781  DWORD numNonLoopbackInterfaces = getNumNonLoopbackInterfaces();
782 
783  if (numNonLoopbackInterfaces > 0) {
784  /* this calculation assumes only one address in the IP_ADDR_STRING lists.
785  that's okay, because:
786  - we don't get multiple addresses per adapter anyway
787  - we don't know about per-adapter gateways
788  - DHCP and WINS servers can have max one entry per list */
789  ULONG size = sizeof(IP_ADAPTER_INFO) * numNonLoopbackInterfaces;
790 
791  if (!pAdapterInfo || *pOutBufLen < size) {
792  *pOutBufLen = size;
794  }
795  else {
797 
798  if (table) {
799  size = sizeof(IP_ADAPTER_INFO) * table->numIndexes;
800  if (*pOutBufLen < size) {
801  *pOutBufLen = size;
803  }
804  else {
805  DWORD ndx;
806  HKEY hKey;
807  BOOL winsEnabled = FALSE;
808  IP_ADDRESS_STRING primaryWINS, secondaryWINS;
809 
810  memset(pAdapterInfo, 0, size);
811  /* @@ Wine registry key: HKCU\Software\Wine\Network */
812  if (RegOpenKeyA(HKEY_CURRENT_USER, "Software\\Wine\\Network", &hKey) == ERROR_SUCCESS) {
813  DWORD size = sizeof(primaryWINS.String);
814  unsigned long addr;
815 
816  RegQueryValueExA(hKey, "WinsServer", NULL, NULL,
817  (PBYTE)primaryWINS.String, &size);
818  addr = inet_addr(primaryWINS.String);
819  if (addr != INADDR_NONE && addr != INADDR_ANY)
820  winsEnabled = TRUE;
821  size = sizeof(secondaryWINS.String);
822  RegQueryValueExA(hKey, "BackupWinsServer", NULL, NULL,
823  (PBYTE)secondaryWINS.String, &size);
824  addr = inet_addr(secondaryWINS.String);
825  if (addr != INADDR_NONE && addr != INADDR_ANY)
826  winsEnabled = TRUE;
827  RegCloseKey(hKey);
828  }
829  TRACE("num of index is %lu\n", table->numIndexes);
830  for (ndx = 0; ndx < table->numIndexes; ndx++) {
831  PIP_ADAPTER_INFO ptr = &pAdapterInfo[ndx];
832  DWORD addrLen = sizeof(ptr->Address), type;
833  const char *ifname =
834  getInterfaceNameByIndex(table->indexes[ndx]);
835  if (!ifname) {
837  break;
838  }
839 
840  /* on Win98 this is left empty, but whatever */
841  strncpy(ptr->AdapterName,ifname,sizeof(ptr->AdapterName));
842  consumeInterfaceName(ifname);
843  ptr->AdapterName[MAX_ADAPTER_NAME_LENGTH] = '\0';
844  getInterfacePhysicalByIndex(table->indexes[ndx], &addrLen,
845  ptr->Address, &type);
846  /* MS defines address length and type as UINT in some places and
847  DWORD in others, **sigh**. Don't want to assume that PUINT and
848  PDWORD are equiv (64-bit?) */
849  ptr->AddressLength = addrLen;
850  ptr->Type = type;
851  ptr->Index = table->indexes[ndx];
853  ptr->IpAddressList.IpAddress.String);
855  ptr->IpAddressList.IpMask.String);
856  ptr->IpAddressList.Context = ptr->Index;
858  ptr->GatewayList.IpAddress.String);
859  getDhcpInfoForAdapter(table->indexes[ndx], &dhcpEnabled,
860  &dhcpServer, &ptr->LeaseObtained,
861  &ptr->LeaseExpires);
862  ptr->DhcpEnabled = (DWORD) dhcpEnabled;
863  toIPAddressString(dhcpServer,
864  ptr->DhcpServer.IpAddress.String);
865  if (winsEnabled) {
866  ptr->HaveWins = TRUE;
867  memcpy(ptr->PrimaryWinsServer.IpAddress.String,
868  primaryWINS.String, sizeof(primaryWINS.String));
869  memcpy(ptr->SecondaryWinsServer.IpAddress.String,
870  secondaryWINS.String, sizeof(secondaryWINS.String));
871  }
872  if (ndx < table->numIndexes - 1)
873  ptr->Next = &pAdapterInfo[ndx + 1];
874  else
875  ptr->Next = NULL;
876  }
877  ret = NO_ERROR;
878  }
879  free(table);
880  }
881  else
883  }
884  }
885  else
886  ret = ERROR_NO_DATA;
887  }
888  TRACE("returning %ld\n", ret);
889  return ret;
890 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
LONG WINAPI RegOpenKeyA(HKEY hKey, LPCSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3257
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4023
#define inet_addr(cp)
Definition: inet.h:98
#define ERROR_SUCCESS
Definition: deptool.c:10
#define TRUE
Definition: types.h:120
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
#define HKEY_CURRENT_USER
Definition: winreg.h:11
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
#define free
Definition: debug_ros.c:5
#define INADDR_NONE
Definition: tcp.c:42
#define INADDR_ANY
Definition: StrAddr.c:4
char String[4 *4]
Definition: iptypes.h:42
if(dx==0 &&dy==0)
Definition: linetemp.h:174
#define NO_ERROR
Definition: dderror.h:5
InterfaceIndexTable * getNonLoopbackInterfaceIndexTable(void)
DWORD getNumNonLoopbackInterfaces(void)
#define DWORD
Definition: nt_native.h:44
struct _IP_ADAPTER_INFO IP_ADAPTER_INFO
void consumeInterfaceName(const char *ifname)
const char * getInterfaceNameByIndex(DWORD index)
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
DWORD getDhcpInfoForAdapter(DWORD AdapterIndex, PBOOL DhcpEnabled, PDWORD DhcpServer, time_t *LeaseObtained, time_t *LeaseExpires)
Definition: dhcp_reactos.c:17
char * toIPAddressString(unsigned int addr, char string[16])
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
static PVOID ptr
Definition: dispmode.c:27
DWORD getInterfacePhysicalByIndex(DWORD index, PDWORD len, PBYTE addr, PDWORD type)
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define ERROR_NO_DATA
Definition: winerror.h:284
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD getInterfaceMaskByIndex(DWORD index)
DWORD getInterfaceGatewayByIndex(DWORD index)
Definition: iphlpapi_main.c:76
int ret
#define MAX_ADAPTER_NAME_LENGTH
Definition: iptypes.h:27
GLenum const GLvoid * addr
Definition: glext.h:9621
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define memset(x, y, z)
Definition: compat.h:39
BYTE * PBYTE
Definition: pedump.c:66
DWORD getInterfaceIPAddrByIndex(DWORD index)
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by CNetConnectionManager::EnumerateINetConnections(), Initialize(), InitializePropertyDialog(), IsReconnectHackNeeded(), LANStatusUiDetailsDlg(), PrintRoutes(), RPC_UuidGetNodeAddress(), ShowInfo(), and TestUM().

◆ GetBestInterface()

DWORD WINAPI GetBestInterface ( IPAddr  dwDestAddr,
PDWORD  pdwBestIfIndex 
)

Definition at line 907 of file iphlpapi_main.c.

908 {
909  DWORD ret;
910 
911  TRACE("dwDestAddr 0x%08lx, pdwBestIfIndex %p\n", dwDestAddr, pdwBestIfIndex);
912  if (!pdwBestIfIndex)
914  else {
915  MIB_IPFORWARDROW ipRow;
916 
917  ret = GetBestRoute(dwDestAddr, 0, &ipRow);
918  if (ret == ERROR_SUCCESS)
919  *pdwBestIfIndex = ipRow.dwForwardIfIndex;
920  }
921  TRACE("returning %ld\n", ret);
922  return ret;
923 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_SUCCESS
Definition: deptool.c:10
IF_INDEX dwForwardIfIndex
Definition: ipmib.h:75
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
DWORD WINAPI GetBestRoute(DWORD dwDestAddr, DWORD dwSourceAddr, PMIB_IPFORWARDROW pBestRoute)

◆ GetBestInterfaceEx()

DWORD WINAPI GetBestInterfaceEx ( struct sockaddr pDestAddr,
PDWORD  pdwBestIfIndex 
)

Definition at line 3378 of file iphlpapi_main.c.

3379 {
3380  FIXME(":stub\n");
3381  return 0L;
3382 }
#define FIXME(fmt,...)
Definition: debug.h:111
static const WCHAR L[]
Definition: oid.c:1250

◆ GetBestRoute()

DWORD WINAPI GetBestRoute ( DWORD  dwDestAddr,
DWORD  dwSourceAddr,
PMIB_IPFORWARDROW  pBestRoute 
)

Definition at line 941 of file iphlpapi_main.c.

942 {
944  DWORD ret;
945 
946  TRACE("dwDestAddr 0x%08lx, dwSourceAddr 0x%08lx, pBestRoute %p\n", dwDestAddr,
947  dwSourceAddr, pBestRoute);
948  if (!pBestRoute)
950 
952  if (table) {
953  DWORD ndx, minMaskSize, matchedNdx = 0;
954 
955  for (ndx = 0, minMaskSize = 255; ndx < table->dwNumEntries; ndx++) {
956  if ((dwDestAddr & table->table[ndx].dwForwardMask) ==
957  (table->table[ndx].dwForwardDest & table->table[ndx].dwForwardMask)) {
958  DWORD hostMaskSize;
959 
960  if (!_BitScanForward(&hostMaskSize, ntohl(table->table[ndx].dwForwardMask)))
961  {
962  hostMaskSize = 32;
963  }
964  if (hostMaskSize < minMaskSize) {
965  minMaskSize = hostMaskSize;
966  matchedNdx = ndx;
967  }
968  }
969  }
970  memcpy(pBestRoute, &table->table[matchedNdx], sizeof(MIB_IPFORWARDROW));
972  ret = ERROR_SUCCESS;
973  }
974  else
976  TRACE("returning %ld\n", ret);
977  return ret;
978 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
unsigned char _BitScanForward(unsigned long *_Index, unsigned long _Mask)
Definition: intrin_arm.h:57
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD WINAPI AllocateAndGetIpForwardTableFromStack(PMIB_IPFORWARDTABLE *ppIpForwardTable, BOOL bOrder, HANDLE heap, DWORD flags)
GLenum GLsizei GLenum GLenum const GLvoid * table
Definition: glext.h:5644
#define FALSE
Definition: types.h:117
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:595
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ntohl(x)
Definition: module.h:203
#define HeapFree(x, y, z)
Definition: compat.h:594
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13

Referenced by GetBestInterface().

◆ GetExtendedTcpTable()

DWORD WINAPI GetExtendedTcpTable ( PVOID  pTcpTable,
PDWORD  pdwSize,
BOOL  bOrder,
ULONG  ulAf,
TCP_TABLE_CLASS  TableClass,
ULONG  Reserved 
)

Definition at line 1022 of file iphlpapi_main.c.

1023 {
1024  DWORD i, count, size;
1025  DWORD ret = NO_ERROR;
1026 
1027  if (!pdwSize)
1028  {
1029  return ERROR_INVALID_PARAMETER;
1030  }
1031 
1032  if (ulAf != AF_INET)
1033  {
1034  UNIMPLEMENTED;
1035  return ERROR_INVALID_PARAMETER;
1036  }
1037 
1038  switch (TableClass)
1039  {
1040  case TCP_TABLE_BASIC_ALL:
1041  {
1042  PMIB_TCPTABLE pOurTcpTable = getTcpTable(ClassBasic);
1043  PMIB_TCPTABLE pTheirTcpTable = pTcpTable;
1044 
1045  if (pOurTcpTable)
1046  {
1047  size = FIELD_OFFSET(MIB_TCPTABLE, table) + pOurTcpTable->dwNumEntries * sizeof(MIB_TCPROW);
1048  if (size > *pdwSize || !pTheirTcpTable)
1049  {
1050  *pdwSize = size;
1052  }
1053  else
1054  {
1055  memcpy(pTheirTcpTable, pOurTcpTable, size);
1056 
1057  if (bOrder)
1058  qsort(pTheirTcpTable->table, pTheirTcpTable->dwNumEntries,
1059  sizeof(MIB_TCPROW), TcpTableSorter);
1060  }
1061 
1062  HeapFree(GetProcessHeap(),0, pOurTcpTable);
1063  }
1064  }
1065  break;
1066 
1068  {
1069  PMIB_TCPTABLE pOurTcpTable = getTcpTable(ClassBasic);
1070  PMIB_TCPTABLE pTheirTcpTable = pTcpTable;
1071 
1072  if (pOurTcpTable)
1073  {
1074  for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1075  {
1076  if (pOurTcpTable->table[i].State != MIB_TCP_STATE_LISTEN)
1077  {
1078  ++count;
1079  }
1080  }
1081 
1083  if (size > *pdwSize || !pTheirTcpTable)
1084  {
1085  *pdwSize = size;
1087  }
1088  else
1089  {
1090  pTheirTcpTable->dwNumEntries = count;
1091 
1092  for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1093  {
1094  if (pOurTcpTable->table[i].State != MIB_TCP_STATE_LISTEN)
1095  {
1096  memcpy(&pTheirTcpTable->table[count], &pOurTcpTable->table[i], sizeof(MIB_TCPROW));
1097  ++count;
1098  }
1099  }
1100  ASSERT(count == pTheirTcpTable->dwNumEntries);
1101 
1102  if (bOrder)
1103  qsort(pTheirTcpTable->table, pTheirTcpTable->dwNumEntries,
1104  sizeof(MIB_TCPROW), TcpTableSorter);
1105  }
1106 
1107  HeapFree(GetProcessHeap(), 0, pOurTcpTable);
1108  }
1109  }
1110  break;
1111 
1113  {
1114  PMIB_TCPTABLE pOurTcpTable = getTcpTable(ClassBasic);
1115  PMIB_TCPTABLE pTheirTcpTable = pTcpTable;
1116 
1117  if (pOurTcpTable)
1118  {
1119  for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1120  {
1121  if (pOurTcpTable->table[i].State == MIB_TCP_STATE_LISTEN)
1122  {
1123  ++count;
1124  }
1125  }
1126 
1128  if (size > *pdwSize || !pTheirTcpTable)
1129  {
1130  *pdwSize = size;
1132  }
1133  else
1134  {
1135  pTheirTcpTable->dwNumEntries = count;
1136 
1137  for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1138  {
1139  if (pOurTcpTable->table[i].State == MIB_TCP_STATE_LISTEN)
1140  {
1141  memcpy(&pTheirTcpTable->table[count], &pOurTcpTable->table[i], sizeof(MIB_TCPROW));
1142  ++count;
1143  }
1144  }
1145  ASSERT(count == pTheirTcpTable->dwNumEntries);
1146 
1147  if (bOrder)
1148  qsort(pTheirTcpTable->table, pTheirTcpTable->dwNumEntries,
1149  sizeof(MIB_TCPROW), TcpTableSorter);
1150  }
1151 
1152  HeapFree(GetProcessHeap(), 0, pOurTcpTable);
1153  }
1154  }
1155  break;
1156 
1158  {
1160  PMIB_TCPTABLE_OWNER_PID pTheirTcpTable = pTcpTable;
1161 
1162  if (pOurTcpTable)
1163  {
1165  if (size > *pdwSize || !pTheirTcpTable)
1166  {
1167  *pdwSize = size;
1169  }
1170  else
1171  {
1172  memcpy(pTheirTcpTable, pOurTcpTable, size);
1173 
1174  /* Don't sort on PID, so use basic helper */
1175  if (bOrder)
1176  qsort(pTheirTcpTable->table, pTheirTcpTable->dwNumEntries,
1178  }
1179 
1180  HeapFree(GetProcessHeap(), 0, pOurTcpTable);
1181  }
1182  }
1183  break;
1184 
1186  {
1188  PMIB_TCPTABLE_OWNER_PID pTheirTcpTable = pTcpTable;
1189 
1190  if (pOurTcpTable)
1191  {
1192  for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1193  {
1194  if (pOurTcpTable->table[i].dwState != MIB_TCP_STATE_LISTEN)
1195  {
1196  ++count;
1197  }
1198  }
1199 
1201  if (size > *pdwSize || !pTheirTcpTable)
1202  {
1203  *pdwSize = size;
1205  }
1206  else
1207  {
1208  pTheirTcpTable->dwNumEntries = count;
1209 
1210  for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1211  {
1212  if (pOurTcpTable->table[i].dwState != MIB_TCP_STATE_LISTEN)
1213  {
1214  memcpy(&pTheirTcpTable->table[count], &pOurTcpTable->table[i], sizeof(MIB_TCPROW_OWNER_PID));
1215  ++count;
1216  }
1217  }
1218  ASSERT(count == pTheirTcpTable->dwNumEntries);
1219 
1220  /* Don't sort on PID, so use basic helper */
1221  if (bOrder)
1222  qsort(pTheirTcpTable->table, pTheirTcpTable->dwNumEntries,
1224  }
1225 
1226  HeapFree(GetProcessHeap(), 0, pOurTcpTable);
1227  }
1228  }
1229  break;
1230 
1232  {
1234  PMIB_TCPTABLE_OWNER_PID pTheirTcpTable = pTcpTable;
1235 
1236  if (pOurTcpTable)
1237  {
1238  for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1239  {
1240  if (pOurTcpTable->table[i].dwState == MIB_TCP_STATE_LISTEN)
1241  {
1242  ++count;
1243  }
1244  }
1245 
1247  if (size > *pdwSize || !pTheirTcpTable)
1248  {
1249  *pdwSize = size;
1251  }
1252  else
1253  {
1254  pTheirTcpTable->dwNumEntries = count;
1255 
1256  for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1257  {
1258  if (pOurTcpTable->table[i].dwState == MIB_TCP_STATE_LISTEN)
1259  {
1260  memcpy(&pTheirTcpTable->table[count], &pOurTcpTable->table[i], sizeof(MIB_TCPROW_OWNER_PID));
1261  ++count;
1262  }
1263  }
1264  ASSERT(count == pTheirTcpTable->dwNumEntries);
1265 
1266  /* Don't sort on PID, so use basic helper */
1267  if (bOrder)
1268  qsort(pTheirTcpTable->table, pTheirTcpTable->dwNumEntries,
1270  }
1271 
1272  HeapFree(GetProcessHeap(), 0, pOurTcpTable);
1273  }
1274  }
1275  break;
1276 
1278  {
1280  PMIB_TCPTABLE_OWNER_MODULE pTheirTcpTable = pTcpTable;
1281 
1282  if (pOurTcpTable)
1283  {
1285  if (size > *pdwSize || !pTheirTcpTable)
1286  {
1287  *pdwSize = size;
1289  }
1290  else
1291  {
1292  memcpy(pTheirTcpTable, pOurTcpTable, size);
1293 
1294  /* Don't sort on PID, so use basic helper */
1295  if (bOrder)
1296  qsort(pTheirTcpTable->table, pTheirTcpTable->dwNumEntries,
1298  }
1299 
1300  HeapFree(GetProcessHeap(), 0, pOurTcpTable);
1301  }
1302  }
1303  break;
1304 
1306  {
1308  PMIB_TCPTABLE_OWNER_MODULE pTheirTcpTable = pTcpTable;
1309 
1310  if (pOurTcpTable)
1311  {
1312  for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1313  {
1314  if (pOurTcpTable->table[i].dwState != MIB_TCP_STATE_LISTEN)
1315  {
1316  ++count;
1317  }
1318  }
1319 
1321  if (size > *pdwSize || !pTheirTcpTable)
1322  {
1323  *pdwSize = size;
1325  }
1326  else
1327  {
1328  pTheirTcpTable->dwNumEntries = count;
1329 
1330  for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1331  {
1332  if (pOurTcpTable->table[i].dwState != MIB_TCP_STATE_LISTEN)
1333  {
1334  memcpy(&pTheirTcpTable->table[count], &pOurTcpTable->table[i], sizeof(MIB_TCPROW_OWNER_MODULE));
1335  ++count;
1336  }
1337  }
1338  ASSERT(count == pTheirTcpTable->dwNumEntries);
1339 
1340  /* Don't sort on PID, so use basic helper */
1341  if (bOrder)
1342  qsort(pTheirTcpTable->table, pTheirTcpTable->dwNumEntries,
1344  }
1345 
1346  HeapFree(GetProcessHeap(), 0, pOurTcpTable);
1347  }
1348  }
1349  break;
1350 
1352  {
1354  PMIB_TCPTABLE_OWNER_MODULE pTheirTcpTable = pTcpTable;
1355 
1356  if (pOurTcpTable)
1357  {
1358  for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1359  {
1360  if (pOurTcpTable->table[i].dwState == MIB_TCP_STATE_LISTEN)
1361  {
1362  ++count;
1363  }
1364  }
1365 
1367  if (size > *pdwSize || !pTheirTcpTable)
1368  {
1369  *pdwSize = size;
1371  }
1372  else
1373  {
1374  pTheirTcpTable->dwNumEntries = count;
1375 
1376  for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1377  {
1378  if (pOurTcpTable->table[i].dwState == MIB_TCP_STATE_LISTEN)
1379  {
1380  memcpy(&pTheirTcpTable->table[count], &pOurTcpTable->table[i], sizeof(MIB_TCPROW_OWNER_MODULE));
1381  ++count;
1382  }
1383  }
1384  ASSERT(count == pTheirTcpTable->dwNumEntries);
1385 
1386  /* Don't sort on PID, so use basic helper */
1387  if (bOrder)
1388  qsort(pTheirTcpTable->table, pTheirTcpTable->dwNumEntries,
1390  }
1391 
1392  HeapFree(GetProcessHeap(), 0, pOurTcpTable);
1393  }
1394  }
1395  break;
1396 
1397  default:
1399  break;
1400  }
1401 
1402  return ret;
1403 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
PVOID getTcpTable(CLASS_TABLE Class)
struct _MIB_TCPROW_OWNER_MODULE MIB_TCPROW_OWNER_MODULE
MIB_TCPROW table[1]
Definition: tcpmib.h:67
static int TcpTableSorter(const void *a, const void *b)
GLuint GLuint GLsizei count
Definition: gl.h:1545
DWORD dwNumEntries
Definition: tcpmib.h:66
#define NO_ERROR
Definition: dderror.h:5
void __cdecl qsort(_Inout_updates_bytes_(_NumOfElements *_SizeOfElements) void *_Base, _In_ size_t _NumOfElements, _In_ size_t _SizeOfElements, _In_ int(__cdecl *_PtFuncCompare)(const void *, const void *))
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:595
#define ASSERT(a)
Definition: mode.c:44
unsigned long DWORD
Definition: ntddk_ex.h:95
MIB_TCP_STATE State
Definition: tcpmib.h:56
struct _MIB_TCPROW_OWNER_PID MIB_TCPROW_OWNER_PID
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
MIB_TCPROW_OWNER_MODULE table[1]
Definition: tcpmib.h:133
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define AF_INET
Definition: tcpip.h:117
#define UNIMPLEMENTED
Definition: debug.h:115
#define HeapFree(x, y, z)
Definition: compat.h:594
MIB_TCPROW_OWNER_PID table[1]
Definition: tcpmib.h:115
struct _MIB_TCPROW MIB_TCPROW
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by AllocateAndGetTcpExTable2FromStack(), AllocateAndGetTcpExTableFromStack(), GetExtendedTcpTableWithAlloc(), GetTcpTable(), and ShowTcpTable().

◆ GetExtendedUdpTable()

DWORD WINAPI GetExtendedUdpTable ( PVOID  pUdpTable,
PDWORD  pdwSize,
BOOL  bOrder,
ULONG  ulAf,
UDP_TABLE_CLASS  TableClass,
ULONG  Reserved 
)

Definition at line 1442 of file iphlpapi_main.c.

1443 {
1444  DWORD size;
1445  DWORD ret = NO_ERROR;
1446 
1447  if (!pdwSize)
1448  {
1449  return ERROR_INVALID_PARAMETER;
1450  }
1451 
1452  if (ulAf != AF_INET)
1453  {
1454  UNIMPLEMENTED;
1455  return ERROR_INVALID_PARAMETER;
1456  }
1457 
1458  switch (TableClass)
1459  {
1460  case UDP_TABLE_BASIC:
1461  {
1462  PMIB_UDPTABLE pOurUdpTable = getUdpTable(ClassBasic);
1463  PMIB_UDPTABLE pTheirUdpTable = pUdpTable;
1464 
1465  if (pOurUdpTable)
1466  {
1467  size = FIELD_OFFSET(MIB_UDPTABLE, table) + pOurUdpTable->dwNumEntries * sizeof(MIB_UDPROW);
1468  if (size > *pdwSize || !pTheirUdpTable)
1469  {
1470  *pdwSize = size;
1472  }
1473  else
1474  {
1475  memcpy(pTheirUdpTable, pOurUdpTable, size);
1476 
1477  if (bOrder)
1478  qsort(pTheirUdpTable->table, pTheirUdpTable->dwNumEntries,
1479  sizeof(MIB_UDPROW), UdpTableSorter);
1480  }
1481 
1482  HeapFree(GetProcessHeap(), 0, pOurUdpTable);
1483  }
1484  }
1485  break;
1486 
1487  case UDP_TABLE_OWNER_PID:
1488  {
1490  PMIB_UDPTABLE_OWNER_PID pTheirUdpTable = pUdpTable;
1491 
1492  if (pOurUdpTable)
1493  {
1495  if (size > *pdwSize || !pTheirUdpTable)
1496  {
1497  *pdwSize = size;
1499  }
1500  else
1501  {
1502  memcpy(pTheirUdpTable, pOurUdpTable, size);
1503 
1504  if (bOrder)
1505  qsort(pTheirUdpTable->table, pTheirUdpTable->dwNumEntries,
1507  }
1508 
1509  HeapFree(GetProcessHeap(), 0, pOurUdpTable);
1510  }
1511  }
1512  break;
1513 
1515  {
1517  PMIB_UDPTABLE_OWNER_MODULE pTheirUdpTable = pUdpTable;
1518 
1519  if (pOurUdpTable)
1520  {
1522  if (size > *pdwSize || !pTheirUdpTable)
1523  {
1524  *pdwSize = size;
1526  }
1527  else
1528  {
1529  memcpy(pTheirUdpTable, pOurUdpTable, size);
1530 
1531  if (bOrder)
1532  qsort(pTheirUdpTable->table, pTheirUdpTable->dwNumEntries,
1534  }
1535 
1536  HeapFree(GetProcessHeap(), 0, pOurUdpTable);
1537  }
1538  }
1539  break;
1540 
1541  default:
1543  break;
1544  }
1545 
1546  return ret;
1547 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
struct _MIB_UDPROW MIB_UDPROW
struct _MIB_UDPROW_OWNER_PID MIB_UDPROW_OWNER_PID
#define NO_ERROR
Definition: dderror.h:5
MIB_UDPROW_OWNER_PID table[1]
Definition: udpmib.h:48
DWORD dwNumEntries
Definition: udpmib.h:34
MIB_UDPROW_OWNER_MODULE table[1]
Definition: udpmib.h:71
void __cdecl qsort(_Inout_updates_bytes_(_NumOfElements *_SizeOfElements) void *_Base, _In_ size_t _NumOfElements, _In_ size_t _SizeOfElements, _In_ int(__cdecl *_PtFuncCompare)(const void *, const void *))
static int UdpTableSorter(const void *a, const void *b)
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:595
MIB_UDPROW table[1]
Definition: udpmib.h:35
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
struct _MIB_UDPROW_OWNER_MODULE MIB_UDPROW_OWNER_MODULE
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define AF_INET
Definition: tcpip.h:117
#define UNIMPLEMENTED
Definition: debug.h:115
PVOID getUdpTable(CLASS_TABLE Class)
#define HeapFree(x, y, z)
Definition: compat.h:594
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by AllocateAndGetUdpExTable2FromStack(), AllocateAndGetUdpExTableFromStack(), GetExtendedUdpTableWithAlloc(), GetUdpTable(), and ShowUdpTable().

◆ GetFriendlyIfIndex()

DWORD WINAPI GetFriendlyIfIndex ( DWORD  IfIndex)

Definition at line 1563 of file iphlpapi_main.c.

1564 {
1565  /* windows doesn't validate these, either, just makes sure the top byte is
1566  cleared. I assume my ifenum module never gives an index with the top
1567  byte set. */
1568  TRACE("returning %ld\n", IfIndex);
1569  return IfIndex;
1570 }
#define TRACE(s)
Definition: solgame.cpp:4

◆ GetIcmpStatistics()

DWORD WINAPI GetIcmpStatistics ( PMIB_ICMP  pStats)

Definition at line 1586 of file iphlpapi_main.c.

1587 {
1588  DWORD ret;
1589 
1590  TRACE("pStats %p\n", pStats);
1591  ret = getICMPStats(pStats);
1592  TRACE("returning %ld\n", ret);
1593  return ret;
1594 }
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
DWORD getICMPStats(MIB_ICMP *stats)

Referenced by mib2IcmpInit(), and ShowIcmpStatistics().

◆ GetIcmpStatisticsEx()

DWORD WINAPI GetIcmpStatisticsEx ( PMIB_ICMP_EX  pStats,
DWORD  dwFamily 
)

Definition at line 3396 of file iphlpapi_main.c.

3397 {
3398  FIXME(":stub\n");
3399 
3400  if (!pStats)
3401  return ERROR_INVALID_PARAMETER;
3402 
3403  if (dwFamily != AF_INET && dwFamily != AF_INET6)
3404  return ERROR_INVALID_PARAMETER;
3405 
3406  return 0L;
3407 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define FIXME(fmt,...)
Definition: debug.h:111
#define AF_INET6
Definition: winsock.h:369
static const WCHAR L[]
Definition: oid.c:1250
#define AF_INET
Definition: tcpip.h:117

◆ GetIfEntry()

DWORD WINAPI GetIfEntry ( PMIB_IFROW  pIfRow)

Definition at line 1610 of file iphlpapi_main.c.

1611 {
1612  DWORD ret;
1613  const char *name;
1614 
1615  TRACE("pIfRow %p\n", pIfRow);
1616  if (!pIfRow)
1617  return ERROR_INVALID_PARAMETER;
1618 
1620  if (name) {
1621  ret = getInterfaceEntryByIndex(pIfRow->dwIndex, pIfRow);
1622  if (ret == NO_ERROR)
1623  ret = getInterfaceStatsByName(name, pIfRow);
1625  }
1626  else
1628  TRACE("returning %ld\n", ret);
1629  return ret;
1630 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define NO_ERROR
Definition: dderror.h:5
void consumeInterfaceName(const char *ifname)
const char * getInterfaceNameByIndex(DWORD index)
DWORD getInterfaceStatsByName(const char *name, PMIB_IFROW entry)
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
DWORD getInterfaceEntryByIndex(DWORD index, PMIB_IFROW entry)
#define ERROR_INVALID_DATA
Definition: winerror.h:116
Definition: name.c:38
DWORD dwIndex
Definition: ifmib.h:38
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by CNetConnectionManager::EnumerateINetConnections(), GetIfTable(), CNetConnection::GetProperties(), NetBTAstat(), ShowInfo(), UpdateLanStatus(), and WkstaEnumAdaptersCallback().

◆ GetIfTable()

DWORD WINAPI GetIfTable ( PMIB_IFTABLE  pIfTable,
PULONG  pdwSize,
BOOL  bOrder 
)

Definition at line 1660 of file iphlpapi_main.c.

1661 {
1662  DWORD ret;
1663 
1664  TRACE("pIfTable %p, pdwSize %p, bOrder %ld\n", pdwSize, pdwSize,
1665  (DWORD)bOrder);
1666  if (!pdwSize)
1668  else {
1669  DWORD numInterfaces = getNumInterfaces();
1670  ULONG size;
1671  TRACE("GetIfTable: numInterfaces = %d\n", (int)numInterfaces);
1672  size = sizeof(MIB_IFTABLE) + (numInterfaces - 1) * sizeof(MIB_IFROW);
1673 
1674  if (!pIfTable || *pdwSize < size) {
1675  *pdwSize = size;
1677  }
1678  else {
1680 
1681  if (table) {
1682  size = sizeof(MIB_IFTABLE) + (table->numIndexes - 1) *
1683  sizeof(MIB_IFROW);
1684  if (*pdwSize < size) {
1685  *pdwSize = size;
1687  }
1688  else {
1689  DWORD ndx;
1690 
1691  pIfTable->dwNumEntries = 0;
1692  for (ndx = 0; ndx < table->numIndexes; ndx++) {
1693  pIfTable->table[ndx].dwIndex = table->indexes[ndx];
1694  GetIfEntry(&pIfTable->table[ndx]);
1695  pIfTable->dwNumEntries++;
1696  }
1697  if (bOrder)
1698  qsort(pIfTable->table, pIfTable->dwNumEntries, sizeof(MIB_IFROW),
1699  IfTableSorter);
1700  ret = NO_ERROR;
1701  }
1702  free(table);
1703  }
1704  else
1706  }
1707  }
1708  TRACE("returning %ld\n", ret);
1709  return ret;
1710 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
MIB_IFROW table[1]
Definition: ifmib.h:66
InterfaceIndexTable * getInterfaceIndexTable(void)
#define free
Definition: debug_ros.c:5
#define NO_ERROR
Definition: dderror.h:5
static int IfTableSorter(const void *a, const void *b)
void __cdecl qsort(_Inout_updates_bytes_(_NumOfElements *_SizeOfElements) void *_Base, _In_ size_t _NumOfElements, _In_ size_t _SizeOfElements, _In_ int(__cdecl *_PtFuncCompare)(const void *, const void *))
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
struct _MIB_IFTABLE MIB_IFTABLE
DWORD getNumInterfaces(void)
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
DWORD dwNumEntries
Definition: ifmib.h:65
DWORD WINAPI GetIfEntry(PMIB_IFROW pIfRow)
unsigned int ULONG
Definition: retypes.h:1
DWORD dwIndex
Definition: ifmib.h:38
struct _MIB_IFROW MIB_IFROW
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by AdapterDiscoveryThread(), AllocateAndGetIfTableFromStack(), CNetConnectionManager::EnumerateINetConnections(), mib2IfNumberInit(), and ShowEthernetStatistics().

◆ getInterfaceGatewayByIndex()

DWORD getInterfaceGatewayByIndex ( DWORD  index)

Definition at line 76 of file iphlpapi_main.c.

77 {
78  DWORD ndx, retVal = 0, numRoutes = getNumRoutes();
80  if (!table) return 0;
81 
82  for (ndx = 0; ndx < numRoutes; ndx++)
83  {
84  if ((table->routes[ndx].ifIndex == (index)) && (table->routes[ndx].dest == 0))
85  retVal = table->routes[ndx].gateway;
86  }
88  return retVal;
89 }
RouteTable * getRouteTable(void)
DWORD getNumRoutes(void)
GLuint index
Definition: glext.h:6031
#define GetProcessHeap()
Definition: compat.h:595
unsigned long DWORD
Definition: ntddk_ex.h:95
#define HeapFree(x, y, z)
Definition: compat.h:594

Referenced by GetAdaptersInfo().

◆ GetInterfaceInfo()

DWORD WINAPI GetInterfaceInfo ( PIP_INTERFACE_INFO  pIfTable,
PULONG  dwOutBufLen 
)

Definition at line 1727 of file iphlpapi_main.c.

1728 {
1729  DWORD ret;
1730 
1731  TRACE("pIfTable %p, dwOutBufLen %p\n", pIfTable, dwOutBufLen);
1732  if (!dwOutBufLen)
1734  else {
1735  DWORD numNonLoopbackInterfaces = getNumNonLoopbackInterfaces();
1736  ULONG size;
1737  TRACE("numNonLoopbackInterfaces == 0x%x\n", numNonLoopbackInterfaces);
1738  size = sizeof(IP_INTERFACE_INFO) + (numNonLoopbackInterfaces) *
1739  sizeof(IP_ADAPTER_INDEX_MAP);
1740 
1741  if (!pIfTable || *dwOutBufLen < size) {
1742  *dwOutBufLen = size;
1744  }
1745  else {
1747 
1748  if (table) {
1749  TRACE("table->numIndexes == 0x%x\n", table->numIndexes);
1750  size = sizeof(IP_INTERFACE_INFO) + (table->numIndexes) *
1751  sizeof(IP_ADAPTER_INDEX_MAP);
1752  if (*dwOutBufLen < size) {
1753  *dwOutBufLen = size;
1755  }
1756  else {
1757  DWORD ndx;
1758 
1759  pIfTable->NumAdapters = 0;
1760  for (ndx = 0; ndx < table->numIndexes; ndx++) {
1761  const char *walker, *name;
1762  WCHAR *assigner;
1763 
1764  pIfTable->Adapter[ndx].Index = table->indexes[ndx];
1765  name = getInterfaceNameByIndex(table->indexes[ndx]);
1766  for (walker = name, assigner = pIfTable->Adapter[ndx].Name;
1767  walker && *walker &&
1768  assigner - pIfTable->Adapter[ndx].Name < MAX_ADAPTER_NAME - 1;
1769  walker++, assigner++)
1770  *assigner = *walker;
1771  *assigner = 0;
1773  pIfTable->NumAdapters++;
1774  }
1775  ret = NO_ERROR;
1776  }
1777  free(table);
1778  }
1779  else
1781  }
1782  }
1783  TRACE("returning %ld\n", ret);
1784  return ret;
1785 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
IP_ADAPTER_INDEX_MAP Adapter[1]
Definition: ipexport.h:152
#define free
Definition: debug_ros.c:5
#define NO_ERROR
Definition: dderror.h:5
InterfaceIndexTable * getNonLoopbackInterfaceIndexTable(void)
DWORD getNumNonLoopbackInterfaces(void)
void consumeInterfaceName(const char *ifname)
const char * getInterfaceNameByIndex(DWORD index)
WCHAR Name[MAX_ADAPTER_NAME]
Definition: ipexport.h:147
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
struct _IP_ADAPTER_INDEX_MAP IP_ADAPTER_INDEX_MAP
Definition: name.c:38
#define MAX_ADAPTER_NAME
Definition: ipexport.h:143
unsigned int ULONG
Definition: retypes.h:1
struct _IP_INTERFACE_INFO IP_INTERFACE_INFO
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
GLuint const GLchar * name
Definition: glext.h:6031

Referenced by OpenAdapterHandle(), Release(), Renew(), and test_GetInterfaceName().

◆ GetInterfaceNameInternal()

DWORD GetInterfaceNameInternal ( _In_ const GUID pInterfaceGUID,
_Out_writes_bytes_to_ *, *pOutBufLen PWCHAR  pInterfaceName,
_Inout_ PULONG  pOutBufLen 
)

Definition at line 3416 of file iphlpapi_main.c.

3419 {
3421  DWORD result, type;
3422  WCHAR szKeyName[2*MAX_PATH];
3423  HRESULT hr;
3424  HKEY hKey;
3425 
3426  if (pInterfaceGUID == NULL || pOutBufLen == NULL)
3427  return ERROR_INVALID_PARAMETER;
3428 
3429  result = RtlStringFromGUID(pInterfaceGUID, &GuidString);
3430 
3431  if (!NT_SUCCESS(result))
3432  {
3433  // failed to convert guid to string
3434  return RtlNtStatusToDosError(result);
3435  }
3436 
3437  hr = StringCbPrintfW(szKeyName, sizeof(szKeyName), L"SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\%s\\Connection", GuidString.Buffer);
3439 
3440  if (FAILED(hr))
3441  {
3442  // key name is too long
3443  return ERROR_BUFFER_OVERFLOW;
3444  }
3445 
3446  result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, szKeyName, 0, KEY_READ, &hKey);
3447 
3448  if (result != ERROR_SUCCESS)
3449  {
3450  // failed to find adapter entry
3451  return ERROR_NOT_FOUND;
3452  }
3453 
3454  result = RegQueryValueExW(hKey, L"Name", NULL, &type, (PVOID)pInterfaceName, pOutBufLen);
3455 
3456  RegCloseKey(hKey);
3457 
3458  if (result == ERROR_MORE_DATA)
3459  {
3460  *pOutBufLen = MAX_INTERFACE_NAME_LEN * 2;
3462  }
3463 
3464  if (result != ERROR_SUCCESS || type != REG_SZ)
3465  {
3466  // failed to read adapter name
3467  return ERROR_NO_DATA;
3468  }
3469  return ERROR_SUCCESS;
3470 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
static PWSTR GuidString
Definition: apphelp.c:93
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
GLuint64EXT * result
Definition: glext.h:11304
#define KEY_READ
Definition: nt_native.h:1023
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
STRSAFEAPI StringCbPrintfW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszFormat,...)
Definition: strsafe.h:557
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
LONG HRESULT
Definition: typedefs.h:79
#define ERROR_NO_DATA
Definition: winerror.h:284
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
static const WCHAR L[]
Definition: oid.c:1250
#define MAX_INTERFACE_NAME_LEN
Definition: ifmib.h:31
#define ERROR_MORE_DATA
Definition: dderror.h:13
FxAutoRegKey hKey
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
#define NULL
Definition: types.h:112
#define ERROR_NOT_FOUND
Definition: winerror.h:690
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
#define REG_SZ
Definition: layer.c:22

Referenced by NhGetInterfaceNameFromDeviceGuid(), and NhGetInterfaceNameFromGuid().

◆ GetIpAddrTable()

DWORD WINAPI GetIpAddrTable ( PMIB_IPADDRTABLE  pIpAddrTable,
PULONG  pdwSize,
BOOL  bOrder 
)

Definition at line 1815 of file iphlpapi_main.c.

1816 {
1817  DWORD ret;
1818 
1819  TRACE("pIpAddrTable %p, pdwSize %p, bOrder %ld\n", pIpAddrTable, pdwSize,
1820  (DWORD)bOrder);
1821  if (!pdwSize)
1823  else {
1824  DWORD numInterfaces = getNumInterfaces();
1825  ULONG size = sizeof(MIB_IPADDRTABLE) + (numInterfaces - 1) *
1826  sizeof(MIB_IPADDRROW);
1827 
1828  if (!pIpAddrTable || *pdwSize < size) {
1829  *pdwSize = size;
1831  }
1832  else {
1834 
1835  if (table) {
1836  size = sizeof(MIB_IPADDRTABLE) + (table->numIndexes - 1) *
1837  sizeof(MIB_IPADDRROW);
1838  if (*pdwSize < size) {
1839  *pdwSize = size;
1841  }
1842  else {
1843  DWORD ndx, bcast;
1844 
1845  pIpAddrTable->dwNumEntries = 0;
1846  for (ndx = 0; ndx < table->numIndexes; ndx++) {
1847  pIpAddrTable->table[ndx].dwIndex = table->indexes[ndx];
1848  pIpAddrTable->table[ndx].dwAddr =
1849  getInterfaceIPAddrByIndex(table->indexes[ndx]);
1850  pIpAddrTable->table[ndx].dwMask =
1851  getInterfaceMaskByIndex(table->indexes[ndx]);
1852  /* the dwBCastAddr member isn't the broadcast address, it indicates
1853  * whether the interface uses the 1's broadcast address (1) or the
1854  * 0's broadcast address (0).
1855  */
1856  bcast = getInterfaceBCastAddrByIndex(table->indexes[ndx]);
1857  pIpAddrTable->table[ndx].dwBCastAddr =
1858  (bcast & pIpAddrTable->table[ndx].dwMask) ? 1 : 0;
1859  /* FIXME: hardcoded reasm size, not sure where to get it */
1860  pIpAddrTable->table[ndx].dwReasmSize = 65535;
1861  pIpAddrTable->table[ndx].unused1 = 0;
1862  pIpAddrTable->table[ndx].wType = 0; /* aka unused2 */
1863  pIpAddrTable->dwNumEntries++;
1864  }
1865  if (bOrder)
1866  qsort(pIpAddrTable->table, pIpAddrTable->dwNumEntries,
1867  sizeof(MIB_IPADDRROW), IpAddrTableSorter);
1868  ret = NO_ERROR;
1869  }
1870  free(table);
1871  }
1872  else
1874  }
1875  }
1876  TRACE("returning %ld\n", ret);
1877  return ret;
1878 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
struct _MIB_IPADDRTABLE MIB_IPADDRTABLE
InterfaceIndexTable * getInterfaceIndexTable(void)
#define free
Definition: debug_ros.c:5
static int IpAddrTableSorter(const void *a, const void *b)
#define NO_ERROR
Definition: dderror.h:5
DWORD dwReasmSize
Definition: ipmib.h:40
DWORD getInterfaceBCastAddrByIndex(DWORD index)
void __cdecl qsort(_Inout_updates_bytes_(_NumOfElements *_SizeOfElements) void *_Base, _In_ size_t _NumOfElements, _In_ size_t _SizeOfElements, _In_ int(__cdecl *_PtFuncCompare)(const void *, const void *))
unsigned short wType
Definition: ipmib.h:42
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
DWORD dwBCastAddr
Definition: ipmib.h:39
DWORD getNumInterfaces(void)
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD getInterfaceMaskByIndex(DWORD index)
unsigned short unused1
Definition: ipmib.h:41
int ret
DWORD dwMask
Definition: ipmib.h:38
struct _MIB_IPADDRROW MIB_IPADDRROW
DWORD dwNumEntries
Definition: ipmib.h:47
IF_INDEX dwIndex
Definition: ipmib.h:37
unsigned int ULONG
Definition: retypes.h:1
DWORD dwAddr
Definition: ipmib.h:36
DWORD getInterfaceIPAddrByIndex(DWORD index)
MIB_IPADDRROW table[1]
Definition: ipmib.h:48
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by AllocateAndGetIpAddrTableFromStack(), DisplayArpEntries(), mib2IpAddrInit(), NetBTEnum(), and Test_WSAIoctl_InitTest().

◆ GetIpErrorString()

DWORD WINAPI GetIpErrorString ( IP_STATUS  ErrorCode,
PWCHAR  Buffer,
PDWORD  Size 
)

Definition at line 3149 of file iphlpapi_main.c.

3150 {
3151  FIXME(":stub\n");
3152  return 0L;
3153 }
#define FIXME(fmt,...)
Definition: debug.h:111
static const WCHAR L[]
Definition: oid.c:1250

◆ GetIpForwardTable()

DWORD WINAPI GetIpForwardTable ( PMIB_IPFORWARDTABLE  pIpForwardTable,
PULONG  pdwSize,
BOOL  bOrder 
)

Definition at line 1919 of file iphlpapi_main.c.

1920 {
1921  DWORD ret;
1922 
1923  TRACE("pIpForwardTable %p, pdwSize %p, bOrder %ld\n", pIpForwardTable,
1924  pdwSize, (DWORD)bOrder);
1925  if (!pdwSize)
1927  else {
1928  DWORD numRoutes = getNumRoutes();
1929  ULONG sizeNeeded = sizeof(MIB_IPFORWARDTABLE) + (numRoutes - 1) *
1930  sizeof(MIB_IPFORWARDROW);
1931 
1932  if (!pIpForwardTable || *pdwSize < sizeNeeded) {
1933  *pdwSize = sizeNeeded;
1935  }
1936  else {
1938  if (table) {
1939  sizeNeeded = sizeof(MIB_IPFORWARDTABLE) + (table->numRoutes - 1) *
1940  sizeof(MIB_IPFORWARDROW);
1941  if (*pdwSize < sizeNeeded) {
1942  *pdwSize = sizeNeeded;
1944  }
1945  else {
1946  DWORD ndx;
1947 
1948  pIpForwardTable->dwNumEntries = table->numRoutes;
1949  for (ndx = 0; ndx < numRoutes; ndx++) {
1950  pIpForwardTable->table[ndx].dwForwardIfIndex =
1951  table->routes[ndx].ifIndex;
1952  pIpForwardTable->table[ndx].dwForwardDest =
1953  table->routes[ndx].dest;
1954  pIpForwardTable->table[ndx].dwForwardMask =
1955  table->routes[ndx].mask;
1956  pIpForwardTable->table[ndx].dwForwardPolicy = 0;
1957  pIpForwardTable->table[ndx].dwForwardNextHop =
1958  table->routes[ndx].gateway;
1959  /* FIXME: this type is appropriate for local interfaces; may not
1960  always be appropriate */
1961  pIpForwardTable->table[ndx].dwForwardType = MIB_IPROUTE_TYPE_DIRECT;
1962  /* FIXME: other protos might be appropriate, e.g. the default route
1963  is typically set with MIB_IPPROTO_NETMGMT instead */
1964  pIpForwardTable->table[ndx].dwForwardProto = MIB_IPPROTO_LOCAL;
1965  /* punt on age and AS */
1966  pIpForwardTable->table[ndx].dwForwardAge = 0;
1967  pIpForwardTable->table[ndx].dwForwardNextHopAS = 0;
1968  pIpForwardTable->table[ndx].dwForwardMetric1 =
1969  table->routes[ndx].metric;
1970  /* rest of the metrics are 0.. */
1971  pIpForwardTable->table[ndx].dwForwardMetric2 = 0;
1972  pIpForwardTable->table[ndx].dwForwardMetric3 = 0;
1973  pIpForwardTable->table[ndx].dwForwardMetric4 = 0;
1974  pIpForwardTable->table[ndx].dwForwardMetric5 = 0;
1975  }
1976  if (bOrder)
1977  qsort(pIpForwardTable->table, pIpForwardTable->dwNumEntries,
1979  ret = NO_ERROR;
1980  }
1981  HeapFree(GetProcessHeap(), 0, table);
1982  }
1983  else
1985  }
1986  }
1987  TRACE("returning %ld\n", ret);
1988  return ret;
1989 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
DWORD dwForwardMetric4
Definition: ipmib.h:91
DWORD dwForwardType
Definition: ipmib.h:78
RouteTable * getRouteTable(void)
DWORD dwForwardNextHopAS
Definition: ipmib.h:87
DWORD dwForwardMask
Definition: ipmib.h:72
DWORD dwForwardMetric5
Definition: ipmib.h:92
#define NO_ERROR
Definition: dderror.h:5
DWORD dwForwardMetric3
Definition: ipmib.h:90
DWORD dwForwardAge
Definition: ipmib.h:86
void __cdecl qsort(_Inout_updates_bytes_(_NumOfElements *_SizeOfElements) void *_Base, _In_ size_t _NumOfElements, _In_ size_t _SizeOfElements, _In_ int(__cdecl *_PtFuncCompare)(const void *, const void *))
DWORD dwForwardMetric2
Definition: ipmib.h:89
DWORD getNumRoutes(void)
IF_INDEX dwForwardIfIndex
Definition: ipmib.h:75
#define TRACE(s)
Definition: solgame.cpp:4
DWORD dwForwardNextHop
Definition: ipmib.h:74
#define GetProcessHeap()
Definition: compat.h:595
static int IpForwardTableSorter(const void *a, const void *b)
DWORD dwNumEntries
Definition: ipmib.h:97
DWORD dwForwardDest
Definition: ipmib.h:71
unsigned long DWORD
Definition: ntddk_ex.h:95
MIB_IPFORWARDROW table[1]
Definition: ipmib.h:98
int ret
DWORD dwForwardPolicy
Definition: ipmib.h:73
struct _MIB_IPFORWARDTABLE MIB_IPFORWARDTABLE
struct _MIB_IPFORWARDROW MIB_IPFORWARDROW
unsigned int ULONG
Definition: retypes.h:1
DWORD dwForwardProto
Definition: ipmib.h:83
DWORD dwForwardMetric1
Definition: ipmib.h:88
#define HeapFree(x, y, z)
Definition: compat.h:594
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by AllocateAndGetIpForwardTableFromStack(), fill_ip4routetable(), INetCfgComponentControl_fnApplyRegistryChanges(), mib2IpRouteInit(), and PrintRoutes().

◆ GetIpNetTable()

DWORD WINAPI GetIpNetTable ( PMIB_IPNETTABLE  pIpNetTable,
PULONG  pdwSize,
BOOL  bOrder 
)

Definition at line 2019 of file iphlpapi_main.c.

2020 {
2021  DWORD ret = NO_ERROR;
2022 
2023  TRACE("pIpNetTable %p, pdwSize %p, bOrder %d\n", pIpNetTable, pdwSize,
2024  (DWORD)bOrder);
2025  if (!pdwSize)
2027  else {
2028  DWORD numEntries = getNumArpEntries();
2029  ULONG size = sizeof(MIB_IPNETTABLE);
2030 
2031  if (numEntries > 1)
2032  size += (numEntries - 1) * sizeof(MIB_IPNETROW);
2033  if (!pIpNetTable || *pdwSize < size) {
2034  *pdwSize = size;
2036  }
2037  else {
2039  if (table) {
2040  size = sizeof(MIB_IPNETTABLE);
2041  if (table->dwNumEntries > 1)
2042  size += (table->dwNumEntries - 1) * sizeof(MIB_IPNETROW);
2043  if (*pdwSize < size) {
2044  *pdwSize = size;
2046  }
2047  else {
2048  *pdwSize = size;
2049  memcpy(pIpNetTable, table, size);
2050  if (bOrder)
2051  qsort(pIpNetTable->table, pIpNetTable->dwNumEntries,
2052  sizeof(MIB_IPNETROW), IpNetTableSorter);
2053  ret = NO_ERROR;
2054  }
2055  HeapFree(GetProcessHeap(), 0, table);
2056  }
2057  }
2058  }
2059  TRACE("returning %d\n", ret);
2060  return ret;
2061 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
DWORD getNumArpEntries(void)
struct _MIB_IPNETTABLE MIB_IPNETTABLE
#define NO_ERROR
Definition: dderror.h:5
void __cdecl qsort(_Inout_updates_bytes_(_NumOfElements *_SizeOfElements) void *_Base, _In_ size_t _NumOfElements, _In_ size_t _SizeOfElements, _In_ int(__cdecl *_PtFuncCompare)(const void *, const void *))
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:595
unsigned long DWORD
Definition: ntddk_ex.h:95
PMIB_IPNETTABLE getArpTable(void)
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
MIB_IPNETROW table[1]
Definition: ipmib.h:128
unsigned int ULONG
Definition: retypes.h:1
static int IpNetTableSorter(const void *a, const void *b)
#define HeapFree(x, y, z)
Definition: compat.h:594
DWORD dwNumEntries
Definition: ipmib.h:127
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by Addhost(), AllocateAndGetIpNetTableFromStack(), Deletehost(), DisplayArpEntries(), and mib2IpNetInit().

◆ GetIpStatistics()

DWORD WINAPI GetIpStatistics ( PMIB_IPSTATS  pStats)

Definition at line 2077 of file iphlpapi_main.c.

2078 {
2079  return GetIpStatisticsEx(pStats, PF_INET);
2080 }
DWORD WINAPI GetIpStatisticsEx(PMIB_IPSTATS pStats, DWORD dwFamily)
#define PF_INET
Definition: winsock.h:373

Referenced by mib2IpStatsInit(), and ShowIpStatistics().

◆ GetIpStatisticsEx()

DWORD WINAPI GetIpStatisticsEx ( PMIB_IPSTATS  pStats,
DWORD  dwFamily 
)

Definition at line 2096 of file iphlpapi_main.c.

2097 {
2098  DWORD ret;
2099 
2100  TRACE("pStats %p\n", pStats);
2101  ret = getIPStats(pStats, dwFamily);
2102  TRACE("returning %ld\n", ret);
2103  return ret;
2104 }
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD getIPStats(PMIB_IPSTATS stats, DWORD family)
int ret

Referenced by GetIpStatistics().

◆ GetNetworkParams()

DWORD WINAPI GetNetworkParams ( PFIXED_INFO  pFixedInfo,
PULONG  pOutBufLen 
)

Definition at line 2120 of file iphlpapi_main.c.

2121 {
2122  DWORD ret, size, type;
2123  LONG regReturn;
2124  HKEY hKey;
2125  PIPHLP_RES_INFO resInfo;
2126 
2127  TRACE("pFixedInfo %p, pOutBufLen %p\n", pFixedInfo, pOutBufLen);
2128  if (!pOutBufLen)
2129  return ERROR_INVALID_PARAMETER;
2130 
2131  resInfo = getResInfo();
2132  if (!resInfo)
2133  return ERROR_OUTOFMEMORY;
2134 
2135  size = sizeof(FIXED_INFO) + (resInfo->riCount > 1 ? (resInfo->riCount-1) *
2136  sizeof(IP_ADDR_STRING) : 0);
2137  if (!pFixedInfo || *pOutBufLen < size) {
2138  *pOutBufLen = size;
2139  disposeResInfo( resInfo );
2140  return ERROR_BUFFER_OVERFLOW;
2141  }
2142 
2143  memset(pFixedInfo, 0, size);
2144  /* Check for DhcpHostname and DhcpDomain first */
2145  regReturn = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
2146  "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters",
2147  0,
2148  KEY_READ,
2149  &hKey);
2150  if (regReturn == ERROR_SUCCESS) {
2151  /* Windows doesn't honor DHCP option 12 even if RFC requires it if it is returned by DHCP server! */
2152 #if 0
2153  type = REG_SZ;
2154  size = sizeof(pFixedInfo->HostName);
2155  regReturn = RegQueryValueExA(hKey,
2156  "DhcpHostname",
2157  NULL,
2158  &type,
2159  (LPBYTE)pFixedInfo->HostName,
2160  &size);
2161  if (regReturn == ERROR_FILE_NOT_FOUND || (regReturn == ERROR_SUCCESS && size < 1))
2162  {
2163 #endif
2164  type = REG_SZ;
2165  size = sizeof(pFixedInfo->HostName);
2166  regReturn = RegQueryValueExA(hKey,
2167  "Hostname",
2168  NULL,
2169  &type,
2170  (LPBYTE)pFixedInfo->HostName,
2171  &size);
2172 #if 0
2173  }
2174 #endif
2175 
2176  type = REG_SZ;
2177  size = sizeof(pFixedInfo->DomainName);
2178  regReturn = RegQueryValueExA(hKey,
2179  "DhcpDomain",
2180  NULL,
2181  &type,
2182  (LPBYTE)pFixedInfo->DomainName,
2183  &size);
2184  if (regReturn == ERROR_FILE_NOT_FOUND || (regReturn == ERROR_SUCCESS && size < 1))
2185  {
2186  type = REG_SZ;
2187  size = sizeof(pFixedInfo->DomainName);
2188  regReturn = RegQueryValueExA(hKey,
2189  "Domain",
2190  NULL,
2191  &type,
2192  (LPBYTE)pFixedInfo->DomainName,
2193  &size);
2194  }
2195  RegCloseKey(hKey);
2196  }
2197 
2198  TRACE("GetComputerNameExA: %s\n", pFixedInfo->DomainName);
2199 
2200  if (resInfo->riCount > 0)
2201  {
2202  CopyMemory(&pFixedInfo->DnsServerList, resInfo->DnsList, sizeof(IP_ADDR_STRING));
2203  if (resInfo->riCount > 1)
2204  {
2205  IP_ADDR_STRING *pSrc = resInfo->DnsList->Next;
2206  IP_ADDR_STRING *pTarget = (struct _IP_ADDR_STRING*)((char*)pFixedInfo + sizeof(FIXED_INFO));
2207 
2208  pFixedInfo->DnsServerList.Next = pTarget;
2209 
2210  do
2211  {
2212  CopyMemory(pTarget, pSrc, sizeof(IP_ADDR_STRING));
2213  resInfo->riCount--;
2214  if (resInfo->riCount > 1)
2215  {
2216  pTarget->Next = (IP_ADDR_STRING*)((char*)pTarget + sizeof(IP_ADDR_STRING));
2217  pTarget = pTarget->Next;
2218  pSrc = pSrc->Next;
2219  }
2220  else
2221  {
2222  pTarget->Next = NULL;
2223  break;
2224  }
2225  }
2226  while(TRUE);
2227  }
2228  else
2229  {
2230  pFixedInfo->DnsServerList.Next = NULL;
2231  }
2232  }
2233 
2234  pFixedInfo->NodeType = HYBRID_NODETYPE;
2235  regReturn = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
2236  "SYSTEM\\CurrentControlSet\\Services\\VxD\\MSTCP", 0, KEY_READ, &hKey);
2237  if (regReturn != ERROR_SUCCESS)
2238  regReturn = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
2239  "SYSTEM\\CurrentControlSet\\Services\\NetBT\\Parameters", 0, KEY_READ,
2240  &hKey);
2241  if (regReturn == ERROR_SUCCESS)
2242  {
2243  DWORD size = sizeof(pFixedInfo->ScopeId);
2244 
2245  RegQueryValueExA(hKey, "ScopeID", NULL, NULL, (PBYTE)pFixedInfo->ScopeId, &size);
2246  RegCloseKey(hKey);
2247  }
2248 
2249  disposeResInfo( resInfo );
2250  /* FIXME: can check whether routing's enabled in /proc/sys/net/ipv4/ip_forward
2251  I suppose could also check for a listener on port 53 to set EnableDns */
2252  ret = NO_ERROR;
2253  TRACE("returning %ld\n", ret);
2254 
2255  return ret;
2256 }
FxIoTarget * pTarget
Definition: fxdeviceapi.cpp:97
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
LONG WINAPI RegQueryValueExA(_In_ HKEY hkeyorg, _In_ LPCSTR name, _In_ LPDWORD reserved, _Out_opt_ LPDWORD type, _Out_opt_ LPBYTE data, _Inout_opt_ LPDWORD count)
Definition: reg.c:4023
DWORD riCount
Definition: resinfo.h:25
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
VOID disposeResInfo(PIPHLP_RES_INFO InfoPtr)
Definition: resinfo.c:60
struct _IP_ADDR_STRING * Next
Definition: iptypes.h:46
LONG WINAPI RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3331
#define NO_ERROR
Definition: dderror.h:5
IP_ADDR_STRING * DnsList
Definition: resinfo.h:26
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:53
long LONG
Definition: pedump.c:60
char DomainName[MAX_DOMAIN_NAME_LEN+4]
Definition: iptypes.h:82
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
#define CopyMemory
Definition: winbase.h:1662
UINT NodeType
Definition: iptypes.h:85
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
PIPHLP_RES_INFO getResInfo()
Definition: resinfo.c:54
char HostName[MAX_HOSTNAME_LEN+4]
Definition: iptypes.h:81
#define HYBRID_NODETYPE
Definition: iptypes.h:39
FxAutoRegKey hKey
#define NULL
Definition: types.h:112
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
IP_ADDR_STRING DnsServerList
Definition: iptypes.h:84
#define memset(x, y, z)
Definition: compat.h:39
char ScopeId[MAX_SCOPE_ID_LEN+4]
Definition: iptypes.h:86
BYTE * PBYTE
Definition: pedump.c:66
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
struct _IP_ADDR_STRING IP_ADDR_STRING
#define REG_SZ
Definition: layer.c:22

Referenced by getdomainname(), main(), Query_Main(), ShowInfo(), test_GetNetworkParams(), and TestHostName().

◆ GetNumberOfInterfaces()

DWORD WINAPI GetNumberOfInterfaces ( PDWORD  pdwNumIf)

Definition at line 2272 of file iphlpapi_main.c.

2273 {
2274  DWORD ret;
2275 
2276  TRACE("pdwNumIf %p\n", pdwNumIf);
2277  if (!pdwNumIf)
2279  else {
2280  *pdwNumIf = getNumInterfaces();
2281  ret = NO_ERROR;
2282  }
2283  TRACE("returning %ld\n", ret);
2284  return ret;
2285 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define NO_ERROR
Definition: dderror.h:5
#define TRACE(s)
Definition: solgame.cpp:4
DWORD getNumInterfaces(void)
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret

Referenced by _RpcEnumInterfaces().

◆ GetOwnerModuleFromPidEntry()

static DWORD GetOwnerModuleFromPidEntry ( DWORD  OwningPid,
TCPIP_OWNER_MODULE_INFO_CLASS  Class,
PVOID  Buffer,
PDWORD  pdwSize 
)
static

Definition at line 2288 of file iphlpapi_main.c.

2289 {
2290  HANDLE Process;
2291  DWORD FileLen, PathLen, Error;
2294 
2295  if (IsBadWritePtr(pdwSize, sizeof(DWORD)) ||
2296  IsBadWritePtr(Buffer, *pdwSize))
2297  {
2298  return ERROR_INVALID_PARAMETER;
2299  }
2300 
2301  if (OwningPid == 0)
2302  {
2303  return ERROR_NOT_FOUND;
2304  }
2305 
2307  if (Process == NULL)
2308  {
2309  return GetLastError();
2310  }
2311 
2313  if (FileLen != 0)
2314  {
2316  if (PathLen == 0)
2317  {
2319  return GetLastError();
2320  }
2321 
2322  /* Add NULL char */
2323  ++FileLen;
2324  ++PathLen;
2325  PathLen *= sizeof(WCHAR);
2326  FileLen *= sizeof(WCHAR);
2327  }
2328  else
2329  {
2330  Error = GetLastError();
2331 
2332  if (Error == ERROR_PARTIAL_COPY)
2333  {
2334  wcscpy(File, L"System");
2335  wcscpy(Path, L"System");
2336 
2337  PathLen = sizeof(L"System");
2338  FileLen = sizeof(L"System");
2339  }
2340  else
2341  {
2343  return Error;
2344  }
2345  }
2346 
2348 
2349  if (*pdwSize < sizeof(TCPIP_OWNER_MODULE_BASIC_INFO) + PathLen + FileLen)
2350  {
2351  *pdwSize = sizeof(TCPIP_OWNER_MODULE_BASIC_INFO) + PathLen + FileLen;
2353  }
2354 
2355  BasicInfo = Buffer;
2356  BasicInfo->pModuleName = (PVOID)((ULONG_PTR)BasicInfo + sizeof(TCPIP_OWNER_MODULE_BASIC_INFO));
2357  BasicInfo->pModulePath = (PVOID)((ULONG_PTR)BasicInfo->pModuleName + FileLen);
2358  wcscpy(BasicInfo->pModuleName, File);
2359  wcscpy(BasicInfo->pModulePath, Path);
2360  *pdwSize = sizeof(TCPIP_OWNER_MODULE_BASIC_INFO) + PathLen + FileLen;
2361 
2362  return NO_ERROR;
2363 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define CloseHandle
Definition: compat.h:598
BOOL NTAPI IsBadWritePtr(IN LPVOID lp, IN UINT_PTR ucb)
Definition: except.c:881
#define PROCESS_QUERY_INFORMATION
Definition: pstypes.h:166
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define NO_ERROR
Definition: dderror.h:5
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define FALSE
Definition: types.h:117
#define ERROR_PARTIAL_COPY
Definition: winerror.h:303
#define GetModuleFileNameExW(w, x, y, z)
Definition: compat.h:781
Definition: bufpool.h:45
void * PVOID
Definition: retypes.h:9
DWORD WINAPI GetModuleBaseNameW(HANDLE hProcess, HMODULE hModule, LPWSTR lpBaseName, DWORD nSize)
Definition: psapi.c:914
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
BOOL Error
Definition: chkdsk.c:66
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
struct _TCPIP_OWNER_MODULE_BASIC_INFO TCPIP_OWNER_MODULE_BASIC_INFO
HANDLE WINAPI OpenProcess(IN DWORD dwDesiredAccess, IN BOOL bInheritHandle, IN DWORD dwProcessId)
Definition: proc.c:1227
PRTL_UNICODE_STRING_BUFFER Path
#define NULL
Definition: types.h:112
#define ERROR_NOT_FOUND
Definition: winerror.h:690
#define PROCESS_VM_READ
Definition: pstypes.h:161
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:219
Definition: File.h:15
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by GetOwnerModuleFromTcpEntry(), and GetOwnerModuleFromUdpEntry().

◆ GetOwnerModuleFromTagEntry()

static DWORD GetOwnerModuleFromTagEntry ( DWORD  OwningPid,
DWORD  OwningTag,
TCPIP_OWNER_MODULE_INFO_CLASS  Class,
PVOID  Buffer,
PDWORD  pdwSize 
)
static

Definition at line 2365 of file iphlpapi_main.c.

2366 {
2367  UINT Size;
2368  HRESULT Res;
2369  HANDLE hAdvapi32;
2370  WCHAR SysDir[MAX_PATH];
2372  ULONG (NTAPI *_I_QueryTagInformation)(PVOID, DWORD, PVOID);
2373  struct
2374  {
2375  DWORD ProcessId;
2376  DWORD ServiceTag;
2377  DWORD TagType;
2378  PWSTR Buffer;
2379  } ServiceQuery;
2380 
2381  if (IsBadWritePtr(pdwSize, sizeof(DWORD)) ||
2382  IsBadWritePtr(Buffer, *pdwSize))
2383  {
2384  return ERROR_INVALID_PARAMETER;
2385  }
2386 
2387  /* First, secure (avoid injections) load advapi32.dll */
2388  Size = GetSystemDirectoryW(SysDir, MAX_PATH);
2389  if (Size == 0)
2390  {
2391  return GetLastError();
2392  }
2393 
2394  Res = StringCchCatW(&SysDir[Size], MAX_PATH - Size, L"\\advapi32.dll");
2395  if (FAILED(Res))
2396  {
2397  return Res;
2398  }
2399 
2400  hAdvapi32 = GetModuleHandleW(SysDir);
2401  if (hAdvapi32 == NULL)
2402  {
2403  return GetLastError();
2404  }
2405 
2406  /* Now, we'll query the service associated with the tag */
2407  _I_QueryTagInformation = (PVOID)GetProcAddress(hAdvapi32, "I_QueryTagInformation");
2408  if (_I_QueryTagInformation == NULL)
2409  {
2410  return GetLastError();
2411  }
2412 
2413  /* Set tag and PID for the query */
2414  ServiceQuery.ProcessId = OwningPid;
2415  ServiceQuery.ServiceTag = OwningTag;
2416  ServiceQuery.TagType = 0;
2417  ServiceQuery.Buffer = NULL;
2418 
2419  /* And query */
2420  Res = _I_QueryTagInformation(NULL, 1, &ServiceQuery);
2421  if (Res != ERROR_SUCCESS)
2422  {
2423  return Res;
2424  }
2425 
2426  /* Compute service name length */
2427  Size = wcslen(ServiceQuery.Buffer) * sizeof(WCHAR) + sizeof(UNICODE_NULL);
2428 
2429  /* We'll copy it twice, so make sure we have enough room */
2430  if (*pdwSize < sizeof(TCPIP_OWNER_MODULE_BASIC_INFO) + 2 * Size)
2431  {
2432  *pdwSize = sizeof(TCPIP_OWNER_MODULE_BASIC_INFO) + 2 * Size;
2433  LocalFree(ServiceQuery.Buffer);
2435  }
2436 
2437  /* Copy back data */
2438  BasicInfo = Buffer;
2439  BasicInfo->pModuleName = (PVOID)((ULONG_PTR)BasicInfo + sizeof(TCPIP_OWNER_MODULE_BASIC_INFO));
2440  BasicInfo->pModulePath = (PVOID)((ULONG_PTR)BasicInfo->pModuleName + Size);
2441  wcscpy(BasicInfo->pModuleName, ServiceQuery.Buffer);
2442  wcscpy(BasicInfo->pModulePath, ServiceQuery.Buffer);
2443  *pdwSize = sizeof(TCPIP_OWNER_MODULE_BASIC_INFO) + 2 * Size;
2444  LocalFree(ServiceQuery.Buffer);
2445 
2446  return NO_ERROR;
2447 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2709
BOOL NTAPI IsBadWritePtr(IN LPVOID lp, IN UINT_PTR ucb)
Definition: except.c:881
#define ERROR_SUCCESS
Definition: deptool.c:10
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
uint16_t * PWSTR
Definition: typedefs.h:56
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1040
#define NO_ERROR
Definition: dderror.h:5
#define DWORD
Definition: nt_native.h:44
STRSAFEAPI StringCchCatW(STRSAFE_LPWSTR pszDest, size_t cchDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:325
uint32_t ULONG_PTR
Definition: typedefs.h:65
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define UNICODE_NULL
Definition: bufpool.h:45
void * PVOID
Definition: retypes.h:9
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
static const WCHAR L[]
Definition: oid.c:1250
struct _TCPIP_OWNER_MODULE_BASIC_INFO TCPIP_OWNER_MODULE_BASIC_INFO
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
UINT WINAPI GetSystemDirectoryW(OUT LPWSTR lpBuffer, IN UINT uSize)
Definition: path.c:2312
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
unsigned int ULONG
Definition: retypes.h:1
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
#define GetProcAddress(x, y)
Definition: compat.h:612
static DWORD ServiceTag
Definition: database.c:34
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

Referenced by GetOwnerModuleFromTcpEntry(), and GetOwnerModuleFromUdpEntry().

◆ GetOwnerModuleFromTcpEntry()

DWORD WINAPI GetOwnerModuleFromTcpEntry ( PMIB_TCPROW_OWNER_MODULE  pTcpEntry,
TCPIP_OWNER_MODULE_INFO_CLASS  Class,
PVOID  Buffer,
PDWORD  pdwSize 
)

Definition at line 2468 of file iphlpapi_main.c.

2469 {
2470  /* If we have a service tag, that's a service connection */
2471  if (pTcpEntry->OwningModuleInfo[0] != 0)
2472  {
2473  return GetOwnerModuleFromTagEntry(pTcpEntry->dwOwningPid, (DWORD)(pTcpEntry->OwningModuleInfo[0]), Class, Buffer, pdwSize);
2474  }
2475  else
2476  {
2477  return GetOwnerModuleFromPidEntry(pTcpEntry->dwOwningPid, Class, Buffer, pdwSize);
2478  }
2479 }
static DWORD GetOwnerModuleFromPidEntry(DWORD OwningPid, TCPIP_OWNER_MODULE_INFO_CLASS Class, PVOID Buffer, PDWORD pdwSize)
Definition: bufpool.h:45
ULONGLONG OwningModuleInfo[TCPIP_OWNING_MODULE_SIZE]
Definition: tcpmib.h:127
unsigned long DWORD
Definition: ntddk_ex.h:95
static DWORD GetOwnerModuleFromTagEntry(DWORD OwningPid, DWORD OwningTag, TCPIP_OWNER_MODULE_INFO_CLASS Class, PVOID Buffer, PDWORD pdwSize)

Referenced by START_TEST(), and test_tcp().

◆ GetOwnerModuleFromUdpEntry()

DWORD WINAPI GetOwnerModuleFromUdpEntry ( PMIB_UDPROW_OWNER_MODULE  pUdpEntry,
TCPIP_OWNER_MODULE_INFO_CLASS  Class,
PVOID  Buffer,
PDWORD  pdwSize 
)

Definition at line 2500 of file iphlpapi_main.c.

2501 {
2502  /* If we have a service tag, that's a service connection */
2503  if (pUdpEntry->OwningModuleInfo[0] != 0)
2504  {
2505  return GetOwnerModuleFromTagEntry(pUdpEntry->dwOwningPid, (DWORD)(pUdpEntry->OwningModuleInfo[0]), Class, Buffer, pdwSize);
2506  }
2507  else
2508  {
2509  return GetOwnerModuleFromPidEntry(pUdpEntry->dwOwningPid, Class, Buffer, pdwSize);
2510  }
2511 }
ULONGLONG OwningModuleInfo[TCPIP_OWNING_MODULE_SIZE]
Definition: udpmib.h:65
static DWORD GetOwnerModuleFromPidEntry(DWORD OwningPid, TCPIP_OWNER_MODULE_INFO_CLASS Class, PVOID Buffer, PDWORD pdwSize)
Definition: bufpool.h:45
unsigned long DWORD
Definition: ntddk_ex.h:95
static DWORD GetOwnerModuleFromTagEntry(DWORD OwningPid, DWORD OwningTag, TCPIP_OWNER_MODULE_INFO_CLASS Class, PVOID Buffer, PDWORD pdwSize)

Referenced by START_TEST(), and test_udp().

◆ GetPerAdapterInfo()

DWORD WINAPI GetPerAdapterInfo ( ULONG  IfIndex,
PIP_PER_ADAPTER_INFO  pPerAdapterInfo,
PULONG  pOutBufLen 
)

Definition at line 2558 of file iphlpapi_main.c.

2559 {
2560  HKEY hkey;
2561  DWORD dwSize = 0;
2562  const char *ifName;
2564  WCHAR keyname[200] = L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\";
2565 
2566  if (!pOutBufLen)
2567  return ERROR_INVALID_PARAMETER;
2568 
2569  if (!pPerAdapterInfo || *pOutBufLen < sizeof(IP_PER_ADAPTER_INFO))
2570  {
2571  *pOutBufLen = sizeof(IP_PER_ADAPTER_INFO);
2572  return ERROR_BUFFER_OVERFLOW;
2573  }
2574 
2575  ifName = getInterfaceNameByIndex(IfIndex);
2576  if (!ifName)
2577  return ERROR_INVALID_PARAMETER;
2578 
2579  MultiByteToWideChar(CP_ACP, 0, ifName, -1, &keyname[62], sizeof(keyname)/sizeof(WCHAR) - 63);
2580  HeapFree(GetProcessHeap(), 0, (LPVOID)ifName);
2581 
2582  if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, keyname, 0, KEY_READ, &hkey) != ERROR_SUCCESS)
2583  {
2584  return ERROR_NOT_SUPPORTED;
2585  }
2586  Context.NumServers = 0;
2587  Context.uSizeAvailable = *pOutBufLen;
2588  Context.uSizeRequired = sizeof(IP_PER_ADAPTER_INFO);
2589  Context.pData = pPerAdapterInfo;
2590 
2591  if (*pOutBufLen >= sizeof(IP_PER_ADAPTER_INFO))
2592  ZeroMemory(pPerAdapterInfo, sizeof(IP_PER_ADAPTER_INFO));
2593 
2595 
2596  if (Context.uSizeRequired > Context.uSizeAvailable)
2597  {
2598  *pOutBufLen = Context.uSizeRequired;
2599  RegCloseKey(hkey);
2600  return ERROR_BUFFER_OVERFLOW;
2601  }
2602 
2603  if(RegQueryValueExW(hkey, L"NameServer", NULL, NULL, NULL, &dwSize) == ERROR_SUCCESS)
2604  {
2605  pPerAdapterInfo->AutoconfigActive = FALSE;
2606  }
2607  else
2608  {
2609  pPerAdapterInfo->AutoconfigActive = TRUE;
2610  }
2611 
2612  RegCloseKey(hkey);
2613  return NOERROR;
2614 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NOERROR
Definition: winerror.h:2354
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
#define CP_ACP
Definition: compat.h:109
#define ZeroMemory
Definition: winbase.h:1664
const char * getInterfaceNameByIndex(DWORD index)
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
#define FALSE
Definition: types.h:117
#define GetProcessHeap()
Definition: compat.h:595
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
struct _IP_PER_ADAPTER_INFO IP_PER_ADAPTER_INFO
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
static void CreateNameServerListEnumNamesFunc(PWCHAR Interface, PWCHAR Server, PVOID Data)
#define NULL
Definition: types.h:112
#define MultiByteToWideChar
Definition: compat.h:110
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100
struct tagContext Context
Definition: acpixf.h:1034
LSTATUS EnumNameServers(HKEY RegHandle, LPWSTR Interface, PVOID Data, EnumNameServersFunc cb)
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define HeapFree(x, y, z)
Definition: compat.h:594
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:56
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by Initialize(), LANStatusUiDetailsDlg(), and ShowInfo().

◆ GetRTTAndHopCount()

BOOL WINAPI GetRTTAndHopCount ( IPAddr  DestIpAddress,
PULONG  HopCount,
ULONG  MaxHops,
PULONG  RTT 
)

Definition at line 2633 of file iphlpapi_main.c.

2634 {
2635  TRACE("DestIpAddress 0x%08lx, HopCount %p, MaxHops %ld, RTT %p\n",
2636  DestIpAddress, HopCount, MaxHops, RTT);
2637  FIXME(":stub\n");
2638  return (BOOL) 0;
2639 }
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FIXME(fmt,...)
Definition: debug.h:111
#define TRACE(s)
Definition: solgame.cpp:4

◆ GetTcpStatistics()

DWORD WINAPI GetTcpStatistics ( PMIB_TCPSTATS  pStats)

Definition at line 2679 of file iphlpapi_main.c.

2680 {
2681  return GetTcpStatisticsEx(pStats, PF_INET);
2682 }
#define PF_INET
Definition: winsock.h:373
DWORD WINAPI GetTcpStatisticsEx(PMIB_TCPSTATS pStats, DWORD dwFamily)

Referenced by mib2TcpInit(), and ShowTcpStatistics().

◆ GetTcpStatisticsEx()

DWORD WINAPI GetTcpStatisticsEx ( PMIB_TCPSTATS  pStats,
DWORD  dwFamily 
)

Definition at line 2656 of file iphlpapi_main.c.

2657 {
2658  DWORD ret;
2659 
2660  TRACE("pStats %p\n", pStats);
2661  ret = getTCPStats(pStats, dwFamily);
2662  TRACE("returning %ld\n", ret);
2663  return ret;
2664 }
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
DWORD getTCPStats(MIB_TCPSTATS *stats, DWORD family)
int ret

Referenced by GetTcpStatistics().

◆ GetTcpTable()

DWORD WINAPI GetTcpTable ( PMIB_TCPTABLE  pTcpTable,
PDWORD  pdwSize,
BOOL  bOrder 
)

Definition at line 2707 of file iphlpapi_main.c.

2708 {
2709  return GetExtendedTcpTable(pTcpTable, pdwSize, bOrder, AF_INET, TCP_TABLE_BASIC_ALL, 0);
2710 }
DWORD WINAPI GetExtendedTcpTable(PVOID pTcpTable, PDWORD pdwSize, BOOL bOrder, ULONG ulAf, TCP_TABLE_CLASS TableClass, ULONG Reserved)
#define AF_INET
Definition: tcpip.h:117

Referenced by AllocateAndGetTcpTableFromStack().

◆ GetUdpStatistics()

DWORD WINAPI GetUdpStatistics ( PMIB_UDPSTATS  pStats)

Definition at line 2750 of file iphlpapi_main.c.

2751 {
2752  return GetUdpStatisticsEx(pStats, PF_INET);
2753 }
#define PF_INET
Definition: winsock.h:373
DWORD WINAPI GetUdpStatisticsEx(PMIB_UDPSTATS pStats, DWORD dwFamily)

Referenced by mib2UdpInit(), and ShowUdpStatistics().

◆ GetUdpStatisticsEx()

DWORD WINAPI GetUdpStatisticsEx ( PMIB_UDPSTATS  pStats,
DWORD  dwFamily 
)

Definition at line 2727 of file iphlpapi_main.c.

2728 {
2729  DWORD ret;
2730 
2731  TRACE("pStats %p\n", pStats);
2732  ret = getUDPStats(pStats, dwFamily);
2733  TRACE("returning %ld\n", ret);
2734  return ret;
2735 }
DWORD getUDPStats(MIB_UDPSTATS *stats, DWORD family)
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret

Referenced by GetUdpStatistics().

◆ GetUdpTable()

DWORD WINAPI GetUdpTable ( PMIB_UDPTABLE  pUdpTable,
PDWORD  pdwSize,
BOOL  bOrder 
)

Definition at line 2771 of file iphlpapi_main.c.

2772 {
2773  return GetExtendedUdpTable(pUdpTable, pdwSize, bOrder, AF_INET, UDP_TABLE_BASIC, 0);
2774 }
DWORD WINAPI GetExtendedUdpTable(PVOID pUdpTable, PDWORD pdwSize, BOOL bOrder, ULONG ulAf, UDP_TABLE_CLASS TableClass, ULONG Reserved)
#define AF_INET
Definition: tcpip.h:117

Referenced by AllocateAndGetUdpTableFromStack(), and mib2UdpEntryInit().

◆ GetUniDirectionalAdapterInfo()

DWORD WINAPI GetUniDirectionalAdapterInfo ( PIP_UNIDIRECTIONAL_ADAPTER_ADDRESS  pIPIfInfo,
PULONG  dwOutBufLen 
)

Definition at line 2795 of file iphlpapi_main.c.

2796 {
2797  TRACE("pIPIfInfo %p, dwOutBufLen %p\n", pIPIfInfo, dwOutBufLen);
2798  /* a unidirectional adapter?? not bloody likely! */
2799  return ERROR_NOT_SUPPORTED;
2800 }
#define TRACE(s)
Definition: solgame.cpp:4
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100

◆ IfTableSorter()

static int IfTableSorter ( const void a,
const void b 
)
static

Definition at line 1633 of file iphlpapi_main.c.

1634 {
1635  int ret;
1636 
1637  if (a && b)
1638  ret = ((PMIB_IFROW)a)->dwIndex - ((PMIB_IFROW)b)->dwIndex;
1639  else
1640  ret = 0;
1641  return ret;
1642 }
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
int ret
struct _MIB_IFROW * PMIB_IFROW
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

Referenced by GetIfTable().

◆ IpAddrTableSorter()

static int IpAddrTableSorter ( const void a,
const void b 
)
static

Definition at line 1788 of file iphlpapi_main.c.

1789 {
1790  int ret;
1791 
1792  if (a && b)
1793  ret = ((PMIB_IPADDRROW)a)->dwAddr - ((PMIB_IPADDRROW)b)->dwAddr;
1794  else
1795  ret = 0;
1796  return ret;
1797 }
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
int ret
struct _MIB_IPADDRROW * PMIB_IPADDRROW
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

Referenced by GetIpAddrTable().

◆ IpForwardTableSorter()

static int IpForwardTableSorter ( const void a,
const void b 
)
static

Definition at line 1881 of file iphlpapi_main.c.

1882 {
1883  int ret;
1884 
1885  if (a && b) {
1887 
1888  ret = rowA->dwForwardDest - rowB->dwForwardDest;
1889  if (ret == 0) {
1890  ret = rowA->dwForwardProto - rowB->dwForwardProto;
1891  if (ret == 0) {
1892  ret = rowA->dwForwardPolicy - rowB->dwForwardPolicy;
1893  if (ret == 0)
1894  ret = rowA->dwForwardNextHop - rowB->dwForwardNextHop;
1895  }
1896  }
1897  }
1898  else
1899  ret = 0;
1900  return ret;
1901 }
struct _MIB_IPFORWARDROW * PMIB_IPFORWARDROW
#define b
Definition: ke_i.h:79
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
DWORD dwForwardNextHop
Definition: ipmib.h:74
DWORD dwForwardDest
Definition: ipmib.h:71
int ret
DWORD dwForwardPolicy
Definition: ipmib.h:73
DWORD dwForwardProto
Definition: ipmib.h:83
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

Referenced by GetIpForwardTable().

◆ IpNetTableSorter()

static int IpNetTableSorter ( const void a,
const void b 
)
static

Definition at line 1992 of file iphlpapi_main.c.

1993 {
1994  int ret;
1995 
1996  if (a && b)
1997  ret = ((PMIB_IPNETROW)a)->dwAddr - ((PMIB_IPNETROW)b)->dwAddr;
1998  else
1999  ret = 0;
2000  return ret;
2001 }
struct _MIB_IPNETROW * PMIB_IPNETROW
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
int ret
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

Referenced by GetIpNetTable().

◆ IpReleaseAddress()

DWORD WINAPI IpReleaseAddress ( PIP_ADAPTER_INDEX_MAP  AdapterInfo)

Definition at line 2816 of file iphlpapi_main.c.

2817 {
2818  DWORD Status, Version = 0;
2819 
2820  if (!AdapterInfo)
2821  return ERROR_INVALID_PARAMETER;
2822 
2823  /* Maybe we should do this in DllMain */
2825  return ERROR_PROC_NOT_FOUND;
2826 
2827  if (DhcpReleaseIpAddressLease(AdapterInfo->Index))
2829  else
2831 
2832  DhcpCApiCleanup();
2833 
2834  return Status;
2835 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_SUCCESS
Definition: deptool.c:10
DWORD APIENTRY DhcpReleaseIpAddressLease(DWORD AdapterIndex)
Definition: dhcpcsvc.c:139
Status
Definition: gdiplustypes.h:24
unsigned long DWORD
Definition: ntddk_ex.h:95
IN PVOID IN PVOID IN USHORT Version
Definition: pci.h:361
DWORD APIENTRY DhcpCApiInitialize(LPDWORD Version)
Definition: dhcpcsvc.c:26
#define ERROR_PROC_NOT_FOUND
Definition: winerror.h:199
VOID APIENTRY DhcpCApiCleanup(VOID)
Definition: dhcpcsvc.c:71

Referenced by Release(), and WlanDisconnect().

◆ IpRenewAddress()

DWORD WINAPI IpRenewAddress ( PIP_ADAPTER_INDEX_MAP  AdapterInfo)

Definition at line 2850 of file iphlpapi_main.c.

2851 {
2852  DWORD Status, Version = 0;
2853 
2854  if (!AdapterInfo)
2855  return ERROR_INVALID_PARAMETER;
2856 
2857  /* Maybe we should do this in DllMain */
2859  return ERROR_PROC_NOT_FOUND;
2860 
2861  if (DhcpRenewIpAddressLease(AdapterInfo->Index))
2863  else
2865 
2866  DhcpCApiCleanup();
2867 
2868  return Status;
2869 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_SUCCESS
Definition: deptool.c:10
Status
Definition: gdiplustypes.h:24
unsigned long DWORD
Definition: ntddk_ex.h:95
IN PVOID IN PVOID IN USHORT Version
Definition: pci.h:361
DWORD APIENTRY DhcpCApiInitialize(LPDWORD Version)
Definition: dhcpcsvc.c:26
#define ERROR_PROC_NOT_FOUND
Definition: winerror.h:199
DWORD APIENTRY DhcpRenewIpAddressLease(DWORD AdapterIndex)
Definition: dhcpcsvc.c:165
VOID APIENTRY DhcpCApiCleanup(VOID)
Definition: dhcpcsvc.c:71

Referenced by Renew().

◆ NhGetInterfaceNameFromDeviceGuid()

DWORD WINAPI NhGetInterfaceNameFromDeviceGuid ( _In_ const GUID pInterfaceGUID,
_Out_writes_bytes_to_ *, *pOutBufLen PWCHAR  pInterfaceName,
_Inout_ PULONG  pOutBufLen,
DWORD  dwUnknown4,
DWORD  dwUnknown5 
)

Definition at line 3476 of file iphlpapi_main.c.

3481 {
3483 
3484  if (pInterfaceName == NULL)
3485  return ERROR_INVALID_PARAMETER;
3486 
3487  return GetInterfaceNameInternal(pInterfaceGUID, pInterfaceName, pOutBufLen);
3488 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define ERROR_SUCCESS
Definition: deptool.c:10
#define SetLastError(x)
Definition: compat.h:611
DWORD GetInterfaceNameInternal(_In_ const GUID *pInterfaceGUID, _Out_writes_bytes_to_(*pOutBufLen, *pOutBufLen) PWCHAR pInterfaceName, _Inout_ PULONG pOutBufLen)
#define NULL
Definition: types.h:112

◆ NhGetInterfaceNameFromGuid()

DWORD WINAPI NhGetInterfaceNameFromGuid ( _In_ const GUID pInterfaceGUID,
_Out_writes_bytes_to_ *, *pOutBufLen PWCHAR  pInterfaceName,
_Inout_ PULONG  pOutBufLen,
DWORD  dwUnknown4,
DWORD  dwUnknown5 
)

Definition at line 3494 of file iphlpapi_main.c.

3499 {
3500  DWORD result;
3501 
3502  result = GetInterfaceNameInternal(pInterfaceGUID, pInterfaceName, pOutBufLen);
3503 
3504  if (result == ERROR_NOT_FOUND)
3506 
3507  return result;
3508 }
GLuint64EXT * result
Definition: glext.h:11304
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
DWORD GetInterfaceNameInternal(_In_ const GUID *pInterfaceGUID, _Out_writes_bytes_to_(*pOutBufLen, *pOutBufLen) PWCHAR pInterfaceName, _Inout_ PULONG pOutBufLen)
#define ERROR_NOT_FOUND
Definition: winerror.h:690
#define ERROR_PATH_NOT_FOUND
Definition: winerror.h:106

◆ NhpAllocateAndGetInterfaceInfoFromStack()

DWORD WINAPI NhpAllocateAndGetInterfaceInfoFromStack ( IP_INTERFACE_NAME_INFO **  ppTable,
PDWORD  pdwCount,
BOOL  bOrder,
HANDLE  hHeap,
DWORD  dwFlags 
)

Definition at line 3387 of file iphlpapi_main.c.

3388 {
3389  FIXME(":stub\n");
3390  return 0L;
3391 }
#define FIXME(fmt,...)
Definition: debug.h:111
static const WCHAR L[]
Definition: oid.c:1250

◆ NotifyAddrChange()

DWORD WINAPI NotifyAddrChange ( PHANDLE  Handle,
LPOVERLAPPED  overlapped 
)

Definition at line 2888 of file iphlpapi_main.c.

2889 {
2890  FIXME("(Handle %p, overlapped %p): stub\n", Handle, overlapped);
2892  if (overlapped) ((IO_STATUS_BLOCK *) overlapped)->Status = STATUS_PENDING;
2893  return ERROR_IO_PENDING;
2894 }
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
#define ERROR_IO_PENDING
Definition: dderror.h:15
#define FIXME(fmt,...)
Definition: debug.h:111
#define STATUS_PENDING
Definition: ntstatus.h:82
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED * overlapped
Definition: sock.c:82
_In_ HANDLE Handle
Definition: extypes.h:390

Referenced by AdapterDiscoveryThread(), and detectChange().

◆ NotifyRouteChange()

DWORD WINAPI NotifyRouteChange ( PHANDLE  Handle,
LPOVERLAPPED  overlapped 
)

Definition at line 2913 of file iphlpapi_main.c.

2914 {
2915  FIXME("(Handle %p, overlapped %p): stub\n", Handle, overlapped);
2916  return ERROR_NOT_SUPPORTED;
2917 }
#define FIXME(fmt,...)
Definition: debug.h:111
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED * overlapped
Definition: sock.c:82
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100
_In_ HANDLE Handle
Definition: extypes.h:390

◆ SendARP()

DWORD WINAPI SendARP ( IPAddr  DestIP,
IPAddr  SrcIP,
PULONG  pMacAddr,
PULONG  PhyAddrLen 
)

Definition at line 2934 of file iphlpapi_main.c.

2935 {
2936  IPAddr IPs[2];
2937  ULONG Size;
2938 
2939  if (IsBadWritePtr(pMacAddr, sizeof(ULONG)) || IsBadWritePtr(PhyAddrLen, sizeof(ULONG)))
2940  return ERROR_INVALID_PARAMETER;
2941 
2942  IPs[0] = DestIP;
2943  IPs[1] = SrcIP;
2944  Size = sizeof(IPs);
2945  return TCPSendIoctl(INVALID_HANDLE_VALUE, IOCTL_QUERY_IP_HW_ADDRESS, IPs, &Size, pMacAddr, PhyAddrLen);
2946 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
BOOL NTAPI IsBadWritePtr(IN LPVOID lp, IN UINT_PTR ucb)
Definition: except.c:881
#define INVALID_HANDLE_VALUE
Definition: compat.h:590
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
ULONG IPAddr
Definition: pfhook.h:35
unsigned int ULONG
Definition: retypes.h:1
#define IOCTL_QUERY_IP_HW_ADDRESS
Definition: tcpioctl.h:40
DWORD TCPSendIoctl(HANDLE hDevice, DWORD dwIoControlCode, LPVOID lpInBuffer, PULONG pInBufferSize, LPVOID lpOutBuffer, PULONG pOutBufferSize)

Referenced by Ping(), state_panic(), and TestUM().

◆ SetIfEntry()

DWORD WINAPI SetIfEntry ( PMIB_IFROW  pIfRow)

Definition at line 2964 of file iphlpapi_main.c.

2965 {
2966  FIXME("(pIfRow %p): stub\n", pIfRow);
2967  /* this is supposed to set an interface administratively up or down.
2968  Could do SIOCSIFFLAGS and set/clear IFF_UP, but, not sure I want to, and
2969  this sort of down is indistinguishable from other sorts of down (e.g. no
2970  link). */
2971  return ERROR_NOT_SUPPORTED;
2972 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100

◆ SetIpForwardEntry()

DWORD WINAPI SetIpForwardEntry ( PMIB_IPFORWARDROW  pRoute)

Definition at line 2988 of file iphlpapi_main.c.

2989 {
2990  return setIpForwardEntry( pRoute );
2991 }
DWORD setIpForwardEntry(PMIB_IPFORWARDROW pRoute)
Definition: route.c:59

◆ SetIpForwardEntryToStack()

DWORD WINAPI SetIpForwardEntryToStack ( PMIB_IPFORWARDROW  pRoute)

Definition at line 3410 of file iphlpapi_main.c.

3411 {
3412  FIXME("SetIpForwardEntryToStack() stub\n");
3413  return 0L;
3414 }
#define FIXME(fmt,...)
Definition: debug.h:111
static const WCHAR L[]
Definition: oid.c:1250

◆ SetIpNetEntry()

DWORD WINAPI SetIpNetEntry ( PMIB_IPNETROW  pArpEntry)

Definition at line 3006 of file iphlpapi_main.c.

3007 {
3008  HANDLE tcpFile;
3009  NTSTATUS status;
3012  TDIEntityID id;
3013  DWORD returnSize;
3014  PMIB_IPNETROW arpBuff;
3015 
3016  if (!pArpEntry)
3017  return ERROR_INVALID_PARAMETER;
3018 
3020  return ERROR_NOT_SUPPORTED;
3021 
3022  if (!NT_SUCCESS(getNthIpEntity( tcpFile, pArpEntry->dwIndex, &id )))
3023  {
3024  closeTcpFile(tcpFile);
3025  return ERROR_INVALID_PARAMETER;
3026  }
3027 
3031  req.Req.ID.toi_entity.tei_instance = id.tei_instance;
3033  req.Req.BufferSize = sizeof(MIB_IPNETROW);
3034  arpBuff = (PMIB_IPNETROW)&req.Req.Buffer[0];
3035 
3036  RtlCopyMemory(arpBuff, pArpEntry, sizeof(MIB_IPNETROW));
3037 
3038  status = DeviceIoControl( tcpFile,
3040  &req,
3041  sizeof(req),
3042  NULL,
3043  0,
3044  &returnSize,
3045  NULL );
3046 
3047  closeTcpFile(tcpFile);
3048 
3049  if (status)
3050  return NO_ERROR;
3051  else
3052  return ERROR_INVALID_PARAMETER;
3053 }
TDIEntityID toi_entity
Definition: tdiinfo.h:74
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define AT_ENTITY
Definition: tdiinfo.h:41
struct _MIB_IPNETROW * PMIB_IPNETROW
ULONG toi_class
Definition: tdiinfo.h:75
unsigned char Buffer[1]
Definition: tdiinfo.h:97
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS getNthIpEntity(HANDLE tcpFile, DWORD index, TDIEntityID *ent)
#define NO_ERROR
Definition: dderror.h:5
#define IP_MIB_ARPTABLE_ENTRY_ID
Definition: tcpioctl.h:54
#define FILE_READ_DATA
Definition: nt_native.h:628
ULONG toi_id
Definition: tdiinfo.h:77
TCP_REQUEST_SET_INFORMATION_EX Req
#define FILE_WRITE_DATA
Definition: nt_native.h:631
ULONG tei_entity
Definition: tdiinfo.h:31
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG tei_instance
Definition: tdiinfo.h:32
unsigned long DWORD
Definition: ntddk_ex.h:95
#define TCP_REQUEST_SET_INFORMATION_INIT
VOID closeTcpFile(HANDLE h)
Definition: handle.c:43
#define IOCTL_TCP_SET_INFORMATION_EX
Definition: tditest.h:112
struct _MIB_IPNETROW MIB_IPNETROW
BOOL WINAPI DeviceIoControl(IN HANDLE hDevice, IN DWORD dwIoControlCode, IN LPVOID lpInBuffer OPTIONAL, IN DWORD nInBufferSize OPTIONAL, OUT LPVOID lpOutBuffer OPTIONAL, IN DWORD nOutBufferSize OPTIONAL, OUT LPDWORD lpBytesReturned OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: deviceio.c:136
#define NULL
Definition: types.h:112
#define INFO_TYPE_PROVIDER
Definition: tdiinfo.h:69
NTSTATUS openTcpFile(PHANDLE tcpFile, ACCESS_MASK DesiredAccess)
Definition: handle.c:12
#define ERROR_NOT_SUPPORTED
Definition: compat.h:100
GLenum GLuint id
Definition: glext.h:5579
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
DWORD dwIndex
Definition: ipmib.h:114
static SERVICE_STATUS status
Definition: service.c:31
ULONG toi_type
Definition: tdiinfo.h:76
#define INFO_CLASS_PROTOCOL
Definition: tdiinfo.h:65
Definition: ps.c:97

Referenced by Addhost().

◆ SetIpStatistics()

DWORD WINAPI SetIpStatistics ( PMIB_IPSTATS  pIpStats)

Definition at line 3071 of file iphlpapi_main.c.

3072 {
3073  FIXME("(pIpStats %p): stub\n", pIpStats);
3074  return 0;
3075 }
#define FIXME(fmt,...)
Definition: debug.h:111

◆ SetIpTTL()

DWORD WINAPI SetIpTTL ( UINT  nTTL)

Definition at line 3093 of file iphlpapi_main.c.

3094 {
3095  FIXME("(nTTL %d): stub\n", nTTL);
3096  return 0;
3097 }
#define FIXME(fmt,...)
Definition: debug.h:111

◆ SetTcpEntry()

DWORD WINAPI SetTcpEntry ( PMIB_TCPROW  pTcpRow)

Definition at line 3115 of file iphlpapi_main.c.

3116 {
3117  FIXME("(pTcpRow %p): stub\n", pTcpRow);
3118  return 0;
3119 }
#define FIXME(fmt,...)
Definition: debug.h:111

◆ TcpTableSorter()

static int TcpTableSorter ( const void a,
const void b 
)
static

Definition at line 980 of file iphlpapi_main.c.

981 {
982  int ret;
983 
984  if (a && b) {
985  PMIB_TCPROW rowA = (PMIB_TCPROW)a, rowB = (PMIB_TCPROW)b;
986 
987  ret = rowA->dwLocalAddr - rowB->dwLocalAddr;
988  if (ret == 0) {
989  ret = rowA->dwLocalPort - rowB->dwLocalPort;
990  if (ret == 0) {
991  ret = rowA->dwRemoteAddr - rowB->dwRemoteAddr;
992  if (ret == 0)
993  ret = rowA->dwRemotePort - rowB->dwRemotePort;
994  }
995  }
996  }
997  else
998  ret = 0;
999  return ret;
1000 }
DWORD dwLocalPort
Definition: tcpmib.h:59
DWORD dwRemoteAddr
Definition: tcpmib.h:60
#define b
Definition: ke_i.h:79
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
DWORD dwLocalAddr
Definition: tcpmib.h:58
int ret
DWORD dwRemotePort
Definition: tcpmib.h:61
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
struct _MIB_TCPROW * PMIB_TCPROW

Referenced by GetExtendedTcpTable().

◆ UdpTableSorter()

static int UdpTableSorter ( const void a,
const void b 
)
static

Definition at line 1406 of file iphlpapi_main.c.

1407 {
1408  int ret;
1409 
1410  if (a && b) {
1411