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