/** Extract the client interested options, all the parameters are converted to host byte order. @param[in] Tag The DHCP option tag @param[in] Len The length of the option @param[in] Data The value of the DHCP option @param[out] Para The variable to save the interested parameter @retval EFI_SUCCESS The DHCP option is successfully extracted. @retval EFI_INVALID_PARAMETER The DHCP option is mal-formated **/ EFI_STATUS DhcpGetParameter ( IN UINT8 Tag, IN INTN Len, IN UINT8 *Data, OUT DHCP_PARAMETER *Para ) { switch (Tag) { case DHCP_TAG_NETMASK: Para->NetMask = NetGetUint32 (Data); break; case DHCP_TAG_ROUTER: // // Return the first router to consumer which is the preferred one // Para->Router = NetGetUint32 (Data); break; case DHCP_TAG_LEASE: Para->Lease = NetGetUint32 (Data); break; case DHCP_TAG_OVERLOAD: Para->Overload = *Data; if ((Para->Overload < 1) || (Para->Overload > 3)) { return EFI_INVALID_PARAMETER; } break; case DHCP_TAG_TYPE: Para->DhcpType = *Data; if ((Para->DhcpType < 1) || (Para->DhcpType > 9)) { return EFI_INVALID_PARAMETER; } break; case DHCP_TAG_SERVER_ID: Para->ServerId = NetGetUint32 (Data); break; case DHCP_TAG_T1: Para->T1 = NetGetUint32 (Data); break; case DHCP_TAG_T2: Para->T2 = NetGetUint32 (Data); break; } return EFI_SUCCESS; }
STATIC EFI_STATUS DhcpGetParameter ( IN UINT8 Tag, IN INTN Len, IN UINT8 *Data, IN DHCP_PARAMETER *Para ) /*++ Routine Description: Extract the client interested options, all the parameters are converted to host byte order. Arguments: Tag - The DHCP option tag Len - The length of the option Data - The value of the DHCP option Para - The variable to save the interested parameter Returns: EFI_SUCCESS - The DHCP option is successfully extracted. EFI_INVALID_PARAMETER - The DHCP option is mal-formated --*/ { switch (Tag) { case DHCP_TAG_NETMASK: Para->NetMask = NetGetUint32 (Data); break; case DHCP_TAG_ROUTER: // // Return the first router to consumer which is the preferred one // Para->Router = NetGetUint32 (Data); break; case DHCP_TAG_LEASE: Para->Lease = NetGetUint32 (Data); break; case DHCP_TAG_OVERLOAD: Para->Overload = *Data; if ((Para->Overload < 1) || (Para->Overload > 3)) { return EFI_INVALID_PARAMETER; } break; case DHCP_TAG_TYPE: Para->DhcpType = *Data; if ((Para->DhcpType < 1) || (Para->DhcpType > 9)) { return EFI_INVALID_PARAMETER; } break; case DHCP_TAG_SERVER_ID: Para->ServerId = NetGetUint32 (Data); break; case DHCP_TAG_T1: Para->T1 = NetGetUint32 (Data); break; case DHCP_TAG_T2: Para->T2 = NetGetUint32 (Data); break; } return EFI_SUCCESS; }