]> git.proxmox.com Git - mirror_edk2.git/blame - NetworkPkg/Ip6Dxe/Ip6Input.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / NetworkPkg / Ip6Dxe / Ip6Input.h
CommitLineData
a3bcde70
HT
1/** @file\r
2 IP6 internal functions and definitions to process the incoming packets.\r
3\r
4 Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
5\r
ecf98fbc 6 SPDX-License-Identifier: BSD-2-Clause-Patent\r
a3bcde70
HT
7\r
8**/\r
9\r
10#ifndef __EFI_IP6_INPUT_H__\r
11#define __EFI_IP6_INPUT_H__\r
12\r
d1050b9d
MK
13#define IP6_MIN_HEADLEN 40\r
14#define IP6_MAX_HEADLEN 120\r
a3bcde70
HT
15///\r
16/// 8(ESP header) + 16(max IV) + 16(max padding) + 2(ESP tail) + 12(max ICV) = 54\r
17///\r
d1050b9d 18#define IP6_MAX_IPSEC_HEADLEN 54\r
a3bcde70 19\r
d1050b9d 20#define IP6_ASSEMLE_HASH_SIZE 127\r
a3bcde70
HT
21///\r
22/// Lift time in seconds.\r
23///\r
d1050b9d
MK
24#define IP6_FRAGMENT_LIFE 60\r
25#define IP6_MAX_PACKET_SIZE 65535\r
a3bcde70 26\r
d1050b9d 27#define IP6_GET_CLIP_INFO(Packet) ((IP6_CLIP_INFO *) ((Packet)->ProtoData))\r
a3bcde70
HT
28\r
29#define IP6_ASSEMBLE_HASH(Dst, Src, Id) \\r
30 ((*((UINT32 *) (Dst)) + *((UINT32 *) (Src)) + (Id)) % IP6_ASSEMLE_HASH_SIZE)\r
31\r
32#define IP6_RXDATA_WRAP_SIZE(NumFrag) \\r
33 (sizeof (IP6_RXDATA_WRAP) + sizeof (EFI_IP6_FRAGMENT_DATA) * ((NumFrag) - 1))\r
34\r
35//\r
36// Per packet information for input process. LinkFlag specifies whether\r
37// the packet is received as Link layer unicast, multicast or broadcast.\r
38// The CastType is the IP layer cast type, such as IP multicast or unicast.\r
39// Start, End and Length are staffs used to assemble the packets. Start\r
40// is the sequence number of the first byte of data in the packet. Length\r
41// is the number of bytes of data. End = Start + Length, that is, the\r
42// sequence number of last byte + 1. Each assembled packet has a count down\r
43// life. If it isn't consumed before Life reaches zero, the packet is released.\r
44//\r
45typedef struct {\r
d1050b9d
MK
46 UINT32 LinkFlag;\r
47 INT32 CastType;\r
48 INT32 Start;\r
49 INT32 End;\r
50 INT32 Length;\r
51 UINT32 Life;\r
52 EFI_STATUS Status;\r
53 UINT32 Id;\r
54 UINT16 HeadLen;\r
55 UINT8 NextHeader;\r
56 UINT8 LastFrag;\r
57 UINT32 FormerNextHeader;\r
a3bcde70
HT
58} IP6_CLIP_INFO;\r
59\r
60//\r
61// Structure used to assemble IP packets.\r
62//\r
63typedef struct {\r
d1050b9d
MK
64 LIST_ENTRY Link;\r
65 LIST_ENTRY Fragments; // List of all the fragments of this packet\r
a3bcde70
HT
66\r
67 //\r
68 // Identity of one IP6 packet. Each fragment of a packet has\r
69 // the same (Dst, Src, Id).\r
70 //\r
d1050b9d
MK
71 EFI_IPv6_ADDRESS Dst;\r
72 EFI_IPv6_ADDRESS Src;\r
73 UINT32 Id;\r
a3bcde70 74\r
d1050b9d
MK
75 UINT32 TotalLen;\r
76 UINT32 CurLen;\r
77 UINT32 Life; // Count down life for the packet.\r
a3bcde70 78\r
d1050b9d
MK
79 EFI_IP6_HEADER *Head; // IP head of the first fragment\r
80 IP6_CLIP_INFO *Info; // Per packet information of the first fragment\r
81 NET_BUF *Packet; // The first fragment of the packet\r
a3bcde70
HT
82} IP6_ASSEMBLE_ENTRY;\r
83\r
84//\r
85// Each Ip service instance has an assemble table to reassemble\r
86// the packets before delivery to its children. It is organized\r
87// as hash table.\r
88//\r
89typedef struct {\r
d1050b9d 90 LIST_ENTRY Bucket[IP6_ASSEMLE_HASH_SIZE];\r
a3bcde70
HT
91} IP6_ASSEMBLE_TABLE;\r
92\r
93/**\r
94 The IP6 input routine. It is called by the IP6_INTERFACE when an\r
95 IP6 fragment is received from MNP.\r
96\r
97 @param[in] Packet The IP6 packet received.\r
98 @param[in] IoStatus The return status of receive request.\r
99 @param[in] Flag The link layer flag for the packet received, such\r
100 as multicast.\r
101 @param[in] Context The IP6 service instance that own the MNP.\r
102\r
103**/\r
104VOID\r
105Ip6AcceptFrame (\r
d1050b9d
MK
106 IN NET_BUF *Packet,\r
107 IN EFI_STATUS IoStatus,\r
108 IN UINT32 Flag,\r
109 IN VOID *Context\r
a3bcde70
HT
110 );\r
111\r
112/**\r
113 Deliver the received packets to upper layer if there are both received\r
114 requests and enqueued packets. If the enqueued packet is shared, it will\r
115 duplicate it to a non-shared packet, release the shared packet, then\r
116 deliver the non-shared packet up.\r
117\r
118 @param[in] IpInstance The IP child to deliver the packet up.\r
119\r
120 @retval EFI_OUT_OF_RESOURCES Failed to allocate resources to deliver the\r
121 packets.\r
122 @retval EFI_SUCCESS All the enqueued packets that can be delivered\r
123 are delivered up.\r
124\r
125**/\r
126EFI_STATUS\r
127Ip6InstanceDeliverPacket (\r
d1050b9d 128 IN IP6_PROTOCOL *IpInstance\r
a3bcde70
HT
129 );\r
130\r
131/**\r
68d3f2fb 132 The work function to locate the IPsec protocol to process the inbound or\r
133 outbound IP packets. The process routine handles the packet with the following\r
a3bcde70
HT
134 actions: bypass the packet, discard the packet, or protect the packet.\r
135\r
136 @param[in] IpSb The IP6 service instance.\r
68d3f2fb 137 @param[in, out] Head The caller-supplied IP6 header.\r
a3bcde70
HT
138 @param[in, out] LastHead The next header field of last IP header.\r
139 @param[in, out] Netbuf The IP6 packet to be processed by IPsec.\r
68d3f2fb 140 @param[in, out] ExtHdrs The caller-supplied options.\r
141 @param[in, out] ExtHdrsLen The length of the option.\r
a3bcde70 142 @param[in] Direction The directionality in an SPD entry,\r
68d3f2fb 143 EfiIPsecInBound, or EfiIPsecOutBound.\r
a3bcde70
HT
144 @param[in] Context The token's wrap.\r
145\r
146 @retval EFI_SUCCESS The IPsec protocol is not available or disabled.\r
68d3f2fb 147 @retval EFI_SUCCESS The packet was bypassed, and all buffers remain the same.\r
a3bcde70
HT
148 @retval EFI_SUCCESS The packet was protected.\r
149 @retval EFI_ACCESS_DENIED The packet was discarded.\r
7de8045a 150 @retval EFI_OUT_OF_RESOURCES There are not sufficient resources to complete the operation.\r
68d3f2fb 151 @retval EFI_BUFFER_TOO_SMALL The number of non-empty blocks is bigger than the\r
a3bcde70
HT
152 number of input data blocks when building a fragment table.\r
153\r
154**/\r
155EFI_STATUS\r
156Ip6IpSecProcessPacket (\r
68d3f2fb 157 IN IP6_SERVICE *IpSb,\r
158 IN OUT EFI_IP6_HEADER **Head,\r
159 IN OUT UINT8 *LastHead,\r
160 IN OUT NET_BUF **Netbuf,\r
161 IN OUT UINT8 **ExtHdrs,\r
162 IN OUT UINT32 *ExtHdrsLen,\r
163 IN EFI_IPSEC_TRAFFIC_DIR Direction,\r
164 IN VOID *Context\r
a3bcde70
HT
165 );\r
166\r
167/**\r
168 Initialize an already allocated assemble table. This is generally\r
169 the assemble table embedded in the IP6 service instance.\r
170\r
171 @param[in, out] Table The assemble table to initialize.\r
172\r
173**/\r
174VOID\r
175Ip6CreateAssembleTable (\r
d1050b9d 176 IN OUT IP6_ASSEMBLE_TABLE *Table\r
a3bcde70
HT
177 );\r
178\r
179/**\r
180 Clean up the assemble table: remove all the fragments\r
181 and assemble entries.\r
182\r
183 @param[in, out] Table The assemble table to clean up.\r
184\r
185**/\r
186VOID\r
187Ip6CleanAssembleTable (\r
d1050b9d 188 IN OUT IP6_ASSEMBLE_TABLE *Table\r
a3bcde70
HT
189 );\r
190\r
191/**\r
192 Demultiple the packet. the packet delivery is processed in two\r
7de8045a 193 passes. The first pass will enqueue a shared copy of the packet\r
a3bcde70
HT
194 to each IP6 child that accepts the packet. The second pass will\r
195 deliver a non-shared copy of the packet to each IP6 child that\r
196 has pending receive requests. Data is copied if more than one\r
7de8045a 197 child wants to consume the packet because each IP child need\r
a3bcde70
HT
198 its own copy of the packet to make changes.\r
199\r
200 @param[in] IpSb The IP6 service instance that received the packet.\r
201 @param[in] Head The header of the received packet.\r
202 @param[in] Packet The data of the received packet.\r
203\r
204 @retval EFI_NOT_FOUND No IP child accepts the packet.\r
205 @retval EFI_SUCCESS The packet is enqueued or delivered to some IP\r
206 children.\r
207\r
208**/\r
209EFI_STATUS\r
210Ip6Demultiplex (\r
d1050b9d
MK
211 IN IP6_SERVICE *IpSb,\r
212 IN EFI_IP6_HEADER *Head,\r
213 IN NET_BUF *Packet\r
a3bcde70
HT
214 );\r
215\r
216/**\r
217 Timeout the fragmented, enqueued, and transmitted packets.\r
218\r
219 @param[in] IpSb The IP6 service instance to timeout.\r
220\r
221**/\r
222VOID\r
223Ip6PacketTimerTicking (\r
d1050b9d 224 IN IP6_SERVICE *IpSb\r
a3bcde70
HT
225 );\r
226\r
227#endif\r