]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.h
1. retired NicIp4ConfigProtocolGuid
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4ConfigDxe / NicIp4Variable.h
index 74d1660c4d0e48bb90afb549935b6f78cadc248c..6a4e94193e983bf72a1f94697018c0d53cc5be23 100644 (file)
-/** @file
-
-Copyright (c) 2006, Intel Corporation
-All rights reserved. This program and the accompanying materials
-are licensed and made available under the terms and conditions of the BSD License
-which accompanies this distribution.  The full text of the license may be found at
-http://opensource.org/licenses/bsd-license.php
-
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-Module Name:
-
-  NicIp4Variable.h
-
-Abstract:
-
-  Routines used to operate the Ip4 configure variable
-
-
-**/
-
-#ifndef _NIC_IP4_VARIABLE_H_
-#define _NIC_IP4_VARIABLE_H_
-
-
-#include <Protocol/NicIp4Config.h>
-
-//
-// Return the size of NIC_IP4_CONFIG_INFO and EFI_IP4_IPCONFIG_DATA.
-// They are of variable size
-//
-#define SIZEOF_IP4_CONFIG_INFO(Ip4Config) \
-  (sizeof (EFI_IP4_IPCONFIG_DATA) + \
-   sizeof (EFI_IP4_ROUTE_TABLE) * (NET_MAX (1, (Ip4Config)->RouteTableSize) - 1))
-
-#define SIZEOF_NIC_IP4_CONFIG_INFO(NicConfig) \
-  (sizeof (NIC_IP4_CONFIG_INFO) + \
-   sizeof (EFI_IP4_ROUTE_TABLE) * (NET_MAX (1, (NicConfig)->Ip4Info.RouteTableSize) - 1))
-
-//
-// Compare whether two NIC address are equal includes their type and length.
-//
-#define NIC_ADDR_EQUAL(Nic1, Nic2) \
-  (((Nic1)->Type == (Nic2)->Type) && ((Nic1)->Len == (Nic2)->Len) && \
-   NET_MAC_EQUAL (&(Nic1)->MacAddr, &(Nic2)->MacAddr, (Nic1)->Len))
-
-BOOLEAN
-Ip4ConfigIsValid (
-  IN NIC_IP4_CONFIG_INFO    *NicConfig
-  );
-
-IP4_CONFIG_VARIABLE *
-Ip4ConfigReadVariable (
-  VOID
-  );
-
-EFI_STATUS
-Ip4ConfigWriteVariable (
-  IN IP4_CONFIG_VARIABLE    *Config       OPTIONAL
-  );
-
-NIC_IP4_CONFIG_INFO *
-Ip4ConfigFindNicVariable (
-  IN IP4_CONFIG_VARIABLE    *Variable,
-  IN NIC_ADDR               *NicAddr
-  );
-
-IP4_CONFIG_VARIABLE *
-Ip4ConfigModifyVariable (
-  IN IP4_CONFIG_VARIABLE    *Variable,    OPTIONAL
-  IN NIC_ADDR               *NicAddr,
-  IN NIC_IP4_CONFIG_INFO    *Config       OPTIONAL
-  );
-#endif
+/** @file\r
+  Routines used to operate the Ip4 configure variable.\r
+\r
+Copyright (c) 2006 - 2009, Intel Corporation.<BR>                                                         \r
+All rights reserved. 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<BR>\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 _NIC_IP4_VARIABLE_H_\r
+#define _NIC_IP4_VARIABLE_H_\r
+\r
+#include <Uefi.h>\r
+\r
+#include <Guid/NicIp4ConfigNvData.h>\r
+\r
+#include <Library/NetLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/UefiRuntimeServicesTableLib.h>\r
+\r
+///\r
+/// IP4_CONFIG_VARIABLE is the EFI variable to\r
+/// save the configuration. IP4_CONFIG_VARIABLE is\r
+/// of variable length.\r
+///\r
+typedef struct {\r
+  UINT32                    Len;        ///< Total length of the variable\r
+  UINT16                    CheckSum;   ///< CheckSum, the same as IP4 head checksum\r
+  UINT32                    Count;      ///< Number of NIC_IP4_CONFIG_INFO follows\r
+  NIC_IP4_CONFIG_INFO       ConfigInfo;\r
+} IP4_CONFIG_VARIABLE;\r
+\r
+//\r
+// Return the size of NIC_IP4_CONFIG_INFO and EFI_IP4_IPCONFIG_DATA.\r
+// They are of variable size\r
+//\r
+#define SIZEOF_IP4_CONFIG_INFO(Ip4Config) \\r
+  (sizeof (EFI_IP4_IPCONFIG_DATA) + \\r
+   sizeof (EFI_IP4_ROUTE_TABLE) * (Ip4Config)->RouteTableSize)\r
+\r
+#define SIZEOF_NIC_IP4_CONFIG_INFO(NicConfig) \\r
+  (sizeof (NIC_IP4_CONFIG_INFO) + \\r
+   sizeof (EFI_IP4_ROUTE_TABLE) * (NicConfig)->Ip4Info.RouteTableSize)\r
+\r
+//\r
+// Compare whether two NIC address are equal includes their type and length.\r
+//\r
+#define NIC_ADDR_EQUAL(Nic1, Nic2) \\r
+  (((Nic1)->Type == (Nic2)->Type) && ((Nic1)->Len == (Nic2)->Len) && \\r
+   NET_MAC_EQUAL (&(Nic1)->MacAddr, &(Nic2)->MacAddr, (Nic1)->Len))\r
+\r
+/**\r
+  Check whether the configure parameter is valid.\r
+\r
+  @param  NicConfig    The configure parameter to check\r
+\r
+  @return TRUE if the parameter is valid for the interface, otherwise FALSE.\r
+\r
+**/\r
+BOOLEAN\r
+Ip4ConfigIsValid (\r
+  IN NIC_IP4_CONFIG_INFO    *NicConfig\r
+  );\r
+\r
+/**\r
+  Read the ip4 configure variable from the EFI variable.\r
+\r
+  None\r
+\r
+  @return The IP4 configure read if it is there and is valid, otherwise NULL\r
+\r
+**/\r
+IP4_CONFIG_VARIABLE *\r
+Ip4ConfigReadVariable (\r
+  VOID\r
+  );\r
+\r
+/**\r
+  Write the IP4 configure variable to the NVRAM. If Config\r
+  is NULL, remove the variable.\r
+\r
+  @param  Config       The IP4 configure data to write\r
+\r
+  @retval EFI_SUCCESS  The variable is written to the NVRam\r
+  @retval Others       Failed to write the variable.\r
+\r
+**/\r
+EFI_STATUS\r
+Ip4ConfigWriteVariable (\r
+  IN IP4_CONFIG_VARIABLE    *Config        OPTIONAL\r
+  );\r
+\r
+/**\r
+  Locate the IP4 configure parameters from the variable.If a\r
+  configuration is found, copy it to a newly allocated block\r
+  of memory to avoid the alignment problem. Caller should\r
+  release the memory after use.\r
+\r
+  @param  Variable     The IP4 configure variable to search in\r
+  @param  NicAddr      The interface address to check\r
+\r
+  @return The point to the NIC's IP4 configure info if it is found\r
+          in the IP4 variable, otherwise NULL.\r
+\r
+**/\r
+NIC_IP4_CONFIG_INFO *\r
+Ip4ConfigFindNicVariable (\r
+  IN IP4_CONFIG_VARIABLE    *Variable,\r
+  IN NIC_ADDR               *NicAddr\r
+  );\r
+\r
+/**\r
+  Modify the configuration parameter for the NIC in the variable.\r
+  If Config is NULL, old configuration will be remove from the new\r
+  variable. Otherwise, append it or replace the old one.\r
+\r
+  @param  Variable     The IP4 variable to change\r
+  @param  NicAddr      The interface to search\r
+  @param  Config       The new configuration parameter (NULL to remove the old)\r
+\r
+  @return The new IP4_CONFIG_VARIABLE variable if the new variable has at\r
+          least one NIC configure and no EFI_OUT_OF_RESOURCES failure.\r
+          Return NULL either because failed to locate memory for new variable\r
+          or the only NIC configure is removed from the Variable.\r
+\r
+**/\r
+IP4_CONFIG_VARIABLE *\r
+Ip4ConfigModifyVariable (\r
+  IN IP4_CONFIG_VARIABLE    *Variable     OPTIONAL,\r
+  IN NIC_ADDR               *NicAddr,\r
+  IN NIC_IP4_CONFIG_INFO    *Config       OPTIONAL\r
+  );\r
+\r
+/**\r
+  Fix the RouteTable pointer in an EFI_IP4_IPCONFIG_DATA structure. \r
+  \r
+  The pointer is set to be immediately follow the ConfigData if there're entries\r
+  in the RouteTable. Otherwise it is set to NULL.\r
+  \r
+  @param  ConfigData     The IP4 IP configure data.\r
+\r
+**/\r
+VOID\r
+Ip4ConfigFixRouteTablePointer (\r
+  IN OUT EFI_IP4_IPCONFIG_DATA  *ConfigData\r
+  );\r
+\r
+#endif\r
+\r