]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.h
MdeModulePkg: Update Ip4Dxe driver to support Ip4Config2 protocol,
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4Dxe / Ip4Config2Impl.h
diff --git a/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.h b/MdeModulePkg/Universal/Network/Ip4Dxe/Ip4Config2Impl.h
new file mode 100644 (file)
index 0000000..26e16a2
--- /dev/null
@@ -0,0 +1,252 @@
+/** @file\r
+  Definitions for EFI IPv4 Configuration II Protocol implementation.\r
+\r
+  Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>\r
+\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php.\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef __IP4_CONFIG2_IMPL_H__\r
+#define __IP4_CONFIG2_IMPL_H__\r
+\r
+#define IP4_CONFIG2_INSTANCE_SIGNATURE    SIGNATURE_32 ('I', 'P', 'C', '2')\r
+#define IP4_FORM_CALLBACK_INFO_SIGNATURE  SIGNATURE_32 ('I', 'F', 'C', 'I')\r
+\r
+#define IP4_CONFIG2_VARIABLE_ATTRIBUTE    (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS)\r
+\r
+#define DATA_ATTRIB_SIZE_FIXED              0x1\r
+#define DATA_ATTRIB_VOLATILE                0x2\r
+\r
+#define DHCP_TAG_PARA_LIST             55\r
+#define DHCP_TAG_NETMASK               1\r
+#define DHCP_TAG_ROUTER                3\r
+\r
+\r
+#define DATA_ATTRIB_SET(Attrib, Bits)       (BOOLEAN)((Attrib) & (Bits))\r
+#define SET_DATA_ATTRIB(Attrib, Bits)       ((Attrib) |= (Bits))\r
+\r
+typedef struct _IP4_CONFIG2_INSTANCE IP4_CONFIG2_INSTANCE;\r
+\r
+#define IP4_CONFIG2_INSTANCE_FROM_PROTOCOL(Proto) \\r
+  CR ((Proto), \\r
+      IP4_CONFIG2_INSTANCE, \\r
+      Ip4Config2, \\r
+      IP4_CONFIG2_INSTANCE_SIGNATURE \\r
+      )\r
+\r
+#define IP4_SERVICE_FROM_IP4_CONFIG2_INSTANCE(Instance) \\r
+  CR ((Instance), \\r
+      IP4_SERVICE, \\r
+      Ip4Config2Instance, \\r
+      IP4_SERVICE_SIGNATURE \\r
+      )\r
+\r
+#define IP4_CONFIG2_INSTANCE_FROM_FORM_CALLBACK(Callback) \\r
+  CR ((Callback), \\r
+      IP4_CONFIG2_INSTANCE, \\r
+      CallbackInfo, \\r
+      IP4_CONFIG2_INSTANCE_SIGNATURE \\r
+      )\r
+\r
+#define IP4_FORM_CALLBACK_INFO_FROM_CONFIG_ACCESS(ConfigAccess) \\r
+  CR ((ConfigAccess), \\r
+      IP4_FORM_CALLBACK_INFO, \\r
+      HiiConfigAccessProtocol, \\r
+      IP4_FORM_CALLBACK_INFO_SIGNATURE \\r
+      )\r
+\r
+/**\r
+  The prototype of work function for EfiIp4Config2SetData().\r
+\r
+  @param[in]     Instance The pointer to the IP4 config2 instance data.\r
+  @param[in]     DataSize In bytes, the size of the buffer pointed to by Data.\r
+  @param[in]     Data     The data buffer to set.\r
+\r
+  @retval EFI_BAD_BUFFER_SIZE  The DataSize does not match the size of the type,\r
+                               8 bytes.\r
+  @retval EFI_SUCCESS          The specified configuration data for the EFI IPv4\r
+                               network stack was set successfully.\r
+  \r
+**/\r
+typedef\r
+EFI_STATUS\r
+(*IP4_CONFIG2_SET_DATA) (\r
+  IN IP4_CONFIG2_INSTANCE *Instance,\r
+  IN UINTN                DataSize,\r
+  IN VOID                 *Data\r
+  );\r
+\r
+/**\r
+  The prototype of work function for EfiIp4Config2GetData().\r
+\r
+  @param[in]      Instance The pointer to the IP4 config2 instance data.\r
+  @param[in, out] DataSize On input, in bytes, the size of Data. On output, in\r
+                           bytes, the size of buffer required to store the specified\r
+                           configuration data.\r
+  @param[in]      Data     The data buffer in which the configuration data is returned.  \r
+                           Ignored if DataSize is ZERO.\r
+\r
+  @retval EFI_BUFFER_TOO_SMALL The size of Data is too small for the specified\r
+                               configuration data, and the required size is \r
+                               returned in DataSize.\r
+  @retval EFI_SUCCESS          The specified configuration data was obtained successfully.                               \r
+  \r
+**/\r
+typedef\r
+EFI_STATUS\r
+(*IP4_CONFIG2_GET_DATA) (\r
+  IN IP4_CONFIG2_INSTANCE *Instance,\r
+  IN OUT UINTN            *DataSize,\r
+  IN VOID                 *Data      OPTIONAL\r
+  );\r
+\r
+typedef union {\r
+  VOID                                      *Ptr;\r
+  EFI_IP4_CONFIG2_INTERFACE_INFO            *IfInfo;\r
+  EFI_IP4_CONFIG2_POLICY                    *Policy;\r
+  EFI_IP4_CONFIG2_MANUAL_ADDRESS            *ManualAddress;\r
+  EFI_IPv4_ADDRESS                          *Gateway;\r
+  EFI_IPv4_ADDRESS                          *DnsServers;\r
+} IP4_CONFIG2_DATA;\r
+\r
+typedef struct {\r
+  IP4_CONFIG2_SET_DATA SetData;\r
+  IP4_CONFIG2_GET_DATA GetData;\r
+  EFI_STATUS           Status;\r
+  UINT8                Attribute;\r
+  NET_MAP              EventMap;\r
+  IP4_CONFIG2_DATA     Data;\r
+  UINTN                DataSize;\r
+} IP4_CONFIG2_DATA_ITEM;\r
+\r
+typedef struct {\r
+  UINT16                    Offset;\r
+  UINT32                    DataSize;\r
+  EFI_IP4_CONFIG2_DATA_TYPE DataType;\r
+} IP4_CONFIG2_DATA_RECORD;\r
+\r
+#pragma pack(1)\r
+\r
+//\r
+// heap data that contains the data for each data record.\r
+//\r
+//  EFI_IP4_CONFIG2_POLICY                    Policy;\r
+//  UINT32                                    ManualaddressCount;\r
+//  UINT32                                    GatewayCount;\r
+//  UINT32                                    DnsServersCount;\r
+//  EFI_IP4_CONFIG2_MANUAL_ADDRESS            ManualAddress[];\r
+//  EFI_IPv4_ADDRESS                          Gateway[];\r
+//  EFI_IPv4_ADDRESS                          DnsServers[];\r
+//\r
+typedef struct {\r
+  UINT16                  Checksum;\r
+  UINT16                  DataRecordCount;\r
+  IP4_CONFIG2_DATA_RECORD DataRecord[1];\r
+} IP4_CONFIG2_VARIABLE;\r
+\r
+#pragma pack()\r
+\r
+typedef struct {\r
+  EFI_IP4_CONFIG2_POLICY                   Policy;               ///< manual or automatic  \r
+  EFI_IP4_CONFIG2_MANUAL_ADDRESS           *ManualAddress;       ///< IP addresses\r
+  UINT32                                   ManualAddressCount;   ///< IP addresses count\r
+  EFI_IPv4_ADDRESS                         *GatewayAddress;      ///< Gateway address\r
+  UINT32                                   GatewayAddressCount;  ///< Gateway address count\r
+  EFI_IPv4_ADDRESS                         *DnsAddress;          ///< DNS server address\r
+  UINT32                                   DnsAddressCount;      ///< DNS server address count\r
+} IP4_CONFIG2_NVDATA;\r
+\r
+typedef struct _IP4_FORM_CALLBACK_INFO {\r
+  UINT32                           Signature;\r
+  EFI_HANDLE                       ChildHandle;\r
+  EFI_HII_CONFIG_ACCESS_PROTOCOL   HiiConfigAccessProtocol;\r
+  EFI_DEVICE_PATH_PROTOCOL         *HiiVendorDevicePath;\r
+  EFI_HII_HANDLE                   RegisteredHandle;\r
+} IP4_FORM_CALLBACK_INFO;\r
+\r
+struct _IP4_CONFIG2_INSTANCE {\r
+  UINT32                                    Signature;\r
+  BOOLEAN                                   Configured;\r
+  LIST_ENTRY                                Link;\r
+  UINT16                                    IfIndex;\r
+\r
+  EFI_IP4_CONFIG2_PROTOCOL                  Ip4Config2;\r
+\r
+  EFI_IP4_CONFIG2_INTERFACE_INFO            InterfaceInfo;\r
+  EFI_IP4_CONFIG2_POLICY                    Policy;  \r
+  IP4_CONFIG2_DATA_ITEM                     DataItem[Ip4Config2DataTypeMaximum];\r
+\r
+  EFI_EVENT                                 Dhcp4SbNotifyEvent;\r
+  VOID                                      *Registration;\r
+  EFI_HANDLE                                Dhcp4Handle;\r
+  EFI_DHCP4_PROTOCOL                        *Dhcp4;\r
+  BOOLEAN                                   DhcpSuccess;\r
+  BOOLEAN                                   OtherInfoOnly;\r
+  EFI_EVENT                                 Dhcp4Event;\r
+  UINT32                                    FailedIaAddressCount;\r
+  EFI_IPv4_ADDRESS                          *DeclineAddress;\r
+  UINT32                                    DeclineAddressCount;\r
+  \r
+  IP4_FORM_CALLBACK_INFO                    CallbackInfo;\r
+\r
+  IP4_CONFIG2_NVDATA                        Ip4NvData;\r
+};\r
+\r
+//\r
+// Configure the DHCP to request the routers and netmask\r
+// from server. The DHCP_TAG_NETMASK is included in Head.\r
+//\r
+#pragma pack(1)\r
+typedef struct {\r
+  EFI_DHCP4_PACKET_OPTION Head;\r
+  UINT8                   Route;\r
+} IP4_CONFIG2_DHCP4_OPTION;\r
+#pragma pack()\r
+\r
+/**\r
+  Initialize an IP4_CONFIG2_INSTANCE.\r
+\r
+  @param[out]    Instance       The buffer of IP4_CONFIG2_INSTANCE to be initialized.\r
+\r
+  @retval EFI_OUT_OF_RESOURCES  Failed to allocate resources to complete the operation.\r
+  @retval EFI_SUCCESS           The IP4_CONFIG2_INSTANCE initialized successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+Ip4Config2InitInstance (\r
+  OUT IP4_CONFIG2_INSTANCE  *Instance\r
+  );\r
+\r
+/**\r
+  Release an IP4_CONFIG2_INSTANCE.\r
+\r
+  @param[in, out] Instance    The buffer of IP4_CONFIG2_INSTANCE to be freed.\r
+\r
+**/\r
+VOID\r
+Ip4Config2CleanInstance (\r
+  IN OUT IP4_CONFIG2_INSTANCE  *Instance\r
+  );\r
+\r
+/**\r
+  Destroy the Dhcp4 child in IP4_CONFIG2_INSTANCE and release the resources.\r
+\r
+  @param[in, out] Instance    The buffer of IP4 config2 instance to be freed.\r
+\r
+  @retval EFI_SUCCESS         The child was successfully destroyed.\r
+  @retval Others              Failed to destroy the child.\r
+\r
+**/\r
+EFI_STATUS\r
+Ip4Config2DestroyDhcp4 (\r
+  IN OUT IP4_CONFIG2_INSTANCE  *Instance\r
+  );\r
+\r
+#endif\r