ReactOS  0.4.15-dev-344-g6808e40
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 642 of file ifenum_reactos.c.

644 {
645  HANDLE tcpFile;
649 
650  TRACE("Called.\n");
651 
652  if( !NT_SUCCESS(status) ) return status;
653 
654  Data.NteContext = IfIndex;
655  Data.NewAddress = Address;
656  Data.NewNetmask = Mask;
657 
658  status = NtDeviceIoControlFile( tcpFile,
659  NULL,
660  NULL,
661  NULL,
662  &Iosb,
664  &Data,
665  sizeof(Data),
666  &Data,
667  sizeof(Data) );
668 
669  closeTcpFile( tcpFile );
670 
671  if( NT_SUCCESS(status) ) {
672  *NteContext = Iosb.Information;
673  *NteInstance = Data.NewAddress;
674  }
675 
676  if (!NT_SUCCESS(status)) {
677  ERR("addIPAddress for if %d returning 0x%lx\n", IfIndex, status);
678  }
679 
680  return status;
681 
682 }
LONG NTSTATUS
Definition: precomp.h:26
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)
#define FILE_READ_DATA
Definition: nt_native.h:628
smooth NULL
Definition: ftsmooth.c:416
static WCHAR Address[46]
Definition: ping.c:68
_In_ LPGUID _In_ PVOID Data
Definition: classpnp.h:778
#define FILE_WRITE_DATA
Definition: nt_native.h:631
#define TRACE(s)
Definition: solgame.cpp:4
return Iosb
Definition: create.c:4426
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define IOCTL_SET_IP_ADDRESS
Definition: tcpioctl.h:43
VOID closeTcpFile(HANDLE h)
Definition: handle.c:43
#define ERR(fmt,...)
Definition: debug.h:110
NTSTATUS openTcpFile(PHANDLE tcpFile, ACCESS_MASK DesiredAccess)
Definition: handle.c:12
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by AddIPAddress().

◆ consumeInterfaceName()

void consumeInterfaceName ( const char name)

Definition at line 376 of file ifenum_reactos.c.

376  {
377  HeapFree( GetProcessHeap(), 0, (char *)name );
378 }
#define GetProcessHeap()
Definition: compat.h:404
Definition: name.c:38
#define HeapFree(x, y, z)
Definition: compat.h:403

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

◆ deleteIpAddress()

NTSTATUS deleteIpAddress ( ULONG  NteContext)

Definition at line 684 of file ifenum_reactos.c.

685 {
686  HANDLE tcpFile;
689 
690  TRACE("Called.\n");
691 
692  if( !NT_SUCCESS(status) ) return status;
693 
694  status = NtDeviceIoControlFile( tcpFile,
695  NULL,
696  NULL,
697  NULL,
698  &Iosb,
700  &NteContext,
701  sizeof(USHORT),
702  NULL,
703  0 );
704 
705  closeTcpFile( tcpFile );
706 
707  if (!NT_SUCCESS(status)) {
708  ERR("deleteIpAddress(%lu) returning 0x%lx\n", NteContext, status);
709  }
710 
711  return status;
712 }
LONG NTSTATUS
Definition: precomp.h:26
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)
#define FILE_READ_DATA
Definition: nt_native.h:628
smooth NULL
Definition: ftsmooth.c:416
#define FILE_WRITE_DATA
Definition: nt_native.h:631
#define IOCTL_DELETE_IP_ADDRESS
Definition: tcpioctl.h:46
#define TRACE(s)
Definition: solgame.cpp:4
return Iosb
Definition: create.c:4426
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID closeTcpFile(HANDLE h)
Definition: handle.c:43
#define ERR(fmt,...)
Definition: debug.h:110
unsigned short USHORT
Definition: pedump.c:61
NTSTATUS openTcpFile(PHANDLE tcpFile, ACCESS_MASK DesiredAccess)
Definition: handle.c:12
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by DeleteIPAddress().

◆ getAddrByIndexOrName()

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

Definition at line 475 of file ifenum_reactos.c.

475  {
476  IFInfo ifInfo;
477  HANDLE tcpFile;
479  DWORD addrOut = INADDR_ANY;
480 
481  status = openTcpFile( &tcpFile, FILE_READ_DATA );
482 
483  if( NT_SUCCESS(status) ) {
484  status = getIPAddrEntryForIf( tcpFile, name, index, &ifInfo );
485  if( NT_SUCCESS(status) ) {
486  switch( addrType ) {
487  case IPAAddr: addrOut = ifInfo.ip_addr.iae_addr; break;
488  case IPABcast: addrOut = ifInfo.ip_addr.iae_bcastaddr; break;
489  case IPAMask: addrOut = ifInfo.ip_addr.iae_mask; break;
490  case IFMtu: addrOut = ifInfo.if_info.ent.if_mtu; break;
491  case IFStatus: addrOut = ifInfo.if_info.ent.if_operstatus; break;
492  }
493  }
494  closeTcpFile( tcpFile );
495  }
496 
497  return addrOut;
498 }
LONG NTSTATUS
Definition: precomp.h:26
#define INADDR_ANY
Definition: StrAddr.c:4
ULONG if_operstatus
Definition: tcpioctl.h:115
ULONG iae_bcastaddr
Definition: tcpioctl.h:165
IPAddrEntry ip_addr
#define FILE_READ_DATA
Definition: nt_native.h:628
GLuint index
Definition: glext.h:6031
ULONG if_mtu
Definition: tcpioctl.h:110
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
unsigned long DWORD
Definition: ntddk_ex.h:95
VOID closeTcpFile(HANDLE h)
Definition: handle.c:43
ULONG iae_mask
Definition: tcpioctl.h:164
ULONG iae_addr
Definition: tcpioctl.h:162
NTSTATUS openTcpFile(PHANDLE tcpFile, ACCESS_MASK DesiredAccess)
Definition: handle.c:12
Definition: name.c:38
IFEntrySafelySized if_info
return STATUS_SUCCESS
Definition: btrfs.c:3014
NTSTATUS getIPAddrEntryForIf(HANDLE tcpFile, char *name, DWORD index, IFInfo *ifInfo)
Definition: ps.c:97

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

◆ getInterfaceBCastAddrByIndex()

DWORD getInterfaceBCastAddrByIndex ( DWORD  index)

Definition at line 508 of file ifenum_reactos.c.

508  {
509  return getAddrByIndexOrName( 0, index, IPABcast );
510 }
GLuint index
Definition: glext.h:6031
DWORD getAddrByIndexOrName(char *name, DWORD index, IPHLPAddrType addrType)

Referenced by GetIpAddrTable().

◆ getInterfaceBCastAddrByName()

DWORD getInterfaceBCastAddrByName ( const char name)

Definition at line 504 of file ifenum_reactos.c.

504  {
505  return getAddrByIndexOrName( (char *)name, 0, IPABcast );
506 }
DWORD getAddrByIndexOrName(char *name, DWORD index, IPHLPAddrType addrType)
Definition: name.c:38

◆ getInterfaceEntryByIndex()

DWORD getInterfaceEntryByIndex ( DWORD  index,
PMIB_IFROW  entry 
)

Definition at line 607 of file ifenum_reactos.c.

608 {
609  HANDLE tcpFile;
610  IFInfo info;
611  NTSTATUS status = openTcpFile( &tcpFile, FILE_READ_DATA );
612 
613  TRACE("Called.\n");
614 
615  if( NT_SUCCESS(status) ) {
616  status = getInterfaceInfoByIndex( tcpFile, index, &info );
617 
618  if( NT_SUCCESS(status) ) {
619  memcpy( &entry->wszName[MAX_INTERFACE_NAME_LEN],
620  &info.if_info,
621  sizeof(info.if_info) );
622  }
623 
624  closeTcpFile( tcpFile );
625  }
626 
627  return status;
628 }
LONG NTSTATUS
Definition: precomp.h:26
struct _test_info info[]
Definition: SetCursorPos.c:19
#define FILE_READ_DATA
Definition: nt_native.h:628
GLuint index
Definition: glext.h:6031
#define TRACE(s)
Definition: solgame.cpp:4
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID closeTcpFile(HANDLE h)
Definition: handle.c:43
#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
NTSTATUS getInterfaceInfoByIndex(HANDLE tcpFile, DWORD index, IFInfo *info)
NTSTATUS openTcpFile(PHANDLE tcpFile, ACCESS_MASK DesiredAccess)
Definition: handle.c:12
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by GetIfEntry().

◆ getInterfaceEntryByName()

DWORD getInterfaceEntryByName ( const char name,
PMIB_IFROW  entry 
)

Definition at line 582 of file ifenum_reactos.c.

583 {
584  HANDLE tcpFile;
585  IFInfo info;
586  NTSTATUS status = openTcpFile( &tcpFile, FILE_READ_DATA );
587 
588  TRACE("Called.\n");
589 
590  if( NT_SUCCESS(status) ) {
591  status = getInterfaceInfoByName( tcpFile, (char *)name, &info );
592 
593  if( NT_SUCCESS(status) ) {
594  memcpy( &entry->wszName[MAX_INTERFACE_NAME_LEN],
595  &info.if_info,
596  sizeof(info.if_info) );
597  }
598 
599  TRACE("entry->bDescr = %s\n", entry->bDescr);
600 
601  closeTcpFile( tcpFile );
602  }
603 
604  return status;
605 }
LONG NTSTATUS
Definition: precomp.h:26
struct _test_info info[]
Definition: SetCursorPos.c:19
NTSTATUS getInterfaceInfoByName(HANDLE tcpFile, char *name, IFInfo *info)
#define FILE_READ_DATA
Definition: nt_native.h:628
#define TRACE(s)
Definition: solgame.cpp:4
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID closeTcpFile(HANDLE h)
Definition: handle.c:43
#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
NTSTATUS openTcpFile(PHANDLE tcpFile, ACCESS_MASK DesiredAccess)
Definition: handle.c:12
Definition: name.c:38
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

◆ getInterfaceIndexByName()

DWORD getInterfaceIndexByName ( const char name,
PDWORD  index 
)

Definition at line 380 of file ifenum_reactos.c.

381 {
382  IFInfo ifInfo;
383  HANDLE tcpFile;
384  NTSTATUS status = openTcpFile( &tcpFile, FILE_READ_DATA );
385 
386  if( NT_SUCCESS(status) ) {
387  status = getInterfaceInfoByName( tcpFile, (char *)name, &ifInfo );
388 
389  if( NT_SUCCESS(status) ) {
390  *index = ifInfo.if_info.ent.if_index;
391  }
392 
393  closeTcpFile( tcpFile );
394  }
395 
396  return status;
397 }
LONG NTSTATUS
Definition: precomp.h:26
ULONG if_index
Definition: tcpioctl.h:108
NTSTATUS getInterfaceInfoByName(HANDLE tcpFile, char *name, IFInfo *info)
#define FILE_READ_DATA
Definition: nt_native.h:628
GLuint index
Definition: glext.h:6031
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID closeTcpFile(HANDLE h)
Definition: handle.c:43
NTSTATUS openTcpFile(PHANDLE tcpFile, ACCESS_MASK DesiredAccess)
Definition: handle.c:12
Definition: name.c:38
IFEntrySafelySized if_info
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

◆ getInterfaceIndexTable()

InterfaceIndexTable* getInterfaceIndexTable ( void  )

Definition at line 446 of file ifenum_reactos.c.

446  {
448 }
InterfaceIndexTable * getInterfaceIndexTableInt(BOOL nonLoopbackOnly)

Referenced by GetIfTable(), and GetIpAddrTable().

◆ getInterfaceIndexTableInt()

InterfaceIndexTable* getInterfaceIndexTableInt ( BOOL  nonLoopbackOnly)

Definition at line 399 of file ifenum_reactos.c.

399  {
400  DWORD numInterfaces, curInterface = 0;
401  int i;
402  IFInfo *ifInfo;
404  HANDLE tcpFile;
405  NTSTATUS status = openTcpFile( &tcpFile, FILE_READ_DATA );
406 
407  if( NT_SUCCESS(status) ) {
408  status = getInterfaceInfoSet( tcpFile, &ifInfo, &numInterfaces );
409 
410  TRACE("InterfaceInfoSet: %08x, %04x:%08x\n",
411  status,
412  ifInfo->entity_id.tei_entity,
413  ifInfo->entity_id.tei_instance);
414 
415  if( NT_SUCCESS(status) ) {
417  calloc(1,
418  sizeof(InterfaceIndexTable) +
419  (numInterfaces - 1) * sizeof(DWORD));
420 
421  if (ret) {
422  ret->numAllocated = numInterfaces;
423  TRACE("NumInterfaces = %d\n", numInterfaces);
424 
425  for( i = 0; i < numInterfaces; i++ ) {
426  TRACE("Examining interface %d\n", i);
427  if( !nonLoopbackOnly ||
428  !isLoopback( tcpFile, &ifInfo[i].entity_id ) ) {
429  TRACE("Interface %d matches (%d)\n", i, curInterface);
430  ret->indexes[curInterface++] =
431  ifInfo[i].if_info.ent.if_index;
432  }
433  }
434 
435  ret->numIndexes = curInterface;
436  }
437 
438  tdiFreeThingSet( ifInfo );
439  }
440  closeTcpFile( tcpFile );
441  }
442 
443  return ret;
444 }
LONG NTSTATUS
Definition: precomp.h:26
TDIEntityID entity_id
ULONG if_index
Definition: tcpioctl.h:108
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FILE_READ_DATA
Definition: nt_native.h:628
BOOL isLoopback(HANDLE tcpFile, TDIEntityID *loop_maybe)
VOID tdiFreeThingSet(PVOID things)
Definition: enum.c:118
ULONG tei_entity
Definition: tdiinfo.h:31
#define TRACE(s)
Definition: solgame.cpp:4
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG tei_instance
Definition: tdiinfo.h:32
unsigned long DWORD
Definition: ntddk_ex.h:95
static NTSTATUS getInterfaceInfoSet(HANDLE tcpFile, IFInfo **infoSet, PDWORD numInterfaces)
VOID closeTcpFile(HANDLE h)
Definition: handle.c:43
int ret
NTSTATUS openTcpFile(PHANDLE tcpFile, ACCESS_MASK DesiredAccess)
Definition: handle.c:12
#define calloc
Definition: rosglue.h:14
IFEntrySafelySized if_info
Definition: ps.c:97

Referenced by getInterfaceIndexTable(), and getNonLoopbackInterfaceIndexTable().

◆ getInterfaceInfoByIndex()

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

Definition at line 303 of file ifenum_reactos.c.

303  {
304  IFInfo *ifInfo;
305  DWORD numInterfaces;
306  NTSTATUS status = getInterfaceInfoSet( tcpFile, &ifInfo, &numInterfaces );
307  int i;
308 
309  if( NT_SUCCESS(status) )
310  {
311  for( i = 0; i < numInterfaces; i++ ) {
312  if( ifInfo[i].if_info.ent.if_index == index ) {
313  memcpy( info, &ifInfo[i], sizeof(*info) );
314  break;
315  }
316  }
317 
318  HeapFree(GetProcessHeap(), 0, ifInfo);
319 
320  return i < numInterfaces ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL;
321  }
322 
323  return status;
324 }
LONG NTSTATUS
Definition: precomp.h:26
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
GLuint index
Definition: glext.h:6031
#define GetProcessHeap()
Definition: compat.h:404
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
unsigned long DWORD
Definition: ntddk_ex.h:95
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
static NTSTATUS getInterfaceInfoSet(HANDLE tcpFile, IFInfo **infoSet, PDWORD numInterfaces)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
return STATUS_SUCCESS
Definition: btrfs.c:3014
static SERVICE_STATUS status
Definition: service.c:31
#define HeapFree(x, y, z)
Definition: compat.h:403
Definition: ps.c:97

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

◆ getInterfaceInfoByName()

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

Definition at line 326 of file ifenum_reactos.c.

326  {
327  IFInfo *ifInfo;
328  DWORD numInterfaces;
329  int i;
330  NTSTATUS status = getInterfaceInfoSet( tcpFile, &ifInfo, &numInterfaces );
331 
332  if( NT_SUCCESS(status) )
333  {
334  for( i = 0; i < numInterfaces; i++ ) {
335  if( !strncmp((PCHAR)ifInfo[i].if_info.ent.if_descr, name, ifInfo[i].if_info.ent.if_descrlen) ) {
336  memcpy( info, &ifInfo[i], sizeof(*info) );
337  break;
338  }
339  }
340 
341  HeapFree(GetProcessHeap(), 0,ifInfo);
342 
343  return i < numInterfaces ? STATUS_SUCCESS : STATUS_UNSUCCESSFUL;
344  }
345 
346  return status;
347 }
signed char * PCHAR
Definition: retypes.h:7
LONG NTSTATUS
Definition: precomp.h:26
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define GetProcessHeap()
Definition: compat.h:404
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
unsigned long DWORD
Definition: ntddk_ex.h:95
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
static NTSTATUS getInterfaceInfoSet(HANDLE tcpFile, IFInfo **infoSet, PDWORD numInterfaces)
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
Definition: name.c:38
return STATUS_SUCCESS
Definition: btrfs.c:3014
static SERVICE_STATUS status
Definition: service.c:31
#define HeapFree(x, y, z)
Definition: compat.h:403
Definition: ps.c:97

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

◆ getInterfaceInfoSet()

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

Definition at line 155 of file ifenum_reactos.c.

157  {
158  DWORD numEntities;
159  TDIEntityID *entIDSet = NULL;
160  NTSTATUS status = tdiGetEntityIDSet( tcpFile, &entIDSet, &numEntities );
161  IFInfo *infoSetInt = 0;
162  int curInterf = 0, i;
163 
164  if (!NT_SUCCESS(status)) {
165  ERR("getInterfaceInfoSet: tdiGetEntityIDSet() failed: 0x%lx\n", status);
166  return status;
167  }
168 
169  infoSetInt = HeapAlloc( GetProcessHeap(), 0,
170  sizeof(IFInfo) * numEntities );
171 
172  if( infoSetInt ) {
173  for( i = 0; i < numEntities; i++ ) {
174  if( isInterface( &entIDSet[i] ) ) {
175  infoSetInt[curInterf].entity_id = entIDSet[i];
177  ( tcpFile,
178  &entIDSet[i],
179  &infoSetInt[curInterf].if_info );
180  TRACE("tdiGetMibForIfEntity: %08x\n", status);
181  if( NT_SUCCESS(status) ) {
182  DWORD numAddrs;
183  IPAddrEntry *addrs;
184  TDIEntityID ip_ent;
185  int j;
186 
187  status = getNthIpEntity( tcpFile, curInterf, &ip_ent );
188  if( NT_SUCCESS(status) )
190  ( tcpFile, &ip_ent, &addrs, &numAddrs );
191  for( j = 0; NT_SUCCESS(status) && j < numAddrs; j++ ) {
192  TRACE("ADDR %d: index %d (target %d)\n", j, addrs[j].iae_index, infoSetInt[curInterf].if_info.ent.if_index);
193  if( addrs[j].iae_index ==
194  infoSetInt[curInterf].if_info.ent.if_index ) {
195  memcpy( &infoSetInt[curInterf].ip_addr,
196  &addrs[j],
197  sizeof( addrs[j] ) );
198  curInterf++;
199  break;
200  }
201  }
202  if ( NT_SUCCESS(status) )
203  tdiFreeThingSet(addrs);
204  }
205  }
206  }
207 
208  tdiFreeThingSet(entIDSet);
209 
210  if (NT_SUCCESS(status)) {
211  *infoSet = infoSetInt;
212  *numInterfaces = curInterf;
213  } else {
214  HeapFree(GetProcessHeap(), 0, infoSetInt);
215  }
216 
217  return status;
218  } else {
219  tdiFreeThingSet(entIDSet);
221  }
222 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
LONG NTSTATUS
Definition: precomp.h:26
TDIEntityID entity_id
NTSTATUS getNthIpEntity(HANDLE tcpFile, DWORD index, TDIEntityID *ent)
BOOL isInterface(TDIEntityID *if_maybe)
NTSTATUS tdiGetEntityIDSet(HANDLE tcpFile, TDIEntityID **entitySet, PDWORD numEntities)
Definition: enum.c:122
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
smooth NULL
Definition: ftsmooth.c:416
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
VOID tdiFreeThingSet(PVOID things)
Definition: enum.c:118
#define TRACE(s)
Definition: solgame.cpp:4
NTSTATUS tdiGetMibForIfEntity(HANDLE tcpFile, TDIEntityID *ent, IFEntrySafelySized *entry)
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
unsigned long DWORD
Definition: ntddk_ex.h:95
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ERR(fmt,...)
Definition: debug.h:110
NTSTATUS tdiGetIpAddrsForIpEntity(HANDLE tcpFile, TDIEntityID *ent, IPAddrEntry **addrs, PDWORD numAddrs)
static SERVICE_STATUS status
Definition: service.c:31
#define HeapFree(x, y, z)
Definition: compat.h:403
Definition: ps.c:97

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

◆ getInterfaceIPAddrByIndex()

DWORD getInterfaceIPAddrByIndex ( DWORD  index)

Definition at line 500 of file ifenum_reactos.c.

500  {
501  return getAddrByIndexOrName( 0, index, IPAAddr );
502 }
GLuint index
Definition: glext.h:6031
DWORD getAddrByIndexOrName(char *name, DWORD index, IPHLPAddrType addrType)

Referenced by GetAdaptersInfo(), and GetIpAddrTable().

◆ getInterfaceIPAddrByName()

DWORD getInterfaceIPAddrByName ( const char name)

Definition at line 454 of file ifenum_reactos.c.

455 {
456  return INADDR_ANY;
457 }
#define INADDR_ANY
Definition: StrAddr.c:4

◆ getInterfaceMaskByIndex()

DWORD getInterfaceMaskByIndex ( DWORD  index)

Definition at line 516 of file ifenum_reactos.c.

516  {
517  return getAddrByIndexOrName( 0, index, IPAMask );
518 }
GLuint index
Definition: glext.h:6031
DWORD getAddrByIndexOrName(char *name, DWORD index, IPHLPAddrType addrType)

Referenced by GetAdaptersInfo(), and GetIpAddrTable().

◆ getInterfaceMaskByName()

DWORD getInterfaceMaskByName ( const char name)

Definition at line 512 of file ifenum_reactos.c.

512  {
513  return getAddrByIndexOrName( (char *)name, 0, IPAMask );
514 }
DWORD getAddrByIndexOrName(char *name, DWORD index, IPHLPAddrType addrType)
Definition: name.c:38

◆ getInterfaceMtuByIndex()

DWORD getInterfaceMtuByIndex ( DWORD  index,
PDWORD  mtu 
)

Definition at line 566 of file ifenum_reactos.c.

566  {
567  *mtu = getAddrByIndexOrName( 0, index, IFMtu );
568  return STATUS_SUCCESS;
569 }
GLuint index
Definition: glext.h:6031
DWORD getAddrByIndexOrName(char *name, DWORD index, IPHLPAddrType addrType)
return STATUS_SUCCESS
Definition: btrfs.c:3014

◆ getInterfaceMtuByName()

DWORD getInterfaceMtuByName ( const char name,
PDWORD  mtu 
)

Definition at line 561 of file ifenum_reactos.c.

561  {
562  *mtu = getAddrByIndexOrName( (char *)name, 0, IFMtu );
563  return STATUS_SUCCESS;
564 }
DWORD getAddrByIndexOrName(char *name, DWORD index, IPHLPAddrType addrType)
Definition: name.c:38
return STATUS_SUCCESS
Definition: btrfs.c:3014

◆ getInterfaceNameByIndex()

const char* getInterfaceNameByIndex ( DWORD  index)

Definition at line 351 of file ifenum_reactos.c.

352 {
353  IFInfo ifInfo;
354  HANDLE tcpFile;
355  char *interfaceName = NULL;
356  NTSTATUS status = openTcpFile( &tcpFile, FILE_READ_DATA );
357 
358  if( NT_SUCCESS(status) ) {
359  status = getInterfaceInfoByIndex( tcpFile, index, &ifInfo );
360 
361  if( NT_SUCCESS(status) ) {
362  interfaceName = HeapAlloc( GetProcessHeap(), 0,
363  ifInfo.if_info.ent.if_descrlen + 1 );
364  if( interfaceName ) {
365  memcpy(interfaceName, ifInfo.if_info.ent.if_descr, ifInfo.if_info.ent.if_descrlen);
366  interfaceName[ifInfo.if_info.ent.if_descrlen] = '\0';
367  }
368  }
369 
370  closeTcpFile( tcpFile );
371  }
372 
373  return interfaceName;
374 }
ULONG if_descrlen
Definition: tcpioctl.h:129
LONG NTSTATUS
Definition: precomp.h:26
#define FILE_READ_DATA
Definition: nt_native.h:628
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
#define GetProcessHeap()
Definition: compat.h:404
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID closeTcpFile(HANDLE h)
Definition: handle.c:43
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
NTSTATUS getInterfaceInfoByIndex(HANDLE tcpFile, DWORD index, IFInfo *info)
NTSTATUS openTcpFile(PHANDLE tcpFile, ACCESS_MASK DesiredAccess)
Definition: handle.c:12
IFEntrySafelySized if_info
UCHAR if_descr[1]
Definition: tcpioctl.h:130
Definition: ps.c:97

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

◆ getInterfacePhysicalByIndex()

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

Definition at line 544 of file ifenum_reactos.c.

546 {
547  HANDLE tcpFile;
548  IFInfo info;
549  NTSTATUS status = openTcpFile( &tcpFile, FILE_READ_DATA );
550 
551  if( NT_SUCCESS(status) ) {
552  status = getInterfaceInfoByIndex( tcpFile, index, &info );
553  if( NT_SUCCESS(status) )
555  closeTcpFile( tcpFile );
556  }
557 
558  return status;
559 }
LONG NTSTATUS
Definition: precomp.h:26
void getInterfacePhysicalFromInfo(IFInfo *info, PDWORD len, PBYTE addr, PDWORD type)
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
struct _test_info info[]
Definition: SetCursorPos.c:19
#define FILE_READ_DATA
Definition: nt_native.h:628
GLuint index
Definition: glext.h:6031
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID closeTcpFile(HANDLE h)
Definition: handle.c:43
GLenum const GLvoid * addr
Definition: glext.h:9621
GLenum GLsizei len
Definition: glext.h:6722
NTSTATUS getInterfaceInfoByIndex(HANDLE tcpFile, DWORD index, IFInfo *info)
NTSTATUS openTcpFile(PHANDLE tcpFile, ACCESS_MASK DesiredAccess)
Definition: handle.c:12
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by GetAdaptersInfo().

◆ getInterfacePhysicalByName()

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

Definition at line 527 of file ifenum_reactos.c.

529 {
530  HANDLE tcpFile;
531  IFInfo info;
532  NTSTATUS status = openTcpFile( &tcpFile, FILE_READ_DATA );
533 
534  if( NT_SUCCESS(status) ) {
535  status = getInterfaceInfoByName( tcpFile, (char *)name, &info );
536  if( NT_SUCCESS(status) )
538  closeTcpFile( tcpFile );
539  }
540 
541  return status;
542 }
LONG NTSTATUS
Definition: precomp.h:26
void getInterfacePhysicalFromInfo(IFInfo *info, PDWORD len, PBYTE addr, PDWORD type)
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
struct _test_info info[]
Definition: SetCursorPos.c:19
NTSTATUS getInterfaceInfoByName(HANDLE tcpFile, char *name, IFInfo *info)
#define FILE_READ_DATA
Definition: nt_native.h:628
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID closeTcpFile(HANDLE h)
Definition: handle.c:43
GLenum const GLvoid * addr
Definition: glext.h:9621
GLenum GLsizei len
Definition: glext.h:6722
NTSTATUS openTcpFile(PHANDLE tcpFile, ACCESS_MASK DesiredAccess)
Definition: handle.c:12
Definition: name.c:38
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

◆ getInterfacePhysicalFromInfo()

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

Definition at line 520 of file ifenum_reactos.c.

521  {
522  *len = info->if_info.ent.if_physaddrlen;
523  memcpy( addr, info->if_info.ent.if_physaddr, *len );
524  *type = info->if_info.ent.if_type;
525 }
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLenum const GLvoid * addr
Definition: glext.h:9621
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722

Referenced by getInterfacePhysicalByIndex(), and getInterfacePhysicalByName().

◆ getInterfaceStatusByIndex()

DWORD getInterfaceStatusByIndex ( DWORD  index,
PDWORD  status 
)

Definition at line 576 of file ifenum_reactos.c.

577 {
579  return STATUS_SUCCESS;
580 }
GLuint index
Definition: glext.h:6031
DWORD getAddrByIndexOrName(char *name, DWORD index, IPHLPAddrType addrType)
return STATUS_SUCCESS
Definition: btrfs.c:3014
Definition: ps.c:97

◆ getInterfaceStatusByName()

DWORD getInterfaceStatusByName ( const char name,
PDWORD  status 
)

Definition at line 571 of file ifenum_reactos.c.

571  {
572  *status = getAddrByIndexOrName( (char *)name, 0, IFStatus );
573  return STATUS_SUCCESS;
574 }
DWORD getAddrByIndexOrName(char *name, DWORD index, IPHLPAddrType addrType)
Definition: name.c:38
return STATUS_SUCCESS
Definition: btrfs.c:3014
Definition: ps.c:97

◆ getIPAddrEntryForIf()

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

Definition at line 459 of file ifenum_reactos.c.

462  {
463  NTSTATUS status =
464  name ?
465  getInterfaceInfoByName( tcpFile, name, ifInfo ) :
466  getInterfaceInfoByIndex( tcpFile, index, ifInfo );
467 
468  if (!NT_SUCCESS(status)) {
469  ERR("getIPAddrEntryForIf returning %lx\n", status);
470  }
471 
472  return status;
473 }
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS getInterfaceInfoByName(HANDLE tcpFile, char *name, IFInfo *info)
GLuint index
Definition: glext.h:6031
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ERR(fmt,...)
Definition: debug.h:110
NTSTATUS getInterfaceInfoByIndex(HANDLE tcpFile, DWORD index, IFInfo *info)
Definition: name.c:38
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by getAddrByIndexOrName().

◆ getNonLoopbackInterfaceIndexTable()

InterfaceIndexTable* getNonLoopbackInterfaceIndexTable ( void  )

Definition at line 450 of file ifenum_reactos.c.

450  {
452 }
#define TRUE
Definition: types.h:120
InterfaceIndexTable * getInterfaceIndexTableInt(BOOL nonLoopbackOnly)

Referenced by GetAdaptersInfo(), and GetInterfaceInfo().

◆ getNthInterfaceEntity()

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

Definition at line 273 of file ifenum_reactos.c.

273  {
274  DWORD numEntities = 0;
275  DWORD numInterfaces = 0;
276  TDIEntityID *entitySet = 0;
277  NTSTATUS status = tdiGetEntityIDSet( tcpFile, &entitySet, &numEntities );
278  int i;
279 
280  if( !NT_SUCCESS(status) )
281  return status;
282 
283  for( i = 0; i < numEntities; i++ ) {
284  if( isInterface( &entitySet[i] ) ) {
285  if( numInterfaces == index ) break;
286  else numInterfaces++;
287  }
288  }
289 
290  TRACE("Index %d is entity #%d - %04x:%08x\n", index, i,
291  entitySet[i].tei_entity, entitySet[i].tei_instance );
292 
293  if( numInterfaces == index && i < numEntities ) {
294  memcpy( ent, &entitySet[i], sizeof(*ent) );
295  tdiFreeThingSet( entitySet );
296  return STATUS_SUCCESS;
297  } else {
298  tdiFreeThingSet( entitySet );
299  return STATUS_UNSUCCESSFUL;
300  }
301 }
LONG NTSTATUS
Definition: precomp.h:26
BOOL isInterface(TDIEntityID *if_maybe)
NTSTATUS tdiGetEntityIDSet(HANDLE tcpFile, TDIEntityID **entitySet, PDWORD numEntities)
Definition: enum.c:122
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
GLuint index
Definition: glext.h:6031
VOID tdiFreeThingSet(PVOID things)
Definition: enum.c:118
#define TRACE(s)
Definition: solgame.cpp:4
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
unsigned long DWORD
Definition: ntddk_ex.h:95
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
return STATUS_SUCCESS
Definition: btrfs.c:3014
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

◆ getNumInterfaces()

DWORD getNumInterfaces ( void  )

Definition at line 263 of file ifenum_reactos.c.

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

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

◆ getNumInterfacesInt()

static DWORD getNumInterfacesInt ( BOOL  onlyNonLoopback)
static

Definition at line 224 of file ifenum_reactos.c.

225 {
226  DWORD numEntities, numInterfaces = 0;
227  TDIEntityID *entitySet;
228  HANDLE tcpFile;
230  int i;
231 
232  status = openTcpFile( &tcpFile, FILE_READ_DATA );
233 
234  if( !NT_SUCCESS(status) ) {
235  WARN("getNumInterfaces: failed %08x\n", status );
236  return 0;
237  }
238 
239  status = tdiGetEntityIDSet( tcpFile, &entitySet, &numEntities );
240 
241  if( !NT_SUCCESS(status) ) {
242  WARN("getNumInterfaces: failed %08x\n", status );
243  closeTcpFile( tcpFile );
244  return 0;
245  }
246 
247  for( i = 0; i < numEntities; i++ ) {
248  if( isInterface( &entitySet[i] ) &&
249  (!onlyNonLoopback || !isLoopback( tcpFile, &entitySet[i] )) )
250  numInterfaces++;
251  }
252 
253  TRACE("getNumInterfaces: success: %d %d %08x\n",
254  onlyNonLoopback, numInterfaces, status );
255 
256  closeTcpFile( tcpFile );
257 
258  tdiFreeThingSet( entitySet );
259 
260  return numInterfaces;
261 }
#define WARN(fmt,...)
Definition: debug.h:112
LONG NTSTATUS
Definition: precomp.h:26
BOOL isInterface(TDIEntityID *if_maybe)
NTSTATUS tdiGetEntityIDSet(HANDLE tcpFile, TDIEntityID **entitySet, PDWORD numEntities)
Definition: enum.c:122
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define FILE_READ_DATA
Definition: nt_native.h:628
BOOL isLoopback(HANDLE tcpFile, TDIEntityID *loop_maybe)
VOID tdiFreeThingSet(PVOID things)
Definition: enum.c:118
#define TRACE(s)
Definition: solgame.cpp:4
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
unsigned long DWORD
Definition: ntddk_ex.h:95
VOID closeTcpFile(HANDLE h)
Definition: handle.c:43
NTSTATUS openTcpFile(PHANDLE tcpFile, ACCESS_MASK DesiredAccess)
Definition: handle.c:12
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by getNumInterfaces(), and getNumNonLoopbackInterfaces().

◆ getNumNonLoopbackInterfaces()

DWORD getNumNonLoopbackInterfaces ( void  )

Definition at line 268 of file ifenum_reactos.c.

269 {
270  return getNumInterfacesInt( TRUE );
271 }
#define TRUE
Definition: types.h:120
static DWORD getNumInterfacesInt(BOOL onlyNonLoopback)

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 
138  req.ID.toi_id = ENTITY_TYPE_ID;
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  return (type & AT_ARP);
153 }
TDIEntityID toi_entity
Definition: tdiinfo.h:74
#define AT_ENTITY
Definition: tdiinfo.h:41
#define TCP_REQUEST_QUERY_INFORMATION_INIT
ULONG toi_class
Definition: tdiinfo.h:75
LONG NTSTATUS
Definition: precomp.h:26
#define ENTITY_TYPE_ID
Definition: tdiinfo.h:39
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define AT_ARP
Definition: tdiinfo.h:49
ULONG toi_id
Definition: tdiinfo.h:77
smooth NULL
Definition: ftsmooth.c:416
ULONG tei_entity
Definition: tdiinfo.h:31
#define INFO_CLASS_GENERIC
Definition: tdiinfo.h:64
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
ULONG tei_instance
Definition: tdiinfo.h:32
unsigned long DWORD
Definition: ntddk_ex.h:95
#define IOCTL_TCP_QUERY_INFORMATION_EX
Definition: tditest.h:110
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
return STATUS_SUCCESS
Definition: btrfs.c:3014
ULONG toi_type
Definition: tdiinfo.h:76
Definition: ps.c:97

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 }
ULONG tei_entity
Definition: tdiinfo.h:31
#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 }
LONG NTSTATUS
Definition: precomp.h:26
ULONG if_type
Definition: tcpioctl.h:109
#define IFENT_SOFTWARE_LOOPBACK
NTSTATUS tdiGetMibForIfEntity(HANDLE tcpFile, TDIEntityID *ent, IFEntrySafelySized *entry)
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by getInterfaceIndexTableInt(), and getNumInterfacesInt().

◆ tdiGetMibForIfEntity()

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

Definition at line 60 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");
85  return STATUS_UNSUCCESSFUL;
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 }
TDIEntityID toi_entity
Definition: tdiinfo.h:74
#define TCP_REQUEST_QUERY_INFORMATION_INIT
ULONG toi_class
Definition: tdiinfo.h:75
#define WARN(fmt,...)
Definition: debug.h:112
LONG NTSTATUS
Definition: precomp.h:26
ULONG toi_id
Definition: tdiinfo.h:77
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
ULONG tei_instance
Definition: tdiinfo.h:32
unsigned long DWORD
Definition: ntddk_ex.h:95
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
uint32_t entry
Definition: isohybrid.c:63
#define IOCTL_TCP_QUERY_INFORMATION_EX
Definition: tditest.h:110
#define IF_MIB_STATS_ID
Definition: tcpioctl.h:52
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
return STATUS_SUCCESS
Definition: btrfs.c:3014
ULONG toi_type
Definition: tdiinfo.h:76
#define INFO_CLASS_PROTOCOL
Definition: tdiinfo.h:65
Definition: ps.c:97

Referenced by getInterfaceInfoSet(), and isLoopback().

◆ toIPAddressString()

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

Definition at line 630 of file ifenum_reactos.c.

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

Referenced by GetAdaptersInfo().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( iphlpapi  )