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

View file

@ -28,24 +28,6 @@
#ifndef _MSC_VER
/* 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(
* IN PMDL Mdl)

View file

@ -48,6 +48,14 @@ UINT ResizePacket(
PNDIS_PACKET Packet,
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 */
/* EOF */

View file

@ -33,7 +33,7 @@
/* 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 */
#define _NTTEST_
//#define _NTTEST_
/* FIXME: The following should be moved to ntddk.h or tdi headers */
#ifndef _MSC_VER

View file

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

View file

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

View file

@ -285,10 +285,19 @@ PADDRESS_FILE AddrSearchNext(
KeAcquireSpinLock(&AddressFileListLock, &OldIrql);
while (CurrentEntry != &AddressFileListHead) {
Current = CONTAINING_RECORD(CurrentEntry, ADDRESS_FILE, ListEntry);
Current = CONTAINING_RECORD(CurrentEntry, ADDRESS_FILE, ListEntry);
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 */
IPAddress = Current->ADE->Address;
if (((Current->Port == SearchContext->Port) &&
(Current->Protocol == SearchContext->Protocol) &&
(AddrIsEqual(IPAddress, SearchContext->Address))) ||

View file

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

View file

@ -153,10 +153,10 @@ NTSTATUS TiCreateFileObject(
/* This is a request to open an address */
/* 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)) ||
(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)) {
TI_DbgPrint(MIN_TRACE, ("Parameters are invalid.\n"));
ExFreePool(Context);
@ -375,9 +375,10 @@ NTSTATUS TiDispatchInternal(
NTSTATUS Status;
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.Information = 0;
@ -701,7 +702,7 @@ DriverEntry(
return STATUS_INSUFFICIENT_RESOURCES;
}
#if 1
#if 0
/* Open underlying adapter(s) we are bound to */
/* FIXME: Get binding information from registry */

View file

@ -400,4 +400,43 @@ UINT ResizePacket(
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 */

View file

@ -51,6 +51,8 @@ NTSTATUS AddUDPHeaderIPv4(
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 */
NdisAllocateBuffer(&NdisStatus,
&HeaderBuffer,
@ -137,10 +139,10 @@ NTSTATUS BuildUDPPacket(
}
RtlZeroMemory(Packet, sizeof(IP_PACKET));
Packet->RefCount = 1;
Packet->TotalSize = sizeof(IPv4_HEADER) +
sizeof(UDP_HEADER) +
SendRequest->BufferSize;
Packet->RefCount = 1;
Packet->TotalSize = sizeof(IPv4_HEADER) +
sizeof(UDP_HEADER) +
SendRequest->BufferSize;
/* Allocate NDIS packet */
NdisAllocatePacket(&NdisStatus, &Packet->NdisPacket, GlobalPacketPool);
@ -171,6 +173,8 @@ NTSTATUS BuildUDPPacket(
/* Chain data after header */
NdisChainBufferAtBack(Packet->NdisPacket, SendRequest->Buffer);
DISPLAY_IP_PACKET(Packet);
*IPPacket = Packet;
return STATUS_SUCCESS;
@ -197,6 +201,12 @@ VOID DeliverUDPData(
*/
{
KIRQL OldIrql;
PTDI_IND_RECEIVE_DATAGRAM ReceiveHandler;
PVOID HandlerContext;
LONG AddressLength;
PVOID SourceAddress;
ULONG BytesTaken;
NTSTATUS Status;
TI_DbgPrint(MAX_TRACE, ("Called.\n"));
@ -247,11 +257,33 @@ VOID DeliverUDPData(
PoolFreeBuffer(Current->RemoteAddress);
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);
/* FIXME: Call event handler */
TI_DbgPrint(MAX_TRACE, ("Calling receive event handler.\n"));
if (Address->Type == IP_ADDRESS_V4) {
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"));