mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 20:43:00 +00:00
Create a branch for network fixes.
svn path=/branches/aicom-network-fixes/; revision=34994
This commit is contained in:
parent
0e213bbc00
commit
c501d8112c
18148 changed files with 0 additions and 860488 deletions
83
drivers/network/tcpip/include/address.h
Normal file
83
drivers/network/tcpip/include/address.h
Normal file
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS TCP/IP protocol driver
|
||||
* FILE: include/address.h
|
||||
* PURPOSE: Address manipulation prototypes
|
||||
*/
|
||||
#ifndef __ADDRESS_H
|
||||
#define __ADDRESS_H
|
||||
|
||||
/*
|
||||
* Initialize an IPv4 style address
|
||||
* VOID AddrInitIPv4(
|
||||
* PIP_ADDRESS IPAddress,
|
||||
* IPv4_RAW_ADDRESS RawAddress)
|
||||
*/
|
||||
#define AddrInitIPv4(IPAddress, RawAddress) \
|
||||
{ \
|
||||
INIT_TAG((IPAddress), TAG('I','P','V','4')); \
|
||||
(IPAddress)->Type = IP_ADDRESS_V4; \
|
||||
(IPAddress)->Address.IPv4Address = (RawAddress); \
|
||||
}
|
||||
|
||||
#ifdef DBG
|
||||
|
||||
PCHAR A2S(
|
||||
PIP_ADDRESS Address);
|
||||
|
||||
#endif /* DBG */
|
||||
|
||||
VOID IPAddressFree(
|
||||
PVOID Object);
|
||||
|
||||
BOOLEAN AddrIsUnspecified(
|
||||
PIP_ADDRESS Address);
|
||||
|
||||
NTSTATUS AddrGetAddress(
|
||||
PTRANSPORT_ADDRESS AddrList,
|
||||
PIP_ADDRESS Address,
|
||||
PUSHORT Port);
|
||||
|
||||
NTSTATUS AddrBuildAddress(
|
||||
PTRANSPORT_ADDRESS TdiAddress,
|
||||
PIP_ADDRESS Address,
|
||||
PUSHORT Port);
|
||||
|
||||
BOOLEAN AddrIsEqual(
|
||||
PIP_ADDRESS Address1,
|
||||
PIP_ADDRESS Address2);
|
||||
|
||||
INT AddrCompare(
|
||||
PIP_ADDRESS Address1,
|
||||
PIP_ADDRESS Address2);
|
||||
|
||||
BOOLEAN AddrIsEqualIPv4(
|
||||
PIP_ADDRESS Address1,
|
||||
IPv4_RAW_ADDRESS Address2);
|
||||
|
||||
BOOLEAN AddrLocateADEv4(
|
||||
IPv4_RAW_ADDRESS MatchAddress, PIP_ADDRESS Address);
|
||||
|
||||
BOOLEAN IPGetDefaultAddress( PIP_ADDRESS Address );
|
||||
|
||||
PADDRESS_FILE AddrSearchFirst(
|
||||
PIP_ADDRESS Address,
|
||||
USHORT Port,
|
||||
USHORT Protocol,
|
||||
PAF_SEARCH SearchContext);
|
||||
|
||||
PADDRESS_FILE AddrSearchNext(
|
||||
PAF_SEARCH SearchContext);
|
||||
|
||||
unsigned long PASCAL inet_addr(const char*);
|
||||
|
||||
ULONG IPv4NToHl( ULONG Address );
|
||||
|
||||
UINT AddrCountPrefixBits( PIP_ADDRESS Netmask );
|
||||
|
||||
VOID AddrWidenAddress( PIP_ADDRESS Network, PIP_ADDRESS Source,
|
||||
PIP_ADDRESS Netmask );
|
||||
|
||||
#endif /* __ADDRESS_H */
|
||||
|
||||
/* EOF */
|
35
drivers/network/tcpip/include/arp.h
Normal file
35
drivers/network/tcpip/include/arp.h
Normal file
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS TCP/IP protocol driver
|
||||
* FILE: include/arp.h
|
||||
* PURPOSE: Address Resolution Protocol definitions
|
||||
*/
|
||||
#ifndef __ARP_H
|
||||
#define __ARP_H
|
||||
|
||||
typedef struct ARP_HEADER {
|
||||
USHORT HWType; /* Hardware Type */
|
||||
USHORT ProtoType; /* Protocol Type */
|
||||
UCHAR HWAddrLen; /* Hardware Address Length */
|
||||
UCHAR ProtoAddrLen; /* Protocol Address Length */
|
||||
USHORT Opcode; /* Opcode */
|
||||
/* Sender's Hardware Address */
|
||||
/* Sender's Protocol Address */
|
||||
/* Target's Hardware Address */
|
||||
/* Target's Protocol Address */
|
||||
} ARP_HEADER, *PARP_HEADER;
|
||||
|
||||
/* We swap constants so we can compare values at runtime without swapping them */
|
||||
#define ARP_OPCODE_REQUEST WH2N(0x0001) /* ARP request */
|
||||
#define ARP_OPCODE_REPLY WH2N(0x0002) /* ARP reply */
|
||||
|
||||
|
||||
BOOLEAN ARPTransmit(PIP_ADDRESS Address, PIP_INTERFACE Interface);
|
||||
|
||||
VOID ARPReceive(
|
||||
PVOID Context,
|
||||
PIP_PACKET Packet);
|
||||
|
||||
#endif /* __ARP_H */
|
||||
|
||||
/* EOF */
|
6
drivers/network/tcpip/include/bug.h
Normal file
6
drivers/network/tcpip/include/bug.h
Normal file
|
@ -0,0 +1,6 @@
|
|||
#ifndef _TCPIP_BUG_H
|
||||
#define _TCPIP_BUG_H
|
||||
|
||||
VOID TcpipBugCheck( ULONG BugCode );
|
||||
|
||||
#endif/*_TCPIP_BUG_H*/
|
46
drivers/network/tcpip/include/checksum.h
Normal file
46
drivers/network/tcpip/include/checksum.h
Normal file
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS TCP/IP protocol driver
|
||||
* FILE: include/checksum.h
|
||||
* PURPOSE: Checksum routine definitions
|
||||
*/
|
||||
#ifndef __CHECKSUM_H
|
||||
#define __CHECKSUM_H
|
||||
|
||||
|
||||
ULONG ChecksumFold(
|
||||
ULONG Sum);
|
||||
|
||||
ULONG ChecksumCompute(
|
||||
PVOID Data,
|
||||
UINT Count,
|
||||
ULONG Seed);
|
||||
|
||||
unsigned int
|
||||
csum_partial(
|
||||
const unsigned char * buff,
|
||||
int len,
|
||||
unsigned int sum);
|
||||
|
||||
#define IPv4Checksum(Data, Count, Seed)(~ChecksumFold(ChecksumCompute(Data, Count, Seed)))
|
||||
#define TCPv4Checksum(Data, Count, Seed)(~ChecksumFold(csum_partial(Data, Count, Seed)))
|
||||
//#define TCPv4Checksum(Data, Count, Seed)(~ChecksumFold(ChecksumCompute(Data, Count, Seed)))
|
||||
|
||||
/*
|
||||
* Macro to check for a correct checksum
|
||||
* BOOLEAN IPv4CorrectChecksum(PVOID Data, UINT Count)
|
||||
*/
|
||||
#define IPv4CorrectChecksum(Data, Count) \
|
||||
(BOOLEAN)(IPv4Checksum(Data, Count, 0) == DH2N(0x0000FFFF))
|
||||
|
||||
/*
|
||||
* Macro to check for a correct checksum
|
||||
* BOOLEAN TCPv4CorrectChecksum(PTCPv4_PSEUDO_HEADER TcpPseudoHeader,
|
||||
* PVOID Data, UINT Count)
|
||||
*/
|
||||
#define TCPv4CorrectChecksum(TcpPseudoHeader, Data, Count) \
|
||||
(BOOLEAN)(TCPv4Checksum(Data, Count, \
|
||||
TCPv4Checksum(TcpPseudoHeader, sizeof(TCPv4_PSEUDO_HEADER), \
|
||||
0)) == DH2N(0x0000FFFF))
|
||||
|
||||
#endif /* __CHECKSUM_H */
|
39
drivers/network/tcpip/include/datagram.h
Normal file
39
drivers/network/tcpip/include/datagram.h
Normal file
|
@ -0,0 +1,39 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS TCP/IP protocol driver
|
||||
* FILE: include/datagram.h
|
||||
* PURPOSE: Datagram types and constants
|
||||
*/
|
||||
#ifndef __DATAGRAM_H
|
||||
#define __DATAGRAM_H
|
||||
|
||||
#include <titypes.h>
|
||||
|
||||
NTSTATUS DGReceiveDatagram(
|
||||
PADDRESS_FILE AddrFile,
|
||||
PTDI_CONNECTION_INFORMATION ConnInfo,
|
||||
PCHAR Buffer,
|
||||
ULONG ReceiveLength,
|
||||
ULONG ReceiveFlags,
|
||||
PTDI_CONNECTION_INFORMATION ReturnInfo,
|
||||
PULONG BytesReceived,
|
||||
PDATAGRAM_COMPLETION_ROUTINE Complete,
|
||||
PVOID Context,
|
||||
PIRP Irp);
|
||||
|
||||
VOID DGRemoveIRP(
|
||||
PADDRESS_FILE AddrFile,
|
||||
PIRP Irp);
|
||||
|
||||
VOID DGDeliverData(
|
||||
PADDRESS_FILE AddrFile,
|
||||
PIP_ADDRESS SrcAddress,
|
||||
PIP_ADDRESS DstAddress,
|
||||
USHORT SrcPort,
|
||||
USHORT DstPort,
|
||||
PIP_PACKET IPPacket,
|
||||
UINT DataSize);
|
||||
|
||||
#endif /* __DATAGRAM_H */
|
||||
|
||||
/* EOF */
|
82
drivers/network/tcpip/include/debug.h
Normal file
82
drivers/network/tcpip/include/debug.h
Normal file
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS TCP/IP protocol driver
|
||||
* FILE: include/debug.h
|
||||
* PURPOSE: Debugging support macros
|
||||
* DEFINES: DBG - Enable debug output
|
||||
* NASSERT - Disable assertions
|
||||
*/
|
||||
#ifndef __DEBUG_H
|
||||
#define __DEBUG_H
|
||||
|
||||
#define MIN_TRACE ((1 << DPFLTR_WARNING_LEVEL))
|
||||
#define MID_TRACE ((1 << DPFLTR_WARNING_LEVEL) | (1 << DPFLTR_TRACE_LEVEL))
|
||||
#define MAX_TRACE ((1 << DPFLTR_WARNING_LEVEL) | (1 << DPFLTR_TRACE_LEVEL) | (1 << DPFLTR_INFO_LEVEL))
|
||||
|
||||
#define DEBUG_CHECK 0x00000100
|
||||
#define DEBUG_MEMORY 0x00000200
|
||||
#define DEBUG_PBUFFER 0x00000400
|
||||
#define DEBUG_IRP 0x00000800
|
||||
#define DEBUG_TCPIF 0x00001000
|
||||
#define DEBUG_ADDRFILE 0x00002000
|
||||
#define DEBUG_DATALINK 0x00004000
|
||||
#define DEBUG_ARP 0x00008000
|
||||
#define DEBUG_IP 0x00010000
|
||||
#define DEBUG_UDP 0x00020000
|
||||
#define DEBUG_TCP 0x00040000
|
||||
#define DEBUG_ICMP 0x00080000
|
||||
#define DEBUG_ROUTER 0x00100000
|
||||
#define DEBUG_RCACHE 0x00200000
|
||||
#define DEBUG_NCACHE 0x00400000
|
||||
#define DEBUG_CPOINT 0x00800000
|
||||
#define DEBUG_LOCK 0x01000000
|
||||
#define DEBUG_INFO 0x02000000
|
||||
#define DEBUG_ULTRA 0x7FFFFFFF
|
||||
|
||||
#ifdef DBG
|
||||
|
||||
#define REMOVE_PARENS(...) __VA_ARGS__
|
||||
#define TI_DbgPrint(_t_, _x_) \
|
||||
DbgPrintEx(DPFLTR_TCPIP_ID, (_t_) | DPFLTR_MASK, "(%s:%d) ", __FILE__, __LINE__), \
|
||||
DbgPrintEx(DPFLTR_TCPIP_ID, (_t_) | DPFLTR_MASK, REMOVE_PARENS _x_)
|
||||
|
||||
#else /* DBG */
|
||||
|
||||
#define TI_DbgPrint(_t_, _x_)
|
||||
|
||||
#endif /* DBG */
|
||||
|
||||
|
||||
#define assert(x) ASSERT(x)
|
||||
#define assert_irql(x) ASSERT_IRQL(x)
|
||||
|
||||
|
||||
#ifdef _MSC_VER
|
||||
|
||||
#define UNIMPLEMENTED \
|
||||
TI_DbgPrint(MIN_TRACE, ("The function at %s:%d is unimplemented, \
|
||||
but come back another day.\n", __FILE__, __LINE__));
|
||||
|
||||
#else /* _MSC_VER */
|
||||
|
||||
#define UNIMPLEMENTED \
|
||||
TI_DbgPrint(MIN_TRACE, ("(%s:%d)(%s) is unimplemented, \
|
||||
but come back another day.\n", __FILE__, __LINE__, __FUNCTION__));
|
||||
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
|
||||
#define CHECKPOINT \
|
||||
do { TI_DbgPrint(DEBUG_CHECK, ("(%s:%d)\n", __FILE__, __LINE__)); } while(0);
|
||||
|
||||
#define CP CHECKPOINT
|
||||
|
||||
#include <memtrack.h>
|
||||
|
||||
#define ASSERT_KM_POINTER(_x) \
|
||||
ASSERT(((PVOID)_x) != (PVOID)0xcccccccc); \
|
||||
ASSERT(((PVOID)_x) >= (PVOID)0x80000000);
|
||||
|
||||
#endif /* __DEBUG_H */
|
||||
|
||||
/* EOF */
|
69
drivers/network/tcpip/include/dispatch.h
Normal file
69
drivers/network/tcpip/include/dispatch.h
Normal file
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS TCP/IP protocol driver
|
||||
* FILE: include/dispatch.h
|
||||
* PURPOSE: Dispatch routine prototypes
|
||||
*/
|
||||
#ifndef __DISPATCH_H
|
||||
#define __DISPATCH_H
|
||||
|
||||
|
||||
NTSTATUS DispTdiAccept(
|
||||
PIRP Irp);
|
||||
|
||||
NTSTATUS DispTdiAssociateAddress(
|
||||
PIRP Irp);
|
||||
|
||||
NTSTATUS DispTdiConnect(
|
||||
PIRP Irp);
|
||||
|
||||
NTSTATUS DispTdiDisassociateAddress(
|
||||
PIRP Irp);
|
||||
|
||||
NTSTATUS DispTdiDisconnect(
|
||||
PIRP Irp);
|
||||
|
||||
NTSTATUS DispTdiListen(
|
||||
PIRP Irp);
|
||||
|
||||
NTSTATUS DispTdiQueryInformation(
|
||||
PDEVICE_OBJECT DeviceObject,
|
||||
PIRP Irp);
|
||||
|
||||
NTSTATUS DispTdiReceive(
|
||||
PIRP Irp);
|
||||
|
||||
NTSTATUS DispTdiReceiveDatagram(
|
||||
PIRP Irp);
|
||||
|
||||
NTSTATUS DispTdiSend(
|
||||
PIRP Irp);
|
||||
|
||||
NTSTATUS DispTdiSendDatagram(
|
||||
PIRP Irp);
|
||||
|
||||
NTSTATUS DispTdiSetEventHandler(
|
||||
PIRP Irp);
|
||||
|
||||
NTSTATUS DispTdiSetInformation(
|
||||
PIRP Irp);
|
||||
|
||||
NTSTATUS DispTdiQueryInformationEx(
|
||||
PIRP Irp,
|
||||
PIO_STACK_LOCATION IrpSp);
|
||||
|
||||
NTSTATUS DispTdiSetInformationEx(
|
||||
PIRP Irp,
|
||||
PIO_STACK_LOCATION IrpSp);
|
||||
|
||||
NTSTATUS DispTdiSetIPAddress(
|
||||
PIRP Irp,
|
||||
PIO_STACK_LOCATION IrpSp);
|
||||
|
||||
NTSTATUS DispTdiDeleteIPAddress(
|
||||
PIRP Irp,
|
||||
PIO_STACK_LOCATION IrpSp);
|
||||
|
||||
#endif /* __DISPATCH_H */
|
||||
|
||||
/* EOF */
|
43
drivers/network/tcpip/include/fileobjs.h
Normal file
43
drivers/network/tcpip/include/fileobjs.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS TCP/IP protocol driver
|
||||
* FILE: include/fileobjs.h
|
||||
* PURPOSE: File object routine prototypes
|
||||
*/
|
||||
#ifndef __FILEOBJS_H
|
||||
#define __FILEOBJS_H
|
||||
|
||||
|
||||
extern LIST_ENTRY AddressFileListHead;
|
||||
extern KSPIN_LOCK AddressFileListLock;
|
||||
extern LIST_ENTRY ConnectionEndpointListHead;
|
||||
extern KSPIN_LOCK ConnectionEndpointListLock;
|
||||
|
||||
|
||||
NTSTATUS FileOpenAddress(
|
||||
PTDI_REQUEST Request,
|
||||
PTA_IP_ADDRESS AddrList,
|
||||
USHORT Protocol,
|
||||
PVOID Options);
|
||||
|
||||
NTSTATUS FileCloseAddress(
|
||||
PTDI_REQUEST Request);
|
||||
|
||||
NTSTATUS FileOpenConnection(
|
||||
PTDI_REQUEST Request,
|
||||
PVOID ClientContext);
|
||||
|
||||
PCONNECTION_ENDPOINT FileFindConnectionByContext( PVOID Context );
|
||||
|
||||
NTSTATUS FileCloseConnection(
|
||||
PTDI_REQUEST Request);
|
||||
|
||||
NTSTATUS FileOpenControlChannel(
|
||||
PTDI_REQUEST Request);
|
||||
|
||||
NTSTATUS FileCloseControlChannel(
|
||||
PTDI_REQUEST Request);
|
||||
|
||||
#endif /* __FILEOBJS_H */
|
||||
|
||||
/* EOF */
|
69
drivers/network/tcpip/include/icmp.h
Normal file
69
drivers/network/tcpip/include/icmp.h
Normal file
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS TCP/IP protocol driver
|
||||
* FILE: include/icmp.h
|
||||
* PURPOSE: Internet Control Message Protocol definitions
|
||||
*/
|
||||
#ifndef __ICMP_H
|
||||
#define __ICMP_H
|
||||
|
||||
typedef struct ICMP_HEADER {
|
||||
UCHAR Type; /* ICMP message type */
|
||||
UCHAR Code; /* ICMP message code */
|
||||
USHORT Checksum; /* ICMP message checksum */
|
||||
ULONG Unused; /* ICMP unused */
|
||||
} ICMP_HEADER, *PICMP_HEADER;
|
||||
|
||||
/* ICMP message types */
|
||||
#define ICMP_TYPE_ECHO_REPLY 0 /* Echo reply */
|
||||
#define ICMP_TYPE_DEST_UNREACH 3 /* Destination unreachable */
|
||||
#define ICMP_TYPE_SOURCE_QUENCH 4 /* Source quench */
|
||||
#define ICMP_TYPE_REDIRECT 5 /* Redirect */
|
||||
#define ICMP_TYPE_ECHO_REQUEST 8 /* Echo request */
|
||||
#define ICMP_TYPE_TIME_EXCEEDED 11 /* Time exceeded */
|
||||
#define ICMP_TYPE_PARAMETER 12 /* Parameter problem */
|
||||
#define ICMP_TYPE_TIMESTAMP_REQUEST 13 /* Timestamp request */
|
||||
#define ICMP_TYPE_TIMESTAMP_REPLY 14 /* Timestamp reply */
|
||||
#define ICMP_TYPE_INFO_REQUEST 15 /* Information request */
|
||||
#define ICMP_TYPE_INFO_REPLY 16 /* Information reply */
|
||||
|
||||
/* ICMP codes for ICMP_TYPE_DEST_UNREACH */
|
||||
#define ICMP_CODE_DU_NET_UNREACH 0 /* Network unreachable */
|
||||
#define ICMP_CODE_DU_HOST_UNREACH 1 /* Host unreachable */
|
||||
#define ICMP_CODE_DU_PROTOCOL_UNREACH 2 /* Protocol unreachable */
|
||||
#define ICMP_CODE_DU_PORT_UNREACH 3 /* Port unreachable */
|
||||
#define ICMP_CODE_DU_FRAG_DF_SET 4 /* Fragmentation needed and DF set */
|
||||
#define ICMP_CODE_DU_SOURCE_ROUTE_FAILED 5 /* Source route failed */
|
||||
|
||||
/* ICMP codes for ICMP_TYPE_REDIRECT */
|
||||
#define ICMP_CODE_RD_NET 0 /* Redirect datagrams for the network */
|
||||
#define ICMP_CODE_RD_HOST 1 /* Redirect datagrams for the host */
|
||||
#define ICMP_CODE_RD_TOS_NET 2 /* Redirect datagrams for the Type of Service and network */
|
||||
#define ICMP_CODE_RD_TOS_HOST 3 /* Redirect datagrams for the Type of Service and host */
|
||||
|
||||
/* ICMP codes for ICMP_TYPE_TIME_EXCEEDED */
|
||||
#define ICMP_CODE_TE_TTL 0 /* Time to live exceeded in transit */
|
||||
#define ICMP_CODE_TE_REASSEMBLY 1 /* Fragment reassembly time exceeded */
|
||||
|
||||
/* ICMP codes for ICMP_TYPE_PARAMETER */
|
||||
#define ICMP_CODE_TP_POINTER 1 /* Pointer indicates the error */
|
||||
|
||||
|
||||
VOID ICMPReceive(
|
||||
PIP_INTERFACE Interface,
|
||||
PIP_PACKET IPPacket);
|
||||
|
||||
VOID ICMPTransmit(
|
||||
PIP_PACKET IPPacket,
|
||||
PIP_TRANSMIT_COMPLETE Complete,
|
||||
PVOID Context);
|
||||
|
||||
VOID ICMPReply(
|
||||
PIP_INTERFACE Interface,
|
||||
PIP_PACKET IPPacket,
|
||||
UCHAR Type,
|
||||
UCHAR Code);
|
||||
|
||||
#endif /* __ICMP_H */
|
||||
|
||||
/* EOF */
|
215
drivers/network/tcpip/include/info.h
Normal file
215
drivers/network/tcpip/include/info.h
Normal file
|
@ -0,0 +1,215 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS TCP/IP protocol driver
|
||||
* FILE: include/info.h
|
||||
* PURPOSE: TdiQueryInformation definitions
|
||||
*/
|
||||
#ifndef __INFO_H
|
||||
#define __INFO_H
|
||||
|
||||
#define MAX_PHYSADDR_LEN 8
|
||||
#define MAX_IFDESCR_LEN 256
|
||||
|
||||
typedef struct IPSNMP_INFO {
|
||||
ULONG Forwarding;
|
||||
ULONG DefaultTTL;
|
||||
ULONG InReceives;
|
||||
ULONG InHdrErrors;
|
||||
ULONG InAddrErrors;
|
||||
ULONG ForwDatagrams;
|
||||
ULONG InUnknownProtos;
|
||||
ULONG InDiscards;
|
||||
ULONG InDelivers;
|
||||
ULONG OutRequests;
|
||||
ULONG RoutingDiscards;
|
||||
ULONG OutDiscards;
|
||||
ULONG OutNoRoutes;
|
||||
ULONG ReasmTimeout;
|
||||
ULONG ReasmReqds;
|
||||
ULONG ReasmOks;
|
||||
ULONG ReasmFails;
|
||||
ULONG FragOks;
|
||||
ULONG FragFails;
|
||||
ULONG FragCreates;
|
||||
ULONG NumIf;
|
||||
ULONG NumAddr;
|
||||
ULONG NumRoutes;
|
||||
} IPSNMP_INFO, *PIPSNMP_INFO;
|
||||
|
||||
typedef struct IPADDR_ENTRY {
|
||||
ULONG Addr;
|
||||
ULONG Index;
|
||||
ULONG Mask;
|
||||
ULONG BcastAddr;
|
||||
ULONG ReasmSize;
|
||||
USHORT Context;
|
||||
USHORT Pad;
|
||||
} IPADDR_ENTRY, *PIPADDR_ENTRY;
|
||||
|
||||
#define ARP_ENTRY_STATIC 4
|
||||
#define ARP_ENTRY_DYNAMIC 3
|
||||
#define ARP_ENTRY_INVALID 2
|
||||
#define ARP_ENTRY_OTHER 1
|
||||
|
||||
typedef struct IPARP_ENTRY {
|
||||
ULONG Index;
|
||||
ULONG AddrSize;
|
||||
UCHAR PhysAddr[8];
|
||||
ULONG LogAddr;
|
||||
ULONG Type;
|
||||
} IPARP_ENTRY, *PIPARP_ENTRY;
|
||||
|
||||
typedef struct IPROUTE_ENTRY {
|
||||
ULONG Dest;
|
||||
ULONG Index; //matches if_index in IFEntry and iae_index in IPAddrEntry
|
||||
ULONG Metric1;
|
||||
ULONG Metric2;
|
||||
ULONG Metric3;
|
||||
ULONG Metric4;
|
||||
ULONG Gw;
|
||||
ULONG Type;
|
||||
ULONG Proto;
|
||||
ULONG Age;
|
||||
ULONG Mask;
|
||||
ULONG Metric5;
|
||||
ULONG Info;
|
||||
} IPROUTE_ENTRY, *PIPROUTE_ENTRY;
|
||||
|
||||
typedef struct IFENTRY {
|
||||
ULONG Index;
|
||||
ULONG Type;
|
||||
ULONG Mtu;
|
||||
ULONG Speed;
|
||||
ULONG PhysAddrLen;
|
||||
UCHAR PhysAddr[MAX_PHYSADDR_LEN];
|
||||
ULONG AdminStatus;
|
||||
ULONG OperStatus;
|
||||
ULONG LastChange;
|
||||
ULONG InOctets;
|
||||
ULONG InUcastPackets;
|
||||
ULONG InNUcastPackets;
|
||||
ULONG InDiscards;
|
||||
ULONG InErrors;
|
||||
ULONG InUnknownProtos;
|
||||
ULONG OutOctets;
|
||||
ULONG OutUcastPackets;
|
||||
ULONG OutNUcastPackets;
|
||||
ULONG OutDiscards;
|
||||
ULONG OutErrors;
|
||||
ULONG OutQLen;
|
||||
ULONG DescrLen;
|
||||
} IFENTRY, *PIFENTRY;
|
||||
|
||||
#define IP_MIB_STATS_ID 1
|
||||
#define IF_MIB_STATS_ID 1
|
||||
|
||||
#ifndef IP_MIB_ROUTETABLE_ENTRY_ID
|
||||
#define IP_MIB_ROUTETABLE_ENTRY_ID 0x101
|
||||
#endif
|
||||
#ifndef IP_MIB_ADDRTABLE_ENTRY_ID
|
||||
#define IP_MIB_ADDRTABLE_ENTRY_ID 0x102
|
||||
#endif
|
||||
#ifndef IP_MIB_ARPTABLE_ENTRY_ID
|
||||
#define IP_MIB_ARPTABLE_ENTRY_ID 0x101
|
||||
#endif
|
||||
#ifndef MAX_PHYSADDR_SIZE
|
||||
#define MAX_PHYSADDR_SIZE 8
|
||||
#endif
|
||||
|
||||
|
||||
/* Only UDP is supported */
|
||||
#define TDI_SERVICE_FLAGS (TDI_SERVICE_CONNECTIONLESS_MODE | \
|
||||
TDI_SERVICE_BROADCAST_SUPPORTED)
|
||||
|
||||
#define TCP_MIB_STAT_ID 1
|
||||
#define UDP_MIB_STAT_ID 1
|
||||
#define TCP_MIB_TABLE_ID 0x101
|
||||
#define UDP_MIB_TABLE_ID 0x101
|
||||
|
||||
#define TL_INSTANCE 0
|
||||
|
||||
|
||||
typedef struct ADDRESS_INFO {
|
||||
ULONG LocalAddress;
|
||||
ULONG LocalPort;
|
||||
} ADDRESS_INFO, *PADDRESS_INFO;
|
||||
|
||||
typedef union TDI_INFO {
|
||||
TDI_CONNECTION_INFO ConnInfo;
|
||||
TDI_ADDRESS_INFO AddrInfo;
|
||||
TDI_PROVIDER_INFO ProviderInfo;
|
||||
TDI_PROVIDER_STATISTICS ProviderStats;
|
||||
} TDI_INFO, *PTDI_INFO;
|
||||
|
||||
TDI_STATUS InfoCopyOut( PCHAR DataOut, UINT SizeOut,
|
||||
PNDIS_BUFFER ClientBuf, PUINT ClientBufSize );
|
||||
|
||||
TDI_STATUS InfoTdiQueryInformationEx(
|
||||
PTDI_REQUEST Request,
|
||||
TDIObjectID *ID,
|
||||
PNDIS_BUFFER Buffer,
|
||||
PUINT BufferSize,
|
||||
PVOID Context);
|
||||
|
||||
TDI_STATUS InfoTdiSetInformationEx(
|
||||
PTDI_REQUEST Request,
|
||||
TDIObjectID *ID,
|
||||
PVOID Buffer,
|
||||
UINT BufferSize);
|
||||
|
||||
/* Network layer info functions */
|
||||
TDI_STATUS InfoNetworkLayerTdiQueryEx( UINT InfoClass,
|
||||
UINT InfoType,
|
||||
UINT InfoId,
|
||||
PVOID Context,
|
||||
TDIEntityID *id,
|
||||
PNDIS_BUFFER Buffer,
|
||||
PUINT BufferSize );
|
||||
|
||||
TDI_STATUS InfoNetworkLayerTdiSetEx( UINT InfoClass,
|
||||
UINT InfoType,
|
||||
UINT InfoId,
|
||||
PVOID Context,
|
||||
TDIEntityID *id,
|
||||
PCHAR Buffer,
|
||||
UINT BufferSize );
|
||||
|
||||
TDI_STATUS InfoTransportLayerTdiQueryEx( UINT InfoClass,
|
||||
UINT InfoType,
|
||||
UINT InfoId,
|
||||
PVOID Context,
|
||||
TDIEntityID *id,
|
||||
PNDIS_BUFFER Buffer,
|
||||
PUINT BufferSize );
|
||||
|
||||
TDI_STATUS InfoTransportLayerTdiSetEx( UINT InfoClass,
|
||||
UINT InfoType,
|
||||
UINT InfoId,
|
||||
PVOID Context,
|
||||
TDIEntityID *id,
|
||||
PCHAR Buffer,
|
||||
UINT BufferSize );
|
||||
|
||||
TDI_STATUS InfoInterfaceTdiQueryEx( UINT InfoClass,
|
||||
UINT InfoType,
|
||||
UINT InfoId,
|
||||
PVOID Context,
|
||||
TDIEntityID *id,
|
||||
PNDIS_BUFFER Buffer,
|
||||
PUINT BufferSize );
|
||||
|
||||
TDI_STATUS InfoInterfaceTdiSetEx( UINT InfoClass,
|
||||
UINT InfoType,
|
||||
UINT InfoId,
|
||||
PVOID Context,
|
||||
TDIEntityID *id,
|
||||
PCHAR Buffer,
|
||||
UINT BufferSize );
|
||||
|
||||
/* Insert and remove interface entities */
|
||||
VOID InsertTDIInterfaceEntity( PIP_INTERFACE Interface );
|
||||
VOID RemoveTDIInterfaceEntity( PIP_INTERFACE Interface );
|
||||
|
||||
#endif /* __INFO_H */
|
||||
|
||||
/* EOF */
|
20
drivers/network/tcpip/include/interface.h
Normal file
20
drivers/network/tcpip/include/interface.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef _TCPIP_INTERFACE_H
|
||||
#define _TCPIP_INTERFACE_H
|
||||
|
||||
#include <ip.h>
|
||||
|
||||
#define IFENT_SOFTWARE_LOOPBACK 24 /* This is an SNMP constant from rfc1213 */
|
||||
|
||||
NTSTATUS GetInterfaceIPv4Address( PIP_INTERFACE Interface,
|
||||
ULONG Type,
|
||||
PULONG Address );
|
||||
UINT CountInterfaces();
|
||||
UINT CountInterfaceAddresses( PIP_INTERFACE Interface );
|
||||
NTSTATUS GetInterfaceSpeed( PIP_INTERFACE Interface, PUINT Speed );
|
||||
NTSTATUS GetInterfaceName( PIP_INTERFACE Interface, PCHAR NameBuffer,
|
||||
UINT NameMaxLen );
|
||||
NTSTATUS GetInterfaceConnectionStatus( PIP_INTERFACE Interface,
|
||||
PDWORD OperStatus );
|
||||
PIP_INTERFACE FindOnLinkInterface(PIP_ADDRESS Address);
|
||||
|
||||
#endif//_TCPIP_INTERFACE_H
|
244
drivers/network/tcpip/include/ip.h
Normal file
244
drivers/network/tcpip/include/ip.h
Normal file
|
@ -0,0 +1,244 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS TCP/IP protocol driver
|
||||
* FILE: include/ip.h
|
||||
* PURPOSE: Internet Protocol related definitions
|
||||
*/
|
||||
#ifndef __IP_H
|
||||
#define __IP_H
|
||||
|
||||
typedef VOID (*OBJECT_FREE_ROUTINE)(PVOID Object);
|
||||
|
||||
#define FOURCC(a,b,c,d) (((a)<<24)|((b)<<16)|((c)<<8)|(d))
|
||||
|
||||
/* Raw IPv4 style address */
|
||||
typedef ULONG IPv4_RAW_ADDRESS;
|
||||
typedef IPv4_RAW_ADDRESS *PIPv4_RAW_ADDRESS;
|
||||
|
||||
/* Raw IPv6 style address */
|
||||
typedef USHORT IPv6_RAW_ADDRESS[8];
|
||||
typedef IPv6_RAW_ADDRESS *PIPv6_RAW_ADDRESS;
|
||||
|
||||
/* IP style address */
|
||||
typedef struct IP_ADDRESS {
|
||||
DEFINE_TAG
|
||||
UCHAR Type; /* Type of IP address */
|
||||
union {
|
||||
IPv4_RAW_ADDRESS IPv4Address;/* IPv4 address (in network byte order) */
|
||||
IPv6_RAW_ADDRESS IPv6Address;/* IPv6 address (in network byte order) */
|
||||
} Address;
|
||||
} IP_ADDRESS, *PIP_ADDRESS;
|
||||
|
||||
/* IP type constants */
|
||||
#define IP_ADDRESS_V4 0x04 /* IPv4 style address */
|
||||
#define IP_ADDRESS_V6 0x06 /* IPv6 style address */
|
||||
|
||||
|
||||
/* IPv4 header format */
|
||||
typedef struct IPv4_HEADER {
|
||||
UCHAR VerIHL; /* 4-bit version, 4-bit Internet Header Length */
|
||||
UCHAR Tos; /* Type of Service */
|
||||
USHORT TotalLength; /* Total Length */
|
||||
USHORT Id; /* Identification */
|
||||
USHORT FlagsFragOfs; /* 3-bit Flags, 13-bit Fragment Offset */
|
||||
UCHAR Ttl; /* Time to Live */
|
||||
UCHAR Protocol; /* Protocol */
|
||||
USHORT Checksum; /* Header Checksum */
|
||||
IPv4_RAW_ADDRESS SrcAddr; /* Source Address */
|
||||
IPv4_RAW_ADDRESS DstAddr; /* Destination Address */
|
||||
} IPv4_HEADER, *PIPv4_HEADER;
|
||||
|
||||
/* IPv6 header format */
|
||||
typedef struct IPv6_HEADER {
|
||||
ULONG VTF; /* Version, Traffic Class, Flow Label */
|
||||
USHORT PayloadLength;
|
||||
UCHAR NextHeader; /* Same as Protocol in IPv4 */
|
||||
UCHAR HopLimit; /* Same as Ttl in IPv4 */
|
||||
IPv6_RAW_ADDRESS SrcAddr;
|
||||
IPv6_RAW_ADDRESS DstAddr;
|
||||
} IPv6_HEADER, *PIPv6_HEADER;
|
||||
|
||||
typedef union _IP_HEADER {
|
||||
IPv4_HEADER v4;
|
||||
IPv6_HEADER v6;
|
||||
} IP_HEADER, *PIP_HEADER;
|
||||
|
||||
#define IPv4_FRAGOFS_MASK 0x1FFF /* Fragment offset mask (host byte order) */
|
||||
#define IPv4_MF_MASK 0x2000 /* More fragments (host byte order) */
|
||||
#define IPv4_DF_MASK 0x4000 /* Don't fragment (host byte order) */
|
||||
#define IPv4_MAX_HEADER_SIZE 60
|
||||
|
||||
/* Packet completion handler prototype */
|
||||
typedef VOID (*PACKET_COMPLETION_ROUTINE)(
|
||||
PVOID Context,
|
||||
PNDIS_PACKET NdisPacket,
|
||||
NDIS_STATUS NdisStatus);
|
||||
|
||||
/* Structure for an IP packet */
|
||||
typedef struct _IP_PACKET {
|
||||
DEFINE_TAG
|
||||
OBJECT_FREE_ROUTINE Free; /* Routine used to free resources for the object */
|
||||
UCHAR Type; /* Type of IP packet (see IP_ADDRESS_xx above) */
|
||||
UCHAR Flags; /* Flags for packet (see IP_PACKET_FLAG_xx below)*/
|
||||
PVOID Header; /* Pointer to IP header for this packet */
|
||||
UINT HeaderSize; /* Size of IP header */
|
||||
PVOID Data; /* Current pointer into packet data */
|
||||
UINT TotalSize; /* Total amount of data in packet (IP header and data) */
|
||||
UINT ContigSize; /* Number of contiguous bytes left in current buffer */
|
||||
UINT Position; /* Current logical offset into packet */
|
||||
PNDIS_PACKET NdisPacket; /* Pointer to NDIS packet */
|
||||
IP_ADDRESS SrcAddr; /* Source address */
|
||||
IP_ADDRESS DstAddr; /* Destination address */
|
||||
} IP_PACKET, *PIP_PACKET;
|
||||
|
||||
#define IP_PACKET_FLAG_RAW 0x01 /* Raw IP packet */
|
||||
|
||||
|
||||
/* Packet context */
|
||||
typedef struct _PACKET_CONTEXT {
|
||||
PACKET_COMPLETION_ROUTINE DLComplete; /* Data link level completion handler
|
||||
* Also used to link to next packet
|
||||
* in a queue */
|
||||
PVOID Context; /* Context information for handler */
|
||||
UINT PacketType; /* Type of packet */
|
||||
} PACKET_CONTEXT, *PPACKET_CONTEXT;
|
||||
|
||||
/* The ProtocolReserved field is structured as a PACKET_CONTEXT */
|
||||
#define PC(Packet) ((PPACKET_CONTEXT)(&Packet->ProtocolReserved))
|
||||
|
||||
/* Values for address type -- also the interface flags */
|
||||
/* These values are mean to overlap meaningfully with the BSD ones */
|
||||
#define ADE_UNICAST 0x01
|
||||
#define ADE_BROADCAST 0x02
|
||||
#define ADE_ADDRMASK 0x04
|
||||
#define ADE_POINTOPOINT 0x10
|
||||
#define ADE_MULTICAST 0x8000
|
||||
|
||||
/* There is one NTE for each source (unicast) address assigned to an interface */
|
||||
/* Link layer transmit prototype */
|
||||
typedef VOID (*LL_TRANSMIT_ROUTINE)(
|
||||
PVOID Context,
|
||||
PNDIS_PACKET NdisPacket,
|
||||
UINT Offset,
|
||||
PVOID LinkAddress,
|
||||
USHORT Type);
|
||||
|
||||
/* Link layer to IP binding information */
|
||||
typedef struct _LLIP_BIND_INFO {
|
||||
PVOID Context; /* Pointer to link layer context information */
|
||||
UINT HeaderSize; /* Size of link level header */
|
||||
UINT MinFrameSize; /* Minimum frame size in bytes */
|
||||
UINT MTU; /* Maximum transmission unit */
|
||||
PUCHAR Address; /* Pointer to interface address */
|
||||
UINT AddressLength; /* Length of address in bytes */
|
||||
LL_TRANSMIT_ROUTINE Transmit; /* Transmit function for this interface */
|
||||
} LLIP_BIND_INFO, *PLLIP_BIND_INFO;
|
||||
|
||||
|
||||
/* Information about an IP interface */
|
||||
typedef struct _IP_INTERFACE {
|
||||
DEFINE_TAG
|
||||
LIST_ENTRY ListEntry; /* Entry on list */
|
||||
OBJECT_FREE_ROUTINE Free; /* Routine used to free resources used by the object */
|
||||
KSPIN_LOCK Lock; /* Spin lock for this object */
|
||||
PVOID Context; /* Pointer to link layer context information */
|
||||
UINT HeaderSize; /* Size of link level header */
|
||||
UINT MinFrameSize; /* Minimum frame size in bytes */
|
||||
UINT MTU; /* Maximum transmission unit */
|
||||
UINT Speed; /* Link speed */
|
||||
IP_ADDRESS Unicast; /* Unicast address */
|
||||
IP_ADDRESS PointToPoint; /* Point to point address */
|
||||
IP_ADDRESS Netmask; /* Netmask */
|
||||
IP_ADDRESS Broadcast; /* Broadcast */
|
||||
UNICODE_STRING Name; /* Adapter name (GUID) */
|
||||
UNICODE_STRING Description; /* Adapter description (Human readable) */
|
||||
PUCHAR Address; /* Pointer to interface address */
|
||||
UINT AddressLength; /* Length of address in bytes */
|
||||
UINT Index; /* Index of adapter (used to add ip addr) */
|
||||
LL_TRANSMIT_ROUTINE Transmit; /* Pointer to transmit function */
|
||||
PVOID TCPContext; /* TCP Content for this interface */
|
||||
} IP_INTERFACE, *PIP_INTERFACE;
|
||||
|
||||
typedef struct _IP_SET_ADDRESS {
|
||||
ULONG NteIndex;
|
||||
IPv4_RAW_ADDRESS Address;
|
||||
IPv4_RAW_ADDRESS Netmask;
|
||||
} IP_SET_ADDRESS, *PIP_SET_ADDRESS;
|
||||
|
||||
#define IP_PROTOCOL_TABLE_SIZE 0x100
|
||||
|
||||
typedef VOID (*IP_PROTOCOL_HANDLER)(
|
||||
PIP_INTERFACE Interface,
|
||||
PIP_PACKET IPPacket);
|
||||
|
||||
/* Loopback adapter address information (network byte order) */
|
||||
#define LOOPBACK_ADDRESS_IPv4 ((IPv4_RAW_ADDRESS)DH2N(0x7F000001))
|
||||
#define LOOPBACK_BCASTADDR_IPv4 ((IPv4_RAW_ADDRESS)DH2N(0x7F0000FF))
|
||||
#define LOOPBACK_ADDRMASK_IPv4 ((IPv4_RAW_ADDRESS)DH2N(0xFFFFFF00))
|
||||
|
||||
/* Protocol definitions */
|
||||
#ifndef IPPROTO_RAW
|
||||
#define IPPROTO_RAW 0 /* Raw IP */
|
||||
#endif
|
||||
#define IPPROTO_ICMP 1 /* Internet Control Message Protocol */
|
||||
#define IPPROTO_IGMP 2 /* Internet Group Management Protocol */
|
||||
#define IPPROTO_TCP 6 /* Transmission Control Protocol */
|
||||
#define IPPROTO_UDP 17 /* User Datagram Protocol */
|
||||
|
||||
/* Timeout timer constants */
|
||||
#define IP_TICKS_SECOND 2 /* Two ticks per second */
|
||||
#define IP_TIMEOUT (1000 / IP_TICKS_SECOND) /* Timeout in milliseconds */
|
||||
#define IP_DEFAULT_LINK_SPEED 10000
|
||||
|
||||
extern LIST_ENTRY InterfaceListHead;
|
||||
extern KSPIN_LOCK InterfaceListLock;
|
||||
extern LIST_ENTRY NetTableListHead;
|
||||
extern KSPIN_LOCK NetTableListLock;
|
||||
extern UINT MaxLLHeaderSize;
|
||||
extern UINT MinLLFrameSize;
|
||||
extern BOOLEAN IpWorkItemQueued;
|
||||
|
||||
PIP_PACKET IPCreatePacket(
|
||||
ULONG Type);
|
||||
|
||||
PIP_PACKET IPInitializePacket(
|
||||
PIP_PACKET IPPacket,
|
||||
ULONG Type);
|
||||
|
||||
PIP_INTERFACE IPCreateInterface(
|
||||
PLLIP_BIND_INFO BindInfo);
|
||||
|
||||
VOID IPAddInterfaceRoute(
|
||||
PIP_INTERFACE IF);
|
||||
|
||||
VOID IPRemoveInterfaceRoute(
|
||||
PIP_INTERFACE IF);
|
||||
|
||||
VOID IPDestroyInterface(
|
||||
PIP_INTERFACE IF);
|
||||
|
||||
BOOLEAN IPRegisterInterface(
|
||||
PIP_INTERFACE IF);
|
||||
|
||||
VOID IPUnregisterInterface(
|
||||
PIP_INTERFACE IF);
|
||||
|
||||
VOID STDCALL IPTimeout( PVOID Context );
|
||||
|
||||
VOID IPDispatchProtocol(
|
||||
PIP_INTERFACE Interface,
|
||||
PIP_PACKET IPPacket);
|
||||
|
||||
VOID IPRegisterProtocol(
|
||||
UINT ProtocolNumber,
|
||||
IP_PROTOCOL_HANDLER Handler);
|
||||
|
||||
NTSTATUS IPStartup(PUNICODE_STRING RegistryPath);
|
||||
|
||||
NTSTATUS IPShutdown(VOID);
|
||||
|
||||
|
||||
|
||||
#endif /* __IP_H */
|
||||
|
||||
/* EOF */
|
19
drivers/network/tcpip/include/irp.h
Normal file
19
drivers/network/tcpip/include/irp.h
Normal file
|
@ -0,0 +1,19 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS TCP/IP protocol driver
|
||||
* FILE: include/irp.h
|
||||
* PURPOSE: IRP routines
|
||||
*/
|
||||
#ifndef __IRP_H
|
||||
#define __IRP_H
|
||||
|
||||
VOID IRPRemember( PIRP Irp, PCHAR File, UINT Line );
|
||||
NTSTATUS IRPFinish( PIRP Irp, NTSTATUS Status );
|
||||
|
||||
#ifdef MEMTRACK
|
||||
#define RIRP(x) IRPRemember(x,__FILE__,__LINE__)
|
||||
#else
|
||||
#define RIRP(x)
|
||||
#endif
|
||||
|
||||
#endif/*__IRP_H*/
|
113
drivers/network/tcpip/include/lan.h
Normal file
113
drivers/network/tcpip/include/lan.h
Normal file
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS TCP/IP protocol driver
|
||||
* FILE: include/lan.h
|
||||
* PURPOSE: LAN adapter definitions
|
||||
*/
|
||||
#ifndef __LAN_H
|
||||
#define __LAN_H
|
||||
|
||||
|
||||
/* Media we support */
|
||||
#define MEDIA_ETH 0
|
||||
|
||||
#define MAX_MEDIA 1
|
||||
|
||||
#define IEEE_802_ADDR_LENGTH 6
|
||||
|
||||
/* Ethernet header layout */
|
||||
typedef struct ETH_HEADER {
|
||||
UCHAR DstAddr[IEEE_802_ADDR_LENGTH]; /* Destination MAC address */
|
||||
UCHAR SrcAddr[IEEE_802_ADDR_LENGTH]; /* Source MAC address */
|
||||
USHORT EType; /* Ethernet protocol type */
|
||||
} ETH_HEADER, *PETH_HEADER;
|
||||
|
||||
#define MAX_MEDIA_ETH sizeof(ETH_HEADER)
|
||||
|
||||
/* Broadcast masks */
|
||||
#define BCAST_ETH_MASK 0x01
|
||||
|
||||
/* Broadcast values to check against */
|
||||
#define BCAST_ETH_CHECK 0x01
|
||||
|
||||
/* Offset of broadcast address */
|
||||
#define BCAST_ETH_OFFSET 0x00
|
||||
|
||||
/* Max packets queued for a single adapter */
|
||||
#define IP_MAX_RECV_BACKLOG 0x20
|
||||
|
||||
/* Per adapter information */
|
||||
typedef struct LAN_ADAPTER {
|
||||
LIST_ENTRY ListEntry; /* Entry on list */
|
||||
KSPIN_LOCK Lock; /* Lock for this structure */
|
||||
UCHAR State; /* State of the adapter */
|
||||
KEVENT Event; /* Opening event */
|
||||
PVOID Context; /* Upper layer context information */
|
||||
NDIS_HANDLE NdisHandle; /* NDIS binding handle */
|
||||
NDIS_STATUS NdisStatus; /* NDIS status of last request */
|
||||
NDIS_MEDIUM Media; /* Media type */
|
||||
UCHAR HWAddress[IEEE_802_ADDR_LENGTH]; /* Local HW address */
|
||||
UINT HWAddressLength; /* Length of HW address */
|
||||
UCHAR BCastMask; /* Mask for checking broadcast */
|
||||
UCHAR BCastCheck; /* Value to check against */
|
||||
UCHAR BCastOffset; /* Offset in frame to check against */
|
||||
UCHAR HeaderSize; /* Size of link-level header */
|
||||
USHORT MTU; /* Maximum Transfer Unit */
|
||||
UINT MinFrameSize; /* Minimum frame size in bytes */
|
||||
UINT MaxPacketSize; /* Maximum packet size when sending */
|
||||
UINT MaxSendPackets; /* Maximum number of packets per send */
|
||||
UINT MacOptions; /* MAC options for NIC driver/adapter */
|
||||
UINT Speed; /* Link speed */
|
||||
UINT PacketFilter; /* Packet filter for this adapter */
|
||||
} LAN_ADAPTER, *PLAN_ADAPTER;
|
||||
|
||||
/* LAN adapter state constants */
|
||||
#define LAN_STATE_OPENING 0
|
||||
#define LAN_STATE_RESETTING 1
|
||||
#define LAN_STATE_STARTED 2
|
||||
#define LAN_STATE_STOPPED 3
|
||||
|
||||
/* Size of out lookahead buffer */
|
||||
#define LOOKAHEAD_SIZE 128
|
||||
|
||||
/* Ethernet types. We swap constants so we can compare values at runtime
|
||||
without swapping them there */
|
||||
#define ETYPE_IPv4 WH2N(0x0800)
|
||||
#define ETYPE_IPv6 WH2N(0x86DD)
|
||||
#define ETYPE_ARP WH2N(0x0806)
|
||||
|
||||
/* Protocols */
|
||||
#define LAN_PROTO_IPv4 0x0000 /* Internet Protocol version 4 */
|
||||
#define LAN_PROTO_IPv6 0x0001 /* Internet Protocol version 6 */
|
||||
#define LAN_PROTO_ARP 0x0002 /* Address Resolution Protocol */
|
||||
|
||||
|
||||
NDIS_STATUS LANRegisterAdapter(
|
||||
PNDIS_STRING AdapterName,
|
||||
PNDIS_STRING RegistryPath);
|
||||
|
||||
NDIS_STATUS LANUnregisterAdapter(
|
||||
PLAN_ADAPTER Adapter);
|
||||
|
||||
NTSTATUS LANRegisterProtocol(
|
||||
PNDIS_STRING Name);
|
||||
|
||||
VOID LANUnregisterProtocol(
|
||||
VOID);
|
||||
|
||||
VOID LANStartup();
|
||||
VOID LANShutdown();
|
||||
|
||||
NTSTATUS TcpipLanGetDwordOid( PIP_INTERFACE Interface, NDIS_OID Oid,
|
||||
PDWORD Result );
|
||||
|
||||
NDIS_STATUS NDISCall(
|
||||
PLAN_ADAPTER Adapter,
|
||||
NDIS_REQUEST_TYPE Type,
|
||||
NDIS_OID OID,
|
||||
PVOID Buffer,
|
||||
UINT Length);
|
||||
|
||||
#endif /* __LAN_H */
|
||||
|
||||
/* EOF */
|
1876
drivers/network/tcpip/include/linux.h
Executable file
1876
drivers/network/tcpip/include/linux.h
Executable file
File diff suppressed because it is too large
Load diff
20
drivers/network/tcpip/include/lock.h
Normal file
20
drivers/network/tcpip/include/lock.h
Normal file
|
@ -0,0 +1,20 @@
|
|||
#ifndef _LOCK_H
|
||||
#define _LOCK_H
|
||||
|
||||
extern KIRQL TcpipGetCurrentIrql();
|
||||
extern VOID TcpipInitializeSpinLock( PKSPIN_LOCK SpinLock );
|
||||
extern VOID TcpipAcquireSpinLock( PKSPIN_LOCK SpinLock, PKIRQL Irql );
|
||||
extern VOID TcpipReleaseSpinLock( PKSPIN_LOCK SpinLock, KIRQL Irql );
|
||||
extern VOID TcpipAcquireSpinLockAtDpcLevel( PKSPIN_LOCK SpinLock );
|
||||
extern VOID TcpipReleaseSpinLockFromDpcLevel( PKSPIN_LOCK SpinLock );
|
||||
extern VOID TcpipInterlockedInsertTailList( PLIST_ENTRY ListHead,
|
||||
PLIST_ENTRY Item,
|
||||
PKSPIN_LOCK Lock );
|
||||
extern VOID TcpipAcquireFastMutex( PFAST_MUTEX Mutex );
|
||||
extern VOID TcpipReleaseFastMutex( PFAST_MUTEX Mutex );
|
||||
extern VOID TcpipRecursiveMutexInit( PRECURSIVE_MUTEX RecMutex );
|
||||
extern UINT TcpipRecursiveMutexEnter( PRECURSIVE_MUTEX RecMutex,
|
||||
BOOL ToWrite );
|
||||
extern VOID TcpipRecursiveMutexLeave( PRECURSIVE_MUTEX RecMutex );
|
||||
|
||||
#endif/*_LOCK_H*/
|
23
drivers/network/tcpip/include/loopback.h
Normal file
23
drivers/network/tcpip/include/loopback.h
Normal file
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS TCP/IP protocol driver
|
||||
* FILE: include/loopback.h
|
||||
* PURPOSE: Loopback adapter definitions
|
||||
*/
|
||||
#ifndef __LOOPBACK_H
|
||||
#define __LOOPBACK_H
|
||||
|
||||
#include <lan.h>
|
||||
|
||||
extern PIP_INTERFACE Loopback;
|
||||
|
||||
NDIS_STATUS LoopRegisterAdapter(
|
||||
PNDIS_STRING AdapterName,
|
||||
PLAN_ADAPTER *Adapter);
|
||||
|
||||
NDIS_STATUS LoopUnregisterAdapter(
|
||||
PLAN_ADAPTER Adapter);
|
||||
|
||||
#endif /* __LOOPBACK_H */
|
||||
|
||||
/* EOF */
|
68
drivers/network/tcpip/include/memtrack.h
Normal file
68
drivers/network/tcpip/include/memtrack.h
Normal file
|
@ -0,0 +1,68 @@
|
|||
#ifndef MEMTRACK_H
|
||||
#define MEMTRACK_H
|
||||
|
||||
#include <pool.h>
|
||||
|
||||
#ifndef FOURCC
|
||||
#define FOURCC(a,b,c,d) (((a)<<24)|((b)<<16)|((c)<<8)|(d))
|
||||
#endif
|
||||
|
||||
#define FBSD_MALLOC FOURCC('d','s','b','f')
|
||||
#define EXALLOC_TAG FOURCC('E','x','A','l')
|
||||
#define IRP_TAG FOURCC('P','I','R','P')
|
||||
|
||||
#define AllocatePacketWithBuffer(x,y,z) AllocatePacketWithBufferX(x,y,z,__FILE__,__LINE__)
|
||||
#define FreeNdisPacket(x) FreeNdisPacketX(x,__FILE__,__LINE__)
|
||||
|
||||
#ifdef MEMTRACK
|
||||
#define MTMARK() TrackDumpFL(__FILE__, __LINE__)
|
||||
#define exAllocatePool(x,y) ExAllocatePoolX(x,y,__FILE__,__LINE__)
|
||||
#define exAllocatePoolWithTag(x,y,z) ExAllocatePoolX(x,y,__FILE__,__LINE__)
|
||||
#define exFreePool(x) ExFreePoolX(x,__FILE__,__LINE__)
|
||||
|
||||
extern LIST_ENTRY AllocatedObjectsHead;
|
||||
extern KSPIN_LOCK AllocatedObjectsLock;
|
||||
|
||||
typedef struct _ALLOCATION_TRACKER {
|
||||
LIST_ENTRY Entry;
|
||||
DWORD Tag;
|
||||
PVOID Thing;
|
||||
PCHAR FileName;
|
||||
DWORD LineNo;
|
||||
} ALLOCATION_TRACKER, *PALLOCATION_TRACKER;
|
||||
|
||||
VOID TrackingInit();
|
||||
VOID TrackWithTag( DWORD Tag, PVOID Thing, PCHAR File, DWORD Line );
|
||||
#define Track(Tag,Thing) TrackWithTag(Tag,Thing,__FILE__,__LINE__)
|
||||
VOID UntrackFL( PCHAR File, DWORD Line, PVOID Thing );
|
||||
#define Untrack(Thing) UntrackFL(__FILE__,__LINE__,Thing)
|
||||
VOID TrackDumpFL( PCHAR File, DWORD Line );
|
||||
#define TrackDump() TrackDumpFL(__FILE__,__LINE__)
|
||||
VOID TrackTag( DWORD Tag );
|
||||
|
||||
static __inline PVOID ExAllocatePoolX( POOL_TYPE type, SIZE_T size, PCHAR File, ULONG Line ) {
|
||||
PVOID Out = PoolAllocateBuffer( size );
|
||||
if( Out ) TrackWithTag( EXALLOC_TAG, Out, File, Line );
|
||||
return Out;
|
||||
}
|
||||
static __inline VOID ExFreePoolX( PVOID Data, PCHAR File, ULONG Line ) {
|
||||
UntrackFL(File, Line, Data);
|
||||
PoolFreeBuffer(Data);
|
||||
}
|
||||
|
||||
#define MEMTRACK_MAX_TAGS_TO_TRACK 64
|
||||
#else
|
||||
#define MTMARK()
|
||||
#define Track(x,y)
|
||||
#define TrackingInit()
|
||||
#define TrackDump()
|
||||
#define Untrack(x)
|
||||
#define TrackTag(x)
|
||||
#define exAllocatePoolWithTag(x,y,z) ExAllocatePoolWithTag(x,y,z)
|
||||
#define exAllocatePool(x,y) PoolAllocateBuffer(y)
|
||||
#define exFreePool(x) PoolFreeBuffer(x)
|
||||
#define TrackWithTag(w,x,y,z)
|
||||
#define UntrackFL(x,y,z)
|
||||
#endif
|
||||
|
||||
#endif/*MEMMTRAC_H*/
|
116
drivers/network/tcpip/include/neighbor.h
Normal file
116
drivers/network/tcpip/include/neighbor.h
Normal file
|
@ -0,0 +1,116 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS TCP/IP protocol driver
|
||||
* FILE: include/neighbor.h
|
||||
* PURPOSE: Neighbor definitions
|
||||
*/
|
||||
#ifndef __NEIGHBOR_H
|
||||
#define __NEIGHBOR_H
|
||||
|
||||
|
||||
#define NB_HASHMASK 0xF /* Hash mask for neighbor cache */
|
||||
|
||||
typedef VOID (*PNEIGHBOR_PACKET_COMPLETE)
|
||||
( PVOID Context, PNDIS_PACKET Packet, NDIS_STATUS Status );
|
||||
|
||||
typedef struct _NEIGHBOR_PACKET {
|
||||
LIST_ENTRY Next;
|
||||
PNDIS_PACKET Packet;
|
||||
PNEIGHBOR_PACKET_COMPLETE Complete;
|
||||
PVOID Context;
|
||||
} NEIGHBOR_PACKET, *PNEIGHBOR_PACKET;
|
||||
|
||||
typedef struct NEIGHBOR_CACHE_TABLE {
|
||||
struct NEIGHBOR_CACHE_ENTRY *Cache; /* Pointer to cache */
|
||||
KSPIN_LOCK Lock; /* Protecting lock */
|
||||
} NEIGHBOR_CACHE_TABLE, *PNEIGHBOR_CACHE_TABLE;
|
||||
|
||||
/* Information about a neighbor */
|
||||
typedef struct NEIGHBOR_CACHE_ENTRY {
|
||||
DEFINE_TAG
|
||||
struct NEIGHBOR_CACHE_ENTRY *Next; /* Pointer to next entry */
|
||||
struct NEIGHBOR_CACHE_TABLE *Table; /* Pointer to table */
|
||||
UCHAR State; /* State of NCE */
|
||||
UINT EventTimer; /* Ticks since last event */
|
||||
UINT EventCount; /* Number of events */
|
||||
PIP_INTERFACE Interface; /* Pointer to interface */
|
||||
UINT LinkAddressLength; /* Length of link address */
|
||||
PVOID LinkAddress; /* Pointer to link address */
|
||||
IP_ADDRESS Address; /* IP address of neighbor */
|
||||
LIST_ENTRY PacketQueue; /* Packet queue */
|
||||
} NEIGHBOR_CACHE_ENTRY, *PNEIGHBOR_CACHE_ENTRY;
|
||||
|
||||
/* NCE states */
|
||||
#define NUD_NONE 0x00
|
||||
#define NUD_INCOMPLETE 0x01
|
||||
#define NUD_REACHABLE 0x02
|
||||
#define NUD_STALE 0x04
|
||||
#define NUD_DELAY 0x08
|
||||
#define NUD_PROBE 0x10
|
||||
#define NUD_FAILED 0x20
|
||||
#define NUD_NOARP 0x40
|
||||
#define NUD_PERMANENT 0x80
|
||||
|
||||
#define NUD_IN_TIMER (NUD_INCOMPLETE | NUD_DELAY | NUD_PROBE)
|
||||
#define NUD_VALID (NUD_REACHABLE | NUD_NOARP | NUD_STALE | NUD_DELAY | \
|
||||
NUD_PROBE | NUD_PERMANENT)
|
||||
#define NUD_CONNECTED (NUD_PERMANENT | NUD_NOARP | NUD_REACHABLE)
|
||||
|
||||
|
||||
/* Maximum number of retransmissions of multicast solicits */
|
||||
#define MAX_MULTICAST_SOLICIT 3 /* 3 transmissions */
|
||||
|
||||
/* Number of ticks between address resolution messages */
|
||||
#define RETRANS_TIMER IP_TICKS_SECOND /* One second */
|
||||
|
||||
|
||||
extern NEIGHBOR_CACHE_TABLE NeighborCache[NB_HASHMASK + 1];
|
||||
|
||||
|
||||
VOID NBTimeout(
|
||||
VOID);
|
||||
|
||||
VOID NBStartup(
|
||||
VOID);
|
||||
|
||||
VOID NBShutdown(
|
||||
VOID);
|
||||
|
||||
VOID NBSendSolicit(
|
||||
PNEIGHBOR_CACHE_ENTRY NCE);
|
||||
|
||||
PNEIGHBOR_CACHE_ENTRY NBAddNeighbor(
|
||||
PIP_INTERFACE Interface,
|
||||
PIP_ADDRESS Address,
|
||||
PVOID LinkAddress,
|
||||
UINT LinkAddressLength,
|
||||
UCHAR Type);
|
||||
|
||||
VOID NBUpdateNeighbor(
|
||||
PNEIGHBOR_CACHE_ENTRY NCE,
|
||||
PVOID LinkAddress,
|
||||
UCHAR State);
|
||||
|
||||
PNEIGHBOR_CACHE_ENTRY NBLocateNeighbor(
|
||||
PIP_ADDRESS Address);
|
||||
|
||||
PNEIGHBOR_CACHE_ENTRY NBFindOrCreateNeighbor(
|
||||
PIP_INTERFACE Interface,
|
||||
PIP_ADDRESS Address);
|
||||
|
||||
BOOLEAN NBQueuePacket(
|
||||
PNEIGHBOR_CACHE_ENTRY NCE,
|
||||
PNDIS_PACKET NdisPacket,
|
||||
PNEIGHBOR_PACKET_COMPLETE PacketComplete,
|
||||
PVOID PacketContext);
|
||||
|
||||
VOID NBRemoveNeighbor(
|
||||
PNEIGHBOR_CACHE_ENTRY NCE);
|
||||
|
||||
DWORD NBCopyNeighbors(
|
||||
PIP_INTERFACE Interface,
|
||||
PIPARP_ENTRY ArpTable);
|
||||
|
||||
#endif /* __NEIGHBOR_H */
|
||||
|
||||
/* EOF */
|
25
drivers/network/tcpip/include/pool.h
Normal file
25
drivers/network/tcpip/include/pool.h
Normal file
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS TCP/IP protocol driver
|
||||
* FILE: include/pool.h
|
||||
* PURPOSE: Prototypes for memory pooling
|
||||
*/
|
||||
#ifndef __POOL_H
|
||||
#define __POOL_H
|
||||
|
||||
|
||||
PVOID PoolAllocateBuffer(
|
||||
ULONG Size);
|
||||
|
||||
VOID PoolFreeBuffer(
|
||||
PVOID Buffer);
|
||||
|
||||
PVOID TcpipAllocateFromNPagedLookasideList( PNPAGED_LOOKASIDE_LIST List );
|
||||
VOID TcpipFreeToNPagedLookasideList( PNPAGED_LOOKASIDE_LIST List,
|
||||
PVOID Thing );
|
||||
NDIS_STATUS PrependPacket( PNDIS_PACKET Packet, PCHAR Data, UINT Len,
|
||||
BOOLEAN Copy );
|
||||
|
||||
#endif /* __POOL_H */
|
||||
|
||||
/* EOF */
|
32
drivers/network/tcpip/include/ports.h
Normal file
32
drivers/network/tcpip/include/ports.h
Normal file
|
@ -0,0 +1,32 @@
|
|||
#ifndef _TCPIP_PORTS_H
|
||||
#define _TCPIP_PORTS_H
|
||||
|
||||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS TCP/IP protocol driver
|
||||
* FILE: include/ports.h
|
||||
* PURPOSE: Port allocation
|
||||
* PROGRAMMERS: arty (ayerkes@speakeasy.net)
|
||||
* REVISIONS:
|
||||
* arty 20041114 Created
|
||||
*/
|
||||
|
||||
typedef struct _PORT_SET {
|
||||
RTL_BITMAP ProtoBitmap;
|
||||
PVOID ProtoBitBuffer;
|
||||
UINT StartingPort;
|
||||
UINT PortsToOversee;
|
||||
UINT LastAllocatedPort;
|
||||
FAST_MUTEX Mutex;
|
||||
} PORT_SET, *PPORT_SET;
|
||||
|
||||
VOID PortsStartup( PPORT_SET PortSet,
|
||||
UINT StartingPort,
|
||||
UINT PortsToManage );
|
||||
VOID PortsShutdown( PPORT_SET PortSet );
|
||||
VOID DeallocatePort( PPORT_SET PortSet, ULONG Port );
|
||||
BOOLEAN AllocatePort( PPORT_SET PortSet, ULONG Port );
|
||||
ULONG AllocateAnyPort( PPORT_SET PortSet );
|
||||
ULONG AllocatePortFromRange( PPORT_SET PortSet, ULONG Lowest, ULONG Highest );
|
||||
|
||||
#endif/*_TCPIP_PORTS_H*/
|
41
drivers/network/tcpip/include/precomp.h
Normal file
41
drivers/network/tcpip/include/precomp.h
Normal file
|
@ -0,0 +1,41 @@
|
|||
#include <roscfg.h>
|
||||
#include <limits.h>
|
||||
#include <ntddk.h>
|
||||
#include <ntifs.h>
|
||||
#include <tdi.h>
|
||||
#include <tdistat.h>
|
||||
#include <../recmutex/recmutex.h>
|
||||
#include <roscfg.h>
|
||||
#include <tcpip.h>
|
||||
#include <loopback.h>
|
||||
#include <ip.h>
|
||||
#include <lan.h>
|
||||
#include <datagram.h>
|
||||
#include <checksum.h>
|
||||
#include <address.h>
|
||||
#include <routines.h>
|
||||
#include <info.h>
|
||||
#include <neighbor.h>
|
||||
#include <route.h>
|
||||
#include <receive.h>
|
||||
#include <transmit.h>
|
||||
#include <router.h>
|
||||
#include <pool.h>
|
||||
#include <rawip.h>
|
||||
#include <icmp.h>
|
||||
#include <udp.h>
|
||||
#include <tcp.h>
|
||||
#include <arp.h>
|
||||
#include <irp.h>
|
||||
#include <tilists.h>
|
||||
#include <dispatch.h>
|
||||
#include <fileobjs.h>
|
||||
#include <lock.h>
|
||||
#include <wait.h>
|
||||
#include <bug.h>
|
||||
#include <memtrack.h>
|
||||
#include <oskittcp.h>
|
||||
#include <interface.h>
|
||||
#include <ports.h>
|
||||
#include <ipifcons.h>
|
||||
#include <chew/chew.h>
|
40
drivers/network/tcpip/include/rawip.h
Normal file
40
drivers/network/tcpip/include/rawip.h
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS TCP/IP protocol driver
|
||||
* FILE: include/rawip.h
|
||||
* PURPOSE: Raw IP types and constants
|
||||
*/
|
||||
#ifndef __RAWIP_H
|
||||
#define __RAWIP_H
|
||||
|
||||
NTSTATUS RawIPSendDatagram(
|
||||
PADDRESS_FILE AddrFile,
|
||||
PTDI_CONNECTION_INFORMATION ConnInfo,
|
||||
PCHAR Buffer,
|
||||
ULONG DataSize,
|
||||
PULONG DataUsed);
|
||||
|
||||
VOID RawIPReceive(
|
||||
PIP_INTERFACE Interface,
|
||||
PIP_PACKET IPPacket);
|
||||
|
||||
NTSTATUS RawIPStartup(
|
||||
VOID);
|
||||
|
||||
NTSTATUS RawIPShutdown(
|
||||
VOID);
|
||||
|
||||
NTSTATUS AddGenericHeaderIPv4(
|
||||
PIP_ADDRESS RemoteAddress,
|
||||
USHORT RemotePort,
|
||||
PIP_ADDRESS LocalAddress,
|
||||
USHORT LocalPort,
|
||||
PIP_PACKET IPPacket,
|
||||
UINT DataLength,
|
||||
UINT Protocol,
|
||||
UINT ExtraLength,
|
||||
PVOID *NextHeader );
|
||||
|
||||
#endif /* __RAWIP_H */
|
||||
|
||||
/* EOF */
|
63
drivers/network/tcpip/include/receive.h
Normal file
63
drivers/network/tcpip/include/receive.h
Normal file
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS TCP/IP protocol driver
|
||||
* FILE: include/receive.h
|
||||
* PURPOSE: Internet Protocol receive prototypes
|
||||
*/
|
||||
#ifndef __RECEIVE_H
|
||||
#define __RECEIVE_H
|
||||
|
||||
#include <ip.h>
|
||||
|
||||
|
||||
/* IP datagram fragment descriptor. Used to store IP datagram fragments */
|
||||
typedef struct IP_FRAGMENT {
|
||||
LIST_ENTRY ListEntry; /* Entry on list */
|
||||
PVOID Data; /* Pointer to fragment data */
|
||||
UINT Offset; /* Offset into datagram where this fragment is */
|
||||
UINT Size; /* Size of this fragment */
|
||||
} IP_FRAGMENT, *PIP_FRAGMENT;
|
||||
|
||||
/* IP datagram hole descriptor. Used to reassemble IP datagrams */
|
||||
typedef struct IPDATAGRAM_HOLE {
|
||||
LIST_ENTRY ListEntry; /* Entry on list */
|
||||
UINT First; /* Offset of first octet of the hole */
|
||||
UINT Last; /* Offset of last octet of the hole */
|
||||
} IPDATAGRAM_HOLE, *PIPDATAGRAM_HOLE;
|
||||
|
||||
/* IP datagram reassembly information */
|
||||
typedef struct IPDATAGRAM_REASSEMBLY {
|
||||
LIST_ENTRY ListEntry; /* Entry on list */
|
||||
KSPIN_LOCK Lock; /* Protecting spin lock */
|
||||
UINT DataSize; /* Size of datagram data area */
|
||||
IP_ADDRESS SrcAddr; /* Source address */
|
||||
IP_ADDRESS DstAddr; /* Destination address */
|
||||
UCHAR Protocol; /* Internet Protocol number */
|
||||
USHORT Id; /* Identification number */
|
||||
IP_HEADER IPv4Header; /* Pointer to IP header */
|
||||
UINT HeaderSize; /* Length of IP header */
|
||||
LIST_ENTRY FragmentListHead; /* IP fragment list */
|
||||
LIST_ENTRY HoleListHead; /* IP datagram hole list */
|
||||
} IPDATAGRAM_REASSEMBLY, *PIPDATAGRAM_REASSEMBLY;
|
||||
|
||||
|
||||
extern LIST_ENTRY ReassemblyListHead;
|
||||
extern KSPIN_LOCK ReassemblyListLock;
|
||||
extern NPAGED_LOOKASIDE_LIST IPDRList;
|
||||
extern NPAGED_LOOKASIDE_LIST IPFragmentList;
|
||||
extern NPAGED_LOOKASIDE_LIST IPHoleList;
|
||||
|
||||
|
||||
VOID IPFreeReassemblyList(
|
||||
VOID);
|
||||
|
||||
VOID IPDatagramReassemblyTimeout(
|
||||
VOID);
|
||||
|
||||
VOID IPReceive(
|
||||
PIP_INTERFACE IF,
|
||||
PIP_PACKET IPPacket);
|
||||
|
||||
#endif /* __RECEIVE_H */
|
||||
|
||||
/* EOF */
|
21
drivers/network/tcpip/include/route.h
Normal file
21
drivers/network/tcpip/include/route.h
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS TCP/IP protocol driver
|
||||
* FILE: include/route.h
|
||||
* PURPOSE: Routing cache definitions
|
||||
*/
|
||||
#ifndef __ROUTE_H
|
||||
#define __ROUTE_H
|
||||
|
||||
#include <neighbor.h>
|
||||
#include <address.h>
|
||||
#include <router.h>
|
||||
#include <pool.h>
|
||||
#include <info.h>
|
||||
#include <arp.h>
|
||||
|
||||
PNEIGHBOR_CACHE_ENTRY RouteGetRouteToDestination(PIP_ADDRESS Destination);
|
||||
|
||||
#endif /* __ROUTE_H */
|
||||
|
||||
/* EOF */
|
52
drivers/network/tcpip/include/router.h
Normal file
52
drivers/network/tcpip/include/router.h
Normal file
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS TCP/IP protocol driver
|
||||
* FILE: include/router.h
|
||||
* PURPOSE: IP routing definitions
|
||||
*/
|
||||
#ifndef __ROUTER_H
|
||||
#define __ROUTER_H
|
||||
|
||||
#include <neighbor.h>
|
||||
|
||||
|
||||
/* Forward Information Base Entry */
|
||||
typedef struct _FIB_ENTRY {
|
||||
LIST_ENTRY ListEntry; /* Entry on list */
|
||||
OBJECT_FREE_ROUTINE Free; /* Routine used to free resources for the object */
|
||||
IP_ADDRESS NetworkAddress; /* Address of network */
|
||||
IP_ADDRESS Netmask; /* Netmask of network */
|
||||
PNEIGHBOR_CACHE_ENTRY Router; /* Pointer to NCE of router to use */
|
||||
UINT Metric; /* Cost of this route */
|
||||
} FIB_ENTRY, *PFIB_ENTRY;
|
||||
|
||||
PFIB_ENTRY RouterAddRoute(
|
||||
PIP_ADDRESS NetworkAddress,
|
||||
PIP_ADDRESS Netmask,
|
||||
PNEIGHBOR_CACHE_ENTRY Router,
|
||||
UINT Metric);
|
||||
|
||||
PNEIGHBOR_CACHE_ENTRY RouterGetRoute(PIP_ADDRESS Destination);
|
||||
|
||||
NTSTATUS RouterRemoveRoute(PIP_ADDRESS Target, PIP_ADDRESS Router);
|
||||
|
||||
PFIB_ENTRY RouterCreateRoute(
|
||||
PIP_ADDRESS NetworkAddress,
|
||||
PIP_ADDRESS Netmask,
|
||||
PIP_ADDRESS RouterAddress,
|
||||
PIP_INTERFACE Interface,
|
||||
UINT Metric);
|
||||
|
||||
NTSTATUS RouterStartup(
|
||||
VOID);
|
||||
|
||||
NTSTATUS RouterShutdown(
|
||||
VOID);
|
||||
|
||||
UINT CountFIBs(VOID);
|
||||
|
||||
UINT CopyFIBs( PFIB_ENTRY Target );
|
||||
|
||||
#endif /* __ROUTER_H */
|
||||
|
||||
/* EOF */
|
75
drivers/network/tcpip/include/routines.h
Normal file
75
drivers/network/tcpip/include/routines.h
Normal file
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS TCP/IP protocol driver
|
||||
* FILE: include/routines.h
|
||||
* PURPOSE: Common routine prototypes
|
||||
*/
|
||||
#ifndef __ROUTINES_H
|
||||
#define __ROUTINES_H
|
||||
|
||||
|
||||
UINT Random(VOID);
|
||||
|
||||
UINT CopyBufferToBufferChain(
|
||||
PNDIS_BUFFER DstBuffer,
|
||||
UINT DstOffset,
|
||||
PCHAR SrcData,
|
||||
UINT Length);
|
||||
|
||||
UINT CopyBufferChainToBuffer(
|
||||
PCHAR DstData,
|
||||
PNDIS_BUFFER SrcBuffer,
|
||||
UINT SrcOffset,
|
||||
UINT Length);
|
||||
|
||||
UINT CopyPacketToBuffer(
|
||||
PCHAR DstData,
|
||||
PNDIS_PACKET SrcPacket,
|
||||
UINT SrcOffset,
|
||||
UINT Length);
|
||||
|
||||
UINT CopyPacketToBufferChain(
|
||||
PNDIS_BUFFER DstBuffer,
|
||||
UINT DstOffset,
|
||||
PNDIS_PACKET SrcPacket,
|
||||
UINT SrcOffset,
|
||||
UINT Length);
|
||||
|
||||
VOID FreeNdisPacketX(
|
||||
PNDIS_PACKET Packet,
|
||||
PCHAR File,
|
||||
UINT Line);
|
||||
|
||||
PVOID AdjustPacket(
|
||||
PNDIS_PACKET Packet,
|
||||
UINT Available,
|
||||
UINT Needed);
|
||||
|
||||
UINT ResizePacket(
|
||||
PNDIS_PACKET Packet,
|
||||
UINT Size);
|
||||
|
||||
NDIS_STATUS AllocatePacketWithBufferX( PNDIS_PACKET *NdisPacket,
|
||||
PCHAR Data, UINT Len,
|
||||
PCHAR File, UINT Line );
|
||||
|
||||
void GetDataPtr( PNDIS_PACKET Packet,
|
||||
UINT Offset,
|
||||
PCHAR *DataOut,
|
||||
PUINT Size );
|
||||
|
||||
#ifdef DBG
|
||||
VOID DisplayIPPacket(
|
||||
PIP_PACKET IPPacket);
|
||||
#define DISPLAY_IP_PACKET(x) DisplayIPPacket(x)
|
||||
VOID DisplayTCPPacket(
|
||||
PIP_PACKET IPPacket);
|
||||
#define DISPLAY_TCP_PACKET(x) DisplayTCPPacket(x)
|
||||
#else
|
||||
#define DISPLAY_IP_PACKET(x)
|
||||
#define DISPLAY_TCP_PACKET(x)
|
||||
#endif /* DBG */
|
||||
|
||||
#endif /* __ROUTINES_H */
|
||||
|
||||
/* EOF */
|
185
drivers/network/tcpip/include/tcp.h
Normal file
185
drivers/network/tcpip/include/tcp.h
Normal file
|
@ -0,0 +1,185 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS TCP/IP protocol driver
|
||||
* FILE: include/tcp.h
|
||||
* PURPOSE: Transmission Control Protocol definitions
|
||||
*/
|
||||
#ifndef __TCP_H
|
||||
#define __TCP_H
|
||||
|
||||
typedef VOID
|
||||
(*PTCP_COMPLETION_ROUTINE)( PVOID Context, NTSTATUS Status, ULONG Count );
|
||||
|
||||
/* TCPv4 header structure */
|
||||
#include <pshpack1.h>
|
||||
typedef struct TCPv4_HEADER {
|
||||
USHORT SourcePort; /* Source port */
|
||||
USHORT DestinationPort; /* Destination port */
|
||||
ULONG SequenceNumber; /* Sequence number */
|
||||
ULONG AckNumber; /* Acknowledgement number */
|
||||
UCHAR DataOffset; /* Data offset; 32-bit words (leftmost 4 bits) */
|
||||
UCHAR Flags; /* Control bits (rightmost 6 bits) */
|
||||
USHORT Window; /* Maximum acceptable receive window */
|
||||
USHORT Checksum; /* Checksum of segment */
|
||||
USHORT Urgent; /* Pointer to urgent data */
|
||||
} TCPv4_HEADER, *PTCPv4_HEADER;
|
||||
|
||||
/* TCPv4 header flags */
|
||||
#define TCP_URG 0x20
|
||||
#define TCP_ACK 0x10
|
||||
#define TCP_PSH 0x08
|
||||
#define TCP_RST 0x04
|
||||
#define TCP_SYN 0x02
|
||||
#define TCP_FIN 0x01
|
||||
|
||||
|
||||
#define TCPOPT_END_OF_LIST 0x0
|
||||
#define TCPOPT_NO_OPERATION 0x1
|
||||
#define TCPOPT_MAX_SEG_SIZE 0x2
|
||||
|
||||
#define TCPOPTLEN_MAX_SEG_SIZE 0x4
|
||||
|
||||
/* Data offset; 32-bit words (leftmost 4 bits); convert to bytes */
|
||||
#define TCP_DATA_OFFSET(DataOffset)(((DataOffset) & 0xF0) >> (4-2))
|
||||
|
||||
|
||||
/* TCPv4 pseudo header */
|
||||
typedef struct TCPv4_PSEUDO_HEADER {
|
||||
ULONG SourceAddress; /* Source address */
|
||||
ULONG DestinationAddress; /* Destination address */
|
||||
UCHAR Zero; /* Reserved */
|
||||
UCHAR Protocol; /* Protocol */
|
||||
USHORT TCPLength; /* Size of TCP segment */
|
||||
} TCPv4_PSEUDO_HEADER, *PTCPv4_PSEUDO_HEADER;
|
||||
#include <poppack.h>
|
||||
|
||||
typedef struct _SLEEPING_THREAD {
|
||||
LIST_ENTRY Entry;
|
||||
PVOID SleepToken;
|
||||
KEVENT Event;
|
||||
} SLEEPING_THREAD, *PSLEEPING_THREAD;
|
||||
|
||||
/* Retransmission timeout constants */
|
||||
|
||||
/* Lower bound for retransmission timeout in TCP timer ticks */
|
||||
#define TCP_MIN_RETRANSMISSION_TIMEOUT 1*1000 /* 1 tick */
|
||||
|
||||
/* Upper bound for retransmission timeout in TCP timer ticks */
|
||||
#define TCP_MAX_RETRANSMISSION_TIMEOUT 1*60*1000 /* 1 tick */
|
||||
|
||||
/* Smoothing factor */
|
||||
#define TCP_ALPHA_RETRANSMISSION_TIMEOUT(x)(((x)*8)/10) /* 0.8 */
|
||||
|
||||
/* Delay variance factor */
|
||||
#define TCP_BETA_RETRANSMISSION_TIMEOUT(x)(((x)*16)/10) /* 1.6 */
|
||||
|
||||
|
||||
/* Datagram/segment send request flags */
|
||||
|
||||
#define SRF_URG TCP_URG
|
||||
#define SRF_ACK TCP_ACK
|
||||
#define SRF_PSH TCP_PSH
|
||||
#define SRF_RST TCP_RST
|
||||
#define SRF_SYN TCP_SYN
|
||||
#define SRF_FIN TCP_FIN
|
||||
|
||||
extern LONG TCP_IPIdentification;
|
||||
extern LIST_ENTRY SignalledConnections;
|
||||
extern LIST_ENTRY SleepingThreadsList;
|
||||
extern FAST_MUTEX SleepingThreadsLock;
|
||||
extern RECURSIVE_MUTEX TCPLock;
|
||||
|
||||
/* accept.c */
|
||||
NTSTATUS TCPServiceListeningSocket( PCONNECTION_ENDPOINT Listener,
|
||||
PCONNECTION_ENDPOINT Connection,
|
||||
PTDI_REQUEST_KERNEL Request );
|
||||
NTSTATUS TCPListen( PCONNECTION_ENDPOINT Connection, UINT Backlog );
|
||||
VOID TCPAbortListenForSocket( PCONNECTION_ENDPOINT Listener,
|
||||
PCONNECTION_ENDPOINT Connection );
|
||||
NTSTATUS TCPAccept
|
||||
( PTDI_REQUEST Request,
|
||||
PCONNECTION_ENDPOINT Listener,
|
||||
PCONNECTION_ENDPOINT Connection,
|
||||
PTCP_COMPLETION_ROUTINE Complete,
|
||||
PVOID Context );
|
||||
|
||||
/* tcp.c */
|
||||
PCONNECTION_ENDPOINT TCPAllocateConnectionEndpoint( PVOID ClientContext );
|
||||
VOID TCPFreeConnectionEndpoint( PCONNECTION_ENDPOINT Connection );
|
||||
|
||||
NTSTATUS TCPSocket( PCONNECTION_ENDPOINT Connection,
|
||||
UINT Family, UINT Type, UINT Proto );
|
||||
|
||||
PTCP_SEGMENT TCPCreateSegment(
|
||||
PIP_PACKET IPPacket,
|
||||
PTCPv4_HEADER TCPHeader,
|
||||
ULONG SegmentLength);
|
||||
|
||||
VOID TCPFreeSegment(
|
||||
PTCP_SEGMENT Segment);
|
||||
|
||||
VOID TCPAddSegment(
|
||||
PCONNECTION_ENDPOINT Connection,
|
||||
PTCP_SEGMENT Segment,
|
||||
PULONG Acknowledged);
|
||||
|
||||
NTSTATUS TCPConnect(
|
||||
PCONNECTION_ENDPOINT Connection,
|
||||
PTDI_CONNECTION_INFORMATION ConnInfo,
|
||||
PTDI_CONNECTION_INFORMATION ReturnInfo,
|
||||
PTCP_COMPLETION_ROUTINE Complete,
|
||||
PVOID Context);
|
||||
|
||||
NTSTATUS TCPDisconnect(
|
||||
PCONNECTION_ENDPOINT Connection,
|
||||
UINT Flags,
|
||||
PTDI_CONNECTION_INFORMATION ConnInfo,
|
||||
PTDI_CONNECTION_INFORMATION ReturnInfo,
|
||||
PTCP_COMPLETION_ROUTINE Complete,
|
||||
PVOID Context);
|
||||
|
||||
NTSTATUS TCPReceiveData(
|
||||
PCONNECTION_ENDPOINT Connection,
|
||||
PNDIS_BUFFER Buffer,
|
||||
ULONG ReceiveLength,
|
||||
PULONG BytesReceived,
|
||||
ULONG ReceiveFlags,
|
||||
PTCP_COMPLETION_ROUTINE Complete,
|
||||
PVOID Context);
|
||||
|
||||
NTSTATUS TCPSendData(
|
||||
PCONNECTION_ENDPOINT Connection,
|
||||
PCHAR Buffer,
|
||||
ULONG DataSize,
|
||||
PULONG DataUsed,
|
||||
ULONG Flags,
|
||||
PTCP_COMPLETION_ROUTINE Complete,
|
||||
PVOID Context);
|
||||
|
||||
NTSTATUS TCPClose( PCONNECTION_ENDPOINT Connection );
|
||||
|
||||
PVOID TCPPrepareInterface( PIP_INTERFACE IF );
|
||||
|
||||
VOID TCPDisposeInterfaceData( PVOID Data );
|
||||
|
||||
NTSTATUS TCPTranslateError( int OskitError );
|
||||
|
||||
VOID TCPTimeout();
|
||||
|
||||
UINT TCPAllocatePort( UINT HintPort );
|
||||
|
||||
VOID TCPFreePort( UINT Port );
|
||||
|
||||
NTSTATUS TCPGetPeerAddress
|
||||
( PCONNECTION_ENDPOINT Connection,
|
||||
PTRANSPORT_ADDRESS TransportAddress );
|
||||
|
||||
NTSTATUS TCPStartup(
|
||||
VOID);
|
||||
|
||||
NTSTATUS TCPShutdown(
|
||||
VOID);
|
||||
|
||||
VOID TCPRemoveIRP( PCONNECTION_ENDPOINT Connection, PIRP Irp );
|
||||
|
||||
#endif /* __TCP_H */
|
3856
drivers/network/tcpip/include/tcpcore.h
Executable file
3856
drivers/network/tcpip/include/tcpcore.h
Executable file
File diff suppressed because it is too large
Load diff
187
drivers/network/tcpip/include/tcpdef.h
Executable file
187
drivers/network/tcpip/include/tcpdef.h
Executable file
|
@ -0,0 +1,187 @@
|
|||
/*
|
||||
* INET An implementation of the TCP/IP protocol suite for the LINUX
|
||||
* operating system. INET is implemented using the BSD Socket
|
||||
* interface as the means of communication with the user level.
|
||||
*
|
||||
* Definitions for the TCP protocol.
|
||||
*
|
||||
* Version: @(#)tcp.h 1.0.2 04/28/93
|
||||
*
|
||||
* Author: Fred N. van Kempen, <waltje@uWalt.NL.Mugnet.ORG>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version
|
||||
* 2 of the License, or (at your option) any later version.
|
||||
*/
|
||||
#ifndef _LINUX_TCP_H
|
||||
#define _LINUX_TCP_H
|
||||
|
||||
#include "linux.h"
|
||||
|
||||
struct tcphdr {
|
||||
__u16 source;
|
||||
__u16 dest;
|
||||
__u32 seq;
|
||||
__u32 ack_seq;
|
||||
//#if defined(__LITTLE_ENDIAN_BITFIELD)
|
||||
__u16 res1:4,
|
||||
doff:4,
|
||||
fin:1,
|
||||
syn:1,
|
||||
rst:1,
|
||||
psh:1,
|
||||
ack:1,
|
||||
urg:1,
|
||||
ece:1,
|
||||
cwr:1;
|
||||
/*#elif defined(__BIG_ENDIAN_BITFIELD)
|
||||
__u16 doff:4,
|
||||
res1:4,
|
||||
cwr:1,
|
||||
ece:1,
|
||||
urg:1,
|
||||
ack:1,
|
||||
psh:1,
|
||||
rst:1,
|
||||
syn:1,
|
||||
fin:1;
|
||||
#else
|
||||
#error "Adjust your <asm/byteorder.h> defines"
|
||||
#endif */
|
||||
__u16 window;
|
||||
__u16 check;
|
||||
__u16 urg_ptr;
|
||||
};
|
||||
|
||||
|
||||
enum {
|
||||
TCP_ESTABLISHED = 1,
|
||||
TCP_SYN_SENT,
|
||||
TCP_SYN_RECV,
|
||||
TCP_FIN_WAIT1,
|
||||
TCP_FIN_WAIT2,
|
||||
TCP_TIME_WAIT,
|
||||
TCP_CLOSE,
|
||||
TCP_CLOSE_WAIT,
|
||||
TCP_LAST_ACK,
|
||||
TCP_LISTEN,
|
||||
TCP_CLOSING, /* now a valid state */
|
||||
|
||||
TCP_MAX_STATES /* Leave at the end! */
|
||||
};
|
||||
|
||||
#define TCP_STATE_MASK 0xF
|
||||
#define TCP_ACTION_FIN (1 << 7)
|
||||
|
||||
enum {
|
||||
TCPF_ESTABLISHED = (1 << 1),
|
||||
TCPF_SYN_SENT = (1 << 2),
|
||||
TCPF_SYN_RECV = (1 << 3),
|
||||
TCPF_FIN_WAIT1 = (1 << 4),
|
||||
TCPF_FIN_WAIT2 = (1 << 5),
|
||||
TCPF_TIME_WAIT = (1 << 6),
|
||||
TCPF_CLOSE = (1 << 7),
|
||||
TCPF_CLOSE_WAIT = (1 << 8),
|
||||
TCPF_LAST_ACK = (1 << 9),
|
||||
TCPF_LISTEN = (1 << 10),
|
||||
TCPF_CLOSING = (1 << 11)
|
||||
};
|
||||
|
||||
/*
|
||||
* The union cast uses a gcc extension to avoid aliasing problems
|
||||
* (union is compatible to any of its members)
|
||||
* This means this part of the code is -fstrict-aliasing safe now.
|
||||
*/
|
||||
union tcp_word_hdr {
|
||||
struct tcphdr hdr;
|
||||
__u32 words[5];
|
||||
};
|
||||
|
||||
#define tcp_flag_word(tp) ( ((union tcp_word_hdr *)(tp))->words [3])
|
||||
|
||||
enum {
|
||||
TCP_FLAG_CWR = 0x00800000, // __constant_htonl(0x00800000),
|
||||
TCP_FLAG_ECE = 0x00400000, //__constant_htonl(0x00400000),
|
||||
TCP_FLAG_URG = 0x00200000, //__constant_htonl(0x00200000),
|
||||
TCP_FLAG_ACK = 0x00100000, //__constant_htonl(0x00100000),
|
||||
TCP_FLAG_PSH = 0x00080000, //__constant_htonl(0x00080000),
|
||||
TCP_FLAG_RST = 0x00040000, //__constant_htonl(0x00040000),
|
||||
TCP_FLAG_SYN = 0x00020000, //__constant_htonl(0x00020000),
|
||||
TCP_FLAG_FIN = 0x00010000, //__constant_htonl(0x00010000),
|
||||
TCP_RESERVED_BITS = 0x0F000000, //__constant_htonl(0x0F000000),
|
||||
TCP_DATA_OFFSET = 0xF0000000, //__constant_htonl(0xF0000000)
|
||||
};
|
||||
|
||||
/* TCP socket options */
|
||||
#define TCP_NODELAY 1 /* Turn off Nagle's algorithm. */
|
||||
#define TCP_MAXSEG 2 /* Limit MSS */
|
||||
#define TCP_CORK 3 /* Never send partially complete segments */
|
||||
#define TCP_KEEPIDLE 4 /* Start keeplives after this period */
|
||||
#define TCP_KEEPINTVL 5 /* Interval between keepalives */
|
||||
#define TCP_KEEPCNT 6 /* Number of keepalives before death */
|
||||
#define TCP_SYNCNT 7 /* Number of SYN retransmits */
|
||||
#define TCP_LINGER2 8 /* Life time of orphaned FIN-WAIT-2 state */
|
||||
#define TCP_DEFER_ACCEPT 9 /* Wake up listener only when data arrive */
|
||||
#define TCP_WINDOW_CLAMP 10 /* Bound advertised window */
|
||||
#define TCP_INFO 11 /* Information about this connection. */
|
||||
#define TCP_QUICKACK 12 /* Block/reenable quick acks */
|
||||
|
||||
#define TCPI_OPT_TIMESTAMPS 1
|
||||
#define TCPI_OPT_SACK 2
|
||||
#define TCPI_OPT_WSCALE 4
|
||||
#define TCPI_OPT_ECN 8
|
||||
|
||||
enum tcp_ca_state
|
||||
{
|
||||
TCP_CA_Open = 0,
|
||||
#define TCPF_CA_Open (1<<TCP_CA_Open)
|
||||
TCP_CA_Disorder = 1,
|
||||
#define TCPF_CA_Disorder (1<<TCP_CA_Disorder)
|
||||
TCP_CA_CWR = 2,
|
||||
#define TCPF_CA_CWR (1<<TCP_CA_CWR)
|
||||
TCP_CA_Recovery = 3,
|
||||
#define TCPF_CA_Recovery (1<<TCP_CA_Recovery)
|
||||
TCP_CA_Loss = 4
|
||||
#define TCPF_CA_Loss (1<<TCP_CA_Loss)
|
||||
};
|
||||
|
||||
struct tcp_info
|
||||
{
|
||||
__u8 tcpi_state;
|
||||
__u8 tcpi_ca_state;
|
||||
__u8 tcpi_retransmits;
|
||||
__u8 tcpi_probes;
|
||||
__u8 tcpi_backoff;
|
||||
__u8 tcpi_options;
|
||||
__u8 tcpi_snd_wscale : 4, tcpi_rcv_wscale : 4;
|
||||
|
||||
__u32 tcpi_rto;
|
||||
__u32 tcpi_ato;
|
||||
__u32 tcpi_snd_mss;
|
||||
__u32 tcpi_rcv_mss;
|
||||
|
||||
__u32 tcpi_unacked;
|
||||
__u32 tcpi_sacked;
|
||||
__u32 tcpi_lost;
|
||||
__u32 tcpi_retrans;
|
||||
__u32 tcpi_fackets;
|
||||
|
||||
/* Times. */
|
||||
__u32 tcpi_last_data_sent;
|
||||
__u32 tcpi_last_ack_sent; /* Not remembered, sorry. */
|
||||
__u32 tcpi_last_data_recv;
|
||||
__u32 tcpi_last_ack_recv;
|
||||
|
||||
/* Metrics. */
|
||||
__u32 tcpi_pmtu;
|
||||
__u32 tcpi_rcv_ssthresh;
|
||||
__u32 tcpi_rtt;
|
||||
__u32 tcpi_rttvar;
|
||||
__u32 tcpi_snd_ssthresh;
|
||||
__u32 tcpi_snd_cwnd;
|
||||
__u32 tcpi_advmss;
|
||||
__u32 tcpi_reordering;
|
||||
};
|
||||
|
||||
#endif /* _LINUX_TCP_H */
|
203
drivers/network/tcpip/include/tcpip.h
Normal file
203
drivers/network/tcpip/include/tcpip.h
Normal file
|
@ -0,0 +1,203 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS TCP/IP protocol driver
|
||||
* FILE: include/tcpip.h
|
||||
* PURPOSE: TCP/IP protocol driver definitions
|
||||
* NOTES: Spin lock acquire order:
|
||||
* - Net table list lock
|
||||
* - Interface lock
|
||||
* - Interface list lock
|
||||
* - Prefix list lock
|
||||
* - Neighbor cache lock
|
||||
* - Route cache lock
|
||||
*/
|
||||
#ifndef __TCPIP_H
|
||||
#define __TCPIP_H
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <basetsd.h>
|
||||
#include <ntddk.h>
|
||||
#include <windef.h>
|
||||
#include <ndis.h>
|
||||
#include <tdikrnl.h>
|
||||
#include <tdiinfo.h>
|
||||
#else
|
||||
#include <ntddk.h>
|
||||
#include <ndis.h>
|
||||
#include <tdikrnl.h>
|
||||
#include <tdiinfo.h>
|
||||
#endif
|
||||
|
||||
#include <debug.h>
|
||||
|
||||
#define TAG(A, B, C, D) (ULONG)(((A)<<0) + ((B)<<8) + ((C)<<16) + ((D)<<24))
|
||||
#define TAG_STRING TAG('S', 'T', 'R', ' ') /* string */
|
||||
|
||||
/* 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_
|
||||
|
||||
/* FIXME: The following should be moved to ntddk.h or tdi headers */
|
||||
#ifndef _MSC_VER
|
||||
|
||||
#ifndef IO_NETWORK_INCREMENT
|
||||
#define IO_NETWORK_INCREMENT 2
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef _MSC_VER
|
||||
/* EXPORTED is already defined ddk/defines.h */
|
||||
#define EXPORTED __declspec(dllexport)
|
||||
|
||||
#endif
|
||||
|
||||
#include <titypes.h>
|
||||
#include <ticonsts.h>
|
||||
|
||||
/* Macros */
|
||||
|
||||
#define MIN(value1, value2) \
|
||||
((value1 < value2)? value1 : value2)
|
||||
|
||||
#define MAX(value1, value2) \
|
||||
((value1 > value2)? value1 : value2)
|
||||
|
||||
#define NDIS_BUFFER_TAG FOURCC('n','b','u','f')
|
||||
#define NDIS_PACKET_TAG FOURCC('n','p','k','t')
|
||||
|
||||
#ifdef i386
|
||||
|
||||
/* DWORD network to host byte order conversion for i386 */
|
||||
#define DN2H(dw) \
|
||||
((((dw) & 0xFF000000L) >> 24) | \
|
||||
(((dw) & 0x00FF0000L) >> 8) | \
|
||||
(((dw) & 0x0000FF00L) << 8) | \
|
||||
(((dw) & 0x000000FFL) << 24))
|
||||
|
||||
/* DWORD host to network byte order conversion for i386 */
|
||||
#define DH2N(dw) \
|
||||
((((dw) & 0xFF000000L) >> 24) | \
|
||||
(((dw) & 0x00FF0000L) >> 8) | \
|
||||
(((dw) & 0x0000FF00L) << 8) | \
|
||||
(((dw) & 0x000000FFL) << 24))
|
||||
|
||||
/* WORD network to host order conversion for i386 */
|
||||
#define WN2H(w) \
|
||||
((((w) & 0xFF00) >> 8) | \
|
||||
(((w) & 0x00FF) << 8))
|
||||
|
||||
/* WORD host to network byte order conversion for i386 */
|
||||
#define WH2N(w) \
|
||||
((((w) & 0xFF00) >> 8) | \
|
||||
(((w) & 0x00FF) << 8))
|
||||
|
||||
#else /* i386 */
|
||||
|
||||
/* DWORD network to host byte order conversion for other architectures */
|
||||
#define DN2H(dw) \
|
||||
(dw)
|
||||
|
||||
/* DWORD host to network byte order conversion for other architectures */
|
||||
#define DH2N(dw) \
|
||||
(dw)
|
||||
|
||||
/* WORD network to host order conversion for other architectures */
|
||||
#define WN2H(w) \
|
||||
(w)
|
||||
|
||||
/* WORD host to network byte order conversion for other architectures */
|
||||
#define WH2N(w) \
|
||||
(w)
|
||||
|
||||
#endif /* i386 */
|
||||
|
||||
/* AF_INET and other things Arty likes to use ;) */
|
||||
#define AF_INET 2
|
||||
#define SOCK_STREAM 1
|
||||
|
||||
/* Should use TDI structure, but Arty wants to keep BSD style */
|
||||
typedef unsigned char u_char;
|
||||
typedef unsigned short u_short;
|
||||
typedef unsigned int u_int;
|
||||
typedef unsigned long u_long;
|
||||
struct in_addr
|
||||
{
|
||||
union
|
||||
{
|
||||
struct { u_char s_b1,s_b2,s_b3,s_b4; } S_un_b;
|
||||
struct { u_short s_w1,s_w2; } S_un_w;
|
||||
u_long S_addr;
|
||||
} S_un;
|
||||
#define s_addr S_un.S_addr
|
||||
#define s_host S_un.S_un_b.s_b2
|
||||
#define s_net S_un.S_un_b.s_b1
|
||||
#define s_imp S_un.S_un_w.s_w2
|
||||
#define s_impno S_un.S_un_b.s_b4
|
||||
#define s_lh S_un.S_un_b.s_b3
|
||||
};
|
||||
struct sockaddr_in
|
||||
{
|
||||
short sin_family;
|
||||
u_short sin_port;
|
||||
struct in_addr sin_addr;
|
||||
char sin_zero[8];
|
||||
};
|
||||
typedef struct sockaddr_in SOCKADDR_IN;
|
||||
struct sockaddr
|
||||
{
|
||||
u_short sa_family;
|
||||
char sa_data[14];
|
||||
};
|
||||
|
||||
typedef TDI_STATUS (*InfoRequest_f)( UINT InfoClass,
|
||||
UINT InfoType,
|
||||
UINT InfoId,
|
||||
PVOID Context,
|
||||
TDIEntityID *id,
|
||||
PNDIS_BUFFER Buffer,
|
||||
PUINT BufferSize );
|
||||
|
||||
typedef TDI_STATUS (*InfoSet_f)( UINT InfoClass,
|
||||
UINT InfoType,
|
||||
UINT InfoId,
|
||||
PVOID Context,
|
||||
TDIEntityID *id,
|
||||
PCHAR Buffer,
|
||||
UINT BufferSize );
|
||||
|
||||
/* Sufficient information to manage the entity list */
|
||||
typedef struct {
|
||||
UINT tei_entity;
|
||||
UINT tei_instance;
|
||||
PVOID context;
|
||||
InfoRequest_f info_req;
|
||||
InfoSet_f info_set;
|
||||
} TDIEntityInfo;
|
||||
|
||||
#ifndef htons
|
||||
#define htons(x) ((((x) & 0xff) << 8) | (((x) >> 8) & 0xff))
|
||||
#endif
|
||||
|
||||
/* Global variable */
|
||||
extern PDEVICE_OBJECT TCPDeviceObject;
|
||||
extern PDEVICE_OBJECT UDPDeviceObject;
|
||||
extern PDEVICE_OBJECT IPDeviceObject;
|
||||
extern PDEVICE_OBJECT RawIPDeviceObject;
|
||||
extern LIST_ENTRY InterfaceListHead;
|
||||
extern KSPIN_LOCK InterfaceListLock;
|
||||
extern LIST_ENTRY AddressFileListHead;
|
||||
extern KSPIN_LOCK AddressFileListLock;
|
||||
extern NDIS_HANDLE GlobalPacketPool;
|
||||
extern NDIS_HANDLE GlobalBufferPool;
|
||||
extern KSPIN_LOCK EntityListLock;
|
||||
extern TDIEntityInfo *EntityList;
|
||||
extern ULONG EntityCount;
|
||||
extern ULONG EntityMax;
|
||||
|
||||
extern NTSTATUS TiGetProtocolNumber( PUNICODE_STRING FileName,
|
||||
PULONG Protocol );
|
||||
|
||||
#endif /* __TCPIP_H */
|
||||
|
||||
/* EOF */
|
64
drivers/network/tcpip/include/ticonsts.h
Normal file
64
drivers/network/tcpip/include/ticonsts.h
Normal file
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS TCP/IP protocol driver
|
||||
* FILE: include/ticonsts.h
|
||||
* PURPOSE: TCP/IP protocol driver constants
|
||||
*/
|
||||
#ifndef __TICONSTS_H
|
||||
#define __TICONSTS_H
|
||||
|
||||
/* NDIS version this driver supports */
|
||||
#define NDIS_VERSION_MAJOR 4
|
||||
#define NDIS_VERSION_MINOR 0
|
||||
|
||||
#ifdef _NTTEST_
|
||||
/* Name of devices */
|
||||
#define DD_TCP_DEVICE_NAME L"\\Device\\NTTcp"
|
||||
#define DD_UDP_DEVICE_NAME L"\\Device\\NTUdp"
|
||||
#define DD_IP_DEVICE_NAME L"\\Device\\NTIp"
|
||||
#define DD_RAWIP_DEVICE_NAME L"\\Device\\NTRawIp"
|
||||
|
||||
/* For NDIS protocol registration */
|
||||
#define IP_DEVICE_NAME L"\\Device\\NTIp"
|
||||
#else
|
||||
#define DD_TCP_DEVICE_NAME L"\\Device\\Tcp"
|
||||
#define DD_UDP_DEVICE_NAME L"\\Device\\Udp"
|
||||
#define DD_IP_DEVICE_NAME L"\\Device\\Ip"
|
||||
#define DD_RAWIP_DEVICE_NAME L"\\Device\\RawIp"
|
||||
|
||||
/* For NDIS protocol registration */
|
||||
/* The DDK says you have to register with the name that's regstered with SCM, e.g. tcpip */
|
||||
#define IP_DEVICE_NAME L"\\Device\\Ip"
|
||||
#define TCPIP_PROTOCOL_NAME L"Tcpip"
|
||||
#endif /* _NTTEST_ */
|
||||
|
||||
/* TCP/UDP/RawIP IOCTL code definitions */
|
||||
|
||||
#define FSCTL_TCP_BASE FILE_DEVICE_NETWORK
|
||||
|
||||
#define _TCP_CTL_CODE(Function, Method, Access) \
|
||||
CTL_CODE(FSCTL_TCP_BASE, Function, Method, Access)
|
||||
|
||||
#define IOCTL_TCP_QUERY_INFORMATION_EX \
|
||||
_TCP_CTL_CODE(0, METHOD_NEITHER, FILE_ANY_ACCESS)
|
||||
|
||||
#define IOCTL_TCP_SET_INFORMATION_EX \
|
||||
_TCP_CTL_CODE(1, METHOD_BUFFERED, FILE_WRITE_ACCESS)
|
||||
|
||||
#define IOCTL_SET_IP_ADDRESS \
|
||||
_TCP_CTL_CODE(14, METHOD_BUFFERED, FILE_WRITE_ACCESS)
|
||||
|
||||
#define IOCTL_DELETE_IP_ADDRESS \
|
||||
_TCP_CTL_CODE(16, METHOD_BUFFERED, FILE_WRITE_ACCESS)
|
||||
|
||||
/* Unique error values for log entries */
|
||||
#define TI_ERROR_DRIVERENTRY 0
|
||||
|
||||
/* Internal status codes */
|
||||
#define IP_SUCCESS 0x0000 /* Successful */
|
||||
#define IP_NO_RESOURCES 0x0001 /* Not enough free resources */
|
||||
#define IP_NO_ROUTE_TO_DESTINATION 0x0002 /* No route to destination */
|
||||
|
||||
#endif /* __TICONSTS_H */
|
||||
|
||||
/* EOF */
|
27
drivers/network/tcpip/include/tilists.h
Normal file
27
drivers/network/tcpip/include/tilists.h
Normal file
|
@ -0,0 +1,27 @@
|
|||
#ifndef _TILISTS_H
|
||||
#define _TILISTS_H
|
||||
|
||||
#define TIPASTE(x,y) x ## y
|
||||
|
||||
#define IF_LIST_ITER(n) \
|
||||
PLIST_ENTRY TIPASTE(n,Entry); \
|
||||
PIP_INTERFACE n;
|
||||
|
||||
#define ForEachInterface(n) \
|
||||
TIPASTE(n,Entry) = InterfaceListHead.Flink; \
|
||||
while (TIPASTE(n,Entry) != &InterfaceListHead) { \
|
||||
TI_DbgPrint \
|
||||
(MAX_TRACE,( # n ": %x\n", \
|
||||
TIPASTE(n,Entry))); \
|
||||
ASSERT(TIPASTE(n,Entry)); \
|
||||
n = CONTAINING_RECORD(TIPASTE(n,Entry), IP_INTERFACE, \
|
||||
ListEntry); \
|
||||
ASSERT(n);
|
||||
|
||||
#define EndFor(n) \
|
||||
TI_DbgPrint(MAX_TRACE,("Next " # n " %x\n", \
|
||||
TIPASTE(n,Entry->Flink))); \
|
||||
TIPASTE(n,Entry) = TIPASTE(n,Entry)->Flink; \
|
||||
}
|
||||
|
||||
#endif/*_TILISTS_H*/
|
350
drivers/network/tcpip/include/titypes.h
Normal file
350
drivers/network/tcpip/include/titypes.h
Normal file
|
@ -0,0 +1,350 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS TCP/IP protocol driver
|
||||
* FILE: include/titypes.h
|
||||
* PURPOSE: TCP/IP protocol driver types
|
||||
*/
|
||||
#ifndef __TITYPES_H
|
||||
#define __TITYPES_H
|
||||
|
||||
|
||||
#ifdef DBG
|
||||
|
||||
#define DEFINE_TAG ULONG Tag;
|
||||
#define INIT_TAG(_Object, _Tag) \
|
||||
((_Object)->Tag = (_Tag))
|
||||
|
||||
#define DEBUG_REFCHECK(Object) { \
|
||||
if ((Object)->RefCount <= 0) { \
|
||||
TI_DbgPrint(MIN_TRACE, ("Object at (0x%X) has invalid reference count (%d).\n", \
|
||||
(Object), (Object)->RefCount)); \
|
||||
} \
|
||||
}
|
||||
|
||||
/*
|
||||
* VOID ReferenceObject(
|
||||
* PVOID Object)
|
||||
*/
|
||||
#define ReferenceObject(Object) \
|
||||
{ \
|
||||
CHAR c1, c2, c3, c4; \
|
||||
\
|
||||
c1 = ((Object)->Tag >> 24) & 0xFF; \
|
||||
c2 = ((Object)->Tag >> 16) & 0xFF; \
|
||||
c3 = ((Object)->Tag >> 8) & 0xFF; \
|
||||
c4 = ((Object)->Tag & 0xFF); \
|
||||
\
|
||||
DEBUG_REFCHECK(Object); \
|
||||
TI_DbgPrint(DEBUG_REFCOUNT, ("Referencing object of type (%c%c%c%c) at (0x%X). RefCount (%d).\n", \
|
||||
c4, c3, c2, c1, (Object), (Object)->RefCount)); \
|
||||
\
|
||||
InterlockedIncrement(&((Object)->RefCount)); \
|
||||
}
|
||||
|
||||
/*
|
||||
* VOID DereferenceObject(
|
||||
* PVOID Object)
|
||||
*/
|
||||
#define DereferenceObject(Object) \
|
||||
{ \
|
||||
CHAR c1, c2, c3, c4; \
|
||||
\
|
||||
c1 = ((Object)->Tag >> 24) & 0xFF; \
|
||||
c2 = ((Object)->Tag >> 16) & 0xFF; \
|
||||
c3 = ((Object)->Tag >> 8) & 0xFF; \
|
||||
c4 = ((Object)->Tag & 0xFF); \
|
||||
\
|
||||
DEBUG_REFCHECK(Object); \
|
||||
TI_DbgPrint(DEBUG_REFCOUNT, ("Dereferencing object of type (%c%c%c%c) at (0x%X). RefCount (%d).\n", \
|
||||
c4, c3, c2, c1, (Object), (Object)->RefCount)); \
|
||||
\
|
||||
if (InterlockedDecrement(&((Object)->RefCount)) == 0) \
|
||||
(((Object)->Free)(Object)); \
|
||||
}
|
||||
|
||||
#else /* DBG */
|
||||
|
||||
#define DEFINE_TAG
|
||||
#define INIT_TAG(Object, Tag)
|
||||
|
||||
/*
|
||||
* VOID ReferenceObject(
|
||||
* PVOID Object)
|
||||
*/
|
||||
#define ReferenceObject(Object) \
|
||||
{ \
|
||||
InterlockedIncrement(&((Object)->RefCount)); \
|
||||
}
|
||||
|
||||
/*
|
||||
* VOID DereferenceObject(
|
||||
* PVOID Object)
|
||||
*/
|
||||
#define DereferenceObject(Object) \
|
||||
{ \
|
||||
if (InterlockedDecrement(&((Object)->RefCount)) == 0) \
|
||||
(((Object)->Free)(Object)); \
|
||||
}
|
||||
|
||||
#endif /* DBG */
|
||||
|
||||
|
||||
#include <ip.h>
|
||||
|
||||
struct _ADDRESS_FILE;
|
||||
|
||||
/***************************************************
|
||||
* Connection-less communication support structures *
|
||||
***************************************************/
|
||||
|
||||
typedef NTSTATUS (*DATAGRAM_SEND_ROUTINE)(
|
||||
struct _ADDRESS_FILE *AddrFile,
|
||||
PTDI_CONNECTION_INFORMATION ConnInfo,
|
||||
PCHAR Buffer,
|
||||
ULONG DataSize,
|
||||
PULONG DataUsed);
|
||||
|
||||
/* Datagram completion handler prototype */
|
||||
typedef VOID (*DATAGRAM_COMPLETION_ROUTINE)(
|
||||
PVOID Context,
|
||||
NDIS_STATUS Status,
|
||||
ULONG Count);
|
||||
|
||||
typedef DATAGRAM_COMPLETION_ROUTINE PDATAGRAM_COMPLETION_ROUTINE;
|
||||
|
||||
typedef struct _DATAGRAM_RECEIVE_REQUEST {
|
||||
struct _ADDRESS_FILE *AddressFile; /* AddressFile on behalf of */
|
||||
LIST_ENTRY ListEntry; /* Entry on list */
|
||||
IP_ADDRESS RemoteAddress; /* Remote address we receive from (NULL means any) */
|
||||
USHORT RemotePort; /* Remote port we receive from (0 means any) */
|
||||
PTDI_CONNECTION_INFORMATION ReturnInfo;/* Return information */
|
||||
PCHAR Buffer; /* Pointer to receive buffer */
|
||||
ULONG BufferSize; /* Size of Buffer */
|
||||
DATAGRAM_COMPLETION_ROUTINE Complete; /* Completion routine */
|
||||
PVOID Context; /* Pointer to context information */
|
||||
DATAGRAM_COMPLETION_ROUTINE UserComplete; /* Completion routine */
|
||||
PVOID UserContext; /* Pointer to context information */
|
||||
PIRP Irp; /* IRP on behalf of */
|
||||
} DATAGRAM_RECEIVE_REQUEST, *PDATAGRAM_RECEIVE_REQUEST;
|
||||
|
||||
/* Datagram build routine prototype */
|
||||
typedef NTSTATUS (*DATAGRAM_BUILD_ROUTINE)(
|
||||
PVOID Context,
|
||||
PIP_ADDRESS LocalAddress,
|
||||
USHORT LocalPort,
|
||||
PIP_PACKET *IPPacket);
|
||||
|
||||
typedef struct _DATAGRAM_SEND_REQUEST {
|
||||
LIST_ENTRY ListEntry;
|
||||
PNDIS_PACKET PacketToSend;
|
||||
DATAGRAM_COMPLETION_ROUTINE Complete; /* Completion routine */
|
||||
PVOID Context; /* Pointer to context information */
|
||||
IP_PACKET Packet;
|
||||
UINT BufferSize;
|
||||
IP_ADDRESS RemoteAddress;
|
||||
USHORT RemotePort;
|
||||
ULONG Flags; /* Protocol specific flags */
|
||||
} DATAGRAM_SEND_REQUEST, *PDATAGRAM_SEND_REQUEST;
|
||||
|
||||
/* Transport address file context structure. The FileObject->FsContext2
|
||||
field holds a pointer to this structure */
|
||||
typedef struct _ADDRESS_FILE {
|
||||
DEFINE_TAG
|
||||
LIST_ENTRY ListEntry; /* Entry on list */
|
||||
KSPIN_LOCK Lock; /* Spin lock to manipulate this structure */
|
||||
OBJECT_FREE_ROUTINE Free; /* Routine to use to free resources for the object */
|
||||
USHORT Flags; /* Flags for address file (see below) */
|
||||
IP_ADDRESS Address; /* Address of this address file */
|
||||
USHORT Family; /* Address family */
|
||||
USHORT Protocol; /* Protocol number */
|
||||
USHORT Port; /* Network port (network byte order) */
|
||||
WORK_QUEUE_ITEM WorkItem; /* Work queue item handle */
|
||||
DATAGRAM_COMPLETION_ROUTINE Complete; /* Completion routine for delete request */
|
||||
PVOID Context; /* Delete request context */
|
||||
DATAGRAM_SEND_ROUTINE Send; /* Routine to send a datagram */
|
||||
LIST_ENTRY ReceiveQueue; /* List of outstanding receive requests */
|
||||
LIST_ENTRY TransmitQueue; /* List of outstanding transmit requests */
|
||||
struct _CONNECTION_ENDPOINT *Connection;
|
||||
/* Associated connection or NULL if no associated connection exist */
|
||||
struct _CONNECTION_ENDPOINT *Listener;
|
||||
/* Associated listener (see transport/tcp/accept.c) */
|
||||
IP_ADDRESS AddrCache; /* One entry address cache (destination
|
||||
address of last packet transmitted) */
|
||||
|
||||
/* The following members are used to control event notification */
|
||||
|
||||
/* Connection indication handler */
|
||||
PTDI_IND_CONNECT ConnectHandler;
|
||||
PVOID ConnectHandlerContext;
|
||||
BOOL RegisteredConnectHandler;
|
||||
/* Disconnect indication handler */
|
||||
PTDI_IND_DISCONNECT DisconnectHandler;
|
||||
PVOID DisconnectHandlerContext;
|
||||
BOOL RegisteredDisconnectHandler;
|
||||
/* Error indication handler */
|
||||
PTDI_IND_ERROR ErrorHandler;
|
||||
PVOID ErrorHandlerContext;
|
||||
PVOID ErrorHandlerOwner;
|
||||
BOOL RegisteredErrorHandler;
|
||||
/* Receive indication handler */
|
||||
PTDI_IND_RECEIVE ReceiveHandler;
|
||||
PVOID ReceiveHandlerContext;
|
||||
BOOL RegisteredReceiveHandler;
|
||||
/* Receive datagram indication handler */
|
||||
PTDI_IND_RECEIVE_DATAGRAM ReceiveDatagramHandler;
|
||||
PVOID ReceiveDatagramHandlerContext;
|
||||
BOOL RegisteredReceiveDatagramHandler;
|
||||
/* Expedited receive indication handler */
|
||||
PTDI_IND_RECEIVE_EXPEDITED ExpeditedReceiveHandler;
|
||||
PVOID ExpeditedReceiveHandlerContext;
|
||||
BOOL RegisteredExpeditedReceiveHandler;
|
||||
/* Chained receive indication handler */
|
||||
PTDI_IND_CHAINED_RECEIVE ChainedReceiveHandler;
|
||||
PVOID ChainedReceiveHandlerContext;
|
||||
BOOL RegisteredChainedReceiveHandler;
|
||||
/* Chained receive datagram indication handler */
|
||||
PTDI_IND_CHAINED_RECEIVE_DATAGRAM ChainedReceiveDatagramHandler;
|
||||
PVOID ChainedReceiveDatagramHandlerContext;
|
||||
BOOL RegisteredChainedReceiveDatagramHandler;
|
||||
/* Chained expedited receive indication handler */
|
||||
PTDI_IND_CHAINED_RECEIVE_EXPEDITED ChainedReceiveExpeditedHandler;
|
||||
PVOID ChainedReceiveExpeditedHandlerContext;
|
||||
BOOL RegisteredChainedReceiveExpeditedHandler;
|
||||
} ADDRESS_FILE, *PADDRESS_FILE;
|
||||
|
||||
/* Address File Flag constants */
|
||||
#define AFF_VALID 0x0001 /* Address file object is valid for use */
|
||||
#define AFF_BUSY 0x0002 /* Address file object is exclusive to someone */
|
||||
#define AFF_DELETE 0x0004 /* Address file object is sheduled to be deleted */
|
||||
#define AFF_SEND 0x0008 /* A send request is pending */
|
||||
#define AFF_RECEIVE 0x0010 /* A receive request is pending */
|
||||
#define AFF_PENDING 0x001C /* A request is pending */
|
||||
|
||||
/* Macros for manipulating address file object flags */
|
||||
|
||||
#define AF_IS_VALID(ADF) ((ADF)->Flags & AFF_VALID)
|
||||
#define AF_SET_VALID(ADF) ((ADF)->Flags |= AFF_VALID)
|
||||
#define AF_CLR_VALID(ADF) ((ADF)->Flags &= ~AFF_VALID)
|
||||
|
||||
#define AF_IS_BUSY(ADF) ((ADF)->Flags & AFF_BUSY)
|
||||
#define AF_SET_BUSY(ADF) ((ADF)->Flags |= AFF_BUSY)
|
||||
#define AF_CLR_BUSY(ADF) ((ADF)->Flags &= ~AFF_BUSY)
|
||||
|
||||
#define AF_IS_PENDING(ADF, X) (ADF->Flags & X)
|
||||
#define AF_SET_PENDING(ADF, X) (ADF->Flags |= X)
|
||||
#define AF_CLR_PENDING(ADF, X) (ADF->Flags &= ~X)
|
||||
|
||||
|
||||
/* Structure used to search through Address Files */
|
||||
typedef struct _AF_SEARCH {
|
||||
PLIST_ENTRY Next; /* Next address file to check */
|
||||
PIP_ADDRESS Address; /* Pointer to address to be found */
|
||||
USHORT Port; /* Network port */
|
||||
USHORT Protocol; /* Protocol number */
|
||||
} AF_SEARCH, *PAF_SEARCH;
|
||||
|
||||
/*******************************************************
|
||||
* Connection-oriented communication support structures *
|
||||
*******************************************************/
|
||||
|
||||
typedef struct _TCP_RECEIVE_REQUEST {
|
||||
LIST_ENTRY ListEntry; /* Entry on list */
|
||||
PNDIS_BUFFER Buffer; /* Pointer to receive buffer */
|
||||
ULONG BufferSize; /* Size of Buffer */
|
||||
DATAGRAM_COMPLETION_ROUTINE Complete; /* Completion routine */
|
||||
PVOID Context; /* Pointer to context information */
|
||||
} TCP_RECEIVE_REQUEST, *PTCP_RECEIVE_REQUEST;
|
||||
|
||||
/* Connection states */
|
||||
typedef enum {
|
||||
ctListen = 0, /* Waiting for incoming connection requests */
|
||||
ctSynSent, /* Waiting for matching connection request */
|
||||
ctSynReceived, /* Waiting for connection request acknowledgment */
|
||||
ctEstablished, /* Connection is open for data transfer */
|
||||
ctFinWait1, /* Waiting for termination request or ack. for same */
|
||||
ctFinWait2, /* Waiting for termination request from remote TCP */
|
||||
ctCloseWait, /* Waiting for termination request from local user */
|
||||
ctClosing, /* Waiting for termination ack. from remote TCP */
|
||||
ctLastAck, /* Waiting for termination request ack. from remote TCP */
|
||||
ctTimeWait, /* Waiting for enough time to pass to be sure the remote TCP
|
||||
received the ack. of its connection termination request */
|
||||
ctClosed /* Represents a closed connection */
|
||||
} CONNECTION_STATE, *PCONNECTION_STATE;
|
||||
|
||||
|
||||
/* Structure for an TCP segment */
|
||||
typedef struct _TCP_SEGMENT {
|
||||
LIST_ENTRY ListEntry;
|
||||
PIP_PACKET IPPacket; /* Pointer to IP packet */
|
||||
PVOID SegmentData; /* Pointer to segment data */
|
||||
ULONG SequenceNumber; /* Sequence number of first byte in segment */
|
||||
ULONG Length; /* Number of bytes in segment */
|
||||
ULONG BytesDelivered; /* Number of bytes already delivered to the client */
|
||||
} TCP_SEGMENT, *PTCP_SEGMENT;
|
||||
|
||||
typedef struct _TDI_BUCKET {
|
||||
LIST_ENTRY Entry;
|
||||
struct _CONNECTION_ENDPOINT *AssociatedEndpoint;
|
||||
TDI_REQUEST Request;
|
||||
} TDI_BUCKET, *PTDI_BUCKET;
|
||||
|
||||
/* Transport connection context structure A.K.A. Transmission Control Block
|
||||
(TCB) in TCP terminology. The FileObject->FsContext2 field holds a pointer
|
||||
to this structure */
|
||||
typedef struct _CONNECTION_ENDPOINT {
|
||||
LIST_ENTRY ListEntry; /* Entry on list */
|
||||
KSPIN_LOCK Lock; /* Spin lock to protect this structure */
|
||||
PVOID ClientContext; /* Pointer to client context information */
|
||||
PADDRESS_FILE AddressFile; /* Associated address file object (NULL if none) */
|
||||
PVOID SocketContext; /* Context for lower layer */
|
||||
|
||||
UINT State; /* Socket state W.R.T. oskit */
|
||||
|
||||
/* Requests */
|
||||
LIST_ENTRY ConnectRequest; /* Queued connect rqueusts */
|
||||
LIST_ENTRY ListenRequest; /* Queued listen requests */
|
||||
LIST_ENTRY ReceiveRequest; /* Queued receive requests */
|
||||
LIST_ENTRY SendRequest; /* Queued send requests */
|
||||
|
||||
/* Signals */
|
||||
LIST_ENTRY SignalList; /* Entry in the list of sockets waiting for
|
||||
* notification service to the client */
|
||||
UINT SignalState; /* Active signals from oskit */
|
||||
BOOLEAN Signalled; /* Are we a member of the signal list */
|
||||
} CONNECTION_ENDPOINT, *PCONNECTION_ENDPOINT;
|
||||
|
||||
|
||||
|
||||
/*************************
|
||||
* TDI support structures *
|
||||
*************************/
|
||||
|
||||
/* Transport control channel context structure. The FileObject->FsContext2
|
||||
field holds a pointer to this structure */
|
||||
typedef struct _CONTROL_CHANNEL {
|
||||
LIST_ENTRY ListEntry; /* Entry on list */
|
||||
KSPIN_LOCK Lock; /* Spin lock to protect this structure */
|
||||
} CONTROL_CHANNEL, *PCONTROL_CHANNEL;
|
||||
|
||||
/* Transport (TCP/UDP) endpoint context structure. The FileObject->FsContext
|
||||
field holds a pointer to this structure */
|
||||
typedef struct _TRANSPORT_CONTEXT {
|
||||
union {
|
||||
HANDLE AddressHandle;
|
||||
CONNECTION_CONTEXT ConnectionContext;
|
||||
HANDLE ControlChannel;
|
||||
} Handle;
|
||||
BOOL CancelIrps;
|
||||
KEVENT CleanupEvent;
|
||||
} TRANSPORT_CONTEXT, *PTRANSPORT_CONTEXT;
|
||||
|
||||
typedef struct _TI_QUERY_CONTEXT {
|
||||
PIRP Irp;
|
||||
PMDL InputMdl;
|
||||
PMDL OutputMdl;
|
||||
TCP_REQUEST_QUERY_INFORMATION_EX QueryInfo;
|
||||
} TI_QUERY_CONTEXT, *PTI_QUERY_CONTEXT;
|
||||
|
||||
#endif /* __TITYPES_H */
|
||||
|
||||
/* EOF */
|
38
drivers/network/tcpip/include/transmit.h
Normal file
38
drivers/network/tcpip/include/transmit.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS TCP/IP protocol driver
|
||||
* FILE: include/transmit.h
|
||||
* PURPOSE: Internet Protocol transmit prototypes
|
||||
*/
|
||||
#ifndef __TRANSMIT_H
|
||||
#define __TRANSMIT_H
|
||||
|
||||
typedef VOID (*PIP_TRANSMIT_COMPLETE)( PVOID Context,
|
||||
PNDIS_PACKET Packet,
|
||||
NDIS_STATUS Status );
|
||||
|
||||
/* IP fragment context information */
|
||||
typedef struct IPFRAGMENT_CONTEXT {
|
||||
struct IPFRAGMENT_CONTEXT *Next; /* Pointer to next in list */
|
||||
PNDIS_PACKET Datagram; /* Pointer to original NDIS packet */
|
||||
PVOID DatagramData; /* Pointer to datagram data */
|
||||
UINT HeaderSize; /* IP datagram header size */
|
||||
PNDIS_PACKET NdisPacket; /* Pointer to NDIS packet */
|
||||
PNDIS_BUFFER NdisBuffer; /* Pointer to NDIS buffer */
|
||||
PVOID Header; /* Pointer to IP header in fragment buffer */
|
||||
PVOID Data; /* Pointer to fragment data */
|
||||
UINT Position; /* Current fragment offset */
|
||||
UINT BytesLeft; /* Number of bytes left to send */
|
||||
UINT PathMTU; /* Path Maximum Transmission Unit */
|
||||
PNEIGHBOR_CACHE_ENTRY NCE; /* Pointer to NCE to use */
|
||||
PIP_TRANSMIT_COMPLETE Complete; /* Completion Routine */
|
||||
PVOID Context; /* Completion Context */
|
||||
} IPFRAGMENT_CONTEXT, *PIPFRAGMENT_CONTEXT;
|
||||
|
||||
|
||||
NTSTATUS IPSendDatagram(PIP_PACKET IPPacket, PNEIGHBOR_CACHE_ENTRY NCE,
|
||||
PIP_TRANSMIT_COMPLETE Complete, PVOID Context);
|
||||
|
||||
#endif /* __TRANSMIT_H */
|
||||
|
||||
/* EOF */
|
67
drivers/network/tcpip/include/udp.h
Normal file
67
drivers/network/tcpip/include/udp.h
Normal file
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS TCP/IP protocol driver
|
||||
* FILE: include/udp.h
|
||||
* PURPOSE: User Datagram Protocol definitions
|
||||
*/
|
||||
#ifndef __UDP_H
|
||||
#define __UDP_H
|
||||
|
||||
#define UDP_STARTING_PORT 0x8000
|
||||
#define UDP_DYNAMIC_PORTS 0x8000
|
||||
|
||||
/* UDPv4 header structure */
|
||||
#include <pshpack1.h>
|
||||
typedef struct UDP_HEADER {
|
||||
USHORT SourcePort; /* Source port */
|
||||
USHORT DestPort; /* Destination port */
|
||||
USHORT Length; /* Size of header and data */
|
||||
USHORT Checksum; /* Checksum of datagram */
|
||||
} UDP_HEADER, *PUDP_HEADER;
|
||||
|
||||
/* UDPv4 pseudo header */
|
||||
typedef struct UDP_PSEUDO_HEADER {
|
||||
ULONG SourceAddress; /* Source address */
|
||||
ULONG DestAddress; /* Destination address */
|
||||
UCHAR Zero; /* Reserved */
|
||||
UCHAR Protocol; /* Protocol */
|
||||
USHORT UDPLength; /* Size of UDP datagram */
|
||||
} UDP_PSEUDO_HEADER, *PUDP_PSEUDO_HEADER;
|
||||
#include <poppack.h>
|
||||
|
||||
typedef struct UDP_STATISTICS {
|
||||
ULONG InputDatagrams;
|
||||
ULONG NumPorts;
|
||||
ULONG InputErrors;
|
||||
ULONG OutputDatagrams;
|
||||
ULONG NumAddresses;
|
||||
} UDP_STATISTICS, *PUDP_STATISTICS;
|
||||
|
||||
extern UDP_STATISTICS UDPStats;
|
||||
|
||||
VOID UDPSend(
|
||||
PVOID Context,
|
||||
PDATAGRAM_SEND_REQUEST SendRequest);
|
||||
|
||||
NTSTATUS UDPSendDatagram(
|
||||
PADDRESS_FILE AddrFile,
|
||||
PTDI_CONNECTION_INFORMATION ConnInfo,
|
||||
PCHAR BufferData,
|
||||
ULONG DataSize,
|
||||
PULONG DataUsed );
|
||||
|
||||
VOID UDPReceive(
|
||||
PIP_INTERFACE Interface,
|
||||
PIP_PACKET IPPacket);
|
||||
|
||||
NTSTATUS UDPStartup(
|
||||
VOID);
|
||||
|
||||
NTSTATUS UDPShutdown(
|
||||
VOID);
|
||||
UINT UDPAllocatePort( UINT HintPort );
|
||||
VOID UDPFreePort( UINT Port );
|
||||
|
||||
#endif /* __UDP_H */
|
||||
|
||||
/* EOF */
|
10
drivers/network/tcpip/include/wait.h
Normal file
10
drivers/network/tcpip/include/wait.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
#ifndef _TCPIP_WAIT_H
|
||||
#define _TCPIP_WAIT_H
|
||||
|
||||
NTSTATUS TcpipWaitForSingleObject( PVOID Object,
|
||||
KWAIT_REASON Reason,
|
||||
KPROCESSOR_MODE WaitMode,
|
||||
BOOLEAN Alertable,
|
||||
PLARGE_INTEGER Timeout );
|
||||
|
||||
#endif/*_TCPIP_WAIT_H*/
|
Loading…
Add table
Add a link
Reference in a new issue