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