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