ReactOS  0.4.14-dev-41-g31d7680
tcp_info.c File Reference
#include <apitest.h>
#include <stdio.h>
#include <winioctl.h>
#include <tcpioctl.h>
#include <tdiinfo.h>
#include <iptypes.h>
#include <winsock.h>
Include dependency graph for tcp_info.c:

Go to the source code of this file.

Classes

struct  IPRouteEntry
 
struct  ARPInfo
 
struct  ARPEntry
 

Macros

#define AT_MIB_ADDRXLAT_INFO_ID   1
 
#define AT_MIB_ADDRXLAT_ENTRY_ID   0x101
 

Typedefs

typedef struct IPRouteEntry IPRouteEntry
 
typedef struct ARPInfo ARPInfo
 
typedef struct ARPEntry ARPEntry
 

Functions

NTSYSAPI PSTR NTAPI RtlIpv4AddressToStringA (_In_ const struct in_addr *Addr, _Out_writes_(16) PSTR S)
 
static chardbg_print_physaddr (const unsigned char *addr, unsigned long addr_len)
 
static int __cdecl indent_printf (const char *format,...)
 
static void test_IF_MIB_STATS (TDIEntityID Id, ULONG EntityType)
 
static void test_IP_MIB_STATS (TDIEntityID Id, ULONG EntityType)
 
static void test_AT_ARP_STATS (TDIEntityID Id, ULONG EntityType)
 
 START_TEST (tcp_info)
 

Variables

static HANDLE TcpFileHandle
 
static ULONG IndentationLevel = 0
 

Macro Definition Documentation

◆ AT_MIB_ADDRXLAT_ENTRY_ID

#define AT_MIB_ADDRXLAT_ENTRY_ID   0x101

Definition at line 20 of file tcp_info.c.

◆ AT_MIB_ADDRXLAT_INFO_ID

#define AT_MIB_ADDRXLAT_INFO_ID   1

Definition at line 19 of file tcp_info.c.

Typedef Documentation

◆ ARPEntry

◆ ARPInfo

◆ IPRouteEntry

Function Documentation

◆ dbg_print_physaddr()

static char* dbg_print_physaddr ( const unsigned char addr,
unsigned long  addr_len 
)
static

Definition at line 54 of file tcp_info.c.

55 {
56  static char buffer[24];
57 
58  char* dest = buffer;
59  *dest = '\0';
60 
61  while (addr_len--)
62  {
63  dest += sprintf(dest, "%02x", *addr);
64  addr++;
65  if (addr_len)
66  *dest++ = ':';
67  }
68 
69  return buffer;
70 }
GLuint buffer
Definition: glext.h:5915
#define sprintf(buf, format,...)
Definition: sprintf.c:55
GLenum const GLvoid * addr
Definition: glext.h:9621
static char * dest
Definition: rtl.c:135

Referenced by test_AT_ARP_STATS(), test_IF_MIB_STATS(), and test_IP_MIB_STATS().

◆ indent_printf()

static int __cdecl indent_printf ( const char format,
  ... 
)
static

Definition at line 75 of file tcp_info.c.

76 {
77  ULONG Indent = IndentationLevel;
78  int ret;
79  va_list args;
80 
81  while(Indent--)
82  printf("\t");
83 
85  ret = vprintf(format, args);
86  va_end(args);
87 
89 
90  return ret;
91 }
Definition: match.c:390
GLint GLint GLsizei GLsizei GLsizei GLint GLenum format
Definition: gl.h:1546
#define va_end(ap)
Definition: acmsvcex.h:90
char * va_list
Definition: acmsvcex.h:78
_Check_return_opt_ _CRTIMP int __cdecl vprintf(_In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
static ULONG IndentationLevel
Definition: tcp_info.c:50
int ret
#define va_start(ap, A)
Definition: acmsvcex.h:91
unsigned int ULONG
Definition: retypes.h:1
#define args
Definition: format.c:66
#define printf
Definition: config.h:203

Referenced by test_AT_ARP_STATS(), test_IF_MIB_STATS(), and test_IP_MIB_STATS().

◆ RtlIpv4AddressToStringA()

NTSYSAPI PSTR NTAPI RtlIpv4AddressToStringA ( _In_ const struct in_addr Addr,
_Out_writes_(16) PSTR  S 
)

◆ START_TEST()

START_TEST ( tcp_info  )

Definition at line 469 of file tcp_info.c.

470 {
471  TDIEntityID* Entities;
473  BOOL Result;
476 
477  /* Open a control channel file for TCP */
479  L"\\\\.\\Tcp",
482  NULL,
484  0,
485  NULL);
486  ok(TcpFileHandle != INVALID_HANDLE_VALUE, "CreateFile failed, GLE %lu\n", GetLastError());
487 
488  /* Try the IOCTL */
489  BufferSize = 0;
493  NULL,
494  0,
495  NULL,
496  0,
497  &BufferSize,
498  NULL);
499  ok(!Result, "DeviceIoControl succeeded.\n");
501  ok_long(BufferSize, 0);
502 
503  ZeroMemory(&Request, sizeof(Request));
504  Request.ID.toi_entity.tei_entity = GENERIC_ENTITY;
505  Request.ID.toi_entity.tei_instance = 0;
506  Request.ID.toi_class = INFO_CLASS_GENERIC;
507  Request.ID.toi_type = INFO_TYPE_PROVIDER;
508  Request.ID.toi_id = ENTITY_LIST_ID;
509 
510  BufferSize = 0;
514  &Request,
515  sizeof(Request),
516  NULL,
517  0,
518  &BufferSize,
519  NULL);
520  ok(!Result, "DeviceIoControl succeeded.\n");
522  ok_long(BufferSize, 0);
523 
524  BufferSize = 4 * sizeof(Entities[0]);
526  ok(Entities != NULL, "\n");
527 
528  while (TRUE)
529  {
533  &Request,
534  sizeof(Request),
535  Entities,
536  BufferSize,
537  &BufferSize,
538  NULL);
539 
540  if (Result)
541  break;
542 
544  break;
545 
546  BufferSize *= 2;
547  Entities = HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, Entities, BufferSize);
548  ok(Entities != NULL, "\n");
549  }
550 
551  ok(Result, "DeviceIoControl failed!\n");
552  EntityCount = BufferSize / sizeof(Entities[0]);
553  trace("Got %lu entities.\n", EntityCount);
554 
555  for (i = 0; i < EntityCount; i++)
556  {
557  ULONG EntityType;
558 
559  /* Get the type */
560  Request.ID.toi_entity = Entities[i];
561  Request.ID.toi_class = INFO_CLASS_GENERIC;
562  Request.ID.toi_type = INFO_TYPE_PROVIDER;
563  Request.ID.toi_id = ENTITY_TYPE_ID;
564 
568  &Request,
569  sizeof(Request),
570  &EntityType,
571  sizeof(EntityType),
572  &BufferSize,
573  NULL);
574  ok(Result, "DeviceIoControl failed.\n");
575 
576  printf("Entity %lu: %#lx, %#lx, type %#lx\n", i, Entities[i].tei_entity, Entities[i].tei_instance, EntityType);
577  test_IF_MIB_STATS(Entities[i], EntityType);
578  test_IP_MIB_STATS(Entities[i], EntityType);
579  test_AT_ARP_STATS(Entities[i], EntityType);
580  }
581 
582  HeapFree(GetProcessHeap(), 0, Entities);
584 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
ULONG EntityCount
Definition: main.c:24
#define TRUE
Definition: types.h:120
#define CloseHandle
Definition: compat.h:398
#define ENTITY_TYPE_ID
Definition: tdiinfo.h:39
#define INVALID_HANDLE_VALUE
Definition: compat.h:391
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define ZeroMemory
Definition: winbase.h:1635
#define FILE_SHARE_WRITE
Definition: nt_native.h:681
#define IOCTL_TCP_QUERY_INFORMATION_EX
Definition: ticonsts.h:42
#define ok_long(expression, result)
Definition: atltest.h:133
#define FILE_SHARE_READ
Definition: compat.h:125
_In_ NDIS_HANDLE _In_ PNDIS_REQUEST Request
Definition: ndis.h:5173
static void test_IP_MIB_STATS(TDIEntityID Id, ULONG EntityType)
Definition: tcp_info.c:159
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
unsigned int BOOL
Definition: ntddk_ex.h:94
#define FILE_READ_DATA
Definition: nt_native.h:628
smooth NULL
Definition: ftsmooth.c:416
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
#define FILE_WRITE_DATA
Definition: nt_native.h:631
#define OPEN_EXISTING
Definition: compat.h:426
#define GetProcessHeap()
Definition: compat.h:395
#define trace
Definition: atltest.h:70
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define INFO_CLASS_GENERIC
Definition: tdiinfo.h:64
static void test_IF_MIB_STATS(TDIEntityID Id, ULONG EntityType)
Definition: tcp_info.c:95
#define BufferSize
Definition: classpnp.h:419
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
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 ENTITY_LIST_ID
Definition: tdiinfo.h:38
#define ok(value,...)
Definition: atltest.h:57
#define HeapReAlloc
Definition: compat.h:393
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define CreateFileW
Definition: compat.h:400
#define INFO_TYPE_PROVIDER
Definition: tdiinfo.h:69
unsigned int ULONG
Definition: retypes.h:1
static HANDLE TcpFileHandle
Definition: tcp_info.c:48
#define GENERIC_ENTITY
Definition: tdiinfo.h:37
#define HeapFree(x, y, z)
Definition: compat.h:394
static void test_AT_ARP_STATS(TDIEntityID Id, ULONG EntityType)
Definition: tcp_info.c:384
#define printf
Definition: config.h:203
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10

◆ test_AT_ARP_STATS()

static void test_AT_ARP_STATS ( TDIEntityID  Id,
ULONG  EntityType 
)
static

Definition at line 384 of file tcp_info.c.

387 {
388  ARPInfo ArpInfo;
390  ULONG BufferSize = 0;
391  BOOL Result;
392 
393  /* Not valid for other entity types */
394  if (EntityType != AT_ARP)
395  return;
396 
397  ZeroMemory(&Request, sizeof(Request));
398  Request.ID.toi_entity = Id;
399  Request.ID.toi_class = INFO_CLASS_PROTOCOL;
400  Request.ID.toi_type = INFO_TYPE_PROVIDER;
401  Request.ID.toi_id = AT_MIB_ADDRXLAT_INFO_ID;
402 
406  &Request,
407  sizeof(Request),
408  &ArpInfo,
409  sizeof(ArpInfo),
410  &BufferSize,
411  NULL);
412  ok(Result, "DeviceIoControl failed.\n");
413  ok_long(BufferSize, sizeof(ArpInfo));
414 
415  indent_printf("ARP Info:\n");
417 
418  indent_printf("ai_numroutes: %lu\n", ArpInfo.ai_numroutes);
419  indent_printf("ai_unknown: %lx\n", ArpInfo.ai_unknown);
420 
421  if (ArpInfo.ai_numroutes)
422  {
423  ARPEntry* ArpEntries;
424  ULONG i;
425 
426  Request.ID.toi_id = AT_MIB_ADDRXLAT_ENTRY_ID;
427 
428  ArpEntries = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, ArpInfo.ai_numroutes * sizeof(ArpEntries[0]));
429  ok(ArpEntries != NULL, "\n");
430 
434  &Request,
435  sizeof(Request),
436  ArpEntries,
437  ArpInfo.ai_numroutes * sizeof(ArpEntries[0]),
438  &BufferSize,
439  NULL);
440  ok(Result, "DeviceIoControl failed.\n");
441  ok_long(BufferSize, ArpInfo.ai_numroutes * sizeof(ArpEntries[0]));
442 
443  for (i = 0; i < ArpInfo.ai_numroutes; i++)
444  {
445  CHAR AddressString[16];
446  struct in_addr Addr;
447 
448  Addr.S_un.S_addr = ArpEntries[i].ae_address;
449  RtlIpv4AddressToStringA(&Addr, AddressString);
450 
451  indent_printf("ARP Entry %lu:\n", i);
452 
454 
455  indent_printf("ae_index: %lu\n", ArpEntries[i].ae_index);
456  indent_printf("ae_physaddr: %s\n", dbg_print_physaddr(ArpEntries[i].ae_physaddr, ArpEntries[i].ae_physaddrlen));
457  indent_printf("ae_address: %lx (%s)\n", ArpEntries[i].ae_address, AddressString);
458  indent_printf("ae_unknown: %lu.\n", ArpEntries[i].ae_unknown);
459 
461  }
462 
463  HeapFree(GetProcessHeap(), 0, ArpEntries);
464  }
465 
467 }
static int __cdecl indent_printf(const char *format,...)
Definition: tcp_info.c:75
#define AT_MIB_ADDRXLAT_INFO_ID
Definition: tcp_info.c:19
char CHAR
Definition: xmlstorage.h:175
NTSYSAPI PSTR NTAPI RtlIpv4AddressToStringA(_In_ const struct in_addr *Addr, _Out_writes_(16) PSTR S)
#define ZeroMemory
Definition: winbase.h:1635
#define IOCTL_TCP_QUERY_INFORMATION_EX
Definition: ticonsts.h:42
#define ok_long(expression, result)
Definition: atltest.h:133
DWORD Id
_In_ NDIS_HANDLE _In_ PNDIS_REQUEST Request
Definition: ndis.h:5173
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
unsigned int BOOL
Definition: ntddk_ex.h:94
#define AT_ARP
Definition: tdiinfo.h:49
smooth NULL
Definition: ftsmooth.c:416
static char * dbg_print_physaddr(const unsigned char *addr, unsigned long addr_len)
Definition: tcp_info.c:54
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
unsigned long ai_numroutes
Definition: tcp_info.c:369
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
Definition: tcpip.h:125
#define BufferSize
Definition: classpnp.h:419
static ULONG IndentationLevel
Definition: tcp_info.c:50
u_long S_addr
Definition: tcpip.h:131
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
unsigned long ai_unknown
Definition: tcp_info.c:370
#define ok(value,...)
Definition: atltest.h:57
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define INFO_TYPE_PROVIDER
Definition: tdiinfo.h:69
unsigned int ULONG
Definition: retypes.h:1
union in_addr::@990 S_un
static HANDLE TcpFileHandle
Definition: tcp_info.c:48
#define HeapFree(x, y, z)
Definition: compat.h:394
#define AT_MIB_ADDRXLAT_ENTRY_ID
Definition: tcp_info.c:20
unsigned long ae_address
Definition: tcp_info.c:378
#define INFO_CLASS_PROTOCOL
Definition: tdiinfo.h:65

Referenced by START_TEST().

◆ test_IF_MIB_STATS()

static void test_IF_MIB_STATS ( TDIEntityID  Id,
ULONG  EntityType 
)
static

Definition at line 95 of file tcp_info.c.

98 {
99  IFEntry* IfEntry;
102  BOOL Result;
103 
104  /* Not valid for other entity types */
105  if (EntityType != IF_MIB)
106  return;
107 
109  ok(IfEntry != NULL, "\n");
110 
111  ZeroMemory(&Request, sizeof(Request));
112  Request.ID.toi_entity = Id;
113  Request.ID.toi_class = INFO_CLASS_PROTOCOL;
114  Request.ID.toi_type = INFO_TYPE_PROVIDER;
115  Request.ID.toi_id = IF_MIB_STATS_ID;
116 
120  &Request,
121  sizeof(Request),
122  IfEntry,
123  BufferSize,
124  &BufferSize,
125  NULL);
126  ok(Result, "DeviceIoControl failed.\n");
127 
128  /* Dump it */
129  indent_printf("IF_MIB Statistics:\n");
131  indent_printf("if_index: %lu\n", IfEntry->if_index);
132  indent_printf("if_type: %lu\n", IfEntry->if_type);
133  indent_printf("if_mtu: %lu\n", IfEntry->if_mtu);
134  indent_printf("if_speed: %lu\n", IfEntry->if_speed);
135  indent_printf("if_physaddr: %s\n", dbg_print_physaddr(IfEntry->if_physaddr, IfEntry->if_physaddrlen));
136  indent_printf("if_adminstatus: %lu\n", IfEntry->if_adminstatus);
137  indent_printf("if_operstatus: %lu\n", IfEntry->if_operstatus);
138  indent_printf("if_lastchange: %lu\n", IfEntry->if_lastchange);
139  indent_printf("if_inoctets: %lu\n", IfEntry->if_inoctets);
140  indent_printf("if_inucastpkts: %lu\n", IfEntry->if_inucastpkts);
141  indent_printf("if_innucastpkts: %lu\n", IfEntry->if_innucastpkts);
142  indent_printf("if_indiscards: %lu\n", IfEntry->if_indiscards);
143  indent_printf("if_inerrors: %lu\n", IfEntry->if_inerrors);
144  indent_printf("if_inunknownprotos: %lu\n", IfEntry->if_inunknownprotos);
145  indent_printf("if_outoctets: %lu\n", IfEntry->if_outoctets);
146  indent_printf("if_outucastpkts: %lu\n", IfEntry->if_outucastpkts);
147  indent_printf("if_outnucastpkts: %lu\n", IfEntry->if_outnucastpkts);
148  indent_printf("if_outdiscards: %lu\n", IfEntry->if_outdiscards);
149  indent_printf("if_outerrors: %lu\n", IfEntry->if_outerrors);
150  indent_printf("if_outqlen: %lu\n", IfEntry->if_outqlen);
151  indent_printf("if_descr: %*s\n", IfEntry->if_descrlen, IfEntry->if_descr);
153 
154  HeapFree(GetProcessHeap(), 0, IfEntry);
155 }
ULONG if_descrlen
Definition: tcpioctl.h:126
ULONG if_inoctets
Definition: tcpioctl.h:114
static int __cdecl indent_printf(const char *format,...)
Definition: tcp_info.c:75
ULONG if_physaddrlen
Definition: tcpioctl.h:109
ULONG if_outucastpkts
Definition: tcpioctl.h:121
#define ZeroMemory
Definition: winbase.h:1635
ULONG if_index
Definition: tcpioctl.h:105
ULONG if_operstatus
Definition: tcpioctl.h:112
ULONG if_outerrors
Definition: tcpioctl.h:124
#define IOCTL_TCP_QUERY_INFORMATION_EX
Definition: ticonsts.h:42
DWORD Id
ULONG if_innucastpkts
Definition: tcpioctl.h:116
_In_ NDIS_HANDLE _In_ PNDIS_REQUEST Request
Definition: ndis.h:5173
unsigned int BOOL
Definition: ntddk_ex.h:94
ULONG if_outnucastpkts
Definition: tcpioctl.h:122
ULONG if_outqlen
Definition: tcpioctl.h:125
ULONG if_type
Definition: tcpioctl.h:106
smooth NULL
Definition: ftsmooth.c:416
ULONG if_outoctets
Definition: tcpioctl.h:120
static char * dbg_print_physaddr(const unsigned char *addr, unsigned long addr_len)
Definition: tcp_info.c:54
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
ULONG if_mtu
Definition: tcpioctl.h:107
ULONG if_speed
Definition: tcpioctl.h:108
ULONG if_outdiscards
Definition: tcpioctl.h:123
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define BufferSize
Definition: classpnp.h:419
ULONG if_inerrors
Definition: tcpioctl.h:118
ULONG if_inucastpkts
Definition: tcpioctl.h:115
static ULONG IndentationLevel
Definition: tcp_info.c:50
struct IFEntry IFEntry
ULONG if_inunknownprotos
Definition: tcpioctl.h:119
#define IF_MIB_STATS_ID
Definition: tcpioctl.h:49
ULONG if_adminstatus
Definition: tcpioctl.h:111
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 ok(value,...)
Definition: atltest.h:57
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
#define INFO_TYPE_PROVIDER
Definition: tdiinfo.h:69
#define MAX_ADAPTER_DESCRIPTION_LENGTH
Definition: iinfo.c:16
unsigned int ULONG
Definition: retypes.h:1
#define IF_MIB
Definition: tdiinfo.h:61
static HANDLE TcpFileHandle
Definition: tcp_info.c:48
UCHAR if_physaddr[MAX_PHYSADDR_SIZE]
Definition: tcpioctl.h:110
ULONG if_indiscards
Definition: tcpioctl.h:117
ULONG if_lastchange
Definition: tcpioctl.h:113
#define HeapFree(x, y, z)
Definition: compat.h:394
UCHAR if_descr[1]
Definition: tcpioctl.h:127
#define INFO_CLASS_PROTOCOL
Definition: tdiinfo.h:65

Referenced by START_TEST().

◆ test_IP_MIB_STATS()

static void test_IP_MIB_STATS ( TDIEntityID  Id,
ULONG  EntityType 
)
static

Definition at line 159 of file tcp_info.c.

162 {
163  IPSNMPInfo IpSnmpInfo;
165  ULONG BufferSize = 0;
166  BOOL Result;
167 
168  /* Not valid for other entity types */
169  if (EntityType != CL_NL_IP)
170  return;
171 
172  ZeroMemory(&IpSnmpInfo, sizeof(IpSnmpInfo));
173 
174  ZeroMemory(&Request, sizeof(Request));
175  Request.ID.toi_entity = Id;
176  Request.ID.toi_class = INFO_CLASS_PROTOCOL;
177  Request.ID.toi_type = INFO_TYPE_PROVIDER;
178  Request.ID.toi_id = IP_MIB_STATS_ID;
179 
183  &Request,
184  sizeof(Request),
185  &IpSnmpInfo,
186  sizeof(IpSnmpInfo),
187  &BufferSize,
188  NULL);
189  ok(Result, "DeviceIoControl failed.\n");
190 
191  /* Dump it */
192  indent_printf("IP_MIB Statistics:\n");
194  indent_printf("ipsi_forwarding: %lu\n", IpSnmpInfo.ipsi_forwarding);
195  indent_printf("ipsi_defaultttl: %lu\n", IpSnmpInfo.ipsi_defaultttl);
196  indent_printf("ipsi_inreceives: %lu\n", IpSnmpInfo.ipsi_inreceives);
197  indent_printf("ipsi_inhdrerrors: %lu\n", IpSnmpInfo.ipsi_inhdrerrors);
198  indent_printf("ipsi_inaddrerrors: %lu\n", IpSnmpInfo.ipsi_inaddrerrors);
199  indent_printf("ipsi_forwdatagrams: %lu\n", IpSnmpInfo.ipsi_forwdatagrams);
200  indent_printf("ipsi_inunknownprotos: %lu\n", IpSnmpInfo.ipsi_inunknownprotos);
201  indent_printf("ipsi_indiscards: %lu\n", IpSnmpInfo.ipsi_indiscards);
202  indent_printf("ipsi_indelivers: %lu\n", IpSnmpInfo.ipsi_indelivers);
203  indent_printf("ipsi_outrequests: %lu\n", IpSnmpInfo.ipsi_outrequests);
204  indent_printf("ipsi_routingdiscards: %lu\n", IpSnmpInfo.ipsi_routingdiscards);
205  indent_printf("ipsi_outdiscards: %lu\n", IpSnmpInfo.ipsi_outdiscards);
206  indent_printf("ipsi_outnoroutes: %lu\n", IpSnmpInfo.ipsi_outnoroutes);
207  indent_printf("ipsi_reasmtimeout: %lu\n", IpSnmpInfo.ipsi_reasmtimeout);
208  indent_printf("ipsi_reasmreqds: %lu\n", IpSnmpInfo.ipsi_reasmreqds);
209  indent_printf("ipsi_reasmoks: %lu\n", IpSnmpInfo.ipsi_reasmoks);
210  indent_printf("ipsi_reasmfails: %lu\n", IpSnmpInfo.ipsi_reasmfails);
211  indent_printf("ipsi_fragoks: %lu\n", IpSnmpInfo.ipsi_fragoks);
212  indent_printf("ipsi_fragfails: %lu\n", IpSnmpInfo.ipsi_fragfails);
213  indent_printf("ipsi_fragcreates: %lu\n", IpSnmpInfo.ipsi_fragcreates);
214  indent_printf("ipsi_numif: %lu\n", IpSnmpInfo.ipsi_numif);
215  indent_printf("ipsi_numaddr: %lu\n", IpSnmpInfo.ipsi_numaddr);
216  indent_printf("ipsi_numroutes: %lu\n", IpSnmpInfo.ipsi_numroutes);
217 
218  if (IpSnmpInfo.ipsi_numaddr != 0)
219  {
220  IPAddrEntry* AddrEntries;
221  ULONG i;
222 
223  AddrEntries = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, IpSnmpInfo.ipsi_numaddr * sizeof(AddrEntries[0]));
224  ok(AddrEntries != NULL, "\n");
225 
226  ZeroMemory(&Request, sizeof(Request));
227  Request.ID.toi_entity = Id;
228  Request.ID.toi_class = INFO_CLASS_PROTOCOL;
229  Request.ID.toi_type = INFO_TYPE_PROVIDER;
231 
235  &Request,
236  sizeof(Request),
237  AddrEntries,
238  IpSnmpInfo.ipsi_numaddr * sizeof(AddrEntries[0]),
239  &BufferSize,
240  NULL);
241  ok(Result, "DeviceIoControl failed.\n");
242  ok_long(BufferSize, IpSnmpInfo.ipsi_numaddr * sizeof(AddrEntries[0]));
243 
244  for(i = 0; i < IpSnmpInfo.ipsi_numaddr; i++)
245  {
246  CHAR AddressString[16];
247  struct in_addr Addr;
248 
249  Addr.S_un.S_addr = AddrEntries[i].iae_addr;
250  RtlIpv4AddressToStringA(&Addr, AddressString);
251 
252  indent_printf("Address %lu: %s\n", i, AddressString);
253 
255 
256  indent_printf("iae_addr: %lx\n", AddrEntries[i].iae_addr);
257  indent_printf("iae_index: %lu\n", AddrEntries[i].iae_index);
258  Addr.S_un.S_addr = AddrEntries[i].iae_mask;
259  RtlIpv4AddressToStringA(&Addr, AddressString);
260  indent_printf("iae_mask: %lx (%s)\n", AddrEntries[i].iae_mask, AddressString);
261  indent_printf("iae_bcastaddr: %lu\n", AddrEntries[i].iae_bcastaddr);
262  indent_printf("iae_reasmsize: %lu\n", AddrEntries[i].iae_reasmsize);
263  indent_printf("iae_context: %u\n", AddrEntries[i].iae_context);
264 
265  {
266  IPInterfaceInfo* InterfaceInfo;
267 
268  /* Get the interface info */
271  ok(InterfaceInfo != NULL, "\n");
272 
273  Request.ID.toi_id = IP_INTFC_INFO_ID;
274  Request.Context[0] = AddrEntries[i].iae_addr;
278  &Request,
279  sizeof(Request),
280  InterfaceInfo,
281  BufferSize,
282  &BufferSize,
283  NULL);
284  ok(Result, "DeviceIoControl failed.\n");
285 
286  indent_printf("Interface info:\n");
288 
289  indent_printf("iii_flags: %lu\n", InterfaceInfo->iii_flags);
290  indent_printf("iii_mtu : %lu\n", InterfaceInfo->iii_mtu);
291  indent_printf("iii_speed: %lu\n", InterfaceInfo->iii_speed);
292  indent_printf("iii_physaddr: %s\n", dbg_print_physaddr(InterfaceInfo->iii_addr, InterfaceInfo->iii_addrlength));
293 
295  }
296 
298  }
299 
300  HeapFree(GetProcessHeap(), 0, AddrEntries);
301  }
302 
303  /* See for the routes */
304  if (IpSnmpInfo.ipsi_numroutes)
305  {
306  IPRouteEntry* RouteEntries;
307  ULONG i;
308 
309  RouteEntries = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, IpSnmpInfo.ipsi_numroutes * sizeof(RouteEntries[0]));
310  ok(RouteEntries != NULL, "\n");
311 
312  ZeroMemory(&Request, sizeof(Request));
313  Request.ID.toi_entity = Id;
314  Request.ID.toi_class = INFO_CLASS_PROTOCOL;
315  Request.ID.toi_type = INFO_TYPE_PROVIDER;
316  Request.ID.toi_id = IP_MIB_ARPTABLE_ENTRY_ID;
317 
321  &Request,
322  sizeof(Request),
323  RouteEntries,
324  IpSnmpInfo.ipsi_numroutes * sizeof(RouteEntries[0]),
325  &BufferSize,
326  NULL);
327  ok(Result, "DeviceIoControl failed.\n");
328  ok_long(BufferSize, IpSnmpInfo.ipsi_numroutes * sizeof(RouteEntries[0]));
329 
330  for (i = 0; i < IpSnmpInfo.ipsi_numroutes; i++)
331  {
332  CHAR AddressString[16];
333  struct in_addr Addr;
334 
335  Addr.S_un.S_addr = RouteEntries[i].ire_dest;
336  RtlIpv4AddressToStringA(&Addr, AddressString);
337 
338  indent_printf("Route %lu:\n", i);
339 
341 
342  indent_printf("ire_dest: %s (%lx)\n", AddressString, RouteEntries[i].ire_dest);
343  indent_printf("ire_index: %lu\n", RouteEntries[i].ire_index);
344  indent_printf("ire_metric1: %#lx\n", RouteEntries[i].ire_metric1);
345  indent_printf("ire_metric2: %#lx\n", RouteEntries[i].ire_metric2);
346  indent_printf("ire_metric3: %#lx\n", RouteEntries[i].ire_metric3);
347  indent_printf("ire_metric4: %#lx\n", RouteEntries[i].ire_metric4);
348  Addr.S_un.S_addr = RouteEntries[i].ire_nexthop;
349  RtlIpv4AddressToStringA(&Addr, AddressString);
350  indent_printf("ire_nexthop: %s (%lx)\n", AddressString, RouteEntries[i].ire_nexthop);
351  indent_printf("ire_type: %lu\n", RouteEntries[i].ire_type);
352  indent_printf("ire_proto: %lu\n", RouteEntries[i].ire_proto);
353  indent_printf("ire_age: %lu\n", RouteEntries[i].ire_age);
354  Addr.S_un.S_addr = RouteEntries[i].ire_mask;
355  RtlIpv4AddressToStringA(&Addr, AddressString);
356  indent_printf("ire_mask: %s (%lx)\n", AddressString, RouteEntries[i].ire_mask);
357  indent_printf("ire_metric5: %lx\n", RouteEntries[i].ire_metric5);
358  indent_printf("ire_context: %lx\n", RouteEntries[i].ire_context);
359 
361  }
362  }
363 
365 }
UCHAR iii_addr[1]
Definition: tcpioctl.h:174
ULONG iii_speed
Definition: tcpioctl.h:172
ULONG ipsi_indiscards
Definition: tcpioctl.h:139
ULONG ipsi_inunknownprotos
Definition: tcpioctl.h:138
ULONG ipsi_numaddr
Definition: tcpioctl.h:153
unsigned long ire_dest
Definition: tcp_info.c:24
ULONG ipsi_reasmoks
Definition: tcpioctl.h:147
static int __cdecl indent_printf(const char *format,...)
Definition: tcp_info.c:75
ULONG ipsi_forwarding
Definition: tcpioctl.h:132
char CHAR
Definition: xmlstorage.h:175
ULONG ipsi_forwdatagrams
Definition: tcpioctl.h:137
NTSYSAPI PSTR NTAPI RtlIpv4AddressToStringA(_In_ const struct in_addr *Addr, _Out_writes_(16) PSTR S)
ULONG ipsi_fragcreates
Definition: tcpioctl.h:151
unsigned long ire_nexthop
Definition: tcp_info.c:30
unsigned long ire_mask
Definition: tcp_info.c:34
ULONG ipsi_outrequests
Definition: tcpioctl.h:141
struct IPInterfaceInfo IPInterfaceInfo
#define ZeroMemory
Definition: winbase.h:1635
ULONG ipsi_reasmtimeout
Definition: tcpioctl.h:145
#define IOCTL_TCP_QUERY_INFORMATION_EX
Definition: ticonsts.h:42
#define ok_long(expression, result)
Definition: atltest.h:133
#define CL_NL_IP
Definition: tdiinfo.h:54
ULONG ipsi_numroutes
Definition: tcpioctl.h:154
#define IP_MIB_ARPTABLE_ENTRY_ID
Definition: tcpioctl.h:51
DWORD Id
_In_ NDIS_HANDLE _In_ PNDIS_REQUEST Request
Definition: ndis.h:5173
ULONG ipsi_reasmfails
Definition: tcpioctl.h:148
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
unsigned int BOOL
Definition: ntddk_ex.h:94
ULONG ipsi_reasmreqds
Definition: tcpioctl.h:146
smooth NULL
Definition: ftsmooth.c:416
static char * dbg_print_physaddr(const unsigned char *addr, unsigned long addr_len)
Definition: tcp_info.c:54
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:426
ULONG iii_addrlength
Definition: tcpioctl.h:173
#define IP_MIB_STATS_ID
Definition: afd.h:35
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
ULONG ipsi_numif
Definition: tcpioctl.h:152
ULONG ipsi_inhdrerrors
Definition: tcpioctl.h:135
#define MAX_PHYSADDR_SIZE
Definition: tcpioctl.h:58
Definition: tcpip.h:125
#define BufferSize
Definition: classpnp.h:419
static ULONG IndentationLevel
Definition: tcp_info.c:50
ULONG ipsi_defaultttl
Definition: tcpioctl.h:133
ULONG ipsi_routingdiscards
Definition: tcpioctl.h:142
ULONG iae_mask
Definition: tcpioctl.h:161
ULONG iae_addr
Definition: tcpioctl.h:159
ULONG ipsi_outdiscards
Definition: tcpioctl.h:143
u_long S_addr
Definition: tcpip.h:131
ULONG ipsi_fragfails
Definition: tcpioctl.h:150
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
ULONG ipsi_fragoks
Definition: tcpioctl.h:149
#define ok(value,...)
Definition: atltest.h:57
ULONG ipsi_outnoroutes
Definition: tcpioctl.h:144
ULONG iii_flags
Definition: tcpioctl.h:170
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
ULONG ipsi_inaddrerrors
Definition: tcpioctl.h:136
#define INFO_TYPE_PROVIDER
Definition: tdiinfo.h:69
ULONG ipsi_inreceives
Definition: tcpioctl.h:134
unsigned int ULONG
Definition: retypes.h:1
union in_addr::@990 S_un
static HANDLE TcpFileHandle
Definition: tcp_info.c:48
#define IP_INTFC_INFO_ID
Definition: tcpioctl.h:53
#define IP_MIB_ADDRTABLE_ENTRY_ID
Definition: afd.h:36
ULONG ipsi_indelivers
Definition: tcpioctl.h:140
#define HeapFree(x, y, z)
Definition: compat.h:394
#define INFO_CLASS_PROTOCOL
Definition: tdiinfo.h:65

Referenced by START_TEST().

Variable Documentation

◆ IndentationLevel

ULONG IndentationLevel = 0
static

Definition at line 50 of file tcp_info.c.

Referenced by indent_printf(), test_AT_ARP_STATS(), test_IF_MIB_STATS(), and test_IP_MIB_STATS().

◆ TcpFileHandle

HANDLE TcpFileHandle
static

Definition at line 48 of file tcp_info.c.

Referenced by START_TEST(), test_AT_ARP_STATS(), test_IF_MIB_STATS(), and test_IP_MIB_STATS().