/** @file\r
Implement IP4 pesudo interface.\r
\r
-Copyright (c) 2005 - 2009, Intel Corporation.<BR>\r
-All rights reserved. This program and the accompanying materials\r
+Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
which accompanies this distribution. The full text of the license may be found at\r
http://opensource.org/licenses/bsd-license.php\r
either queued on ARP queues or that have already been delivered to\r
MNP and not yet recycled.\r
\r
- @param[in] Interface Interface to remove the frames from\r
+ @param[in] Interface Interface to remove the frames from.\r
@param[in] IoStatus The transmit status returned to the frames'\r
- callback\r
+ callback.\r
@param[in] FrameToCancel Function to select the frame to cancel, NULL to\r
- select all\r
- @param[in] Context Opaque parameters passed to FrameToCancel\r
+ select all.\r
+ @param[in] Context Opaque parameters passed to FrameToCancel.\r
\r
**/\r
VOID\r
the interface is configured.\r
\r
@param[in] Mnp The shared MNP child of this IP4 service binding\r
- instance\r
+ instance.\r
@param[in] Controller The controller this IP4 service binding instance\r
is installed. Most like the UNDI handle.\r
- @param[in] ImageHandle This driver's image handle\r
+ @param[in] ImageHandle This driver's image handle.\r
\r
@return Point to the created IP4_INTERFACE, otherwise NULL.\r
\r
Set the interface's address, create and configure\r
the ARP child if necessary.\r
\r
- @param Interface The interface to set the address\r
- @param IpAddr The interface's IP address\r
- @param SubnetMask The interface's netmask\r
+ @param Interface The interface to set the address.\r
+ @param IpAddr The interface's IP address.\r
+ @param SubnetMask The interface's netmask.\r
\r
@retval EFI_SUCCESS The interface is configured with Ip/netmask pair,\r
and a ARP is created for it.\r
\r
NET_CHECK_SIGNATURE (Interface, IP4_INTERFACE_SIGNATURE);\r
\r
- ASSERT (!Interface->Configured);\r
-\r
//\r
// Set the ip/netmask, then compute the subnet broadcast\r
// and network broadcast for easy access. When computing\r
Interface->SubnetBrdcast = (IpAddr | ~SubnetMask);\r
\r
Type = NetGetIpClass (IpAddr);\r
+ ASSERT (Type <= IP4_ADDR_CLASSC);\r
Len = NetGetMaskLength (SubnetMask);\r
- Netmask = gIp4AllMasks[MIN ((Len - 1), Type << 3)];\r
+ ASSERT (Len <= IP4_MASK_MAX);\r
+ Netmask = gIp4AllMasks[MIN (Len, Type << 3)];\r
Interface->NetBrdcast = (IpAddr | ~Netmask);\r
\r
+ //\r
+ // Do clean up for Arp child\r
+ //\r
+ if (Interface->ArpHandle != NULL) {\r
+ if (Interface->Arp != NULL) {\r
+ gBS->CloseProtocol (\r
+ Interface->ArpHandle,\r
+ &gEfiArpProtocolGuid,\r
+ Interface->Image,\r
+ Interface->Controller\r
+ );\r
+ \r
+ Interface->Arp = NULL;\r
+ }\r
+ \r
+ NetLibDestroyServiceChild (\r
+ Interface->Controller,\r
+ Interface->Image,\r
+ &gEfiArpServiceBindingProtocolGuid,\r
+ &Interface->ArpHandle\r
+ );\r
+\r
+ Interface->ArpHandle = NULL;\r
+ }\r
+\r
//\r
// If the address is NOT all zero, create then configure an ARP child.\r
// Pay attention: DHCP configures its station address as 0.0.0.0/0\r
//\r
- Interface->Arp = NULL;\r
- Interface->ArpHandle = NULL;\r
-\r
if (IpAddr != IP4_ALLZERO_ADDRESS) {\r
Status = NetLibCreateServiceChild (\r
Interface->Controller,\r
);\r
\r
if (EFI_ERROR (Status)) {\r
- return Status;;\r
+ return Status;\r
}\r
\r
Status = gBS->OpenProtocol (\r
\r
if (EFI_ERROR (Status)) {\r
gBS->CloseProtocol (\r
- Interface->ArpHandle,\r
- &gEfiArpProtocolGuid,\r
- Interface->Image,\r
- Interface->Controller\r
- );\r
+ Interface->ArpHandle,\r
+ &gEfiArpProtocolGuid,\r
+ Interface->Image,\r
+ Interface->Controller\r
+ );\r
\r
goto ON_ERROR;\r
}\r
Because the IpInstance is optional, the caller must remove\r
IpInstance from the interface's instance list itself.\r
\r
- @param[in] Interface The interface used by the IpInstance\r
+ @param[in] Interface The interface used by the IpInstance.\r
@param[in] IpInstance The Ip instance that free the interface. NULL if\r
the Ip driver is releasing the default interface.\r
\r
}\r
\r
//\r
- // Destory the interface if this is the last IP instance that\r
+ // Destroy the interface if this is the last IP instance that\r
// has the address. Remove all the system transmitted packets\r
// from this interface, cancel the receive request if there is\r
- // one, and destory the ARP requests.\r
+ // one, and destroy the ARP requests.\r
//\r
Ip4CancelFrames (Interface, EFI_ABORTED, Ip4CancelInstanceFrame, NULL);\r
Ip4CancelReceive (Interface);\r
/**\r
Request to receive the packet from the interface.\r
\r
- @param[in] Interface The interface to receive the frames from\r
+ @param[in] Interface The interface to receive the frames from.\r
@param[in] IpInstance The instance that requests the receive. NULL for\r
the driver itself.\r
@param[in] CallBack Function to call when receive finished.\r
- @param[in] Context Opaque parameter to the callback\r
+ @param[in] Context Opaque parameter to the callback.\r
\r
@retval EFI_ALREADY_STARTED There is already a pending receive request.\r
- @retval EFI_OUT_OF_RESOURCES Failed to allocate resource to receive\r
+ @retval EFI_OUT_OF_RESOURCES Failed to allocate resource to receive.\r
@retval EFI_SUCCESS The recieve request has been started.\r
@retval other Other error occurs.\r
\r