ReactOS 0.4.15-dev-8236-g99f0937
ifenum_reactos.c File Reference
#include "iphlpapi_private.h"
Include dependency graph for ifenum_reactos.c:

Go to the source code of this file.

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (iphlpapi)
 
void interfaceMapInit (void)
 
void interfaceMapFree (void)
 
NTSTATUS tdiGetMibForIfEntity (HANDLE tcpFile, TDIEntityID *ent, IFEntrySafelySized *entry)
 
BOOL isInterface (TDIEntityID *if_maybe)
 
BOOL isLoopback (HANDLE tcpFile, TDIEntityID *loop_maybe)
 
BOOL hasArp (HANDLE tcpFile, TDIEntityID *arp_maybe)
 
static NTSTATUS getInterfaceInfoSet (HANDLE tcpFile, IFInfo **infoSet, PDWORD numInterfaces)
 
static DWORD getNumInterfacesInt (BOOL onlyNonLoopback)
 
DWORD getNumInterfaces (void)
 
DWORD getNumNonLoopbackInterfaces (void)
 
DWORD getNthInterfaceEntity (HANDLE tcpFile, DWORD index, TDIEntityID *ent)
 
NTSTATUS getInterfaceInfoByIndex (HANDLE tcpFile, DWORD index, IFInfo *info)
 
NTSTATUS getInterfaceInfoByName (HANDLE tcpFile, char *name, IFInfo *info)
 
const chargetInterfaceNameByIndex (DWORD index)
 
void consumeInterfaceName (const char *name)
 
DWORD getInterfaceIndexByName (const char *name, PDWORD index)
 
InterfaceIndexTablegetInterfaceIndexTableInt (BOOL nonLoopbackOnly)
 
InterfaceIndexTablegetInterfaceIndexTable (void)
 
InterfaceIndexTablegetNonLoopbackInterfaceIndexTable (void)
 
DWORD getInterfaceIPAddrByName (const char *name)
 
NTSTATUS getIPAddrEntryForIf (HANDLE tcpFile, char *name, DWORD index, IFInfo *ifInfo)
 
DWORD getAddrByIndexOrName (char *name, DWORD index, IPHLPAddrType addrType)
 
DWORD getInterfaceIPAddrByIndex (DWORD index)
 
DWORD getInterfaceBCastAddrByName (const char *name)
 
DWORD getInterfaceBCastAddrByIndex (DWORD index)
 
DWORD getInterfaceMaskByName (const char *name)
 
DWORD getInterfaceMaskByIndex (DWORD index)
 
void getInterfacePhysicalFromInfo (IFInfo *info, PDWORD len, PBYTE addr, PDWORD type)
 
DWORD getInterfacePhysicalByName (const char *name, PDWORD len, PBYTE addr, PDWORD type)
 
DWORD getInterfacePhysicalByIndex (DWORD index, PDWORD len, PBYTE addr, PDWORD type)
 
DWORD getInterfaceMtuByName (const char *name, PDWORD mtu)
 
DWORD getInterfaceMtuByIndex (DWORD index, PDWORD mtu)
 
DWORD getInterfaceStatusByName (const char *name, PDWORD status)
 
DWORD getInterfaceStatusByIndex (DWORD index, PDWORD status)
 
DWORD getInterfaceEntryByName (const char *name, PMIB_IFROW entry)
 
DWORD getInterfaceEntryByIndex (DWORD index, PMIB_IFROW entry)
 
chartoIPAddressString (unsigned int addr, char string[16])
 
NTSTATUS addIPAddress (IPAddr Address, IPMask Mask, DWORD IfIndex, PULONG NteContext, PULONG NteInstance)
 
NTSTATUS deleteIpAddress (ULONG NteContext)
 

Function Documentation

◆ addIPAddress()

NTSTATUS addIPAddress ( IPAddr  Address,
IPMask  Mask,
DWORD  IfIndex,
PULONG  NteContext,
PULONG  NteInstance 
)

Definition at line 643 of file ifenum_reactos.c.

645{
646 HANDLE tcpFile;
650
651 TRACE("Called.\n");
652
653 if( !NT_SUCCESS(status) ) return status;
654
655 Data.NteContext = IfIndex;
656 Data.NewAddress = Address;
657 Data.NewNetmask = Mask;
658
659 status = NtDeviceIoControlFile( tcpFile,
660 NULL,
661 NULL,
662 NULL,
663 &Iosb,
665 &Data,
666 sizeof(Data),
667 &Data,
668 sizeof(Data) );
669
670 closeTcpFile( tcpFile );
671
672 if( NT_SUCCESS(status) ) {
673 *NteContext = Iosb.Information;
674 *NteInstance = Data.NewAddress;
675 }
676
677 if (!NT_SUCCESS(status)) {
678 ERR("addIPAddress for if %d returning 0x%lx\n", IfIndex, status);
679 }
680
681 return status;
682
683}
LONG NTSTATUS
Definition: precomp.h:26
#define ERR(fmt,...)
Definition: debug.h:113
#define NULL
Definition: types.h:112
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
return Iosb
Definition: create.c:4402
unsigned int Mask
Definition: fpcontrol.c:82
#define FILE_WRITE_DATA
Definition: nt_native.h:631
#define FILE_READ_DATA
Definition: nt_native.h:628
NTSYSAPI NTSTATUS NTAPI NtDeviceIoControlFile(IN HANDLE hFile, IN HANDLE hEvent OPTIONAL, IN PIO_APC_ROUTINE IoApcRoutine OPTIONAL, IN PVOID IoApcContext OPTIONAL, OUT PIO_STATUS_BLOCK pIoStatusBlock, IN ULONG DeviceIoControlCode, IN PVOID InBuffer OPTIONAL, IN ULONG InBufferLength, OUT PVOID OutBuffer OPTIONAL, IN ULONG OutBufferLength)
static WCHAR Address[46]
Definition: ping.c:68
NTSTATUS openTcpFile(PHANDLE tcpFile, ACCESS_MASK DesiredAccess)
Definition: handle.c:12
VOID closeTcpFile(HANDLE h)
Definition: handle.c:43
#define TRACE(s)
Definition: solgame.cpp:4
Definition: ps.c:97
#define IOCTL_SET_IP_ADDRESS
Definition: tcpioctl.h:43

Referenced by AddIPAddress().

◆ consumeInterfaceName()

void consumeInterfaceName ( const char name)

Definition at line 377 of file ifenum_reactos.c.

377 {
378 HeapFree( GetProcessHeap(), 0, (char *)name );
379}
#define GetProcessHeap()
Definition: compat.h:736
#define HeapFree(x, y, z)
Definition: compat.h:735
Definition: name.c:39

Referenced by GetAdaptersInfo(), GetIfEntry(), and GetInterfaceInfo().

◆ deleteIpAddress()

NTSTATUS deleteIpAddress ( ULONG  NteContext)

Definition at line 685 of file ifenum_reactos.c.

686{
687 HANDLE tcpFile;
690
691 TRACE("Called.\n");
692
693 if( !NT_SUCCESS(status) ) return status;
694
695 status = NtDeviceIoControlFile( tcpFile,
696 NULL,
697 NULL,
698 NULL,
699 &Iosb,
701 &NteContext,
702 sizeof(USHORT),
703 NULL,
704 0 );
705
706 closeTcpFile( tcpFile );
707
708 if (!NT_SUCCESS(status)) {
709 ERR("deleteIpAddress(%lu) returning 0x%lx\n", NteContext, status);
710 }
711
712 return status;
713}
unsigned short USHORT
Definition: pedump.c:61
#define IOCTL_DELETE_IP_ADDRESS
Definition: tcpioctl.h:46

Referenced by DeleteIPAddress().

◆ getAddrByIndexOrName()

DWORD getAddrByIndexOrName ( char name,
DWORD  index,
IPHLPAddrType  addrType 
)

Definition at line 476 of file ifenum_reactos.c.

476 {
477 IFInfo ifInfo;
478 HANDLE tcpFile;
480 DWORD addrOut = INADDR_ANY;
481
482 status = openTcpFile( &tcpFile, FILE_READ_DATA );
483
484 if( NT_SUCCESS(status) ) {
485 status = getIPAddrEntryForIf( tcpFile, name, index, &ifInfo );
486 if( NT_SUCCESS(status) ) {
487 switch( addrType ) {
488 case IPAAddr: addrOut = ifInfo.ip_addr.iae_addr; break;
489 case IPABcast: addrOut = ifInfo.ip_addr.iae_bcastaddr; break;
490 case IPAMask: addrOut = ifInfo.ip_addr.iae_mask; break;
491 case IFMtu: addrOut = ifInfo.if_info.ent.if_mtu; break;
492 case IFStatus: addrOut = ifInfo.if_info.ent.if_operstatus; break;
493 }
494 }
495 closeTcpFile( tcpFile );
496 }
497
498 return addrOut;
499}
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint index
Definition: glext.h:6031
NTSTATUS getIPAddrEntryForIf(HANDLE tcpFile, char *name, DWORD index, IFInfo *ifInfo)
@ IFMtu
@ IPABcast
@ IPAMask
@ IFStatus
@ IPAAddr
#define INADDR_ANY
Definition: inet.h:53
#define STATUS_SUCCESS
Definition: shellext.h:65
ULONG if_operstatus
Definition: tcpioctl.h:115
ULONG if_mtu
Definition: tcpioctl.h:110
ULONG iae_mask
Definition: tcpioctl.h:164
ULONG iae_addr
Definition: tcpioctl.h:162
ULONG iae_bcastaddr
Definition: tcpioctl.h:165
IFEntrySafelySized if_info
IPAddrEntry ip_addr

Referenced by getInterfaceBCastAddrByIndex(), getInterfaceBCastAddrByName(), getInterfaceIPAddrByIndex(), getInterfaceMaskByIndex(), getInterfaceMaskByName(), getInterfaceMtuByIndex(), getInterfaceMtuByName(), getInterfaceStatusByIndex(), and getInterfaceStatusByName().

◆ getInterfaceBCastAddrByIndex()

DWORD getInterfaceBCastAddrByIndex ( DWORD  index)

Definition at line 509 of file ifenum_reactos.c.

509 {
510 return getAddrByIndexOrName( 0, index, IPABcast );
511}
DWORD getAddrByIndexOrName(char *name, DWORD index, IPHLPAddrType addrType)

Referenced by GetIpAddrTable().

◆ getInterfaceBCastAddrByName()

DWORD getInterfaceBCastAddrByName ( const char name)

Definition at line 505 of file ifenum_reactos.c.

505 {
506 return getAddrByIndexOrName( (char *)name, 0, IPABcast );
507}

◆ getInterfaceEntryByIndex()

DWORD getInterfaceEntryByIndex ( DWORD  index,
PMIB_IFROW  entry 
)

Definition at line 608 of file ifenum_reactos.c.

609{
610 HANDLE tcpFile;
611 IFInfo info;
613
614 TRACE("Called.\n");
615
616 if( NT_SUCCESS(status) ) {
618
619 if( NT_SUCCESS(status) ) {
621 &info.if_info,
622 sizeof(info.if_info) );
623 }
624
625 closeTcpFile( tcpFile );
626 }
627
628 return status;
629}
NTSTATUS getInterfaceInfoByIndex(HANDLE tcpFile, DWORD index, IFInfo *info)
#define MAX_INTERFACE_NAME_LEN
Definition: ifmib.h:31
uint32_t entry
Definition: isohybrid.c:63
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878

Referenced by GetIfEntry().

◆ getInterfaceEntryByName()

DWORD getInterfaceEntryByName ( const char name,
PMIB_IFROW  entry 
)

Definition at line 583 of file ifenum_reactos.c.

584{
585 HANDLE tcpFile;
586 IFInfo info;
588
589 TRACE("Called.\n");
590
591 if( NT_SUCCESS(status) ) {
592 status = getInterfaceInfoByName( tcpFile, (char *)name, &info );
593
594 if( NT_SUCCESS(status) ) {
596 &info.if_info,
597 sizeof(info.if_info) );
598 }
599
600 TRACE("entry->bDescr = %s\n", entry->bDescr);
601
602 closeTcpFile( tcpFile );
603 }
604
605 return status;
606}
NTSTATUS getInterfaceInfoByName(HANDLE tcpFile, char *name, IFInfo *info)

◆ getInterfaceIndexByName()

DWORD getInterfaceIndexByName ( const char name,
PDWORD  index 
)

Definition at line 381 of file ifenum_reactos.c.

382{
383 IFInfo ifInfo;
384 HANDLE tcpFile;
386
387 if( NT_SUCCESS(status) ) {
388 status = getInterfaceInfoByName( tcpFile, (char *)name, &ifInfo );
389
390 if( NT_SUCCESS(status) ) {
391 *index = ifInfo.if_info.ent.if_index;
392 }
393
394 closeTcpFile( tcpFile );
395 }
396
397 return status;
398}
ULONG if_index
Definition: tcpioctl.h:108

◆ getInterfaceIndexTable()

InterfaceIndexTable * getInterfaceIndexTable ( void  )

Definition at line 447 of file ifenum_reactos.c.

447 {
449}
#define FALSE
Definition: types.h:117
InterfaceIndexTable * getInterfaceIndexTableInt(BOOL nonLoopbackOnly)

Referenced by GetIfTable(), and GetIpAddrTable().

◆ getInterfaceIndexTableInt()

InterfaceIndexTable * getInterfaceIndexTableInt ( BOOL  nonLoopbackOnly)

Definition at line 400 of file ifenum_reactos.c.

400 {
401 DWORD numInterfaces, curInterface = 0;
402 int i;
403 IFInfo *ifInfo;
405 HANDLE tcpFile;
407
408 if( NT_SUCCESS(status) ) {
409 status = getInterfaceInfoSet( tcpFile, &ifInfo, &numInterfaces );
410
411 TRACE("InterfaceInfoSet: %08x, %04x:%08x\n",
412 status,
413 ifInfo->entity_id.tei_entity,
414 ifInfo->entity_id.tei_instance);
415
416 if( NT_SUCCESS(status) ) {
418 calloc(1,
419 sizeof(InterfaceIndexTable) +
420 (numInterfaces - 1) * sizeof(DWORD));
421
422 if (ret) {
423 ret->numAllocated = numInterfaces;
424 TRACE("NumInterfaces = %d\n", numInterfaces);
425
426 for( i = 0; i < numInterfaces; i++ ) {
427 TRACE("Examining interface %d\n", i);
428 if( !nonLoopbackOnly ||
429 !isLoopback( tcpFile, &ifInfo[i].entity_id ) ) {
430 TRACE("Interface %d matches (%d)\n", i, curInterface);
431 ret->indexes[curInterface++] =
432 ifInfo[i].if_info.ent.if_index;
433 }
434 }
435
436 ret->numIndexes = curInterface;
437 }
438
439 tdiFreeThingSet( ifInfo );
440 }
441 closeTcpFile( tcpFile );
442 }
443
444 return ret;
445}
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
static NTSTATUS getInterfaceInfoSet(HANDLE tcpFile, IFInfo **infoSet, PDWORD numInterfaces)
BOOL isLoopback(HANDLE tcpFile, TDIEntityID *loop_maybe)
#define calloc
Definition: rosglue.h:14
VOID tdiFreeThingSet(PVOID things)
Definition: enum.c:118
TDIEntityID entity_id
ULONG tei_entity
Definition: tdiinfo.h:31
ULONG tei_instance
Definition: tdiinfo.h:32
int ret

Referenced by getInterfaceIndexTable(), and getNonLoopbackInterfaceIndexTable().

◆ getInterfaceInfoByIndex()

NTSTATUS getInterfaceInfoByIndex ( HANDLE  tcpFile,
DWORD  index,
IFInfo info 
)

Definition at line 304 of file ifenum_reactos.c.

304 {
305 IFInfo *ifInfo;
306 DWORD numInterfaces;
307 NTSTATUS status = getInterfaceInfoSet( tcpFile, &ifInfo, &numInterfaces );
308 int i;
309
310 if( NT_SUCCESS(status) )
311 {
312 for( i = 0; i < numInterfaces; i++ ) {
313 if( ifInfo[i].if_info.ent.if_index == index ) {
314 memcpy( info, &ifInfo[i], sizeof(*info) );
315 break;
316 }
317 }
318
319 HeapFree(GetProcessHeap(), 0, ifInfo);
320
321 return i < numInterfaces ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL;
322 }
323
324 return status;
325}
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132

Referenced by getInterfaceEntryByIndex(), getInterfaceNameByIndex(), getInterfacePhysicalByIndex(), and getIPAddrEntryForIf().

◆ getInterfaceInfoByName()

NTSTATUS getInterfaceInfoByName ( HANDLE  tcpFile,
char name,
IFInfo info 
)

Definition at line 327 of file ifenum_reactos.c.

327 {
328 IFInfo *ifInfo;
329 DWORD numInterfaces;
330 int i;
331 NTSTATUS status = getInterfaceInfoSet( tcpFile, &ifInfo, &numInterfaces );
332
333 if( NT_SUCCESS(status) )
334 {
335 for( i = 0; i < numInterfaces; i++ ) {
336 if( !strncmp((PCHAR)ifInfo[i].if_info.ent.if_descr, name, ifInfo[i].if_info.ent.if_descrlen) ) {
337 memcpy( info, &ifInfo[i], sizeof(*info) );
338 break;
339 }
340 }
341
342 HeapFree(GetProcessHeap(), 0,ifInfo);
343
344 return i < numInterfaces ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL;
345 }
346
347 return status;
348}
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
char * PCHAR
Definition: typedefs.h:51

Referenced by getInterfaceEntryByName(), getInterfaceIndexByName(), getInterfacePhysicalByName(), and getIPAddrEntryForIf().

◆ getInterfaceInfoSet()

static NTSTATUS getInterfaceInfoSet ( HANDLE  tcpFile,
IFInfo **  infoSet,
PDWORD  numInterfaces 
)
static

Definition at line 156 of file ifenum_reactos.c.

158 {
159 DWORD numEntities;
160 TDIEntityID *entIDSet = NULL;
161 NTSTATUS status = tdiGetEntityIDSet( tcpFile, &entIDSet, &numEntities );
162 IFInfo *infoSetInt = 0;
163 int curInterf = 0, i;
164
165 if (!NT_SUCCESS(status)) {
166 ERR("getInterfaceInfoSet: tdiGetEntityIDSet() failed: 0x%lx\n", status);
167 return status;
168 }
169
170 infoSetInt = HeapAlloc( GetProcessHeap(), 0,
171 sizeof(IFInfo) * numEntities );
172
173 if( infoSetInt ) {
174 for( i = 0; i < numEntities; i++ ) {
175 if( isInterface( &entIDSet[i] ) ) {
176 infoSetInt[curInterf].entity_id = entIDSet[i];
178 ( tcpFile,
179 &entIDSet[i],
180 &infoSetInt[curInterf].if_info );
181 TRACE("tdiGetMibForIfEntity: %08x\n", status);
182 if( NT_SUCCESS(status) ) {
183 DWORD numAddrs;
184 IPAddrEntry *addrs;
185 TDIEntityID ip_ent;
186 int j;
187
188 status = getNthIpEntity( tcpFile, curInterf, &ip_ent );
189 if( NT_SUCCESS(status) )
191 ( tcpFile, &ip_ent, &addrs, &numAddrs );
192 for( j = 0; NT_SUCCESS(status) && j < numAddrs; j++ ) {
193 TRACE("ADDR %d: index %d (target %d)\n", j, addrs[j].iae_index, infoSetInt[curInterf].if_info.ent.if_index);
194 if( addrs[j].iae_index ==
195 infoSetInt[curInterf].if_info.ent.if_index ) {
196 memcpy( &infoSetInt[curInterf].ip_addr,
197 &addrs[j],
198 sizeof( addrs[j] ) );
199 curInterf++;
200 break;
201 }
202 }
203 if ( NT_SUCCESS(status) )
204 tdiFreeThingSet(addrs);
205 }
206 }
207 }
208
209 tdiFreeThingSet(entIDSet);
210
211 if (NT_SUCCESS(status)) {
212 *infoSet = infoSetInt;
213 *numInterfaces = curInterf;
214 } else {
215 HeapFree(GetProcessHeap(), 0, infoSetInt);
216 }
217
218 return status;
219 } else {
220 tdiFreeThingSet(entIDSet);
222 }
223}
#define HeapAlloc
Definition: compat.h:733
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 GLint GLint j
Definition: glfuncs.h:250
NTSTATUS tdiGetMibForIfEntity(HANDLE tcpFile, TDIEntityID *ent, IFEntrySafelySized *entry)
BOOL isInterface(TDIEntityID *if_maybe)
NTSTATUS tdiGetIpAddrsForIpEntity(HANDLE tcpFile, TDIEntityID *ent, IPAddrEntry **addrs, PDWORD numAddrs)
NTSTATUS getNthIpEntity(HANDLE tcpFile, DWORD index, TDIEntityID *ent)
NTSTATUS tdiGetEntityIDSet(HANDLE tcpFile, TDIEntityID **entitySet, PDWORD numEntities)
Definition: enum.c:122
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158

Referenced by getInterfaceIndexTableInt(), getInterfaceInfoByIndex(), and getInterfaceInfoByName().

◆ getInterfaceIPAddrByIndex()

DWORD getInterfaceIPAddrByIndex ( DWORD  index)

Definition at line 501 of file ifenum_reactos.c.

501 {
502 return getAddrByIndexOrName( 0, index, IPAAddr );
503}

Referenced by GetAdaptersInfo(), and GetIpAddrTable().

◆ getInterfaceIPAddrByName()

DWORD getInterfaceIPAddrByName ( const char name)

Definition at line 455 of file ifenum_reactos.c.

456{
457 return INADDR_ANY;
458}

◆ getInterfaceMaskByIndex()

DWORD getInterfaceMaskByIndex ( DWORD  index)

Definition at line 517 of file ifenum_reactos.c.

517 {
518 return getAddrByIndexOrName( 0, index, IPAMask );
519}

Referenced by GetAdaptersInfo(), and GetIpAddrTable().

◆ getInterfaceMaskByName()

DWORD getInterfaceMaskByName ( const char name)

Definition at line 513 of file ifenum_reactos.c.

513 {
514 return getAddrByIndexOrName( (char *)name, 0, IPAMask );
515}

◆ getInterfaceMtuByIndex()

DWORD getInterfaceMtuByIndex ( DWORD  index,
PDWORD  mtu 
)

Definition at line 567 of file ifenum_reactos.c.

567 {
568 *mtu = getAddrByIndexOrName( 0, index, IFMtu );
569 return STATUS_SUCCESS;
570}

◆ getInterfaceMtuByName()

DWORD getInterfaceMtuByName ( const char name,
PDWORD  mtu 
)

Definition at line 562 of file ifenum_reactos.c.

562 {
563 *mtu = getAddrByIndexOrName( (char *)name, 0, IFMtu );
564 return STATUS_SUCCESS;
565}

◆ getInterfaceNameByIndex()

const char * getInterfaceNameByIndex ( DWORD  index)

Definition at line 352 of file ifenum_reactos.c.

353{
354 IFInfo ifInfo;
355 HANDLE tcpFile;
356 char *interfaceName = NULL;
358
359 if( NT_SUCCESS(status) ) {
360 status = getInterfaceInfoByIndex( tcpFile, index, &ifInfo );
361
362 if( NT_SUCCESS(status) ) {
363 interfaceName = HeapAlloc( GetProcessHeap(), 0,
364 ifInfo.if_info.ent.if_descrlen + 1 );
365 if( interfaceName ) {
366 memcpy(interfaceName, ifInfo.if_info.ent.if_descr, ifInfo.if_info.ent.if_descrlen);
367 interfaceName[ifInfo.if_info.ent.if_descrlen] = '\0';
368 }
369 }
370
371 closeTcpFile( tcpFile );
372 }
373
374 return interfaceName;
375}
UCHAR if_descr[1]
Definition: tcpioctl.h:130
ULONG if_descrlen
Definition: tcpioctl.h:129

Referenced by GetAdaptersInfo(), GetIfEntry(), GetInterfaceInfo(), and GetPerAdapterInfo().

◆ getInterfacePhysicalByIndex()

DWORD getInterfacePhysicalByIndex ( DWORD  index,
PDWORD  len,
PBYTE  addr,
PDWORD  type 
)

Definition at line 545 of file ifenum_reactos.c.

547{
548 HANDLE tcpFile;
549 IFInfo info;
551
552 if( NT_SUCCESS(status) ) {
554 if( NT_SUCCESS(status) )
556 closeTcpFile( tcpFile );
557 }
558
559 return status;
560}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLenum const GLvoid * addr
Definition: glext.h:9621
GLenum GLsizei len
Definition: glext.h:6722
void getInterfacePhysicalFromInfo(IFInfo *info, PDWORD len, PBYTE addr, PDWORD type)

Referenced by GetAdaptersInfo().

◆ getInterfacePhysicalByName()

DWORD getInterfacePhysicalByName ( const char name,
PDWORD  len,
PBYTE  addr,
PDWORD  type 
)

Definition at line 528 of file ifenum_reactos.c.

530{
531 HANDLE tcpFile;
532 IFInfo info;
534
535 if( NT_SUCCESS(status) ) {
536 status = getInterfaceInfoByName( tcpFile, (char *)name, &info );
537 if( NT_SUCCESS(status) )
539 closeTcpFile( tcpFile );
540 }
541
542 return status;
543}

◆ getInterfacePhysicalFromInfo()

void getInterfacePhysicalFromInfo ( IFInfo info,
PDWORD  len,
PBYTE  addr,
PDWORD  type 
)

Definition at line 521 of file ifenum_reactos.c.

522 {
523 *len = info->if_info.ent.if_physaddrlen;
524 memcpy( addr, info->if_info.ent.if_physaddr, *len );
525 *type = info->if_info.ent.if_type;
526}

Referenced by getInterfacePhysicalByIndex(), and getInterfacePhysicalByName().

◆ getInterfaceStatusByIndex()

DWORD getInterfaceStatusByIndex ( DWORD  index,
PDWORD  status 
)

Definition at line 577 of file ifenum_reactos.c.

578{
580 return STATUS_SUCCESS;
581}

◆ getInterfaceStatusByName()

DWORD getInterfaceStatusByName ( const char name,
PDWORD  status 
)

Definition at line 572 of file ifenum_reactos.c.

572 {
573 *status = getAddrByIndexOrName( (char *)name, 0, IFStatus );
574 return STATUS_SUCCESS;
575}

◆ getIPAddrEntryForIf()

NTSTATUS getIPAddrEntryForIf ( HANDLE  tcpFile,
char name,
DWORD  index,
IFInfo ifInfo 
)

Definition at line 460 of file ifenum_reactos.c.

463 {
465 name ?
466 getInterfaceInfoByName( tcpFile, name, ifInfo ) :
467 getInterfaceInfoByIndex( tcpFile, index, ifInfo );
468
469 if (!NT_SUCCESS(status)) {
470 ERR("getIPAddrEntryForIf returning %lx\n", status);
471 }
472
473 return status;
474}

Referenced by getAddrByIndexOrName().

◆ getNonLoopbackInterfaceIndexTable()

InterfaceIndexTable * getNonLoopbackInterfaceIndexTable ( void  )

Definition at line 451 of file ifenum_reactos.c.

451 {
453}
#define TRUE
Definition: types.h:120

Referenced by GetAdaptersInfo(), and GetInterfaceInfo().

◆ getNthInterfaceEntity()

DWORD getNthInterfaceEntity ( HANDLE  tcpFile,
DWORD  index,
TDIEntityID ent 
)

Definition at line 274 of file ifenum_reactos.c.

274 {
275 DWORD numEntities = 0;
276 DWORD numInterfaces = 0;
277 TDIEntityID *entitySet = 0;
278 NTSTATUS status = tdiGetEntityIDSet( tcpFile, &entitySet, &numEntities );
279 int i;
280
281 if( !NT_SUCCESS(status) )
282 return status;
283
284 for( i = 0; i < numEntities; i++ ) {
285 if( isInterface( &entitySet[i] ) ) {
286 if( numInterfaces == index ) break;
287 else numInterfaces++;
288 }
289 }
290
291 TRACE("Index %d is entity #%d - %04x:%08x\n", index, i,
292 entitySet[i].tei_entity, entitySet[i].tei_instance );
293
294 if( numInterfaces == index && i < numEntities ) {
295 memcpy( ent, &entitySet[i], sizeof(*ent) );
296 tdiFreeThingSet( entitySet );
297 return STATUS_SUCCESS;
298 } else {
299 tdiFreeThingSet( entitySet );
300 return STATUS_UNSUCCESSFUL;
301 }
302}

◆ getNumInterfaces()

DWORD getNumInterfaces ( void  )

Definition at line 264 of file ifenum_reactos.c.

265{
266 return getNumInterfacesInt( FALSE );
267}
static DWORD getNumInterfacesInt(BOOL onlyNonLoopback)

Referenced by GetIfTable(), GetIpAddrTable(), and GetNumberOfInterfaces().

◆ getNumInterfacesInt()

static DWORD getNumInterfacesInt ( BOOL  onlyNonLoopback)
static

Definition at line 225 of file ifenum_reactos.c.

226{
227 DWORD numEntities, numInterfaces = 0;
228 TDIEntityID *entitySet;
229 HANDLE tcpFile;
231 int i;
232
233 status = openTcpFile( &tcpFile, FILE_READ_DATA );
234
235 if( !NT_SUCCESS(status) ) {
236 WARN("getNumInterfaces: failed %08x\n", status );
237 return 0;
238 }
239
240 status = tdiGetEntityIDSet( tcpFile, &entitySet, &numEntities );
241
242 if( !NT_SUCCESS(status) ) {
243 WARN("getNumInterfaces: failed %08x\n", status );
244 closeTcpFile( tcpFile );
245 return 0;
246 }
247
248 for( i = 0; i < numEntities; i++ ) {
249 if( isInterface( &entitySet[i] ) &&
250 (!onlyNonLoopback || !isLoopback( tcpFile, &entitySet[i] )) )
251 numInterfaces++;
252 }
253
254 TRACE("getNumInterfaces: success: %d %d %08x\n",
255 onlyNonLoopback, numInterfaces, status );
256
257 closeTcpFile( tcpFile );
258
259 tdiFreeThingSet( entitySet );
260
261 return numInterfaces;
262}
#define WARN(fmt,...)
Definition: debug.h:115

Referenced by getNumInterfaces(), and getNumNonLoopbackInterfaces().

◆ getNumNonLoopbackInterfaces()

DWORD getNumNonLoopbackInterfaces ( void  )

Definition at line 269 of file ifenum_reactos.c.

270{
271 return getNumInterfacesInt( TRUE );
272}

Referenced by GetAdaptersInfo(), and GetInterfaceInfo().

◆ hasArp()

BOOL hasArp ( HANDLE  tcpFile,
TDIEntityID arp_maybe 
)

Definition at line 131 of file ifenum_reactos.c.

131 {
134 DWORD returnSize, type;
135
140 req.ID.toi_entity.tei_instance = arp_maybe->tei_instance;
141
142 status = DeviceIoControl( tcpFile,
144 &req,
145 sizeof(req),
146 &type,
147 sizeof(type),
148 &returnSize,
149 NULL );
150 if( !NT_SUCCESS(status) ) return FALSE;
151
152 /* AT_ARP corresponds to an individual TDI entity type */
153 return (type == AT_ARP);
154}
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 TCP_REQUEST_QUERY_INFORMATION_INIT
ULONG toi_id
Definition: tdiinfo.h:77
ULONG toi_type
Definition: tdiinfo.h:76
ULONG toi_class
Definition: tdiinfo.h:75
TDIEntityID toi_entity
Definition: tdiinfo.h:74
#define ENTITY_TYPE_ID
Definition: tdiinfo.h:39
#define INFO_CLASS_GENERIC
Definition: tdiinfo.h:64
#define AT_ENTITY
Definition: tdiinfo.h:41
#define INFO_TYPE_PROVIDER
Definition: tdiinfo.h:69
#define AT_ARP
Definition: tdiinfo.h:49
#define IOCTL_TCP_QUERY_INFORMATION_EX
Definition: tditest.h:110

Referenced by getArpTable(), getNumArpEntries(), getNumTcpEntries(), getNumUdpEntries(), getTcpTable(), and getUdpTable().

◆ interfaceMapFree()

void interfaceMapFree ( void  )

Definition at line 54 of file ifenum_reactos.c.

55{
56 /* Ditto. */
57}

Referenced by DllMain().

◆ interfaceMapInit()

void interfaceMapInit ( void  )

Definition at line 49 of file ifenum_reactos.c.

50{
51 /* For now, nothing */
52}

Referenced by DllMain().

◆ isInterface()

BOOL isInterface ( TDIEntityID if_maybe)

Definition at line 114 of file ifenum_reactos.c.

114 {
115 return
116 if_maybe->tei_entity == IF_ENTITY;
117}
#define IF_ENTITY
Definition: tdiinfo.h:47

Referenced by getArpTable(), getInterfaceInfoSet(), getNthInterfaceEntity(), getNumArpEntries(), and getNumInterfacesInt().

◆ isLoopback()

BOOL isLoopback ( HANDLE  tcpFile,
TDIEntityID loop_maybe 
)

Definition at line 119 of file ifenum_reactos.c.

119 {
120 IFEntrySafelySized entryInfo;
122
123 status = tdiGetMibForIfEntity( tcpFile,
124 loop_maybe,
125 &entryInfo );
126
127 return NT_SUCCESS(status) &&
128 (entryInfo.ent.if_type == IFENT_SOFTWARE_LOOPBACK);
129}
#define IFENT_SOFTWARE_LOOPBACK
ULONG if_type
Definition: tcpioctl.h:109

Referenced by getInterfaceIndexTableInt(), and getNumInterfacesInt().

◆ tdiGetMibForIfEntity()

NTSTATUS tdiGetMibForIfEntity ( HANDLE  tcpFile,
TDIEntityID ent,
IFEntrySafelySized entry 
)

Definition at line 59 of file ifenum_reactos.c.

60 {
63 DWORD returnSize;
64
65 WARN("TdiGetMibForIfEntity(tcpFile %p,entityId %p)\n",
66 tcpFile, ent->tei_instance);
67
71 req.ID.toi_entity = *ent;
72
73 status = DeviceIoControl( tcpFile,
75 &req,
76 sizeof(req),
77 entry,
78 sizeof(*entry),
79 &returnSize,
80 NULL );
81
82 if(!status)
83 {
84 WARN("IOCTL Failed\n");
86 }
87
88 TRACE("TdiGetMibForIfEntity() => {\n"
89 " if_index ....................... %x\n"
90 " if_type ........................ %x\n"
91 " if_mtu ......................... %d\n"
92 " if_speed ....................... %x\n"
93 " if_physaddrlen ................. %d\n",
94 entry->ent.if_index,
95 entry->ent.if_type,
96 entry->ent.if_mtu,
97 entry->ent.if_speed,
98 entry->ent.if_physaddrlen);
99 TRACE(" if_physaddr .................... %02x:%02x:%02x:%02x:%02x:%02x\n"
100 " if_descr ....................... %*s\n",
101 entry->ent.if_physaddr[0] & 0xff,
102 entry->ent.if_physaddr[1] & 0xff,
103 entry->ent.if_physaddr[2] & 0xff,
104 entry->ent.if_physaddr[3] & 0xff,
105 entry->ent.if_physaddr[4] & 0xff,
106 entry->ent.if_physaddr[5] & 0xff,
107 entry->ent.if_descrlen,
108 entry->ent.if_descr);
109 TRACE("} status %08x\n",status);
110
111 return STATUS_SUCCESS;
112}
#define IF_MIB_STATS_ID
Definition: tcpioctl.h:52
#define INFO_CLASS_PROTOCOL
Definition: tdiinfo.h:65

Referenced by getInterfaceInfoSet(), and isLoopback().

◆ toIPAddressString()

char * toIPAddressString ( unsigned int  addr,
char  string[16] 
)

Definition at line 631 of file ifenum_reactos.c.

632{
633 struct in_addr iAddr;
634
635 iAddr.s_addr = addr;
636
637 if (string)
638 strncpy(string, inet_ntoa(iAddr), 16);
639
640 return inet_ntoa(iAddr);
641}
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
#define inet_ntoa(addr)
Definition: inet.h:100
Definition: tcpip.h:126
u32_t s_addr
Definition: inet.h:45

Referenced by GetAdaptersInfo().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( iphlpapi  )