コード例 #1
0
/**
  Convert the network configuration data into the IFR data.

  @param[in]   Ip4ConfigInstance The IP4Config instance
  @param[out]  IfrFormNvData     The IFR nv data.
**/
VOID
Ip4ConfigConvertDeviceConfigDataToIfrNvData (
  IN  IP4_CONFIG_INSTANCE       *Ip4ConfigInstance,
  OUT IP4_CONFIG_IFR_NVDATA     *IfrFormNvData
  )
{
  EFI_STATUS                    Status;
  NIC_IP4_CONFIG_INFO           *NicConfig;
  UINTN                         ConfigLen;

  ConfigLen = sizeof (NIC_IP4_CONFIG_INFO) + sizeof (EFI_IP4_ROUTE_TABLE) * 2;
  NicConfig = AllocateZeroPool (ConfigLen);
  ASSERT (NicConfig != NULL);
  Status = EfiNicIp4ConfigGetInfo (Ip4ConfigInstance, &ConfigLen, NicConfig);
  if (!EFI_ERROR (Status)) {
    IfrFormNvData->Configure = 1;
    if (NicConfig->Source == IP4_CONFIG_SOURCE_DHCP) {
      IfrFormNvData->DhcpEnable = 1;
    } else {
      IfrFormNvData->DhcpEnable = 0;
      Ip4ConfigIpToStr (&NicConfig->Ip4Info.StationAddress, IfrFormNvData->StationAddress);
      Ip4ConfigIpToStr (&NicConfig->Ip4Info.SubnetMask, IfrFormNvData->SubnetMask);
      Ip4ConfigIpToStr (&NicConfig->Ip4Info.RouteTable[1].GatewayAddress, IfrFormNvData->GatewayAddress);
    }
  } else {
    IfrFormNvData->Configure = 0;
  }

  FreePool (NicConfig);
}
コード例 #2
0
ファイル: Ip4ConfigNv.c プロジェクト: Cutty/edk2
/**
  Convert the network configuration data into the IFR data.

  @param[in]   Ip4ConfigInstance The IP4Config instance
  @param[out]  IfrFormNvData     The IFR nv data.
**/
VOID
Ip4ConfigConvertDeviceConfigDataToIfrNvData (
  IN  IP4_CONFIG_INSTANCE       *Ip4ConfigInstance,
  OUT IP4_CONFIG_IFR_NVDATA     *IfrFormNvData
  )
{
  NIC_IP4_CONFIG_INFO  *NicConfig;

  NicConfig = EfiNicIp4ConfigGetInfo (Ip4ConfigInstance);
  if (NicConfig != NULL) {
    IfrFormNvData->Configure = 1;
    Ip4ConfigInstance->Ip4ConfigCallbackInfo.Configured = TRUE;
    if (NicConfig->Source == IP4_CONFIG_SOURCE_DHCP) {
      IfrFormNvData->DhcpEnable = 1;
      Ip4ConfigInstance->Ip4ConfigCallbackInfo.DhcpEnabled = TRUE;
    } else {
      IfrFormNvData->DhcpEnable = 0;
      Ip4ConfigIpToStr (&NicConfig->Ip4Info.StationAddress, IfrFormNvData->StationAddress);
      Ip4ConfigIpToStr (&NicConfig->Ip4Info.SubnetMask, IfrFormNvData->SubnetMask);
      Ip4ConfigIpToStr (&NicConfig->Ip4Info.RouteTable[1].GatewayAddress, IfrFormNvData->GatewayAddress);

      Ip4ConfigInstance->Ip4ConfigCallbackInfo.DhcpEnabled = FALSE;
      CopyMem (&Ip4ConfigInstance->Ip4ConfigCallbackInfo.LocalIp, &NicConfig->Ip4Info.StationAddress, sizeof (EFI_IPv4_ADDRESS));
      CopyMem (&Ip4ConfigInstance->Ip4ConfigCallbackInfo.SubnetMask, &NicConfig->Ip4Info.SubnetMask, sizeof (EFI_IPv4_ADDRESS));
      CopyMem (&Ip4ConfigInstance->Ip4ConfigCallbackInfo.Gateway, &NicConfig->Ip4Info.RouteTable[1].GatewayAddress, sizeof (EFI_IPv4_ADDRESS));
    }

    FreePool (NicConfig);
  } else {
    IfrFormNvData->Configure = 0;
    Ip4ConfigInstance->Ip4ConfigCallbackInfo.Configured = FALSE;
  }
}