]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Impl.h
added comments for CAPSULE_HOB_INFO in CapsuleVendor.h (MdeModuleModulePkg).
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4Dxe / Ip4Impl.h
... / ...
CommitLineData
1/** @file\r
2 Ip4 internal functions and type defintions.\r
3 \r
4Copyright (c) 2005 - 2007, Intel Corporation.<BR> \r
5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#ifndef __EFI_IP4_IMPL_H__\r
16#define __EFI_IP4_IMPL_H__\r
17\r
18#include <Uefi.h>\r
19\r
20#include <Protocol/Ip4.h>\r
21#include <Protocol/Ip4Config.h>\r
22#include <Protocol/Arp.h>\r
23#include <Protocol/ManagedNetwork.h>\r
24\r
25#include <Library/DebugLib.h>\r
26#include <Library/UefiRuntimeServicesTableLib.h>\r
27#include <Library/UefiDriverEntryPoint.h>\r
28#include <Library/UefiBootServicesTableLib.h>\r
29#include <Library/BaseLib.h>\r
30#include <Library/UefiLib.h>\r
31#include <Library/NetLib.h>\r
32#include <Library/BaseMemoryLib.h>\r
33#include <Library/MemoryAllocationLib.h>\r
34#include <Library/DpcLib.h>\r
35\r
36#include "Ip4Common.h"\r
37#include "Ip4Driver.h"\r
38#include "Ip4If.h"\r
39#include "Ip4Icmp.h"\r
40#include "Ip4Option.h"\r
41#include "Ip4Igmp.h"\r
42#include "Ip4Route.h"\r
43#include "Ip4Input.h"\r
44#include "Ip4Output.h"\r
45\r
46\r
47\r
48typedef enum {\r
49 IP4_PROTOCOL_SIGNATURE = SIGNATURE_32 ('I', 'P', '4', 'P'),\r
50 IP4_SERVICE_SIGNATURE = SIGNATURE_32 ('I', 'P', '4', 'S'),\r
51\r
52 //\r
53 // The state of IP4 protocol. It starts from UNCONFIGED. if it is\r
54 // successfully configured, it goes to CONFIGED. if configure NULL\r
55 // is called, it becomes UNCONFIGED again. If (partly) destoried, it\r
56 // becomes DESTORY.\r
57 //\r
58 IP4_STATE_UNCONFIGED = 0,\r
59 IP4_STATE_CONFIGED,\r
60 IP4_STATE_DESTORY,\r
61\r
62 //\r
63 // The state of IP4 service. It starts from UNSTARTED. It transits\r
64 // to STARTED if autoconfigure is started. If default address is\r
65 // configured, it becomes CONFIGED. and if partly destoried, it goes\r
66 // to DESTORY.\r
67 //\r
68 IP4_SERVICE_UNSTARTED = 0,\r
69 IP4_SERVICE_STARTED,\r
70 IP4_SERVICE_CONFIGED,\r
71 IP4_SERVICE_DESTORY\r
72} IP4_IMPL_ENUM_TYPES;\r
73\r
74///\r
75/// IP4_TXTOKEN_WRAP wraps the upper layer's transmit token.\r
76/// The user's data is kept in the Packet. When fragment is\r
77/// needed, each fragment of the Packet has a reference to the\r
78/// Packet, no data is actually copied. The Packet will be\r
79/// released when all the fragments of it have been recycled by\r
80/// MNP. Upon then, the IP4_TXTOKEN_WRAP will be released, and\r
81/// user's event signalled.\r
82///\r
83typedef struct {\r
84 IP4_PROTOCOL *IpInstance;\r
85 EFI_IP4_COMPLETION_TOKEN *Token;\r
86 NET_BUF *Packet;\r
87 BOOLEAN Sent;\r
88 INTN Life;\r
89} IP4_TXTOKEN_WRAP;\r
90\r
91///\r
92/// IP4_RXDATA_WRAP wraps the data IP4 child delivers to the\r
93/// upper layers. The received packet is kept in the Packet.\r
94/// The Packet itself may be constructured from some fragments.\r
95/// All the fragments of the Packet is organized by a\r
96/// IP4_ASSEMBLE_ENTRY structure. If the Packet is recycled by\r
97/// the upper layer, the assemble entry and its associated\r
98/// fragments will be freed at last.\r
99///\r
100typedef struct {\r
101 LIST_ENTRY Link;\r
102 IP4_PROTOCOL *IpInstance;\r
103 NET_BUF *Packet;\r
104 EFI_IP4_RECEIVE_DATA RxData;\r
105} IP4_RXDATA_WRAP;\r
106\r
107\r
108struct _IP4_PROTOCOL {\r
109 UINT32 Signature;\r
110\r
111 EFI_IP4_PROTOCOL Ip4Proto;\r
112 EFI_HANDLE Handle;\r
113 INTN State;\r
114\r
115 IP4_SERVICE *Service;\r
116 LIST_ENTRY Link; // Link to all the IP protocol from the service\r
117\r
118 //\r
119 // User's transmit/receive tokens, and received/deliverd packets\r
120 //\r
121 NET_MAP RxTokens;\r
122 NET_MAP TxTokens; // map between (User's Token, IP4_TXTOKE_WRAP)\r
123 LIST_ENTRY Received; // Received but not delivered packet\r
124 LIST_ENTRY Delivered; // Delivered and to be recycled packets\r
125 EFI_LOCK RecycleLock;\r
126\r
127 //\r
128 // Instance's address and route tables. There are two route tables.\r
129 // RouteTable is used by the IP4 driver to route packet. EfiRouteTable\r
130 // is used to communicate the current route info to the upper layer.\r
131 //\r
132 IP4_INTERFACE *Interface;\r
133 LIST_ENTRY AddrLink; // Ip instances with the same IP address.\r
134 IP4_ROUTE_TABLE *RouteTable;\r
135\r
136 EFI_IP4_ROUTE_TABLE *EfiRouteTable;\r
137 UINT32 EfiRouteCount;\r
138\r
139 //\r
140 // IGMP data for this instance\r
141 //\r
142 IP4_ADDR *Groups; // stored in network byte order\r
143 UINT32 GroupCount;\r
144\r
145 EFI_IP4_CONFIG_DATA ConfigData;\r
146\r
147};\r
148\r
149struct _IP4_SERVICE {\r
150 UINT32 Signature;\r
151 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;\r
152 INTN State;\r
153 BOOLEAN InDestory;\r
154\r
155 //\r
156 // List of all the IP instances and interfaces, and default\r
157 // interface and route table and caches.\r
158 //\r
159 UINTN NumChildren;\r
160 LIST_ENTRY Children;\r
161\r
162 LIST_ENTRY Interfaces;\r
163\r
164 IP4_INTERFACE *DefaultInterface;\r
165 IP4_ROUTE_TABLE *DefaultRouteTable;\r
166\r
167 //\r
168 // Ip reassemble utilities, and IGMP data\r
169 //\r
170 IP4_ASSEMBLE_TABLE Assemble;\r
171 IGMP_SERVICE_DATA IgmpCtrl;\r
172\r
173 //\r
174 // Low level protocol used by this service instance\r
175 //\r
176 EFI_HANDLE Image;\r
177 EFI_HANDLE Controller;\r
178\r
179 EFI_HANDLE MnpChildHandle;\r
180 EFI_MANAGED_NETWORK_PROTOCOL *Mnp;\r
181\r
182 EFI_MANAGED_NETWORK_CONFIG_DATA MnpConfigData;\r
183 EFI_SIMPLE_NETWORK_MODE SnpMode;\r
184\r
185 EFI_EVENT Timer;\r
186\r
187 //\r
188 // Auto configure staff\r
189 //\r
190 EFI_IP4_CONFIG_PROTOCOL *Ip4Config;\r
191 EFI_EVENT DoneEvent;\r
192 EFI_EVENT ReconfigEvent;\r
193 EFI_EVENT ActiveEvent;\r
194\r
195 //\r
196 // The string representation of the current mac address of the\r
197 // NIC this IP4_SERVICE works on.\r
198 //\r
199 CHAR16 *MacString;\r
200};\r
201\r
202#define IP4_INSTANCE_FROM_PROTOCOL(Ip4) \\r
203 CR ((Ip4), IP4_PROTOCOL, Ip4Proto, IP4_PROTOCOL_SIGNATURE)\r
204\r
205#define IP4_SERVICE_FROM_PROTOCOL(Sb) \\r
206 CR ((Sb), IP4_SERVICE, ServiceBinding, IP4_SERVICE_SIGNATURE)\r
207\r
208#define IP4_NO_MAPPING(IpInstance) (!(IpInstance)->Interface->Configured)\r
209\r
210extern EFI_IP4_PROTOCOL mEfiIp4ProtocolTemplete;\r
211\r
212/**\r
213 Config the MNP parameter used by IP. The IP driver use one MNP\r
214 child to transmit/receive frames. By default, it configures MNP\r
215 to receive unicast/multicast/broadcast. And it will enable/disable\r
216 the promiscous receive according to whether there is IP child\r
217 enable that or not. If Force is FALSE, it will iterate through\r
218 all the IP children to check whether the promiscuous receive\r
219 setting has been changed. If it hasn't been changed, it won't\r
220 reconfigure the MNP. If Force is TRUE, the MNP is configured no\r
221 matter whether that is changed or not.\r
222\r
223 @param[in] IpSb The IP4 service instance that is to be changed.\r
224 @param[in] Force Force the configuration or not.\r
225\r
226 @retval EFI_SUCCESS The MNP is successfully configured/reconfigured.\r
227 @retval Others Configuration failed.\r
228\r
229**/\r
230EFI_STATUS\r
231Ip4ServiceConfigMnp (\r
232 IN IP4_SERVICE *IpSb,\r
233 IN BOOLEAN Force\r
234 );\r
235\r
236/**\r
237 Intiialize the IP4_PROTOCOL structure to the unconfigured states.\r
238\r
239 @param IpSb The IP4 service instance.\r
240 @param IpInstance The IP4 child instance.\r
241\r
242**/\r
243VOID\r
244Ip4InitProtocol (\r
245 IN IP4_SERVICE *IpSb,\r
246 IN OUT IP4_PROTOCOL *IpInstance\r
247 );\r
248\r
249/**\r
250 Clean up the IP4 child, release all the resources used by it.\r
251\r
252 @param[in] IpInstance The IP4 child to clean up.\r
253\r
254 @retval EFI_SUCCESS The IP4 child is cleaned up\r
255 @retval EFI_DEVICE_ERROR Some resources failed to be released\r
256\r
257**/\r
258EFI_STATUS\r
259Ip4CleanProtocol (\r
260 IN IP4_PROTOCOL *IpInstance\r
261 );\r
262\r
263/**\r
264 Cancel the user's receive/transmit request.\r
265\r
266 @param[in] IpInstance The IP4 child\r
267 @param[in] Token The token to cancel. If NULL, all token will be\r
268 cancelled.\r
269\r
270 @retval EFI_SUCCESS The token is cancelled\r
271 @retval EFI_NOT_FOUND The token isn't found on either the\r
272 transmit/receive queue\r
273 @retval EFI_DEVICE_ERROR Not all token is cancelled when Token is NULL.\r
274\r
275**/\r
276EFI_STATUS\r
277Ip4Cancel (\r
278 IN IP4_PROTOCOL *IpInstance,\r
279 IN EFI_IP4_COMPLETION_TOKEN *Token OPTIONAL\r
280 );\r
281\r
282/**\r
283 Change the IP4 child's multicast setting. The caller\r
284 should make sure that the parameters is valid.\r
285\r
286 @param[in] IpInstance The IP4 child to change the setting.\r
287 @param[in] JoinFlag TRUE to join the group, otherwise leave it\r
288 @param[in] GroupAddress The target group address\r
289\r
290 @retval EFI_ALREADY_STARTED Want to join the group, but already a member of it\r
291 @retval EFI_OUT_OF_RESOURCES Failed to allocate some resources.\r
292 @retval EFI_DEVICE_ERROR Failed to set the group configuraton\r
293 @retval EFI_SUCCESS Successfully updated the group setting.\r
294 @retval EFI_NOT_FOUND Try to leave the group which it isn't a member.\r
295\r
296**/\r
297EFI_STATUS\r
298Ip4Groups (\r
299 IN IP4_PROTOCOL *IpInstance,\r
300 IN BOOLEAN JoinFlag,\r
301 IN EFI_IPv4_ADDRESS *GroupAddress OPTIONAL\r
302 );\r
303\r
304/**\r
305 The heart beat timer of IP4 service instance. It times out\r
306 all of its IP4 children's received-but-not-delivered and\r
307 transmitted-but-not-recycle packets, and provides time input\r
308 for its IGMP protocol.\r
309\r
310 @param[in] Event The IP4 service instance's heart beat timer.\r
311 @param[in] Context The IP4 service instance.\r
312\r
313**/\r
314VOID\r
315EFIAPI\r
316Ip4TimerTicking (\r
317 IN EFI_EVENT Event,\r
318 IN VOID *Context\r
319 );\r
320\r
321/**\r
322 Decrease the life of the transmitted packets. If it is\r
323 decreased to zero, cancel the packet. This function is\r
324 called by Ip4PacketTimerTicking which time out both the\r
325 received-but-not-delivered and transmitted-but-not-recycle\r
326 packets.\r
327\r
328 @param[in] Map The IP4 child's transmit map.\r
329 @param[in] Item Current transmitted packet\r
330 @param[in] Context Not used.\r
331\r
332 @retval EFI_SUCCESS Always returns EFI_SUCCESS\r
333\r
334**/\r
335EFI_STATUS\r
336Ip4SentPacketTicking (\r
337 IN NET_MAP *Map,\r
338 IN NET_MAP_ITEM *Item,\r
339 IN VOID *Context\r
340 );\r
341#endif\r