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