msafd + afd: Changed type of PVOID args to PAFD_WSABUF, avoiding some casts.

Added some tracing.
Converted afd.sys to use METHOD_NEITHER in the correct places.
oskittcp: Added some tracking in tcp_input and tcp_output to help look for
the ack bug.
tcpip: some cleaning.  Realized that an NTE was getting sent to IPReceive as
the Context parameter, but was later treated as IP_INTERFACE.  Changed
prototypes to keep this from happening again.

svn path=/trunk/; revision=10207
This commit is contained in:
Art Yerkes 2004-07-18 22:03:49 +00:00
parent 430efd137f
commit 6ac4bce416
14 changed files with 88 additions and 108 deletions

View file

@ -1,6 +1,6 @@
# $Id: makefile,v 1.1 2004/05/29 00:15:44 sedwards Exp $
# $Id: makefile,v 1.2 2004/07/18 22:03:48 arty Exp $
PATH_TO_TOP = ../../..
@ -10,7 +10,8 @@ TARGET_TYPE = library
TARGET_NAME = oskittcp
TARGET_CFLAGS = -g -D__REACTOS__=1 -DKERNEL -Iinclude/freebsd -Iinclude/freebsd/sys/include -Iinclude/freebsd/src/sys -Iinclude/freebsd/dev/include -Iinclude/freebsd/net/include -Iinclude -I$(PATH_TO_TOP)/w32api/include -I$(PATH_TO_TOP)/include -DMEMTRACK
#-DMEMTRACK
TARGET_CFLAGS = -g -D__REACTOS__=1 -DKERNEL -Iinclude/freebsd -Iinclude/freebsd/sys/include -Iinclude/freebsd/src/sys -Iinclude/freebsd/dev/include -Iinclude/freebsd/net/include -Iinclude -I$(PATH_TO_TOP)/w32api/include -I$(PATH_TO_TOP)/include
# require os code to explicitly request A/W version of structs/functions
TARGET_CFLAGS += -D_DISABLE_TIDENTS

View file

@ -195,9 +195,9 @@ present:
if (ti == (struct tcpiphdr *)tp || ti->ti_seq != tp->rcv_nxt)
return (0);
do {
tp->rcv_nxt += ti->ti_len;
OS_DbgPrint(OSK_MID_TRACE,("Added %d to rcv_nxt\n",
ti->ti_len));
tp->rcv_nxt += ti->ti_len - sizeof( struct ip );
OS_DbgPrint(OSK_MID_TRACE,("Added %d to rcv_nxt (result %d)\n",
ti->ti_len - sizeof(struct ip), tp->rcv_nxt));
flags = ti->ti_flags & TH_FIN;
remque(ti);
m = REASS_MBUF(ti);
@ -598,7 +598,8 @@ findpcb:
* we have enough buffer space to take it.
*/
++tcpstat.tcps_preddat;
tp->rcv_nxt += ti->ti_len;
tp->rcv_nxt += ti->ti_len - sizeof(struct ip);
OS_DbgPrint(OSK_MID_TRACE,("Added %d to rcv_nxt\n", ti->ti_len - sizeof(struct ip)));
tcpstat.tcps_rcvpack++;
tcpstat.tcps_rcvbyte += ti->ti_len;
/*

View file

@ -570,6 +570,7 @@ send:
ti->ti_seq = htonl(tp->snd_max);
ti->ti_ack = htonl(tp->rcv_nxt);
printf("ti->ti_ack = %d\n", ti->ti_ack);
if (optlen) {
(void)memcpy(ti + 1, opt, optlen);

View file

@ -148,12 +148,12 @@ typedef struct _LLIP_BIND_INFO {
/* Information about an IP interface */
typedef struct _IP_INTERFACE {
DEFINE_TAG
LIST_ENTRY NTEListHead; /* List of NTEs on this interface */
LIST_ENTRY ADEListHead; /* List of ADEs on this interface */
LIST_ENTRY ListEntry; /* Entry on list */
ULONG RefCount; /* Reference count */
OBJECT_FREE_ROUTINE Free; /* Routine used to free resources used by the object */
KSPIN_LOCK Lock; /* Spin lock for this object */
LIST_ENTRY NTEListHead; /* List of NTEs on this interface */
LIST_ENTRY ADEListHead; /* List of ADEs on this interface */
PVOID Context; /* Pointer to link layer context information */
UINT HeaderSize; /* Size of link level header */
UINT MinFrameSize; /* Minimum frame size in bytes */
@ -239,7 +239,7 @@ VOID STDCALL IPTimeout(
PVOID SystemArgument2);
VOID IPDispatchProtocol(
PNET_TABLE_ENTRY NTE,
PIP_INTERFACE IF,
PIP_PACKET IPPacket);
VOID IPRegisterProtocol(

View file

@ -69,6 +69,11 @@ static inline VOID ExFreePoolX( PVOID Data, PCHAR File, ULONG Line ) {
#define TrackDump()
#define Untrack(x)
#define TrackTag(x)
#define exAllocatePoolWithTag(x,y,z) ExAllocatePoolWithTag(x,y,z)
#define exAllocatePool(x,y) ExAllocatePool(x,y)
#define exFreePool(x) ExFreePool(x)
#define TrackWithTag(w,x,y,z)
#define UntrackFL(x,y,z)
#endif
#endif/*MEMMTRAC_H*/

View file

@ -56,7 +56,7 @@ VOID IPDatagramReassemblyTimeout(
VOID);
VOID IPReceive(
PVOID Context,
PIP_INTERFACE IF,
PIP_PACKET IPPacket);
#endif /* __RECEIVE_H */

View file

@ -1,4 +1,4 @@
# $Id: makefile,v 1.17 2004/06/09 18:11:37 arty Exp $
# $Id: makefile,v 1.18 2004/07/18 22:03:49 arty Exp $
PATH_TO_TOP = ../../..
@ -8,10 +8,10 @@ TARGET_TYPE = export_driver
TARGET_NAME = tcpip
# -DMEMTRACK
TARGET_CFLAGS = \
-D__USE_W32API \
-DNDIS40 \
-DMEMTRACK \
-I./include \
-I$(PATH_TO_TOP)/drivers/lib/oskittcp/include \
-I$(PATH_TO_TOP)/w32api/include \

View file

@ -19,7 +19,7 @@
#include <route.h>
#include <icmp.h>
#include <pool.h>
#include <tilists.h>
KTIMER IPTimer;
KDPC IPTimeoutDpc;
@ -534,10 +534,8 @@ PADDRESS_ENTRY IPLocateADE(
*/
{
KIRQL OldIrql;
PLIST_ENTRY CurrentIFEntry;
PLIST_ENTRY CurrentADEEntry;
PIP_INTERFACE CurrentIF;
PADDRESS_ENTRY CurrentADE;
IF_LIST_ITER(CurrentIF);
ADE_LIST_ITER(CurrentADE);
// TI_DbgPrint(DEBUG_IP, ("Called. Address (0x%X) AddressType (0x%X).\n",
// Address, AddressType));
@ -547,24 +545,17 @@ PADDRESS_ENTRY IPLocateADE(
KeAcquireSpinLock(&InterfaceListLock, &OldIrql);
/* Search the interface list */
CurrentIFEntry = InterfaceListHead.Flink;
while (CurrentIFEntry != &InterfaceListHead) {
CurrentIF = CONTAINING_RECORD(CurrentIFEntry, IP_INTERFACE, ListEntry);
ForEachInterface(CurrentIF) {
/* Search the address entry list and return the ADE if found */
CurrentADEEntry = CurrentIF->ADEListHead.Flink;
while (CurrentADEEntry != &CurrentIF->ADEListHead) {
CurrentADE = CONTAINING_RECORD(CurrentADEEntry, ADDRESS_ENTRY, ListEntry);
ForEachADE(CurrentIF->ADEListHead,CurrentADE) {
if ((AddrIsEqual(Address, CurrentADE->Address)) &&
(CurrentADE->Type == AddressType)) {
ReferenceObject(CurrentADE);
KeReleaseSpinLock(&InterfaceListLock, OldIrql);
return CurrentADE;
}
CurrentADEEntry = CurrentADEEntry->Flink;
}
CurrentIFEntry = CurrentIFEntry->Flink;
}
} EndFor(CurrentADE);
} EndFor(CurrentIF);
KeReleaseSpinLock(&InterfaceListLock, OldIrql);
@ -586,10 +577,8 @@ PADDRESS_ENTRY IPGetDefaultADE(
*/
{
KIRQL OldIrql;
PLIST_ENTRY CurrentIFEntry;
PLIST_ENTRY CurrentADEEntry;
PIP_INTERFACE CurrentIF;
PADDRESS_ENTRY CurrentADE;
ADE_LIST_ITER(CurrentADE);
IF_LIST_ITER(CurrentIF);
BOOLEAN LoopbackIsRegistered = FALSE;
TI_DbgPrint(DEBUG_IP, ("Called. AddressType (0x%X).\n", AddressType));
@ -597,38 +586,30 @@ PADDRESS_ENTRY IPGetDefaultADE(
KeAcquireSpinLock(&InterfaceListLock, &OldIrql);
/* Search the interface list */
CurrentIFEntry = InterfaceListHead.Flink;
while (CurrentIFEntry != &InterfaceListHead) {
CurrentIF = CONTAINING_RECORD(CurrentIFEntry, IP_INTERFACE, ListEntry);
ForEachInterface(CurrentIF) {
if (CurrentIF != Loopback) {
/* Search the address entry list and return the first appropriate ADE found */
CurrentADEEntry = CurrentIF->ADEListHead.Flink;
while (CurrentADEEntry != &CurrentIF->ADEListHead) {
CurrentADE = CONTAINING_RECORD(CurrentADEEntry, ADDRESS_ENTRY, ListEntry);
if (CurrentADE->Type == AddressType)
TI_DbgPrint(DEBUG_IP,("Checking interface %x\n", CurrentIF));
ForEachADE(CurrentIF->ADEListHead,CurrentADE) {
if (CurrentADE->Type == AddressType) {
ReferenceObject(CurrentADE);
KeReleaseSpinLock(&InterfaceListLock, OldIrql);
return CurrentADE;
}
CurrentADEEntry = CurrentADEEntry->Flink;
} EndFor(CurrentADE);
} else
LoopbackIsRegistered = TRUE;
CurrentIFEntry = CurrentIFEntry->Flink;
}
} EndFor(CurrentIF);
/* No address was found. Use loopback interface if available */
if (LoopbackIsRegistered) {
CurrentADEEntry = Loopback->ADEListHead.Flink;
while (CurrentADEEntry != &Loopback->ADEListHead) {
CurrentADE = CONTAINING_RECORD(CurrentADEEntry, ADDRESS_ENTRY, ListEntry);
ForEachADE(CurrentIF->ADEListHead,CurrentADE) {
if (CurrentADE->Type == AddressType) {
ReferenceObject(CurrentADE);
KeReleaseSpinLock(&InterfaceListLock, OldIrql);
return CurrentADE;
}
CurrentADEEntry = CurrentADEEntry->Flink;
}
} EndFor(CurrentADE);
}
KeReleaseSpinLock(&InterfaceListLock, OldIrql);
@ -665,7 +646,7 @@ VOID STDCALL IPTimeout(
VOID IPDispatchProtocol(
PNET_TABLE_ENTRY NTE,
PIP_INTERFACE IPInterface,
PIP_PACKET IPPacket)
/*
* FUNCTION: IP protocol dispatcher
@ -692,7 +673,7 @@ VOID IPDispatchProtocol(
}
/* Call the appropriate protocol handler */
(*ProtocolTable[Protocol])(NTE, IPPacket);
(*ProtocolTable[Protocol])(IPInterface, IPPacket);
}
@ -850,7 +831,10 @@ BOOLEAN IPRegisterInterface(
}
/* Add interface to the global interface list */
ExInterlockedInsertTailList(&InterfaceListHead, &IF->ListEntry, &InterfaceListLock);
ASSERT(&IF->ListEntry);
ExInterlockedInsertTailList(&InterfaceListHead,
&IF->ListEntry,
&InterfaceListLock);
KeReleaseSpinLock(&IF->Lock, OldIrql);

View file

@ -228,15 +228,24 @@ VOID NBSendSolicit(
a request for the neighbor */
/* FIXME: Choose first NTE. We might want to give an NTE as argument */
CurrentEntry = NCE->Interface->NTEListHead.Flink;
if (!IsListEmpty(CurrentEntry))
if (!NCE->Interface || !NCE->Interface->NTEListHead.Flink) {
TI_DbgPrint(MID_TRACE,
("NCE->Interface: %x, "
"NCE->Interface->NTEListHead.Flink %x\n",
NCE->Interface,
NCE->Interface ? NCE->Interface->NTEListHead.Flink : 0));
}
if (!IsListEmpty(&NCE->Interface->NTEListHead))
{
NTE = CONTAINING_RECORD(CurrentEntry, NET_TABLE_ENTRY, IFListEntry);
ARPTransmit(NCE->Address, NTE);
CurrentEntry = NCE->Interface->NTEListHead.Flink;
NTE = CONTAINING_RECORD(CurrentEntry, NET_TABLE_ENTRY,
IFListEntry);
ARPTransmit(NCE->Address, NTE);
}
else
{
TI_DbgPrint(MIN_TRACE, ("Interface at 0x%X has zero NTE.\n", NCE->Interface));
TI_DbgPrint(MIN_TRACE, ("Interface at 0x%X has zero NTE.\n",
NCE->Interface));
}
}
else

View file

@ -479,7 +479,7 @@ VOID ProcessFragment(
DISPLAY_IP_PACKET(Datagram);
/* Give the packet to the protocol dispatcher */
IPDispatchProtocol(NTE, Datagram);
IPDispatchProtocol(IF, Datagram);
/* We're done with this datagram */
exFreePool(Datagram->Header);
@ -529,9 +529,7 @@ VOID IPDatagramReassemblyTimeout(
{
}
VOID IPv4Receive(
PVOID Context,
PIP_PACKET IPPacket)
VOID IPv4Receive( PIP_INTERFACE IF, PIP_PACKET IPPacket)
/*
* FUNCTION: Receives an IPv4 datagram (or fragment)
* ARGUMENTS:
@ -580,11 +578,11 @@ VOID IPv4Receive(
/* FIXME: Possibly forward packets with multicast addresses */
/* FIXME: Should we allow packets to be received on the wrong interface? */
NTE = IPLocateNTEOnInterface((PIP_INTERFACE)Context, &IPPacket->DstAddr, &AddressType);
NTE = IPLocateNTEOnInterface(IF, &IPPacket->DstAddr, &AddressType);
if (NTE) {
/* This packet is destined for us */
ProcessFragment((PIP_INTERFACE)Context, IPPacket, NTE);
ProcessFragment(IF, IPPacket, NTE);
/* Done with this NTE */
DereferenceObject(NTE);
@ -608,12 +606,11 @@ VOID IPv4Receive(
}
VOID IPReceive( PVOID Context,
PIP_PACKET IPPacket )
VOID IPReceive( PIP_INTERFACE IF, PIP_PACKET IPPacket )
/*
* FUNCTION: Receives an IP datagram (or fragment)
* ARGUMENTS:
* Context = Pointer to context information (IP_INTERFACE)
* IF = Interface
* IPPacket = Pointer to IP packet
*/
{
@ -625,7 +622,7 @@ VOID IPReceive( PVOID Context,
switch (Version) {
case 4:
IPPacket->Type = IP_ADDRESS_V4;
IPv4Receive(Context, IPPacket);
IPv4Receive(IF, IPPacket);
break;
case 6:
IPPacket->Type = IP_ADDRESS_V6;

View file

@ -14,24 +14,19 @@
#include <address.h>
#include <pool.h>
#include <ip.h>
#include <tilists.h>
NTSTATUS GetInterfaceIPv4Address( PIP_INTERFACE Interface,
ULONG TargetType,
PULONG Address ) {
PLIST_ENTRY CurrentIFEntry;
PLIST_ENTRY CurrentADEEntry;
PADDRESS_ENTRY CurrentADE;
CurrentADEEntry = Interface->ADEListHead.Flink;
while (CurrentADEEntry != &Interface->ADEListHead)
{
CurrentADE = CONTAINING_RECORD(CurrentADEEntry, ADDRESS_ENTRY, ListEntry);
ADE_LIST_ITER(CurrentADE);
ForEachADE(Interface->ADEListHead,CurrentADE) {
if (CurrentADE->Type == TargetType) {
*Address = CurrentADE->Address->Address.IPv4Address;
return STATUS_SUCCESS;
}
CurrentADEEntry = CurrentADEEntry->Flink;
}
} EndFor(CurrentADE);
return STATUS_UNSUCCESSFUL;
}
@ -39,15 +34,13 @@ NTSTATUS GetInterfaceIPv4Address( PIP_INTERFACE Interface,
UINT CountInterfaces() {
DWORD Count = 0;
KIRQL OldIrql;
PLIST_ENTRY CurrentIFEntry;
IF_LIST_ITER(CurrentIF);
KeAcquireSpinLock(&InterfaceListLock, &OldIrql);
CurrentIFEntry = InterfaceListHead.Flink;
while (CurrentIFEntry != &InterfaceListHead) {
ForEachInterface(CurrentIF) {
Count++;
CurrentIFEntry = CurrentIFEntry->Flink;
}
} EndFor(CurrentIF);
KeReleaseSpinLock(&InterfaceListLock, OldIrql);
@ -56,19 +49,12 @@ UINT CountInterfaces() {
UINT CountInterfaceAddresses( PIP_INTERFACE Interface ) {
UINT AddrCount = 0;
PADDRESS_ENTRY CurrentADE;
PLIST_ENTRY CurrentADEntry;
ADE_LIST_ITER(CurrentADE);
CurrentADEntry = Interface->ADEListHead.Flink;
while( CurrentADEntry != &Interface->ADEListHead ) {
CurrentADEntry = CurrentADEntry->Flink;
CurrentADE = CONTAINING_RECORD(CurrentADEntry,
ADDRESS_ENTRY,
ListEntry);
ForEachADE(Interface->ADEListHead,CurrentADE) {
if( CurrentADE->Type == ADE_UNICAST )
AddrCount++;
}
} EndFor(CurrentADE);
return AddrCount;
}

View file

@ -20,7 +20,7 @@
#include <info.h>
#include <memtrack.h>
#define NDEBUG
//#define NDEBUG
#ifndef NDEBUG
DWORD DebugTraceLevel = 0x7fffffff;
@ -208,7 +208,9 @@ CP
/* XXX This should probably be done in IoCreateFile() */
/* Parameter checks */
Address = (PTA_IP_ADDRESS)(EaInfo->EaName + EaInfo->EaNameLength + 1); //0-term
if ((EaInfo->EaValueLength < sizeof(TA_IP_ADDRESS)) ||
(Address->TAAddressCount != 1) ||
(Address->Address[0].AddressLength < TDI_ADDRESS_LENGTH_IP) ||
@ -227,6 +229,7 @@ CP
CP
/* Open address file object */
/* Protocol depends on device object so find the protocol */
if (DeviceObject == TCPDeviceObject)
Protocol = IPPROTO_TCP;

View file

@ -5,6 +5,7 @@
#include <memtrack.h>
#ifdef MEMTRACK
LIST_ENTRY AllocatedObjectsList;
KSPIN_LOCK AllocatedObjectsLock;
DWORD TagsToShow[MEMTRACK_MAX_TAGS_TO_TRACK] = { 0 };

View file

@ -15,11 +15,12 @@
#include <prefix.h>
#include <ip.h>
#include <route.h>
#include <tilists.h>
TDI_STATUS InfoTdiQueryGetAddrTable( PNDIS_BUFFER Buffer,
PUINT BufferSize ) {
PIP_INTERFACE CurrentIF;
PLIST_ENTRY CurrentIFEntry;
IF_LIST_ITER(CurrentIF);
TDI_STATUS Status = TDI_INVALID_REQUEST;
KIRQL OldIrql;
UINT Count = 1; /* Start adapter indices at 1 */
@ -32,11 +33,7 @@ TDI_STATUS InfoTdiQueryGetAddrTable( PNDIS_BUFFER Buffer,
KeAcquireSpinLock(&InterfaceListLock, &OldIrql);
CurrentIFEntry = InterfaceListHead.Flink;
while (CurrentIFEntry != &InterfaceListHead)
{
CurrentIF = CONTAINING_RECORD(CurrentIFEntry, IP_INTERFACE, ListEntry);
ForEachInterface(CurrentIF) {
IpCurrent->Index = Count;
IpCurrent->Addr = 0;
IpCurrent->BcastAddr = 0;
@ -53,9 +50,8 @@ TDI_STATUS InfoTdiQueryGetAddrTable( PNDIS_BUFFER Buffer,
ADE_ADDRMASK,
&IpAddress->Mask );
IpCurrent++;
CurrentIFEntry = CurrentIFEntry->Flink;
Count++;
}
} EndFor(CurrentIF);
KeReleaseSpinLock(&InterfaceListLock, OldIrql);
@ -155,8 +151,7 @@ TDI_STATUS InfoTdiQueryGetRouteTable( PNDIS_BUFFER Buffer, PUINT BufferSize ) {
TDI_STATUS InfoTdiQueryGetIPSnmpInfo( PNDIS_BUFFER Buffer,
PUINT BufferSize ) {
KIRQL OldIrql;
PIP_INTERFACE CurrentIF;
PLIST_ENTRY CurrentIFEntry;
IF_LIST_ITER(CurrentIF);
IPSNMP_INFO SnmpInfo;
UINT IfCount = CountInterfaces();
UINT AddrCount = 0;
@ -171,13 +166,10 @@ TDI_STATUS InfoTdiQueryGetIPSnmpInfo( PNDIS_BUFFER Buffer,
AddrCount = 0;
KeAcquireSpinLock(&InterfaceListLock, &OldIrql);
CurrentIFEntry = InterfaceListHead.Flink;
while (CurrentIFEntry != &InterfaceListHead)
{
ForEachInterface(CurrentIF) {
CurrentIF = CONTAINING_RECORD(CurrentIFEntry, IP_INTERFACE, ListEntry);
AddrCount += CountInterfaceAddresses( CurrentIF );
CurrentIFEntry = CurrentIFEntry->Flink;
}
} EndFor(CurrentIF);
KeReleaseSpinLock(&InterfaceListLock, OldIrql);