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