Blame view
include/env_flags.h
4.59 KB
83d290c56 SPDX: Convert all... |
1 |
/* SPDX-License-Identifier: GPL-2.0+ */ |
2598090b7 env: Add environm... |
2 3 4 |
/* * (C) Copyright 2012 * Joe Hershberger, National Instruments, joe.hershberger@ni.com |
2598090b7 env: Add environm... |
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
*/ #ifndef __ENV_FLAGS_H__ #define __ENV_FLAGS_H__ enum env_flags_vartype { env_flags_vartype_string, env_flags_vartype_decimal, env_flags_vartype_hex, env_flags_vartype_bool, #ifdef CONFIG_CMD_NET env_flags_vartype_ipaddr, env_flags_vartype_macaddr, #endif env_flags_vartype_end }; |
267541f77 env: Add support ... |
21 22 23 24 25 26 27 |
enum env_flags_varaccess { env_flags_varaccess_any, env_flags_varaccess_readonly, env_flags_varaccess_writeonce, env_flags_varaccess_changedefault, env_flags_varaccess_end }; |
2598090b7 env: Add environm... |
28 29 30 |
#define ENV_FLAGS_VAR ".flags" #define ENV_FLAGS_ATTR_MAX_LEN 2 #define ENV_FLAGS_VARTYPE_LOC 0 |
267541f77 env: Add support ... |
31 |
#define ENV_FLAGS_VARACCESS_LOC 1 |
2598090b7 env: Add environm... |
32 33 34 35 |
#ifndef CONFIG_ENV_FLAGS_LIST_STATIC #define CONFIG_ENV_FLAGS_LIST_STATIC "" #endif |
cccc05ee3 env: net: U_BOOT_... |
36 |
#ifdef CONFIG_NET |
73c2bbeea net: Apply defaul... |
37 |
#ifdef CONFIG_REGEX |
be09f5bc7 net: fix env flag... |
38 |
#define ETHADDR_WILDCARD "\\d*" |
73c2bbeea net: Apply defaul... |
39 40 41 |
#else #define ETHADDR_WILDCARD #endif |
1d6cd0a3f env: Handle write... |
42 |
#ifdef CONFIG_ENV_OVERWRITE |
73c2bbeea net: Apply defaul... |
43 |
#define ETHADDR_FLAGS "eth" ETHADDR_WILDCARD "addr:ma," |
1d6cd0a3f env: Handle write... |
44 45 |
#else #ifdef CONFIG_OVERWRITE_ETHADDR_ONCE |
73c2bbeea net: Apply defaul... |
46 |
#define ETHADDR_FLAGS "eth" ETHADDR_WILDCARD "addr:mc," |
1d6cd0a3f env: Handle write... |
47 |
#else |
73c2bbeea net: Apply defaul... |
48 |
#define ETHADDR_FLAGS "eth" ETHADDR_WILDCARD "addr:mo," |
1d6cd0a3f env: Handle write... |
49 50 |
#endif #endif |
c0a93440a net: Add default ... |
51 52 53 54 55 |
#define NET_FLAGS \ "ipaddr:i," \ "gatewayip:i," \ "netmask:i," \ "serverip:i," \ |
0299cee53 net: fix vlan val... |
56 57 |
"nvlan:d," \ "vlan:d," \ |
c0a93440a net: Add default ... |
58 |
"dnsip:i," |
1d6cd0a3f env: Handle write... |
59 |
#else |
c0a93440a net: Add default ... |
60 61 |
#define ETHADDR_FLAGS #define NET_FLAGS |
1d6cd0a3f env: Handle write... |
62 63 64 65 66 67 68 |
#endif #ifndef CONFIG_ENV_OVERWRITE #define SERIAL_FLAGS "serial#:so," #else #define SERIAL_FLAGS "" #endif |
2598090b7 env: Add environm... |
69 |
#define ENV_FLAGS_LIST_STATIC \ |
1d6cd0a3f env: Handle write... |
70 |
ETHADDR_FLAGS \ |
c0a93440a net: Add default ... |
71 |
NET_FLAGS \ |
1d6cd0a3f env: Handle write... |
72 |
SERIAL_FLAGS \ |
2598090b7 env: Add environm... |
73 |
CONFIG_ENV_FLAGS_LIST_STATIC |
fffad71bc env: Add a comman... |
74 75 76 77 78 79 |
#ifdef CONFIG_CMD_ENV_FLAGS /* * Print the whole list of available type flags. */ void env_flags_print_vartypes(void); /* |
267541f77 env: Add support ... |
80 81 82 83 |
* Print the whole list of available access flags. */ void env_flags_print_varaccess(void); /* |
fffad71bc env: Add a comman... |
84 85 86 |
* Return the name of the type. */ const char *env_flags_get_vartype_name(enum env_flags_vartype type); |
267541f77 env: Add support ... |
87 88 89 90 |
/* * Return the name of the access. */ const char *env_flags_get_varaccess_name(enum env_flags_varaccess access); |
fffad71bc env: Add a comman... |
91 |
#endif |
2598090b7 env: Add environm... |
92 93 94 95 |
/* * Parse the flags string from a .flags attribute list into the vartype enum. */ enum env_flags_vartype env_flags_parse_vartype(const char *flags); |
267541f77 env: Add support ... |
96 97 98 99 100 101 102 103 |
/* * Parse the flags string from a .flags attribute list into the varaccess enum. */ enum env_flags_varaccess env_flags_parse_varaccess(const char *flags); /* * Parse the binary flags from a hash table entry into the varaccess enum. */ enum env_flags_varaccess env_flags_parse_varaccess_from_binflags(int binflags); |
2598090b7 env: Add environm... |
104 |
|
0118e83ba common/env_flags.... |
105 106 107 108 109 110 |
#ifdef CONFIG_CMD_NET /* * Check if a string has the format of an Ethernet MAC address */ int eth_validate_ethaddr_str(const char *addr); #endif |
30fd4fadb tools/env: Add en... |
111 112 113 114 115 116 |
#ifdef USE_HOSTCC /* * Look up the type of a variable directly from the .flags var. */ enum env_flags_vartype env_flags_get_type(const char *name); /* |
267541f77 env: Add support ... |
117 118 119 120 |
* Look up the access of a variable directly from the .flags var. */ enum env_flags_varaccess env_flags_get_access(const char *name); /* |
30fd4fadb tools/env: Add en... |
121 122 123 124 125 |
* Validate the newval for its type to conform with the requirements defined by * its flags (directly looked at the .flags var). */ int env_flags_validate_type(const char *name, const char *newval); /* |
267541f77 env: Add support ... |
126 127 128 129 130 131 132 133 134 135 |
* Validate the newval for its access to conform with the requirements defined * by its flags (directly looked at the .flags var). */ int env_flags_validate_access(const char *name, int check_mask); /* * Validate that the proposed access to variable "name" is valid according to * the defined flags for that variable, if any. */ int env_flags_validate_varaccess(const char *name, int check_mask); /* |
30fd4fadb tools/env: Add en... |
136 137 |
* Validate the parameters passed to "env set" for type compliance */ |
167f52587 tools: env valida... |
138 |
int env_flags_validate_env_set_params(char *name, char *const val[], int count); |
30fd4fadb tools/env: Add en... |
139 140 |
#else /* !USE_HOSTCC */ |
9fb625ce0 env: Move env_set... |
141 |
#include <env.h> |
2598090b7 env: Add environm... |
142 143 144 145 146 147 |
#include <search.h> /* * When adding a variable to the environment, initialize the flags for that * variable. */ |
dd2408cac env: Drop the ENT... |
148 |
void env_flags_init(struct env_entry *var_entry); |
2598090b7 env: Add environm... |
149 150 151 152 |
/* * Validate the newval for to conform with the requirements defined by its flags */ |
dd2408cac env: Drop the ENT... |
153 154 |
int env_flags_validate(const struct env_entry *item, const char *newval, enum env_op op, int flag); |
2598090b7 env: Add environm... |
155 |
|
267541f77 env: Add support ... |
156 |
#endif /* USE_HOSTCC */ |
2598090b7 env: Add environm... |
157 158 159 160 |
/* * These are the binary flags used in the environment entry->flags variable to * decribe properties of veriables in the table */ |
267541f77 env: Add support ... |
161 |
#define ENV_FLAGS_VARTYPE_BIN_MASK 0x00000007 |
2598090b7 env: Add environm... |
162 |
/* The actual variable type values use the enum value (within the mask) */ |
267541f77 env: Add support ... |
163 164 165 166 167 |
#define ENV_FLAGS_VARACCESS_PREVENT_DELETE 0x00000008 #define ENV_FLAGS_VARACCESS_PREVENT_CREATE 0x00000010 #define ENV_FLAGS_VARACCESS_PREVENT_OVERWR 0x00000020 #define ENV_FLAGS_VARACCESS_PREVENT_NONDEF_OVERWR 0x00000040 #define ENV_FLAGS_VARACCESS_BIN_MASK 0x00000078 |
30fd4fadb tools/env: Add en... |
168 |
|
2598090b7 env: Add environm... |
169 |
#endif /* __ENV_FLAGS_H__ */ |