ReactOS  0.4.14-dev-52-g6116262
iptest.cpp File Reference
#include <iostream>
#include <list>
#include <string>
#include <sstream>
#include <stdio.h>
#include <windows.h>
#include <winsock2.h>
#include <ddk/tdi.h>
#include <ddk/tdikrnl.h>
#include <ddk/tdiinfo.h>
#include <ddk/ndis.h>
#include <titypes.h>
#include <ip.h>
#include <tcp.h>
#include <receive.h>
#include <lan.h>
#include <routines.h>
Include dependency graph for iptest.cpp:

Go to the source code of this file.

Classes

class  SocketObject
 
class  TCPSocketObject
 

Macros

#define MAX_DG_SIZE   16384
 
#define STRINGIFY(x)   #x
 

Typedefs

typedef unsigned short u_short
 

Functions

VOID ExpInitLookasideLists ()
 
void display_row (char *data, int off, int len)
 
void connect_complete (void *context, NTSTATUS status, unsigned long count)
 
void receive_complete (void *context, NTSTATUS status, unsigned long count)
 
UINT TdiAddressSizeFromType (UINT AddressType)
 
NTSTATUS TdiBuildNullConnectionInfoInPlace (PTDI_CONNECTION_INFORMATION ConnInfo, ULONG Type)
 
NTSTATUS TdiBuildNullConnectionInfo (PTDI_CONNECTION_INFORMATION *ConnectionInfo, ULONG Type)
 
UINT TaLengthOfTransportAddress (PTRANSPORT_ADDRESS Addr)
 
NTSTATUS TdiBuildConnectionInfoInPlace (PTDI_CONNECTION_INFORMATION ConnectionInfo, PTA_ADDRESS Address)
 
NTSTATUS TdiBuildConnectionInfo (PTDI_CONNECTION_INFORMATION *ConnectionInfo, PTA_ADDRESS Address)
 
VOID SendPacket (PVOID Context, PNDIS_PACKET NdisPacket, UINT Offset, PVOID LinkAddress, USHORT Type)
 
int main (int argc, char **argv)
 

Variables

std::list< std::stringoutput_packets
 
DWORD DebugTraceLevel = 0x7fffffff
 
PVOID GlobalBufferPool
 
PVOID GlobalPacketPool
 
char hwaddr [6] = { 0x08, 0x00, 0x20, 0x0b, 0xb7, 0xbb }
 
char hdr [14]
 

Macro Definition Documentation

◆ MAX_DG_SIZE

#define MAX_DG_SIZE   16384

Definition at line 29 of file iptest.cpp.

◆ STRINGIFY

#define STRINGIFY (   x)    #x

Definition at line 37 of file iptest.cpp.

Typedef Documentation

◆ u_short

typedef unsigned short u_short

Definition at line 6 of file iptest.cpp.

Function Documentation

◆ connect_complete()

void connect_complete ( void context,
NTSTATUS  status,
unsigned long  count 
)

Definition at line 56 of file iptest.cpp.

56  {
57  printf( "Connection: status %x\n", status );
58 }
#define printf
Definition: config.h:203
Definition: ps.c:97

Referenced by TCPSocketObject::TCPSocketObject().

◆ display_row()

void display_row ( char data,
int  off,
int  len 
)

Definition at line 39 of file iptest.cpp.

39  {
40  int i;
41 
42  printf( "%08x:", off );
43  for( i = off; i < len && i < off + 16; i++ ) {
44  printf( " %02x", data[i] & 0xff );
45  }
46 
47  printf( " -- " );
48 
49  for( i = off; i < len && i < off + 16; i++ ) {
50  printf( "%c", (data[i] >= ' ') ? data[i] : '.' );
51  }
52 
53  printf( "\n" );
54 }
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
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLenum GLsizei len
Definition: glext.h:6722
#define printf
Definition: config.h:203
off
Definition: i386-dis.c:3909

Referenced by receive_complete(), and SendPacket().

◆ ExpInitLookasideLists()

VOID ExpInitLookasideLists ( )

Referenced by ExpInitSystemPhase0(), and main().

◆ main()

int main ( int argc  ,
char **  argv 
)

Definition at line 282 of file iptest.cpp.

282  {
283  int asock = INVALID_SOCKET, selret, dgrecv, fromsize, err, port = 5001;
284  int bytes, adapter_id, mtu, speed;
285  char datagram[MAX_DG_SIZE];
286  struct fd_set readf;
287  struct timeval tv;
288  struct sockaddr_in addr_from = { AF_INET }, addr_to;
289  std::string word, cmdin, host;
290  std::list<std::string>::iterator i;
291  WSADATA wsadata;
293  UNICODE_STRING RegistryUnicodePath;
294  PCONNECTION_ENDPOINT Connection;
296  IP_PACKET IPPacket;
297  LLIP_BIND_INFO BindInfo;
298  SocketObject *S = NULL;
299 
301  ( &RegistryUnicodePath,
302  L"\\SYSTEM\\CurrentControlSet\\Services"
303  L"\\Tcpip" );
304 
306 
307  WSAStartup( 0x101, &wsadata );
308 
309  if( argc > 1 ) port = atoi(argv[1]);
310 
311  IPStartup( &RegistryUnicodePath );
312 
313  BindInfo.Context = NULL;
314  BindInfo.HeaderSize = sizeof(ETH_HEADER);
315  BindInfo.MTU = 1500; /* MTU for ethernet */
316  BindInfo.Address = (PUCHAR)hwaddr;
317  BindInfo.AddressLength = sizeof(hwaddr);
318  BindInfo.Transmit = SendPacket;
319 
320  IPCreateInterface( &BindInfo );
321 
322  asock = socket( AF_INET, SOCK_DGRAM, 0 );
323 
324  addr_from.sin_port = htons( port );
325 
326  if( bind( asock, (struct sockaddr *)&addr_from, sizeof( addr_from ) ) ) {
327  printf( "Bind error\n" );
328  return 0;
329  }
330 
331  while( true ) {
332  FD_ZERO( &readf );
333  FD_SET( asock, &readf );
334  tv.tv_sec = 0;
335  tv.tv_usec = 10000;
336  selret = select( asock + 1, &readf, NULL, NULL, &tv );
337 
338  if( FD_ISSET( asock, &readf ) ) {
339  fromsize = sizeof( addr_from );
340  dgrecv = recvfrom( asock, datagram, sizeof(datagram), 0,
341  (struct sockaddr *)&addr_from, &fromsize );
342 
343  if( datagram[0] == 'C' && datagram[1] == 'M' &&
344  datagram[2] == 'D' && datagram[3] == ' ' ) {
345  int theport, bytes, recvret, off, bytin;
346  struct sockaddr_in nam;
347  std::string faddr, word;
349  cmdin( std::string( datagram + 4, dgrecv - 4 ) );
350 
351  cmdin >> word;
352 
353 /* UDP Section */
354  if( word == "udpsocket" ) {
355 /* TCP Section */
356  } else if( word == "tcpsocket" ) {
357  cmdin >> host >> port;
358  S = new TCPSocketObject( host, port, &Status );
359  fprintf( stderr, "Socket: Result %x\n", Status );
360  } else if( word == "close" ) {
361  TCPClose( Connection );
362  TCPFreeConnectionEndpoint( Connection );
363  } else if( word == "type" ) {
364  std::string therest = &cmdin.str()[word.size()];
365  char* p = &therest[0];
366  p += strspn ( p, " \t" );
367  char* src = p;
368  char* dst = p;
369  while ( *src )
370  {
371  char c = *src++;
372  if ( c == '\r' || c == '\n' ) break;
373  if ( c == '\\' )
374  {
375  c = *src++;
376  switch ( c )
377  {
378  case 'b': c = '\b'; break;
379  case 'n': c = '\n'; break;
380  case 'r': c = '\r'; break;
381  case 't': c = '\t'; break;
382  case 'v': c = '\v'; break;
383  }
384  }
385  *dst++ = c;
386  }
387  *dst = '\0';
388  if( S )
389  err = S->send( p, strlen(p), &bytes, NULL );
390  if( err > 0 ) { bytin = err; err = 0; }
391 
392  if( err )
393  fprintf ( stderr, "OskitTCPConnect: error %d\n",
394  err );
395  else {
396  printf ( "wrote %d bytes\n", bytin );
397  }
398  } else if( word == "send" ) {
399  off = 0;
400  while( cmdin >> word ) {
401  datagram[off++] =
402  atoi( (std::string("0x") + word).c_str() );
403  }
404 
405  if( (err = S->send( datagram, off, &bytin, NULL )) != 0 ) {
406  fprintf( stderr, "OskitTCPConnect: error %d\n", err );
407  } else {
408  printf( "wrote %d bytes\n", bytin );
409  }
410  } else if( word == "recv" ) {
411  cmdin >> bytes;
412 
413  if( (err = S->recv( datagram,
414  sizeof(datagram),
415  &bytes,
416  NULL )) != 0 ) {
417  fprintf( stderr, "OskitTCPRecv: error %d\n", err );
418  }
419 
420 /* Misc section */
421  } else if( word == "end" ) {
422  return 0;
423  }
424  } else if( dgrecv > 14 ) {
425  addr_to = addr_from;
426 
427  if( datagram[12] == 8 && datagram[13] == 6 ) {
428  /* Answer arp query */
429  char laddr[4];
430  /* Mark patch as to the previous sender */
431  memcpy( datagram + 32, datagram + 6, 6 );
432  memcpy( datagram, datagram + 6, 6 );
433  /* Mark packet as from us */
434  memcpy( datagram + 22, hwaddr, 6 );
435  memcpy( datagram + 6, hwaddr, 6 );
436  /* Swap inet addresses */
437  memcpy( laddr, datagram + 28, 4 );
438  memcpy( datagram + 28, datagram + 38, 4 );
439  memcpy( datagram + 38, laddr, 4 );
440  /* Set reply opcode */
441  datagram[21] = 2;
442 
443  err = sendto( asock, datagram, dgrecv, 0,
444  (struct sockaddr *)&addr_to,
445  sizeof(addr_to) );
446 
447  if( err != 0 )
448  printf( "sendto: %d\n", err );
449  } else {
450  memcpy( hdr, datagram + 6, 6 );
451  memcpy( hdr + 6, datagram, 6 );
452  memcpy( hdr + 12, datagram + 12, 2 );
453  IPPacket.Header = datagram;
454  IPPacket.Data = datagram + 14;
455  IPPacket.TotalSize = dgrecv;
456  IPReceive( Interface, &IPPacket );
457  }
458  }
459  }
460 
461  IPTimeout(NULL, NULL, NULL, NULL);
462 
463  for( i = output_packets.begin(); i != output_packets.end(); i++ ) {
464  err = sendto( asock, i->c_str(), i->size(), 0,
465  (struct sockaddr *)&addr_to, sizeof(addr_to) );
466 
467  fprintf( stderr, "** SENDING PACKET %d bytes **\n", i->size() );
468 
469  if( err != 0 )
470  printf( "sendto: %d\n", err );
471  }
472 
473  output_packets.clear();
474  }
475 }
Definition: winsock.h:66
INT WSAAPI recvfrom(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags, OUT LPSOCKADDR from, IN OUT INT FAR *fromlen)
Definition: recv.c:87
UINT AddressLength
Definition: ip.h:131
static int argc
Definition: ServiceArgs.c:12
char hdr[14]
Definition: iptest.cpp:33
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
u_short sin_port
Definition: winsock.h:511
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
Definition: socklife.c:36
unsigned char * PUCHAR
Definition: retypes.h:3
char * host
Definition: whois.c:55
PVOID Context
Definition: ip.h:127
LONG NTSTATUS
Definition: precomp.h:26
_Check_return_ _CRTIMP size_t __cdecl strspn(_In_z_ const char *_Str, _In_z_ const char *_Control)
PIP_INTERFACE IPCreateInterface(PLLIP_BIND_INFO BindInfo)
Definition: ip.c:182
Definition: movable.cpp:7
#define FD_ZERO(set)
Definition: winsock.h:96
#define argv
Definition: mplay32.c:18
#define FD_SET(fd, set)
Definition: winsock.h:89
PUCHAR Address
Definition: ip.h:130
LL_TRANSMIT_ROUTINE Transmit
Definition: ip.h:132
PVOID Data
Definition: ip.h:85
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
NTSTATUS TCPClose(PCONNECTION_ENDPOINT Connection)
Definition: tcp.c:150
static unsigned char bytes[4]
Definition: adnsresfilter.c:74
#define FD_ISSET(fd, set)
Definition: winsock.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
INT WSAAPI select(IN INT s, IN OUT LPFD_SET readfds, IN OUT LPFD_SET writefds, IN OUT LPFD_SET exceptfds, IN CONST struct timeval *timeout)
Definition: select.c:41
char hwaddr[6]
Definition: iptest.cpp:31
PVOID Header
Definition: ip.h:83
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
Definition: startup.c:113
smooth NULL
Definition: ftsmooth.c:416
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
Definition: pci.h:359
#define INVALID_SOCKET
Definition: winsock.h:332
struct _ETH_HEADER ETH_HEADER
UINT HeaderSize
Definition: ip.h:128
UINT TotalSize
Definition: ip.h:86
const GLubyte * c
Definition: glext.h:8905
#define MAX_DG_SIZE
Definition: iptest.cpp:29
VOID ExpInitLookasideLists()
static const WCHAR L[]
Definition: oid.c:1250
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum src
Definition: glext.h:6340
#define err(...)
char string[160]
Definition: util.h:11
Status
Definition: gdiplustypes.h:24
basic_istringstream< char, char_traits< char >, allocator< char > > istringstream
Definition: _iosfwd.h:126
NTSTATUS IPStartup(PUNICODE_STRING RegistryPath)
Definition: ip.c:411
std::list< std::string > output_packets
Definition: iptest.cpp:25
VOID IPReceive(PIP_INTERFACE IF, PIP_PACKET IPPacket)
Definition: receive.c:638
GLenum GLenum dst
Definition: glext.h:6340
const WCHAR * word
Definition: lex.c:78
INT WSAAPI sendto(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags, IN CONST struct sockaddr *to, IN INT tolen)
Definition: send.c:82
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
#define c
Definition: ke_i.h:80
FILE * stderr
#define AF_INET
Definition: tcpip.h:117
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
Definition: ip.h:77
VOID TCPFreeConnectionEndpoint(PCONNECTION_ENDPOINT Connection)
GLfloat GLfloat p
Definition: glext.h:8902
#define htons(x)
Definition: module.h:213
#define SOCK_DGRAM
Definition: winsock.h:336
USHORT port
Definition: uri.c:227
#define printf
Definition: config.h:203
off
Definition: i386-dis.c:3909
VOID SendPacket(PVOID Context, PNDIS_PACKET NdisPacket, UINT Offset, PVOID LinkAddress, USHORT Type)
Definition: iptest.cpp:247

◆ receive_complete()

void receive_complete ( void context,
NTSTATUS  status,
unsigned long  count 
)

Definition at line 60 of file iptest.cpp.

60  {
61  printf( "Receive: status %s (bytes %d)\n", status, count );
62  if( !status && count ) {
63  for( int off = 0; off < count; off += 16 ) {
64  display_row( (char *)context, off, count );
65  }
66  printf( "\n" );
67  }
68 }
Definition: http.c:6587
GLuint GLuint GLsizei count
Definition: gl.h:1545
void display_row(char *data, int off, int len)
Definition: iptest.cpp:39
#define printf
Definition: config.h:203
off
Definition: i386-dis.c:3909
Definition: ps.c:97

◆ SendPacket()

VOID SendPacket ( PVOID  Context,
PNDIS_PACKET  NdisPacket,
UINT  Offset,
PVOID  LinkAddress,
USHORT  Type 
)

Definition at line 247 of file iptest.cpp.

251  {
252  PCHAR DataOut;
253  PUCHAR Addr = (PUCHAR)LinkAddress;
254  UINT Size;
255  std::string output_packet;
256 
257  printf( "Sending packet: %02x:%02x:%02x:%02x:%02x:%02x\n",
258  Addr[0], Addr[1], Addr[2], Addr[3], Addr[4], Addr[5] );
259 
260  GetDataPtr( NdisPacket, Offset, &DataOut, &Size );
261  for( int off = 0; off < Size; off += 16 ) {
262  display_row( DataOut, off, Size );
263  }
264  printf( "\n" );
265 
266  output_packet += std::string( hwaddr, sizeof(hwaddr) );
267  output_packet += std::string( (char *)LinkAddress, sizeof(hwaddr) );
268  output_packet += (char)(Type >> 8);
269  output_packet += (char)Type;
270  output_packet += std::string( DataOut + Offset, Size - Offset );
271 
272  output_packets.push_back( output_packet );
273 }
signed char * PCHAR
Definition: retypes.h:7
Type
Definition: Type.h:6
void GetDataPtr(PNDIS_PACKET Packet, UINT Offset, PCHAR *DataOut, PUINT Size)
Definition: routines.c:65
unsigned char * PUCHAR
Definition: retypes.h:3
void display_row(char *data, int off, int len)
Definition: iptest.cpp:39
_In_ ULONG _In_ ULONG Offset
Definition: ntddpcm.h:101
char hwaddr[6]
Definition: iptest.cpp:31
unsigned char
Definition: typeof.h:29
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
char string[160]
Definition: util.h:11
std::list< std::string > output_packets
Definition: iptest.cpp:25
unsigned int UINT
Definition: ndis.h:50
#define printf
Definition: config.h:203
off
Definition: i386-dis.c:3909

Referenced by main().

◆ TaLengthOfTransportAddress()

UINT TaLengthOfTransportAddress ( PTRANSPORT_ADDRESS  Addr)

Definition at line 156 of file iptest.cpp.

156  {
157  UINT AddrLen = 2 * sizeof( ULONG ) + Addr->Address[0].AddressLength;
158  printf("AddrLen %x\n", AddrLen);
159  return AddrLen;
160 }
TA_ADDRESS Address[1]
Definition: tdi.h:377
unsigned int UINT
Definition: ndis.h:50
USHORT AddressLength
Definition: tdi.h:338
unsigned int ULONG
Definition: retypes.h:1
#define printf
Definition: config.h:203

◆ TdiAddressSizeFromType()

UINT TdiAddressSizeFromType ( UINT  AddressType)

Definition at line 79 of file iptest.cpp.

79  {
80  switch( AddressType ) {
82  return sizeof(TA_IP_ADDRESS);
83  default:
84  KeBugCheck( 0 );
85  }
86  return 0;
87 }
VOID NTAPI KeBugCheck(ULONG BugCheckCode)
Definition: bug.c:1507
struct _TA_ADDRESS_IP TA_IP_ADDRESS
#define TDI_ADDRESS_TYPE_IP
Definition: tdi.h:345

Referenced by TdiBuildNullConnectionInfo(), and TdiBuildNullConnectionInfoInPlace().

◆ TdiBuildConnectionInfo()

NTSTATUS TdiBuildConnectionInfo ( PTDI_CONNECTION_INFORMATION ConnectionInfo,
PTA_ADDRESS  Address 
)

Definition at line 177 of file iptest.cpp.

178  {
179  NTSTATUS Status = TdiBuildNullConnectionInfo( ConnectionInfo,
180  Address->AddressType );
181 
182  if( NT_SUCCESS(Status) )
183  TdiBuildConnectionInfoInPlace( *ConnectionInfo, Address );
184 
185  return Status;
186 }
NTSTATUS TdiBuildNullConnectionInfo(PTDI_CONNECTION_INFORMATION *ConnectionInfo, ULONG Type)
Definition: iptest.cpp:117
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS TdiBuildConnectionInfoInPlace(PTDI_CONNECTION_INFORMATION ConnectionInfo, PTA_ADDRESS Address)
Definition: iptest.cpp:164
static WCHAR Address[46]
Definition: ping.c:68
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
Status
Definition: gdiplustypes.h:24

Referenced by TCPSocketObject::TCPSocketObject().

◆ TdiBuildConnectionInfoInPlace()

NTSTATUS TdiBuildConnectionInfoInPlace ( PTDI_CONNECTION_INFORMATION  ConnectionInfo,
PTA_ADDRESS  Address 
)

Definition at line 164 of file iptest.cpp.

165  {
167 
168  RtlCopyMemory( ConnectionInfo->RemoteAddress,
169  Address,
170  ConnectionInfo->RemoteAddressLength );
171 
172  return Status;
173 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
LONG NTSTATUS
Definition: precomp.h:26
static WCHAR Address[46]
Definition: ping.c:68
Status
Definition: gdiplustypes.h:24
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by TdiBuildConnectionInfo().

◆ TdiBuildNullConnectionInfo()

NTSTATUS TdiBuildNullConnectionInfo ( PTDI_CONNECTION_INFORMATION ConnectionInfo,
ULONG  Type 
)

Definition at line 117 of file iptest.cpp.

128 {
130  ULONG TdiAddressSize;
132 
133  TdiAddressSize = TdiAddressSizeFromType(Type);
134 
135  ConnInfo = (PTDI_CONNECTION_INFORMATION)
138  TdiAddressSize);
139  if (!ConnInfo)
141 
143 
144  if (!NT_SUCCESS(Status))
145  ExFreePool( ConnInfo );
146  else
147  *ConnectionInfo = ConnInfo;
148 
149  ConnInfo->RemoteAddress = (PTA_ADDRESS)&ConnInfo[1];
150  ConnInfo->RemoteAddressLength = TdiAddressSize;
151 
152  return Status;
153 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
Type
Definition: Type.h:6
LONG NTSTATUS
Definition: precomp.h:26
UINT TdiAddressSizeFromType(UINT AddressType)
Definition: iptest.cpp:79
struct _TA_ADDRESS * PTA_ADDRESS
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct _TDI_CONNECTION_INFORMATION * PTDI_CONNECTION_INFORMATION
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
NTSTATUS TdiBuildNullConnectionInfoInPlace(PTDI_CONNECTION_INFORMATION ConnInfo, ULONG Type)
Definition: iptest.cpp:90
Status
Definition: gdiplustypes.h:24
unsigned int ULONG
Definition: retypes.h:1
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by TdiBuildConnectionInfo().

◆ TdiBuildNullConnectionInfoInPlace()

NTSTATUS TdiBuildNullConnectionInfoInPlace ( PTDI_CONNECTION_INFORMATION  ConnInfo,
ULONG  Type 
)

Definition at line 90 of file iptest.cpp.

100 {
101  ULONG TdiAddressSize;
102 
103  TdiAddressSize = TdiAddressSizeFromType(Type);
104 
105  RtlZeroMemory(ConnInfo,
107  TdiAddressSize);
108 
109  ConnInfo->OptionsLength = sizeof(ULONG);
110  ConnInfo->RemoteAddressLength = 0;
111  ConnInfo->RemoteAddress = NULL;
112 
113  return STATUS_SUCCESS;
114 }
Type
Definition: Type.h:6
UINT TdiAddressSizeFromType(UINT AddressType)
Definition: iptest.cpp:79
smooth NULL
Definition: ftsmooth.c:416
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
return STATUS_SUCCESS
Definition: btrfs.c:2966

Referenced by TdiBuildNullConnectionInfo().

Variable Documentation

◆ DebugTraceLevel

DWORD DebugTraceLevel = 0x7fffffff

Definition at line 26 of file iptest.cpp.

◆ GlobalBufferPool

PVOID GlobalBufferPool

Definition at line 27 of file iptest.cpp.

◆ GlobalPacketPool

PVOID GlobalPacketPool

Definition at line 27 of file iptest.cpp.

◆ hdr

char hdr[14]
Initial value:
= { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x08, 0x00 }

Definition at line 33 of file iptest.cpp.

Referenced by addref_object(), AdvProcDetailsDlgProc(), AdvProcDriverDlgProc(), AdvPropGeneralDlgProc(), alloc_async_task(), alloc_handle(), APPINFO_Destroy(), APPINFO_QueryOption(), APPINFO_SetOption(), async_exec_query(), async_read_file_proc(), AsyncFtpCreateDirectoryProc(), AsyncFtpDeleteFileProc(), AsyncFtpFindFirstFileProc(), AsyncFtpGetCurrentDirectoryProc(), AsyncFtpGetFileProc(), AsyncFtpOpenFileProc(), AsyncFtpPutFileProc(), AsyncFtpRemoveDirectoryProc(), AsyncFtpRenameFileProc(), AsyncFtpSetCurrentDirectoryProc(), AsyncHttpEndRequestProc(), AsyncHttpSendRequestProc(), AsyncInternetOpenUrlProc(), cert_mgr_advanced_dlg_proc(), cert_mgr_dlg_proc(), cert_properties_general_dlg_proc(), chmc_pmgl_add(), codeview_process_info(), COMBOEX_ComboWndProc(), COMBOEX_Notify(), COMBOEX_NotifyItem(), ComboExTestOnNotify(), connect_destroy(), connect_query_option(), create_dib(), create_storage_from_def(), CRYPT_AsnDecodeRsaPrivKey(), CRYPT_AsnDecodeRsaPubKey(), CRYPT_AsnEncodeRsaPubKey(), CRYPT_findPropID(), CRYPT_ReadContextProp(), CRYPT_ReadSerializedElement(), CRYPT_SerializeStoreElement(), CryptSIPRetrieveSubjectGuid(), EMFDRV_CreatePalette(), EventDetailsCtrl(), export_file_dlg_proc(), export_finish_dlg_proc(), export_format_dlg_proc(), export_password_dlg_proc(), export_private_key_dlg_proc(), export_welcome_dlg_proc(), findPropID(), free_handle(), FTP_SendCommand(), FTP_SendCommandA(), FTPFILE_Destroy(), FTPFILE_LockRequestFile(), FTPFILE_QueryDataAvailable(), FTPFILE_QueryOption(), FTPFILE_ReadFile(), FTPFILE_WriteFile(), FTPFINDNEXT_AsyncFindNextFileProc(), FTPFINDNEXT_Destroy(), FTPFINDNEXT_FindNextFileW(), FTPFINDNEXT_QueryOption(), FTPSESSION_CloseConnection(), FTPSESSION_Destroy(), FTPSESSION_QueryOption(), getICMPStats(), grab_object(), GroupGeneralPageProc(), HeaderTestWndProc(), hierarchy_dlg_proc(), HTTP_ProcessHeader(), HTTPREQ_CloseConnection(), HTTPREQ_Destroy(), HTTPREQ_LockRequestFile(), HTTPREQ_QueryDataAvailable(), HTTPREQ_QueryOption(), HTTPREQ_ReadFile(), HTTPREQ_SetOption(), HTTPREQ_WriteFile(), HTTPSESSION_Destroy(), HTTPSESSION_QueryOption(), HTTPSESSION_SetOption(), I_RpcReceive(), I_RpcSend(), iewnd_OnNotify(), ImageAddCertificate(), ImageEnumerateCertificates(), IMAGEHLP_GetSectionOffset(), IMAGEHLP_ReportCodeSections(), IMAGEHLP_ReportImportSection(), import_file_dlg_proc(), import_finish_dlg_proc(), import_store_dlg_proc(), import_welcome_dlg_proc(), INET_QueryOption(), INTERNET_SendCallback(), InternetFindNextFileW(), InternetLockRequestFile(), InternetQueryDataAvailable(), InternetQueryOptionA(), InternetQueryOptionW(), InternetReadFile(), InternetReadFileExA(), InternetReadFileExW(), IPersistStream_fnLoad(), IPersistStream_fnSave(), LISTVIEW_MouseHover(), LISTVIEW_MouseMove(), main(), match_profile(), modMessage(), module_find_cb(), MONTHCAL_Notify(), MsiSIPGetSignedDataMsg(), nav_page_proc(), OLEPictureImpl_LoadEnhMetafile(), CLayerUIPropPage::OnClickNotify(), CSysPagerWnd::OnCustomDraw(), CSysPagerWnd::OnGetInfoTip(), CTrayNotifyWnd::OnRealign(), CNotifyToolbar::OnTooltipShow(), CAddressEditBox::OnWinEvent(), CMenuToolbarBase::OnWinEvent(), parent_wnd_notify(), parent_wnd_proc(), pe_load_dbg_file(), process_bind_packet(), process_bind_packet_no_send(), process_header(), process_request_packet(), PropertyStorage_MakeHeader(), PropertyStorage_MakeSectionHdr(), PropertyStorage_ReadFromStream(), PropertyStorage_ReadHeaderFromStream(), PropertyStorage_ReadSectionHeaderFromStream(), PropertyStorage_WriteHeadersToStream(), query_option(), release_object(), request_destroy(), request_query_option(), request_set_option(), RpcAssoc_BindConnection(), rpcrt4_conn_secure_packet(), RPCRT4_default_secure_packet(), rpcrt4_http_prepare_in_pipe(), rpcrt4_http_prepare_out_pipe(), rpcrt4_http_read_http_packet(), RPCRT4_io_thread(), RPCRT4_IsValidHttpPacket(), rpcrt4_ncacn_http_receive_fragment(), RPCRT4_process_packet(), RPCRT4_ValidateCommonHeader(), select_cert_dlg_proc(), send_callback(), send_notify(), session_destroy(), session_query_option(), session_set_option(), set_option(), show_cert_dialog(), show_edit_cert_properties_dialog(), show_export_ui(), show_import_ui(), test_convert(), test_data_cache_save(), test_decodeRsaPrivateKey(), test_decodeRsaPublicKey(), test_encodeRsaPublicKey(), test_fragmentsize(), test_header_proc(), test_ip_pktinfo(), test_notify_parent_proc(), test_notify_proc(), test_prepareheader(), testAddSerialized(), testRegStore(), TOOLBAR_Cust_AddButton(), TOOLBAR_Cust_MoveButton(), TOOLBAR_Cust_RemoveButton(), TOOLBAR_LButtonUp(), TOOLBAR_Restore(), TOOLTIPS_Hide(), TOOLTIPS_Show(), TOOLTIPS_TrackHide(), TREEVIEW_SendRealNotify(), TREEVIEW_SendSimpleNotify(), UserGeneralPageProc(), UserMembershipPageProc(), UserProfilePageProc(), WinHttpCloseHandle(), WinHttpGetDefaultProxyConfiguration(), WinHttpGetIEProxyConfigForCurrentUser(), WinHttpQueryOption(), WinHttpSetDefaultProxyConfiguration(), WinHttpSetOption(), WinHttpSetStatusCallback(), WinHttpSetTimeouts(), and WndProc().

◆ hwaddr

char hwaddr[6] = { 0x08, 0x00, 0x20, 0x0b, 0xb7, 0xbb }

Definition at line 31 of file iptest.cpp.

Referenced by main(), and SendPacket().

◆ output_packets

std::list<std::string> output_packets

Definition at line 25 of file iptest.cpp.

Referenced by main(), and SendPacket().