4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncCopyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncThis program and the accompanying materials
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncare licensed and made available under the terms and conditions of the BSD License
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncwhich accompanies this distribution. The full text of the license may be found at
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncTHE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsyncWITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Gets the current operational settings for this instance of the EFI IPv4 Protocol driver.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The GetModeData() function returns the current operational mode data for this
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync driver instance. The data fields in EFI_IP4_MODE_DATA are read only. This
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync function is used optionally to retrieve the operational mode data of underlying
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync networks or drivers.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] This Pointer to the EFI_IP4_PROTOCOL instance.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[out] Ip4ModeData Pointer to the EFI IPv4 Protocol mode data structure.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[out] MnpConfigData Pointer to the managed network configuration data structure.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[out] SnpModeData Pointer to the simple network mode data structure.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The operation completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_INVALID_PARAMETER This is NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_OUT_OF_RESOURCES The required mode data could not be allocated.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Assigns an IPv4 address and subnet mask to this EFI IPv4 Protocol driver instance.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The Configure() function is used to set, change, or reset the operational
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync parameters and filter settings for this EFI IPv4 Protocol instance. Until these
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync parameters have been set, no network traffic can be sent or received by this
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync instance. Once the parameters have been reset (by calling this function with
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync IpConfigData set to NULL), no more traffic can be sent or received until these
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync parameters have been set again. Each EFI IPv4 Protocol instance can be started
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync and stopped independently of each other by enabling or disabling their receive
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync filter settings with the Configure() function.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync When IpConfigData.UseDefaultAddress is set to FALSE, the new station address will
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync be appended as an alias address into the addresses list in the EFI IPv4 Protocol
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync driver. While set to TRUE, Configure() will trigger the EFI_IP4_CONFIG_PROTOCOL
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync to retrieve the default IPv4 address if it is not available yet. Clients could
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync frequently call GetModeData() to check the status to ensure that the default IPv4
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync address is ready.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If operational parameters are reset or changed, any pending transmit and receive
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync requests will be cancelled. Their completion token status will be set to EFI_ABORTED
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync and their events will be signaled.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] This Pointer to the EFI_IP4_PROTOCOL instance.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] IpConfigData Pointer to the EFI IPv4 Protocol configuration data structure.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The driver instance was successfully opened.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync RARP, etc.) is not finished yet.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_UNSUPPORTED One or more of the following conditions is TRUE:
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync A configuration protocol (DHCP, BOOTP, RARP, etc.) could
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync not be located when clients choose to use the default IPv4
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync address. This EFI IPv4 Protocol implementation does not
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync support this requested filter or timeout setting.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_OUT_OF_RESOURCES The EFI IPv4 Protocol driver instance data could not be allocated.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_ALREADY_STARTED The interface is already open and must be stopped before the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync IPv4 address or subnet mask can be changed. The interface must
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync also be stopped when switching to/from raw packet mode.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The EFI IPv4
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Protocol driver instance is not opened.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Joins and leaves multicast groups.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The Groups() function is used to join and leave multicast group sessions. Joining
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync a group will enable reception of matching multicast packets. Leaving a group will
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync disable the multicast packet reception.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If JoinFlag is FALSE and GroupAddress is NULL, all joined groups will be left.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] This Pointer to the EFI_IP4_PROTOCOL instance.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] JoinFlag Set to TRUE to join the multicast group session and FALSE to leave.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] GroupAddress Pointer to the IPv4 multicast address.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The operation completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_INVALID_PARAMETER One or more of the following is TRUE:
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - This is NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - JoinFlag is TRUE and GroupAddress is NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - GroupAddress is not NULL and *GroupAddress is
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync not a multicast IPv4 address.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NOT_STARTED This instance has not been started.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync RARP, etc.) is not finished yet.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_OUT_OF_RESOURCES System resources could not be allocated.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_UNSUPPORTED This EFI IPv4 Protocol implementation does not support multicast groups.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_ALREADY_STARTED The group address is already in the group table (when
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync JoinFlag is TRUE).
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NOT_FOUND The group address is not in the group table (when JoinFlag is FALSE).
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Adds and deletes routing table entries.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The Routes() function adds a route to or deletes a route from the routing table.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Routes are determined by comparing the SubnetAddress with the destination IPv4
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync address arithmetically AND-ed with the SubnetMask. The gateway address must be
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync on the same subnet as the configured station address.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The default route is added with SubnetAddress and SubnetMask both set to 0.0.0.0.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The default route matches all destination IPv4 addresses that do not match any
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync other routes.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync A GatewayAddress that is zero is a nonroute. Packets are sent to the destination
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync IP address if it can be found in the ARP cache or on the local subnet. One automatic
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync nonroute entry will be inserted into the routing table for outgoing packets that
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync are addressed to a local subnet (gateway address of 0.0.0.0).
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Each EFI IPv4 Protocol instance has its own independent routing table. Those EFI
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync IPv4 Protocol instances that use the default IPv4 address will also have copies
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync of the routing table that was provided by the EFI_IP4_CONFIG_PROTOCOL, and these
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync copies will be updated whenever the EIF IPv4 Protocol driver reconfigures its
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync instances. As a result, client modification to the routing table will be lost.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] This Pointer to the EFI_IP4_PROTOCOL instance.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] DeleteRoute Set to TRUE to delete this route from the routing table. Set to
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync FALSE to add this route to the routing table. SubnetAddress
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync and SubnetMask are used as the key to each route entry.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] SubnetAddress The address of the subnet that needs to be routed.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] SubnetMask The subnet mask of SubnetAddress.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] GatewayAddress The unicast gateway IPv4 address for this route.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The operation completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NOT_STARTED The driver instance has not been started.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync RARP, etc.) is not finished yet.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - This is NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - SubnetAddress is NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - SubnetMask is NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - GatewayAddress is NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - *SubnetAddress is not a valid subnet address.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - *SubnetMask is not a valid subnet mask.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - *GatewayAddress is not a valid unicast IPv4 address.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_OUT_OF_RESOURCES Could not add the entry to the routing table.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NOT_FOUND This route is not in the routing table (when DeleteRoute is TRUE).
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_ACCESS_DENIED The route is already defined in the routing table (when
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync DeleteRoute is FALSE).
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Places outgoing data packets into the transmit queue.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The Transmit() function places a sending request in the transmit queue of this
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync EFI IPv4 Protocol instance. Whenever the packet in the token is sent out or some
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync errors occur, the event in the token will be signaled and the status is updated.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] This Pointer to the EFI_IP4_PROTOCOL instance.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Token Pointer to the transmit token.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The data has been queued for transmission.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NOT_STARTED This instance has not been started.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync RARP, etc.) is not finished yet.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_INVALID_PARAMETER One or more pameters are invalid.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_ACCESS_DENIED The transmit completion token with the same Token.Event
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync was already in the transmit queue.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NOT_READY The completion token could not be queued because the transmit
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync queue is full.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NOT_FOUND Not route is found to destination address.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_BUFFER_TOO_SMALL Token.Packet.TxData.TotalDataLength is too
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync short to transmit.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_BAD_BUFFER_SIZE The length of the IPv4 header + option length + total data length is
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync greater than MTU (or greater than the maximum packet size if
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Token.Packet.TxData.OverrideData.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync DoNotFragment is TRUE.)
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Places a receiving request into the receiving queue.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The Receive() function places a completion token into the receive packet queue.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync This function is always asynchronous.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The Token.Event field in the completion token must be filled in by the caller
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync and cannot be NULL. When the receive operation completes, the EFI IPv4 Protocol
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync driver updates the Token.Status and Token.Packet.RxData fields and the Token.Event
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync is signaled.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] This Pointer to the EFI_IP4_PROTOCOL instance.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Token Pointer to a token that is associated with the receive data descriptor.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The receive completion token was cached.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NOT_STARTED This EFI IPv4 Protocol instance has not been started.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP, RARP, etc.)
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync is not finished yet.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - This is NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - Token is NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - Token.Event is NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of system
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync resources (usually memory).
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The EFI IPv4 Protocol instance has been reset to startup defaults.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync EFI_ACCESS_DENIED The receive completion token with the same Token.Event was already
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync in the receive queue.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_ICMP_ERROR An ICMP error packet was received.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Abort an asynchronous transmit or receive request.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The Cancel() function is used to abort a pending transmit or receive request.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If the token is in the transmit or receive request queues, after calling this
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync function, Token->Status will be set to EFI_ABORTED and then Token->Event will
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync be signaled. If the token is not in one of the queues, which usually means the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync asynchronous operation has completed, this function will not signal the token
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync and EFI_NOT_FOUND is returned.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] This Pointer to the EFI_IP4_PROTOCOL instance.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Token Pointer to a token that has been issued by
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync EFI_IP4_PROTOCOL.Transmit() or
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync EFI_IP4_PROTOCOL.Receive(). If NULL, all pending
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync tokens are aborted. Type EFI_IP4_COMPLETION_TOKEN is
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync defined in EFI_IP4_PROTOCOL.Transmit().
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The asynchronous I/O request was aborted and
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Token.->Event was signaled. When Token is NULL, all
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync pending requests were aborted and their events were signaled.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_INVALID_PARAMETER This is NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NOT_STARTED This instance has not been started.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync RARP, etc.) is not finished yet.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NOT_FOUND When Token is not NULL, the asynchronous I/O request was
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync not found in the transmit or receive queue. It has either completed
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync or was not issued by Transmit() and Receive().
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Polls for incoming data packets and processes outgoing data packets.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The Poll() function polls for incoming data packets and processes outgoing data
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync packets. Network drivers and applications can call the EFI_IP4_PROTOCOL.Poll()
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync function to increase the rate that data packets are moved between the communications
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync device and the transmit and receive queues.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync In some systems the periodic timer event may not poll the underlying communications
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync device fast enough to transmit and/or receive all data packets without missing
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync incoming packets or dropping outgoing packets. Drivers and applications that are
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync experiencing packet loss should try calling the EFI_IP4_PROTOCOL.Poll() function
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync more often.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] This Pointer to the EFI_IP4_PROTOCOL instance.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS Incoming or outgoing data was processed.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NOT_STARTED This EFI IPv4 Protocol instance has not been started.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync RARP, etc.) is not finished yet.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_INVALID_PARAMETER This is NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NOT_READY No incoming or outgoing data is processed.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Consider increasing the polling rate.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Gets the current operational settings for this instance of the EFI IPv4 Protocol driver.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The GetModeData() function returns the current operational mode data for this
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync driver instance. The data fields in EFI_IP4_MODE_DATA are read only. This
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync function is used optionally to retrieve the operational mode data of underlying
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync networks or drivers.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] This Pointer to the EFI_IP4_PROTOCOL instance.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[out] Ip4ModeData Pointer to the EFI IPv4 Protocol mode data structure.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[out] MnpConfigData Pointer to the managed network configuration data structure.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[out] SnpModeData Pointer to the simple network mode data structure.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The operation completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_INVALID_PARAMETER This is NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_OUT_OF_RESOURCES The required mode data could not be allocated.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // IsStarted is "whether the EfiIp4Configure has been called".
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // IsConfigured is "whether the station address has been configured"
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Ip4ModeData->IsStarted = (BOOLEAN)(IpInstance->State == IP4_STATE_CONFIGED);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync CopyMem (&Ip4ModeData->ConfigData, &IpInstance->ConfigData, sizeof (Ip4ModeData->ConfigData));
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Ip4ModeData->GroupTable = (EFI_IPv4_ADDRESS *) IpInstance->Groups;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // return the current station address for this IP child. So,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // the user can get the default address through this. Some
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // application wants to know it station address even it is
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // using the default one, such as a ftp server.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync CopyMem (&Config->StationAddress, &Ip, sizeof (EFI_IPv4_ADDRESS));
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync CopyMem (&Config->SubnetMask, &Ip, sizeof (EFI_IPv4_ADDRESS));
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Ip4ModeData->IsConfigured = IpInstance->Interface->Configured;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Build a EFI route table for user from the internal route table.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Ip4ModeData->RouteTable = IpInstance->EfiRouteTable;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Ip4ModeData->RouteCount = IpInstance->EfiRouteCount;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Get fresh mode data from MNP, since underlying media status may change
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Status = IpSb->Mnp->GetModeData (IpSb->Mnp, MnpConfigData, SnpModeData);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Config the MNP parameter used by IP. The IP driver use one MNP
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync child to transmit/receive frames. By default, it configures MNP
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync to receive unicast/multicast/broadcast. And it will enable/disable
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the promiscous receive according to whether there is IP child
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync enable that or not. If Force is FALSE, it will iterate through
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync all the IP children to check whether the promiscuous receive
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync setting has been changed. If it hasn't been changed, it won't
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync reconfigure the MNP. If Force is TRUE, the MNP is configured no
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync matter whether that is changed or not.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] IpSb The IP4 service instance that is to be changed.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Force Force the configuration or not.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The MNP is successfully configured/reconfigured.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval Others Configuration failed.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Iterate through the IP children to check whether promiscuous
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // receive setting has been changed. Update the interface's receive
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // filter also.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync IpIf = NET_LIST_USER_STRUCT (Entry, IP4_INTERFACE, Link);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync NET_LIST_FOR_EACH (ProtoEntry, &IpIf->IpInstances) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync IpInstance = NET_LIST_USER_STRUCT (ProtoEntry, IP4_PROTOCOL, AddrLink);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // If promiscuous receive isn't changed, it isn't necessary to reconfigure.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if (PromiscReceive == IpSb->MnpConfigData.EnablePromiscuousReceive) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync IpSb->MnpConfigData.EnablePromiscuousReceive = PromiscReceive;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Status = IpSb->Mnp->Configure (IpSb->Mnp, &IpSb->MnpConfigData);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // recover the original configuration if failed to set the configure.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync IpSb->MnpConfigData.EnablePromiscuousReceive = (BOOLEAN) !PromiscReceive;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The event handle for IP4 auto configuration. If IP is asked
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync to reconfigure the default address. The original default
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync interface and route table are removed as the default. If there
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync is active IP children using the default address, the interface
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync will remain valid until all the children have freed their
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync references. If IP is signalled when auto configuration is done,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync it will configure the default interface and default route table
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync with the configuration information retrieved by IP4_CONFIGURE.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Context The IP4 service binding instance.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // IP is asked to do the reconfiguration. If the default interface
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // has been configured, release the default interface and route
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // table, then create a new one. If there are some IP children
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // using it, the interface won't be physically freed until all the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // children have released their reference to it. Also remember to
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // restart the receive on the default address. IP4 driver only receive
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // frames on the default address, and when the default interface is
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // freed, Ip4AcceptFrame won't be informed.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync IpIf = Ip4CreateInterface (IpSb->Mnp, IpSb->Controller, IpSb->Image);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Ip4ReceiveFrame (IpIf, NULL, Ip4AccpetFrame, IpSb);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Ip4Config->Start (Ip4Config, IpSb->DoneEvent, IpSb->ReconfigEvent);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Get the configure data in two steps: get the length then the data.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if (Ip4Config->GetData (Ip4Config, &Len, NULL) != EFI_BUFFER_TOO_SMALL) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Status = Ip4Config->GetData (Ip4Config, &Len, Data);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // If the default address has been configured don't change it.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // This is unlikely to happen if EFI_IP4_CONFIG protocol has
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // informed us to reconfigure each time it wants to change the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // configuration parameters.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Set the default interface's address, then add a directed
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // route for it, that is, the route whose nexthop is zero.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Status = Ip4SetAddress (IpIf, StationAddress, SubnetMask);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Add routes returned by EFI_IP4_CONFIG protocol.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync for (Index = 0; Index < Data->RouteTableSize; Index++) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync SubnetAddress = EFI_NTOHL (RouteEntry->SubnetAddress);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync GatewayAddress = EFI_NTOHL (RouteEntry->GatewayAddress);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Ip4AddRoute (IpSb->DefaultRouteTable, SubnetAddress, SubnetMask, GatewayAddress);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Request Ip4AutoConfigCallBackDpc as a DPC at TPL_CALLBACK.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param Event The event that is signalled.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param Context The IP4 service binding instance.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Request Ip4AutoConfigCallBackDpc as a DPC at TPL_CALLBACK
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync QueueDpc (TPL_CALLBACK, Ip4AutoConfigCallBackDpc, Context);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Start the auto configuration for this IP service instance.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync It will locates the EFI_IP4_CONFIG_PROTOCOL, then start the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync auto configuration.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] IpSb The IP4 service instance to configure
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The auto configuration is successfull started
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval Others Failed to start auto configuration.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Create the DoneEvent and ReconfigEvent to call EFI_IP4_CONFIG
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Open the EFI_IP4_CONFIG protocol then start auto configure
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync EFI_OPEN_PROTOCOL_BY_DRIVER | EFI_OPEN_PROTOCOL_EXCLUSIVE
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Status = Ip4Config->Start (Ip4Config, IpSb->DoneEvent, IpSb->ReconfigEvent);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Intiialize the IP4_PROTOCOL structure to the unconfigured states.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param IpSb The IP4 service instance.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param IpInstance The IP4 child instance.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync CopyMem (&IpInstance->Ip4Proto, &mEfiIp4ProtocolTemplete, sizeof (IpInstance->Ip4Proto));
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync EfiInitializeLock (&IpInstance->RecycleLock, TPL_NOTIFY);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Configure the IP4 child. If the child is already configured,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync change the configuration parameter. Otherwise configure it
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync for the first time. The caller should validate the configuration
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync before deliver them to it. It also don't do configure NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in, out] IpInstance The IP4 child to configure.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Config The configure data.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The IP4 child is successfully configured.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_DEVICE_ERROR Failed to free the pending transive or to
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync configure underlying MNP or other errors.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NO_MAPPING The IP4 child is configured to use default
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync address, but the default address hasn't been
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync configured. The IP4 child doesn't need to be
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync reconfigured when default address is configured.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_OUT_OF_RESOURCES No more memory space is available.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval other Other error occurs.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // User is changing packet filters. It must be stopped
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // before the station address can be changed.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Cancel all the pending transmit/receive from upper layer
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync CopyMem (&IpInstance->ConfigData, Config, sizeof (IpInstance->ConfigData));
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Configure a fresh IP4 protocol instance. Create a route table.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Each IP child has its own route table, which may point to the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // default table if it is using default address.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Set up the interface.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync CopyMem (&Ip, &Config->StationAddress, sizeof (IP4_ADDR));
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync CopyMem (&Netmask, &Config->SubnetMask, sizeof (IP4_ADDR));
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Find whether there is already an interface with the same
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // station address. All the instances with the same station
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // address shares one interface.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync IpIf = Ip4CreateInterface (IpSb->Mnp, IpSb->Controller, IpSb->Image);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Add a route to this connected network in the route table
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Ip4AddRoute (IpInstance->RouteTable, Ip, Netmask, IP4_ALLZERO_ADDRESS);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Use the default address. If the default configuration hasn't
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // been started, start it.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // If default address is used, so is the default route table.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Any route set by the instance has the precedence over the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // routes in the default route table. Link the default table
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // after the instance's table. Routing will search the local
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // table first.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync IpInstance->RouteTable->Next = IpSb->DefaultRouteTable;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync InsertTailList (&IpIf->IpInstances, &IpInstance->AddrLink);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync CopyMem (&IpInstance->ConfigData, Config, sizeof (IpInstance->ConfigData));
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Although EFI_NO_MAPPING is an error code, the IP child has been
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // successfully configured and doesn't need reconfiguration when
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // default address is acquired.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if (Config->UseDefaultAddress && IP4_NO_MAPPING (IpInstance)) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Clean up the IP4 child, release all the resources used by it.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] IpInstance The IP4 child to clean up.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The IP4 child is cleaned up
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_DEVICE_ERROR Some resources failed to be released
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if (EFI_ERROR (Ip4Groups (IpInstance, FALSE, NULL))) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Some packets haven't been recycled. It is because either the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // user forgets to recycle the packets, or because the callback
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // hasn't been called. Just leave it alone.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Ip4FreeInterface (IpInstance->Interface, IpInstance);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Validate that Ip/Netmask pair is OK to be used as station
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync address. Only continuous netmasks are supported. and check
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync that StationAddress is a unicast address on the newtwork.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Ip The IP address to validate
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Netmask The netmaks of the IP
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval TRUE The Ip/Netmask pair is valid
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval FALSE The Ip/Netmask pair is invalid
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Only support the station address with 0.0.0.0/0 to enable DHCP client.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Only support the continuous net masks
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if ((Len = NetGetMaskLength (Netmask)) == IP4_MASK_NUM) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Station address can't be class D or class E address
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if ((Type = NetGetIpClass (Ip)) > IP4_ADDR_CLASSC) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Station address can't be subnet broadcast/net broadcast address
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if ((Ip == (Ip & Netmask)) || (Ip == (Ip | ~Netmask))) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync NetBrdcastMask = gIp4AllMasks[MIN (Len, Type << 3)];
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Assigns an IPv4 address and subnet mask to this EFI IPv4 Protocol driver instance.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The Configure() function is used to set, change, or reset the operational
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync parameters and filter settings for this EFI IPv4 Protocol instance. Until these
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync parameters have been set, no network traffic can be sent or received by this
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync instance. Once the parameters have been reset (by calling this function with
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync IpConfigData set to NULL), no more traffic can be sent or received until these
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync parameters have been set again. Each EFI IPv4 Protocol instance can be started
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync and stopped independently of each other by enabling or disabling their receive
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync filter settings with the Configure() function.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync When IpConfigData.UseDefaultAddress is set to FALSE, the new station address will
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync be appended as an alias address into the addresses list in the EFI IPv4 Protocol
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync driver. While set to TRUE, Configure() will trigger the EFI_IP4_CONFIG_PROTOCOL
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync to retrieve the default IPv4 address if it is not available yet. Clients could
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync frequently call GetModeData() to check the status to ensure that the default IPv4
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync address is ready.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If operational parameters are reset or changed, any pending transmit and receive
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync requests will be cancelled. Their completion token status will be set to EFI_ABORTED
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync and their events will be signaled.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] This Pointer to the EFI_IP4_PROTOCOL instance.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] IpConfigData Pointer to the EFI IPv4 Protocol configuration data structure.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The driver instance was successfully opened.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync RARP, etc.) is not finished yet.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_UNSUPPORTED One or more of the following conditions is TRUE:
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync A configuration protocol (DHCP, BOOTP, RARP, etc.) could
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync not be located when clients choose to use the default IPv4
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync address. This EFI IPv4 Protocol implementation does not
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync support this requested filter or timeout setting.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_OUT_OF_RESOURCES The EFI IPv4 Protocol driver instance data could not be allocated.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_ALREADY_STARTED The interface is already open and must be stopped before the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync IPv4 address or subnet mask can be changed. The interface must
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync also be stopped when switching to/from raw packet mode.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_DEVICE_ERROR An unexpected system or network error occurred. The EFI IPv4
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Protocol driver instance is not opened.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // First, validate the parameters
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Validate the configuration first.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // This implementation doesn't support RawData
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync CopyMem (&IpAddress, &IpConfigData->StationAddress, sizeof (IP4_ADDR));
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync CopyMem (&SubnetMask, &IpConfigData->SubnetMask, sizeof (IP4_ADDR));
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Check whether the station address is a valid unicast address
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync AddrOk = Ip4StationAddressValid (IpAddress, SubnetMask);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // User can only update packet filters when already configured.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // If it wants to change the station address, it must configure(NULL)
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // the instance first.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if (Current->UseDefaultAddress != IpConfigData->UseDefaultAddress) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync (!EFI_IP4_EQUAL (&Current->StationAddress, &IpConfigData->StationAddress) ||
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync !EFI_IP4_EQUAL (&Current->SubnetMask, &IpConfigData->SubnetMask))) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if (Current->UseDefaultAddress && IP4_NO_MAPPING (IpInstance)) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Configure the instance or clean it up.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Status = Ip4ConfigProtocol (IpInstance, IpConfigData);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Don't change the state if it is DESTORY, consider the following
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // valid sequence: Mnp is unloaded-->Ip Stopped-->Udp Stopped,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Configure (ThisIp, NULL). If the state is changed to UNCONFIGED,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // the unload fails miserably.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Update the MNP's configure data. Ip4ServiceConfigMnp will check
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // whether it is necessary to reconfigure the MNP.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Update the variable data.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Change the IP4 child's multicast setting. The caller
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync should make sure that the parameters is valid.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] IpInstance The IP4 child to change the setting.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] JoinFlag TRUE to join the group, otherwise leave it
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] GroupAddress The target group address
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_ALREADY_STARTED Want to join the group, but already a member of it
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_OUT_OF_RESOURCES Failed to allocate some resources.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_DEVICE_ERROR Failed to set the group configuraton
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS Successfully updated the group setting.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NOT_FOUND Try to leave the group which it isn't a member.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Add it to the instance's Groups, and join the group by IGMP.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // IpInstance->Groups is in network byte order. IGMP operates in
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // host byte order
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // When JoinFlag is TRUE, GroupAddress shouldn't be NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync for (Index = 0; Index < IpInstance->GroupCount; Index++) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Members = Ip4CombineGroups (IpInstance->Groups, IpInstance->GroupCount, Group);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if (EFI_ERROR (Ip4JoinGroup (IpInstance, NTOHL (Group)))) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Leave the group. Leave all the groups if GroupAddress is NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Must iterate from the end to the beginning because the GroupCount
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // is decreamented each time an address is removed..
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync for (Index = IpInstance->GroupCount; Index > 0 ; Index--) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if ((GroupAddress == NULL) || EFI_IP4_EQUAL (&Group, GroupAddress)) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if (EFI_ERROR (Ip4LeaveGroup (IpInstance, NTOHL (Group)))) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Ip4RemoveGroupAddr (IpInstance->Groups, IpInstance->GroupCount, Group);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync return ((GroupAddress != NULL) ? EFI_NOT_FOUND : EFI_SUCCESS);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Joins and leaves multicast groups.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The Groups() function is used to join and leave multicast group sessions. Joining
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync a group will enable reception of matching multicast packets. Leaving a group will
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync disable the multicast packet reception.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If JoinFlag is FALSE and GroupAddress is NULL, all joined groups will be left.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] This Pointer to the EFI_IP4_PROTOCOL instance.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] JoinFlag Set to TRUE to join the multicast group session and FALSE to leave.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] GroupAddress Pointer to the IPv4 multicast address.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The operation completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_INVALID_PARAMETER One or more of the following is TRUE:
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - This is NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - JoinFlag is TRUE and GroupAddress is NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - GroupAddress is not NULL and *GroupAddress is
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync not a multicast IPv4 address.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NOT_STARTED This instance has not been started.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync RARP, etc.) is not finished yet.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_OUT_OF_RESOURCES System resources could not be allocated.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_UNSUPPORTED This EFI IPv4 Protocol implementation does not support multicast groups.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_ALREADY_STARTED The group address is already in the group table (when
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync JoinFlag is TRUE).
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NOT_FOUND The group address is not in the group table (when JoinFlag is FALSE).
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if ((This == NULL) || (JoinFlag && (GroupAddress == NULL))) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync CopyMem (&McastIp, GroupAddress, sizeof (IP4_ADDR));
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if (IpInstance->ConfigData.UseDefaultAddress && IP4_NO_MAPPING (IpInstance)) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Status = Ip4Groups (IpInstance, JoinFlag, GroupAddress);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Adds and deletes routing table entries.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The Routes() function adds a route to or deletes a route from the routing table.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Routes are determined by comparing the SubnetAddress with the destination IPv4
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync address arithmetically AND-ed with the SubnetMask. The gateway address must be
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync on the same subnet as the configured station address.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The default route is added with SubnetAddress and SubnetMask both set to 0.0.0.0.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The default route matches all destination IPv4 addresses that do not match any
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync other routes.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync A GatewayAddress that is zero is a nonroute. Packets are sent to the destination
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync IP address if it can be found in the ARP cache or on the local subnet. One automatic
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync nonroute entry will be inserted into the routing table for outgoing packets that
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync are addressed to a local subnet (gateway address of 0.0.0.0).
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Each EFI IPv4 Protocol instance has its own independent routing table. Those EFI
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync IPv4 Protocol instances that use the default IPv4 address will also have copies
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync of the routing table that was provided by the EFI_IP4_CONFIG_PROTOCOL, and these
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync copies will be updated whenever the EIF IPv4 Protocol driver reconfigures its
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync instances. As a result, client modification to the routing table will be lost.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] This Pointer to the EFI_IP4_PROTOCOL instance.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] DeleteRoute Set to TRUE to delete this route from the routing table. Set to
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync FALSE to add this route to the routing table. SubnetAddress
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync and SubnetMask are used as the key to each route entry.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] SubnetAddress The address of the subnet that needs to be routed.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] SubnetMask The subnet mask of SubnetAddress.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] GatewayAddress The unicast gateway IPv4 address for this route.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The operation completed successfully.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NOT_STARTED The driver instance has not been started.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync RARP, etc.) is not finished yet.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - This is NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - SubnetAddress is NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - SubnetMask is NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - GatewayAddress is NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - *SubnetAddress is not a valid subnet address.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - *SubnetMask is not a valid subnet mask.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - *GatewayAddress is not a valid unicast IPv4 address.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_OUT_OF_RESOURCES Could not add the entry to the routing table.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NOT_FOUND This route is not in the routing table (when DeleteRoute is TRUE).
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_ACCESS_DENIED The route is already defined in the routing table (when
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync DeleteRoute is FALSE).
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // First, validate the parameters
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync (SubnetMask == NULL) || (GatewayAddress == NULL)) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if (IpInstance->ConfigData.UseDefaultAddress && IP4_NO_MAPPING (IpInstance)) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync CopyMem (&Nexthop, GatewayAddress, sizeof (IP4_ADDR));
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // the gateway address must be a unicast on the connected network if not zero.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync (!IP4_NET_EQUAL (Nexthop, IpIf->Ip, IpIf->SubnetMask) ||
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync IP4_IS_BROADCAST (Ip4GetNetCast (Nexthop, IpIf)))) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Status = Ip4DelRoute (IpInstance->RouteTable, Dest, Netmask, Nexthop);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Status = Ip4AddRoute (IpInstance->RouteTable, Dest, Netmask, Nexthop);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Check whether the user's token or event has already
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync been enqueued on IP4's list.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Map The container of either user's transmit or receive
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Item Current item to check against
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Context The Token to check againist.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_ACCESS_DENIED The token or event has already been enqueued in IP
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The current item isn't the same token/event as the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync TokenInItem = (EFI_IP4_COMPLETION_TOKEN *) Item->Key;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if ((Token == TokenInItem) || (Token->Event == TokenInItem->Event)) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Validate the user's token against current station address.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Token User's token to validate
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] IpIf The IP4 child's interface.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_INVALID_PARAMETER Some parameters are invalid
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_BAD_BUFFER_SIZE The user's option/data is too long.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The token is OK
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if ((Token == NULL) || (Token->Event == NULL) || (Token->Packet.TxData == NULL)) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Check the IP options: no more than 40 bytes and format is OK
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if ((TxData->OptionsLength > 40) || (TxData->OptionsBuffer == NULL)) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if (!Ip4OptionIsValid (TxData->OptionsBuffer, TxData->OptionsLength, FALSE)) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Check the fragment table: no empty fragment, and length isn't bogus
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if ((TxData->TotalDataLength == 0) || (TxData->FragmentCount == 0)) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync for (Index = 0; Index < TxData->FragmentCount; Index++) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if ((TxData->FragmentTable[Index].FragmentBuffer == NULL) ||
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync (TxData->FragmentTable[Index].FragmentLength == 0)) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Offset -= TxData->FragmentTable[Index].FragmentLength;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Check the source and gateway: they must be a valid unicast.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Gateway must also be on the connected network.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync CopyMem (&Src, &Override->SourceAddress, sizeof (IP4_ADDR));
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync CopyMem (&Gateway, &Override->GatewayAddress, sizeof (IP4_ADDR));
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // If gateway isn't zero, it must be a unicast address, and
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // on the connected network.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync !IP4_NET_EQUAL (Gateway, IpIf->Ip, IpIf->SubnetMask) ||
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync IP4_IS_BROADCAST (Ip4GetNetCast (Gateway, IpIf)))) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Check the packet length: Head length and packet length all has a limit
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync HeadLen = sizeof (IP4_HEAD) + ((TxData->OptionsLength + 3) &~0x03);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync (TxData->TotalDataLength + HeadLen > IP4_MAX_PACKET_SIZE)) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The callback function for the net buffer which wraps the user's
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync transmit token. Although it seems this function is pretty simple,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync there are some subtle things.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync When user requests the IP to transmit a packet by passing it a
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync token, the token is wrapped in an IP4_TXTOKEN_WRAP and the data
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync is wrapped in an net buffer. the net buffer's Free function is
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync set to Ip4FreeTxToken. The Token and token wrap are added to the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync IP child's TxToken map. Then the buffer is passed to Ip4Output for
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync transmission. If something error happened before that, the buffer
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync is freed, which in turn will free the token wrap. The wrap may
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync have been added to the TxToken map or not, and the user's event
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync shouldn't be fired because we are still in the EfiIp4Transmit. If
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the buffer has been sent by Ip4Output, it should be removed from
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync the TxToken map and user's event signaled. The token wrap and buffer
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync are bound together. Check the comments in Ip4Output for information
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync about IP fragmentation.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Context The token's wrap
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Signal IpSecRecycleEvent to inform IPsec free the memory
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Find the token in the instance's map. EfiIp4Transmit put the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // token to the map. If that failed, NetMapFindKey will return NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Item = NetMapFindKey (&Wrap->IpInstance->TxTokens, Wrap->Token);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync NetMapRemoveItem (&Wrap->IpInstance->TxTokens, Item, NULL);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Dispatch the DPC queued by the NotifyFunction of Token->Event.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The callback function to Ip4Output to update the transmit status.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param Ip4Instance The Ip4Instance that request the transmit.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param Packet The user's transmit request
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param IoStatus The result of the transmission
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param Flag Not used during transmission
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param Context The token's wrap.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // This is the transmission request from upper layer,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // not the IP4 driver itself.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // The first fragment of the packet has been sent. Update
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // the token's status. That is, if fragmented, the transmit's
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // status is the first fragment's status. The Wrap will be
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // release when all the fragments are release. Check the comments
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // in Ip4FreeTxToken and Ip4Output for information.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Places outgoing data packets into the transmit queue.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The Transmit() function places a sending request in the transmit queue of this
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync EFI IPv4 Protocol instance. Whenever the packet in the token is sent out or some
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync errors occur, the event in the token will be signaled and the status is updated.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] This Pointer to the EFI_IP4_PROTOCOL instance.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Token Pointer to the transmit token.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The data has been queued for transmission.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NOT_STARTED This instance has not been started.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync RARP, etc.) is not finished yet.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_INVALID_PARAMETER One or more pameters are invalid.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_ACCESS_DENIED The transmit completion token with the same Token.Event
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync was already in the transmit queue.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NOT_READY The completion token could not be queued because the transmit
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync queue is full.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NOT_FOUND Not route is found to destination address.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_OUT_OF_RESOURCES Could not queue the transmit data.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_BUFFER_TOO_SMALL Token.Packet.TxData.TotalDataLength is too
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync short to transmit.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_BAD_BUFFER_SIZE The length of the IPv4 header + option length + total data length is
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync greater than MTU (or greater than the maximum packet size if
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Token.Packet.TxData.OverrideData.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync DoNotFragment is TRUE.)
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if (Config->UseDefaultAddress && IP4_NO_MAPPING (IpInstance)) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // make sure that token is properly formated
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Check whether the token or signal already existed.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if (EFI_ERROR (NetMapIterate (&IpInstance->TxTokens, Ip4TokenExist, Token))) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Build the IP header, need to fill in the Tos, TotalLen, Id,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // fragment, Ttl, protocol, Src, and Dst.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync CopyMem (&Head.Dst, &TxData->DestinationAddress, sizeof (IP4_ADDR));
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync CopyMem (&Head.Src, &Override->SourceAddress, sizeof (IP4_ADDR));
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync CopyMem (&GateWay, &Override->GatewayAddress, sizeof (IP4_ADDR));
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Head.Fragment = IP4_HEAD_FRAGMENT_FIELD (DontFragment, FALSE, 0);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // If don't fragment and fragment needed, return error
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if (DontFragment && (TxData->TotalDataLength + HeadLen > IpSb->MaxPacketSize)) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // OK, it survives all the validation check. Wrap the token in
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // a IP4_TXTOKEN_WRAP and the data in a netbuf
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Wrap = AllocateZeroPool (sizeof (IP4_TXTOKEN_WRAP));
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Wrap->Life = IP4_US_TO_SEC (Config->TransmitTimeout);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if (EFI_ERROR (NetMapInsertTail (&IpInstance->TxTokens, Token, Wrap))) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // NetbufFree will call Ip4FreeTxToken, which in turn will
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // free the IP4_TXTOKEN_WRAP. Now, the token wrap hasn't been
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // enqueued.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Mark the packet sent before output it. Mark it not sent again if the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // returned status is not EFI_SUCCESS;
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Places a receiving request into the receiving queue.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The Receive() function places a completion token into the receive packet queue.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync This function is always asynchronous.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The Token.Event field in the completion token must be filled in by the caller
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync and cannot be NULL. When the receive operation completes, the EFI IPv4 Protocol
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync driver updates the Token.Status and Token.Packet.RxData fields and the Token.Event
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync is signaled.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] This Pointer to the EFI_IP4_PROTOCOL instance.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Token Pointer to a token that is associated with the receive data descriptor.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The receive completion token was cached.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NOT_STARTED This EFI IPv4 Protocol instance has not been started.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP, RARP, etc.)
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync is not finished yet.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - This is NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - Token is NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync - Token.Event is NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_OUT_OF_RESOURCES The receive completion token could not be queued due to a lack of system
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync resources (usually memory).
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The EFI IPv4 Protocol instance has been reset to startup defaults.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync EFI_ACCESS_DENIED The receive completion token with the same Token.Event was already
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync in the receive queue.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NOT_READY The receive request could not be queued because the receive queue is full.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_ICMP_ERROR An ICMP error packet was received.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // First validate the parameters
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if ((This == NULL) || (Token == NULL) || (Token->Event == NULL)) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Check whether the toke is already on the receive queue.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Status = NetMapIterate (&IpInstance->RxTokens, Ip4TokenExist, Token);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Queue the token then check whether there is pending received packet.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Status = NetMapInsertTail (&IpInstance->RxTokens, Token, NULL);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Dispatch the DPC queued by the NotifyFunction of this instane's receive
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Cancel the transmitted but not recycled packet. If a matching
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync token is found, it will call Ip4CancelPacket to cancel the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync packet. Ip4CancelPacket will cancel all the fragments of the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync packet. When all the fragments are freed, the IP4_TXTOKEN_WRAP
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync will be deleted from the Map, and user's event signalled.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Because Ip4CancelPacket and other functions are all called in
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync line, so, after Ip4CancelPacket returns, the Item has been freed.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Map The IP4 child's transmit queue
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Item The current transmitted packet to test.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Context The user's token to cancel.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS Continue to check the next Item.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_ABORTED The user's Token (Token != NULL) is cancelled.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Return EFI_SUCCESS to check the next item in the map if
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // this one doesn't match.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Don't access the Item, Wrap and Token's members after this point.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Item and wrap has been freed. And we no longer own the Token.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Ip4CancelPacket (Wrap->IpInstance->Interface, Wrap->Packet, EFI_ABORTED);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // If only one item is to be cancel, return EFI_ABORTED to stop
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // iterating the map any more.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Cancel the receive request. This is quiet simple, because
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync it is only enqueued in our local receive map.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Map The IP4 child's receive queue
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Item Current receive request to cancel.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Context The user's token to cancel
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS Continue to check the next receive request on the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_ABORTED The user's token (token != NULL) has been
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Cancel the user's receive/transmit request.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] IpInstance The IP4 child
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Token The token to cancel. If NULL, all token will be
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The token is cancelled
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NOT_FOUND The token isn't found on either the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_DEVICE_ERROR Not all token is cancelled when Token is NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // First check the transmitted packet. Ip4CancelTxTokens returns
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // EFI_ABORTED to mean that the token has been cancelled when
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // token != NULL. So, return EFI_SUCCESS for this condition.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Status = NetMapIterate (&IpInstance->TxTokens, Ip4CancelTxTokens, Token);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Check the receive queue. Ip4CancelRxTokens also returns EFI_ABORT
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // for Token!=NULL and it is cancelled.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Status = NetMapIterate (&IpInstance->RxTokens, Ip4CancelRxTokens, Token);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Dispatch the DPCs queued by the NotifyFunction of the canceled rx token's
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // OK, if the Token is found when Token != NULL, the NetMapIterate
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // will return EFI_ABORTED, which has been interrupted as EFI_SUCCESS.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // If Token == NULL, cancel all the tokens. return error if no
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // all of them are cancelled.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Abort an asynchronous transmit or receive request.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The Cancel() function is used to abort a pending transmit or receive request.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync If the token is in the transmit or receive request queues, after calling this
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync function, Token->Status will be set to EFI_ABORTED and then Token->Event will
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync be signaled. If the token is not in one of the queues, which usually means the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync asynchronous operation has completed, this function will not signal the token
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync and EFI_NOT_FOUND is returned.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] This Pointer to the EFI_IP4_PROTOCOL instance.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Token Pointer to a token that has been issued by
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync EFI_IP4_PROTOCOL.Transmit() or
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync EFI_IP4_PROTOCOL.Receive(). If NULL, all pending
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync tokens are aborted. Type EFI_IP4_COMPLETION_TOKEN is
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync defined in EFI_IP4_PROTOCOL.Transmit().
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS The asynchronous I/O request was aborted and
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Token.->Event was signaled. When Token is NULL, all
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync pending requests were aborted and their events were signaled.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_INVALID_PARAMETER This is NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NOT_STARTED This instance has not been started.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync RARP, etc.) is not finished yet.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NOT_FOUND When Token is not NULL, the asynchronous I/O request was
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync not found in the transmit or receive queue. It has either completed
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync or was not issued by Transmit() and Receive().
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync if (IpInstance->ConfigData.UseDefaultAddress && IP4_NO_MAPPING (IpInstance)) {
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Polls for incoming data packets and processes outgoing data packets.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The Poll() function polls for incoming data packets and processes outgoing data
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync packets. Network drivers and applications can call the EFI_IP4_PROTOCOL.Poll()
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync function to increase the rate that data packets are moved between the communications
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync device and the transmit and receive queues.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync In some systems the periodic timer event may not poll the underlying communications
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync device fast enough to transmit and/or receive all data packets without missing
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync incoming packets or dropping outgoing packets. Drivers and applications that are
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync experiencing packet loss should try calling the EFI_IP4_PROTOCOL.Poll() function
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync more often.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] This Pointer to the EFI_IP4_PROTOCOL instance.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS Incoming or outgoing data was processed.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NOT_STARTED This EFI IPv4 Protocol instance has not been started.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NO_MAPPING When using the default address, configuration (DHCP, BOOTP,
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync RARP, etc.) is not finished yet.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_INVALID_PARAMETER This is NULL.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_DEVICE_ERROR An unexpected system or network error occurred.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_NOT_READY No incoming or outgoing data is processed.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_TIMEOUT Data was dropped out of the transmit and/or receive queue.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Consider increasing the polling rate.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // Don't lock the Poll function to enable the deliver of
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync // the packet polled up.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Decrease the life of the transmitted packets. If it is
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync decreased to zero, cancel the packet. This function is
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync called by Ip4PacketTimerTicking which time out both the
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync received-but-not-delivered and transmitted-but-not-recycle
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Map The IP4 child's transmit map.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Item Current transmitted packet
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Context Not used.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @retval EFI_SUCCESS Always returns EFI_SUCCESS
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync Ip4CancelPacket (Wrap->IpInstance->Interface, Wrap->Packet, EFI_ABORTED);
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync The heart beat timer of IP4 service instance. It times out
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync all of its IP4 children's received-but-not-delivered and
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync transmitted-but-not-recycle packets, and provides time input
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync for its IGMP protocol.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Event The IP4 service instance's heart beat timer.
4fd606d1f5abe38e1f42c38de1d2e895166bd0f4vboxsync @param[in] Context The IP4 service instance.