1f6729ff |
1 | /** @file\r |
2 | Definitions for EFI IPv4 Configuration II Protocol implementation.\r |
3 | \r |
4 | Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r |
5 | \r |
6 | This program and the accompanying materials\r |
7 | are licensed and made available under the terms and conditions of the BSD License\r |
8 | which accompanies this distribution. The full text of the license may be found at\r |
9 | http://opensource.org/licenses/bsd-license.php.\r |
10 | \r |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r |
13 | \r |
14 | **/\r |
15 | \r |
16 | #ifndef __IP4_CONFIG2_IMPL_H__\r |
17 | #define __IP4_CONFIG2_IMPL_H__\r |
18 | \r |
19 | #define IP4_CONFIG2_INSTANCE_SIGNATURE SIGNATURE_32 ('I', 'P', 'C', '2')\r |
20 | #define IP4_FORM_CALLBACK_INFO_SIGNATURE SIGNATURE_32 ('I', 'F', 'C', 'I')\r |
21 | \r |
22 | #define IP4_CONFIG2_VARIABLE_ATTRIBUTE (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS)\r |
23 | \r |
24 | #define DATA_ATTRIB_SIZE_FIXED 0x1\r |
25 | #define DATA_ATTRIB_VOLATILE 0x2\r |
26 | \r |
27 | #define DHCP_TAG_PARA_LIST 55\r |
28 | #define DHCP_TAG_NETMASK 1\r |
29 | #define DHCP_TAG_ROUTER 3\r |
30 | \r |
31 | \r |
32 | #define DATA_ATTRIB_SET(Attrib, Bits) (BOOLEAN)((Attrib) & (Bits))\r |
33 | #define SET_DATA_ATTRIB(Attrib, Bits) ((Attrib) |= (Bits))\r |
34 | \r |
35 | typedef struct _IP4_CONFIG2_INSTANCE IP4_CONFIG2_INSTANCE;\r |
36 | \r |
37 | #define IP4_CONFIG2_INSTANCE_FROM_PROTOCOL(Proto) \\r |
38 | CR ((Proto), \\r |
39 | IP4_CONFIG2_INSTANCE, \\r |
40 | Ip4Config2, \\r |
41 | IP4_CONFIG2_INSTANCE_SIGNATURE \\r |
42 | )\r |
43 | \r |
44 | #define IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE(Instance) \\r |
45 | CR ((Instance), \\r |
46 | IP4_SERVICE, \\r |
47 | Ip4Config2Instance, \\r |
48 | IP4_SERVICE_SIGNATURE \\r |
49 | )\r |
50 | \r |
51 | #define IP4_CONFIG2_INSTANCE_FROM_FORM_CALLBACK(Callback) \\r |
52 | CR ((Callback), \\r |
53 | IP4_CONFIG2_INSTANCE, \\r |
54 | CallbackInfo, \\r |
55 | IP4_CONFIG2_INSTANCE_SIGNATURE \\r |
56 | )\r |
57 | \r |
58 | #define IP4_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS(ConfigAccess) \\r |
59 | CR ((ConfigAccess), \\r |
60 | IP4_FORM_CALLBACK_INFO, \\r |
61 | HiiConfigAccessProtocol, \\r |
62 | IP4_FORM_CALLBACK_INFO_SIGNATURE \\r |
63 | )\r |
64 | \r |
65 | /**\r |
66 | The prototype of work function for EfiIp4Config2SetData().\r |
67 | \r |
68 | @param[in] Instance The pointer to the IP4 config2 instance data.\r |
69 | @param[in] DataSize In bytes, the size of the buffer pointed to by Data.\r |
70 | @param[in] Data The data buffer to set.\r |
71 | \r |
72 | @retval EFI_BAD_BUFFER_SIZE The DataSize does not match the size of the type,\r |
73 | 8 bytes.\r |
74 | @retval EFI_SUCCESS The specified configuration data for the EFI IPv4\r |
75 | network stack was set successfully.\r |
76 | \r |
77 | **/\r |
78 | typedef\r |
79 | EFI_STATUS\r |
80 | (*IP4_CONFIG2_SET_DATA) (\r |
81 | IN IP4_CONFIG2_INSTANCE *Instance,\r |
82 | IN UINTN DataSize,\r |
83 | IN VOID *Data\r |
84 | );\r |
85 | \r |
86 | /**\r |
87 | The prototype of work function for EfiIp4Config2GetData().\r |
88 | \r |
89 | @param[in] Instance The pointer to the IP4 config2 instance data.\r |
90 | @param[in, out] DataSize On input, in bytes, the size of Data. On output, in\r |
91 | bytes, the size of buffer required to store the specified\r |
92 | configuration data.\r |
93 | @param[in] Data The data buffer in which the configuration data is returned. \r |
94 | Ignored if DataSize is ZERO.\r |
95 | \r |
96 | @retval EFI_BUFFER_TOO_SMALL The size of Data is too small for the specified\r |
97 | configuration data, and the required size is \r |
98 | returned in DataSize.\r |
99 | @retval EFI_SUCCESS The specified configuration data was obtained successfully. \r |
100 | \r |
101 | **/\r |
102 | typedef\r |
103 | EFI_STATUS\r |
104 | (*IP4_CONFIG2_GET_DATA) (\r |
105 | IN IP4_CONFIG2_INSTANCE *Instance,\r |
106 | IN OUT UINTN *DataSize,\r |
107 | IN VOID *Data OPTIONAL\r |
108 | );\r |
109 | \r |
110 | typedef union {\r |
111 | VOID *Ptr;\r |
112 | EFI_IP4_CONFIG2_INTERFACE_INFO *IfInfo;\r |
113 | EFI_IP4_CONFIG2_POLICY *Policy;\r |
114 | EFI_IP4_CONFIG2_MANUAL_ADDRESS *ManualAddress;\r |
115 | EFI_IPv4_ADDRESS *Gateway;\r |
116 | EFI_IPv4_ADDRESS *DnsServers;\r |
117 | } IP4_CONFIG2_DATA;\r |
118 | \r |
119 | typedef struct {\r |
120 | IP4_CONFIG2_SET_DATA SetData;\r |
121 | IP4_CONFIG2_GET_DATA GetData;\r |
122 | EFI_STATUS Status;\r |
123 | UINT8 Attribute;\r |
124 | NET_MAP EventMap;\r |
125 | IP4_CONFIG2_DATA Data;\r |
126 | UINTN DataSize;\r |
127 | } IP4_CONFIG2_DATA_ITEM;\r |
128 | \r |
129 | typedef struct {\r |
130 | UINT16 Offset;\r |
131 | UINT32 DataSize;\r |
132 | EFI_IP4_CONFIG2_DATA_TYPE DataType;\r |
133 | } IP4_CONFIG2_DATA_RECORD;\r |
134 | \r |
135 | #pragma pack(1)\r |
136 | \r |
137 | //\r |
138 | // heap data that contains the data for each data record.\r |
139 | //\r |
140 | // EFI_IP4_CONFIG2_POLICY Policy;\r |
141 | // UINT32 ManualaddressCount;\r |
142 | // UINT32 GatewayCount;\r |
143 | // UINT32 DnsServersCount;\r |
144 | // EFI_IP4_CONFIG2_MANUAL_ADDRESS ManualAddress[];\r |
145 | // EFI_IPv4_ADDRESS Gateway[];\r |
146 | // EFI_IPv4_ADDRESS DnsServers[];\r |
147 | //\r |
148 | typedef struct {\r |
149 | UINT16 Checksum;\r |
150 | UINT16 DataRecordCount;\r |
151 | IP4_CONFIG2_DATA_RECORD DataRecord[1];\r |
152 | } IP4_CONFIG2_VARIABLE;\r |
153 | \r |
154 | #pragma pack()\r |
155 | \r |
156 | typedef struct {\r |
157 | EFI_IP4_CONFIG2_POLICY Policy; ///< manual or automatic \r |
158 | EFI_IP4_CONFIG2_MANUAL_ADDRESS *ManualAddress; ///< IP addresses\r |
159 | UINT32 ManualAddressCount; ///< IP addresses count\r |
160 | EFI_IPv4_ADDRESS *GatewayAddress; ///< Gateway address\r |
161 | UINT32 GatewayAddressCount; ///< Gateway address count\r |
162 | EFI_IPv4_ADDRESS *DnsAddress; ///< DNS server address\r |
163 | UINT32 DnsAddressCount; ///< DNS server address count\r |
164 | } IP4_CONFIG2_NVDATA;\r |
165 | \r |
166 | typedef struct _IP4_FORM_CALLBACK_INFO {\r |
167 | UINT32 Signature;\r |
168 | EFI_HANDLE ChildHandle;\r |
169 | EFI_HII_CONFIG_ACCESS_PROTOCOL HiiConfigAccessProtocol;\r |
170 | EFI_DEVICE_PATH_PROTOCOL *HiiVendorDevicePath;\r |
171 | EFI_HII_HANDLE RegisteredHandle;\r |
172 | } IP4_FORM_CALLBACK_INFO;\r |
173 | \r |
174 | struct _IP4_CONFIG2_INSTANCE {\r |
175 | UINT32 Signature;\r |
176 | BOOLEAN Configured;\r |
177 | LIST_ENTRY Link;\r |
178 | UINT16 IfIndex;\r |
179 | \r |
180 | EFI_IP4_CONFIG2_PROTOCOL Ip4Config2;\r |
181 | \r |
182 | EFI_IP4_CONFIG2_INTERFACE_INFO InterfaceInfo;\r |
183 | EFI_IP4_CONFIG2_POLICY Policy; \r |
184 | IP4_CONFIG2_DATA_ITEM DataItem[Ip4Config2DataTypeMaximum];\r |
185 | \r |
186 | EFI_EVENT Dhcp4SbNotifyEvent;\r |
187 | VOID *Registration;\r |
188 | EFI_HANDLE Dhcp4Handle;\r |
189 | EFI_DHCP4_PROTOCOL *Dhcp4;\r |
190 | BOOLEAN DhcpSuccess;\r |
191 | BOOLEAN OtherInfoOnly;\r |
192 | EFI_EVENT Dhcp4Event;\r |
193 | UINT32 FailedIaAddressCount;\r |
194 | EFI_IPv4_ADDRESS *DeclineAddress;\r |
195 | UINT32 DeclineAddressCount;\r |
196 | \r |
197 | IP4_FORM_CALLBACK_INFO CallbackInfo;\r |
198 | \r |
199 | IP4_CONFIG2_NVDATA Ip4NvData;\r |
200 | };\r |
201 | \r |
202 | //\r |
203 | // Configure the DHCP to request the routers and netmask\r |
204 | // from server. The DHCP_TAG_NETMASK is included in Head.\r |
205 | //\r |
206 | #pragma pack(1)\r |
207 | typedef struct {\r |
208 | EFI_DHCP4_PACKET_OPTION Head;\r |
209 | UINT8 Route;\r |
210 | } IP4_CONFIG2_DHCP4_OPTION;\r |
211 | #pragma pack()\r |
212 | \r |
213 | /**\r |
214 | Initialize an IP4_CONFIG2_INSTANCE.\r |
215 | \r |
216 | @param[out] Instance The buffer of IP4_CONFIG2_INSTANCE to be initialized.\r |
217 | \r |
218 | @retval EFI_OUT_OF_RESOURCES Failed to allocate resources to complete the operation.\r |
219 | @retval EFI_SUCCESS The IP4_CONFIG2_INSTANCE initialized successfully.\r |
220 | \r |
221 | **/\r |
222 | EFI_STATUS\r |
223 | Ip4Config2InitInstance (\r |
224 | OUT IP4_CONFIG2_INSTANCE *Instance\r |
225 | );\r |
226 | \r |
227 | /**\r |
228 | Release an IP4_CONFIG2_INSTANCE.\r |
229 | \r |
230 | @param[in, out] Instance The buffer of IP4_CONFIG2_INSTANCE to be freed.\r |
231 | \r |
232 | **/\r |
233 | VOID\r |
234 | Ip4Config2CleanInstance (\r |
235 | IN OUT IP4_CONFIG2_INSTANCE *Instance\r |
236 | );\r |
237 | \r |
238 | /**\r |
239 | Destroy the Dhcp4 child in IP4_CONFIG2_INSTANCE and release the resources.\r |
240 | \r |
241 | @param[in, out] Instance The buffer of IP4 config2 instance to be freed.\r |
242 | \r |
243 | @retval EFI_SUCCESS The child was successfully destroyed.\r |
244 | @retval Others Failed to destroy the child.\r |
245 | \r |
246 | **/\r |
247 | EFI_STATUS\r |
248 | Ip4Config2DestroyDhcp4 (\r |
249 | IN OUT IP4_CONFIG2_INSTANCE *Instance\r |
250 | );\r |
251 | \r |
252 | #endif\r |