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 Udp4InstanceCancelToken (Instance
, NULL
);
290 // Remove the buffered RxData for this instance.
292 Udp4FlushRxData (&Instance
->RcvdDgramQue
);
295 Udp4SetVariableData (Instance
->Udp4Service
);
299 NET_RESTORE_TPL (OldTpl
);
306 This function is used to enable and disable the multicast group filtering.
308 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
309 @param JoinFlag Set to TRUE to join a multicast group. Set to
310 FALSE to leave one or all multicast groups.
311 @param MulticastAddress Pointer to multicast group address to join or
314 @retval EFI_SUCCESS The operation completed successfully.
315 @retval EFI_NOT_STARTED The EFI UDPv4 Protocol instance has not been
317 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP,
318 BOOTP, RARP, etc.) is not finished yet.
319 @retval EFI_OUT_OF_RESOURCES Could not allocate resources to join the group.
320 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
321 This is NULL. JoinFlag is TRUE and
322 MulticastAddress is NULL. JoinFlag is TRUE and
323 *MulticastAddress is not a valid multicast
325 @retval EFI_ALREADY_STARTED The group address is already in the group table
326 (when JoinFlag is TRUE).
327 @retval EFI_NOT_FOUND The group address is not in the group table (when
329 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
335 IN EFI_UDP4_PROTOCOL
*This
,
337 IN EFI_IPv4_ADDRESS
*MulticastAddress OPTIONAL
341 UDP4_INSTANCE_DATA
*Instance
;
342 EFI_IP4_PROTOCOL
*Ip
;
346 if ((This
== NULL
) || (JoinFlag
&& (MulticastAddress
== NULL
))) {
347 return EFI_INVALID_PARAMETER
;
352 NetCopyMem (&McastIp
, MulticastAddress
, sizeof (IP4_ADDR
));
354 if (!IP4_IS_MULTICAST (NTOHL (McastIp
))) {
355 return EFI_INVALID_PARAMETER
;
359 Instance
= UDP4_INSTANCE_DATA_FROM_THIS (This
);
361 if (Instance
->IsNoMapping
) {
362 return EFI_NO_MAPPING
;
365 if (!Instance
->Configured
) {
366 return EFI_NOT_STARTED
;
369 Ip
= Instance
->IpInfo
->Ip
;
371 OldTpl
= NET_RAISE_TPL (NET_TPL_LOCK
);
374 // Invoke the Ip instance the Udp4 instance consumes to do the group operation.
376 Status
= Ip
->Groups (Ip
, JoinFlag
, MulticastAddress
);
378 if (EFI_ERROR (Status
)) {
383 // Keep a local copy of the configured multicast IPs because IpIo receives
384 // datagrams from the 0 station address IP instance and then UDP delivers to
385 // the matched instance. This copy of multicast IPs is used to avoid receive
386 // the mutlicast datagrams destinated to multicast IPs the other instances configured.
390 NetMapInsertTail (&Instance
->McastIps
, (VOID
*) (UINTN
) McastIp
, NULL
);
393 NetMapIterate (&Instance
->McastIps
, Udp4LeaveGroup
, MulticastAddress
);
398 NET_RESTORE_TPL (OldTpl
);
405 This function adds a route to or deletes a route from the routing table.
407 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
408 @param DeleteRoute Set to TRUE to delete this route from the routing
409 table. Set to FALSE to add this route to the
411 @param SubnetAddress The destination network address that needs to be
413 @param SubnetMask The subnet mask of SubnetAddress.
414 @param GatewayAddress The gateway IP address for this route.
416 @retval EFI_SUCCESS The operation completed successfully.
417 @retval EFI_NOT_STARTED The EFI UDPv4 Protocol instance has not been
419 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP,
420 BOOTP, RARP, etc.) is not finished yet.
421 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
422 This is NULL. SubnetAddress is NULL. SubnetMask is
423 NULL. GatewayAddress is NULL. SubnetAddress is not
424 a valid subnet address. SubnetMask is not a valid
425 subnet mask. GatewayAddress is not a valid unicast
427 @retval EFI_OUT_OF_RESOURCES Could not add the entry to the routing table.
428 @retval EFI_NOT_FOUND This route is not in the routing table.
429 @retval EFI_ACCESS_DENIED The route is already defined in the routing table.
435 IN EFI_UDP4_PROTOCOL
*This
,
436 IN BOOLEAN DeleteRoute
,
437 IN EFI_IPv4_ADDRESS
*SubnetAddress
,
438 IN EFI_IPv4_ADDRESS
*SubnetMask
,
439 IN EFI_IPv4_ADDRESS
*GatewayAddress
442 UDP4_INSTANCE_DATA
*Instance
;
443 EFI_IP4_PROTOCOL
*Ip
;
446 return EFI_INVALID_PARAMETER
;
449 Instance
= UDP4_INSTANCE_DATA_FROM_THIS (This
);
451 if (Instance
->IsNoMapping
) {
452 return EFI_NO_MAPPING
;
455 if (!Instance
->Configured
) {
456 return EFI_NOT_STARTED
;
459 Ip
= Instance
->IpInfo
->Ip
;
462 // Invoke the Ip instance the Udp4 instance consumes to do the actual operation.
464 return Ip
->Routes (Ip
, DeleteRoute
, SubnetAddress
, SubnetMask
, GatewayAddress
);
469 This function places a sending request to this instance of the EFI UDPv4 Protocol,
470 alongside the transmit data that was filled by the user.
472 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
473 @param Token Pointer to the completion token that will be
474 placed into the transmit queue.
476 @retval EFI_SUCCESS The data has been queued for transmission.
477 @retval EFI_NOT_STARTED This EFI UDPv4 Protocol instance has not been
479 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP,
480 BOOTP, RARP, etc.) is not finished yet.
481 @retval EFI_INVALID_PARAMETER One or more of the following are TRUE: This is
482 NULL. Token is NULL. Token.Event is NULL.
483 Token.Packet.TxData is NULL.
484 Token.Packet.TxData.FragmentCount is zero.
485 Token.Packet.TxData.DataLength is not equal to the
486 sum of fragment lengths. One or more of the
487 Token.Packet.TxData.FragmentTable[].
488 FragmentLength fields is zero. One or more of the
489 Token.Packet.TxData.FragmentTable[].
490 FragmentBuffer fields is NULL.
491 Token.Packet.TxData. GatewayAddress is not a
492 unicast IPv4 address if it is not NULL. One or
493 more IPv4 addresses in Token.Packet.TxData.
494 UdpSessionData are not valid unicast IPv4
495 addresses if the UdpSessionData is not NULL.
496 @retval EFI_ACCESS_DENIED The transmit completion token with the same
497 Token.Event is already in the transmit queue.
498 @retval EFI_NOT_READY The completion token could not be queued because
499 the transmit queue is full.
500 @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data.
501 @retval EFI_NOT_FOUND There is no route to the destination network or
503 @retval EFI_BAD_BUFFER_SIZE The data length is greater than the maximum UDP
504 packet size. Or the length of the IP header + UDP
505 header + data length is greater than MTU if
506 DoNotFragment is TRUE.
512 IN EFI_UDP4_PROTOCOL
*This
,
513 IN EFI_UDP4_COMPLETION_TOKEN
*Token
517 UDP4_INSTANCE_DATA
*Instance
;
520 EFI_UDP4_HEADER
*Udp4Header
;
521 EFI_UDP4_CONFIG_DATA
*ConfigData
;
523 IP4_ADDR Destination
;
524 EFI_UDP4_TRANSMIT_DATA
*TxData
;
525 EFI_UDP4_SESSION_DATA
*UdpSessionData
;
526 UDP4_SERVICE_DATA
*Udp4Service
;
527 IP_IO_OVERRIDE Override
;
530 if ((This
== NULL
) || (Token
== NULL
)) {
531 return EFI_INVALID_PARAMETER
;
534 Instance
= UDP4_INSTANCE_DATA_FROM_THIS (This
);
536 if (Instance
->IsNoMapping
) {
537 return EFI_NO_MAPPING
;
540 if (!Instance
->Configured
) {
541 return EFI_NOT_STARTED
;
544 OldTpl
= NET_RAISE_TPL (NET_TPL_LOCK
);
547 // Validate the Token, if the token is invalid return the error code.
549 Status
= Udp4ValidateTxToken (Instance
, Token
);
550 if (EFI_ERROR (Status
)) {
554 if (EFI_ERROR (NetMapIterate (&Instance
->TxTokens
, Udp4TokenExist
, Token
)) ||
555 EFI_ERROR (NetMapIterate (&Instance
->RxTokens
, Udp4TokenExist
, Token
))) {
557 // Try to find a duplicate token in the two token maps, if found, return
558 // EFI_ACCESS_DENIED.
560 Status
= EFI_ACCESS_DENIED
;
564 TxData
= Token
->Packet
.TxData
;
567 // Create a net buffer to hold the user buffer and the udp header.
569 Packet
= NetbufFromExt (
570 (NET_FRAGMENT
*)TxData
->FragmentTable
,
571 TxData
->FragmentCount
,
574 Udp4NetVectorExtFree
,
577 if (Packet
== NULL
) {
578 Status
= EFI_OUT_OF_RESOURCES
;
583 // Store the IpIo in ProtoData.
585 Udp4Service
= Instance
->Udp4Service
;
586 *((UINTN
*) &Packet
->ProtoData
[0]) = (UINTN
) (Udp4Service
->IpIo
);
588 Udp4Header
= (EFI_UDP4_HEADER
*) NetbufAllocSpace (Packet
, UDP4_HEADER_SIZE
, TRUE
);
589 ConfigData
= &Instance
->ConfigData
;
592 // Fill the udp header.
594 Udp4Header
->SrcPort
= HTONS (ConfigData
->StationPort
);
595 Udp4Header
->DstPort
= HTONS (ConfigData
->RemotePort
);
596 Udp4Header
->Length
= HTONS (Packet
->TotalSize
);
597 Udp4Header
->Checksum
= 0;
599 UdpSessionData
= TxData
->UdpSessionData
;
600 Override
.SourceAddress
= ConfigData
->StationAddress
;
602 if (UdpSessionData
!= NULL
) {
604 // Set the SourceAddress, SrcPort and Destination according to the specified
607 if (!EFI_IP4_EQUAL (UdpSessionData
->SourceAddress
, mZeroIp4Addr
)) {
608 NetCopyMem (&Override
.SourceAddress
, &UdpSessionData
->SourceAddress
, sizeof (EFI_IPv4_ADDRESS
));
611 if (UdpSessionData
->SourcePort
!= 0) {
612 Udp4Header
->SrcPort
= HTONS (UdpSessionData
->SourcePort
);
615 if (UdpSessionData
->DestinationPort
!= 0) {
616 Udp4Header
->DstPort
= HTONS (UdpSessionData
->DestinationPort
);
619 NetCopyMem (&Source
, &Override
.SourceAddress
, sizeof (IP4_ADDR
));
620 NetCopyMem (&Destination
, &UdpSessionData
->DestinationAddress
, sizeof (IP4_ADDR
));
623 // calculate the pseudo head checksum using the overridden parameters.
625 HeadSum
= NetPseudoHeadChecksum (
633 // UdpSessionData is NULL, use the address and port information previously configured.
635 NetCopyMem (&Destination
, &ConfigData
->RemoteAddress
, sizeof (IP4_ADDR
));
637 HeadSum
= Instance
->HeadSum
;
641 // calculate the checksum.
643 Udp4Header
->Checksum
= Udp4Checksum (Packet
, HeadSum
);
644 if (Udp4Header
->Checksum
== 0) {
646 // If the calculated checksum is 0, fill the Checksum field with all ones.
648 Udp4Header
->Checksum
= 0xffff;
652 // Fill the IpIo Override data.
654 if (TxData
->GatewayAddress
!= NULL
) {
655 NetCopyMem (&Override
.GatewayAddress
, TxData
->GatewayAddress
, sizeof (EFI_IPv4_ADDRESS
));
657 NetZeroMem (&Override
.GatewayAddress
, sizeof (EFI_IPv4_ADDRESS
));
660 Override
.Protocol
= EFI_IP_PROTO_UDP
;
661 Override
.TypeOfService
= ConfigData
->TypeOfService
;
662 Override
.TimeToLive
= ConfigData
->TimeToLive
;
663 Override
.DoNotFragment
= ConfigData
->DoNotFragment
;
666 // Save the token into the TxToken map.
668 Status
= NetMapInsertTail (&Instance
->TxTokens
, Token
, Packet
);
669 if (EFI_ERROR (Status
)) {
674 // Send out this datagram through IpIo.
685 if (EFI_ERROR (Status
)) {
687 // Remove this token from the TxTokens.
689 Udp4RemoveToken (&Instance
->TxTokens
, Token
);
698 NET_RESTORE_TPL (OldTpl
);
705 This function places a completion token into the receive packet queue. This function
706 is always asynchronous.
708 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
709 @param Token Pointer to a token that is associated with the
710 receive data descriptor.
712 @retval EFI_SUCCESS The receive completion token is cached.
713 @retval EFI_NOT_STARTED This EFI UDPv4 Protocol instance has not been
715 @retval EFI_NO_MAPPING When using a default address, configuration (DHCP,
716 BOOTP, RARP, etc.) is not finished yet.
717 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
718 This is NULL. Token is NULL. Token.Event is NULL.
719 @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued
720 due to a lack of system resources (usually
722 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
723 The EFI UDPv4 Protocol instance has been reset to
725 @retval EFI_ACCESS_DENIED A receive completion token with the same
726 Token.Event is already in the receive queue.
727 @retval EFI_NOT_READY The receive request could not be queued because
728 the receive queue is full.
734 IN EFI_UDP4_PROTOCOL
*This
,
735 IN EFI_UDP4_COMPLETION_TOKEN
*Token
739 UDP4_INSTANCE_DATA
*Instance
;
742 if ((This
== NULL
) || (Token
== NULL
) || (Token
->Event
== NULL
)) {
743 return EFI_INVALID_PARAMETER
;
746 Instance
= UDP4_INSTANCE_DATA_FROM_THIS (This
);
748 if (Instance
->IsNoMapping
) {
749 return EFI_NO_MAPPING
;
752 if (!Instance
->Configured
) {
753 return EFI_NOT_STARTED
;
756 OldTpl
= NET_RAISE_TPL (NET_TPL_LOCK
);
758 if (EFI_ERROR (NetMapIterate (&Instance
->RxTokens
, Udp4TokenExist
, Token
))||
759 EFI_ERROR (NetMapIterate (&Instance
->TxTokens
, Udp4TokenExist
, Token
))) {
761 // Return EFI_ACCESS_DENIED if the specified token is already in the TxTokens or
764 Status
= EFI_ACCESS_DENIED
;
768 Token
->Packet
.RxData
= NULL
;
771 // Save the token into the RxTokens map.
773 Status
= NetMapInsertTail (&Instance
->RxTokens
, Token
, NULL
);
774 if (EFI_ERROR (Status
)) {
775 return EFI_NOT_READY
;
779 // If there is an icmp error, report it.
781 Udp4ReportIcmpError (Instance
);
784 // Try to delivered the received datagrams.
786 Udp4InstanceDeliverDgram (Instance
);
790 NET_RESTORE_TPL (OldTpl
);
797 This function is used to abort a pending transmit or receive request.
799 @param This Pointer to the EFI_UDP4_PROTOCOL instance.
800 @param Token Pointer to a token that has been issued by
801 EFI_UDP4_PROTOCOL.Transmit() or
802 EFI_UDP4_PROTOCOL.Receive().
804 @retval EFI_SUCCESS The asynchronous I/O request is aborted and
805 Token.Event is signaled. When Token is NULL, all
806 pending requests are aborted and their events are
808 @retval EFI_INVALID_PARAMETER This is NULL.
809 @retval EFI_NOT_STARTED This instance has not been started.
810 @retval EFI_NO_MAPPING When using the default address, configuration
811 (DHCP, BOOTP, RARP, etc.) is not finished yet.
812 @retval EFI_NOT_FOUND When Token is not NULL, the asynchronous I/O
813 request is not found in the transmit or receive
814 queue. It is either completed or not issued by
815 Transmit() or Receive().
821 IN EFI_UDP4_PROTOCOL
*This
,
822 IN EFI_UDP4_COMPLETION_TOKEN
*Token OPTIONAL
826 UDP4_INSTANCE_DATA
*Instance
;
830 return EFI_INVALID_PARAMETER
;
833 Instance
= UDP4_INSTANCE_DATA_FROM_THIS (This
);
835 if (Instance
->IsNoMapping
) {
836 return EFI_NO_MAPPING
;
839 if (!Instance
->Configured
) {
840 return EFI_NOT_STARTED
;
843 OldTpl
= NET_RAISE_TPL (NET_TPL_LOCK
);
846 // Cancle the tokens specified by Token for this instance.
848 Status
= Udp4InstanceCancelToken (Instance
, Token
);
850 NET_RESTORE_TPL (OldTpl
);
857 This function can be used by network drivers and applications to increase the rate that
858 data packets are moved between the communications device and the transmit/receive queues.
860 This - Pointer to the EFI_UDP4_PROTOCOL instance.
862 @retval EFI_SUCCESS Incoming or outgoing data was processed.
863 @retval EFI_INVALID_PARAMETER This is NULL.
864 @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
865 @retval EFI_TIMEOUT Data was dropped out of the transmit and/or
872 IN EFI_UDP4_PROTOCOL
*This
875 UDP4_INSTANCE_DATA
*Instance
;
876 EFI_IP4_PROTOCOL
*Ip
;
879 return EFI_INVALID_PARAMETER
;
882 Instance
= UDP4_INSTANCE_DATA_FROM_THIS (This
);
883 Ip
= Instance
->IpInfo
->Ip
;
886 // Invode the Ip instance consumed by the udp instance to do the poll operation.
888 return Ip
->Poll (Ip
);