12 #include <ddk/tdiinfo.h> 29 #define MAX_DG_SIZE 16384 31 char hwaddr[6] = { 0x08, 0x00, 0x20, 0x0b, 0xb7, 0xbb };
33 char hdr[14] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37 #define STRINGIFY(x) #x 80 switch( AddressType ) {
101 ULONG TdiAddressSize;
130 ULONG TdiAddressSize;
147 *ConnectionInfo = ConnInfo;
158 printf(
"AddrLen %x\n", AddrLen);
198 ConnectTo.
Address[0].Address[0].in_addr = 0x6a020a0a;
257 printf(
"Sending packet: %02x:%02x:%02x:%02x:%02x:%02x\n",
258 Addr[0], Addr[1], Addr[2], Addr[3], Addr[4], Addr[5] );
284 int bytes, adapter_id, mtu, speed;
290 std::list<std::string>::iterator
i;
301 ( &RegistryUnicodePath,
302 L"\\SYSTEM\\CurrentControlSet\\Services" 326 if(
bind( asock, (
struct sockaddr *)&addr_from,
sizeof( addr_from ) ) ) {
339 fromsize =
sizeof( addr_from );
340 dgrecv =
recvfrom( asock, datagram,
sizeof(datagram), 0,
341 (
struct sockaddr *)&addr_from, &fromsize );
343 if( datagram[0] ==
'C' && datagram[1] ==
'M' &&
344 datagram[2] ==
'D' && datagram[3] ==
' ' ) {
345 int theport,
bytes, recvret,
off, bytin;
354 if(
word ==
"udpsocket" ) {
356 }
else if(
word ==
"tcpsocket" ) {
360 }
else if(
word ==
"close" ) {
363 }
else if(
word ==
"type" ) {
365 char*
p = &therest[0];
372 if (
c ==
'\r' ||
c ==
'\n' )
break;
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;
396 printf (
"wrote %d bytes\n", bytin );
398 }
else if(
word ==
"send" ) {
400 while( cmdin >>
word ) {
405 if( (
err =
S->send( datagram,
off, &bytin,
NULL )) != 0 ) {
408 printf(
"wrote %d bytes\n", bytin );
410 }
else if(
word ==
"recv" ) {
413 if( (
err =
S->recv( datagram,
421 }
else if(
word ==
"end" ) {
424 }
else if( dgrecv > 14 ) {
427 if( datagram[12] == 8 && datagram[13] == 6 ) {
431 memcpy( datagram + 32, datagram + 6, 6 );
432 memcpy( datagram, datagram + 6, 6 );
437 memcpy( laddr, datagram + 28, 4 );
438 memcpy( datagram + 28, datagram + 38, 4 );
439 memcpy( datagram + 38, laddr, 4 );
443 err =
sendto( asock, datagram, dgrecv, 0,
453 IPPacket.
Header = datagram;
454 IPPacket.
Data = datagram + 14;
465 (
struct sockaddr *)&addr_to,
sizeof(addr_to) );
NTSTATUS TCPConnect(PCONNECTION_ENDPOINT Connection, PTDI_CONNECTION_INFORMATION ConnInfo, PTDI_CONNECTION_INFORMATION ReturnInfo, PTCP_COMPLETION_ROUTINE Complete, PVOID Context)
UINT CopyBufferToBufferChain(PNDIS_BUFFER DstBuffer, UINT DstOffset, PUCHAR SrcData, UINT Length)
INT WSAAPI recvfrom(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags, OUT LPSOCKADDR from, IN OUT INT FAR *fromlen)
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
NTSTATUS TdiBuildNullConnectionInfo(PTDI_CONNECTION_INFORMATION *ConnectionInfo, ULONG Type)
#define STATUS_INSUFFICIENT_RESOURCES
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
ACPI_SIZE strlen(const char *String)
GLenum GLuint GLenum GLsizei const GLchar * buf
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
void GetDataPtr(PNDIS_PACKET Packet, UINT Offset, PCHAR *DataOut, PUINT Size)
GLuint GLuint GLsizei count
NTSTATUS TCPSendData(PCONNECTION_ENDPOINT Connection, PCHAR Buffer, ULONG DataSize, PULONG DataUsed, ULONG Flags, PTCP_COMPLETION_ROUTINE Complete, PVOID Context)
NTSTATUS TCPSocket(PCONNECTION_ENDPOINT Connection, UINT Family, UINT Type, UINT Proto)
virtual int recv(char *buf, int len, int *bytes, struct sockaddr_in *si)=0
NTSTATUS TdiBuildConnectionInfoInPlace(PTDI_CONNECTION_INFORMATION ConnectionInfo, PTA_ADDRESS Address)
_Check_return_ _CRTIMP size_t __cdecl strspn(_In_z_ const char *_Str, _In_z_ const char *_Control)
int recv(char *buf, int len, int *bytes, struct sockaddr_in *si)
PIP_INTERFACE IPCreateInterface(PLLIP_BIND_INFO BindInfo)
UINT TdiAddressSizeFromType(UINT AddressType)
UINT TaLengthOfTransportAddress(PTRANSPORT_ADDRESS Addr)
void display_row(char *data, int off, int len)
LL_TRANSMIT_ROUTINE Transmit
struct _TA_ADDRESS * PTA_ADDRESS
PCONNECTION_ENDPOINT Connection
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
NTSTATUS TCPClose(PCONNECTION_ENDPOINT Connection)
static unsigned char bytes[4]
_In_ ULONG _In_ ULONG Offset
#define FD_ISSET(fd, set)
_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)
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
VOID NTAPI KeBugCheck(ULONG BugCheckCode)
struct _TA_ADDRESS_IP::_AddrIp Address[1]
IN PVOID IN PVOID IN USHORT IN USHORT IN PINTERFACE Interface
struct _ETH_HEADER ETH_HEADER
#define NT_SUCCESS(StatCode)
virtual int send(char *buf, int len, int *bytes, struct sockaddr_in *si)=0
struct _TDI_CONNECTION_INFORMATION * PTDI_CONNECTION_INFORMATION
int main(int argc, char **argv)
_In_ ULONG _In_ ULONG _In_ ULONG Length
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
struct _TA_ADDRESS_IP TA_IP_ADDRESS
#define STATUS_UNSUCCESSFUL
VOID ExpInitLookasideLists()
#define ExAllocatePool(type, size)
NTSTATUS TdiBuildNullConnectionInfoInPlace(PTDI_CONNECTION_INFORMATION ConnInfo, ULONG Type)
#define TDI_ADDRESS_TYPE_IP
#define memcpy(s1, s2, n)
IN PVOID IN PVOID IN USHORT IN USHORT Size
basic_istringstream< char, char_traits< char >, allocator< char > > istringstream
struct _TDI_ADDRESS_IP TDI_ADDRESS_IP
NTSTATUS IPStartup(PUNICODE_STRING RegistryPath)
std::list< std::string > output_packets
VOID IPReceive(PIP_INTERFACE IF, PIP_PACKET IPPacket)
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)
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
void connect_complete(void *context, NTSTATUS status, unsigned long count)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
void receive_complete(void *context, NTSTATUS status, unsigned long count)
VOID TCPFreeConnectionEndpoint(PCONNECTION_ENDPOINT Connection)
NTSTATUS TdiBuildConnectionInfo(PTDI_CONNECTION_INFORMATION *ConnectionInfo, PTA_ADDRESS Address)
TCPSocketObject(std::string host, int port, NTSTATUS *status)
PCONNECTION_ENDPOINT TCPAllocateConnectionEndpoint(PVOID ClientContext)
int send(char *buf, int len, int *bytes, struct sockaddr_in *si)
VOID SendPacket(PVOID Context, PNDIS_PACKET NdisPacket, UINT Offset, PVOID LinkAddress, USHORT Type)