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
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.
23 #include <Protocol/Ip4.h>
25 EFI_UDP4_PROTOCOL mUdp4Protocol
= {
38 This function copies the current operational settings of this EFI UDPv4 Protocol
39 instance into user-supplied buffers. This function is used optionally to retrieve
40 the operational mode data of underlying networks or drivers.
42 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
43 @param Udp4ConfigData Pointer to the buffer to receive the current
45 @param Ip4ModeData Pointer to the EFI IPv4 Protocol mode data
47 @param MnpConfigData Pointer to the managed network configuration data
49 @param SnpModeData Pointer to the simple network mode data structure.
51 @retval EFI_SUCCESS The mode data was read.
52 @retval EFI_NOT_STARTED When Udp4ConfigData is queried, no configuration
53 data is available because this instance has not
55 @retval EFI_INVALID_PARAMETER This is NULL.
61 IN EFI_UDP4_PROTOCOL
*This
,
62 OUT EFI_UDP4_CONFIG_DATA
*Udp4ConfigData OPTIONAL
,
63 OUT EFI_IP4_MODE_DATA
*Ip4ModeData OPTIONAL
,
64 OUT EFI_MANAGED_NETWORK_CONFIG_DATA
*MnpConfigData OPTIONAL
,
65 OUT EFI_SIMPLE_NETWORK_MODE
*SnpModeData OPTIONAL
68 UDP4_INSTANCE_DATA
*Instance
;
74 return EFI_INVALID_PARAMETER
;
77 Instance
= UDP4_INSTANCE_DATA_FROM_THIS (This
);
79 if (!Instance
->Configured
&& (Udp4ConfigData
!= NULL
)) {
80 return EFI_NOT_STARTED
;
83 OldTpl
= NET_RAISE_TPL (NET_TPL_LOCK
);
85 if (Udp4ConfigData
!= NULL
) {
87 // Set the Udp4ConfigData.
89 CopyMem (Udp4ConfigData
, &Instance
->ConfigData
, sizeof (*Udp4ConfigData
));
92 Ip
= Instance
->IpInfo
->Ip
;
95 // Get the underlying Ip4ModeData, MnpConfigData and SnpModeData.
97 Status
= Ip
->GetModeData (Ip
, Ip4ModeData
, MnpConfigData
, SnpModeData
);
99 NET_RESTORE_TPL (OldTpl
);
106 This function is used to do the following:
107 Initialize and start this instance of the EFI UDPv4 Protocol.
108 Change the filtering rules and operational parameters.
109 Reset this instance of the EFI UDPv4 Protocol.
111 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
112 @param UdpConfigData Pointer to the buffer to receive the current mode
115 @retval EFI_SUCCESS The configuration settings were set, changed, or
117 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP,
118 BOOTP, RARP, etc.) is not finished yet.
119 @retval EFI_INVALID_PARAMETER One or more following conditions are TRUE: This is
120 NULL. UdpConfigData.StationAddress is not a valid
121 unicast IPv4 address. UdpConfigData.SubnetMask is
122 not a valid IPv4 address mask.
123 UdpConfigData.RemoteAddress is not a valid unicast
124 IPv4 address if it is not zero.
125 @retval EFI_ALREADY_STARTED The EFI UDPv4 Protocol instance is already
126 started/configured and must be stopped/reset
127 before it can be reconfigured. Only TypeOfService,
128 TimeToLive, DoNotFragment, ReceiveTimeout, and
129 TransmitTimeout can be reconfigured without
130 stopping the current instance of the EFI UDPv4
132 @retval EFI_ACCESS_DENIED UdpConfigData.AllowDuplicatePort is FALSE and
133 UdpConfigData.StationPort is already used by other
135 @retval EFI_OUT_OF_RESOURCES The EFI UDPv4 Protocol driver cannot allocate
136 memory for this EFI UDPv4 Protocol instance.
137 @retval EFI_DEVICE_ERROR An unexpected network or system error occurred and
138 this instance was not opened.
144 IN EFI_UDP4_PROTOCOL
*This
,
145 IN EFI_UDP4_CONFIG_DATA
*UdpConfigData OPTIONAL
149 UDP4_INSTANCE_DATA
*Instance
;
150 UDP4_SERVICE_DATA
*Udp4Service
;
152 IP4_ADDR StationAddress
;
154 IP4_ADDR RemoteAddress
;
155 EFI_IP4_CONFIG_DATA Ip4ConfigData
;
160 return EFI_INVALID_PARAMETER
;
163 Instance
= UDP4_INSTANCE_DATA_FROM_THIS (This
);
165 if (!Instance
->Configured
&& (UdpConfigData
== NULL
)) {
169 Udp4Service
= Instance
->Udp4Service
;
170 Status
= EFI_SUCCESS
;
172 OldTpl
= NET_RAISE_TPL (NET_TPL_LOCK
);
174 if (UdpConfigData
!= NULL
) {
176 NetCopyMem (&StationAddress
, &UdpConfigData
->StationAddress
, sizeof (IP4_ADDR
));
177 NetCopyMem (&SubnetMask
, &UdpConfigData
->SubnetMask
, sizeof (IP4_ADDR
));
178 NetCopyMem (&RemoteAddress
, &UdpConfigData
->RemoteAddress
, sizeof (IP4_ADDR
));
180 StationAddress
= NTOHL (StationAddress
);
181 SubnetMask
= NTOHL (SubnetMask
);
182 RemoteAddress
= NTOHL (RemoteAddress
);
185 if (!UdpConfigData
->UseDefaultAddress
&&
186 (!IP4_IS_VALID_NETMASK (SubnetMask
) ||
187 !((StationAddress
== 0) || Ip4IsUnicast (StationAddress
, SubnetMask
)) ||
188 !((RemoteAddress
== 0) || Ip4IsUnicast (RemoteAddress
, 0)))) {
190 // Don't use default address, and subnet mask is invalid or StationAddress is not
191 // a valid unicast IPv4 address or RemoteAddress is not a valid unicast IPv4 address
194 Status
= EFI_INVALID_PARAMETER
;
198 if (Instance
->Configured
) {
200 // The instance is already configured, try to do the re-configuration.
202 if (!Udp4IsReconfigurable (&Instance
->ConfigData
, UdpConfigData
)) {
204 // If the new configuration data wants to change some unreconfigurable
205 // settings, return EFI_ALREADY_STARTED.
207 Status
= EFI_ALREADY_STARTED
;
212 // Save the reconfigurable parameters.
214 Instance
->ConfigData
.TypeOfService
= UdpConfigData
->TypeOfService
;
215 Instance
->ConfigData
.TimeToLive
= UdpConfigData
->TimeToLive
;
216 Instance
->ConfigData
.DoNotFragment
= UdpConfigData
->DoNotFragment
;
217 Instance
->ConfigData
.ReceiveTimeout
= UdpConfigData
->ReceiveTimeout
;
218 Instance
->ConfigData
.TransmitTimeout
= UdpConfigData
->TransmitTimeout
;
221 // Construct the Ip configuration data from the UdpConfigData.
223 Udp4BuildIp4ConfigData (UdpConfigData
, &Ip4ConfigData
);
226 // Configure the Ip instance wrapped in the IpInfo.
228 Status
= IpIoConfigIp (Instance
->IpInfo
, &Ip4ConfigData
);
229 if (EFI_ERROR (Status
)) {
230 if (Status
== EFI_NO_MAPPING
) {
231 Instance
->IsNoMapping
= TRUE
;
237 Instance
->IsNoMapping
= FALSE
;
240 // Save the configuration data.
242 CopyMem (&Instance
->ConfigData
, UdpConfigData
, sizeof (Instance
->ConfigData
));
243 Instance
->ConfigData
.StationAddress
= Ip4ConfigData
.StationAddress
;
244 Instance
->ConfigData
.SubnetMask
= Ip4ConfigData
.SubnetMask
;
247 // Try to allocate the required port resource.
249 Status
= Udp4Bind (&Udp4Service
->ChildrenList
, &Instance
->ConfigData
);
250 if (EFI_ERROR (Status
)) {
252 // Reset the ip instance if bind fails.
254 IpIoConfigIp (Instance
->IpInfo
, NULL
);
259 // Pre calculate the checksum for the pseudo head, ignore the UDP length first.
261 NetCopyMem (&LocalAddr
, &Instance
->ConfigData
.StationAddress
, sizeof (IP4_ADDR
));
262 NetCopyMem (&RemoteAddr
, &Instance
->ConfigData
.RemoteAddress
, sizeof (IP4_ADDR
));
263 Instance
->HeadSum
= NetPseudoHeadChecksum (
270 Instance
->Configured
= TRUE
;
274 // UdpConfigData is NULL, reset the instance.
276 Instance
->Configured
= FALSE
;
277 Instance
->IsNoMapping
= FALSE
;
280 // Reset the Ip instance wrapped in the IpInfo.
282 IpIoConfigIp (Instance
->IpInfo
, NULL
);
285 // Cancel all the user tokens.
287 Instance
->Udp4Proto
.Cancel (&Instance
->Udp4Proto
, NULL
);
290 // Remove the buffered RxData for this instance.
292 Udp4FlushRcvdDgram (Instance
);
294 ////bugbug ASSERT (NetListIsEmpty (&Instance->DeliveredDgramQue));
297 Udp4SetVariableData (Instance
->Udp4Service
);
301 NET_RESTORE_TPL (OldTpl
);
308 This function is used to enable and disable the multicast group filtering.
310 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
311 @param JoinFlag Set to TRUE to join a multicast group. Set to
312 FALSE to leave one or all multicast groups.
313 @param MulticastAddress Pointer to multicast group address to join or
316 @retval EFI_SUCCESS The operation completed successfully.
317 @retval EFI_NOT_STARTED The EFI UDPv4 Protocol instance has not been
319 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP,
320 BOOTP, RARP, etc.) is not finished yet.
321 @retval EFI_OUT_OF_RESOURCES Could not allocate resources to join the group.
322 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
323 This is NULL. JoinFlag is TRUE and
324 MulticastAddress is NULL. JoinFlag is TRUE and
325 *MulticastAddress is not a valid multicast
327 @retval EFI_ALREADY_STARTED The group address is already in the group table
328 (when JoinFlag is TRUE).
329 @retval EFI_NOT_FOUND The group address is not in the group table (when
331 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
337 IN EFI_UDP4_PROTOCOL
*This
,
339 IN EFI_IPv4_ADDRESS
*MulticastAddress OPTIONAL
343 UDP4_INSTANCE_DATA
*Instance
;
344 EFI_IP4_PROTOCOL
*Ip
;
348 if ((This
== NULL
) || (JoinFlag
&& (MulticastAddress
== NULL
))) {
349 return EFI_INVALID_PARAMETER
;
354 NetCopyMem (&McastIp
, MulticastAddress
, sizeof (IP4_ADDR
));
356 if (!IP4_IS_MULTICAST (NTOHL (McastIp
))) {
357 return EFI_INVALID_PARAMETER
;
361 Instance
= UDP4_INSTANCE_DATA_FROM_THIS (This
);
363 if (Instance
->IsNoMapping
) {
364 return EFI_NO_MAPPING
;
367 if (!Instance
->Configured
) {
368 return EFI_NOT_STARTED
;
371 Ip
= Instance
->IpInfo
->Ip
;
373 OldTpl
= NET_RAISE_TPL (NET_TPL_LOCK
);
376 // Invoke the Ip instance the Udp4 instance consumes to do the group operation.
378 Status
= Ip
->Groups (Ip
, JoinFlag
, MulticastAddress
);
380 if (EFI_ERROR (Status
)) {
385 // Keep a local copy of the configured multicast IPs because IpIo receives
386 // datagrams from the 0 station address IP instance and then UDP delivers to
387 // the matched instance. This copy of multicast IPs is used to avoid receive
388 // the mutlicast datagrams destinated to multicast IPs the other instances configured.
392 NetMapInsertTail (&Instance
->McastIps
, (VOID
*) (UINTN
) McastIp
, NULL
);
395 NetMapIterate (&Instance
->McastIps
, Udp4LeaveGroup
, MulticastAddress
);
400 NET_RESTORE_TPL (OldTpl
);
407 This function adds a route to or deletes a route from the routing table.
409 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
410 @param DeleteRoute Set to TRUE to delete this route from the routing
411 table. Set to FALSE to add this route to the
413 @param SubnetAddress The destination network address that needs to be
415 @param SubnetMask The subnet mask of SubnetAddress.
416 @param GatewayAddress The gateway IP address for this route.
418 @retval EFI_SUCCESS The operation completed successfully.
419 @retval EFI_NOT_STARTED The EFI UDPv4 Protocol instance has not been
421 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP,
422 BOOTP, RARP, etc.) is not finished yet.
423 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
424 This is NULL. SubnetAddress is NULL. SubnetMask is
425 NULL. GatewayAddress is NULL. SubnetAddress is not
426 a valid subnet address. SubnetMask is not a valid
427 subnet mask. GatewayAddress is not a valid unicast
429 @retval EFI_OUT_OF_RESOURCES Could not add the entry to the routing table.
430 @retval EFI_NOT_FOUND This route is not in the routing table.
431 @retval EFI_ACCESS_DENIED The route is already defined in the routing table.
437 IN EFI_UDP4_PROTOCOL
*This
,
438 IN BOOLEAN DeleteRoute
,
439 IN EFI_IPv4_ADDRESS
*SubnetAddress
,
440 IN EFI_IPv4_ADDRESS
*SubnetMask
,
441 IN EFI_IPv4_ADDRESS
*GatewayAddress
444 UDP4_INSTANCE_DATA
*Instance
;
445 EFI_IP4_PROTOCOL
*Ip
;
448 return EFI_INVALID_PARAMETER
;
451 Instance
= UDP4_INSTANCE_DATA_FROM_THIS (This
);
453 if (Instance
->IsNoMapping
) {
454 return EFI_NO_MAPPING
;
457 if (!Instance
->Configured
) {
458 return EFI_NOT_STARTED
;
461 Ip
= Instance
->IpInfo
->Ip
;
464 // Invoke the Ip instance the Udp4 instance consumes to do the actual operation.
466 return Ip
->Routes (Ip
, DeleteRoute
, SubnetAddress
, SubnetMask
, GatewayAddress
);
471 This function places a sending request to this instance of the EFI UDPv4 Protocol,
472 alongside the transmit data that was filled by the user.
474 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
475 @param Token Pointer to the completion token that will be
476 placed into the transmit queue.
478 @retval EFI_SUCCESS The data has been queued for transmission.
479 @retval EFI_NOT_STARTED This EFI UDPv4 Protocol instance has not been
481 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP,
482 BOOTP, RARP, etc.) is not finished yet.
483 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE: This is
484 NULL. Token is NULL. Token.Event is NULL.
485 Token.Packet.TxData is NULL.
486 Token.Packet.TxData.FragmentCount is zero.
487 Token.Packet.TxData.DataLength is not equal to the
488 sum of fragment lengths. One or more of the
489 Token.Packet.TxData.FragmentTable[].
490 FragmentLength fields is zero. One or more of the
491 Token.Packet.TxData.FragmentTable[].
492 FragmentBuffer fields is NULL.
493 Token.Packet.TxData. GatewayAddress is not a
494 unicast IPv4 address if it is not NULL. One or
495 more IPv4 addresses in Token.Packet.TxData.
496 UdpSessionData are not valid unicast IPv4
497 addresses if the UdpSessionData is not NULL.
498 @retval EFI_ACCESS_DENIED The transmit completion token with the same
499 Token.Event is already in the transmit queue.
500 @retval EFI_NOT_READY The completion token could not be queued because
501 the transmit queue is full.
502 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data.
503 @retval EFI_NOT_FOUND There is no route to the destination network or
505 @retval EFI_BAD_BUFFER_SIZE The data length is greater than the maximum UDP
506 packet size. Or the length of the IP header + UDP
507 header + data length is greater than MTU if
508 DoNotFragment is TRUE.
514 IN EFI_UDP4_PROTOCOL
*This
,
515 IN EFI_UDP4_COMPLETION_TOKEN
*Token
519 UDP4_INSTANCE_DATA
*Instance
;
522 EFI_UDP4_HEADER
*Udp4Header
;
523 EFI_UDP4_CONFIG_DATA
*ConfigData
;
525 IP4_ADDR Destination
;
526 EFI_UDP4_TRANSMIT_DATA
*TxData
;
527 EFI_UDP4_SESSION_DATA
*UdpSessionData
;
528 UDP4_SERVICE_DATA
*Udp4Service
;
529 IP_IO_OVERRIDE Override
;
532 if ((This
== NULL
) || (Token
== NULL
)) {
533 return EFI_INVALID_PARAMETER
;
536 Instance
= UDP4_INSTANCE_DATA_FROM_THIS (This
);
538 if (Instance
->IsNoMapping
) {
539 return EFI_NO_MAPPING
;
542 if (!Instance
->Configured
) {
543 return EFI_NOT_STARTED
;
546 OldTpl
= NET_RAISE_TPL (NET_TPL_LOCK
);
549 // Validate the Token, if the token is invalid return the error code.
551 Status
= Udp4ValidateTxToken (Instance
, Token
);
552 if (EFI_ERROR (Status
)) {
556 if (EFI_ERROR (NetMapIterate (&Instance
->TxTokens
, Udp4TokenExist
, Token
)) ||
557 EFI_ERROR (NetMapIterate (&Instance
->RxTokens
, Udp4TokenExist
, Token
))) {
559 // Try to find a duplicate token in the two token maps, if found, return
560 // EFI_ACCESS_DENIED.
562 Status
= EFI_ACCESS_DENIED
;
566 TxData
= Token
->Packet
.TxData
;
569 // Create a net buffer to hold the user buffer and the udp header.
571 Packet
= NetbufFromExt (
572 (NET_FRAGMENT
*)TxData
->FragmentTable
,
573 TxData
->FragmentCount
,
576 Udp4NetVectorExtFree
,
579 if (Packet
== NULL
) {
580 Status
= EFI_OUT_OF_RESOURCES
;
585 // Store the IpIo in ProtoData.
587 Udp4Service
= Instance
->Udp4Service
;
588 *((UINTN
*) &Packet
->ProtoData
[0]) = (UINTN
) (Udp4Service
->IpIo
);
590 Udp4Header
= (EFI_UDP4_HEADER
*) NetbufAllocSpace (Packet
, UDP4_HEADER_SIZE
, TRUE
);
591 ConfigData
= &Instance
->ConfigData
;
594 // Fill the udp header.
596 Udp4Header
->SrcPort
= HTONS (ConfigData
->StationPort
);
597 Udp4Header
->DstPort
= HTONS (ConfigData
->RemotePort
);
598 Udp4Header
->Length
= HTONS (Packet
->TotalSize
);
599 Udp4Header
->Checksum
= 0;
601 UdpSessionData
= TxData
->UdpSessionData
;
602 Override
.SourceAddress
= ConfigData
->StationAddress
;
604 if (UdpSessionData
!= NULL
) {
606 // Set the SourceAddress, SrcPort and Destination according to the specified
609 if (!EFI_IP4_EQUAL (&UdpSessionData
->SourceAddress
, &mZeroIp4Addr
)) {
610 NetCopyMem (&Override
.SourceAddress
, &UdpSessionData
->SourceAddress
, sizeof (EFI_IPv4_ADDRESS
));
613 if (UdpSessionData
->SourcePort
!= 0) {
614 Udp4Header
->SrcPort
= HTONS (UdpSessionData
->SourcePort
);
617 if (UdpSessionData
->DestinationPort
!= 0) {
618 Udp4Header
->DstPort
= HTONS (UdpSessionData
->DestinationPort
);
621 NetCopyMem (&Source
, &Override
.SourceAddress
, sizeof (IP4_ADDR
));
622 NetCopyMem (&Destination
, &UdpSessionData
->DestinationAddress
, sizeof (IP4_ADDR
));
625 // calculate the pseudo head checksum using the overridden parameters.
627 HeadSum
= NetPseudoHeadChecksum (
635 // UdpSessionData is NULL, use the address and port information previously configured.
637 NetCopyMem (&Destination
, &ConfigData
->RemoteAddress
, sizeof (IP4_ADDR
));
639 HeadSum
= Instance
->HeadSum
;
643 // calculate the checksum.
645 Udp4Header
->Checksum
= Udp4Checksum (Packet
, HeadSum
);
646 if (Udp4Header
->Checksum
== 0) {
648 // If the calculated checksum is 0, fill the Checksum field with all ones.
650 Udp4Header
->Checksum
= 0xffff;
654 // Fill the IpIo Override data.
656 if (TxData
->GatewayAddress
!= NULL
) {
657 NetCopyMem (&Override
.GatewayAddress
, TxData
->GatewayAddress
, sizeof (EFI_IPv4_ADDRESS
));
659 NetZeroMem (&Override
.GatewayAddress
, sizeof (EFI_IPv4_ADDRESS
));
662 Override
.Protocol
= EFI_IP_PROTO_UDP
;
663 Override
.TypeOfService
= ConfigData
->TypeOfService
;
664 Override
.TimeToLive
= ConfigData
->TimeToLive
;
665 Override
.DoNotFragment
= ConfigData
->DoNotFragment
;
668 // Save the token into the TxToken map.
670 Status
= NetMapInsertTail (&Instance
->TxTokens
, Token
, Packet
);
671 if (EFI_ERROR (Status
)) {
676 // Send out this datagram through IpIo.
687 if (EFI_ERROR (Status
)) {
689 // Remove this token from the TxTokens.
691 Udp4RemoveToken (&Instance
->TxTokens
, Token
);
700 NET_RESTORE_TPL (OldTpl
);
707 This function places a completion token into the receive packet queue. This function
708 is always asynchronous.
710 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
711 @param Token Pointer to a token that is associated with the
712 receive data descriptor.
714 @retval EFI_SUCCESS The receive completion token is cached.
715 @retval EFI_NOT_STARTED This EFI UDPv4 Protocol instance has not been
717 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP,
718 BOOTP, RARP, etc.) is not finished yet.
719 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
720 This is NULL. Token is NULL. Token.Event is NULL.
721 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued
722 due to a lack of system resources (usually
724 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
725 The EFI UDPv4 Protocol instance has been reset to
727 @retval EFI_ACCESS_DENIED A receive completion token with the same
728 Token.Event is already in the receive queue.
729 @retval EFI_NOT_READY The receive request could not be queued because
730 the receive queue is full.
736 IN EFI_UDP4_PROTOCOL
*This
,
737 IN EFI_UDP4_COMPLETION_TOKEN
*Token
741 UDP4_INSTANCE_DATA
*Instance
;
744 if ((This
== NULL
) || (Token
== NULL
) || (Token
->Event
== NULL
)) {
745 return EFI_INVALID_PARAMETER
;
748 Instance
= UDP4_INSTANCE_DATA_FROM_THIS (This
);
750 if (Instance
->IsNoMapping
) {
751 return EFI_NO_MAPPING
;
754 if (!Instance
->Configured
) {
755 return EFI_NOT_STARTED
;
758 OldTpl
= NET_RAISE_TPL (NET_TPL_LOCK
);
760 if (EFI_ERROR (NetMapIterate (&Instance
->RxTokens
, Udp4TokenExist
, Token
))||
761 EFI_ERROR (NetMapIterate (&Instance
->TxTokens
, Udp4TokenExist
, Token
))) {
763 // Return EFI_ACCESS_DENIED if the specified token is already in the TxTokens or
766 Status
= EFI_ACCESS_DENIED
;
770 Token
->Packet
.RxData
= NULL
;
773 // Save the token into the RxTokens map.
775 Status
= NetMapInsertTail (&Instance
->RxTokens
, Token
, NULL
);
776 if (EFI_ERROR (Status
)) {
777 Status
= EFI_NOT_READY
;
782 // If there is an icmp error, report it.
784 Udp4ReportIcmpError (Instance
);
787 // Try to delivered the received datagrams.
789 Udp4InstanceDeliverDgram (Instance
);
792 // Dispatch the DPC queued by the NotifyFunction of Token->Event.
794 NetLibDispatchDpc ();
798 NET_RESTORE_TPL (OldTpl
);
805 This function is used to abort a pending transmit or receive request.
807 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
808 @param Token Pointer to a token that has been issued by
809 EFI_UDP4_PROTOCOL.Transmit() or
810 EFI_UDP4_PROTOCOL.Receive().
812 @retval EFI_SUCCESS The asynchronous I/O request is aborted and
813 Token.Event is signaled. When Token is NULL, all
814 pending requests are aborted and their events are
816 @retval EFI_INVALID_PARAMETER This is NULL.
817 @retval EFI_NOT_STARTED This instance has not been started.
818 @retval EFI_NO_MAPPING When using the default address, configuration
819 (DHCP, BOOTP, RARP, etc.) is not finished yet.
820 @retval EFI_NOT_FOUND When Token is not NULL, the asynchronous I/O
821 request is not found in the transmit or receive
822 queue. It is either completed or not issued by
823 Transmit() or Receive().
829 IN EFI_UDP4_PROTOCOL
*This
,
830 IN EFI_UDP4_COMPLETION_TOKEN
*Token OPTIONAL
834 UDP4_INSTANCE_DATA
*Instance
;
838 return EFI_INVALID_PARAMETER
;
841 Instance
= UDP4_INSTANCE_DATA_FROM_THIS (This
);
843 if (Instance
->IsNoMapping
) {
844 return EFI_NO_MAPPING
;
847 if (!Instance
->Configured
) {
848 return EFI_NOT_STARTED
;
851 OldTpl
= NET_RAISE_TPL (NET_TPL_LOCK
);
854 // Cancle the tokens specified by Token for this instance.
856 Status
= Udp4InstanceCancelToken (Instance
, Token
);
859 // Dispatch the DPC queued by the NotifyFunction of the canceled token's events.
861 NetLibDispatchDpc ();
863 NET_RESTORE_TPL (OldTpl
);
870 This function can be used by network drivers and applications to increase the rate that
871 data packets are moved between the communications device and the transmit/receive queues.
873 This - Pointer to the EFI_UDP4_PROTOCOL instance.
875 @retval EFI_SUCCESS Incoming or outgoing data was processed.
876 @retval EFI_INVALID_PARAMETER This is NULL.
877 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
878 @retval EFI_TIMEOUT Data was dropped out of the transmit and/or
885 IN EFI_UDP4_PROTOCOL
*This
888 UDP4_INSTANCE_DATA
*Instance
;
889 EFI_IP4_PROTOCOL
*Ip
;
892 return EFI_INVALID_PARAMETER
;
895 Instance
= UDP4_INSTANCE_DATA_FROM_THIS (This
);
896 Ip
= Instance
->IpInfo
->Ip
;
899 // Invode the Ip instance consumed by the udp instance to do the poll operation.
901 return Ip
->Poll (Ip
);