2 IP6 internal functions and definitions to process the incoming packets.
4 Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #ifndef __EFI_IP6_INPUT_H__
17 #define __EFI_IP6_INPUT_H__
19 #define IP6_MIN_HEADLEN 40
20 #define IP6_MAX_HEADLEN 120
22 /// 8(ESP header) + 16(max IV) + 16(max padding) + 2(ESP tail) + 12(max ICV) = 54
24 #define IP6_MAX_IPSEC_HEADLEN 54
27 #define IP6_ASSEMLE_HASH_SIZE 127
29 /// Lift time in seconds.
31 #define IP6_FRAGMENT_LIFE 60
32 #define IP6_MAX_PACKET_SIZE 65535
35 #define IP6_GET_CLIP_INFO(Packet) ((IP6_CLIP_INFO *) ((Packet)->ProtoData))
37 #define IP6_ASSEMBLE_HASH(Dst, Src, Id) \
38 ((*((UINT32 *) (Dst)) + *((UINT32 *) (Src)) + (Id)) % IP6_ASSEMLE_HASH_SIZE)
40 #define IP6_RXDATA_WRAP_SIZE(NumFrag) \
41 (sizeof (IP6_RXDATA_WRAP) + sizeof (EFI_IP6_FRAGMENT_DATA) * ((NumFrag) - 1))
44 // Per packet information for input process. LinkFlag specifies whether
45 // the packet is received as Link layer unicast, multicast or broadcast.
46 // The CastType is the IP layer cast type, such as IP multicast or unicast.
47 // Start, End and Length are staffs used to assemble the packets. Start
48 // is the sequence number of the first byte of data in the packet. Length
49 // is the number of bytes of data. End = Start + Length, that is, the
50 // sequence number of last byte + 1. Each assembled packet has a count down
51 // life. If it isn't consumed before Life reaches zero, the packet is released.
65 UINT32 FormerNextHeader
;
69 // Structure used to assemble IP packets.
73 LIST_ENTRY Fragments
; // List of all the fragments of this packet
76 // Identity of one IP6 packet. Each fragment of a packet has
77 // the same (Dst, Src, Id).
85 UINT32 Life
; // Count down life for the packet.
87 EFI_IP6_HEADER
*Head
; // IP head of the first fragment
88 IP6_CLIP_INFO
*Info
; // Per packet information of the first fragment
89 NET_BUF
*Packet
; // The first fragment of the packet
93 // Each Ip service instance has an assemble table to reassemble
94 // the packets before delivery to its children. It is organized
98 LIST_ENTRY Bucket
[IP6_ASSEMLE_HASH_SIZE
];
102 The IP6 input routine. It is called by the IP6_INTERFACE when an
103 IP6 fragment is received from MNP.
105 @param[in] Packet The IP6 packet received.
106 @param[in] IoStatus The return status of receive request.
107 @param[in] Flag The link layer flag for the packet received, such
109 @param[in] Context The IP6 service instance that own the MNP.
115 IN EFI_STATUS IoStatus
,
121 Deliver the received packets to upper layer if there are both received
122 requests and enqueued packets. If the enqueued packet is shared, it will
123 duplicate it to a non-shared packet, release the shared packet, then
124 deliver the non-shared packet up.
126 @param[in] IpInstance The IP child to deliver the packet up.
128 @retval EFI_OUT_OF_RESOURCES Failed to allocate resources to deliver the
130 @retval EFI_SUCCESS All the enqueued packets that can be delivered
135 Ip6InstanceDeliverPacket (
136 IN IP6_PROTOCOL
*IpInstance
140 The work function to locate the IPsec protocol to process the inbound or
141 outbound IP packets. The process routine handles the packet with the following
142 actions: bypass the packet, discard the packet, or protect the packet.
144 @param[in] IpSb The IP6 service instance.
145 @param[in, out] Head The caller-supplied IP6 header.
146 @param[in, out] LastHead The next header field of last IP header.
147 @param[in, out] Netbuf The IP6 packet to be processed by IPsec.
148 @param[in, out] ExtHdrs The caller-supplied options.
149 @param[in, out] ExtHdrsLen The length of the option.
150 @param[in] Direction The directionality in an SPD entry,
151 EfiIPsecInBound, or EfiIPsecOutBound.
152 @param[in] Context The token's wrap.
154 @retval EFI_SUCCESS The IPsec protocol is not available or disabled.
155 @retval EFI_SUCCESS The packet was bypassed, and all buffers remain the same.
156 @retval EFI_SUCCESS The packet was protected.
157 @retval EFI_ACCESS_DENIED The packet was discarded.
158 @retval EFI_OUT_OF_RESOURCES There are not suffcient resources to complete the operation.
159 @retval EFI_BUFFER_TOO_SMALL The number of non-empty blocks is bigger than the
160 number of input data blocks when building a fragment table.
164 Ip6IpSecProcessPacket (
165 IN IP6_SERVICE
*IpSb
,
166 IN OUT EFI_IP6_HEADER
**Head
,
167 IN OUT UINT8
*LastHead
,
168 IN OUT NET_BUF
**Netbuf
,
169 IN OUT UINT8
**ExtHdrs
,
170 IN OUT UINT32
*ExtHdrsLen
,
171 IN EFI_IPSEC_TRAFFIC_DIR Direction
,
176 Initialize an already allocated assemble table. This is generally
177 the assemble table embedded in the IP6 service instance.
179 @param[in, out] Table The assemble table to initialize.
183 Ip6CreateAssembleTable (
184 IN OUT IP6_ASSEMBLE_TABLE
*Table
188 Clean up the assemble table: remove all the fragments
189 and assemble entries.
191 @param[in, out] Table The assemble table to clean up.
195 Ip6CleanAssembleTable (
196 IN OUT IP6_ASSEMBLE_TABLE
*Table
200 Demultiple the packet. the packet delivery is processed in two
201 passes. The first pass will enque a shared copy of the packet
202 to each IP6 child that accepts the packet. The second pass will
203 deliver a non-shared copy of the packet to each IP6 child that
204 has pending receive requests. Data is copied if more than one
205 child wants to consume the packet bacause each IP child need
206 its own copy of the packet to make changes.
208 @param[in] IpSb The IP6 service instance that received the packet.
209 @param[in] Head The header of the received packet.
210 @param[in] Packet The data of the received packet.
212 @retval EFI_NOT_FOUND No IP child accepts the packet.
213 @retval EFI_SUCCESS The packet is enqueued or delivered to some IP
219 IN IP6_SERVICE
*IpSb
,
220 IN EFI_IP6_HEADER
*Head
,
225 Timeout the fragmented, enqueued, and transmitted packets.
227 @param[in] IpSb The IP6 service instance to timeout.
231 Ip6PacketTimerTicking (