ReactOS  0.4.14-dev-358-gbef841c
tcptest.cpp File Reference
#include <list>
#include <string>
#include <sstream>
#include <malloc.h>
#include <stdio.h>
#include <oskittcp.h>
#include <windows.h>
#include <winsock2.h>
Include dependency graph for tcptest.cpp:

Go to the source code of this file.

Classes

struct  _CONNECTION_ENDPOINT
 

Macros

#define MAX_DG_SIZE   0x10000
 
#define TI_DbgPrint(x, y)   printf y
 
#define STRINGIFY(x)   #x
 

Typedefs

typedef unsigned short u_short
 
typedef struct _CONNECTION_ENDPOINT CONNECTION_ENDPOINT
 
typedef struct _CONNECTION_ENDPOINTPCONNECTION_ENDPOINT
 

Functions

int is_stack_ptr (const void *p)
 
int TCPSocketState (void *ClientData, void *WhichSocket, void *WhichConnection, OSK_UINT NewState)
 
int TCPPacketSend (void *ClientData, OSK_PCHAR data, OSK_UINT len)
 
struct ifaddr * TCPFindInterface (void *ClientData, OSK_UINT AddrType, OSK_UINT FindType, struct sockaddr *ReqAddr)
 
voidTCPMalloc (void *ClientData, OSK_UINT Bytes, OSK_PCHAR File, OSK_UINT Line)
 
void TCPFree (void *ClientData, void *data, OSK_PCHAR File, OSK_UINT Line)
 
int TCPSleep (void *ClientData, void *token, int priority, char *msg, int tmio)
 
void TCPWakeup (void *ClientData, void *token)
 
void display_row (char *data, int off, int len)
 
int main (int argc, char **argv)
 

Variables

unsigned char hwaddr [6] = { 0x08, 0x00, 0x20, 0x0b, 0xb7, 0xbb }
 
unsigned long TCP_IPIdentification
 
std::list< std::stringoutput_packets
 
char hdr [14]
 
OSKITTCP_EVENT_HANDLERS EventHandlers
 

Macro Definition Documentation

◆ MAX_DG_SIZE

#define MAX_DG_SIZE   0x10000

Definition at line 26 of file tcptest.cpp.

◆ STRINGIFY

#define STRINGIFY (   x)    #x

Definition at line 65 of file tcptest.cpp.

◆ TI_DbgPrint

#define TI_DbgPrint (   x,
  y 
)    printf y

Definition at line 27 of file tcptest.cpp.

Typedef Documentation

◆ CONNECTION_ENDPOINT

◆ PCONNECTION_ENDPOINT

◆ u_short

typedef unsigned short u_short

Definition at line 10 of file tcptest.cpp.

Function Documentation

◆ display_row()

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

Definition at line 176 of file tcptest.cpp.

176  {
177  int i;
178 
179  printf( "%08x:", off );
180  for( i = off; i < len && i < off + 16; i++ ) {
181  printf( " %02x", data[i] & 0xff );
182  }
183 
184  printf( " -- " );
185 
186  for( i = off; i < len && i < off + 16; i++ ) {
187  printf( "%c", (data[i] >= ' ') ? data[i] : '.' );
188  }
189 
190  printf( "\n" );
191 }
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 main().

◆ is_stack_ptr()

int is_stack_ptr ( const void p)

Definition at line 35 of file tcptest.cpp.

36 {
37  MEMORY_BASIC_INFORMATION mbi1, mbi2;
38  VirtualQuery ( p, &mbi1, sizeof(mbi1) );
39  VirtualQuery ( _alloca(1), &mbi2, sizeof(mbi2) );
40  return mbi1.AllocationBase == mbi2.AllocationBase;
41 }
SIZE_T NTAPI VirtualQuery(IN LPCVOID lpAddress, OUT PMEMORY_BASIC_INFORMATION lpBuffer, IN SIZE_T dwLength)
Definition: virtmem.c:220
GLfloat GLfloat p
Definition: glext.h:8902

◆ main()

int main ( int argc  ,
char **  argv 
)

Definition at line 193 of file tcptest.cpp.

193  {
194  int asock = INVALID_SOCKET, selret, dgrecv, fromsize, err, port = 5001;
195  char datagram[MAX_DG_SIZE];
196  void *conn = 0;
197  struct fd_set readf;
198  struct timeval tv;
199  struct sockaddr_in addr_from = { AF_INET }, addr_to = { AF_INET };
200  std::list<std::string>::iterator i;
201  WSADATA wsadata;
202 
203  WSAStartup( 0x101, &wsadata );
204 
205  if( argc > 1 ) port = atoi(argv[1]);
206 
207  RegisterOskitTCPEventHandlers( &EventHandlers );
208  InitOskitTCP();
209 
210  asock = socket( AF_INET, SOCK_DGRAM, 0 );
211 
212  addr_from.sin_port = htons( port );
213 
214  if( bind( asock, (struct sockaddr *)&addr_from, sizeof( addr_from ) ) ) {
215  printf( "Bind error\n" );
216  return 0;
217  }
218 
219  addr_to.sin_port = htons( port & (~1) );
220  addr_to.sin_addr.s_addr = inet_addr("127.0.0.1");
221 
222  while( true ) {
223  FD_ZERO( &readf );
224  FD_SET( asock, &readf );
225  tv.tv_sec = 0;
226  tv.tv_usec = 10000;
227  selret = select( asock + 1, &readf, NULL, NULL, &tv );
228 
229  if( FD_ISSET( asock, &readf ) ) {
230  fromsize = sizeof( addr_from );
231  dgrecv = recvfrom( asock, datagram, sizeof(datagram), 0,
232  (struct sockaddr *)&addr_from, &fromsize );
233 
234  if( datagram[0] == 'C' && datagram[1] == 'M' &&
235  datagram[2] == 'D' && datagram[3] == ' ' ) {
236  int theport, bytes, /*recvret,*/ off, bytin;
237  struct sockaddr_in nam;
238  std::string faddr, word;
240  cmdin( std::string( datagram + 4, dgrecv - 4 ) );
241 
242  cmdin >> word;
243 
244  if( word == "socket" ) {
245  cmdin >> faddr >> theport;
246 
247  nam.sin_family = AF_INET;
248  nam.sin_addr.s_addr = inet_addr(faddr.c_str());
249  nam.sin_port = htons(theport);
250 
251  if( (err = OskitTCPSocket( NULL, &conn, AF_INET,
252  SOCK_STREAM, 0 )) != 0 ) {
253  fprintf( stderr, "OskitTCPSocket: error %d\n", err );
254  }
255 
256  if( (err = OskitTCPConnect( conn, NULL, &nam,
257  sizeof(nam) )) != 0 ) {
258  fprintf( stderr, "OskitTCPConnect: error %d\n", err );
259  } else {
260  printf( "Socket created\n" );
261  }
262  }
263 
264  /* The rest of the commands apply only to an open socket */
265  if( !conn ) continue;
266 
267  if( word == "recv" ) {
268  cmdin >> bytes;
269 
270  if( (err = OskitTCPRecv( conn, (OSK_PCHAR)datagram,
271  sizeof(datagram),
272  (unsigned int *)&bytin, 0 )) != 0 ) {
273  fprintf( stderr, "OskitTCPRecv: error %d\n", err );
274  } else {
275  for( off = 0; off < bytin; off += 16 ) {
276  display_row( datagram, off, bytin );
277  }
278  printf( "\n" );
279  }
280  } else if ( word == "type" ) {
281  std::string therest = &cmdin.str()[word.size()];
282  char* p = &therest[0];
283  p += strspn ( p, " \t" );
284  char* src = p;
285  char* dst = p;
286  while ( *src )
287  {
288  char c = *src++;
289  if ( c == '\r' || c == '\n' ) break;
290  if ( c == '\\' )
291  {
292  c = *src++;
293  switch ( c )
294  {
295  case 'b': c = '\b'; break;
296  case 'n': c = '\n'; break;
297  case 'r': c = '\r'; break;
298  case 't': c = '\t'; break;
299  case 'v': c = '\v'; break;
300  }
301  }
302  *dst++ = c;
303  }
304  *dst = '\0';
305  if ( (err = OskitTCPSend ( conn, (OSK_PCHAR)p, strlen(p), (OSK_UINT*)&bytin, 0 ))
306  != 0 ) {
307  fprintf ( stderr, "OskitTCPConnect: error %d\n", err );
308  } else {
309  printf ( "wrote %d bytes\n", bytin );
310  }
311  } else if( word == "send" ) {
312  off = 0;
313  while( cmdin >> word ) {
314  datagram[off++] =
315  atoi( (std::string("0x") + word).c_str() );
316  }
317 
318  if( (err = OskitTCPSend( conn, (OSK_PCHAR)datagram,
319  off, (OSK_UINT *)&bytin, 0 ))
320  != 0 ) {
321  fprintf( stderr, "OskitTCPConnect: error %d\n", err );
322  } else {
323  printf( "wrote %d bytes\n", bytin );
324  }
325  } else if( word == "close" ) {
326  OskitTCPClose( conn );
327  conn = NULL;
328  }
329  } else if( dgrecv > 14 ) {
330  addr_to = addr_from;
331 
332  if( datagram[12] == 8 && datagram[13] == 6 ) {
333  /* Answer arp query */
334  char laddr[4];
335  /* Mark patch as to the previous sender */
336  memcpy( datagram + 32, datagram + 6, 6 );
337  memcpy( datagram, datagram + 6, 6 );
338  /* Mark packet as from us */
339  memcpy( datagram + 22, hwaddr, 6 );
340  memcpy( datagram + 6, hwaddr, 6 );
341  /* Swap inet addresses */
342  memcpy( laddr, datagram + 28, 4 );
343  memcpy( datagram + 28, datagram + 38, 4 );
344  memcpy( datagram + 38, laddr, 4 );
345  /* Set reply opcode */
346  datagram[21] = 2;
347 
348  err = sendto( asock, datagram, dgrecv, 0,
349  (struct sockaddr *)&addr_to,
350  sizeof(addr_to) );
351 
352  if( err != 0 )
353  printf( "sendto: %d\n", err );
354  } else {
355  memcpy( hdr, datagram + 6, 6 );
356  memcpy( hdr + 6, datagram, 6 );
357  memcpy( hdr + 12, datagram + 12, 2 );
358  OskitTCPReceiveDatagram
359  ( (unsigned char *)datagram + 14,
360  dgrecv - 14, 20 );
361  }
362  }
363  }
364 
365  TimerOskitTCP();
366 
367  for( i = output_packets.begin(); i != output_packets.end(); i++ ) {
368  err = sendto( asock, i->c_str(), i->size(), 0,
369  (struct sockaddr *)&addr_to, sizeof(addr_to) );
370 
371  fprintf( stderr, "** SENDING PACKET %d bytes **\n", i->size() );
372 
373  if( err != 0 )
374  printf( "sendto: %d\n", err );
375  }
376 
377  output_packets.clear();
378  }
379 }
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
static int argc
Definition: ServiceArgs.c:12
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
Definition: socklife.c:143
u_short sin_port
Definition: winsock.h:511
#define inet_addr(cp)
Definition: inet.h:98
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
_Check_return_ _CRTIMP size_t __cdecl strspn(_In_z_ const char *_Str, _In_z_ const char *_Control)
#define FD_ZERO(set)
Definition: winsock.h:96
#define argv
Definition: mplay32.c:18
#define FD_SET(fd, set)
Definition: winsock.h:89
void display_row(char *data, int off, int len)
Definition: tcptest.cpp:176
#define MAX_DG_SIZE
Definition: tcptest.cpp: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
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
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
Definition: startup.c:113
smooth NULL
Definition: ftsmooth.c:416
#define INVALID_SOCKET
Definition: winsock.h:332
const GLubyte * c
Definition: glext.h:8905
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum src
Definition: glext.h:6340
#define err(...)
std::list< std::string > output_packets
Definition: tcptest.cpp:29
char string[160]
Definition: util.h:11
basic_istringstream< char, char_traits< char >, allocator< char > > istringstream
Definition: _iosfwd.h:126
char hdr[14]
Definition: tcptest.cpp:67
OSKITTCP_EVENT_HANDLERS EventHandlers
Definition: tcptest.cpp:165
unsigned char hwaddr[6]
Definition: tcptest.cpp:19
GLenum GLenum dst
Definition: glext.h:6340
const WCHAR * word
Definition: lex.c:36
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
#define SOCK_STREAM
Definition: tcpip.h:118
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

◆ TCPFindInterface()

struct ifaddr* TCPFindInterface ( void ClientData,
OSK_UINT  AddrType,
OSK_UINT  FindType,
struct sockaddr ReqAddr 
)

Definition at line 77 of file tcptest.cpp.

80  {
81  static struct sockaddr_in ifa = { AF_INET }, nm = { AF_INET };
82  static struct ifaddr a = {
83  (struct sockaddr *)&ifa,
84  NULL,
85  (struct sockaddr *)&nm,
86  0,
87  0,
88  1,
89  1500
90  };
91  ifa.sin_addr.s_addr = inet_addr( "10.10.2.115" );
92  nm.sin_addr.s_addr = inet_addr( "255.255.255.0" );
93  return &a;
94 }
#define inet_addr(cp)
Definition: inet.h:98
#define a
Definition: ke_i.h:78
smooth NULL
Definition: ftsmooth.c:416
struct in_addr sin_addr
Definition: winsock.h:512
#define AF_INET
Definition: tcpip.h:117
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204

◆ TCPFree()

void TCPFree ( void ClientData,
void data,
OSK_PCHAR  File,
OSK_UINT  Line 
)

Definition at line 103 of file tcptest.cpp.

104  {
105  fprintf( stderr, "(%s:%d) free( %x )\n", File, Line, data );
106  free( data );
107 }
#define free
Definition: debug_ros.c:5
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
Definition: ncftp.h:79
FILE * stderr
Definition: File.h:15

◆ TCPMalloc()

void* TCPMalloc ( void ClientData,
OSK_UINT  Bytes,
OSK_PCHAR  File,
OSK_UINT  Line 
)

Definition at line 96 of file tcptest.cpp.

97  {
98  void *v = malloc( Bytes );
99  fprintf( stderr, "(%s:%d) malloc( %d ) => %x\n", File, Line, Bytes, v );
100  return v;
101 }
_In_ UINT Bytes
Definition: mmcopy.h:9
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
Definition: ncftp.h:79
const GLdouble * v
Definition: gl.h:2040
FILE * stderr
#define malloc
Definition: debug_ros.c:4
Definition: File.h:15

◆ TCPPacketSend()

int TCPPacketSend ( void ClientData,
OSK_PCHAR  data,
OSK_UINT  len 
)

Definition at line 71 of file tcptest.cpp.

71  {
72  output_packets.push_back( std::string( hdr, 14 ) +
73  std::string( (char *)data, (int)len ) );
74  return 0;
75 }
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLenum GLsizei len
Definition: glext.h:6722
std::list< std::string > output_packets
Definition: tcptest.cpp:29
char string[160]
Definition: util.h:11
char hdr[14]
Definition: tcptest.cpp:67

◆ TCPSleep()

int TCPSleep ( void ClientData,
void token,
int  priority,
char msg,
int  tmio 
)

Definition at line 109 of file tcptest.cpp.

110  {
111 #if 0
112  PSLEEPING_THREAD SleepingThread;
113 
115  ("Called TSLEEP: tok = %x, pri = %d, wmesg = %s, tmio = %x\n",
116  token, priority, msg, tmio));
117 
118  SleepingThread = ExAllocatePool( NonPagedPool, sizeof( *SleepingThread ) );
119  if( SleepingThread ) {
120  KeInitializeEvent( &SleepingThread->Event, NotificationEvent, FALSE );
121  SleepingThread->SleepToken = token;
122 
123  ExAcquireFastMutex( &SleepingThreadsLock );
124  InsertTailList( &SleepingThreadsList, &SleepingThread->Entry );
125  ExReleaseFastMutex( &SleepingThreadsLock );
126 
127  TI_DbgPrint(MID_TRACE,("Waiting on %x\n", token));
128  KeWaitForSingleObject( &SleepingThread->Event,
129  WrSuspended,
130  KernelMode,
131  TRUE,
132  NULL );
133 
134  ExAcquireFastMutex( &SleepingThreadsLock );
135  RemoveEntryList( &SleepingThread->Entry );
136  ExReleaseFastMutex( &SleepingThreadsLock );
137 
138  ExFreePool( SleepingThread );
139  }
140  TI_DbgPrint(MID_TRACE,("Waiting finished: %x\n", token));
141 #endif
142  return 0;
143 }
#define TRUE
Definition: types.h:120
#define MID_TRACE
Definition: debug.h:15
#define InsertTailList(ListHead, Entry)
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
VOID FASTCALL ExReleaseFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:31
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
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 token
Definition: glfuncs.h:210
#define TI_DbgPrint(x, y)
Definition: tcptest.cpp:27
smooth NULL
Definition: ftsmooth.c:416
#define ExAllocatePool(type, size)
Definition: fbtusb.h:44
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
KEVENT Event
Definition: tcp.h:50
VOID FASTCALL ExAcquireFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:23
LIST_ENTRY Entry
Definition: tcp.h:48
#define msg(x)
Definition: auth_time.c:54
static int priority
Definition: timer.c:163
PVOID SleepToken
Definition: tcp.h:49
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

◆ TCPSocketState()

int TCPSocketState ( void ClientData,
void WhichSocket,
void WhichConnection,
OSK_UINT  NewState 
)

Definition at line 43 of file tcptest.cpp.

46  {
47  PCONNECTION_ENDPOINT Connection = (PCONNECTION_ENDPOINT)WhichConnection;
48  //PLIST_ENTRY Entry;
49 
50  TI_DbgPrint(MID_TRACE,("Called: NewState %x\n", NewState));
51 
52  if( !Connection ) {
53  TI_DbgPrint(MID_TRACE,("Socket closing.\n"));
54  return 0;
55  }
56 
57  if( (NewState & SEL_CONNECT) &&
58  !(Connection->State & SEL_CONNECT) ) {
59  } else if( (NewState & SEL_READ) || (NewState & SEL_FIN) ) {
60  }
61 
62  return 0;
63 }
#define MID_TRACE
Definition: debug.h:15
#define SEL_FIN
Definition: tcp.h:74
#define TI_DbgPrint(x, y)
Definition: tcptest.cpp:27
#define SEL_CONNECT
Definition: tcp.h:73
struct _CONNECTION_ENDPOINT * PCONNECTION_ENDPOINT
#define SEL_READ
Definition: tcp.h:77

◆ TCPWakeup()

void TCPWakeup ( void ClientData,
void token 
)

Definition at line 145 of file tcptest.cpp.

145  {
146 #if 0
148  PSLEEPING_THREAD SleepingThread;
149 
150  ExAcquireFastMutex( &SleepingThreadsLock );
151  Entry = SleepingThreadsList.Flink;
152  while( Entry != &SleepingThreadsList ) {
153  SleepingThread = CONTAINING_RECORD(Entry, SLEEPING_THREAD, Entry);
154  TI_DbgPrint(MID_TRACE,("Sleeper @ %x\n", SleepingThread));
155  if( SleepingThread->SleepToken == token ) {
156  TI_DbgPrint(MID_TRACE,("Setting event to wake %x\n", token));
157  KeSetEvent( &SleepingThread->Event, IO_NETWORK_INCREMENT, FALSE );
158  }
159  Entry = Entry->Flink;
160  }
161  ExReleaseFastMutex( &SleepingThreadsLock );
162 #endif
163 }
#define MID_TRACE
Definition: debug.h:15
struct _Entry Entry
Definition: kefuncs.h:640
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
VOID FASTCALL ExReleaseFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:31
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 token
Definition: glfuncs.h:210
#define TI_DbgPrint(x, y)
Definition: tcptest.cpp:27
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
#define IO_NETWORK_INCREMENT
Definition: tcpip.h:43
Definition: typedefs.h:117
KEVENT Event
Definition: tcp.h:50
VOID FASTCALL ExAcquireFastMutex(IN PFAST_MUTEX FastMutex)
Definition: fmutex.c:23
PVOID SleepToken
Definition: tcp.h:49
base of all file and directory entries
Definition: entries.h:82

Variable Documentation

◆ EventHandlers

OSKITTCP_EVENT_HANDLERS EventHandlers
Initial value:
= {
}
struct ifaddr * TCPFindInterface(void *ClientData, OSK_UINT AddrType, OSK_UINT FindType, struct sockaddr *ReqAddr)
Definition: tcptest.cpp:77
void TCPFree(void *ClientData, void *data, OSK_PCHAR File, OSK_UINT Line)
Definition: tcptest.cpp:103
int TCPSleep(void *ClientData, void *token, int priority, char *msg, int tmio)
Definition: tcptest.cpp:109
void * TCPMalloc(void *ClientData, OSK_UINT Bytes, OSK_PCHAR File, OSK_UINT Line)
Definition: tcptest.cpp:96
int TCPSocketState(void *ClientData, void *WhichSocket, void *WhichConnection, OSK_UINT NewState)
Definition: tcptest.cpp:43
smooth NULL
Definition: ftsmooth.c:416
int TCPPacketSend(void *ClientData, OSK_PCHAR data, OSK_UINT len)
Definition: tcptest.cpp:71
void TCPWakeup(void *ClientData, void *token)
Definition: tcptest.cpp:145

Definition at line 165 of file tcptest.cpp.

Referenced by main().

◆ hdr

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

Definition at line 67 of file tcptest.cpp.

Referenced by main(), and TCPPacketSend().

◆ hwaddr

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

Definition at line 19 of file tcptest.cpp.

Referenced by main().

◆ output_packets

std::list<std::string> output_packets

Definition at line 29 of file tcptest.cpp.

Referenced by main(), and TCPPacketSend().

◆ TCP_IPIdentification

unsigned long TCP_IPIdentification

Definition at line 24 of file tcptest.cpp.