• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /** @file
2   Definitions for EFI IPv4 Configuration II Protocol implementation.
3 
4   Copyright (c) 2015, 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 DHCP_TAG_PARA_LIST             55
29 #define DHCP_TAG_NETMASK               1
30 #define DHCP_TAG_ROUTER                3
31 #define DHCP_TAG_DNS_SERVER            6
32 
33 #define DATA_ATTRIB_SET(Attrib, Bits)       (BOOLEAN)((Attrib) & (Bits))
34 #define SET_DATA_ATTRIB(Attrib, Bits)       ((Attrib) |= (Bits))
35 
36 typedef struct _IP4_CONFIG2_INSTANCE IP4_CONFIG2_INSTANCE;
37 
38 #define IP4_CONFIG2_INSTANCE_FROM_PROTOCOL(Proto) \
39   CR ((Proto), \
40       IP4_CONFIG2_INSTANCE, \
41       Ip4Config2, \
42       IP4_CONFIG2_INSTANCE_SIGNATURE \
43       )
44 
45 #define IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE(Instance) \
46   CR ((Instance), \
47       IP4_SERVICE, \
48       Ip4Config2Instance, \
49       IP4_SERVICE_SIGNATURE \
50       )
51 
52 #define IP4_CONFIG2_INSTANCE_FROM_FORM_CALLBACK(Callback) \
53   CR ((Callback), \
54       IP4_CONFIG2_INSTANCE, \
55       CallbackInfo, \
56       IP4_CONFIG2_INSTANCE_SIGNATURE \
57       )
58 
59 #define IP4_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS(ConfigAccess) \
60   CR ((ConfigAccess), \
61       IP4_FORM_CALLBACK_INFO, \
62       HiiConfigAccessProtocol, \
63       IP4_FORM_CALLBACK_INFO_SIGNATURE \
64       )
65 
66 /**
67   The prototype of work function for EfiIp4Config2SetData().
68 
69   @param[in]     Instance The pointer to the IP4 config2 instance data.
70   @param[in]     DataSize In bytes, the size of the buffer pointed to by Data.
71   @param[in]     Data     The data buffer to set.
72 
73   @retval EFI_BAD_BUFFER_SIZE  The DataSize does not match the size of the type,
74                                8 bytes.
75   @retval EFI_SUCCESS          The specified configuration data for the EFI IPv4
76                                network stack was set successfully.
77 
78 **/
79 typedef
80 EFI_STATUS
81 (*IP4_CONFIG2_SET_DATA) (
82   IN IP4_CONFIG2_INSTANCE *Instance,
83   IN UINTN                DataSize,
84   IN VOID                 *Data
85   );
86 
87 /**
88   The prototype of work function for EfiIp4Config2GetData().
89 
90   @param[in]      Instance The pointer to the IP4 config2 instance data.
91   @param[in, out] DataSize On input, in bytes, the size of Data. On output, in
92                            bytes, the size of buffer required to store the specified
93                            configuration data.
94   @param[in]      Data     The data buffer in which the configuration data is returned.
95                            Ignored if DataSize is ZERO.
96 
97   @retval EFI_BUFFER_TOO_SMALL The size of Data is too small for the specified
98                                configuration data, and the required size is
99                                returned in DataSize.
100   @retval EFI_SUCCESS          The specified configuration data was obtained successfully.
101 
102 **/
103 typedef
104 EFI_STATUS
105 (*IP4_CONFIG2_GET_DATA) (
106   IN IP4_CONFIG2_INSTANCE *Instance,
107   IN OUT UINTN            *DataSize,
108   IN VOID                 *Data      OPTIONAL
109   );
110 
111 typedef union {
112   VOID                                      *Ptr;
113   EFI_IP4_CONFIG2_INTERFACE_INFO            *IfInfo;
114   EFI_IP4_CONFIG2_POLICY                    *Policy;
115   EFI_IP4_CONFIG2_MANUAL_ADDRESS            *ManualAddress;
116   EFI_IPv4_ADDRESS                          *Gateway;
117   EFI_IPv4_ADDRESS                          *DnsServers;
118 } IP4_CONFIG2_DATA;
119 
120 typedef struct {
121   IP4_CONFIG2_SET_DATA SetData;
122   IP4_CONFIG2_GET_DATA GetData;
123   EFI_STATUS           Status;
124   UINT8                Attribute;
125   NET_MAP              EventMap;
126   IP4_CONFIG2_DATA     Data;
127   UINTN                DataSize;
128 } IP4_CONFIG2_DATA_ITEM;
129 
130 typedef struct {
131   UINT16                    Offset;
132   UINT32                    DataSize;
133   EFI_IP4_CONFIG2_DATA_TYPE DataType;
134 } IP4_CONFIG2_DATA_RECORD;
135 
136 #pragma pack(1)
137 
138 //
139 // heap data that contains the data for each data record.
140 //
141 //  EFI_IP4_CONFIG2_POLICY                    Policy;
142 //  UINT32                                    ManualaddressCount;
143 //  UINT32                                    GatewayCount;
144 //  UINT32                                    DnsServersCount;
145 //  EFI_IP4_CONFIG2_MANUAL_ADDRESS            ManualAddress[];
146 //  EFI_IPv4_ADDRESS                          Gateway[];
147 //  EFI_IPv4_ADDRESS                          DnsServers[];
148 //
149 typedef struct {
150   UINT16                  Checksum;
151   UINT16                  DataRecordCount;
152   IP4_CONFIG2_DATA_RECORD DataRecord[1];
153 } IP4_CONFIG2_VARIABLE;
154 
155 #pragma pack()
156 
157 typedef struct {
158   EFI_IP4_CONFIG2_POLICY                   Policy;               ///< manual or automatic
159   EFI_IP4_CONFIG2_MANUAL_ADDRESS           *ManualAddress;       ///< IP addresses
160   UINT32                                   ManualAddressCount;   ///< IP addresses count
161   EFI_IPv4_ADDRESS                         *GatewayAddress;      ///< Gateway address
162   UINT32                                   GatewayAddressCount;  ///< Gateway address count
163   EFI_IPv4_ADDRESS                         *DnsAddress;          ///< DNS server address
164   UINT32                                   DnsAddressCount;      ///< DNS server address count
165 } IP4_CONFIG2_NVDATA;
166 
167 typedef struct _IP4_FORM_CALLBACK_INFO {
168   UINT32                           Signature;
169   EFI_HANDLE                       ChildHandle;
170   EFI_HII_CONFIG_ACCESS_PROTOCOL   HiiConfigAccessProtocol;
171   EFI_DEVICE_PATH_PROTOCOL         *HiiVendorDevicePath;
172   EFI_HII_HANDLE                   RegisteredHandle;
173 } IP4_FORM_CALLBACK_INFO;
174 
175 struct _IP4_CONFIG2_INSTANCE {
176   UINT32                                    Signature;
177   BOOLEAN                                   Configured;
178   LIST_ENTRY                                Link;
179   UINT16                                    IfIndex;
180 
181   EFI_IP4_CONFIG2_PROTOCOL                  Ip4Config2;
182 
183   EFI_IP4_CONFIG2_INTERFACE_INFO            InterfaceInfo;
184   EFI_IP4_CONFIG2_POLICY                    Policy;
185   IP4_CONFIG2_DATA_ITEM                     DataItem[Ip4Config2DataTypeMaximum];
186 
187   EFI_EVENT                                 Dhcp4SbNotifyEvent;
188   VOID                                      *Registration;
189   EFI_HANDLE                                Dhcp4Handle;
190   EFI_DHCP4_PROTOCOL                        *Dhcp4;
191   BOOLEAN                                   DhcpSuccess;
192   BOOLEAN                                   OtherInfoOnly;
193   EFI_EVENT                                 Dhcp4Event;
194   UINT32                                    FailedIaAddressCount;
195   EFI_IPv4_ADDRESS                          *DeclineAddress;
196   UINT32                                    DeclineAddressCount;
197 
198   IP4_FORM_CALLBACK_INFO                    CallbackInfo;
199 
200   IP4_CONFIG2_NVDATA                        Ip4NvData;
201 };
202 
203 //
204 // Configure the DHCP to request the routers and netmask
205 // from server. The DHCP_TAG_NETMASK is included in Head.
206 //
207 #pragma pack(1)
208 typedef struct {
209   EFI_DHCP4_PACKET_OPTION Head;
210   UINT8                   Route;
211   UINT8                   Dns;
212 } IP4_CONFIG2_DHCP4_OPTION;
213 #pragma pack()
214 
215 /**
216   Start the DHCP configuration for this IP service instance.
217   It will locates the EFI_IP4_CONFIG2_PROTOCOL, then start the
218   DHCP configuration.
219 
220   @param[in]  Instance           The IP4 config2 instance to configure.
221 
222   @retval EFI_SUCCESS            The auto configuration is successfull started.
223   @retval Others                 Failed to start auto configuration.
224 
225 **/
226 EFI_STATUS
227 Ip4StartAutoConfig (
228   IN IP4_CONFIG2_INSTANCE   *Instance
229   );
230 
231 /**
232   Initialize an IP4_CONFIG2_INSTANCE.
233 
234   @param[out]    Instance       The buffer of IP4_CONFIG2_INSTANCE to be initialized.
235 
236   @retval EFI_OUT_OF_RESOURCES  Failed to allocate resources to complete the operation.
237   @retval EFI_SUCCESS           The IP4_CONFIG2_INSTANCE initialized successfully.
238 
239 **/
240 EFI_STATUS
241 Ip4Config2InitInstance (
242   OUT IP4_CONFIG2_INSTANCE  *Instance
243   );
244 
245 /**
246   Release an IP4_CONFIG2_INSTANCE.
247 
248   @param[in, out] Instance    The buffer of IP4_CONFIG2_INSTANCE to be freed.
249 
250 **/
251 VOID
252 Ip4Config2CleanInstance (
253   IN OUT IP4_CONFIG2_INSTANCE  *Instance
254   );
255 
256 /**
257   Destroy the Dhcp4 child in IP4_CONFIG2_INSTANCE and release the resources.
258 
259   @param[in, out] Instance    The buffer of IP4 config2 instance to be freed.
260 
261   @retval EFI_SUCCESS         The child was successfully destroyed.
262   @retval Others              Failed to destroy the child.
263 
264 **/
265 EFI_STATUS
266 Ip4Config2DestroyDhcp4 (
267   IN OUT IP4_CONFIG2_INSTANCE  *Instance
268   );
269 
270 #endif
271