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