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