]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Universal/Network/Ip4ConfigDxe/NicIp4Variable.h
code scrub fix
[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
402fa70f 4Copyright (c) 2006 - 2008, 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
20#include <Library/NetLib.h>\r
21#include <Library/DebugLib.h>\r
22#include <Library/BaseMemoryLib.h>\r
23#include <Library/MemoryAllocationLib.h>\r
24#include <Library/UefiBootServicesTableLib.h>\r
25#include <Library/UefiRuntimeServicesTableLib.h>\r
83cbd279 26\r
27#include <Protocol/NicIp4Config.h>\r
28\r
c8d8f1e3 29\r
83cbd279 30//\r
31// Return the size of NIC_IP4_CONFIG_INFO and EFI_IP4_IPCONFIG_DATA.\r
32// They are of variable size\r
33//\r
34#define SIZEOF_IP4_CONFIG_INFO(Ip4Config) \\r
35 (sizeof (EFI_IP4_IPCONFIG_DATA) + \\r
7659d0c9 36 sizeof (EFI_IP4_ROUTE_TABLE) * (Ip4Config)->RouteTableSize)\r
83cbd279 37\r
38#define SIZEOF_NIC_IP4_CONFIG_INFO(NicConfig) \\r
39 (sizeof (NIC_IP4_CONFIG_INFO) + \\r
7659d0c9 40 sizeof (EFI_IP4_ROUTE_TABLE) * (NicConfig)->Ip4Info.RouteTableSize)\r
83cbd279 41\r
42//\r
43// Compare whether two NIC address are equal includes their type and length.\r
44//\r
45#define NIC_ADDR_EQUAL(Nic1, Nic2) \\r
46 (((Nic1)->Type == (Nic2)->Type) && ((Nic1)->Len == (Nic2)->Len) && \\r
47 NET_MAC_EQUAL (&(Nic1)->MacAddr, &(Nic2)->MacAddr, (Nic1)->Len))\r
48\r
7bce0c5a 49/**\r
50 Check whether the configure parameter is valid.\r
51\r
52 @param NicConfig The configure parameter to check\r
53\r
54 @return TRUE if the parameter is valid for the interface, otherwise FALSE.\r
55\r
56**/\r
83cbd279 57BOOLEAN\r
58Ip4ConfigIsValid (\r
59 IN NIC_IP4_CONFIG_INFO *NicConfig\r
60 );\r
61\r
7bce0c5a 62/**\r
63 Read the ip4 configure variable from the EFI variable.\r
64\r
65 None\r
66\r
67 @return The IP4 configure read if it is there and is valid, otherwise NULL\r
68\r
69**/\r
83cbd279 70IP4_CONFIG_VARIABLE *\r
71Ip4ConfigReadVariable (\r
72 VOID\r
73 );\r
74\r
7bce0c5a 75/**\r
76 Write the IP4 configure variable to the NVRAM. If Config\r
77 is NULL, remove the variable.\r
78\r
79 @param Config The IP4 configure data to write\r
80\r
81 @retval EFI_SUCCESS The variable is written to the NVRam\r
82 @retval Others Failed to write the variable.\r
83\r
84**/\r
83cbd279 85EFI_STATUS\r
86Ip4ConfigWriteVariable (\r
c8d8f1e3 87 IN IP4_CONFIG_VARIABLE *Config OPTIONAL\r
83cbd279 88 );\r
89\r
7bce0c5a 90/**\r
91 Locate the IP4 configure parameters from the variable.If a\r
92 configuration is found, copy it to a newly allocated block\r
93 of memory to avoid the alignment problem. Caller should\r
94 release the memory after use.\r
95\r
96 @param Variable The IP4 configure variable to search in\r
97 @param NicAddr The interface address to check\r
98\r
99 @return The point to the NIC's IP4 configure info if it is found\r
402fa70f 100 in the IP4 variable, otherwise NULL.\r
7bce0c5a 101\r
102**/\r
83cbd279 103NIC_IP4_CONFIG_INFO *\r
104Ip4ConfigFindNicVariable (\r
105 IN IP4_CONFIG_VARIABLE *Variable,\r
106 IN NIC_ADDR *NicAddr\r
107 );\r
108\r
7bce0c5a 109/**\r
110 Modify the configuration parameter for the NIC in the variable.\r
111 If Config is NULL, old configuration will be remove from the new\r
112 variable. Otherwise, append it or replace the old one.\r
113\r
114 @param Variable The IP4 variable to change\r
115 @param NicAddr The interface to search\r
116 @param Config The new configuration parameter (NULL to remove the old)\r
117\r
118 @return The new IP4_CONFIG_VARIABLE variable if the new variable has at\r
c8d8f1e3 119 least one NIC configure and no EFI_OUT_OF_RESOURCES failure.\r
120 Return NULL either because failed to locate memory for new variable\r
121 or the only NIC configure is removed from the Variable.\r
7bce0c5a 122\r
123**/\r
83cbd279 124IP4_CONFIG_VARIABLE *\r
125Ip4ConfigModifyVariable (\r
3e8c18da 126 IN IP4_CONFIG_VARIABLE *Variable OPTIONAL,\r
83cbd279 127 IN NIC_ADDR *NicAddr,\r
128 IN NIC_IP4_CONFIG_INFO *Config OPTIONAL\r
129 );\r
7659d0c9 130\r
402fa70f 131/**\r
132 Fix the RouteTable pointer in an EFI_IP4_IPCONFIG_DATA structure. \r
133 \r
134 The pointer is set to be immediately follow the ConfigData if there're entries\r
135 in the RouteTable. Otherwise it is set to NULL.\r
136 \r
137 @param ConfigData The IP4 IP configure data.\r
138\r
139**/\r
7659d0c9 140VOID\r
141Ip4ConfigFixRouteTablePointer (\r
c8d8f1e3 142 IN OUT EFI_IP4_IPCONFIG_DATA *ConfigData\r
7659d0c9 143 );\r
144\r
83cbd279 145#endif\r