2 IP6 internal functions and definitions to process the incoming packets.
4 Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #ifndef __EFI_IP6_INPUT_H__
11 #define __EFI_IP6_INPUT_H__
13 #define IP6_MIN_HEADLEN 40
14 #define IP6_MAX_HEADLEN 120
16 /// 8(ESP header) + 16(max IV) + 16(max padding) + 2(ESP tail) + 12(max ICV) = 54
18 #define IP6_MAX_IPSEC_HEADLEN 54
21 #define IP6_ASSEMLE_HASH_SIZE 127
23 /// Lift time in seconds.
25 #define IP6_FRAGMENT_LIFE 60
26 #define IP6_MAX_PACKET_SIZE 65535
29 #define IP6_GET_CLIP_INFO(Packet) ((IP6_CLIP_INFO *) ((Packet)->ProtoData))
31 #define IP6_ASSEMBLE_HASH(Dst, Src, Id) \
32 ((*((UINT32 *) (Dst)) + *((UINT32 *) (Src)) + (Id)) % IP6_ASSEMLE_HASH_SIZE)
34 #define IP6_RXDATA_WRAP_SIZE(NumFrag) \
35 (sizeof (IP6_RXDATA_WRAP) + sizeof (EFI_IP6_FRAGMENT_DATA) * ((NumFrag) - 1))
38 // Per packet information for input process. LinkFlag specifies whether
39 // the packet is received as Link layer unicast, multicast or broadcast.
40 // The CastType is the IP layer cast type, such as IP multicast or unicast.
41 // Start, End and Length are staffs used to assemble the packets. Start
42 // is the sequence number of the first byte of data in the packet. Length
43 // is the number of bytes of data. End = Start + Length, that is, the
44 // sequence number of last byte + 1. Each assembled packet has a count down
45 // life. If it isn't consumed before Life reaches zero, the packet is released.
59 UINT32 FormerNextHeader
;
63 // Structure used to assemble IP packets.
67 LIST_ENTRY Fragments
; // List of all the fragments of this packet
70 // Identity of one IP6 packet. Each fragment of a packet has
71 // the same (Dst, Src, Id).
79 UINT32 Life
; // Count down life for the packet.
81 EFI_IP6_HEADER
*Head
; // IP head of the first fragment
82 IP6_CLIP_INFO
*Info
; // Per packet information of the first fragment
83 NET_BUF
*Packet
; // The first fragment of the packet
87 // Each Ip service instance has an assemble table to reassemble
88 // the packets before delivery to its children. It is organized
92 LIST_ENTRY Bucket
[IP6_ASSEMLE_HASH_SIZE
];
96 The IP6 input routine. It is called by the IP6_INTERFACE when an
97 IP6 fragment is received from MNP.
99 @param[in] Packet The IP6 packet received.
100 @param[in] IoStatus The return status of receive request.
101 @param[in] Flag The link layer flag for the packet received, such
103 @param[in] Context The IP6 service instance that own the MNP.
109 IN EFI_STATUS IoStatus
,
115 Deliver the received packets to upper layer if there are both received
116 requests and enqueued packets. If the enqueued packet is shared, it will
117 duplicate it to a non-shared packet, release the shared packet, then
118 deliver the non-shared packet up.
120 @param[in] IpInstance The IP child to deliver the packet up.
122 @retval EFI_OUT_OF_RESOURCES Failed to allocate resources to deliver the
124 @retval EFI_SUCCESS All the enqueued packets that can be delivered
129 Ip6InstanceDeliverPacket (
130 IN IP6_PROTOCOL
*IpInstance
134 The work function to locate the IPsec protocol to process the inbound or
135 outbound IP packets. The process routine handles the packet with the following
136 actions: bypass the packet, discard the packet, or protect the packet.
138 @param[in] IpSb The IP6 service instance.
139 @param[in, out] Head The caller-supplied IP6 header.
140 @param[in, out] LastHead The next header field of last IP header.
141 @param[in, out] Netbuf The IP6 packet to be processed by IPsec.
142 @param[in, out] ExtHdrs The caller-supplied options.
143 @param[in, out] ExtHdrsLen The length of the option.
144 @param[in] Direction The directionality in an SPD entry,
145 EfiIPsecInBound, or EfiIPsecOutBound.
146 @param[in] Context The token's wrap.
148 @retval EFI_SUCCESS The IPsec protocol is not available or disabled.
149 @retval EFI_SUCCESS The packet was bypassed, and all buffers remain the same.
150 @retval EFI_SUCCESS The packet was protected.
151 @retval EFI_ACCESS_DENIED The packet was discarded.
152 @retval EFI_OUT_OF_RESOURCES There are not sufficient resources to complete the operation.
153 @retval EFI_BUFFER_TOO_SMALL The number of non-empty blocks is bigger than the
154 number of input data blocks when building a fragment table.
158 Ip6IpSecProcessPacket (
159 IN IP6_SERVICE
*IpSb
,
160 IN OUT EFI_IP6_HEADER
**Head
,
161 IN OUT UINT8
*LastHead
,
162 IN OUT NET_BUF
**Netbuf
,
163 IN OUT UINT8
**ExtHdrs
,
164 IN OUT UINT32
*ExtHdrsLen
,
165 IN EFI_IPSEC_TRAFFIC_DIR Direction
,
170 Initialize an already allocated assemble table. This is generally
171 the assemble table embedded in the IP6 service instance.
173 @param[in, out] Table The assemble table to initialize.
177 Ip6CreateAssembleTable (
178 IN OUT IP6_ASSEMBLE_TABLE
*Table
182 Clean up the assemble table: remove all the fragments
183 and assemble entries.
185 @param[in, out] Table The assemble table to clean up.
189 Ip6CleanAssembleTable (
190 IN OUT IP6_ASSEMBLE_TABLE
*Table
194 Demultiple the packet. the packet delivery is processed in two
195 passes. The first pass will enqueue a shared copy of the packet
196 to each IP6 child that accepts the packet. The second pass will
197 deliver a non-shared copy of the packet to each IP6 child that
198 has pending receive requests. Data is copied if more than one
199 child wants to consume the packet because each IP child need
200 its own copy of the packet to make changes.
202 @param[in] IpSb The IP6 service instance that received the packet.
203 @param[in] Head The header of the received packet.
204 @param[in] Packet The data of the received packet.
206 @retval EFI_NOT_FOUND No IP child accepts the packet.
207 @retval EFI_SUCCESS The packet is enqueued or delivered to some IP
213 IN IP6_SERVICE
*IpSb
,
214 IN EFI_IP6_HEADER
*Head
,
219 Timeout the fragmented, enqueued, and transmitted packets.
221 @param[in] IpSb The IP6 service instance to timeout.
225 Ip6PacketTimerTicking (