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