Helper.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /** @file
  2. The assistant function declaration for IpSecConfig application.
  3. Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef _HELPER_H_
  7. #define _HELPER_H_
  8. #define FORMAT_NUMBER 0x1
  9. #define FORMAT_STRING 0x2
  10. /**
  11. Helper function called to change input parameter in string format to number.
  12. @param[in] FlagStr The pointer to the flag string.
  13. @param[in] Maximum most value number.
  14. @param[in, out] ValuePtr The pointer to the input parameter in string format.
  15. @param[in] ByteCount The valid byte count
  16. @param[in] Map The pointer to the STR2INT table.
  17. @param[in] ParamPackage The pointer to the ParamPackage list.
  18. @param[in] FormatMask The bit mask.
  19. BIT 0 set indicates the value of flag might be number.
  20. BIT 1 set indicates the value of flag might be a string that needs to be looked up.
  21. @retval EFI_SUCCESS The operation completed successfully.
  22. @retval EFI_NOT_FOUND The input parameter can't be found.
  23. @retval EFI_INVALID_PARAMETER The input parameter is an invalid input.
  24. **/
  25. EFI_STATUS
  26. GetNumber (
  27. IN CHAR16 *FlagStr,
  28. IN UINT64 Maximum,
  29. IN OUT VOID *ValuePtr,
  30. IN UINTN ByteCount,
  31. IN STR2INT *Map,
  32. IN LIST_ENTRY *ParamPackage,
  33. IN UINT32 FormatMask
  34. );
  35. /**
  36. Helper function called to convert a string containing an (Ipv4) Internet Protocol dotted address
  37. into a proper address for the EFI_IP_ADDRESS structure.
  38. @param[in] Ptr The pointer to the string containing an (Ipv4) Internet Protocol dotted address.
  39. @param[out] Ip The pointer to the Ip address structure to contain the result.
  40. @retval EFI_SUCCESS The operation completed successfully.
  41. @retval EFI_INVALID_PARAMETER Invalid parameter.
  42. **/
  43. EFI_STATUS
  44. EfiInetAddr2 (
  45. IN CHAR16 *Ptr,
  46. OUT EFI_IP_ADDRESS *Ip
  47. );
  48. /**
  49. Helper function called to calculate the prefix length associated with the string
  50. containing an Ipv4 or Ipv6 Internet Protocol address.
  51. @param[in] Ptr The pointer to the string containing an Ipv4 or Ipv6 Internet Protocol address.
  52. @param[out] Addr The pointer to the EFI_IP_ADDRESS_INFO structure to contain the result.
  53. @retval EFI_SUCCESS The operation completed successfully.
  54. @retval EFI_INVALID_PARAMETER Invalid parameter.
  55. @retval Others Other mistake case.
  56. **/
  57. EFI_STATUS
  58. EfiInetAddrRange (
  59. IN CHAR16 *Ptr,
  60. OUT EFI_IP_ADDRESS_INFO *Addr
  61. );
  62. /**
  63. Helper function called to calculate the port range associated with the string.
  64. @param[in] Ptr The pointer to the string containing a port and range.
  65. @param[out] Port The pointer to the Port to contain the result.
  66. @param[out] PortRange The pointer to the PortRange to contain the result.
  67. @retval EFI_SUCCESS The operation completed successfully.
  68. @retval EFI_INVALID_PARAMETER Invalid parameter.
  69. @retval Others Other mistake case.
  70. **/
  71. EFI_STATUS
  72. EfiInetPortRange (
  73. IN CHAR16 *Ptr,
  74. OUT UINT16 *Port,
  75. OUT UINT16 *PortRange
  76. );
  77. /**
  78. Helper function called to transfer a string to an unsigned integer.
  79. @param[in] Str The pointer to the string.
  80. @param[out] Status The operation status.
  81. @return The integer value of a converted str.
  82. **/
  83. UINT64
  84. StrToUInteger (
  85. IN CONST CHAR16 *Str,
  86. OUT EFI_STATUS *Status
  87. );
  88. /**
  89. Helper function called to transfer a string to an unsigned integer according to the map table.
  90. @param[in] Str The pointer to the string.
  91. @param[in] Map The pointer to the map table.
  92. @return The integer value of converted str. If not found, then return -1.
  93. **/
  94. UINT32
  95. MapStringToInteger (
  96. IN CONST CHAR16 *Str,
  97. IN STR2INT *Map
  98. );
  99. /**
  100. Helper function called to transfer an unsigned integer to a string according to the map table.
  101. @param[in] Integer The pointer to the string.
  102. @param[in] Map The pointer to the map table.
  103. @return The converted str. If not found, then return NULL.
  104. **/
  105. CHAR16 *
  106. MapIntegerToString (
  107. IN UINT32 Integer,
  108. IN STR2INT *Map
  109. );
  110. #endif