/** Get the NIC's configure information from the IP4 configure variable. It will remove the invalid variable. @param Instance The IP4 CONFIG instance. @return NULL if no configure for the NIC in the variable, or it is invalid. Otherwise the pointer to the NIC's IP configure parameter will be returned. **/ NIC_IP4_CONFIG_INFO * EfiNicIp4ConfigGetInfo ( IN IP4_CONFIG_INSTANCE *Instance ) { NIC_IP4_CONFIG_INFO *NicConfig; // // Read the configuration parameter for this NIC from // the EFI variable // NicConfig = Ip4ConfigReadVariable (Instance); if (NicConfig == NULL) { return NULL; } // // Validate the configuration, if the configuration is invalid, // remove it from the variable. // if (!Ip4ConfigIsValid (NicConfig)) { Ip4ConfigWriteVariable (Instance, NULL); FreePool (NicConfig); NicConfig = NULL; } return NicConfig; }
/** Get the NIC's configure information from the IP4 configure variable. It will remove the invalid variable. @param NicAddr The NIC to check @return NULL if no configure for the NIC in the variable, or it is invalid. Otherwise the pointer to the NIC's IP configure parameter will be returned. **/ NIC_IP4_CONFIG_INFO * Ip4ConfigGetNicInfo ( IN NIC_ADDR *NicAddr ) { IP4_CONFIG_VARIABLE *Variable; IP4_CONFIG_VARIABLE *NewVariable; NIC_IP4_CONFIG_INFO *Config; // // Read the configuration parameter for this NicAddr from // the EFI variable // Variable = Ip4ConfigReadVariable (); if (Variable == NULL) { return NULL; } Config = Ip4ConfigFindNicVariable (Variable, NicAddr); if (Config == NULL) { FreePool (Variable); return NULL; } // // Validate the configuration, if the configuration is invalid, // remove it from the variable. // if (!Ip4ConfigIsValid (Config)) { NewVariable = Ip4ConfigModifyVariable (Variable, &Config->NicAddr, NULL); Ip4ConfigWriteVariable (NewVariable); if (NewVariable != NULL) { FreePool (NewVariable); }; FreePool (Config); Config = NULL; } FreePool (Variable); return Config; }