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