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