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