]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.h
Fixed one bug when calculating timeout value in timeout function for UDP protocol.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Udp4Dxe / Udp4Impl.h
CommitLineData
83cbd279 1/** @file\r
2\r
3Copyright (c) 2006 - 2007, Intel Corporation\r
4All rights reserved. This program and the accompanying materials\r
5are licensed and made available under the terms and conditions of the BSD License\r
6which accompanies this distribution. The full text of the license may be found at\r
7http://opensource.org/licenses/bsd-license.php\r
8\r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11\r
12Module Name:\r
13\r
14 Udp4Impl.h\r
15\r
16Abstract:\r
17\r
18 EFI UDPv4 protocol implementation\r
19\r
20\r
21**/\r
22\r
23#ifndef _UDP4_IMPL_H_\r
24#define _UDP4_IMPL_H_\r
25\r
8a67d61d 26#include <PiDxe.h>\r
27\r
eaf343ff 28#include <Protocol/Ip4.h>\r
8a67d61d 29#include <Protocol/Udp4.h>\r
83cbd279 30\r
8a67d61d 31#include <Library/IpIoLib.h>\r
32#include <Library/DebugLib.h>\r
33#include <Library/UefiRuntimeServicesTableLib.h>\r
34#include <Library/UefiDriverEntryPoint.h>\r
35#include <Library/UefiBootServicesTableLib.h>\r
36#include <Library/BaseLib.h>\r
83cbd279 37#include <Library/UefiLib.h>\r
38#include <Library/BaseMemoryLib.h>\r
39#include <Library/MemoryAllocationLib.h>\r
40\r
41#include "Udp4Driver.h"\r
42\r
43\r
44extern EFI_COMPONENT_NAME_PROTOCOL gUdp4ComponentName;\r
45extern EFI_COMPONENT_NAME2_PROTOCOL gUdp4ComponentName2;\r
46extern EFI_SERVICE_BINDING_PROTOCOL mUdp4ServiceBinding;\r
47extern EFI_UDP4_PROTOCOL mUdp4Protocol;\r
48extern UINT16 mUdp4RandomPort;\r
49\r
50#define ICMP_ERROR_PACKET_LENGTH 8\r
51\r
52#define UDP4_TIMEOUT_INTERVAL (50 * TICKS_PER_MS) // 50 milliseconds\r
53\r
54#define UDP4_HEADER_SIZE sizeof (EFI_UDP4_HEADER)\r
55#define UDP4_MAX_DATA_SIZE 65507\r
56\r
57#define UDP4_PORT_KNOWN 1024\r
58\r
59#define UDP4_SERVICE_DATA_SIGNATURE EFI_SIGNATURE_32('U', 'd', 'p', '4')\r
60\r
61#define UDP4_SERVICE_DATA_FROM_THIS(a) \\r
62 CR ( \\r
63 (a), \\r
64 UDP4_SERVICE_DATA, \\r
65 ServiceBinding, \\r
66 UDP4_SERVICE_DATA_SIGNATURE \\r
67 )\r
68\r
69typedef struct _UDP4_SERVICE_DATA_ {\r
70 UINT32 Signature;\r
71 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;\r
72 EFI_HANDLE ImageHandle;\r
73 EFI_HANDLE ControllerHandle;\r
e48e37fc 74 LIST_ENTRY ChildrenList;\r
83cbd279 75 UINTN ChildrenNumber;\r
76 IP_IO *IpIo;\r
77\r
78 EFI_EVENT TimeoutEvent;\r
79\r
80 CHAR16 *MacString;\r
81} UDP4_SERVICE_DATA;\r
82\r
83#define UDP4_INSTANCE_DATA_SIGNATURE EFI_SIGNATURE_32('U', 'd', 'p', 'I')\r
84\r
85#define UDP4_INSTANCE_DATA_FROM_THIS(a) \\r
86 CR ( \\r
87 (a), \\r
88 UDP4_INSTANCE_DATA, \\r
89 Udp4Proto, \\r
90 UDP4_INSTANCE_DATA_SIGNATURE \\r
91 )\r
92\r
93typedef struct _UDP4_INSTANCE_DATA_ {\r
94 UINT32 Signature;\r
e48e37fc 95 LIST_ENTRY Link;\r
83cbd279 96\r
97 UDP4_SERVICE_DATA *Udp4Service;\r
98 EFI_UDP4_PROTOCOL Udp4Proto;\r
99 EFI_UDP4_CONFIG_DATA ConfigData;\r
100 EFI_HANDLE ChildHandle;\r
101 BOOLEAN Configured;\r
102 BOOLEAN IsNoMapping;\r
103\r
104 NET_MAP TxTokens;\r
105 NET_MAP RxTokens;\r
106\r
107 NET_MAP McastIps;\r
108\r
e48e37fc 109 LIST_ENTRY RcvdDgramQue;\r
110 LIST_ENTRY DeliveredDgramQue;\r
83cbd279 111\r
112 UINT16 HeadSum;\r
113\r
114 EFI_STATUS IcmpError;\r
115\r
116 IP_IO_IP_INFO *IpInfo;\r
117\r
118 BOOLEAN Destroyed;\r
119} UDP4_INSTANCE_DATA;\r
120\r
121typedef struct _UDP4_RXDATA_WRAP_ {\r
e48e37fc 122 LIST_ENTRY Link;\r
83cbd279 123 NET_BUF *Packet;\r
124 UINT32 TimeoutTick;\r
125 EFI_UDP4_RECEIVE_DATA RxData;\r
126} UDP4_RXDATA_WRAP;\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
136 @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r
137 @param Udp4ConfigData Pointer to the buffer to receive the current configuration data.\r
138 @param Ip4ModeData Pointer to the EFI IPv4 Protocol mode data structure.\r
139 @param MnpConfigData Pointer to the managed network configuration data structure.\r
140 @param SnpModeData Pointer to the simple network mode data structure.\r
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
173 @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r
174 @param UdpConfigData Pointer to the buffer to receive the current configuration data.\r
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
205 @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r
206 @param JoinFlag Set to TRUE to join a multicast group. Set to FALSE to leave one\r
207 or all multicast groups.\r
208 @param MulticastAddress Pointer to multicast group address to join or leave.\r
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
256 @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r
257 @param 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 SubnetAddress The destination network address that needs to be routed.\r
260 @param SubnetMask The subnet mask of SubnetAddress.\r
261 @param GatewayAddress The gateway IP address for this route.\r
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
293 @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r
294 @param Token Pointer to the completion token that will be placed into the\r
295 transmit queue.\r
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
332 @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r
333 @param Token Pointer to a token that is associated with the receive data\r
334 descriptor.\r
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
366 @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r
367 @param 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
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
403 @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r
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
420 @param Udp4Service Pointer to the UDP4_SERVICE_DATA.\r
421 @param ImageHandle The image handle of this udp4 driver.\r
422 @param ControllerHandle The controller handle this udp4 driver binds on.\r
423\r
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
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
440 @param Udp4Service Pointer to the UDP4_SERVICE_DATA.\r
441\r
442 @return None.\r
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
453 @param Udp4Service Pointer to the UDP4_SERVICE_DATA.\r
454 @param Instance Pointer to the un-initialized UDP4_INSTANCE_DATA.\r
455\r
456 @return None.\r
457\r
458**/\r
83cbd279 459VOID\r
460Udp4InitInstance (\r
ce904bae 461 IN UDP4_SERVICE_DATA *Udp4Service,\r
462 IN OUT UDP4_INSTANCE_DATA *Instance\r
83cbd279 463 );\r
464\r
ce904bae 465/**\r
466 This function cleans the udp instance.\r
467\r
468 @param Instance Pointer to the UDP4_INSTANCE_DATA to clean.\r
469\r
470 @return None.\r
471\r
472**/\r
83cbd279 473VOID\r
474Udp4CleanInstance (\r
475 IN UDP4_INSTANCE_DATA *Instance\r
476 );\r
477\r
ce904bae 478/**\r
479 This function tries to bind the udp instance according to the configured port\r
480 allocation strategy.\r
481\r
482 @param InstanceList Pointer to the head of the list linking the udp\r
483 instances.\r
484 @param ConfigData Pointer to the ConfigData of the instance to be\r
485 bound. ConfigData->StationPort will be assigned\r
486 with an available port value on success.\r
487\r
488 @retval EFI_SUCCESS The bound operation is completed successfully.\r
489 @retval EFI_ACCESS_DENIED The <Address, Port> specified by the ConfigData is\r
490 already used by other instance.\r
491 @retval EFI_OUT_OF_RESOURCES No available port resources.\r
492\r
493**/\r
83cbd279 494EFI_STATUS\r
495Udp4Bind (\r
ce904bae 496 IN LIST_ENTRY *InstanceList,\r
497 IN OUT EFI_UDP4_CONFIG_DATA *ConfigData\r
83cbd279 498 );\r
499\r
ce904bae 500/**\r
501 This function is used to check whether the NewConfigData has any un-reconfigurable\r
502 parameters changed compared to the OldConfigData.\r
503\r
504 @param OldConfigData Pointer to the current ConfigData the udp instance\r
505 uses.\r
506 @param NewConfigData Pointer to the new ConfigData.\r
507\r
508 @retval TRUE The instance is reconfigurable.\r
509 @retval FALSE Otherwise.\r
510\r
511**/\r
83cbd279 512BOOLEAN\r
513Udp4IsReconfigurable (\r
514 IN EFI_UDP4_CONFIG_DATA *OldConfigData,\r
515 IN EFI_UDP4_CONFIG_DATA *NewConfigData\r
516 );\r
517\r
ce904bae 518/**\r
519 This function builds the Ip4 configdata from the Udp4ConfigData.\r
520\r
521 @param Udp4ConfigData Pointer to the EFI_UDP4_CONFIG_DATA.\r
522 @param Ip4ConfigData Pointer to the EFI_IP4_CONFIG_DATA.\r
523\r
524 @return None.\r
525\r
526**/\r
83cbd279 527VOID\r
528Udp4BuildIp4ConfigData (\r
ce904bae 529 IN EFI_UDP4_CONFIG_DATA *Udp4ConfigData,\r
530 IN OUT EFI_IP4_CONFIG_DATA *Ip4ConfigData\r
83cbd279 531 );\r
532\r
ce904bae 533/**\r
534 This function validates the TxToken, it returns the error code according to the spec.\r
535\r
536 @param Instance Pointer to the udp instance context data.\r
537 @param TxToken Pointer to the token to be checked.\r
538\r
539 @retval EFI_SUCCESS The TxToken is valid.\r
540 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE: This is\r
541 NULL. Token is NULL. Token.Event is NULL.\r
542 Token.Packet.TxData is NULL.\r
543 Token.Packet.TxData.FragmentCount is zero.\r
544 Token.Packet.TxData.DataLength is not equal to the\r
545 sum of fragment lengths. One or more of the\r
546 Token.Packet.TxData.FragmentTable[].\r
547 FragmentLength fields is zero. One or more of the\r
548 Token.Packet.TxData.FragmentTable[].\r
549 FragmentBuffer fields is NULL.\r
550 Token.Packet.TxData. GatewayAddress is not a\r
551 unicast IPv4 address if it is not NULL. One or\r
552 more IPv4 addresses in Token.Packet.TxData.\r
553 UdpSessionData are not valid unicast IPv4\r
554 addresses if the UdpSessionData is not NULL.\r
555 @retval EFI_BAD_BUFFER_SIZE The data length is greater than the maximum UDP\r
556 packet size.\r
557\r
558**/\r
83cbd279 559EFI_STATUS\r
560Udp4ValidateTxToken (\r
561 IN UDP4_INSTANCE_DATA *Instance,\r
562 IN EFI_UDP4_COMPLETION_TOKEN *TxToken\r
563 );\r
564\r
ce904bae 565/**\r
566 This function checks whether the specified Token duplicates with the one in the Map.\r
567\r
568 @param Map Pointer to the NET_MAP.\r
569 @param Item Pointer to the NET_MAP_ITEM contain the pointer to\r
570 the Token.\r
571 @param Context Pointer to the Token to be checked.\r
572\r
573 @retval EFI_SUCCESS The Token specified by Context differs from the\r
574 one in the Item.\r
575 @retval EFI_ACCESS_DENIED The Token duplicates with the one in the Item.\r
576\r
577**/\r
83cbd279 578EFI_STATUS\r
579Udp4TokenExist (\r
580 IN NET_MAP *Map,\r
581 IN NET_MAP_ITEM *Item,\r
582 IN VOID *Context\r
583 );\r
584\r
ce904bae 585/**\r
586 This function calculates the checksum for the Packet, utilizing the pre-calculated\r
587 pseudo HeadSum to reduce some overhead.\r
588\r
589 @param Packet Pointer to the NET_BUF contains the udp datagram.\r
590 @param HeadSum Checksum of the pseudo header execpt the length\r
591 field.\r
592\r
593 @return The 16-bit checksum of this udp datagram.\r
594\r
595**/\r
83cbd279 596UINT16\r
597Udp4Checksum (\r
598 IN NET_BUF *Packet,\r
599 IN UINT16 HeadSum\r
600 );\r
601\r
ce904bae 602/**\r
603 This function removes the specified Token from the TokenMap.\r
604\r
605 @param TokenMap Pointer to the NET_MAP containing the tokens.\r
606 @param Token Pointer to the Token to be removed.\r
607\r
608 @retval EFI_SUCCESS The specified Token is removed from the TokenMap.\r
609 @retval EFI_NOT_FOUND The specified Token is not found in the TokenMap.\r
610\r
611**/\r
83cbd279 612EFI_STATUS\r
613Udp4RemoveToken (\r
ce904bae 614 IN OUT NET_MAP *TokenMap,\r
615 IN EFI_UDP4_COMPLETION_TOKEN *Token\r
83cbd279 616 );\r
617\r
ce904bae 618/**\r
619 This function removes the multicast group specified by Arg from the Map.\r
620\r
621 @param Map Pointer to the NET_MAP.\r
622 @param Item Pointer to the NET_MAP_ITEM.\r
623 @param Arg Pointer to the Arg, it's the pointer to a\r
624 multicast IPv4 Address.\r
625\r
626 @retval EFI_SUCCESS The multicast address is removed.\r
627 @retval EFI_ABORTED The specified multicast address is removed and the\r
628 Arg is not NULL.\r
629\r
630**/\r
83cbd279 631EFI_STATUS\r
632Udp4LeaveGroup (\r
ce904bae 633 IN OUT NET_MAP *Map,\r
634 IN NET_MAP_ITEM *Item,\r
635 IN VOID *Arg OPTIONAL\r
83cbd279 636 );\r
637\r
ce904bae 638/**\r
639 This function removes all the Wrap datas in the RcvdDgramQue.\r
640\r
641 @param Instance Pointer to the udp instance context data.\r
642\r
643 @return None.\r
644\r
645**/\r
83cbd279 646VOID\r
36ee91ca 647Udp4FlushRcvdDgram (\r
648 IN UDP4_INSTANCE_DATA *Instance\r
83cbd279 649 );\r
650\r
ce904bae 651/**\r
652 Cancel Udp4 tokens from the Udp4 instance.\r
653\r
654 @param Instance Pointer to the udp instance context data.\r
655 @param Token Pointer to the token to be canceled, if NULL, all\r
656 tokens in this instance will be cancelled.\r
657\r
658 @retval EFI_SUCCESS The Token is cancelled.\r
659 @retval EFI_NOT_FOUND The Token is not found.\r
660\r
661**/\r
83cbd279 662EFI_STATUS\r
663Udp4InstanceCancelToken (\r
664 IN UDP4_INSTANCE_DATA *Instance,\r
665 IN EFI_UDP4_COMPLETION_TOKEN *Token OPTIONAL\r
666 );\r
667\r
ce904bae 668/**\r
669 This function delivers the received datagrams for the specified instance.\r
670\r
671 @param Instance Pointer to the instance context data.\r
672\r
673 @return None.\r
674\r
675**/\r
83cbd279 676VOID\r
677Udp4InstanceDeliverDgram (\r
678 IN UDP4_INSTANCE_DATA *Instance\r
679 );\r
680\r
ce904bae 681/**\r
682 This function reports the received ICMP error.\r
683\r
684 @param Instance Pointer to the udp instance context data.\r
685\r
686 @return None.\r
687\r
688**/\r
83cbd279 689VOID\r
690Udp4ReportIcmpError (\r
691 IN UDP4_INSTANCE_DATA *Instance\r
692 );\r
693\r
ce904bae 694/**\r
695 This function is a dummy ext-free function for the NET_BUF created for the output\r
696 udp datagram.\r
697\r
698 @param Context Pointer to the context data.\r
699\r
700 @return None.\r
701\r
702**/\r
83cbd279 703VOID\r
704Udp4NetVectorExtFree (\r
705 VOID *Context\r
706 );\r
707\r
ce904bae 708/**\r
709 Set the Udp4 variable data.\r
710\r
711 @param Udp4Service Udp4 service data.\r
712\r
713 @retval EFI_OUT_OF_RESOURCES There are not enough resources to set the\r
714 variable.\r
715 @retval EFI_SUCCESS Set variable successfully.\r
716 @retval other Set variable failed.\r
717\r
718**/\r
83cbd279 719EFI_STATUS\r
720Udp4SetVariableData (\r
721 IN UDP4_SERVICE_DATA *Udp4Service\r
722 );\r
723\r
ce904bae 724/**\r
725 Clear the variable and free the resource.\r
726\r
727 @param Udp4Service Udp4 service data.\r
728\r
729 @return None.\r
730\r
731**/\r
83cbd279 732VOID\r
733Udp4ClearVariableData (\r
734 IN UDP4_SERVICE_DATA *Udp4Service\r
735 );\r
736\r
737#endif\r
738\r