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