ReactOS  0.4.13-dev-66-gc714b7f
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)
static WCHAR Address[46]
Definition: ping.c:68
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)

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:91
#define NO_ERROR
Definition: dderror.h:5
DWORD WINAPI GetIfTable(PMIB_IFTABLE pIfTable, PULONG pdwSize, BOOL bOrder)
smooth NULL
Definition: ftsmooth.c:416
#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 HeapFree(x, y, z)
Definition: compat.h:394
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#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:91
#define NO_ERROR
Definition: dderror.h:5
DWORD WINAPI GetIpAddrTable(PMIB_IPADDRTABLE pIpAddrTable, PULONG pdwSize, BOOL bOrder)
smooth NULL
Definition: ftsmooth.c:416
#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 HeapFree(x, y, z)
Definition: compat.h:394
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#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:91
#define NO_ERROR
Definition: dderror.h:5
smooth NULL
Definition: ftsmooth.c:416
#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 HeapFree(x, y, z)
Definition: compat.h:394
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#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:91
DWORD WINAPI GetIpNetTable(PMIB_IPNETTABLE pIpNetTable, PULONG pdwSize, BOOL bOrder)
#define NO_ERROR
Definition: dderror.h:5
struct _MIB_IPNETTABLE * PMIB_IPNETTABLE
smooth NULL
Definition: ftsmooth.c:416
#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 HeapFree(x, y, z)
Definition: compat.h:394
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#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:91
#define NO_ERROR
Definition: dderror.h:5
smooth NULL
Definition: ftsmooth.c:416
#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 GetExtendedTcpTable(PVOID pTcpTable, PDWORD pdwSize, BOOL bOrder, ULONG ulAf, TCP_TABLE_CLASS TableClass, ULONG Reserved)
#define HeapFree(x, y, z)
Definition: compat.h:394
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#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:91
#define NO_ERROR
Definition: dderror.h:5
smooth NULL
Definition: ftsmooth.c:416
#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
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:394
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#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:91
#define NO_ERROR
Definition: dderror.h:5
smooth NULL
Definition: ftsmooth.c:416
#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 HeapFree(x, y, z)
Definition: compat.h:394
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#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:91
#define NO_ERROR
Definition: dderror.h:5
smooth NULL
Definition: ftsmooth.c:416
#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 HeapFree(x, y, z)
Definition: compat.h:394
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#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:91
#define NO_ERROR
Definition: dderror.h:5
struct _MIB_UDPTABLE_OWNER_PID * PMIB_UDPTABLE_OWNER_PID
smooth NULL
Definition: ftsmooth.c:416
#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 HeapFree(x, y, z)
Definition: compat.h:394
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#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:91
DWORD WINAPI GetUdpTable(PMIB_UDPTABLE pUdpTable, PDWORD pdwSize, BOOL bOrder)
struct _MIB_UDPTABLE * PMIB_UDPTABLE
#define NO_ERROR
Definition: dderror.h:5
smooth NULL
Definition: ftsmooth.c:416
#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 HeapFree(x, y, z)
Definition: compat.h:394
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ CancelIPChangeNotify()

BOOL WINAPI CancelIPChangeNotify ( LPOVERLAPPED  notifyOverlapped)

Definition at line 3366 of file iphlpapi_main.c.

3367 {
3368  FIXME(":stub\n");
3369  return 0L;
3370 }
#define FIXME(fmt,...)
Definition: debug.h:110
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:110
#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 2514 of file iphlpapi_main.c.

2515 {
2516  IP_ADDR_STRING *pNext;
2518 
2519  if (!Context->NumServers)
2520  {
2521  if (Context->uSizeAvailable >= Context->uSizeRequired)
2522  {
2523  WideCharToMultiByte(CP_ACP, 0, Server, -1, Context->pData->DnsServerList.IpAddress.String, 16, NULL, NULL);
2524  Context->pData->DnsServerList.IpAddress.String[15] = '\0';
2525  Context->pLastAddr = &Context->pData->DnsServerList;
2526  }
2527  }
2528  else
2529  {
2530  Context->uSizeRequired += sizeof(IP_ADDR_STRING);
2531  if (Context->uSizeAvailable >= Context->uSizeRequired)
2532  {
2533  pNext = (IP_ADDR_STRING*)(((char*)Context->pLastAddr) + sizeof(IP_ADDR_STRING));
2534  WideCharToMultiByte(CP_ACP, 0, Server, -1, pNext->IpAddress.String, 16, NULL, NULL);
2535  pNext->IpAddress.String[15] = '\0';
2536  Context->pLastAddr->Next = pNext;
2537  Context->pLastAddr = pNext;
2538  pNext->Next = NULL;
2539  }
2540  }
2541  Context->NumServers++;
2542 }
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
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
smooth NULL
Definition: ftsmooth.c:416
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:110
#define TRACE(s)
Definition: solgame.cpp:4
#define ERROR_NOT_SUPPORTED
Definition: compat.h:90

◆ 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 }
NTSTATUS deleteIpAddress(ULONG NteContext)
#define TRACE(s)
Definition: solgame.cpp:4
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)

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:110
#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:110
#define TRACE(s)
Definition: solgame.cpp:4
#define ERROR_NOT_SUPPORTED
Definition: compat.h:90

◆ 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:120
#define DLL_PROCESS_DETACH
Definition: compat.h:119
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:110
#define TRACE(s)
Definition: solgame.cpp:4
#define ERROR_NOT_SUPPORTED
Definition: compat.h:90

◆ 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:110
#define TRACE(s)
Definition: solgame.cpp:4
#define ERROR_NOT_SUPPORTED
Definition: compat.h:90

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:110
#define TRACE(s)
Definition: solgame.cpp:4
#define ERROR_NOT_SUPPORTED
Definition: compat.h:90
_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:5995

◆ GetAdapterOrderMap()

PIP_ADAPTER_ORDER_MAP WINAPI GetAdapterOrderMap ( VOID  )

Definition at line 3160 of file iphlpapi_main.c.

3161 {
3162  FIXME(":stub\n");
3163  return 0L;
3164 }
#define FIXME(fmt,...)
Definition: debug.h:110
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);
812  "Software\\Wine\\Wine\\Config\\Network", 0, KEY_READ,
813  &hKey) == ERROR_SUCCESS) {
814  DWORD size = sizeof(primaryWINS.String);
815  unsigned long addr;
816 
817  RegQueryValueExA(hKey, "WinsServer", NULL, NULL,
818  (PBYTE)primaryWINS.String, &size);
819  addr = inet_addr(primaryWINS.String);
820  if (addr != INADDR_NONE && addr != INADDR_ANY)
821  winsEnabled = TRUE;
822  size = sizeof(secondaryWINS.String);
823  RegQueryValueExA(hKey, "BackupWinsServer", NULL, NULL,
824  (PBYTE)secondaryWINS.String, &size);
825  addr = inet_addr(secondaryWINS.String);
826  if (addr != INADDR_NONE && addr != INADDR_ANY)
827  winsEnabled = TRUE;
828  RegCloseKey(hKey);
829  }
830  TRACE("num of index is %lu\n", table->numIndexes);
831  for (ndx = 0; ndx < table->numIndexes; ndx++) {
832  PIP_ADAPTER_INFO ptr = &pAdapterInfo[ndx];
833  DWORD addrLen = sizeof(ptr->Address), type;
834  const char *ifname =
835  getInterfaceNameByIndex(table->indexes[ndx]);
836  if (!ifname) {
838  break;
839  }
840 
841  /* on Win98 this is left empty, but whatever */
842  strncpy(ptr->AdapterName,ifname,sizeof(ptr->AdapterName));
843  consumeInterfaceName(ifname);
844  ptr->AdapterName[MAX_ADAPTER_NAME_LENGTH] = '\0';
845  getInterfacePhysicalByIndex(table->indexes[ndx], &addrLen,
846  ptr->Address, &type);
847  /* MS defines address length and type as UINT in some places and
848  DWORD in others, **sigh**. Don't want to assume that PUINT and
849  PDWORD are equiv (64-bit?) */
850  ptr->AddressLength = addrLen;
851  ptr->Type = type;
852  ptr->Index = table->indexes[ndx];
854  ptr->IpAddressList.IpAddress.String);
856  ptr->IpAddressList.IpMask.String);
857  ptr->IpAddressList.Context = ptr->Index;
859  ptr->GatewayList.IpAddress.String);
860  getDhcpInfoForAdapter(table->indexes[ndx], &dhcpEnabled,
861  &dhcpServer, &ptr->LeaseObtained,
862  &ptr->LeaseExpires);
863  ptr->DhcpEnabled = (DWORD) dhcpEnabled;
864  toIPAddressString(dhcpServer,
865  ptr->DhcpServer.IpAddress.String);
866  if (winsEnabled) {
867  ptr->HaveWins = TRUE;
868  memcpy(ptr->PrimaryWinsServer.IpAddress.String,
869  primaryWINS.String, sizeof(primaryWINS.String));
870  memcpy(ptr->SecondaryWinsServer.IpAddress.String,
871  secondaryWINS.String, sizeof(secondaryWINS.String));
872  }
873  if (ndx < table->numIndexes - 1)
874  ptr->Next = &pAdapterInfo[ndx + 1];
875  else
876  ptr->Next = NULL;
877  }
878  ret = NO_ERROR;
879  }
880  free(table);
881  }
882  else
884  }
885  }
886  else
887  ret = ERROR_NO_DATA;
888  }
889  TRACE("returning %ld\n", ret);
890  return ret;
891 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
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:4041
#define TRUE
Definition: types.h:120
#define inet_addr(cp)
Definition: inet.h:98
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
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
LONG WINAPI RegOpenKeyExA(_In_ HKEY hKey, _In_ LPCSTR lpSubKey, _In_ DWORD ulOptions, _In_ REGSAM samDesired, _Out_ PHKEY phkResult)
Definition: reg.c:3346
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define INADDR_ANY
Definition: StrAddr.c:4
char String[4 *4]
Definition: iptypes.h:42
#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])
unsigned int BOOL
Definition: ntddk_ex.h:94
static PVOID ptr
Definition: dispmode.c:27
smooth NULL
Definition: ftsmooth.c:416
DWORD getInterfacePhysicalByIndex(DWORD index, PDWORD len, PBYTE addr, PDWORD type)
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
if(!(yy_init))
Definition: macro.lex.yy.c:714
#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
unsigned int ULONG
Definition: retypes.h:1
#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 HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#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 908 of file iphlpapi_main.c.

909 {
910  DWORD ret;
911 
912  TRACE("dwDestAddr 0x%08lx, pdwBestIfIndex %p\n", dwDestAddr, pdwBestIfIndex);
913  if (!pdwBestIfIndex)
915  else {
916  MIB_IPFORWARDROW ipRow;
917 
918  ret = GetBestRoute(dwDestAddr, 0, &ipRow);
919  if (ret == ERROR_SUCCESS)
920  *pdwBestIfIndex = ipRow.dwForwardIfIndex;
921  }
922  TRACE("returning %ld\n", ret);
923  return ret;
924 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#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)

Referenced by IcmpSendEcho().

◆ GetBestInterfaceEx()

DWORD WINAPI GetBestInterfaceEx ( struct sockaddr pDestAddr,
PDWORD  pdwBestIfIndex 
)

Definition at line 3375 of file iphlpapi_main.c.

3376 {
3377  FIXME(":stub\n");
3378  return 0L;
3379 }
#define FIXME(fmt,...)
Definition: debug.h:110
static const WCHAR L[]
Definition: oid.c:1250

◆ GetBestRoute()

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

Definition at line 942 of file iphlpapi_main.c.

943 {
945  DWORD ret;
946 
947  TRACE("dwDestAddr 0x%08lx, dwSourceAddr 0x%08lx, pBestRoute %p\n", dwDestAddr,
948  dwSourceAddr, pBestRoute);
949  if (!pBestRoute)
951 
953  if (table) {
954  DWORD ndx, minMaskSize, matchedNdx = 0;
955 
956  for (ndx = 0, minMaskSize = 255; ndx < table->dwNumEntries; ndx++) {
957  if ((dwDestAddr & table->table[ndx].dwForwardMask) ==
958  (table->table[ndx].dwForwardDest & table->table[ndx].dwForwardMask)) {
959  DWORD hostMaskSize;
960 
961  if (!_BitScanForward(&hostMaskSize, ntohl(table->table[ndx].dwForwardMask)))
962  {
963  hostMaskSize = 32;
964  }
965  if (hostMaskSize < minMaskSize) {
966  minMaskSize = hostMaskSize;
967  matchedNdx = ndx;
968  }
969  }
970  }
971  memcpy(pBestRoute, &table->table[matchedNdx], sizeof(MIB_IPFORWARDROW));
973  ret = ERROR_SUCCESS;
974  }
975  else
977  TRACE("returning %ld\n", ret);
978  return ret;
979 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
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 TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define HeapFree(x, y, z)
Definition: compat.h:394
#define ERROR_OUTOFMEMORY
Definition: deptool.c:13
#define ntohl(x)
Definition: module.h:203

Referenced by GetBestInterface().

◆ GetExtendedTcpTable()

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

Definition at line 1023 of file iphlpapi_main.c.

1024 {
1025  DWORD i, count, size;
1026  DWORD ret = NO_ERROR;
1027 
1028  if (!pdwSize)
1029  {
1030  return ERROR_INVALID_PARAMETER;
1031  }
1032 
1033  if (ulAf != AF_INET)
1034  {
1035  UNIMPLEMENTED;
1036  return ERROR_INVALID_PARAMETER;
1037  }
1038 
1039  switch (TableClass)
1040  {
1041  case TCP_TABLE_BASIC_ALL:
1042  {
1043  PMIB_TCPTABLE pOurTcpTable = getTcpTable(ClassBasic);
1044  PMIB_TCPTABLE pTheirTcpTable = pTcpTable;
1045 
1046  if (pOurTcpTable)
1047  {
1048  size = FIELD_OFFSET(MIB_TCPTABLE, table) + pOurTcpTable->dwNumEntries * sizeof(MIB_TCPROW);
1049  if (size > *pdwSize || !pTheirTcpTable)
1050  {
1051  *pdwSize = size;
1053  }
1054  else
1055  {
1056  memcpy(pTheirTcpTable, pOurTcpTable, size);
1057 
1058  if (bOrder)
1059  qsort(pTheirTcpTable->table, pTheirTcpTable->dwNumEntries,
1060  sizeof(MIB_TCPROW), TcpTableSorter);
1061  }
1062 
1063  free(pOurTcpTable);
1064  }
1065  }
1066  break;
1067 
1069  {
1070  PMIB_TCPTABLE pOurTcpTable = getTcpTable(ClassBasic);
1071  PMIB_TCPTABLE pTheirTcpTable = pTcpTable;
1072 
1073  if (pOurTcpTable)
1074  {
1075  for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1076  {
1077  if (pOurTcpTable->table[i].State != MIB_TCP_STATE_LISTEN)
1078  {
1079  ++count;
1080  }
1081  }
1082 
1084  if (size > *pdwSize || !pTheirTcpTable)
1085  {
1086  *pdwSize = size;
1088  }
1089  else
1090  {
1091  pTheirTcpTable->dwNumEntries = count;
1092 
1093  for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1094  {
1095  if (pOurTcpTable->table[i].State != MIB_TCP_STATE_LISTEN)
1096  {
1097  memcpy(&pTheirTcpTable->table[count], &pOurTcpTable->table[i], sizeof(MIB_TCPROW));
1098  ++count;
1099  }
1100  }
1101  ASSERT(count == pTheirTcpTable->dwNumEntries);
1102 
1103  if (bOrder)
1104  qsort(pTheirTcpTable->table, pTheirTcpTable->dwNumEntries,
1105  sizeof(MIB_TCPROW), TcpTableSorter);
1106  }
1107 
1108  free(pOurTcpTable);
1109  }
1110  }
1111  break;
1112 
1114  {
1115  PMIB_TCPTABLE pOurTcpTable = getTcpTable(ClassBasic);
1116  PMIB_TCPTABLE pTheirTcpTable = pTcpTable;
1117 
1118  if (pOurTcpTable)
1119  {
1120  for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1121  {
1122  if (pOurTcpTable->table[i].State == MIB_TCP_STATE_LISTEN)
1123  {
1124  ++count;
1125  }
1126  }
1127 
1129  if (size > *pdwSize || !pTheirTcpTable)
1130  {
1131  *pdwSize = size;
1133  }
1134  else
1135  {
1136  pTheirTcpTable->dwNumEntries = count;
1137 
1138  for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1139  {
1140  if (pOurTcpTable->table[i].State == MIB_TCP_STATE_LISTEN)
1141  {
1142  memcpy(&pTheirTcpTable->table[count], &pOurTcpTable->table[i], sizeof(MIB_TCPROW));
1143  ++count;
1144  }
1145  }
1146  ASSERT(count == pTheirTcpTable->dwNumEntries);
1147 
1148  if (bOrder)
1149  qsort(pTheirTcpTable->table, pTheirTcpTable->dwNumEntries,
1150  sizeof(MIB_TCPROW), TcpTableSorter);
1151  }
1152 
1153  free(pOurTcpTable);
1154  }
1155  }
1156  break;
1157 
1159  {
1161  PMIB_TCPTABLE_OWNER_PID pTheirTcpTable = pTcpTable;
1162 
1163  if (pOurTcpTable)
1164  {
1166  if (size > *pdwSize || !pTheirTcpTable)
1167  {
1168  *pdwSize = size;
1170  }
1171  else
1172  {
1173  memcpy(pTheirTcpTable, pOurTcpTable, size);
1174 
1175  /* Don't sort on PID, so use basic helper */
1176  if (bOrder)
1177  qsort(pTheirTcpTable->table, pTheirTcpTable->dwNumEntries,
1179  }
1180 
1181  free(pOurTcpTable);
1182  }
1183  }
1184  break;
1185 
1187  {
1189  PMIB_TCPTABLE_OWNER_PID pTheirTcpTable = pTcpTable;
1190 
1191  if (pOurTcpTable)
1192  {
1193  for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1194  {
1195  if (pOurTcpTable->table[i].dwState != MIB_TCP_STATE_LISTEN)
1196  {
1197  ++count;
1198  }
1199  }
1200 
1202  if (size > *pdwSize || !pTheirTcpTable)
1203  {
1204  *pdwSize = size;
1206  }
1207  else
1208  {
1209  pTheirTcpTable->dwNumEntries = count;
1210 
1211  for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1212  {
1213  if (pOurTcpTable->table[i].dwState != MIB_TCP_STATE_LISTEN)
1214  {
1215  memcpy(&pTheirTcpTable->table[count], &pOurTcpTable->table[i], sizeof(MIB_TCPROW_OWNER_PID));
1216  ++count;
1217  }
1218  }
1219  ASSERT(count == pTheirTcpTable->dwNumEntries);
1220 
1221  /* Don't sort on PID, so use basic helper */
1222  if (bOrder)
1223  qsort(pTheirTcpTable->table, pTheirTcpTable->dwNumEntries,
1225  }
1226 
1227  free(pOurTcpTable);
1228  }
1229  }
1230  break;
1231 
1233  {
1235  PMIB_TCPTABLE_OWNER_PID pTheirTcpTable = pTcpTable;
1236 
1237  if (pOurTcpTable)
1238  {
1239  for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1240  {
1241  if (pOurTcpTable->table[i].dwState == MIB_TCP_STATE_LISTEN)
1242  {
1243  ++count;
1244  }
1245  }
1246 
1248  if (size > *pdwSize || !pTheirTcpTable)
1249  {
1250  *pdwSize = size;
1252  }
1253  else
1254  {
1255  pTheirTcpTable->dwNumEntries = count;
1256 
1257  for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1258  {
1259  if (pOurTcpTable->table[i].dwState == MIB_TCP_STATE_LISTEN)
1260  {
1261  memcpy(&pTheirTcpTable->table[count], &pOurTcpTable->table[i], sizeof(MIB_TCPROW_OWNER_PID));
1262  ++count;
1263  }
1264  }
1265  ASSERT(count == pTheirTcpTable->dwNumEntries);
1266 
1267  /* Don't sort on PID, so use basic helper */
1268  if (bOrder)
1269  qsort(pTheirTcpTable->table, pTheirTcpTable->dwNumEntries,
1271  }
1272 
1273  free(pOurTcpTable);
1274  }
1275  }
1276  break;
1277 
1279  {
1281  PMIB_TCPTABLE_OWNER_MODULE pTheirTcpTable = pTcpTable;
1282 
1283  if (pOurTcpTable)
1284  {
1286  if (size > *pdwSize || !pTheirTcpTable)
1287  {
1288  *pdwSize = size;
1290  }
1291  else
1292  {
1293  memcpy(pTheirTcpTable, pOurTcpTable, size);
1294 
1295  /* Don't sort on PID, so use basic helper */
1296  if (bOrder)
1297  qsort(pTheirTcpTable->table, pTheirTcpTable->dwNumEntries,
1299  }
1300 
1301  free(pOurTcpTable);
1302  }
1303  }
1304  break;
1305 
1307  {
1309  PMIB_TCPTABLE_OWNER_MODULE pTheirTcpTable = pTcpTable;
1310 
1311  if (pOurTcpTable)
1312  {
1313  for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1314  {
1315  if (pOurTcpTable->table[i].dwState != MIB_TCP_STATE_LISTEN)
1316  {
1317  ++count;
1318  }
1319  }
1320 
1322  if (size > *pdwSize || !pTheirTcpTable)
1323  {
1324  *pdwSize = size;
1326  }
1327  else
1328  {
1329  pTheirTcpTable->dwNumEntries = count;
1330 
1331  for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1332  {
1333  if (pOurTcpTable->table[i].dwState != MIB_TCP_STATE_LISTEN)
1334  {
1335  memcpy(&pTheirTcpTable->table[count], &pOurTcpTable->table[i], sizeof(MIB_TCPROW_OWNER_MODULE));
1336  ++count;
1337  }
1338  }
1339  ASSERT(count == pTheirTcpTable->dwNumEntries);
1340 
1341  /* Don't sort on PID, so use basic helper */
1342  if (bOrder)
1343  qsort(pTheirTcpTable->table, pTheirTcpTable->dwNumEntries,
1345  }
1346 
1347  free(pOurTcpTable);
1348  }
1349  }
1350  break;
1351 
1353  {
1355  PMIB_TCPTABLE_OWNER_MODULE pTheirTcpTable = pTcpTable;
1356 
1357  if (pOurTcpTable)
1358  {
1359  for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1360  {
1361  if (pOurTcpTable->table[i].dwState == MIB_TCP_STATE_LISTEN)
1362  {
1363  ++count;
1364  }
1365  }
1366 
1368  if (size > *pdwSize || !pTheirTcpTable)
1369  {
1370  *pdwSize = size;
1372  }
1373  else
1374  {
1375  pTheirTcpTable->dwNumEntries = count;
1376 
1377  for (i = 0, count = 0; i < pOurTcpTable->dwNumEntries; ++i)
1378  {
1379  if (pOurTcpTable->table[i].dwState == MIB_TCP_STATE_LISTEN)
1380  {
1381  memcpy(&pTheirTcpTable->table[count], &pOurTcpTable->table[i], sizeof(MIB_TCPROW_OWNER_MODULE));
1382  ++count;
1383  }
1384  }
1385  ASSERT(count == pTheirTcpTable->dwNumEntries);
1386 
1387  /* Don't sort on PID, so use basic helper */
1388  if (bOrder)
1389  qsort(pTheirTcpTable->table, pTheirTcpTable->dwNumEntries,
1391  }
1392 
1393  free(pOurTcpTable);
1394  }
1395  }
1396  break;
1397 
1398  default:
1400  break;
1401  }
1402 
1403  return ret;
1404 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
PVOID getTcpTable(CLASS_TABLE Class)
struct _MIB_TCPROW_OWNER_MODULE MIB_TCPROW_OWNER_MODULE
MIB_TCPROW table[1]
Definition: tcpmib.h:67
GLuint GLuint GLsizei count
Definition: gl.h:1545
static int TcpTableSorter(const void *a, const void *b)
#define free
Definition: debug_ros.c:5
DWORD dwNumEntries
Definition: tcpmib.h:66
#define NO_ERROR
Definition: dderror.h:5
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
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
unsigned long DWORD
Definition: ntddk_ex.h:95
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
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
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
#define AF_INET
Definition: tcpip.h:117
#define UNIMPLEMENTED
Definition: debug.h:114
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 1443 of file iphlpapi_main.c.

1444 {
1445  DWORD size;
1446  DWORD ret = NO_ERROR;
1447 
1448  if (!pdwSize)
1449  {
1450  return ERROR_INVALID_PARAMETER;
1451  }
1452 
1453  if (ulAf != AF_INET)
1454  {
1455  UNIMPLEMENTED;
1456  return ERROR_INVALID_PARAMETER;
1457  }
1458 
1459  switch (TableClass)
1460  {
1461  case UDP_TABLE_BASIC:
1462  {
1463  PMIB_UDPTABLE pOurUdpTable = getUdpTable(ClassBasic);
1464  PMIB_UDPTABLE pTheirUdpTable = pUdpTable;
1465 
1466  if (pOurUdpTable)
1467  {
1468  size = FIELD_OFFSET(MIB_UDPTABLE, table) + pOurUdpTable->dwNumEntries * sizeof(MIB_UDPROW);
1469  if (size > *pdwSize || !pTheirUdpTable)
1470  {
1471  *pdwSize = size;
1473  }
1474  else
1475  {
1476  memcpy(pTheirUdpTable, pOurUdpTable, size);
1477 
1478  if (bOrder)
1479  qsort(pTheirUdpTable->table, pTheirUdpTable->dwNumEntries,
1480  sizeof(MIB_UDPROW), UdpTableSorter);
1481  }
1482 
1483  free(pOurUdpTable);
1484  }
1485  }
1486  break;
1487 
1488  case UDP_TABLE_OWNER_PID:
1489  {
1491  PMIB_UDPTABLE_OWNER_PID pTheirUdpTable = pUdpTable;
1492 
1493  if (pOurUdpTable)
1494  {
1496  if (size > *pdwSize || !pTheirUdpTable)
1497  {
1498  *pdwSize = size;
1500  }
1501  else
1502  {
1503  memcpy(pTheirUdpTable, pOurUdpTable, size);
1504 
1505  if (bOrder)
1506  qsort(pTheirUdpTable->table, pTheirUdpTable->dwNumEntries,
1508  }
1509 
1510  free(pOurUdpTable);
1511  }
1512  }
1513  break;
1514 
1516  {
1518  PMIB_UDPTABLE_OWNER_MODULE pTheirUdpTable = pUdpTable;
1519 
1520  if (pOurUdpTable)
1521  {
1523  if (size > *pdwSize || !pTheirUdpTable)
1524  {
1525  *pdwSize = size;
1527  }
1528  else
1529  {
1530  memcpy(pTheirUdpTable, pOurUdpTable, size);
1531 
1532  if (bOrder)
1533  qsort(pTheirUdpTable->table, pTheirUdpTable->dwNumEntries,
1535  }
1536 
1537  free(pOurUdpTable);
1538  }
1539  }
1540  break;
1541 
1542  default:
1544  break;
1545  }
1546 
1547  return ret;
1548 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
struct _MIB_UDPROW MIB_UDPROW
#define free
Definition: debug_ros.c:5
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
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:254
#define AF_INET
Definition: tcpip.h:117
#define UNIMPLEMENTED
Definition: debug.h:114
PVOID getUdpTable(CLASS_TABLE Class)
#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 1564 of file iphlpapi_main.c.

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

◆ GetIcmpStatistics()

DWORD WINAPI GetIcmpStatistics ( PMIB_ICMP  pStats)

Definition at line 1587 of file iphlpapi_main.c.

1588 {
1589  DWORD ret;
1590 
1591  TRACE("pStats %p\n", pStats);
1592  ret = getICMPStats(pStats);
1593  TRACE("returning %ld\n", ret);
1594  return ret;
1595 }
#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 3393 of file iphlpapi_main.c.

3394 {
3395  FIXME(":stub\n");
3396 
3397  if (!pStats)
3398  return ERROR_INVALID_PARAMETER;
3399 
3400  if (dwFamily != AF_INET && dwFamily != AF_INET6)
3401  return ERROR_INVALID_PARAMETER;
3402 
3403  return 0L;
3404 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define FIXME(fmt,...)
Definition: debug.h:110
#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 1611 of file iphlpapi_main.c.

1612 {
1613  DWORD ret;
1614  const char *name;
1615 
1616  TRACE("pIfRow %p\n", pIfRow);
1617  if (!pIfRow)
1618  return ERROR_INVALID_PARAMETER;
1619 
1621  if (name) {
1622  ret = getInterfaceEntryByIndex(pIfRow->dwIndex, pIfRow);
1623  if (ret == NO_ERROR)
1624  ret = getInterfaceStatsByName(name, pIfRow);
1626  }
1627  else
1629  TRACE("returning %ld\n", ret);
1630  return ret;
1631 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#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:36
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 1661 of file iphlpapi_main.c.

1662 {
1663  DWORD ret;
1664 
1665  TRACE("pIfTable %p, pdwSize %p, bOrder %ld\n", pdwSize, pdwSize,
1666  (DWORD)bOrder);
1667  if (!pdwSize)
1669  else {
1670  DWORD numInterfaces = getNumInterfaces();
1671  ULONG size;
1672  TRACE("GetIfTable: numInterfaces = %d\n", (int)numInterfaces);
1673  size = sizeof(MIB_IFTABLE) + (numInterfaces - 1) * sizeof(MIB_IFROW);
1674 
1675  if (!pIfTable || *pdwSize < size) {
1676  *pdwSize = size;
1678  }
1679  else {
1681 
1682  if (table) {
1683  size = sizeof(MIB_IFTABLE) + (table->numIndexes - 1) *
1684  sizeof(MIB_IFROW);
1685  if (*pdwSize < size) {
1686  *pdwSize = size;
1688  }
1689  else {
1690  DWORD ndx;
1691 
1692  pIfTable->dwNumEntries = 0;
1693  for (ndx = 0; ndx < table->numIndexes; ndx++) {
1694  pIfTable->table[ndx].dwIndex = table->indexes[ndx];
1695  GetIfEntry(&pIfTable->table[ndx]);
1696  pIfTable->dwNumEntries++;
1697  }
1698  if (bOrder)
1699  qsort(pIfTable->table, pIfTable->dwNumEntries, sizeof(MIB_IFROW),
1700  IfTableSorter);
1701  ret = NO_ERROR;
1702  }
1703  free(table);
1704  }
1705  else
1707  }
1708  }
1709  TRACE("returning %ld\n", ret);
1710  return ret;
1711 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
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:395
unsigned long DWORD
Definition: ntddk_ex.h:95
#define HeapFree(x, y, z)
Definition: compat.h:394

Referenced by GetAdaptersInfo().

◆ GetInterfaceInfo()

DWORD WINAPI GetInterfaceInfo ( PIP_INTERFACE_INFO  pIfTable,
PULONG  dwOutBufLen 
)

Definition at line 1728 of file iphlpapi_main.c.

1729 {
1730  DWORD ret;
1731 
1732  TRACE("pIfTable %p, dwOutBufLen %p\n", pIfTable, dwOutBufLen);
1733  if (!dwOutBufLen)
1735  else {
1736  DWORD numNonLoopbackInterfaces = getNumNonLoopbackInterfaces();
1737  ULONG size;
1738  TRACE("numNonLoopbackInterfaces == 0x%x\n", numNonLoopbackInterfaces);
1739  size = sizeof(IP_INTERFACE_INFO) + (numNonLoopbackInterfaces) *
1740  sizeof(IP_ADAPTER_INDEX_MAP);
1741 
1742  if (!pIfTable || *dwOutBufLen < size) {
1743  *dwOutBufLen = size;
1745  }
1746  else {
1748 
1749  if (table) {
1750  TRACE("table->numIndexes == 0x%x\n", table->numIndexes);
1751  size = sizeof(IP_INTERFACE_INFO) + (table->numIndexes) *
1752  sizeof(IP_ADAPTER_INDEX_MAP);
1753  if (*dwOutBufLen < size) {
1754  *dwOutBufLen = size;
1756  }
1757  else {
1758  DWORD ndx;
1759 
1760  pIfTable->NumAdapters = 0;
1761  for (ndx = 0; ndx < table->numIndexes; ndx++) {
1762  const char *walker, *name;
1763  WCHAR *assigner;
1764 
1765  pIfTable->Adapter[ndx].Index = table->indexes[ndx];
1766  name = getInterfaceNameByIndex(table->indexes[ndx]);
1767  for (walker = name, assigner = pIfTable->Adapter[ndx].Name;
1768  walker && *walker &&
1769  assigner - pIfTable->Adapter[ndx].Name < MAX_ADAPTER_NAME - 1;
1770  walker++, assigner++)
1771  *assigner = *walker;
1772  *assigner = 0;
1774  pIfTable->NumAdapters++;
1775  }
1776  ret = NO_ERROR;
1777  }
1778  free(table);
1779  }
1780  else
1782  }
1783  }
1784  TRACE("returning %ld\n", ret);
1785  return ret;
1786 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
IP_ADAPTER_INDEX_MAP Adapter[1]
Definition: ipexport.h:141
#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:136
#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:36
#define MAX_ADAPTER_NAME
Definition: ipexport.h:132
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 3413 of file iphlpapi_main.c.

3416 {
3418  DWORD result, type;
3419  WCHAR szKeyName[2*MAX_PATH];
3420  HRESULT hr;
3421  HKEY hKey;
3422 
3423  if (pInterfaceGUID == NULL || pOutBufLen == NULL)
3424  return ERROR_INVALID_PARAMETER;
3425 
3426  result = RtlStringFromGUID(pInterfaceGUID, &GuidString);
3427 
3428  if (!NT_SUCCESS(result))
3429  {
3430  // failed to convert guid to string
3431  return RtlNtStatusToDosError(result);
3432  }
3433 
3434  hr = StringCbPrintfW(szKeyName, sizeof(szKeyName), L"SYSTEM\\CurrentControlSet\\Control\\Network\\{4D36E972-E325-11CE-BFC1-08002BE10318}\\%s\\Connection", GuidString.Buffer);
3436 
3437  if (FAILED(hr))
3438  {
3439  // key name is too long
3440  return ERROR_BUFFER_OVERFLOW;
3441  }
3442 
3443  result = RegOpenKeyExW(HKEY_LOCAL_MACHINE, szKeyName, 0, KEY_READ, &hKey);
3444 
3445  if (result != ERROR_SUCCESS)
3446  {
3447  // failed to find adapter entry
3448  return ERROR_NOT_FOUND;
3449  }
3450 
3451  result = RegQueryValueExW(hKey, L"Name", NULL, &type, (PVOID)pInterfaceName, pOutBufLen);
3452 
3453  RegCloseKey(hKey);
3454 
3455  if (result == ERROR_MORE_DATA)
3456  {
3457  *pOutBufLen = MAX_INTERFACE_NAME_LEN * 2;
3459  }
3460 
3461  if (result != ERROR_SUCCESS || type != REG_SZ)
3462  {
3463  // failed to read adapter name
3464  return ERROR_NO_DATA;
3465  }
3466  return ERROR_SUCCESS;
3467 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
static PWSTR GuidString
Definition: apphelp.c:91
#define ERROR_SUCCESS
Definition: deptool.c:10
HRESULT hr
Definition: shlfolder.c:183
#define KEY_READ
Definition: nt_native.h:1023
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
smooth NULL
Definition: ftsmooth.c:416
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:4134
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
LONG HRESULT
Definition: typedefs.h:77
#define ERROR_NO_DATA
Definition: winerror.h:284
#define MAX_PATH
Definition: compat.h:26
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
NTSYSAPI NTSTATUS WINAPI RtlStringFromGUID(REFGUID, PUNICODE_STRING)
#define ERROR_MORE_DATA
Definition: dderror.h:13
NTSYSAPI ULONG WINAPI RtlNtStatusToDosError(NTSTATUS)
#define ERROR_NOT_FOUND
Definition: winerror.h:690
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
GLuint64EXT * result
Definition: glext.h:11304
#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 1816 of file iphlpapi_main.c.

1817 {
1818  DWORD ret;
1819 
1820  TRACE("pIpAddrTable %p, pdwSize %p, bOrder %ld\n", pIpAddrTable, pdwSize,
1821  (DWORD)bOrder);
1822  if (!pdwSize)
1824  else {
1825  DWORD numInterfaces = getNumInterfaces();
1826  ULONG size = sizeof(MIB_IPADDRTABLE) + (numInterfaces - 1) *
1827  sizeof(MIB_IPADDRROW);
1828 
1829  if (!pIpAddrTable || *pdwSize < size) {
1830  *pdwSize = size;
1832  }
1833  else {
1835 
1836  if (table) {
1837  size = sizeof(MIB_IPADDRTABLE) + (table->numIndexes - 1) *
1838  sizeof(MIB_IPADDRROW);
1839  if (*pdwSize < size) {
1840  *pdwSize = size;
1842  }
1843  else {
1844  DWORD ndx, bcast;
1845 
1846  pIpAddrTable->dwNumEntries = 0;
1847  for (ndx = 0; ndx < table->numIndexes; ndx++) {
1848  pIpAddrTable->table[ndx].dwIndex = table->indexes[ndx];
1849  pIpAddrTable->table[ndx].dwAddr =
1850  getInterfaceIPAddrByIndex(table->indexes[ndx]);
1851  pIpAddrTable->table[ndx].dwMask =
1852  getInterfaceMaskByIndex(table->indexes[ndx]);
1853  /* the dwBCastAddr member isn't the broadcast address, it indicates
1854  * whether the interface uses the 1's broadcast address (1) or the
1855  * 0's broadcast address (0).
1856  */
1857  bcast = getInterfaceBCastAddrByIndex(table->indexes[ndx]);
1858  pIpAddrTable->table[ndx].dwBCastAddr =
1859  (bcast & pIpAddrTable->table[ndx].dwMask) ? 1 : 0;
1860  /* FIXME: hardcoded reasm size, not sure where to get it */
1861  pIpAddrTable->table[ndx].dwReasmSize = 65535;
1862  pIpAddrTable->table[ndx].unused1 = 0;
1863  pIpAddrTable->table[ndx].wType = 0; /* aka unused2 */
1864  pIpAddrTable->dwNumEntries++;
1865  }
1866  if (bOrder)
1867  qsort(pIpAddrTable->table, pIpAddrTable->dwNumEntries,
1868  sizeof(MIB_IPADDRROW), IpAddrTableSorter);
1869  ret = NO_ERROR;
1870  }
1871  free(table);
1872  }
1873  else
1875  }
1876  }
1877  TRACE("returning %ld\n", ret);
1878  return ret;
1879 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
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(), GetIPv4ByIndex(), mib2IpAddrInit(), NetBTEnum(), and Test_WSAIoctl_InitTest().

◆ GetIpErrorString()

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

Definition at line 3150 of file iphlpapi_main.c.

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

◆ GetIpForwardTable()

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

Definition at line 1920 of file iphlpapi_main.c.

1921 {
1922  DWORD ret;
1923 
1924  TRACE("pIpForwardTable %p, pdwSize %p, bOrder %ld\n", pIpForwardTable,
1925  pdwSize, (DWORD)bOrder);
1926  if (!pdwSize)
1928  else {
1929  DWORD numRoutes = getNumRoutes();
1930  ULONG sizeNeeded = sizeof(MIB_IPFORWARDTABLE) + (numRoutes - 1) *
1931  sizeof(MIB_IPFORWARDROW);
1932 
1933  if (!pIpForwardTable || *pdwSize < sizeNeeded) {
1934  *pdwSize = sizeNeeded;
1936  }
1937  else {
1939  if (table) {
1940  sizeNeeded = sizeof(MIB_IPFORWARDTABLE) + (table->numRoutes - 1) *
1941  sizeof(MIB_IPFORWARDROW);
1942  if (*pdwSize < sizeNeeded) {
1943  *pdwSize = sizeNeeded;
1945  }
1946  else {
1947  DWORD ndx;
1948 
1949  pIpForwardTable->dwNumEntries = table->numRoutes;
1950  for (ndx = 0; ndx < numRoutes; ndx++) {
1951  pIpForwardTable->table[ndx].dwForwardIfIndex =
1952  table->routes[ndx].ifIndex;
1953  pIpForwardTable->table[ndx].dwForwardDest =
1954  table->routes[ndx].dest;
1955  pIpForwardTable->table[ndx].dwForwardMask =
1956  table->routes[ndx].mask;
1957  pIpForwardTable->table[ndx].dwForwardPolicy = 0;
1958  pIpForwardTable->table[ndx].dwForwardNextHop =
1959  table->routes[ndx].gateway;
1960  /* FIXME: this type is appropriate for local interfaces; may not
1961  always be appropriate */
1962  pIpForwardTable->table[ndx].dwForwardType = MIB_IPROUTE_TYPE_DIRECT;
1963  /* FIXME: other protos might be appropriate, e.g. the default route
1964  is typically set with MIB_IPPROTO_NETMGMT instead */
1965  pIpForwardTable->table[ndx].dwForwardProto = MIB_IPPROTO_LOCAL;
1966  /* punt on age and AS */
1967  pIpForwardTable->table[ndx].dwForwardAge = 0;
1968  pIpForwardTable->table[ndx].dwForwardNextHopAS = 0;
1969  pIpForwardTable->table[ndx].dwForwardMetric1 =
1970  table->routes[ndx].metric;
1971  /* rest of the metrics are 0.. */
1972  pIpForwardTable->table[ndx].dwForwardMetric2 = 0;
1973  pIpForwardTable->table[ndx].dwForwardMetric3 = 0;
1974  pIpForwardTable->table[ndx].dwForwardMetric4 = 0;
1975  pIpForwardTable->table[ndx].dwForwardMetric5 = 0;
1976  }
1977  if (bOrder)
1978  qsort(pIpForwardTable->table, pIpForwardTable->dwNumEntries,
1980  ret = NO_ERROR;
1981  }
1982  HeapFree(GetProcessHeap(), 0, table);
1983  }
1984  else
1986  }
1987  }
1988  TRACE("returning %ld\n", ret);
1989  return ret;
1990 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
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:395
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:394
#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 2020 of file iphlpapi_main.c.

2021 {
2022  DWORD ret = NO_ERROR;
2023 
2024  TRACE("pIpNetTable %p, pdwSize %p, bOrder %d\n", pIpNetTable, pdwSize,
2025  (DWORD)bOrder);
2026  if (!pdwSize)
2028  else {
2029  DWORD numEntries = getNumArpEntries();
2030  ULONG size = sizeof(MIB_IPNETTABLE);
2031 
2032  if (numEntries > 1)
2033  size += (numEntries - 1) * sizeof(MIB_IPNETROW);
2034  if (!pIpNetTable || *pdwSize < size) {
2035  *pdwSize = size;
2037  }
2038  else {
2040  if (table) {
2041  size = sizeof(MIB_IPNETTABLE);
2042  if (table->dwNumEntries > 1)
2043  size += (table->dwNumEntries - 1) * sizeof(MIB_IPNETROW);
2044  if (*pdwSize < size) {
2045  *pdwSize = size;
2047  }
2048  else {
2049  *pdwSize = size;
2050  memcpy(pIpNetTable, table, size);
2051  if (bOrder)
2052  qsort(pIpNetTable->table, pIpNetTable->dwNumEntries,
2053  sizeof(MIB_IPNETROW), IpNetTableSorter);
2054  ret = NO_ERROR;
2055  }
2056  HeapFree(GetProcessHeap(), 0, table);
2057  }
2058  }
2059  }
2060  TRACE("returning %d\n", ret);
2061  return ret;
2062 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
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:395
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:394
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 2078 of file iphlpapi_main.c.

2079 {
2080  return GetIpStatisticsEx(pStats, PF_INET);
2081 }
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 2097 of file iphlpapi_main.c.

2098 {
2099  DWORD ret;
2100 
2101  TRACE("pStats %p\n", pStats);
2102  ret = getIPStats(pStats, dwFamily);
2103  TRACE("returning %ld\n", ret);
2104  return ret;
2105 }
#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 2121 of file iphlpapi_main.c.

2122 {
2123  DWORD ret, size, type;
2124  LONG regReturn;
2125  HKEY hKey;
2126  PIPHLP_RES_INFO resInfo;
2127 
2128  TRACE("pFixedInfo %p, pOutBufLen %p\n", pFixedInfo, pOutBufLen);
2129  if (!pOutBufLen)
2130  return ERROR_INVALID_PARAMETER;
2131 
2132  resInfo = getResInfo();
2133  if (!resInfo)
2134  return ERROR_OUTOFMEMORY;
2135 
2136  size = sizeof(FIXED_INFO) + (resInfo->riCount > 1 ? (resInfo->riCount-1) *
2137  sizeof(IP_ADDR_STRING) : 0);
2138  if (!pFixedInfo || *pOutBufLen < size) {
2139  *pOutBufLen = size;
2140  disposeResInfo( resInfo );
2141  return ERROR_BUFFER_OVERFLOW;
2142  }
2143 
2144  memset(pFixedInfo, 0, size);
2145  /* Check for DhcpHostname and DhcpDomain first */
2146  regReturn = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
2147  "SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters",
2148  0,
2149  KEY_READ,
2150  &hKey);
2151  if (regReturn == ERROR_SUCCESS) {
2152  /* Windows doesn't honor DHCP option 12 even if RFC requires it if it is returned by DHCP server! */
2153 #if 0
2154  type = REG_SZ;
2155  size = sizeof(pFixedInfo->HostName);
2156  regReturn = RegQueryValueExA(hKey,
2157  "DhcpHostname",
2158  NULL,
2159  &type,
2160  (LPBYTE)pFixedInfo->HostName,
2161  &size);
2162  if (regReturn == ERROR_FILE_NOT_FOUND || (regReturn == ERROR_SUCCESS && size < 1))
2163  {
2164 #endif
2165  type = REG_SZ;
2166  size = sizeof(pFixedInfo->HostName);
2167  regReturn = RegQueryValueExA(hKey,
2168  "Hostname",
2169  NULL,
2170  &type,
2171  (LPBYTE)pFixedInfo->HostName,
2172  &size);
2173 #if 0
2174  }
2175 #endif
2176 
2177  type = REG_SZ;
2178  size = sizeof(pFixedInfo->DomainName);
2179  regReturn = RegQueryValueExA(hKey,
2180  "DhcpDomain",
2181  NULL,
2182  &type,
2183  (LPBYTE)pFixedInfo->DomainName,
2184  &size);
2185  if (regReturn == ERROR_FILE_NOT_FOUND || (regReturn == ERROR_SUCCESS && size < 1))
2186  {
2187  type = REG_SZ;
2188  size = sizeof(pFixedInfo->DomainName);
2189  regReturn = RegQueryValueExA(hKey,
2190  "Domain",
2191  NULL,
2192  &type,
2193  (LPBYTE)pFixedInfo->DomainName,
2194  &size);
2195  }
2196  RegCloseKey(hKey);
2197  }
2198 
2199  TRACE("GetComputerNameExA: %s\n", pFixedInfo->DomainName);
2200 
2201  if (resInfo->riCount > 0)
2202  {
2203  CopyMemory(&pFixedInfo->DnsServerList, resInfo->DnsList, sizeof(IP_ADDR_STRING));
2204  if (resInfo->riCount > 1)
2205  {
2206  IP_ADDR_STRING *pSrc = resInfo->DnsList->Next;
2207  IP_ADDR_STRING *pTarget = (struct _IP_ADDR_STRING*)((char*)pFixedInfo + sizeof(FIXED_INFO));
2208 
2209  pFixedInfo->DnsServerList.Next = pTarget;
2210 
2211  do
2212  {
2213  CopyMemory(pTarget, pSrc, sizeof(IP_ADDR_STRING));
2214  resInfo->riCount--;
2215  if (resInfo->riCount > 1)
2216  {
2217  pTarget->Next = (IP_ADDR_STRING*)((char*)pTarget + sizeof(IP_ADDR_STRING));
2218  pTarget = pTarget->Next;
2219  pSrc = pSrc->Next;
2220  }
2221  else
2222  {
2223  pTarget->Next = NULL;
2224  break;
2225  }
2226  }
2227  while(TRUE);
2228  }
2229  else
2230  {
2231  pFixedInfo->DnsServerList.Next = NULL;
2232  }
2233  }
2234 
2235  pFixedInfo->NodeType = HYBRID_NODETYPE;
2236  regReturn = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
2237  "SYSTEM\\CurrentControlSet\\Services\\VxD\\MSTCP", 0, KEY_READ, &hKey);
2238  if (regReturn != ERROR_SUCCESS)
2239  regReturn = RegOpenKeyExA(HKEY_LOCAL_MACHINE,
2240  "SYSTEM\\CurrentControlSet\\Services\\NetBT\\Parameters", 0, KEY_READ,
2241  &hKey);
2242  if (regReturn == ERROR_SUCCESS)
2243  {
2244  DWORD size = sizeof(pFixedInfo->ScopeId);
2245 
2246  RegQueryValueExA(hKey, "ScopeID", NULL, NULL, (PBYTE)pFixedInfo->ScopeId, &size);
2247  RegCloseKey(hKey);
2248  }
2249 
2250  disposeResInfo( resInfo );
2251  /* FIXME: can check whether routing's enabled in /proc/sys/net/ipv4/ip_forward
2252  I suppose could also check for a listener on port 53 to set EnableDns */
2253  ret = NO_ERROR;
2254  TRACE("returning %ld\n", ret);
2255 
2256  return ret;
2257 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
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:4041
DWORD riCount
Definition: resinfo.h:25
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#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:3346
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#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:52
long LONG
Definition: pedump.c:60
smooth NULL
Definition: ftsmooth.c:416
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:1633
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
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 DnsQuery_W(), getdomainname(), main(), ShowInfo(), test_GetNetworkParams(), and TestHostName().

◆ GetNumberOfInterfaces()

DWORD WINAPI GetNumberOfInterfaces ( PDWORD  pdwNumIf)

Definition at line 2273 of file iphlpapi_main.c.

2274 {
2275  DWORD ret;
2276 
2277  TRACE("pdwNumIf %p\n", pdwNumIf);
2278  if (!pdwNumIf)
2280  else {
2281  *pdwNumIf = getNumInterfaces();
2282  ret = NO_ERROR;
2283  }
2284  TRACE("returning %ld\n", ret);
2285  return ret;
2286 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#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 2289 of file iphlpapi_main.c.

2290 {
2291  HANDLE Process;
2292  DWORD FileLen, PathLen, Error;
2295 
2296  if (IsBadWritePtr(pdwSize, sizeof(DWORD)) ||
2297  IsBadWritePtr(Buffer, *pdwSize))
2298  {
2299  return ERROR_INVALID_PARAMETER;
2300  }
2301 
2302  if (OwningPid == 0)
2303  {
2304  return ERROR_NOT_FOUND;
2305  }
2306 
2308  if (Process == NULL)
2309  {
2310  return GetLastError();
2311  }
2312 
2314  if (FileLen != 0)
2315  {
2317  if (PathLen == 0)
2318  {
2320  return GetLastError();
2321  }
2322 
2323  /* Add NULL char */
2324  ++FileLen;
2325  ++PathLen;
2326  PathLen *= sizeof(WCHAR);
2327  FileLen *= sizeof(WCHAR);
2328  }
2329  else
2330  {
2331  Error = GetLastError();
2332 
2333  if (Error == ERROR_PARTIAL_COPY)
2334  {
2335  wcscpy(File, L"System");
2336  wcscpy(Path, L"System");
2337 
2338  PathLen = sizeof(L"System");
2339  FileLen = sizeof(L"System");
2340  }
2341  else
2342  {
2344  return Error;
2345  }
2346  }
2347 
2349 
2350  if (*pdwSize < sizeof(TCPIP_OWNER_MODULE_BASIC_INFO) + PathLen + FileLen)
2351  {
2352  *pdwSize = sizeof(TCPIP_OWNER_MODULE_BASIC_INFO) + PathLen + FileLen;
2354  }
2355 
2356  BasicInfo = Buffer;
2357  BasicInfo->pModuleName = (PVOID)((ULONG_PTR)BasicInfo + sizeof(TCPIP_OWNER_MODULE_BASIC_INFO));
2358  BasicInfo->pModulePath = (PVOID)((ULONG_PTR)BasicInfo->pModuleName + FileLen);
2359  wcscpy(BasicInfo->pModuleName, File);
2360  wcscpy(BasicInfo->pModulePath, Path);
2361  *pdwSize = sizeof(TCPIP_OWNER_MODULE_BASIC_INFO) + PathLen + FileLen;
2362 
2363  return NO_ERROR;
2364 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define CloseHandle
Definition: compat.h:398
BOOL NTAPI IsBadWritePtr(IN LPVOID lp, IN UINT_PTR ucb)
Definition: except.c:885
#define PROCESS_QUERY_INFORMATION
Definition: pstypes.h:158
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define NO_ERROR
Definition: dderror.h:5
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define ERROR_PARTIAL_COPY
Definition: winerror.h:303
#define GetModuleFileNameExW(w, x, y, z)
Definition: compat.h:571
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
void * PVOID
Definition: retypes.h:9
DWORD WINAPI GetModuleBaseNameW(HANDLE hProcess, HMODULE hModule, LPWSTR lpBaseName, DWORD nSize)
Definition: psapi.c:930
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:26
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:1257
PRTL_UNICODE_STRING_BUFFER Path
#define ERROR_NOT_FOUND
Definition: winerror.h:690
#define PROCESS_VM_READ
Definition: pstypes.h:153
_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
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
#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 2366 of file iphlpapi_main.c.

2367 {
2368  UINT Size;
2369  HRESULT Res;
2370  HANDLE hAdvapi32;
2371  WCHAR SysDir[MAX_PATH];
2373  ULONG (NTAPI *_I_QueryTagInformation)(PVOID, DWORD, PVOID);
2374  struct
2375  {
2376  DWORD ProcessId;
2377  DWORD ServiceTag;
2378  DWORD TagType;
2379  PWSTR Buffer;
2380  } ServiceQuery;
2381 
2382  if (IsBadWritePtr(pdwSize, sizeof(DWORD)) ||
2383  IsBadWritePtr(Buffer, *pdwSize))
2384  {
2385  return ERROR_INVALID_PARAMETER;
2386  }
2387 
2388  /* First, secure (avoid injections) load advapi32.dll */
2389  Size = GetSystemDirectoryW(SysDir, MAX_PATH);
2390  if (Size == 0)
2391  {
2392  return GetLastError();
2393  }
2394 
2395  Res = StringCchCatW(&SysDir[Size], MAX_PATH - Size, L"\\advapi32.dll");
2396  if (FAILED(Res))
2397  {
2398  return Res;
2399  }
2400 
2401  hAdvapi32 = GetModuleHandleW(SysDir);
2402  if (hAdvapi32 == NULL)
2403  {
2404  return GetLastError();
2405  }
2406 
2407  /* Now, we'll query the service associated with the tag */
2408  _I_QueryTagInformation = (PVOID)GetProcAddress(hAdvapi32, "I_QueryTagInformation");
2409  if (_I_QueryTagInformation == NULL)
2410  {
2411  return GetLastError();
2412  }
2413 
2414  /* Set tag and PID for the query */
2415  ServiceQuery.ProcessId = OwningPid;
2416  ServiceQuery.ServiceTag = OwningTag;
2417  ServiceQuery.TagType = 0;
2418  ServiceQuery.Buffer = NULL;
2419 
2420  /* And query */
2421  Res = _I_QueryTagInformation(NULL, 1, &ServiceQuery);
2422  if (Res != ERROR_SUCCESS)
2423  {
2424  return Res;
2425  }
2426 
2427  /* Compute service name length */
2428  Size = wcslen(ServiceQuery.Buffer) * sizeof(WCHAR) + sizeof(UNICODE_NULL);
2429 
2430  /* We'll copy it twice, so make sure we have enough room */
2431  if (*pdwSize < sizeof(TCPIP_OWNER_MODULE_BASIC_INFO) + 2 * Size)
2432  {
2433  *pdwSize = sizeof(TCPIP_OWNER_MODULE_BASIC_INFO) + 2 * Size;
2434  LocalFree(ServiceQuery.Buffer);
2436  }
2437 
2438  /* Copy back data */
2439  BasicInfo = Buffer;
2440  BasicInfo->pModuleName = (PVOID)((ULONG_PTR)BasicInfo + sizeof(TCPIP_OWNER_MODULE_BASIC_INFO));
2441  BasicInfo->pModulePath = (PVOID)((ULONG_PTR)BasicInfo->pModuleName + Size);
2442  wcscpy(BasicInfo->pModuleName, ServiceQuery.Buffer);
2443  wcscpy(BasicInfo->pModulePath, ServiceQuery.Buffer);
2444  *pdwSize = sizeof(TCPIP_OWNER_MODULE_BASIC_INFO) + 2 * Size;
2445  LocalFree(ServiceQuery.Buffer);
2446 
2447  return NO_ERROR;
2448 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2697
BOOL NTAPI IsBadWritePtr(IN LPVOID lp, IN UINT_PTR ucb)
Definition: except.c:885
#define ERROR_SUCCESS
Definition: deptool.c:10
uint16_t * PWSTR
Definition: typedefs.h:54
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#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:63
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
#define UNICODE_NULL
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
void * PVOID
Definition: retypes.h:9
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
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
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
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
unsigned int ULONG
Definition: retypes.h:1
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:845
#define GetProcAddress(x, y)
Definition: compat.h:410
IN BOOLEAN OUT PSTR Buffer
Definition: progress.h:34
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
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 2469 of file iphlpapi_main.c.

2470 {
2471  /* If we have a service tag, that's a service connection */
2472  if (pTcpEntry->OwningModuleInfo[0] != 0)
2473  {
2474  return GetOwnerModuleFromTagEntry(pTcpEntry->dwOwningPid, (DWORD)(pTcpEntry->OwningModuleInfo[0]), Class, Buffer, pdwSize);
2475  }
2476  else
2477  {
2478  return GetOwnerModuleFromPidEntry(pTcpEntry->dwOwningPid, Class, Buffer, pdwSize);
2479  }
2480 }
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 2501 of file iphlpapi_main.c.

2502 {
2503  /* If we have a service tag, that's a service connection */
2504  if (pUdpEntry->OwningModuleInfo[0] != 0)
2505  {
2506  return GetOwnerModuleFromTagEntry(pUdpEntry->dwOwningPid, (DWORD)(pUdpEntry->OwningModuleInfo[0]), Class, Buffer, pdwSize);
2507  }
2508  else
2509  {
2510  return GetOwnerModuleFromPidEntry(pUdpEntry->dwOwningPid, Class, Buffer, pdwSize);
2511  }
2512 }
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 2559 of file iphlpapi_main.c.

2560 {
2561  HKEY hkey;
2562  DWORD dwSize = 0;
2563  const char *ifName;
2565  WCHAR keyname[200] = L"SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters\\Interfaces\\";
2566 
2567  if (!pOutBufLen)
2568  return ERROR_INVALID_PARAMETER;
2569 
2570  if (!pPerAdapterInfo || *pOutBufLen < sizeof(IP_PER_ADAPTER_INFO))
2571  {
2572  *pOutBufLen = sizeof(IP_PER_ADAPTER_INFO);
2573  return ERROR_BUFFER_OVERFLOW;
2574  }
2575 
2576  ifName = getInterfaceNameByIndex(IfIndex);
2577  if (!ifName)
2578  return ERROR_INVALID_PARAMETER;
2579 
2580  MultiByteToWideChar(CP_ACP, 0, ifName, -1, &keyname[62], sizeof(keyname)/sizeof(WCHAR) - 63);
2581  HeapFree(GetProcessHeap(), 0, (LPVOID)ifName);
2582 
2583  if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, keyname, 0, KEY_READ, &hkey) != ERROR_SUCCESS)
2584  {
2585  return ERROR_NOT_SUPPORTED;
2586  }
2587  Context.NumServers = 0;
2588  Context.uSizeAvailable = *pOutBufLen;
2589  Context.uSizeRequired = sizeof(IP_PER_ADAPTER_INFO);
2590  Context.pData = pPerAdapterInfo;
2591 
2592  if (*pOutBufLen >= sizeof(IP_PER_ADAPTER_INFO))
2593  ZeroMemory(pPerAdapterInfo, sizeof(IP_PER_ADAPTER_INFO));
2594 
2596 
2597  if (Context.uSizeRequired > Context.uSizeAvailable)
2598  {
2599  *pOutBufLen = Context.uSizeRequired;
2600  RegCloseKey(hkey);
2601  return ERROR_BUFFER_OVERFLOW;
2602  }
2603 
2604  if(RegQueryValueExW(hkey, L"NameServer", NULL, NULL, NULL, &dwSize) == ERROR_SUCCESS)
2605  {
2606  pPerAdapterInfo->AutoconfigActive = FALSE;
2607  }
2608  else
2609  {
2610  pPerAdapterInfo->AutoconfigActive = TRUE;
2611  }
2612 
2613  RegCloseKey(hkey);
2614  return NOERROR;
2615 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NOERROR
Definition: winerror.h:2354
#define KEY_READ
Definition: nt_native.h:1023
#define ERROR_BUFFER_OVERFLOW
Definition: winerror.h:185
#define CP_ACP
Definition: compat.h:99
#define ZeroMemory
Definition: winbase.h:1635
const char * getInterfaceNameByIndex(DWORD index)
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4134
__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 MultiByteToWideChar
Definition: compat.h:100
#define ERROR_NOT_SUPPORTED
Definition: compat.h:90
LSTATUS EnumNameServers(HKEY RegHandle, LPWSTR Interface, PVOID Data, EnumNameServersFunc cb)
struct tagContext Context
Definition: acpixf.h:1012
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3381
#define HeapFree(x, y, z)
Definition: compat.h:394
PSDBQUERYRESULT_VISTA PVOID DWORD * dwSize
Definition: env.c:54
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

Referenced by Initialize(), and LANStatusUiDetailsDlg().

◆ GetRTTAndHopCount()

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

Definition at line 2634 of file iphlpapi_main.c.

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

◆ GetTcpStatistics()

DWORD WINAPI GetTcpStatistics ( PMIB_TCPSTATS  pStats)

Definition at line 2680 of file iphlpapi_main.c.

2681 {
2682  return GetTcpStatisticsEx(pStats, PF_INET);
2683 }
#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 2657 of file iphlpapi_main.c.

2658 {
2659  DWORD ret;
2660 
2661  TRACE("pStats %p\n", pStats);
2662  ret = getTCPStats(pStats, dwFamily);
2663  TRACE("returning %ld\n", ret);
2664  return ret;
2665 }
#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 2708 of file iphlpapi_main.c.

2709 {
2710  return GetExtendedTcpTable(pTcpTable, pdwSize, bOrder, AF_INET, TCP_TABLE_BASIC_ALL, 0);
2711 }
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 2751 of file iphlpapi_main.c.

2752 {
2753  return GetUdpStatisticsEx(pStats, PF_INET);
2754 }
#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 2728 of file iphlpapi_main.c.

2729 {
2730  DWORD ret;
2731 
2732  TRACE("pStats %p\n", pStats);
2733  ret = getUDPStats(pStats, dwFamily);
2734  TRACE("returning %ld\n", ret);
2735  return ret;
2736 }
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 2772 of file iphlpapi_main.c.

2773 {
2774  return GetExtendedUdpTable(pUdpTable, pdwSize, bOrder, AF_INET, UDP_TABLE_BASIC, 0);
2775 }
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 2796 of file iphlpapi_main.c.

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

◆ IfTableSorter()

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

Definition at line 1634 of file iphlpapi_main.c.

1635 {
1636  int ret;
1637 
1638  if (a && b)
1639  ret = ((PMIB_IFROW)a)->dwIndex - ((PMIB_IFROW)b)->dwIndex;
1640  else
1641  ret = 0;
1642  return ret;
1643 }
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 1789 of file iphlpapi_main.c.

1790 {
1791  int ret;
1792 
1793  if (a && b)
1794  ret = ((PMIB_IPADDRROW)a)->dwAddr - ((PMIB_IPADDRROW)b)->dwAddr;
1795  else
1796  ret = 0;
1797  return ret;
1798 }
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 1882 of file iphlpapi_main.c.

1883 {
1884  int ret;
1885 
1886  if (a && b) {
1888 
1889  ret = rowA->dwForwardDest - rowB->dwForwardDest;
1890  if (ret == 0) {
1891  ret = rowA->dwForwardProto - rowB->dwForwardProto;
1892  if (ret == 0) {
1893  ret = rowA->dwForwardPolicy - rowB->dwForwardPolicy;
1894  if (ret == 0)
1895  ret = rowA->dwForwardNextHop - rowB->dwForwardNextHop;
1896  }
1897  }
1898  }
1899  else
1900  ret = 0;
1901  return ret;
1902 }
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 1993 of file iphlpapi_main.c.

1994 {
1995  int ret;
1996 
1997  if (a && b)
1998  ret = ((PMIB_IPNETROW)a)->dwAddr - ((PMIB_IPNETROW)b)->dwAddr;
1999  else
2000  ret = 0;
2001  return ret;
2002 }
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 2817 of file iphlpapi_main.c.

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

Referenced by Release(), and WlanDisconnect().

◆ IpRenewAddress()

DWORD WINAPI IpRenewAddress ( PIP_ADAPTER_INDEX_MAP  AdapterInfo)

Definition at line 2851 of file iphlpapi_main.c.

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

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 3473 of file iphlpapi_main.c.

3478 {
3480 
3481  if (pInterfaceName == NULL)
3482  return ERROR_INVALID_PARAMETER;
3483 
3484  return GetInterfaceNameInternal(pInterfaceGUID, pInterfaceName, pOutBufLen);
3485 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define ERROR_SUCCESS
Definition: deptool.c:10
smooth NULL
Definition: ftsmooth.c:416
#define SetLastError(x)
Definition: compat.h:409
DWORD GetInterfaceNameInternal(_In_ const GUID *pInterfaceGUID, _Out_writes_bytes_to_(*pOutBufLen, *pOutBufLen) PWCHAR pInterfaceName, _Inout_ PULONG pOutBufLen)

◆ 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 3491 of file iphlpapi_main.c.

3496 {
3497  DWORD result;
3498 
3499  result = GetInterfaceNameInternal(pInterfaceGUID, pInterfaceName, pOutBufLen);
3500 
3501  if (result == ERROR_NOT_FOUND)
3503 
3504  return result;
3505 }
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
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
GLuint64EXT * result
Definition: glext.h:11304

◆ NhpAllocateAndGetInterfaceInfoFromStack()

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

Definition at line 3384 of file iphlpapi_main.c.

3385 {
3386  FIXME(":stub\n");
3387  return 0L;
3388 }
#define FIXME(fmt,...)
Definition: debug.h:110
static const WCHAR L[]
Definition: oid.c:1250

◆ NotifyAddrChange()

DWORD WINAPI NotifyAddrChange ( PHANDLE  Handle,
LPOVERLAPPED  overlapped 
)

Definition at line 2889 of file iphlpapi_main.c.

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

Referenced by AdapterDiscoveryThread(), and detectChange().

◆ NotifyRouteChange()

DWORD WINAPI NotifyRouteChange ( PHANDLE  Handle,
LPOVERLAPPED  overlapped 
)

Definition at line 2914 of file iphlpapi_main.c.

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

◆ SendARP()

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

Definition at line 2935 of file iphlpapi_main.c.

2936 {
2937  IPAddr IPs[2];
2938  ULONG Size;
2939 
2940  if (IsBadWritePtr(pMacAddr, sizeof(ULONG)) || IsBadWritePtr(PhyAddrLen, sizeof(ULONG)))
2941  return ERROR_INVALID_PARAMETER;
2942 
2943  IPs[0] = DestIP;
2944  IPs[1] = SrcIP;
2945  Size = sizeof(IPs);
2946  return TCPSendIoctl(INVALID_HANDLE_VALUE, IOCTL_QUERY_IP_HW_ADDRESS, IPs, &Size, pMacAddr, PhyAddrLen);
2947 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
BOOL NTAPI IsBadWritePtr(IN LPVOID lp, IN UINT_PTR ucb)
Definition: except.c:885
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
ULONG IPAddr
Definition: pfhook.h:35
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
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(), and TestUM().

◆ SetIfEntry()

DWORD WINAPI SetIfEntry ( PMIB_IFROW  pIfRow)

Definition at line 2965 of file iphlpapi_main.c.

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

◆ SetIpForwardEntry()

DWORD WINAPI SetIpForwardEntry ( PMIB_IPFORWARDROW  pRoute)

Definition at line 2989 of file iphlpapi_main.c.

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

◆ SetIpForwardEntryToStack()

DWORD WINAPI SetIpForwardEntryToStack ( PMIB_IPFORWARDROW  pRoute)

Definition at line 3407 of file iphlpapi_main.c.

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

◆ SetIpNetEntry()

DWORD WINAPI SetIpNetEntry ( PMIB_IPNETROW  pArpEntry)

Definition at line 3007 of file iphlpapi_main.c.

3008 {
3009  HANDLE tcpFile;
3010  NTSTATUS status;
3013  TDIEntityID id;
3014  DWORD returnSize;
3015  PMIB_IPNETROW arpBuff;
3016 
3017  if (!pArpEntry)
3018  return ERROR_INVALID_PARAMETER;
3019 
3021  return ERROR_NOT_SUPPORTED;
3022 
3023  if (!NT_SUCCESS(getNthIpEntity( tcpFile, pArpEntry->dwIndex, &id )))
3024  {
3025  closeTcpFile(tcpFile);
3026  return ERROR_INVALID_PARAMETER;
3027  }
3028 
3032  req.Req.ID.toi_entity.tei_instance = id.tei_instance;
3034  req.Req.BufferSize = sizeof(MIB_IPNETROW);
3035  arpBuff = (PMIB_IPNETROW)&req.Req.Buffer[0];
3036 
3037  RtlCopyMemory(arpBuff, pArpEntry, sizeof(MIB_IPNETROW));
3038 
3039  status = DeviceIoControl( tcpFile,
3041  &req,
3042  sizeof(req),
3043  NULL,
3044  0,
3045  &returnSize,
3046  NULL );
3047 
3048  closeTcpFile(tcpFile);
3049 
3050  if (status)
3051  return NO_ERROR;
3052  else
3053  return ERROR_INVALID_PARAMETER;
3054 }
TDIEntityID toi_entity
Definition: tdiinfo.h:74
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define AT_ENTITY
Definition: tdiinfo.h:41
struct _MIB_IPNETROW * PMIB_IPNETROW
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
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:51
#define FILE_READ_DATA
Definition: nt_native.h:628
ULONG toi_id
Definition: tdiinfo.h:77
#define IOCTL_TCP_SET_INFORMATION_EX
Definition: ticonsts.h:45
TCP_REQUEST_SET_INFORMATION_EX Req
smooth NULL
Definition: ftsmooth.c:416
#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
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 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:90
GLenum GLuint id
Definition: glext.h:5579
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 3072 of file iphlpapi_main.c.

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

◆ SetIpTTL()

DWORD WINAPI SetIpTTL ( UINT  nTTL)

Definition at line 3094 of file iphlpapi_main.c.

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

◆ SetTcpEntry()

DWORD WINAPI SetTcpEntry ( PMIB_TCPROW  pTcpRow)

Definition at line 3116 of file iphlpapi_main.c.

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

◆ TcpTableSorter()

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

Definition at line 981 of file iphlpapi_main.c.

982 {
983  int ret;
984 
985  if (a && b) {
986  PMIB_TCPROW rowA = (PMIB_TCPROW)a, rowB = (PMIB_TCPROW)b;
987 
988  ret = rowA->dwLocalAddr - rowB->dwLocalAddr;
989  if (ret == 0) {
990  ret = rowA->dwLocalPort - rowB->dwLocalPort;
991  if (ret == 0) {
992  ret = rowA->dwRemoteAddr - rowB->dwRemoteAddr;
993  if (ret == 0)
994  ret = rowA->dwRemotePort - rowB->dwRemotePort;
995  }
996  }
997  }
998  else
999  ret = 0;
1000  return ret;
1001 }
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 1407 of file iphlpapi_main.c.

1408 {
1409  int ret;
1410 
1411  if (a && b) {
1412  PMIB_UDPROW rowA = (PMIB_UDPROW)a, rowB = (PMIB_UDPROW)b;
1413 
1414  ret = rowA->dwLocalAddr - rowB->dwLocalAddr;
1415  if (ret == 0)
1416  ret = rowA->dwLocalPort - rowB->dwLocalPort;
1417  }
1418  else
1419  ret = 0;
1420  return ret;
1421 }
DWORD dwLocalAddr
Definition: udpmib.h:28
struct _MIB_UDPROW * PMIB_UDPROW
#define b
Definition: ke_i.h:79
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
int ret
DWORD dwLocalPort
Definition: udpmib.h:29
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

Referenced by GetExtendedUdpTable().

◆ UnenableRouter()

DWORD WINAPI UnenableRouter ( OVERLAPPED pOverlapped,
LPDWORD  lpdwEnableCount 
)

Definition at line 3140 of file iphlpapi_main.c.

3141 {
3142  FIXME("(pOverlapped %p, lpdwEnableCount %p): stub\n", pOverlapped,
3143  lpdwEnableCount);
3144  return ERROR_NOT_SUPPORTED;
3145 }
#define FIXME(fmt,...)
Definition: debug.h:110
#define ERROR_NOT_SUPPORTED
Definition: compat.h:90

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( iphlpapi  )