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