]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.h
1. Add EFI_COMPONENT_NAME2_PROTOCOL.GetControllerName() support.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Udp4Dxe / Udp4Impl.h
CommitLineData
83cbd279 1/** @file\r
3e8c18da 2 EFI UDPv4 protocol implementation.\r
3 \r
216f7970 4Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
e5eed7d3 5This program and the accompanying materials\r
83cbd279 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
83cbd279 13**/\r
14\r
15#ifndef _UDP4_IMPL_H_\r
16#define _UDP4_IMPL_H_\r
17\r
2517435c 18#include <Uefi.h>\r
8a67d61d 19\r
eaf343ff 20#include <Protocol/Ip4.h>\r
8a67d61d 21#include <Protocol/Udp4.h>\r
83cbd279 22\r
8a67d61d 23#include <Library/IpIoLib.h>\r
24#include <Library/DebugLib.h>\r
25#include <Library/UefiRuntimeServicesTableLib.h>\r
26#include <Library/UefiDriverEntryPoint.h>\r
27#include <Library/UefiBootServicesTableLib.h>\r
28#include <Library/BaseLib.h>\r
83cbd279 29#include <Library/UefiLib.h>\r
30#include <Library/BaseMemoryLib.h>\r
31#include <Library/MemoryAllocationLib.h>\r
19873973 32#include <Library/TimerLib.h>\r
d8d26fb2 33#include <Library/DpcLib.h>\r
216f7970 34#include <Library/PrintLib.h>\r
83cbd279 35\r
36#include "Udp4Driver.h"\r
37\r
38\r
39extern EFI_COMPONENT_NAME_PROTOCOL gUdp4ComponentName;\r
40extern EFI_COMPONENT_NAME2_PROTOCOL gUdp4ComponentName2;\r
216f7970 41extern EFI_UNICODE_STRING_TABLE *gUdpControllerNameTable;\r
83cbd279 42extern EFI_SERVICE_BINDING_PROTOCOL mUdp4ServiceBinding;\r
43extern EFI_UDP4_PROTOCOL mUdp4Protocol;\r
44extern UINT16 mUdp4RandomPort;\r
45\r
46#define ICMP_ERROR_PACKET_LENGTH 8\r
47\r
aeddd425 48#define UDP4_TIMEOUT_INTERVAL (50 * TICKS_PER_MS) // 50 milliseconds\r
83cbd279 49\r
fb115c61 50#define UDP4_HEADER_SIZE sizeof (EFI_UDP_HEADER)\r
83cbd279 51#define UDP4_MAX_DATA_SIZE 65507\r
52\r
53#define UDP4_PORT_KNOWN 1024\r
54\r
f3f2e05d 55#define UDP4_SERVICE_DATA_SIGNATURE SIGNATURE_32('U', 'd', 'p', '4')\r
83cbd279 56\r
57#define UDP4_SERVICE_DATA_FROM_THIS(a) \\r
58 CR ( \\r
59 (a), \\r
60 UDP4_SERVICE_DATA, \\r
61 ServiceBinding, \\r
62 UDP4_SERVICE_DATA_SIGNATURE \\r
63 )\r
64\r
65typedef struct _UDP4_SERVICE_DATA_ {\r
66 UINT32 Signature;\r
67 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;\r
68 EFI_HANDLE ImageHandle;\r
69 EFI_HANDLE ControllerHandle;\r
e48e37fc 70 LIST_ENTRY ChildrenList;\r
83cbd279 71 UINTN ChildrenNumber;\r
72 IP_IO *IpIo;\r
73\r
74 EFI_EVENT TimeoutEvent;\r
75\r
76 CHAR16 *MacString;\r
77} UDP4_SERVICE_DATA;\r
78\r
f3f2e05d 79#define UDP4_INSTANCE_DATA_SIGNATURE SIGNATURE_32('U', 'd', 'p', 'I')\r
83cbd279 80\r
81#define UDP4_INSTANCE_DATA_FROM_THIS(a) \\r
82 CR ( \\r
83 (a), \\r
84 UDP4_INSTANCE_DATA, \\r
85 Udp4Proto, \\r
86 UDP4_INSTANCE_DATA_SIGNATURE \\r
87 )\r
88\r
89typedef struct _UDP4_INSTANCE_DATA_ {\r
90 UINT32 Signature;\r
e48e37fc 91 LIST_ENTRY Link;\r
83cbd279 92\r
93 UDP4_SERVICE_DATA *Udp4Service;\r
94 EFI_UDP4_PROTOCOL Udp4Proto;\r
95 EFI_UDP4_CONFIG_DATA ConfigData;\r
96 EFI_HANDLE ChildHandle;\r
97 BOOLEAN Configured;\r
98 BOOLEAN IsNoMapping;\r
99\r
100 NET_MAP TxTokens;\r
101 NET_MAP RxTokens;\r
102\r
103 NET_MAP McastIps;\r
104\r
e48e37fc 105 LIST_ENTRY RcvdDgramQue;\r
106 LIST_ENTRY DeliveredDgramQue;\r
83cbd279 107\r
108 UINT16 HeadSum;\r
109\r
110 EFI_STATUS IcmpError;\r
111\r
112 IP_IO_IP_INFO *IpInfo;\r
113\r
216f7970 114 BOOLEAN InDestroy;\r
83cbd279 115} UDP4_INSTANCE_DATA;\r
116\r
117typedef struct _UDP4_RXDATA_WRAP_ {\r
e48e37fc 118 LIST_ENTRY Link;\r
83cbd279 119 NET_BUF *Packet;\r
120 UINT32 TimeoutTick;\r
121 EFI_UDP4_RECEIVE_DATA RxData;\r
122} UDP4_RXDATA_WRAP;\r
123\r
216f7970 124typedef struct {\r
125 EFI_SERVICE_BINDING_PROTOCOL *ServiceBinding;\r
126 UINTN NumberOfChildren;\r
127 EFI_HANDLE *ChildHandleBuffer;\r
128} UDP4_DESTROY_CHILD_IN_HANDLE_BUF_CONTEXT;\r
129\r
ce904bae 130/**\r
131 Reads the current operational settings.\r
132\r
133 The GetModeData() function copies the current operational settings of this EFI\r
134 UDPv4 Protocol instance into user-supplied buffers. This function is used\r
135 optionally to retrieve the operational mode data of underlying networks or\r
136 drivers.\r
137\r
47c75f64 138 @param[in] This Pointer to the EFI_UDP4_PROTOCOL instance.\r
139 @param[out] Udp4ConfigData Pointer to the buffer to receive the current configuration data.\r
140 @param[out] Ip4ModeData Pointer to the EFI IPv4 Protocol mode data structure.\r
141 @param[out] MnpConfigData Pointer to the managed network configuration data structure.\r
142 @param[out] SnpModeData Pointer to the simple network mode data structure.\r
ce904bae 143\r
144 @retval EFI_SUCCESS The mode data was read.\r
145 @retval EFI_NOT_STARTED When Udp4ConfigData is queried, no configuration data is\r
146 available because this instance has not been started.\r
147 @retval EFI_INVALID_PARAMETER This is NULL.\r
148\r
149**/\r
83cbd279 150EFI_STATUS\r
151EFIAPI\r
152Udp4GetModeData (\r
153 IN EFI_UDP4_PROTOCOL *This,\r
154 OUT EFI_UDP4_CONFIG_DATA *Udp4ConfigData OPTIONAL,\r
155 OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,\r
156 OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,\r
157 OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL\r
158 );\r
159\r
ce904bae 160/**\r
161 Initializes, changes, or resets the operational parameters for this instance of the EFI UDPv4\r
162 Protocol.\r
163 \r
164 The Configure() function is used to do the following:\r
165 * Initialize and start this instance of the EFI UDPv4 Protocol.\r
166 * Change the filtering rules and operational parameters.\r
167 * Reset this instance of the EFI UDPv4 Protocol.\r
168 Until these parameters are initialized, no network traffic can be sent or\r
169 received by this instance. This instance can be also reset by calling Configure()\r
170 with UdpConfigData set to NULL. Once reset, the receiving queue and transmitting\r
171 queue are flushed and no traffic is allowed through this instance.\r
172 With different parameters in UdpConfigData, Configure() can be used to bind\r
173 this instance to specified port.\r
174\r
3e8c18da 175 @param[in] This Pointer to the EFI_UDP4_PROTOCOL instance.\r
176 @param[in] UdpConfigData Pointer to the buffer to receive the current configuration data.\r
ce904bae 177\r
178 @retval EFI_SUCCESS The configuration settings were set, changed, or reset successfully.\r
179 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,\r
180 RARP, etc.) is not finished yet.\r
181 @retval EFI_INVALID_PARAMETER One or more following conditions are TRUE:\r
182 @retval EFI_ALREADY_STARTED The EFI UDPv4 Protocol instance is already started/configured\r
183 and must be stopped/reset before it can be reconfigured.\r
184 @retval EFI_ACCESS_DENIED UdpConfigData. AllowDuplicatePort is FALSE\r
185 and UdpConfigData.StationPort is already used by\r
186 other instance.\r
187 @retval EFI_OUT_OF_RESOURCES The EFI UDPv4 Protocol driver cannot allocate memory for this\r
188 EFI UDPv4 Protocol instance.\r
189 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred and this instance\r
190 was not opened. \r
191\r
192**/\r
83cbd279 193EFI_STATUS\r
194EFIAPI\r
195Udp4Configure (\r
196 IN EFI_UDP4_PROTOCOL *This,\r
197 IN EFI_UDP4_CONFIG_DATA *UdpConfigData OPTIONAL\r
198 );\r
199\r
ce904bae 200/**\r
201 Joins and leaves multicast groups.\r
202 \r
203 The Groups() function is used to enable and disable the multicast group\r
204 filtering. If the JoinFlag is FALSE and the MulticastAddress is NULL, then all\r
205 currently joined groups are left.\r
206\r
3e8c18da 207 @param[in] This Pointer to the EFI_UDP4_PROTOCOL instance.\r
208 @param[in] JoinFlag Set to TRUE to join a multicast group. Set to FALSE to leave one\r
209 or all multicast groups.\r
210 @param[in] MulticastAddress Pointer to multicast group address to join or leave.\r
ce904bae 211\r
212 @retval EFI_SUCCESS The operation completed successfully.\r
213 @retval EFI_NOT_STARTED The EFI UDPv4 Protocol instance has not been started.\r
214 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,\r
215 RARP, etc.) is not finished yet.\r
216 @retval EFI_OUT_OF_RESOURCES Could not allocate resources to join the group.\r
217 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
218 - This is NULL.\r
219 - JoinFlag is TRUE and MulticastAddress is NULL.\r
220 - JoinFlag is TRUE and *MulticastAddress is not\r
221 a valid multicast address.\r
222 @retval EFI_ALREADY_STARTED The group address is already in the group table (when\r
223 JoinFlag is TRUE).\r
224 @retval EFI_NOT_FOUND The group address is not in the group table (when JoinFlag is\r
225 FALSE).\r
226 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
227\r
228**/\r
83cbd279 229EFI_STATUS\r
230EFIAPI\r
231Udp4Groups (\r
232 IN EFI_UDP4_PROTOCOL *This,\r
233 IN BOOLEAN JoinFlag,\r
234 IN EFI_IPv4_ADDRESS *MulticastAddress OPTIONAL\r
235 );\r
236\r
ce904bae 237/**\r
238 Adds and deletes routing table entries.\r
239 \r
240 The Routes() function adds a route to or deletes a route from the routing table.\r
241 Routes are determined by comparing the SubnetAddress with the destination IP\r
242 address and arithmetically AND-ing it with the SubnetMask. The gateway address\r
243 must be on the same subnet as the configured station address.\r
244 The default route is added with SubnetAddress and SubnetMask both set to 0.0.0.0.\r
245 The default route matches all destination IP addresses that do not match any\r
246 other routes.\r
247 A zero GatewayAddress is a nonroute. Packets are sent to the destination IP\r
248 address if it can be found in the Address Resolution Protocol (ARP) cache or\r
249 on the local subnet. One automatic nonroute entry will be inserted into the\r
250 routing table for outgoing packets that are addressed to a local subnet\r
251 (gateway address of 0.0.0.0).\r
252 Each instance of the EFI UDPv4 Protocol has its own independent routing table.\r
253 Instances of the EFI UDPv4 Protocol that use the default IP address will also\r
254 have copies of the routing table provided by the EFI_IP4_CONFIG_PROTOCOL. These\r
255 copies will be updated automatically whenever the IP driver reconfigures its\r
256 instances; as a result, the previous modification to these copies will be lost.\r
257\r
3e8c18da 258 @param[in] This Pointer to the EFI_UDP4_PROTOCOL instance.\r
259 @param[in] DeleteRoute Set to TRUE to delete this route from the routing table.\r
260 Set to FALSE to add this route to the routing table.\r
261 @param[in] SubnetAddress The destination network address that needs to be routed.\r
262 @param[in] SubnetMask The subnet mask of SubnetAddress.\r
263 @param[in] GatewayAddress The gateway IP address for this route.\r
ce904bae 264\r
265 @retval EFI_SUCCESS The operation completed successfully.\r
266 @retval EFI_NOT_STARTED The EFI UDPv4 Protocol instance has not been started.\r
267 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,\r
268 - RARP, etc.) is not finished yet.\r
269 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
270 @retval EFI_OUT_OF_RESOURCES Could not add the entry to the routing table.\r
271 @retval EFI_NOT_FOUND This route is not in the routing table.\r
272 @retval EFI_ACCESS_DENIED The route is already defined in the routing table.\r
273\r
274**/\r
83cbd279 275EFI_STATUS\r
276EFIAPI\r
277Udp4Routes (\r
278 IN EFI_UDP4_PROTOCOL *This,\r
279 IN BOOLEAN DeleteRoute,\r
280 IN EFI_IPv4_ADDRESS *SubnetAddress,\r
281 IN EFI_IPv4_ADDRESS *SubnetMask,\r
282 IN EFI_IPv4_ADDRESS *GatewayAddress\r
283 );\r
284\r
ce904bae 285/**\r
286 Queues outgoing data packets into the transmit queue.\r
287 \r
288 The Transmit() function places a sending request to this instance of the EFI\r
289 UDPv4 Protocol, alongside the transmit data that was filled by the user. Whenever\r
290 the packet in the token is sent out or some errors occur, the Token.Event will\r
291 be signaled and Token.Status is updated. Providing a proper notification function\r
292 and context for the event will enable the user to receive the notification and\r
293 transmitting status.\r
294\r
3e8c18da 295 @param[in] This Pointer to the EFI_UDP4_PROTOCOL instance.\r
296 @param[in] Token Pointer to the completion token that will be placed into the\r
297 transmit queue.\r
ce904bae 298\r
299 @retval EFI_SUCCESS The data has been queued for transmission.\r
300 @retval EFI_NOT_STARTED This EFI UDPv4 Protocol instance has not been started.\r
301 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP,\r
302 RARP, etc.) is not finished yet.\r
303 @retval EFI_INVALID_PARAMETER One or more parameters are invalid.\r
304 @retval EFI_ACCESS_DENIED The transmit completion token with the same\r
305 Token.Event was already in the transmit queue.\r
306 @retval EFI_NOT_READY The completion token could not be queued because the\r
307 transmit queue is full.\r
308 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data.\r
309 @retval EFI_NOT_FOUND There is no route to the destination network or address.\r
310 @retval EFI_BAD_BUFFER_SIZE The data length is greater than the maximum UDP packet\r
311 size. Or the length of the IP header + UDP header + data\r
312 length is greater than MTU if DoNotFragment is TRUE.\r
313\r
314**/\r
83cbd279 315EFI_STATUS\r
316EFIAPI\r
317Udp4Transmit (\r
318 IN EFI_UDP4_PROTOCOL *This,\r
319 IN EFI_UDP4_COMPLETION_TOKEN *Token\r
320 );\r
321\r
ce904bae 322/**\r
323 Places an asynchronous receive request into the receiving queue.\r
324 \r
325 The Receive() function places a completion token into the receive packet queue.\r
326 This function is always asynchronous.\r
327 The caller must fill in the Token.Event field in the completion token, and this\r
328 field cannot be NULL. When the receive operation completes, the EFI UDPv4 Protocol\r
329 driver updates the Token.Status and Token.Packet.RxData fields and the Token.Event\r
330 is signaled. Providing a proper notification function and context for the event\r
331 will enable the user to receive the notification and receiving status. That\r
332 notification function is guaranteed to not be re-entered.\r
333\r
3e8c18da 334 @param[in] This Pointer to the EFI_UDP4_PROTOCOL instance.\r
335 @param[in] Token Pointer to a token that is associated with\r
336 the receive data descriptor.\r
ce904bae 337\r
338 @retval EFI_SUCCESS The receive completion token was cached.\r
339 @retval EFI_NOT_STARTED This EFI UDPv4 Protocol instance has not been started.\r
340 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP, BOOTP, RARP, etc.)\r
341 is not finished yet.\r
342 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
343 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of system\r
344 resources (usually memory).\r
345 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
346 @retval EFI_ACCESS_DENIED A receive completion token with the same Token.Event was already in\r
347 the receive queue.\r
348 @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full.\r
349\r
350**/\r
83cbd279 351EFI_STATUS\r
352EFIAPI\r
353Udp4Receive (\r
354 IN EFI_UDP4_PROTOCOL *This,\r
355 IN EFI_UDP4_COMPLETION_TOKEN *Token\r
356 );\r
357\r
ce904bae 358/**\r
359 Aborts an asynchronous transmit or receive request.\r
360 \r
361 The Cancel() function is used to abort a pending transmit or receive request.\r
362 If the token is in the transmit or receive request queues, after calling this\r
363 function, Token.Status will be set to EFI_ABORTED and then Token.Event will be\r
364 signaled. If the token is not in one of the queues, which usually means that\r
365 the asynchronous operation has completed, this function will not signal the\r
366 token and EFI_NOT_FOUND is returned.\r
367\r
3e8c18da 368 @param[in] This Pointer to the EFI_UDP4_PROTOCOL instance.\r
369 @param[in] Token Pointer to a token that has been issued by\r
370 EFI_UDP4_PROTOCOL.Transmit() or\r
371 EFI_UDP4_PROTOCOL.Receive().If NULL, all pending\r
372 tokens are aborted.\r
ce904bae 373\r
374 @retval EFI_SUCCESS The asynchronous I/O request was aborted and Token.Event\r
375 was signaled. When Token is NULL, all pending requests are\r
376 aborted and their events are signaled.\r
377 @retval EFI_INVALID_PARAMETER This is NULL.\r
378 @retval EFI_NOT_STARTED This instance has not been started.\r
379 @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,\r
380 RARP, etc.) is not finished yet.\r
381 @retval EFI_NOT_FOUND When Token is not NULL, the asynchronous I/O request was\r
382 not found in the transmit or receive queue. It has either completed\r
383 or was not issued by Transmit() and Receive().\r
384\r
385**/\r
83cbd279 386EFI_STATUS\r
387EFIAPI\r
388Udp4Cancel (\r
389 IN EFI_UDP4_PROTOCOL *This,\r
390 IN EFI_UDP4_COMPLETION_TOKEN *Token OPTIONAL\r
391 );\r
392\r
ce904bae 393/**\r
394 Polls for incoming data packets and processes outgoing data packets.\r
395 \r
396 The Poll() function can be used by network drivers and applications to increase\r
397 the rate that data packets are moved between the communications device and the\r
398 transmit and receive queues.\r
399 In some systems, the periodic timer event in the managed network driver may not\r
400 poll the underlying communications device fast enough to transmit and/or receive\r
401 all data packets without missing incoming packets or dropping outgoing packets.\r
402 Drivers and applications that are experiencing packet loss should try calling\r
403 the Poll() function more often.\r
404\r
3e8c18da 405 @param[in] This Pointer to the EFI_UDP4_PROTOCOL instance.\r
ce904bae 406\r
407 @retval EFI_SUCCESS Incoming or outgoing data was processed.\r
408 @retval EFI_INVALID_PARAMETER This is NULL.\r
409 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.\r
410 @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue.\r
411\r
412**/\r
83cbd279 413EFI_STATUS\r
414EFIAPI\r
415Udp4Poll (\r
416 IN EFI_UDP4_PROTOCOL *This\r
417 );\r
418\r
ce904bae 419/**\r
420 Create the Udp service context data.\r
421\r
47c75f64 422 @param[in, out] Udp4Service Pointer to the UDP4_SERVICE_DATA.\r
423 @param[in] ImageHandle The image handle of this udp4 driver.\r
424 @param[in] ControllerHandle The controller handle this udp4 driver binds on.\r
ce904bae 425\r
47c75f64 426 @retval EFI_SUCCESS The udp4 service context data is created and\r
427 initialized.\r
428 @retval EFI_OUT_OF_RESOURCES Cannot allocate memory.\r
429 @retval other Other error occurs.\r
ce904bae 430\r
431**/\r
83cbd279 432EFI_STATUS\r
433Udp4CreateService (\r
ce904bae 434 IN OUT UDP4_SERVICE_DATA *Udp4Service,\r
435 IN EFI_HANDLE ImageHandle,\r
436 IN EFI_HANDLE ControllerHandle\r
83cbd279 437 );\r
438\r
ce904bae 439/**\r
440 Clean the Udp service context data.\r
441\r
3e8c18da 442 @param[in] Udp4Service Pointer to the UDP4_SERVICE_DATA.\r
ce904bae 443\r
444**/\r
83cbd279 445VOID\r
446Udp4CleanService (\r
447 IN UDP4_SERVICE_DATA *Udp4Service\r
448 );\r
449\r
ce904bae 450/**\r
451 This function intializes the new created udp instance.\r
452\r
47c75f64 453 @param[in] Udp4Service Pointer to the UDP4_SERVICE_DATA.\r
454 @param[in, out] Instance Pointer to the un-initialized UDP4_INSTANCE_DATA.\r
ce904bae 455\r
ce904bae 456**/\r
83cbd279 457VOID\r
458Udp4InitInstance (\r
ce904bae 459 IN UDP4_SERVICE_DATA *Udp4Service,\r
460 IN OUT UDP4_INSTANCE_DATA *Instance\r
83cbd279 461 );\r
462\r
ce904bae 463/**\r
464 This function cleans the udp instance.\r
465\r
3e8c18da 466 @param[in] Instance Pointer to the UDP4_INSTANCE_DATA to clean.\r
ce904bae 467\r
468**/\r
83cbd279 469VOID\r
470Udp4CleanInstance (\r
471 IN UDP4_INSTANCE_DATA *Instance\r
472 );\r
473\r
ce904bae 474/**\r
475 This function tries to bind the udp instance according to the configured port\r
476 allocation strategy.\r
477\r
47c75f64 478 @param[in] InstanceList Pointer to the head of the list linking the udp\r
ce904bae 479 instances.\r
47c75f64 480 @param[in, out] ConfigData Pointer to the ConfigData of the instance to be\r
ce904bae 481 bound. ConfigData->StationPort will be assigned\r
482 with an available port value on success.\r
483\r
484 @retval EFI_SUCCESS The bound operation is completed successfully.\r
485 @retval EFI_ACCESS_DENIED The <Address, Port> specified by the ConfigData is\r
486 already used by other instance.\r
487 @retval EFI_OUT_OF_RESOURCES No available port resources.\r
488\r
489**/\r
83cbd279 490EFI_STATUS\r
491Udp4Bind (\r
ce904bae 492 IN LIST_ENTRY *InstanceList,\r
493 IN OUT EFI_UDP4_CONFIG_DATA *ConfigData\r
83cbd279 494 );\r
495\r
ce904bae 496/**\r
497 This function is used to check whether the NewConfigData has any un-reconfigurable\r
498 parameters changed compared to the OldConfigData.\r
499\r
3e8c18da 500 @param[in] OldConfigData Pointer to the current ConfigData the udp instance\r
ce904bae 501 uses.\r
3e8c18da 502 @param[in] NewConfigData Pointer to the new ConfigData.\r
ce904bae 503\r
504 @retval TRUE The instance is reconfigurable.\r
505 @retval FALSE Otherwise.\r
506\r
507**/\r
83cbd279 508BOOLEAN\r
509Udp4IsReconfigurable (\r
510 IN EFI_UDP4_CONFIG_DATA *OldConfigData,\r
511 IN EFI_UDP4_CONFIG_DATA *NewConfigData\r
512 );\r
513\r
ce904bae 514/**\r
515 This function builds the Ip4 configdata from the Udp4ConfigData.\r
516\r
3e8c18da 517 @param[in] Udp4ConfigData Pointer to the EFI_UDP4_CONFIG_DATA.\r
518 @param[in, out] Ip4ConfigData Pointer to the EFI_IP4_CONFIG_DATA.\r
ce904bae 519\r
520**/\r
83cbd279 521VOID\r
522Udp4BuildIp4ConfigData (\r
ce904bae 523 IN EFI_UDP4_CONFIG_DATA *Udp4ConfigData,\r
524 IN OUT EFI_IP4_CONFIG_DATA *Ip4ConfigData\r
83cbd279 525 );\r
526\r
ce904bae 527/**\r
528 This function validates the TxToken, it returns the error code according to the spec.\r
529\r
3e8c18da 530 @param[in] Instance Pointer to the udp instance context data.\r
531 @param[in] TxToken Pointer to the token to be checked.\r
ce904bae 532\r
533 @retval EFI_SUCCESS The TxToken is valid.\r
534 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE: This is\r
535 NULL. Token is NULL. Token.Event is NULL.\r
536 Token.Packet.TxData is NULL.\r
537 Token.Packet.TxData.FragmentCount is zero.\r
538 Token.Packet.TxData.DataLength is not equal to the\r
539 sum of fragment lengths. One or more of the\r
540 Token.Packet.TxData.FragmentTable[].\r
541 FragmentLength fields is zero. One or more of the\r
542 Token.Packet.TxData.FragmentTable[].\r
543 FragmentBuffer fields is NULL.\r
544 Token.Packet.TxData. GatewayAddress is not a\r
545 unicast IPv4 address if it is not NULL. One or\r
546 more IPv4 addresses in Token.Packet.TxData.\r
547 UdpSessionData are not valid unicast IPv4\r
548 addresses if the UdpSessionData is not NULL.\r
549 @retval EFI_BAD_BUFFER_SIZE The data length is greater than the maximum UDP\r
550 packet size.\r
551\r
552**/\r
83cbd279 553EFI_STATUS\r
554Udp4ValidateTxToken (\r
555 IN UDP4_INSTANCE_DATA *Instance,\r
556 IN EFI_UDP4_COMPLETION_TOKEN *TxToken\r
557 );\r
558\r
ce904bae 559/**\r
560 This function checks whether the specified Token duplicates with the one in the Map.\r
561\r
3e8c18da 562 @param[in] Map Pointer to the NET_MAP.\r
563 @param[in] Item Pointer to the NET_MAP_ITEM contain the pointer to\r
ce904bae 564 the Token.\r
3e8c18da 565 @param[in] Context Pointer to the Token to be checked.\r
ce904bae 566\r
567 @retval EFI_SUCCESS The Token specified by Context differs from the\r
568 one in the Item.\r
569 @retval EFI_ACCESS_DENIED The Token duplicates with the one in the Item.\r
570\r
571**/\r
83cbd279 572EFI_STATUS\r
e798cd87 573EFIAPI\r
83cbd279 574Udp4TokenExist (\r
575 IN NET_MAP *Map,\r
576 IN NET_MAP_ITEM *Item,\r
577 IN VOID *Context\r
578 );\r
579\r
ce904bae 580/**\r
581 This function calculates the checksum for the Packet, utilizing the pre-calculated\r
582 pseudo HeadSum to reduce some overhead.\r
583\r
3e8c18da 584 @param[in] Packet Pointer to the NET_BUF contains the udp datagram.\r
585 @param[in] HeadSum Checksum of the pseudo header execpt the length\r
ce904bae 586 field.\r
587\r
3e8c18da 588 @retval The 16-bit checksum of this udp datagram.\r
ce904bae 589\r
590**/\r
83cbd279 591UINT16\r
592Udp4Checksum (\r
593 IN NET_BUF *Packet,\r
594 IN UINT16 HeadSum\r
595 );\r
596\r
ce904bae 597/**\r
598 This function removes the specified Token from the TokenMap.\r
599\r
47c75f64 600 @param[in, out] TokenMap Pointer to the NET_MAP containing the tokens.\r
601 @param[in] Token Pointer to the Token to be removed.\r
ce904bae 602\r
603 @retval EFI_SUCCESS The specified Token is removed from the TokenMap.\r
604 @retval EFI_NOT_FOUND The specified Token is not found in the TokenMap.\r
605\r
606**/\r
83cbd279 607EFI_STATUS\r
608Udp4RemoveToken (\r
ce904bae 609 IN OUT NET_MAP *TokenMap,\r
610 IN EFI_UDP4_COMPLETION_TOKEN *Token\r
83cbd279 611 );\r
612\r
ce904bae 613/**\r
614 This function removes the multicast group specified by Arg from the Map.\r
615\r
47c75f64 616 @param[in, out] Map Pointer to the NET_MAP.\r
617 @param[in] Item Pointer to the NET_MAP_ITEM.\r
618 @param[in] Arg Pointer to the Arg, it's the pointer to a\r
ce904bae 619 multicast IPv4 Address.\r
620\r
621 @retval EFI_SUCCESS The multicast address is removed.\r
622 @retval EFI_ABORTED The specified multicast address is removed and the\r
623 Arg is not NULL.\r
624\r
625**/\r
83cbd279 626EFI_STATUS\r
e798cd87 627EFIAPI\r
83cbd279 628Udp4LeaveGroup (\r
ce904bae 629 IN OUT NET_MAP *Map,\r
630 IN NET_MAP_ITEM *Item,\r
631 IN VOID *Arg OPTIONAL\r
83cbd279 632 );\r
633\r
ce904bae 634/**\r
635 This function removes all the Wrap datas in the RcvdDgramQue.\r
636\r
3e8c18da 637 @param[in] Instance Pointer to the udp instance context data.\r
ce904bae 638\r
639**/\r
83cbd279 640VOID\r
36ee91ca 641Udp4FlushRcvdDgram (\r
642 IN UDP4_INSTANCE_DATA *Instance\r
83cbd279 643 );\r
644\r
ce904bae 645/**\r
646 Cancel Udp4 tokens from the Udp4 instance.\r
647\r
3e8c18da 648 @param[in] Instance Pointer to the udp instance context data.\r
649 @param[in] Token Pointer to the token to be canceled, if NULL, all\r
ce904bae 650 tokens in this instance will be cancelled.\r
651\r
652 @retval EFI_SUCCESS The Token is cancelled.\r
653 @retval EFI_NOT_FOUND The Token is not found.\r
654\r
655**/\r
83cbd279 656EFI_STATUS\r
657Udp4InstanceCancelToken (\r
658 IN UDP4_INSTANCE_DATA *Instance,\r
659 IN EFI_UDP4_COMPLETION_TOKEN *Token OPTIONAL\r
660 );\r
661\r
ce904bae 662/**\r
663 This function delivers the received datagrams for the specified instance.\r
664\r
3e8c18da 665 @param[in] Instance Pointer to the instance context data.\r
ce904bae 666\r
667**/\r
83cbd279 668VOID\r
669Udp4InstanceDeliverDgram (\r
670 IN UDP4_INSTANCE_DATA *Instance\r
671 );\r
672\r
ce904bae 673/**\r
674 This function reports the received ICMP error.\r
675\r
3e8c18da 676 @param[in] Instance Pointer to the udp instance context data.\r
ce904bae 677\r
678**/\r
83cbd279 679VOID\r
680Udp4ReportIcmpError (\r
681 IN UDP4_INSTANCE_DATA *Instance\r
682 );\r
683\r
ce904bae 684/**\r
685 This function is a dummy ext-free function for the NET_BUF created for the output\r
686 udp datagram.\r
687\r
3e8c18da 688 @param[in] Context Pointer to the context data.\r
ce904bae 689\r
690**/\r
83cbd279 691VOID\r
e798cd87 692EFIAPI\r
83cbd279 693Udp4NetVectorExtFree (\r
694 VOID *Context\r
695 );\r
696\r
ce904bae 697/**\r
698 Set the Udp4 variable data.\r
699\r
47c75f64 700 @param[in] Udp4Service Udp4 service data.\r
ce904bae 701\r
702 @retval EFI_OUT_OF_RESOURCES There are not enough resources to set the\r
703 variable.\r
704 @retval EFI_SUCCESS Set variable successfully.\r
705 @retval other Set variable failed.\r
706\r
707**/\r
83cbd279 708EFI_STATUS\r
709Udp4SetVariableData (\r
710 IN UDP4_SERVICE_DATA *Udp4Service\r
711 );\r
712\r
ce904bae 713/**\r
714 Clear the variable and free the resource.\r
715\r
3e8c18da 716 @param[[in] Udp4Service Udp4 service data.\r
ce904bae 717\r
718**/\r
83cbd279 719VOID\r
720Udp4ClearVariableData (\r
721 IN UDP4_SERVICE_DATA *Udp4Service\r
722 );\r
723\r
724#endif\r
725\r