/** @file\r
\r
-Copyright (c) 2005 - 2006, Intel Corporation\r
+Copyright (c) 2005 - 2006, Intel Corporation.<BR>\r
All rights reserved. This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
\r
-Module Name:\r
-\r
- Ip4Input.h\r
-\r
-Abstract:\r
-\r
-\r
**/\r
\r
#ifndef __EFI_IP4_INPUT_H__\r
#define __EFI_IP4_INPUT_H__\r
\r
-enum {\r
+typedef enum {\r
IP4_MIN_HEADLEN = 20,\r
IP4_MAX_HEADLEN = 60,\r
\r
IP4_ASSEMLE_HASH_SIZE = 31,\r
IP4_FRAGMENT_LIFE = 120,\r
IP4_MAX_PACKET_SIZE = 65535\r
-};\r
-\r
-//\r
-// Per packet information for input process. LinkFlag specifies whether\r
-// the packet is received as Link layer unicast, multicast or broadcast.\r
-// The CastType is the IP layer cast type, such as IP multicast or unicast.\r
-// Start, End and Length are staffs used to assemble the packets. Start\r
-// is the sequence number of the first byte of data in the packet. Length\r
-// is the number of bytes of data. End = Start + Length, that is, the\r
-// sequence number of last byte + 1. Each assembled packet has a count down\r
-// life. If it isn't consumed before Life reaches zero, the packet is released.\r
-//\r
+} IP4_INPUT_ENUM_TYPES;\r
+\r
+///\r
+/// Per packet information for input process. LinkFlag specifies whether\r
+/// the packet is received as Link layer unicast, multicast or broadcast.\r
+/// The CastType is the IP layer cast type, such as IP multicast or unicast.\r
+/// Start, End and Length are staffs used to assemble the packets. Start\r
+/// is the sequence number of the first byte of data in the packet. Length\r
+/// is the number of bytes of data. End = Start + Length, that is, the\r
+/// sequence number of last byte + 1. Each assembled packet has a count down\r
+/// life. If it isn't consumed before Life reaches zero, the packet is released.\r
+///\r
typedef struct {\r
UINTN LinkFlag;\r
INTN CastType;\r
EFI_STATUS Status;\r
} IP4_CLIP_INFO;\r
\r
-//\r
-// Structure used to assemble IP packets.\r
-//\r
+///\r
+/// Structure used to assemble IP packets.\r
+///\r
typedef struct {\r
- NET_LIST_ENTRY Link;\r
+ LIST_ENTRY Link;\r
\r
//\r
// Identity of one IP4 packet. Each fragment of a packet has\r
\r
INTN TotalLen;\r
INTN CurLen;\r
- NET_LIST_ENTRY Fragments; // List of all the fragments of this packet\r
+ LIST_ENTRY Fragments; // List of all the fragments of this packet\r
\r
IP4_HEAD *Head; // IP head of the first fragment\r
IP4_CLIP_INFO *Info; // Per packet info of the first fragment\r
INTN Life; // Count down life for the packet.\r
} IP4_ASSEMBLE_ENTRY;\r
\r
-//\r
-// Each Ip service instance has an assemble table to reassemble\r
-// the packets before delivery to its children. It is organized\r
-// as hash table.\r
-//\r
+///\r
+/// Each Ip service instance has an assemble table to reassemble\r
+/// the packets before delivery to its children. It is organized\r
+/// as hash table.\r
+///\r
typedef struct {\r
- NET_LIST_ENTRY Bucket[IP4_ASSEMLE_HASH_SIZE];\r
+ LIST_ENTRY Bucket[IP4_ASSEMLE_HASH_SIZE];\r
} IP4_ASSEMBLE_TABLE;\r
\r
#define IP4_GET_CLIP_INFO(Packet) ((IP4_CLIP_INFO *) ((Packet)->ProtoData))\r
#define IP4_RXDATA_WRAP_SIZE(NumFrag) \\r
(sizeof (IP4_RXDATA_WRAP) + sizeof (EFI_IP4_FRAGMENT_DATA) * ((NumFrag) - 1))\r
\r
+/**\r
+ Initialize an already allocated assemble table. This is generally\r
+ the assemble table embedded in the IP4 service instance.\r
+\r
+ @param[in, out] Table The assemble table to initialize.\r
+\r
+**/\r
VOID\r
Ip4InitAssembleTable (\r
- IN IP4_ASSEMBLE_TABLE *Table\r
+ IN OUT IP4_ASSEMBLE_TABLE *Table\r
);\r
\r
+/**\r
+ Clean up the assemble table: remove all the fragments\r
+ and assemble entries.\r
+\r
+ @param[in] Table The assemble table to clean up\r
+\r
+**/\r
VOID\r
Ip4CleanAssembleTable (\r
IN IP4_ASSEMBLE_TABLE *Table\r
);\r
\r
+/**\r
+ The IP4 input routine. It is called by the IP4_INTERFACE when a\r
+ IP4 fragment is received from MNP.\r
+\r
+ @param[in] Ip4Instance The IP4 child that request the receive, most like\r
+ it is NULL.\r
+ @param[in] Packet The IP4 packet received.\r
+ @param[in] IoStatus The return status of receive request.\r
+ @param[in] Flag The link layer flag for the packet received, such\r
+ as multicast.\r
+ @param[in] Context The IP4 service instance that own the MNP.\r
+\r
+**/\r
VOID\r
Ip4AccpetFrame (\r
IN IP4_PROTOCOL *Ip4Instance,\r
IN VOID *Context\r
);\r
\r
+/**\r
+ Demultiple the packet. the packet delivery is processed in two\r
+ passes. The first pass will enque a shared copy of the packet\r
+ to each IP4 child that accepts the packet. The second pass will\r
+ deliver a non-shared copy of the packet to each IP4 child that\r
+ has pending receive requests. Data is copied if more than one\r
+ child wants to consume the packet because each IP child needs\r
+ its own copy of the packet to make changes.\r
+\r
+ @param[in] IpSb The IP4 service instance that received the packet\r
+ @param[in] Head The header of the received packet\r
+ @param[in] Packet The data of the received packet\r
+\r
+ @retval EFI_NOT_FOUND No IP child accepts the packet\r
+ @retval EFI_SUCCESS The packet is enqueued or delivered to some IP\r
+ children.\r
+\r
+**/\r
EFI_STATUS\r
Ip4Demultiplex (\r
- IN IP4_SERVICE *SbInstance,\r
+ IN IP4_SERVICE *IpSb,\r
IN IP4_HEAD *Head,\r
IN NET_BUF *Packet\r
);\r
\r
+/**\r
+ Enqueue a received packet to all the IP children that share\r
+ the same interface.\r
+\r
+ @param[in] IpSb The IP4 service instance that receive the packet\r
+ @param[in] Head The header of the received packet\r
+ @param[in] Packet The data of the received packet\r
+ @param[in] IpIf The interface to enqueue the packet to\r
+\r
+ @return The number of the IP4 children that accepts the packet\r
+\r
+**/\r
INTN\r
Ip4InterfaceEnquePacket (\r
- IN IP4_SERVICE *SbInstance,\r
+ IN IP4_SERVICE *IpSb,\r
IN IP4_HEAD *Head,\r
IN NET_BUF *Packet,\r
- IN IP4_INTERFACE *Interface\r
+ IN IP4_INTERFACE *IpIf\r
);\r
\r
+/**\r
+ Deliver the received packets to upper layer if there are both received\r
+ requests and enqueued packets. If the enqueued packet is shared, it will\r
+ duplicate it to a non-shared packet, release the shared packet, then\r
+ deliver the non-shared packet up.\r
+\r
+ @param[in] IpInstance The IP child to deliver the packet up.\r
+\r
+ @retval EFI_OUT_OF_RESOURCES Failed to allocate resources to deliver the\r
+ packets.\r
+ @retval EFI_SUCCESS All the enqueued packets that can be delivered\r
+ are delivered up.\r
+\r
+**/\r
EFI_STATUS\r
Ip4InstanceDeliverPacket (\r
- IN IP4_PROTOCOL *Ip4Instance\r
+ IN IP4_PROTOCOL *IpInstance\r
);\r
\r
+/**\r
+ Timeout the fragment and enqueued packets.\r
+\r
+ @param[in] IpSb The IP4 service instance to timeout\r
+\r
+**/\r
VOID\r
Ip4PacketTimerTicking (\r
IN IP4_SERVICE *IpSb\r