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