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