12#include <ddk/tdiinfo.h>
29#define MAX_DG_SIZE 16384
31char hwaddr[6] = { 0x08, 0x00, 0x20, 0x0b, 0xb7, 0xbb };
33char hdr[14] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
34 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
37#define STRINGIFY(x) #x
43 for(
i = off;
i <
len &&
i < off + 16;
i++ ) {
49 for(
i = off;
i <
len &&
i < off + 16;
i++ ) {
63 for(
int off = 0; off <
count; off += 16 ) {
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;
255 std::string output_packet;
257 printf(
"Sending packet: %02x:%02x:%02x:%02x:%02x:%02x\n",
258 Addr[0], Addr[1], Addr[2], Addr[3], Addr[4], Addr[5] );
261 for(
int off = 0; off <
Size; off += 16 ) {
267 output_packet += std::string( (
char *)LinkAddress,
sizeof(
hwaddr) );
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;
347 std::string faddr,
word;
349 cmdin( std::string( datagram + 4, dgrecv - 4 ) );
354 if(
word ==
"udpsocket" ) {
356 }
else if(
word ==
"tcpsocket" ) {
360 }
else if(
word ==
"close" ) {
363 }
else if(
word ==
"type" ) {
364 std::string therest = &cmdin.str()[
word.size()];
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 ) {
402 atoi( (std::string(
"0x") +
word).c_str() );
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) );
ACPI_SIZE strlen(const char *String)
static unsigned char bytes[4]
UINT CopyBufferToBufferChain(PNDIS_BUFFER DstBuffer, UINT DstOffset, PUCHAR SrcData, UINT Length)
DECLSPEC_NORETURN VOID NTAPI KeBugCheck(ULONG BugCheckCode)
virtual int recv(char *buf, int len, int *bytes, struct sockaddr_in *si)=0
virtual int send(char *buf, int len, int *bytes, struct sockaddr_in *si)=0
PCONNECTION_ENDPOINT Connection
int recv(char *buf, int len, int *bytes, struct sockaddr_in *si)
TCPSocketObject(std::string host, int port, NTSTATUS *status)
int send(char *buf, int len, int *bytes, struct sockaddr_in *si)
#define NT_SUCCESS(StatCode)
INT WSAAPI recvfrom(IN SOCKET s, OUT CHAR FAR *buf, IN INT len, IN INT flags, OUT LPSOCKADDR from, IN OUT INT FAR *fromlen)
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 WSAAPI sendto(IN SOCKET s, IN CONST CHAR FAR *buf, IN INT len, IN INT flags, IN CONST struct sockaddr *to, IN INT tolen)
INT WINAPI WSAStartup(IN WORD wVersionRequested, OUT LPWSADATA lpWSAData)
NTSTATUS IPStartup(PUNICODE_STRING RegistryPath)
PIP_INTERFACE IPCreateInterface(PLLIP_BIND_INFO BindInfo)
#define ExAllocatePool(type, size)
GLuint GLuint GLsizei count
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLenum GLuint GLenum GLsizei const GLchar * buf
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
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_ int __cdecl atoi(_In_z_ const char *_Str)
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)
NTSTATUS TCPConnect(PCONNECTION_ENDPOINT Connection, PTDI_CONNECTION_INFORMATION ConnInfo, PTDI_CONNECTION_INFORMATION ReturnInfo, PTCP_COMPLETION_ROUTINE Complete, PVOID Context)
PCONNECTION_ENDPOINT TCPAllocateConnectionEndpoint(PVOID ClientContext)
VOID TCPFreeConnectionEndpoint(PCONNECTION_ENDPOINT Connection)
NTSTATUS TCPClose(PCONNECTION_ENDPOINT Connection)
NTSTATUS TdiBuildNullConnectionInfo(PTDI_CONNECTION_INFORMATION *ConnectionInfo, ULONG Type)
std::list< std::string > output_packets
UINT TdiAddressSizeFromType(UINT AddressType)
UINT TaLengthOfTransportAddress(PTRANSPORT_ADDRESS Addr)
void receive_complete(void *context, NTSTATUS status, unsigned long count)
VOID ExpInitLookasideLists()
NTSTATUS TdiBuildNullConnectionInfoInPlace(PTDI_CONNECTION_INFORMATION ConnInfo, ULONG Type)
void connect_complete(void *context, NTSTATUS status, unsigned long count)
VOID SendPacket(PVOID Context, PNDIS_PACKET NdisPacket, UINT Offset, PVOID LinkAddress, USHORT Type)
NTSTATUS TdiBuildConnectionInfoInPlace(PTDI_CONNECTION_INFORMATION ConnectionInfo, PTA_ADDRESS Address)
NTSTATUS TdiBuildConnectionInfo(PTDI_CONNECTION_INFORMATION *ConnectionInfo, PTA_ADDRESS Address)
void display_row(char *data, int off, int len)
void GetDataPtr(PNDIS_PACKET Packet, UINT Offset, PCHAR *DataOut, PUINT Size)
#define memcpy(s1, s2, n)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
_In_ ULONG _In_ ULONG Offset
_In_ ULONG _In_ ULONG _In_ ULONG Length
VOID IPReceive(PIP_INTERFACE IF, PIP_PACKET IPPacket)
_Check_return_ _CRTIMP size_t __cdecl strspn(_In_z_ const char *_Str, _In_z_ const char *_Control)
INT WSAAPI bind(IN SOCKET s, IN CONST struct sockaddr *name, IN INT namelen)
SOCKET WSAAPI socket(IN INT af, IN INT type, IN INT protocol)
LL_TRANSMIT_ROUTINE Transmit
struct _TA_ADDRESS_IP::_AddrIp Address[1]
struct _TDI_CONNECTION_INFORMATION * PTDI_CONNECTION_INFORMATION
struct _TA_ADDRESS_IP TA_IP_ADDRESS
struct _TA_ADDRESS * PTA_ADDRESS
struct _TDI_ADDRESS_IP TDI_ADDRESS_IP
#define TDI_ADDRESS_TYPE_IP
#define RtlCopyMemory(Destination, Source, Length)
#define RtlZeroMemory(Destination, Length)
#define STATUS_UNSUCCESSFUL
#define STATUS_INSUFFICIENT_RESOURCES
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
_Must_inspect_result_ _In_ WDFDEVICE _In_ LPCGUID _Out_ PINTERFACE Interface
#define FD_ISSET(fd, set)