- EFI_IP4_CONFIG_PROTOCOL *Ip4Config;\r
- EFI_IP4_IPCONFIG_DATA *Data;\r
- EFI_IP4_ROUTE_TABLE *RouteEntry;\r
- IP4_SERVICE *IpSb;\r
- IP4_ROUTE_TABLE *RouteTable;\r
- IP4_INTERFACE *IpIf;\r
- EFI_STATUS Status;\r
- UINTN Len;\r
- UINT32 Index;\r
- IP4_ADDR StationAddress;\r
- IP4_ADDR SubnetMask;\r
- IP4_ADDR SubnetAddress;\r
- IP4_ADDR GatewayAddress;\r
-\r
- IpSb = (IP4_SERVICE *) Context;\r
- NET_CHECK_SIGNATURE (IpSb, IP4_SERVICE_SIGNATURE);\r
-\r
- Ip4Config = IpSb->Ip4Config;\r
-\r
- //\r
- // IP is asked to do the reconfiguration. If the default interface\r
- // has been configured, release the default interface and route\r
- // table, then create a new one. If there are some IP children\r
- // using it, the interface won't be physically freed until all the\r
- // children have released their reference to it. Also remember to\r
- // restart the receive on the default address. IP4 driver only receive\r
- // frames on the default address, and when the default interface is\r
- // freed, Ip4AcceptFrame won't be informed.\r
- //\r
- if (IpSb->ActiveEvent == IpSb->ReconfigEvent) {\r
-\r
- if (IpSb->DefaultInterface->Configured) {\r
- IpIf = Ip4CreateInterface (IpSb->Mnp, IpSb->Controller, IpSb->Image);\r
-\r
- if (IpIf == NULL) {\r
- return;\r
- }\r
-\r
- RouteTable = Ip4CreateRouteTable ();\r
-\r
- if (RouteTable == NULL) {\r
- Ip4FreeInterface (IpIf, NULL);\r
- return;\r
- }\r
-\r
- Ip4CancelReceive (IpSb->DefaultInterface);\r
- Ip4FreeInterface (IpSb->DefaultInterface, NULL);\r
- Ip4FreeRouteTable (IpSb->DefaultRouteTable);\r
-\r
- IpSb->DefaultInterface = IpIf;\r
- InsertHeadList (&IpSb->Interfaces, &IpIf->Link);\r
-\r
- IpSb->DefaultRouteTable = RouteTable;\r
- Ip4ReceiveFrame (IpIf, NULL, Ip4AccpetFrame, IpSb);\r
- }\r
-\r
- Ip4Config->Stop (Ip4Config);\r
- Ip4Config->Start (Ip4Config, IpSb->DoneEvent, IpSb->ReconfigEvent);\r
- return ;\r
- }\r
-\r
- //\r
- // Get the configure data in two steps: get the length then the data.\r
- //\r
- Len = 0;\r
-\r
- if (Ip4Config->GetData (Ip4Config, &Len, NULL) != EFI_BUFFER_TOO_SMALL) {\r
- return ;\r
- }\r
-\r
- Data = AllocatePool (Len);\r
-\r
- if (Data == NULL) {\r
- return ;\r
- }\r
-\r
- Status = Ip4Config->GetData (Ip4Config, &Len, Data);\r
-\r
- if (EFI_ERROR (Status)) {\r
- goto ON_EXIT;\r
- }\r
-\r
- IpIf = IpSb->DefaultInterface;\r
-\r
- //\r
- // If the default address has been configured don't change it.\r
- // This is unlikely to happen if EFI_IP4_CONFIG protocol has\r
- // informed us to reconfigure each time it wants to change the\r
- // configuration parameters.\r
- //\r
- if (IpIf->Configured) {\r
- goto ON_EXIT;\r
- }\r
-\r
- //\r
- // Set the default interface's address, then add a directed\r
- // route for it, that is, the route whose nexthop is zero.\r
- //\r
- StationAddress = EFI_NTOHL (Data->StationAddress);\r
- SubnetMask = EFI_NTOHL (Data->SubnetMask);\r
- Status = Ip4SetAddress (IpIf, StationAddress, SubnetMask);\r
-\r
- if (EFI_ERROR (Status)) {\r
- goto ON_EXIT;\r
- }\r
-\r
- Ip4AddRoute (\r
- IpSb->DefaultRouteTable,\r
- StationAddress,\r
- SubnetMask,\r
- IP4_ALLZERO_ADDRESS\r
- );\r
-\r
- //\r
- // Add routes returned by EFI_IP4_CONFIG protocol.\r
- //\r
- for (Index = 0; Index < Data->RouteTableSize; Index++) {\r
- RouteEntry = &Data->RouteTable[Index];\r