1 /* $FreeBSD$ */
2 /** @file
3   This file provides a definition of the EFI IPv4 Configuration II
4   Protocol.
5 
6 Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
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<BR>
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 @par Revision Reference:
16 This Protocol is introduced in UEFI Specification 2.5
17 
18 **/
19 #ifndef __EFI_IP4CONFIG2_PROTOCOL_H__
20 #define __EFI_IP4CONFIG2_PROTOCOL_H__
21 
22 /* #include <Protocol/Ip4.h> */
23 
24 #define EFI_IP4_CONFIG2_PROTOCOL_GUID \
25   { \
26     0x5b446ed1, 0xe30b, 0x4faa, {0x87, 0x1a, 0x36, 0x54, 0xec, 0xa3, 0x60, 0x80 } \
27   }
28 
29 typedef struct _EFI_IP4_CONFIG2_PROTOCOL EFI_IP4_CONFIG2_PROTOCOL;
30 
31 
32 ///
33 /// EFI_IP4_CONFIG2_DATA_TYPE
34 ///
35 typedef enum {
36   ///
37   /// The interface information of the communication device this EFI
38   /// IPv4 Configuration II Protocol instance manages. This type of
39   /// data is read only. The corresponding Data is of type
40   /// EFI_IP4_CONFIG2_INTERFACE_INFO.
41   ///
42   Ip4Config2DataTypeInterfaceInfo,
43   ///
44   /// The general configuration policy for the EFI IPv4 network stack
45   /// running on the communication device this EFI IPv4
46   /// Configuration II Protocol instance manages. The policy will
47   /// affect other configuration settings. The corresponding Data is of
48   /// type EFI_IP4_CONFIG2_POLICY.
49   ///
50   Ip4Config2DataTypePolicy,
51   ///
52   /// The station addresses set manually for the EFI IPv4 network
53   /// stack. It is only configurable when the policy is
54   /// Ip4Config2PolicyStatic. The corresponding Data is of
55   /// type EFI_IP4_CONFIG2_MANUAL_ADDRESS. When DataSize
56   /// is 0 and Data is NULL, the existing configuration is cleared
57   /// from the EFI IPv4 Configuration II Protocol instance.
58   ///
59   Ip4Config2DataTypeManualAddress,
60   ///
61   /// The gateway addresses set manually for the EFI IPv4 network
62   /// stack running on the communication device this EFI IPv4
63   /// Configuration II Protocol manages. It is not configurable when
64   /// the policy is Ip4Config2PolicyDhcp. The gateway
65   /// addresses must be unicast IPv4 addresses. The corresponding
66   /// Data is a pointer to an array of EFI_IPv4_ADDRESS instances.
67   /// When DataSize is 0 and Data is NULL, the existing configuration
68   /// is cleared from the EFI IPv4 Configuration II Protocol instance.
69   ///
70   Ip4Config2DataTypeGateway,
71   ///
72   /// The DNS server list for the EFI IPv4 network stack running on
73   /// the communication device this EFI IPv4 Configuration II
74   /// Protocol manages. It is not configurable when the policy is
75   /// Ip4Config2PolicyDhcp. The DNS server addresses must be
76   /// unicast IPv4 addresses. The corresponding Data is a pointer to
77   /// an array of EFI_IPv4_ADDRESS instances. When DataSize
78   /// is 0 and Data is NULL, the existing configuration is cleared
79   /// from the EFI IPv4 Configuration II Protocol instance.
80   ///
81   Ip4Config2DataTypeDnsServer,
82   Ip4Config2DataTypeMaximum
83 } EFI_IP4_CONFIG2_DATA_TYPE;
84 
85 ///
86 /// EFI_IP4_CONFIG2_INTERFACE_INFO related definitions
87 ///
88 #define EFI_IP4_CONFIG2_INTERFACE_INFO_NAME_SIZE 32
89 
90 ///
91 /// EFI_IP4_CONFIG2_INTERFACE_INFO
92 ///
93 typedef struct {
94   ///
95   /// The name of the interface. It is a NULL-terminated Unicode string.
96   ///
97   CHAR16                Name[EFI_IP4_CONFIG2_INTERFACE_INFO_NAME_SIZE];
98   ///
99   /// The interface type of the network interface. See RFC 1700,
100   /// section "Number Hardware Type".
101   ///
102   UINT8                 IfType;
103   ///
104   /// The size, in bytes, of the network interface's hardware address.
105   ///
106   UINT32                HwAddressSize;
107   ///
108   /// The hardware address for the network interface.
109   ///
110   EFI_MAC_ADDRESS       HwAddress;
111   ///
112   /// The station IPv4 address of this EFI IPv4 network stack.
113   ///
114   EFI_IPv4_ADDRESS      StationAddress;
115   ///
116   /// The subnet address mask that is associated with the station address.
117   ///
118   EFI_IPv4_ADDRESS      SubnetMask;
119   ///
120   /// Size of the following RouteTable, in bytes. May be zero.
121   ///
122   UINT32                RouteTableSize;
123   ///
124   /// The route table of the IPv4 network stack runs on this interface.
125   /// Set to NULL if RouteTableSize is zero. Type EFI_IP4_ROUTE_TABLE is defined in
126   /// EFI_IP4_PROTOCOL.GetModeData().
127   ///
128   EFI_IP4_ROUTE_TABLE   *RouteTable     OPTIONAL;
129 } EFI_IP4_CONFIG2_INTERFACE_INFO;
130 
131 ///
132 /// EFI_IP4_CONFIG2_POLICY
133 ///
134 typedef enum {
135   ///
136   /// Under this policy, the Ip4Config2DataTypeManualAddress,
137   /// Ip4Config2DataTypeGateway and Ip4Config2DataTypeDnsServer configuration
138   /// data are required to be set manually. The EFI IPv4 Protocol will get all
139   /// required configuration such as IPv4 address, subnet mask and
140   /// gateway settings from the EFI IPv4 Configuration II protocol.
141   ///
142   Ip4Config2PolicyStatic,
143   ///
144   /// Under this policy, the Ip4Config2DataTypeManualAddress,
145   /// Ip4Config2DataTypeGateway and Ip4Config2DataTypeDnsServer configuration data are
146   /// not allowed to set via SetData(). All of these configurations are retrieved from DHCP
147   /// server or other auto-configuration mechanism.
148   ///
149   Ip4Config2PolicyDhcp,
150   Ip4Config2PolicyMax
151 } EFI_IP4_CONFIG2_POLICY;
152 
153 ///
154 /// EFI_IP4_CONFIG2_MANUAL_ADDRESS
155 ///
156 typedef struct {
157   ///
158   /// The IPv4 unicast address.
159   ///
160   EFI_IPv4_ADDRESS        Address;
161   ///
162   /// The subnet mask.
163   ///
164   EFI_IPv4_ADDRESS        SubnetMask;
165 } EFI_IP4_CONFIG2_MANUAL_ADDRESS;
166 
167 /**
168   Set the configuration for the EFI IPv4 network stack running on the communication device this EFI
169   IPv4 Configuration II Protocol instance manages.
170 
171   This function is used to set the configuration data of type DataType for the EFI IPv4 network stack
172   running on the communication device this EFI IPv4 Configuration II Protocol instance manages.
173   The successfully configured data is valid after system reset or power-off.
174   The DataSize is used to calculate the count of structure instances in the Data for some
175   DataType that multiple structure instances are allowed.
176   This function is always non-blocking. When setting some typeof configuration data, an
177   asynchronous process is invoked to check the correctness of the data, such as doing address conflict
178   detection on the manually set local IPv4 address. EFI_NOT_READY is returned immediately to
179   indicate that such an asynchronous process is invoked and the process is not finished yet. The caller
180   willing to get the result of the asynchronous process is required to call RegisterDataNotify()
181   to register an event on the specified configuration data. Once the event is signaled, the caller can call
182   GetData()to get back the configuration data in order to know the result. For other types of
183   configuration data that do not require an asynchronous configuration process, the result of the
184   operation is immediately returned.
185 
186   @param[in]   This               Pointer to the EFI_IP4_CONFIG2_PROTOCOL instance.
187   @param[in]   DataType           The type of data to set.
188   @param[in]   DataSize           Size of the buffer pointed to by Data in bytes.
189   @param[in]   Data               The data buffer to set. The type ofthe data buffer is associated
190                                   with the DataType.
191 
192   @retval EFI_SUCCESS             The specified configuration data for the EFI IPv4 network stack is set
193                                   successfully.
194   @retval EFI_INVALID_PARAMETER   One or more of the following are TRUE:
195                                   This is NULL.
196                                   One or more fields in Data and DataSize do not match the
197                                   requirement of the data type indicated by DataType.
198   @retval EFI_WRITE_PROTECTED     The specified configuration data is read-only or the specified configuration
199                                   data can not be set under the current policy.
200   @retval EFI_ACCESS_DENIED       Another set operation on the specified configuration data is already in process.
201   @retval EFI_NOT_READY           An asynchronous process is invoked to set the specified configuration data and
202                                   the process is not finished yet.
203   @retval EFI_BAD_BUFFER_SIZE     The DataSize does not match the size of the type indicated by DataType.
204   @retval EFI_UNSUPPORTED         This DataType is not supported.
205   @retval EFI_OUT_OF_RESOURCES    Required system resources could not be allocated.
206   @retval EFI_DEVICE_ERROR        An unexpected system error or network error occurred.
207 **/
208 typedef
209 EFI_STATUS
210 (EFIAPI *EFI_IP4_CONFIG2_SET_DATA) (
211   IN EFI_IP4_CONFIG2_PROTOCOL   *This,
212   IN EFI_IP4_CONFIG2_DATA_TYPE  DataType,
213   IN UINTN                      DataSize,
214   IN VOID                       *Data
215   );
216 
217 /**
218   Get the configuration data for the EFI IPv4 network stack running on the communication device this
219   EFI IPv4 Configuration II Protocol instance manages.
220 
221   This function returns the configuration data of type DataType for the EFI IPv4 network stack
222   running on the communication device this EFI IPv4 Configuration II Protocol instance manages.
223   The caller is responsible for allocating the buffer usedto return the specified configuration data and
224   the required size will be returned to the caller if the size of the buffer is too small.
225   EFI_NOT_READY is returned if the specified configuration data is not ready due to an already in
226   progress asynchronous configuration process. The caller can call RegisterDataNotify() to
227   register an event on the specified configuration data. Once the asynchronous configuration process is
228   finished, the event will be signaled and a subsequent GetData() call will return the specified
229   configuration data.
230 
231   @param[in]   This               Pointer to the EFI_IP4_CONFIG2_PROTOCOL instance.
232   @param[in]   DataType           The type of data to get.
233   @param[out]  DataSize           On input, in bytes, the size of Data. On output, in bytes, the size
234                                   of buffer required to store the specified configuration data.
235   @param[in]   Data               The data buffer in which the configuration data is returned. The
236                                   type of the data buffer is associated with the DataType. Ignored
237                                   if DataSize is 0.
238 
239   @retval EFI_SUCCESS             The specified configuration data is got successfully.
240   @retval EFI_INVALID_PARAMETER   One or more of the followings are TRUE:
241                                   This is NULL.
242                                   DataSize is NULL.
243                                   Data is NULL if *DataSizeis not zero.
244   @retval EFI_BUFFER_TOO_SMALL    The size of Data is too small for the specified configuration data
245                                   and the required size is returned in DataSize.
246   @retval EFI_NOT_READY           The specified configuration data is not ready due to an already in
247                                   progress asynchronous configuration process.
248   @retval EFI_NOT_FOUND           The specified configuration data is not found.
249 **/
250 typedef
251 EFI_STATUS
252 (EFIAPI *EFI_IP4_CONFIG2_GET_DATA) (
253   IN EFI_IP4_CONFIG2_PROTOCOL     *This,
254   IN EFI_IP4_CONFIG2_DATA_TYPE    DataType,
255   IN OUT UINTN                    *DataSize,
256   IN VOID                         *Data        OPTIONAL
257   );
258 
259 /**
260   Register an event that is to be signaled whenever a configuration process on the specified
261   configuration data is done.
262 
263   This function registers an event that is to be signaled whenever a configuration process on the
264   specified configuration data is done. An event can be registered for different DataType
265   simultaneously and the caller is responsible for determining which type of configuration data causes
266   the signaling of the event in such case.
267 
268   @param[in]   This               Pointer to the EFI_IP4_CONFIG2_PROTOCOL instance.
269   @param[in]   DataType           The type of data to unregister the event for.
270   @param[in]   Event              The event to register.
271 
272   @retval EFI_SUCCESS             The notification event for the specified configuration data is
273                                   registered.
274   @retval EFI_INVALID_PARAMETER   This is NULL or Event is NULL.
275   @retval EFI_UNSUPPORTED         The configuration data type specified by DataType is not supported.
276   @retval EFI_OUT_OF_RESOURCES    Required system resources could not be allocated.
277   @retval EFI_ACCESS_DENIED       The Event is already registered for the DataType.
278 **/
279 typedef
280 EFI_STATUS
281 (EFIAPI *EFI_IP4_CONFIG2_REGISTER_NOTIFY) (
282   IN EFI_IP4_CONFIG2_PROTOCOL     *This,
283   IN EFI_IP4_CONFIG2_DATA_TYPE    DataType,
284   IN EFI_EVENT                    Event
285   );
286 
287 /**
288   Remove a previously registered event for the specified configuration data.
289 
290   This function removes a previously registeredevent for the specified configuration data.
291 
292   @param[in]   This               Pointer to the EFI_IP4_CONFIG2_PROTOCOL instance.
293   @param[in]   DataType           The type of data to remove the previously registered event for.
294   @param[in]   Event              The event to unregister.
295 
296   @retval EFI_SUCCESS             The event registered for the specified configuration data is removed.
297   @retval EFI_INVALID_PARAMETER   This is NULL or Event is NULL.
298   @retval EFI_NOT_FOUND           The Eventhas not been registered for the specified DataType.
299 **/
300 typedef
301 EFI_STATUS
302 (EFIAPI *EFI_IP4_CONFIG2_UNREGISTER_NOTIFY) (
303   IN EFI_IP4_CONFIG2_PROTOCOL     *This,
304   IN EFI_IP4_CONFIG2_DATA_TYPE    DataType,
305   IN EFI_EVENT                    Event
306   );
307 
308 ///
309 /// The EFI_IP4_CONFIG2_PROTOCOL is designed to be the central repository for the common
310 /// configurations and the administrator configurable settings for the EFI IPv4 network stack.
311 /// An EFI IPv4 Configuration II Protocol instance will be installed on each communication device that
312 /// the EFI IPv4 network stack runs on.
313 ///
314 struct _EFI_IP4_CONFIG2_PROTOCOL {
315   EFI_IP4_CONFIG2_SET_DATA           SetData;
316   EFI_IP4_CONFIG2_GET_DATA           GetData;
317   EFI_IP4_CONFIG2_REGISTER_NOTIFY    RegisterDataNotify;
318   EFI_IP4_CONFIG2_UNREGISTER_NOTIFY  UnregisterDataNotify;
319 };
320 
321 extern EFI_GUID gEfiIp4Config2ProtocolGuid;
322 
323 #endif
324 
325