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