no message

svn path=/trunk/; revision=1556
This commit is contained in:
Casper Hornstrup 2001-01-21 21:04:53 +00:00
parent 782b28151b
commit e6c8459347
11 changed files with 136 additions and 61 deletions

View file

@ -10,8 +10,7 @@ RESOURCE_OBJECT = $(TARGETNAME).coff
NDIS_OBJECTS = ndis/main.o ndis/40gone.o ndis/50gone.o ndis/buffer.o ndis/cl.o \ NDIS_OBJECTS = ndis/main.o ndis/40gone.o ndis/50gone.o ndis/buffer.o ndis/cl.o \
ndis/cm.o ndis/co.o ndis/control.o ndis/hardware.o \ ndis/cm.o ndis/co.o ndis/control.o ndis/hardware.o \
ndis/io.o ndis/memory.o ndis/miniport.o \ ndis/io.o ndis/memory.o ndis/miniport.o \
ndis/protocol.o ndis/string.o ndis/stubs.o ndis/time.o \ ndis/protocol.o ndis/string.o ndis/stubs.o ndis/time.o
$(TARGETNAME).coff
all: objects $(TARGETNAME).sys all: objects $(TARGETNAME).sys
@ -38,8 +37,10 @@ $(TARGETNAME).sys: $(OBJECTS)
--kill-at \ --kill-at \
--output-lib $(TARGETNAME).a --output-lib $(TARGETNAME).a
$(CC) \ $(CC) \
-nostartfiles -nostdlib \
--subsystem=native \
-mdll \ -mdll \
-specs=../../svc_specs \ --dll \
-Wl,-e,_DriverEntry@8 \ -Wl,-e,_DriverEntry@8 \
-Wl,--base-file,base.tmp \ -Wl,--base-file,base.tmp \
-Wl,--defsym,_end=end \ -Wl,--defsym,_end=end \
@ -55,8 +56,10 @@ $(TARGETNAME).sys: $(OBJECTS)
--def $(TARGETNAME).edf --def $(TARGETNAME).edf
- $(RM) base.tmp - $(RM) base.tmp
$(CC) \ $(CC) \
-nostartfiles -nostdlib \
--subsystem=native \
-mdll \ -mdll \
-specs=../../svc_specs \ --dll \
-Wl,--image-base,0x10000 \ -Wl,--image-base,0x10000 \
-Wl,-e,_DriverEntry@8 \ -Wl,-e,_DriverEntry@8 \
-Wl,temp.exp \ -Wl,temp.exp \

View file

@ -28,24 +28,6 @@
#ifndef _MSC_VER #ifndef _MSC_VER
/* FIXME: The following should be moved to ntddk.h */ /* FIXME: The following should be moved to ntddk.h */
/* i386 specific constants */
/* Page size for the Intel 386 is 4096 */
#define PAGE_SIZE (ULONG)0x1000
/* 4096 is 2^12. Used to find the virtual page number from a virtual address */
#define PAGE_SHIFT 12L
/*
* ULONG ADDRESS_AND_SIZE_TO_SPAN_PAGES(
* IN PVOID Va,
* IN ULONG Size);
*/
#define ADDRESS_AND_SIZE_TO_SPAN_PAGES(Va, Size) \
((((ULONG)((ULONG)(Size) - 1) >> PAGE_SHIFT) + \
(((((ULONG)(Size - 1) & (PAGE_SIZE - 1)) + \
((ULONG)Va & (PAGE_SIZE - 1)))) >> PAGE_SHIFT)) + 1)
/* /*
* ULONG MmGetMdlByteCount( * ULONG MmGetMdlByteCount(
* IN PMDL Mdl) * IN PMDL Mdl)

View file

@ -48,6 +48,14 @@ UINT ResizePacket(
PNDIS_PACKET Packet, PNDIS_PACKET Packet,
UINT Size); UINT Size);
#ifdef DBG
VOID DisplayIPPacket(
PIP_PACKET IPPacket);
#define DISPLAY_IP_PACKET(x) DisplayIPPacket(x)
#else
#define DISPLAY_IP_PACKET(x)
#endif /* DBG */
#endif /* __ROUTINES_H */ #endif /* __ROUTINES_H */
/* EOF */ /* EOF */

View file

@ -33,7 +33,7 @@
/* Define _NTTEST_ to make test version. Device names are prefixed with /* Define _NTTEST_ to make test version. Device names are prefixed with
'NT' to allow the driver to run side by side with MS TCP/IP driver */ 'NT' to allow the driver to run side by side with MS TCP/IP driver */
#define _NTTEST_ //#define _NTTEST_
/* FIXME: The following should be moved to ntddk.h or tdi headers */ /* FIXME: The following should be moved to ntddk.h or tdi headers */
#ifndef _MSC_VER #ifndef _MSC_VER

View file

@ -1,6 +1,6 @@
# TCPIP.SYS - TCP/IP protocol driver # TCPIP.SYS - TCP/IP protocol driver
# #
PATH_TO_TOP = ../../../ PATH_TO_TOP = ../../..
TARGETNAME=tcpip TARGETNAME=tcpip
@ -76,8 +76,10 @@ $(TARGETNAME).sys: $(OBJECTS)
--kill-at \ --kill-at \
--output-lib $(TARGETNAME).a --output-lib $(TARGETNAME).a
$(CC) \ $(CC) \
-nostartfiles -nostdlib \
--subsystem=native \
-mdll \ -mdll \
-specs=../../svc_specs \ --dll \
-Wl,-e,_DriverEntry@8 \ -Wl,-e,_DriverEntry@8 \
-Wl,--base-file,base.tmp \ -Wl,--base-file,base.tmp \
-Wl,--defsym,_end=end \ -Wl,--defsym,_end=end \
@ -93,8 +95,10 @@ $(TARGETNAME).sys: $(OBJECTS)
--def $(TARGETNAME).edf --def $(TARGETNAME).edf
- $(RM) base.tmp - $(RM) base.tmp
$(CC) \ $(CC) \
-nostartfiles -nostdlib \
--subsystem=native \
-mdll \ -mdll \
-specs=../../svc_specs \ --dll \
-Wl,--image-base,0x10000 \ -Wl,--image-base,0x10000 \
-Wl,-e,_DriverEntry@8 \ -Wl,-e,_DriverEntry@8 \
-Wl,temp.exp \ -Wl,temp.exp \

View file

@ -631,6 +631,9 @@ VOID IPReceive(
return; return;
default: default:
TI_DbgPrint(MIN_TRACE, ("Datagram has an unsupported IP version %d.\n", Version)); TI_DbgPrint(MIN_TRACE, ("Datagram has an unsupported IP version %d.\n", Version));
DISPLAY_IP_PACKET(IPPacket);
return; return;
} }
} }

View file

@ -287,8 +287,17 @@ PADDRESS_FILE AddrSearchNext(
while (CurrentEntry != &AddressFileListHead) { while (CurrentEntry != &AddressFileListHead) {
Current = CONTAINING_RECORD(CurrentEntry, ADDRESS_FILE, ListEntry); Current = CONTAINING_RECORD(CurrentEntry, ADDRESS_FILE, ListEntry);
/* See if this address matches the search criteria */
IPAddress = Current->ADE->Address; IPAddress = Current->ADE->Address;
TI_DbgPrint(DEBUG_ADDRFILE, ("Comparing: ((%d, %d, 0x%X), (%d, %d, 0x%X)).\n",
Current->Port,
Current->Protocol,
IPAddress->Address.IPv4Address,
SearchContext->Port,
SearchContext->Protocol,
SearchContext->Address->Address.IPv4Address));
/* See if this address matches the search criteria */
if (((Current->Port == SearchContext->Port) && if (((Current->Port == SearchContext->Port) &&
(Current->Protocol == SearchContext->Protocol) && (Current->Protocol == SearchContext->Protocol) &&
(AddrIsEqual(IPAddress, SearchContext->Address))) || (AddrIsEqual(IPAddress, SearchContext->Address))) ||

View file

@ -81,9 +81,7 @@ VOID DispCancelComplete(
IoAcquireCancelSpinLock(&OldIrql); IoAcquireCancelSpinLock(&OldIrql);
/* Remove the reference placed on the endpoint by the cancel routine. /* Remove the reference taken by the cancel routine */
The cancelled IRP will be completed by the completion routine for
the request */
TranContext->RefCount--; TranContext->RefCount--;
if (TranContext->RefCount == 0) { if (TranContext->RefCount == 0) {
@ -482,7 +480,6 @@ NTSTATUS DispTdiSetEventHandler(
* Status of operation * Status of operation
*/ */
{ {
#ifdef _MSC_VER
PTDI_REQUEST_KERNEL_SET_EVENT Parameters; PTDI_REQUEST_KERNEL_SET_EVENT Parameters;
PTRANSPORT_CONTEXT TranContext; PTRANSPORT_CONTEXT TranContext;
PIO_STACK_LOCATION IrpSp; PIO_STACK_LOCATION IrpSp;
@ -518,8 +515,8 @@ NTSTATUS DispTdiSetEventHandler(
switch (Parameters->EventType) { switch (Parameters->EventType) {
case TDI_EVENT_CONNECT: case TDI_EVENT_CONNECT:
if (!Parameters->EventHandler) { if (!Parameters->EventHandler) {
AddrFile->ConnectionHandler = // AddrFile->ConnectionHandler =
(PTDI_IND_CONNECT)TdiDefaultConnectHandler; // (PTDI_IND_CONNECT)TdiDefaultConnectHandler;
AddrFile->ConnectionHandlerContext = NULL; AddrFile->ConnectionHandlerContext = NULL;
AddrFile->RegisteredConnectionHandler = FALSE; AddrFile->RegisteredConnectionHandler = FALSE;
} else { } else {
@ -532,8 +529,8 @@ NTSTATUS DispTdiSetEventHandler(
case TDI_EVENT_DISCONNECT: case TDI_EVENT_DISCONNECT:
if (!Parameters->EventHandler) { if (!Parameters->EventHandler) {
AddrFile->DisconnectHandler = // AddrFile->DisconnectHandler =
(PTDI_IND_DISCONNECT)TdiDefaultDisconnectHandler; // (PTDI_IND_DISCONNECT)TdiDefaultDisconnectHandler;
AddrFile->DisconnectHandlerContext = NULL; AddrFile->DisconnectHandlerContext = NULL;
AddrFile->RegisteredDisconnectHandler = FALSE; AddrFile->RegisteredDisconnectHandler = FALSE;
} else { } else {
@ -546,8 +543,8 @@ NTSTATUS DispTdiSetEventHandler(
case TDI_EVENT_RECEIVE: case TDI_EVENT_RECEIVE:
if (Parameters->EventHandler == NULL) { if (Parameters->EventHandler == NULL) {
AddrFile->ReceiveHandler = // AddrFile->ReceiveHandler =
(PTDI_IND_RECEIVE)TdiDefaultReceiveHandler; // (PTDI_IND_RECEIVE)TdiDefaultReceiveHandler;
AddrFile->ReceiveHandlerContext = NULL; AddrFile->ReceiveHandlerContext = NULL;
AddrFile->RegisteredReceiveHandler = FALSE; AddrFile->RegisteredReceiveHandler = FALSE;
} else { } else {
@ -560,8 +557,8 @@ NTSTATUS DispTdiSetEventHandler(
case TDI_EVENT_RECEIVE_EXPEDITED: case TDI_EVENT_RECEIVE_EXPEDITED:
if (Parameters->EventHandler == NULL) { if (Parameters->EventHandler == NULL) {
AddrFile->ExpeditedReceiveHandler = // AddrFile->ExpeditedReceiveHandler =
(PTDI_IND_RECEIVE_EXPEDITED)TdiDefaultRcvExpeditedHandler; // (PTDI_IND_RECEIVE_EXPEDITED)TdiDefaultRcvExpeditedHandler;
AddrFile->ExpeditedReceiveHandlerContext = NULL; AddrFile->ExpeditedReceiveHandlerContext = NULL;
AddrFile->RegisteredExpeditedReceiveHandler = FALSE; AddrFile->RegisteredExpeditedReceiveHandler = FALSE;
} else { } else {
@ -574,8 +571,8 @@ NTSTATUS DispTdiSetEventHandler(
case TDI_EVENT_RECEIVE_DATAGRAM: case TDI_EVENT_RECEIVE_DATAGRAM:
if (Parameters->EventHandler == NULL) { if (Parameters->EventHandler == NULL) {
AddrFile->ReceiveDatagramHandler = // AddrFile->ReceiveDatagramHandler =
(PTDI_IND_RECEIVE_DATAGRAM)TdiDefaultRcvDatagramHandler; // (PTDI_IND_RECEIVE_DATAGRAM)TdiDefaultRcvDatagramHandler;
AddrFile->ReceiveDatagramHandlerContext = NULL; AddrFile->ReceiveDatagramHandlerContext = NULL;
AddrFile->RegisteredReceiveDatagramHandler = FALSE; AddrFile->RegisteredReceiveDatagramHandler = FALSE;
} else { } else {
@ -588,8 +585,8 @@ NTSTATUS DispTdiSetEventHandler(
case TDI_EVENT_ERROR: case TDI_EVENT_ERROR:
if (Parameters->EventHandler == NULL) { if (Parameters->EventHandler == NULL) {
AddrFile->ErrorHandler = // AddrFile->ErrorHandler =
(PTDI_IND_ERROR)TdiDefaultErrorHandler; // (PTDI_IND_ERROR)TdiDefaultErrorHandler;
AddrFile->ErrorHandlerContext = NULL; AddrFile->ErrorHandlerContext = NULL;
AddrFile->RegisteredErrorHandler = FALSE; AddrFile->RegisteredErrorHandler = FALSE;
} else { } else {
@ -607,9 +604,6 @@ NTSTATUS DispTdiSetEventHandler(
KeReleaseSpinLock(&AddrFile->Lock, OldIrql); KeReleaseSpinLock(&AddrFile->Lock, OldIrql);
return Status; return Status;
#else
return STATUS_NOT_IMPLEMENTED;
#endif
} }

View file

@ -153,10 +153,10 @@ NTSTATUS TiCreateFileObject(
/* This is a request to open an address */ /* This is a request to open an address */
/* Parameter checks */ /* Parameter checks */
Address = (PTA_ADDRESS_IP)(EaInfo->EaName + EaInfo->EaNameLength + 1); Address = (PTA_ADDRESS_IP)(EaInfo->EaName + EaInfo->EaNameLength);
if ((EaInfo->EaValueLength < sizeof(TA_ADDRESS_IP)) || if ((EaInfo->EaValueLength < sizeof(TA_ADDRESS_IP)) ||
(Address->TAAddressCount != 1) || (Address->TAAddressCount != 1) ||
(Address->Address[0].AddressLength < sizeof(TDI_ADDRESS_IP)) || (Address->Address[0].AddressLength < TDI_ADDRESS_LENGTH_IP) ||
(Address->Address[0].AddressType != TDI_ADDRESS_TYPE_IP)) { (Address->Address[0].AddressType != TDI_ADDRESS_TYPE_IP)) {
TI_DbgPrint(MIN_TRACE, ("Parameters are invalid.\n")); TI_DbgPrint(MIN_TRACE, ("Parameters are invalid.\n"));
ExFreePool(Context); ExFreePool(Context);
@ -375,10 +375,11 @@ NTSTATUS TiDispatchInternal(
NTSTATUS Status; NTSTATUS Status;
PIO_STACK_LOCATION IrpSp; PIO_STACK_LOCATION IrpSp;
TI_DbgPrint(DEBUG_IRP, ("Called. DeviceObject is at (0x%X), IRP is at (0x%X).\n", DeviceObject, Irp));
IrpSp = IoGetCurrentIrpStackLocation(Irp); IrpSp = IoGetCurrentIrpStackLocation(Irp);
TI_DbgPrint(DEBUG_IRP, ("Called. DeviceObject is at (0x%X), IRP is at (0x%X) MN (%d).\n",
DeviceObject, Irp, IrpSp->MinorFunction));
Irp->IoStatus.Status = STATUS_SUCCESS; Irp->IoStatus.Status = STATUS_SUCCESS;
Irp->IoStatus.Information = 0; Irp->IoStatus.Information = 0;
@ -701,7 +702,7 @@ DriverEntry(
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
} }
#if 1 #if 0
/* Open underlying adapter(s) we are bound to */ /* Open underlying adapter(s) we are bound to */
/* FIXME: Get binding information from registry */ /* FIXME: Get binding information from registry */

View file

@ -400,4 +400,43 @@ UINT ResizePacket(
return OldSize; return OldSize;
} }
#ifdef DBG
VOID DisplayIPPacket(
PIP_PACKET IPPacket)
{
UINT i;
PCHAR p;
UINT Length;
PNDIS_BUFFER Buffer;
PNDIS_BUFFER NextBuffer;
if ((DebugTraceLevel & MAX_TRACE) == 0)
return;
if (!IPPacket) {
TI_DbgPrint(MIN_TRACE, ("Cannot display null packet.\n"));
return;
}
TI_DbgPrint(MIN_TRACE, ("Header buffer is at (0x%X).\n", IPPacket->Header));
TI_DbgPrint(MIN_TRACE, ("Header size is (%d).\n", IPPacket->HeaderSize));
TI_DbgPrint(MIN_TRACE, ("TotalSize (%d).\n", IPPacket->TotalSize));
TI_DbgPrint(MIN_TRACE, ("ContigSize (%d).\n", IPPacket->ContigSize));
TI_DbgPrint(MIN_TRACE, ("NdisPacket (0x%X).\n", IPPacket->NdisPacket));
NdisQueryPacket(IPPacket->NdisPacket, NULL, NULL, &Buffer, NULL);
for (; Buffer != NULL; Buffer = NextBuffer) {
NdisGetNextBuffer(Buffer, &NextBuffer);
NdisQueryBuffer(Buffer, (PVOID)&p, &Length);
for (i = 0; i < Length; i++) {
if (i % 16 == 0)
DbgPrint("\n");
DbgPrint("%02X ", (p[i]) & 0xFF);
}
DbgPrint("\n");
}
}
#endif /* DBG */
/* EOF */ /* EOF */

View file

@ -51,6 +51,8 @@ NTSTATUS AddUDPHeaderIPv4(
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
} }
TI_DbgPrint(MAX_TRACE, ("Allocated %d bytes for headers at 0x%X.\n", BufferSize, Header));
/* Allocate NDIS buffer for maximum Link level, IP and UDP header */ /* Allocate NDIS buffer for maximum Link level, IP and UDP header */
NdisAllocateBuffer(&NdisStatus, NdisAllocateBuffer(&NdisStatus,
&HeaderBuffer, &HeaderBuffer,
@ -171,6 +173,8 @@ NTSTATUS BuildUDPPacket(
/* Chain data after header */ /* Chain data after header */
NdisChainBufferAtBack(Packet->NdisPacket, SendRequest->Buffer); NdisChainBufferAtBack(Packet->NdisPacket, SendRequest->Buffer);
DISPLAY_IP_PACKET(Packet);
*IPPacket = Packet; *IPPacket = Packet;
return STATUS_SUCCESS; return STATUS_SUCCESS;
@ -197,6 +201,12 @@ VOID DeliverUDPData(
*/ */
{ {
KIRQL OldIrql; KIRQL OldIrql;
PTDI_IND_RECEIVE_DATAGRAM ReceiveHandler;
PVOID HandlerContext;
LONG AddressLength;
PVOID SourceAddress;
ULONG BytesTaken;
NTSTATUS Status;
TI_DbgPrint(MAX_TRACE, ("Called.\n")); TI_DbgPrint(MAX_TRACE, ("Called.\n"));
@ -247,11 +257,33 @@ VOID DeliverUDPData(
PoolFreeBuffer(Current->RemoteAddress); PoolFreeBuffer(Current->RemoteAddress);
PoolFreeBuffer(Current); PoolFreeBuffer(Current);
} }
} else { } else if (AddrFile->RegisteredReceiveDatagramHandler) {
TI_DbgPrint(MAX_TRACE, ("Calling receive event handler.\n"));
ReceiveHandler = AddrFile->ReceiveDatagramHandler;
HandlerContext = AddrFile->ReceiveDatagramHandlerContext;
KeReleaseSpinLock(&AddrFile->Lock, OldIrql); KeReleaseSpinLock(&AddrFile->Lock, OldIrql);
/* FIXME: Call event handler */ if (Address->Type == IP_ADDRESS_V4) {
TI_DbgPrint(MAX_TRACE, ("Calling receive event handler.\n")); AddressLength = sizeof(IPv4_RAW_ADDRESS);
SourceAddress = &Address->Address.IPv4Address;
} else /* (Address->Type == IP_ADDRESS_V6) */ {
AddressLength = sizeof(IPv6_RAW_ADDRESS);
SourceAddress = Address->Address.IPv6Address;
}
Status = (*ReceiveHandler)(HandlerContext,
AddressLength,
SourceAddress,
0,
NULL,
TDI_RECEIVE_ENTIRE_MESSAGE,
DataSize,
DataSize,
&BytesTaken,
IPPacket->Data,
NULL);
} }
TI_DbgPrint(MAX_TRACE, ("Leaving.\n")); TI_DbgPrint(MAX_TRACE, ("Leaving.\n"));