]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.h
Update modules to show real dependencies on the BaseMemoryLib and MemoryAllocationLib
[mirror_edk2.git] / MdeModulePkg / Universal / Network / Ip4ConfigDxe / NicIp4Variable.h
CommitLineData
83cbd279 1/** @file\r
3e8c18da 2 Routines used to operate the Ip4 configure variable.\r
83cbd279 3\r
63886849 4Copyright (c) 2006 - 2009, Intel Corporation.<BR> \r
83cbd279 5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
402fa70f 7which accompanies this distribution. The full text of the license may be found at<BR>\r
83cbd279 8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
83cbd279 13**/\r
14\r
15#ifndef _NIC_IP4_VARIABLE_H_\r
16#define _NIC_IP4_VARIABLE_H_\r
17\r
c8d8f1e3 18#include <Uefi.h>\r
19\r
63886849 20#include <Guid/NicIp4ConfigNvData.h>\r
21\r
c8d8f1e3 22#include <Library/NetLib.h>\r
23#include <Library/DebugLib.h>\r
24#include <Library/BaseMemoryLib.h>\r
25#include <Library/MemoryAllocationLib.h>\r
26#include <Library/UefiBootServicesTableLib.h>\r
27#include <Library/UefiRuntimeServicesTableLib.h>\r
83cbd279 28\r
63886849 29///\r
30/// IP4_CONFIG_VARIABLE is the EFI variable to\r
31/// save the configuration. IP4_CONFIG_VARIABLE is\r
32/// of variable length.\r
33///\r
34typedef struct {\r
35 UINT32 Len; ///< Total length of the variable\r
36 UINT16 CheckSum; ///< CheckSum, the same as IP4 head checksum\r
37 UINT32 Count; ///< Number of NIC_IP4_CONFIG_INFO follows\r
38 NIC_IP4_CONFIG_INFO ConfigInfo;\r
39} IP4_CONFIG_VARIABLE;\r
c8d8f1e3 40\r
83cbd279 41//\r
42// Return the size of NIC_IP4_CONFIG_INFO and EFI_IP4_IPCONFIG_DATA.\r
43// They are of variable size\r
44//\r
45#define SIZEOF_IP4_CONFIG_INFO(Ip4Config) \\r
46 (sizeof (EFI_IP4_IPCONFIG_DATA) + \\r
7659d0c9 47 sizeof (EFI_IP4_ROUTE_TABLE) * (Ip4Config)->RouteTableSize)\r
83cbd279 48\r
49#define SIZEOF_NIC_IP4_CONFIG_INFO(NicConfig) \\r
50 (sizeof (NIC_IP4_CONFIG_INFO) + \\r
7659d0c9 51 sizeof (EFI_IP4_ROUTE_TABLE) * (NicConfig)->Ip4Info.RouteTableSize)\r
83cbd279 52\r
53//\r
54// Compare whether two NIC address are equal includes their type and length.\r
55//\r
56#define NIC_ADDR_EQUAL(Nic1, Nic2) \\r
57 (((Nic1)->Type == (Nic2)->Type) && ((Nic1)->Len == (Nic2)->Len) && \\r
58 NET_MAC_EQUAL (&(Nic1)->MacAddr, &(Nic2)->MacAddr, (Nic1)->Len))\r
59\r
7bce0c5a 60/**\r
61 Check whether the configure parameter is valid.\r
62\r
63 @param NicConfig The configure parameter to check\r
64\r
65 @return TRUE if the parameter is valid for the interface, otherwise FALSE.\r
66\r
67**/\r
83cbd279 68BOOLEAN\r
69Ip4ConfigIsValid (\r
70 IN NIC_IP4_CONFIG_INFO *NicConfig\r
71 );\r
72\r
7bce0c5a 73/**\r
74 Read the ip4 configure variable from the EFI variable.\r
75\r
76 None\r
77\r
78 @return The IP4 configure read if it is there and is valid, otherwise NULL\r
79\r
80**/\r
83cbd279 81IP4_CONFIG_VARIABLE *\r
82Ip4ConfigReadVariable (\r
83 VOID\r
84 );\r
85\r
7bce0c5a 86/**\r
87 Write the IP4 configure variable to the NVRAM. If Config\r
88 is NULL, remove the variable.\r
89\r
90 @param Config The IP4 configure data to write\r
91\r
92 @retval EFI_SUCCESS The variable is written to the NVRam\r
93 @retval Others Failed to write the variable.\r
94\r
95**/\r
83cbd279 96EFI_STATUS\r
97Ip4ConfigWriteVariable (\r
c8d8f1e3 98 IN IP4_CONFIG_VARIABLE *Config OPTIONAL\r
83cbd279 99 );\r
100\r
7bce0c5a 101/**\r
102 Locate the IP4 configure parameters from the variable.If a\r
103 configuration is found, copy it to a newly allocated block\r
104 of memory to avoid the alignment problem. Caller should\r
105 release the memory after use.\r
106\r
107 @param Variable The IP4 configure variable to search in\r
108 @param NicAddr The interface address to check\r
109\r
110 @return The point to the NIC's IP4 configure info if it is found\r
402fa70f 111 in the IP4 variable, otherwise NULL.\r
7bce0c5a 112\r
113**/\r
83cbd279 114NIC_IP4_CONFIG_INFO *\r
115Ip4ConfigFindNicVariable (\r
116 IN IP4_CONFIG_VARIABLE *Variable,\r
117 IN NIC_ADDR *NicAddr\r
118 );\r
119\r
7bce0c5a 120/**\r
121 Modify the configuration parameter for the NIC in the variable.\r
122 If Config is NULL, old configuration will be remove from the new\r
123 variable. Otherwise, append it or replace the old one.\r
124\r
125 @param Variable The IP4 variable to change\r
126 @param NicAddr The interface to search\r
127 @param Config The new configuration parameter (NULL to remove the old)\r
128\r
129 @return The new IP4_CONFIG_VARIABLE variable if the new variable has at\r
c8d8f1e3 130 least one NIC configure and no EFI_OUT_OF_RESOURCES failure.\r
131 Return NULL either because failed to locate memory for new variable\r
132 or the only NIC configure is removed from the Variable.\r
7bce0c5a 133\r
134**/\r
83cbd279 135IP4_CONFIG_VARIABLE *\r
136Ip4ConfigModifyVariable (\r
3e8c18da 137 IN IP4_CONFIG_VARIABLE *Variable OPTIONAL,\r
83cbd279 138 IN NIC_ADDR *NicAddr,\r
139 IN NIC_IP4_CONFIG_INFO *Config OPTIONAL\r
140 );\r
7659d0c9 141\r
402fa70f 142/**\r
143 Fix the RouteTable pointer in an EFI_IP4_IPCONFIG_DATA structure. \r
144 \r
145 The pointer is set to be immediately follow the ConfigData if there're entries\r
146 in the RouteTable. Otherwise it is set to NULL.\r
147 \r
148 @param ConfigData The IP4 IP configure data.\r
149\r
150**/\r
7659d0c9 151VOID\r
152Ip4ConfigFixRouteTablePointer (\r
c8d8f1e3 153 IN OUT EFI_IP4_IPCONFIG_DATA *ConfigData\r
7659d0c9 154 );\r
155\r
83cbd279 156#endif\r
63886849 157\r