]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Udp4Dxe/Udp4Impl.h
add security check.
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Udp4Dxe / Udp4Impl.h
CommitLineData
83cbd279 1/** @file\r
3e8c18da 2 EFI UDPv4 protocol implementation.\r
3 \r
4Copyright (c) 2006 - 2007, 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
83cbd279 33\r
34#include "Udp4Driver.h"\r
35\r
36\r
37extern EFI_COMPONENT_NAME_PROTOCOL gUdp4ComponentName;\r
38extern EFI_COMPONENT_NAME2_PROTOCOL gUdp4ComponentName2;\r
39extern EFI_SERVICE_BINDING_PROTOCOL mUdp4ServiceBinding;\r
40extern EFI_UDP4_PROTOCOL mUdp4Protocol;\r
41extern UINT16 mUdp4RandomPort;\r
42\r
43#define ICMP_ERROR_PACKET_LENGTH 8\r
44\r
19873973 45#define UDP4_TIMEOUT_INTERVAL (10 * TICKS_PER_MS) // 10 milliseconds\r
83cbd279 46\r
47#define UDP4_HEADER_SIZE sizeof (EFI_UDP4_HEADER)\r
48#define UDP4_MAX_DATA_SIZE 65507\r
49\r
50#define UDP4_PORT_KNOWN 1024\r
51\r
f3f2e05d 52#define UDP4_SERVICE_DATA_SIGNATURE SIGNATURE_32('U', 'd', 'p', '4')\r
83cbd279 53\r
54#define UDP4_SERVICE_DATA_FROM_THIS(a) \\r
55 CR ( \\r
56 (a), \\r
57 UDP4_SERVICE_DATA, \\r
58 ServiceBinding, \\r
59 UDP4_SERVICE_DATA_SIGNATURE \\r
60 )\r
61\r
62typedef struct _UDP4_SERVICE_DATA_ {\r
63 UINT32 Signature;\r
64 EFI_SERVICE_BINDING_PROTOCOL ServiceBinding;\r
65 EFI_HANDLE ImageHandle;\r
66 EFI_HANDLE ControllerHandle;\r
e48e37fc 67 LIST_ENTRY ChildrenList;\r
83cbd279 68 UINTN ChildrenNumber;\r
69 IP_IO *IpIo;\r
70\r
71 EFI_EVENT TimeoutEvent;\r
72\r
73 CHAR16 *MacString;\r
74} UDP4_SERVICE_DATA;\r
75\r
f3f2e05d 76#define UDP4_INSTANCE_DATA_SIGNATURE SIGNATURE_32('U', 'd', 'p', 'I')\r
83cbd279 77\r
78#define UDP4_INSTANCE_DATA_FROM_THIS(a) \\r
79 CR ( \\r
80 (a), \\r
81 UDP4_INSTANCE_DATA, \\r
82 Udp4Proto, \\r
83 UDP4_INSTANCE_DATA_SIGNATURE \\r
84 )\r
85\r
86typedef struct _UDP4_INSTANCE_DATA_ {\r
87 UINT32 Signature;\r
e48e37fc 88 LIST_ENTRY Link;\r
83cbd279 89\r
90 UDP4_SERVICE_DATA *Udp4Service;\r
91 EFI_UDP4_PROTOCOL Udp4Proto;\r
92 EFI_UDP4_CONFIG_DATA ConfigData;\r
93 EFI_HANDLE ChildHandle;\r
94 BOOLEAN Configured;\r
95 BOOLEAN IsNoMapping;\r
96\r
97 NET_MAP TxTokens;\r
98 NET_MAP RxTokens;\r
99\r
100 NET_MAP McastIps;\r
101\r
e48e37fc 102 LIST_ENTRY RcvdDgramQue;\r
103 LIST_ENTRY DeliveredDgramQue;\r
83cbd279 104\r
105 UINT16 HeadSum;\r
106\r
107 EFI_STATUS IcmpError;\r
108\r
109 IP_IO_IP_INFO *IpInfo;\r
110\r
111 BOOLEAN Destroyed;\r
112} UDP4_INSTANCE_DATA;\r
113\r
114typedef struct _UDP4_RXDATA_WRAP_ {\r
e48e37fc 115 LIST_ENTRY Link;\r
83cbd279 116 NET_BUF *Packet;\r
117 UINT32 TimeoutTick;\r
118 EFI_UDP4_RECEIVE_DATA RxData;\r
119} UDP4_RXDATA_WRAP;\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
129 @param This Pointer to the EFI_UDP4_PROTOCOL instance.\r
130 @param Udp4ConfigData Pointer to the buffer to receive the current configuration data.\r
131 @param Ip4ModeData Pointer to the EFI IPv4 Protocol mode data structure.\r
132 @param MnpConfigData Pointer to the managed network configuration data structure.\r
133 @param SnpModeData Pointer to the simple network mode data structure.\r
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
154 \r
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
181 was not opened. \r
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
193 \r
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
230 \r
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
278 \r
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
315 \r
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
351 \r
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
386 \r
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
413 @param Udp4Service Pointer to the UDP4_SERVICE_DATA.\r
414 @param ImageHandle The image handle of this udp4 driver.\r
415 @param ControllerHandle The controller handle this udp4 driver binds on.\r
416\r
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
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
442 This function intializes the new created udp instance.\r
443\r
444 @param Udp4Service Pointer to the UDP4_SERVICE_DATA.\r
445 @param Instance Pointer to the un-initialized UDP4_INSTANCE_DATA.\r
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
469 @param InstanceList Pointer to the head of the list linking the udp\r
470 instances.\r
471 @param ConfigData Pointer to the ConfigData of the instance to be\r
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
564Udp4TokenExist (\r
565 IN NET_MAP *Map,\r
566 IN NET_MAP_ITEM *Item,\r
567 IN VOID *Context\r
568 );\r
569\r
ce904bae 570/**\r
571 This function calculates the checksum for the Packet, utilizing the pre-calculated\r
572 pseudo HeadSum to reduce some overhead.\r
573\r
3e8c18da 574 @param[in] Packet Pointer to the NET_BUF contains the udp datagram.\r
575 @param[in] HeadSum Checksum of the pseudo header execpt the length\r
ce904bae 576 field.\r
577\r
3e8c18da 578 @retval The 16-bit checksum of this udp datagram.\r
ce904bae 579\r
580**/\r
83cbd279 581UINT16\r
582Udp4Checksum (\r
583 IN NET_BUF *Packet,\r
584 IN UINT16 HeadSum\r
585 );\r
586\r
ce904bae 587/**\r
588 This function removes the specified Token from the TokenMap.\r
589\r
3e8c18da 590 @param TokenMap Pointer to the NET_MAP containing the tokens.\r
591 @param Token Pointer to the Token to be removed.\r
ce904bae 592\r
593 @retval EFI_SUCCESS The specified Token is removed from the TokenMap.\r
594 @retval EFI_NOT_FOUND The specified Token is not found in the TokenMap.\r
595\r
596**/\r
83cbd279 597EFI_STATUS\r
598Udp4RemoveToken (\r
ce904bae 599 IN OUT NET_MAP *TokenMap,\r
600 IN EFI_UDP4_COMPLETION_TOKEN *Token\r
83cbd279 601 );\r
602\r
ce904bae 603/**\r
604 This function removes the multicast group specified by Arg from the Map.\r
605\r
606 @param Map Pointer to the NET_MAP.\r
607 @param Item Pointer to the NET_MAP_ITEM.\r
608 @param Arg Pointer to the Arg, it's the pointer to a\r
609 multicast IPv4 Address.\r
610\r
611 @retval EFI_SUCCESS The multicast address is removed.\r
612 @retval EFI_ABORTED The specified multicast address is removed and the\r
613 Arg is not NULL.\r
614\r
615**/\r
83cbd279 616EFI_STATUS\r
617Udp4LeaveGroup (\r
ce904bae 618 IN OUT NET_MAP *Map,\r
619 IN NET_MAP_ITEM *Item,\r
620 IN VOID *Arg OPTIONAL\r
83cbd279 621 );\r
622\r
ce904bae 623/**\r
624 This function removes all the Wrap datas in the RcvdDgramQue.\r
625\r
3e8c18da 626 @param[in] Instance Pointer to the udp instance context data.\r
ce904bae 627\r
628**/\r
83cbd279 629VOID\r
36ee91ca 630Udp4FlushRcvdDgram (\r
631 IN UDP4_INSTANCE_DATA *Instance\r
83cbd279 632 );\r
633\r
ce904bae 634/**\r
635 Cancel Udp4 tokens from the Udp4 instance.\r
636\r
3e8c18da 637 @param[in] Instance Pointer to the udp instance context data.\r
638 @param[in] Token Pointer to the token to be canceled, if NULL, all\r
ce904bae 639 tokens in this instance will be cancelled.\r
640\r
641 @retval EFI_SUCCESS The Token is cancelled.\r
642 @retval EFI_NOT_FOUND The Token is not found.\r
643\r
644**/\r
83cbd279 645EFI_STATUS\r
646Udp4InstanceCancelToken (\r
647 IN UDP4_INSTANCE_DATA *Instance,\r
648 IN EFI_UDP4_COMPLETION_TOKEN *Token OPTIONAL\r
649 );\r
650\r
ce904bae 651/**\r
652 This function delivers the received datagrams for the specified instance.\r
653\r
3e8c18da 654 @param[in] Instance Pointer to the instance context data.\r
ce904bae 655\r
656**/\r
83cbd279 657VOID\r
658Udp4InstanceDeliverDgram (\r
659 IN UDP4_INSTANCE_DATA *Instance\r
660 );\r
661\r
ce904bae 662/**\r
663 This function reports the received ICMP error.\r
664\r
3e8c18da 665 @param[in] Instance Pointer to the udp instance context data.\r
ce904bae 666\r
667**/\r
83cbd279 668VOID\r
669Udp4ReportIcmpError (\r
670 IN UDP4_INSTANCE_DATA *Instance\r
671 );\r
672\r
ce904bae 673/**\r
674 This function is a dummy ext-free function for the NET_BUF created for the output\r
675 udp datagram.\r
676\r
3e8c18da 677 @param[in] Context Pointer to the context data.\r
ce904bae 678\r
679**/\r
83cbd279 680VOID\r
681Udp4NetVectorExtFree (\r
682 VOID *Context\r
683 );\r
684\r
ce904bae 685/**\r
686 Set the Udp4 variable data.\r
687\r
688 @param Udp4Service Udp4 service data.\r
689\r
690 @retval EFI_OUT_OF_RESOURCES There are not enough resources to set the\r
691 variable.\r
692 @retval EFI_SUCCESS Set variable successfully.\r
693 @retval other Set variable failed.\r
694\r
695**/\r
83cbd279 696EFI_STATUS\r
697Udp4SetVariableData (\r
698 IN UDP4_SERVICE_DATA *Udp4Service\r
699 );\r
700\r
ce904bae 701/**\r
702 Clear the variable and free the resource.\r
703\r
3e8c18da 704 @param[[in] Udp4Service Udp4 service data.\r
ce904bae 705\r
706**/\r
83cbd279 707VOID\r
708Udp4ClearVariableData (\r
709 IN UDP4_SERVICE_DATA *Udp4Service\r
710 );\r
711\r
712#endif\r
713\r