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