ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

ip.h
Go to the documentation of this file.
00001 /*
00002  * COPYRIGHT:   See COPYING in the top level directory
00003  * PROJECT:     ReactOS TCP/IP protocol driver
00004  * FILE:        include/ip.h
00005  * PURPOSE:     Internet Protocol related definitions
00006  */
00007 
00008 #pragma once
00009 
00010 typedef VOID (*OBJECT_FREE_ROUTINE)(PVOID Object);
00011 
00012 #define FOURCC(a,b,c,d) (((a)<<24)|((b)<<16)|((c)<<8)|(d))
00013 
00014 /* Raw IPv4 style address */
00015 typedef ULONG IPv4_RAW_ADDRESS;
00016 typedef IPv4_RAW_ADDRESS *PIPv4_RAW_ADDRESS;
00017 
00018 /* Raw IPv6 style address */
00019 typedef USHORT IPv6_RAW_ADDRESS[8];
00020 typedef IPv6_RAW_ADDRESS *PIPv6_RAW_ADDRESS;
00021 
00022 /* IP style address */
00023 typedef struct IP_ADDRESS {
00024     UCHAR Type;                      /* Type of IP address */
00025     union {
00026         IPv4_RAW_ADDRESS IPv4Address;/* IPv4 address (in network byte order) */
00027         IPv6_RAW_ADDRESS IPv6Address;/* IPv6 address (in network byte order) */
00028     } Address;
00029 } IP_ADDRESS, *PIP_ADDRESS;
00030 
00031 /* IP type constants */
00032 #define IP_ADDRESS_V4   0x04 /* IPv4 style address */
00033 #define IP_ADDRESS_V6   0x06 /* IPv6 style address */
00034 
00035 
00036 /* IPv4 header format */
00037 typedef struct IPv4_HEADER {
00038     UCHAR VerIHL;                /* 4-bit version, 4-bit Internet Header Length */
00039     UCHAR Tos;                   /* Type of Service */
00040     USHORT TotalLength;          /* Total Length */
00041     USHORT Id;                   /* Identification */
00042     USHORT FlagsFragOfs;         /* 3-bit Flags, 13-bit Fragment Offset */
00043     UCHAR Ttl;                   /* Time to Live */
00044     UCHAR Protocol;              /* Protocol */
00045     USHORT Checksum;             /* Header Checksum */
00046     IPv4_RAW_ADDRESS SrcAddr;    /* Source Address */
00047     IPv4_RAW_ADDRESS DstAddr;    /* Destination Address */
00048 } IPv4_HEADER, *PIPv4_HEADER;
00049 
00050 /* IPv6 header format */
00051 typedef struct IPv6_HEADER {
00052     ULONG VTF;                   /* Version, Traffic Class, Flow Label */
00053     USHORT PayloadLength;
00054     UCHAR NextHeader;            /* Same as Protocol in IPv4 */
00055     UCHAR HopLimit;              /* Same as Ttl in IPv4 */
00056     IPv6_RAW_ADDRESS SrcAddr;
00057     IPv6_RAW_ADDRESS DstAddr;
00058 } IPv6_HEADER, *PIPv6_HEADER;
00059 
00060 typedef union _IP_HEADER {
00061     IPv4_HEADER v4;
00062     IPv6_HEADER v6;
00063 } IP_HEADER, *PIP_HEADER;
00064 
00065 #define IPv4_FRAGOFS_MASK       0x1FFF /* Fragment offset mask (host byte order) */
00066 #define IPv4_MF_MASK            0x2000 /* More fragments (host byte order) */
00067 #define IPv4_DF_MASK            0x4000 /* Don't fragment (host byte order) */
00068 #define IPv4_MAX_HEADER_SIZE    60
00069 
00070 /* Packet completion handler prototype */
00071 typedef VOID (*PACKET_COMPLETION_ROUTINE)(
00072     PVOID Context,
00073     PNDIS_PACKET NdisPacket,
00074     NDIS_STATUS NdisStatus);
00075 
00076 /* Structure for an IP packet */
00077 typedef struct _IP_PACKET {
00078     OBJECT_FREE_ROUTINE Free;           /* Routine used to free resources for the object */
00079     UCHAR Type;                         /* Type of IP packet (see IP_ADDRESS_xx above) */
00080     UCHAR Flags;                        /* Flags for packet (see IP_PACKET_FLAG_xx below)*/
00081     BOOLEAN MappedHeader;               /* States whether Header is from an MDL or allocated from pool */
00082     BOOLEAN ReturnPacket;               /* States whether NdisPacket should be passed to NdisReturnPackets */
00083     PVOID Header;                       /* Pointer to IP header for this packet */
00084     UINT HeaderSize;                    /* Size of IP header */
00085     PVOID Data;                         /* Current pointer into packet data */
00086     UINT TotalSize;                     /* Total amount of data in packet (IP header and data) */
00087     UINT Position;                      /* Current logical offset into packet */
00088     PNDIS_PACKET NdisPacket;            /* Pointer to NDIS packet */
00089     IP_ADDRESS SrcAddr;                 /* Source address */
00090     IP_ADDRESS DstAddr;                 /* Destination address */
00091 } IP_PACKET, *PIP_PACKET;
00092 
00093 #define IP_PACKET_FLAG_RAW      0x01    /* Raw IP packet */
00094 
00095 
00096 /* Packet context */
00097 typedef struct _PACKET_CONTEXT {
00098     PACKET_COMPLETION_ROUTINE DLComplete; /* Data link level completion handler
00099                        * Also used to link to next packet
00100                        * in a queue */
00101     PVOID Context;                        /* Context information for handler */
00102     UINT  PacketType;                     /* Type of packet */
00103 } PACKET_CONTEXT, *PPACKET_CONTEXT;
00104 
00105 /* The ProtocolReserved field is structured as a PACKET_CONTEXT */
00106 #define PC(Packet) ((PPACKET_CONTEXT)(&Packet->ProtocolReserved))
00107 
00108 /* Values for address type -- also the interface flags */
00109 /* These values are mean to overlap meaningfully with the BSD ones */
00110 #define ADE_UNICAST     0x01
00111 #define ADE_BROADCAST   0x02
00112 #define ADE_ADDRMASK    0x04
00113 #define ADE_POINTOPOINT 0x10
00114 #define ADE_MULTICAST   0x8000
00115 
00116 /* There is one NTE for each source (unicast) address assigned to an interface */
00117 /* Link layer transmit prototype */
00118 typedef VOID (*LL_TRANSMIT_ROUTINE)(
00119     PVOID Context,
00120     PNDIS_PACKET NdisPacket,
00121     UINT Offset,
00122     PVOID LinkAddress,
00123     USHORT Type);
00124 
00125 /* Link layer to IP binding information */
00126 typedef struct _LLIP_BIND_INFO {
00127     PVOID Context;                /* Pointer to link layer context information */
00128     UINT  HeaderSize;             /* Size of link level header */
00129     UINT  MinFrameSize;           /* Minimum frame size in bytes */
00130     PUCHAR Address;               /* Pointer to interface address */
00131     UINT  AddressLength;          /* Length of address in bytes */
00132     LL_TRANSMIT_ROUTINE Transmit; /* Transmit function for this interface */
00133 } LLIP_BIND_INFO, *PLLIP_BIND_INFO;
00134 
00135 typedef struct _SEND_RECV_STATS {
00136     UINT InBytes;
00137     UINT InUnicast;
00138     UINT InNUnicast;
00139     UINT InDiscarded;
00140     UINT InErrors;
00141     UINT InDiscardedUnknownProto;
00142     UINT OutBytes;
00143     UINT OutUnicast;
00144     UINT OutNUnicast;
00145     UINT OutDiscarded;
00146     UINT OutErrors;
00147 } SEND_RECV_STATS, *PSEND_RECV_STATS;
00148 
00149 /* Information about an IP interface */
00150 typedef struct _IP_INTERFACE {
00151     LIST_ENTRY ListEntry;         /* Entry on list */
00152     OBJECT_FREE_ROUTINE Free;     /* Routine used to free resources used by the object */
00153     KSPIN_LOCK Lock;              /* Spin lock for this object */
00154     PVOID Context;                /* Pointer to link layer context information */
00155     UINT  HeaderSize;             /* Size of link level header */
00156     UINT  MinFrameSize;           /* Minimum frame size in bytes */
00157     UINT  MTU;                    /* Maximum transmission unit */
00158     UINT  Speed;                  /* Link speed */
00159     IP_ADDRESS Unicast;           /* Unicast address */
00160     IP_ADDRESS PointToPoint;      /* Point to point address */
00161     IP_ADDRESS Netmask;           /* Netmask */
00162     IP_ADDRESS Broadcast;         /* Broadcast */
00163     UNICODE_STRING Name;          /* Adapter name (GUID) */
00164     UNICODE_STRING Description;   /* Adapter description (Human readable) */
00165     PUCHAR Address;               /* Pointer to interface address */
00166     UINT  AddressLength;          /* Length of address in bytes */
00167     UINT  Index;                  /* Index of adapter (used to add ip addr) */
00168     LL_TRANSMIT_ROUTINE Transmit; /* Pointer to transmit function */
00169     PVOID TCPContext;             /* TCP Content for this interface */
00170     SEND_RECV_STATS Stats;        /* Send/Receive statistics */
00171 } IP_INTERFACE, *PIP_INTERFACE;
00172 
00173 typedef struct _IP_SET_ADDRESS {
00174     ULONG NteIndex;
00175     IPv4_RAW_ADDRESS Address;
00176     IPv4_RAW_ADDRESS Netmask;
00177 } IP_SET_ADDRESS, *PIP_SET_ADDRESS;
00178 
00179 #define IP_PROTOCOL_TABLE_SIZE 0x100
00180 
00181 typedef VOID (*IP_PROTOCOL_HANDLER)(
00182     PIP_INTERFACE Interface,
00183     PIP_PACKET IPPacket);
00184 
00185 /* Loopback adapter address information (network byte order) */
00186 #define LOOPBACK_ADDRESS_IPv4   ((IPv4_RAW_ADDRESS)DH2N(0x7F000001))
00187 #define LOOPBACK_BCASTADDR_IPv4 ((IPv4_RAW_ADDRESS)DH2N(0x7FFFFFFF))
00188 #define LOOPBACK_ADDRMASK_IPv4  ((IPv4_RAW_ADDRESS)DH2N(0xFF000000))
00189 
00190 /* Protocol definitions */
00191 #ifndef IPPROTO_RAW
00192 #define IPPROTO_RAW     0   /* Raw IP */
00193 #endif
00194 #define IPPROTO_ICMP    1   /* Internet Control Message Protocol */
00195 #define IPPROTO_IGMP    2   /* Internet Group Management Protocol */
00196 #define IPPROTO_TCP     6   /* Transmission Control Protocol */
00197 #define IPPROTO_UDP     17  /* User Datagram Protocol */
00198 
00199 /* Timeout timer constants */
00200 #define IP_TIMEOUT 1000 /* Timeout in milliseconds */
00201 #define IP_DEFAULT_LINK_SPEED  10000
00202 
00203 extern LIST_ENTRY InterfaceListHead;
00204 extern KSPIN_LOCK InterfaceListLock;
00205 extern LIST_ENTRY NetTableListHead;
00206 extern KSPIN_LOCK NetTableListLock;
00207 
00208 PIP_PACKET IPCreatePacket(
00209   ULONG Type);
00210 
00211 PIP_PACKET IPInitializePacket(
00212     PIP_PACKET IPPacket,
00213     ULONG Type);
00214 
00215 PIP_INTERFACE IPCreateInterface(
00216     PLLIP_BIND_INFO BindInfo);
00217 
00218 VOID IPAddInterfaceRoute(
00219     PIP_INTERFACE IF);
00220 
00221 VOID IPRemoveInterfaceRoute(
00222     PIP_INTERFACE IF);
00223 
00224 VOID IPDestroyInterface(
00225     PIP_INTERFACE IF);
00226 
00227 BOOLEAN IPRegisterInterface(
00228     PIP_INTERFACE IF);
00229 
00230 VOID IPUnregisterInterface(
00231     PIP_INTERFACE IF);
00232 
00233 VOID NTAPI IPTimeoutDpcFn(PKDPC Dpc,
00234                           PVOID DeferredContext,
00235                           PVOID SystemArgument1,
00236                           PVOID SystemArgument2);
00237 
00238 VOID IPDispatchProtocol(
00239     PIP_INTERFACE Interface,
00240     PIP_PACKET IPPacket);
00241 
00242 VOID IPRegisterProtocol(
00243     UINT ProtocolNumber,
00244     IP_PROTOCOL_HANDLER Handler);
00245 
00246 NTSTATUS IPStartup(PUNICODE_STRING RegistryPath);
00247 
00248 NTSTATUS IPShutdown(VOID);
00249 
00250 /* EOF */

Generated on Thu May 24 2012 04:24:25 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.