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