3 Copyright (c) 2005 - 2006, Intel Corporation.<BR>
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 #ifndef __EFI_IP4_INPUT_H__
15 #define __EFI_IP4_INPUT_H__
21 IP4_ASSEMLE_HASH_SIZE
= 31,
22 IP4_FRAGMENT_LIFE
= 120,
23 IP4_MAX_PACKET_SIZE
= 65535
24 } IP4_INPUT_ENUM_TYPES
;
27 /// Per packet information for input process. LinkFlag specifies whether
28 /// the packet is received as Link layer unicast, multicast or broadcast.
29 /// The CastType is the IP layer cast type, such as IP multicast or unicast.
30 /// Start, End and Length are staffs used to assemble the packets. Start
31 /// is the sequence number of the first byte of data in the packet. Length
32 /// is the number of bytes of data. End = Start + Length, that is, the
33 /// sequence number of last byte + 1. Each assembled packet has a count down
34 /// life. If it isn't consumed before Life reaches zero, the packet is released.
47 /// Structure used to assemble IP packets.
53 // Identity of one IP4 packet. Each fragment of a packet has
54 // the same (Dst, Src, Id, Protocol).
63 LIST_ENTRY Fragments
; // List of all the fragments of this packet
65 IP4_HEAD
*Head
; // IP head of the first fragment
66 IP4_CLIP_INFO
*Info
; // Per packet info of the first fragment
67 INTN Life
; // Count down life for the packet.
71 /// Each Ip service instance has an assemble table to reassemble
72 /// the packets before delivery to its children. It is organized
76 LIST_ENTRY Bucket
[IP4_ASSEMLE_HASH_SIZE
];
79 #define IP4_GET_CLIP_INFO(Packet) ((IP4_CLIP_INFO *) ((Packet)->ProtoData))
81 #define IP4_ASSEMBLE_HASH(Dst, Src, Id, Proto) \
82 (((Dst) + (Src) + ((Id) << 16) + (Proto)) % IP4_ASSEMLE_HASH_SIZE)
84 #define IP4_RXDATA_WRAP_SIZE(NumFrag) \
85 (sizeof (IP4_RXDATA_WRAP) + sizeof (EFI_IP4_FRAGMENT_DATA) * ((NumFrag) - 1))
88 Initialize an already allocated assemble table. This is generally
89 the assemble table embedded in the IP4 service instance.
91 @param[in, out] Table The assemble table to initialize.
95 Ip4InitAssembleTable (
96 IN OUT IP4_ASSEMBLE_TABLE
*Table
100 Clean up the assemble table: remove all the fragments
101 and assemble entries.
103 @param[in] Table The assemble table to clean up
107 Ip4CleanAssembleTable (
108 IN IP4_ASSEMBLE_TABLE
*Table
112 The IP4 input routine. It is called by the IP4_INTERFACE when a
113 IP4 fragment is received from MNP.
115 @param[in] Ip4Instance The IP4 child that request the receive, most like
117 @param[in] Packet The IP4 packet received.
118 @param[in] IoStatus The return status of receive request.
119 @param[in] Flag The link layer flag for the packet received, such
121 @param[in] Context The IP4 service instance that own the MNP.
126 IN IP4_PROTOCOL
*Ip4Instance
,
128 IN EFI_STATUS IoStatus
,
134 Demultiple the packet. the packet delivery is processed in two
135 passes. The first pass will enque a shared copy of the packet
136 to each IP4 child that accepts the packet. The second pass will
137 deliver a non-shared copy of the packet to each IP4 child that
138 has pending receive requests. Data is copied if more than one
139 child wants to consume the packet because each IP child needs
140 its own copy of the packet to make changes.
142 @param[in] IpSb The IP4 service instance that received the packet
143 @param[in] Head The header of the received packet
144 @param[in] Packet The data of the received packet
146 @retval EFI_NOT_FOUND No IP child accepts the packet
147 @retval EFI_SUCCESS The packet is enqueued or delivered to some IP
153 IN IP4_SERVICE
*IpSb
,
159 Enqueue a received packet to all the IP children that share
162 @param[in] IpSb The IP4 service instance that receive the packet
163 @param[in] Head The header of the received packet
164 @param[in] Packet The data of the received packet
165 @param[in] IpIf The interface to enqueue the packet to
167 @return The number of the IP4 children that accepts the packet
171 Ip4InterfaceEnquePacket (
172 IN IP4_SERVICE
*IpSb
,
175 IN IP4_INTERFACE
*IpIf
179 Deliver the received packets to upper layer if there are both received
180 requests and enqueued packets. If the enqueued packet is shared, it will
181 duplicate it to a non-shared packet, release the shared packet, then
182 deliver the non-shared packet up.
184 @param[in] IpInstance The IP child to deliver the packet up.
186 @retval EFI_OUT_OF_RESOURCES Failed to allocate resources to deliver the
188 @retval EFI_SUCCESS All the enqueued packets that can be delivered
193 Ip4InstanceDeliverPacket (
194 IN IP4_PROTOCOL
*IpInstance
198 Timeout the fragment and enqueued packets.
200 @param[in] IpSb The IP4 service instance to timeout
204 Ip4PacketTimerTicking (