1
2
3
4
5
6
7
8#ifndef __ENV_FLAGS_H__
9#define __ENV_FLAGS_H__
10
11enum env_flags_vartype {
12 env_flags_vartype_string,
13 env_flags_vartype_decimal,
14 env_flags_vartype_hex,
15 env_flags_vartype_bool,
16#ifdef CONFIG_CMD_NET
17 env_flags_vartype_ipaddr,
18 env_flags_vartype_macaddr,
19#endif
20 env_flags_vartype_end
21};
22
23enum env_flags_varaccess {
24 env_flags_varaccess_any,
25 env_flags_varaccess_readonly,
26 env_flags_varaccess_writeonce,
27 env_flags_varaccess_changedefault,
28 env_flags_varaccess_end
29};
30
31#define ENV_FLAGS_VAR ".flags"
32#define ENV_FLAGS_ATTR_MAX_LEN 2
33#define ENV_FLAGS_VARTYPE_LOC 0
34#define ENV_FLAGS_VARACCESS_LOC 1
35
36#ifndef CONFIG_ENV_FLAGS_LIST_STATIC
37#define CONFIG_ENV_FLAGS_LIST_STATIC ""
38#endif
39
40#ifdef CONFIG_CMD_NET
41#ifdef CONFIG_REGEX
42#define ETHADDR_WILDCARD "\\d?"
43#else
44#define ETHADDR_WILDCARD
45#endif
46#ifdef CONFIG_ENV_OVERWRITE
47#define ETHADDR_FLAGS "eth" ETHADDR_WILDCARD "addr:ma,"
48#else
49#ifdef CONFIG_OVERWRITE_ETHADDR_ONCE
50#define ETHADDR_FLAGS "eth" ETHADDR_WILDCARD "addr:mc,"
51#else
52#define ETHADDR_FLAGS "eth" ETHADDR_WILDCARD "addr:mo,"
53#endif
54#endif
55#define NET_FLAGS \
56 "ipaddr:i," \
57 "gatewayip:i," \
58 "netmask:i," \
59 "serverip:i," \
60 "nvlan:d," \
61 "vlan:d," \
62 "dnsip:i,"
63#else
64#define ETHADDR_FLAGS
65#define NET_FLAGS
66#endif
67
68#ifndef CONFIG_ENV_OVERWRITE
69#define SERIAL_FLAGS "serial#:so,"
70#else
71#define SERIAL_FLAGS ""
72#endif
73
74#define ENV_FLAGS_LIST_STATIC \
75 ETHADDR_FLAGS \
76 NET_FLAGS \
77 SERIAL_FLAGS \
78 CONFIG_ENV_FLAGS_LIST_STATIC
79
80#ifdef CONFIG_CMD_ENV_FLAGS
81
82
83
84void env_flags_print_vartypes(void);
85
86
87
88void env_flags_print_varaccess(void);
89
90
91
92const char *env_flags_get_vartype_name(enum env_flags_vartype type);
93
94
95
96const char *env_flags_get_varaccess_name(enum env_flags_varaccess access);
97#endif
98
99
100
101
102enum env_flags_vartype env_flags_parse_vartype(const char *flags);
103
104
105
106enum env_flags_varaccess env_flags_parse_varaccess(const char *flags);
107
108
109
110enum env_flags_varaccess env_flags_parse_varaccess_from_binflags(int binflags);
111
112#ifdef CONFIG_CMD_NET
113
114
115
116int eth_validate_ethaddr_str(const char *addr);
117#endif
118
119#ifdef USE_HOSTCC
120
121
122
123enum env_flags_vartype env_flags_get_type(const char *name);
124
125
126
127enum env_flags_varaccess env_flags_get_access(const char *name);
128
129
130
131
132int env_flags_validate_type(const char *name, const char *newval);
133
134
135
136
137int env_flags_validate_access(const char *name, int check_mask);
138
139
140
141
142int env_flags_validate_varaccess(const char *name, int check_mask);
143
144
145
146int env_flags_validate_env_set_params(char *name, char *const val[], int count);
147
148#else
149
150#include <search.h>
151
152
153
154
155
156void env_flags_init(ENTRY *var_entry);
157
158
159
160
161int env_flags_validate(const ENTRY *item, const char *newval, enum env_op op,
162 int flag);
163
164#endif
165
166
167
168
169
170#define ENV_FLAGS_VARTYPE_BIN_MASK 0x00000007
171
172#define ENV_FLAGS_VARACCESS_PREVENT_DELETE 0x00000008
173#define ENV_FLAGS_VARACCESS_PREVENT_CREATE 0x00000010
174#define ENV_FLAGS_VARACCESS_PREVENT_OVERWR 0x00000020
175#define ENV_FLAGS_VARACCESS_PREVENT_NONDEF_OVERWR 0x00000040
176#define ENV_FLAGS_VARACCESS_BIN_MASK 0x00000078
177
178#endif
179