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
20 #define IP6_ASSEMLE_HASH_SIZE 127
22 /// Lift time in seconds.
24 #define IP6_FRAGMENT_LIFE 60
25 #define IP6_MAX_PACKET_SIZE 65535
27 #define IP6_GET_CLIP_INFO(Packet) ((IP6_CLIP_INFO *) ((Packet)->ProtoData))
29 #define IP6_ASSEMBLE_HASH(Dst, Src, Id) \
30 ((*((UINT32 *) (Dst)) + *((UINT32 *) (Src)) + (Id)) % IP6_ASSEMLE_HASH_SIZE)
32 #define IP6_RXDATA_WRAP_SIZE(NumFrag) \
33 (sizeof (IP6_RXDATA_WRAP) + sizeof (EFI_IP6_FRAGMENT_DATA) * ((NumFrag) - 1))
36 // Per packet information for input process. LinkFlag specifies whether
37 // the packet is received as Link layer unicast, multicast or broadcast.
38 // The CastType is the IP layer cast type, such as IP multicast or unicast.
39 // Start, End and Length are staffs used to assemble the packets. Start
40 // is the sequence number of the first byte of data in the packet. Length
41 // is the number of bytes of data. End = Start + Length, that is, the
42 // sequence number of last byte + 1. Each assembled packet has a count down
43 // life. If it isn't consumed before Life reaches zero, the packet is released.
57 UINT32 FormerNextHeader
;
61 // Structure used to assemble IP packets.
65 LIST_ENTRY Fragments
; // List of all the fragments of this packet
68 // Identity of one IP6 packet. Each fragment of a packet has
69 // the same (Dst, Src, Id).
77 UINT32 Life
; // Count down life for the packet.
79 EFI_IP6_HEADER
*Head
; // IP head of the first fragment
80 IP6_CLIP_INFO
*Info
; // Per packet information of the first fragment
81 NET_BUF
*Packet
; // The first fragment of the packet
85 // Each Ip service instance has an assemble table to reassemble
86 // the packets before delivery to its children. It is organized
90 LIST_ENTRY Bucket
[IP6_ASSEMLE_HASH_SIZE
];
94 The IP6 input routine. It is called by the IP6_INTERFACE when an
95 IP6 fragment is received from MNP.
97 @param[in] Packet The IP6 packet received.
98 @param[in] IoStatus The return status of receive request.
99 @param[in] Flag The link layer flag for the packet received, such
101 @param[in] Context The IP6 service instance that own the MNP.
107 IN EFI_STATUS IoStatus
,
113 Deliver the received packets to upper layer if there are both received
114 requests and enqueued packets. If the enqueued packet is shared, it will
115 duplicate it to a non-shared packet, release the shared packet, then
116 deliver the non-shared packet up.
118 @param[in] IpInstance The IP child to deliver the packet up.
120 @retval EFI_OUT_OF_RESOURCES Failed to allocate resources to deliver the
122 @retval EFI_SUCCESS All the enqueued packets that can be delivered
127 Ip6InstanceDeliverPacket (
128 IN IP6_PROTOCOL
*IpInstance
132 The work function to locate the IPsec protocol to process the inbound or
133 outbound IP packets. The process routine handles the packet with the following
134 actions: bypass the packet, discard the packet, or protect the packet.
136 @param[in] IpSb The IP6 service instance.
137 @param[in, out] Head The caller-supplied IP6 header.
138 @param[in, out] LastHead The next header field of last IP header.
139 @param[in, out] Netbuf The IP6 packet to be processed by IPsec.
140 @param[in, out] ExtHdrs The caller-supplied options.
141 @param[in, out] ExtHdrsLen The length of the option.
142 @param[in] Direction The directionality in an SPD entry,
143 EfiIPsecInBound, or EfiIPsecOutBound.
144 @param[in] Context The token's wrap.
146 @retval EFI_SUCCESS The IPsec protocol is not available or disabled.
147 @retval EFI_SUCCESS The packet was bypassed, and all buffers remain the same.
148 @retval EFI_SUCCESS The packet was protected.
149 @retval EFI_ACCESS_DENIED The packet was discarded.
150 @retval EFI_OUT_OF_RESOURCES There are not sufficient resources to complete the operation.
151 @retval EFI_BUFFER_TOO_SMALL The number of non-empty blocks is bigger than the
152 number of input data blocks when building a fragment table.
156 Ip6IpSecProcessPacket (
157 IN IP6_SERVICE
*IpSb
,
158 IN OUT EFI_IP6_HEADER
**Head
,
159 IN OUT UINT8
*LastHead
,
160 IN OUT NET_BUF
**Netbuf
,
161 IN OUT UINT8
**ExtHdrs
,
162 IN OUT UINT32
*ExtHdrsLen
,
163 IN EFI_IPSEC_TRAFFIC_DIR Direction
,
168 Initialize an already allocated assemble table. This is generally
169 the assemble table embedded in the IP6 service instance.
171 @param[in, out] Table The assemble table to initialize.
175 Ip6CreateAssembleTable (
176 IN OUT IP6_ASSEMBLE_TABLE
*Table
180 Clean up the assemble table: remove all the fragments
181 and assemble entries.
183 @param[in, out] Table The assemble table to clean up.
187 Ip6CleanAssembleTable (
188 IN OUT IP6_ASSEMBLE_TABLE
*Table
192 Demultiple the packet. the packet delivery is processed in two
193 passes. The first pass will enqueue a shared copy of the packet
194 to each IP6 child that accepts the packet. The second pass will
195 deliver a non-shared copy of the packet to each IP6 child that
196 has pending receive requests. Data is copied if more than one
197 child wants to consume the packet because each IP child need
198 its own copy of the packet to make changes.
200 @param[in] IpSb The IP6 service instance that received the packet.
201 @param[in] Head The header of the received packet.
202 @param[in] Packet The data of the received packet.
204 @retval EFI_NOT_FOUND No IP child accepts the packet.
205 @retval EFI_SUCCESS The packet is enqueued or delivered to some IP
211 IN IP6_SERVICE
*IpSb
,
212 IN EFI_IP6_HEADER
*Head
,
217 Timeout the fragmented, enqueued, and transmitted packets.
219 @param[in] IpSb The IP6 service instance to timeout.
223 Ip6PacketTimerTicking (