Lines Matching +full:key +full:- +full:value

1 /*-
2 * Copyright (c) 2014-2015 Sandvine Inc.
46 report_config_error(const char *key, const ucl_object_t *obj, const char *type) in report_config_error() argument
49 errx(1, "Value '%s' of key '%s' is not of type %s", in report_config_error()
50 ucl_object_tostring(obj), key, type); in report_config_error()
54 * Verifies that the value specified in the config file is a boolean value, and
55 * then adds the value to the configuration.
58 add_bool_config(const char *key, const ucl_object_t *obj, nvlist_t *config) in add_bool_config() argument
63 report_config_error(key, obj, "bool"); in add_bool_config()
65 nvlist_add_bool(config, key, val); in add_bool_config()
69 * Verifies that the value specified in the config file is a string, and then
70 * adds the value to the configuration.
73 add_string_config(const char *key, const ucl_object_t *obj, nvlist_t *config) in add_string_config() argument
78 report_config_error(key, obj, "string"); in add_string_config()
80 nvlist_add_string(config, key, val); in add_string_config()
84 * Verifies that the value specified in the config file is a integer value
85 * within the specified range, and then adds the value to the configuration.
88 add_uint_config(const char *key, const ucl_object_t *obj, nvlist_t *config, in add_uint_config() argument
96 report_config_error(key, obj, type); in add_uint_config()
99 report_config_error(key, obj, type); in add_uint_config()
103 report_config_error(key, obj, type); in add_uint_config()
105 nvlist_add_number(config, key, uval); in add_uint_config()
109 * Verifies that the value specified in the config file is a unicast MAC
110 * address, and then adds the value to the configuration.
113 add_unicast_mac_config(const char *key, const ucl_object_t *obj, nvlist_t *config) in add_unicast_mac_config() argument
119 u_long value; in add_unicast_mac_config() local
123 report_config_error(key, obj, "unicast-mac"); in add_unicast_mac_config()
134 report_config_error(key, obj, "unicast-mac"); in add_unicast_mac_config()
136 value = strtoul(token, &endpos, 16); in add_unicast_mac_config()
139 report_config_error(key, obj, "unicast-mac"); in add_unicast_mac_config()
141 if (value > UINT8_MAX) in add_unicast_mac_config()
142 report_config_error(key, obj, "unicast-mac"); in add_unicast_mac_config()
145 report_config_error(key, obj, "unicast-mac"); in add_unicast_mac_config()
147 mac[i] = value; in add_unicast_mac_config()
154 report_config_error(key, obj, "unicast-mac"); in add_unicast_mac_config()
157 errx(1, "Value '%s' of key '%s' is a multicast address", in add_unicast_mac_config()
158 ucl_object_tostring(obj), key); in add_unicast_mac_config()
160 nvlist_add_binary(config, key, mac, ETHER_ADDR_LEN); in add_unicast_mac_config()
164 add_vlan_config(const char *key, const ucl_object_t *obj, nvlist_t *config) in add_vlan_config() argument
171 nvlist_add_number(config, key, VF_VLAN_TRUNK); in add_vlan_config()
174 report_config_error(key, obj, "vlan"); in add_vlan_config()
178 report_config_error(key, obj, "vlan"); in add_vlan_config()
181 report_config_error(key, obj, "vlan"); in add_vlan_config()
183 nvlist_add_number(config, key, val); in add_vlan_config()
187 * Validates that the given configuration value has the right type as specified
188 * in the schema, and then adds the value to the configuration node.
191 add_config(const char *key, const ucl_object_t *obj, nvlist_t *config, in add_config() argument
199 add_bool_config(key, obj, config); in add_config()
201 add_string_config(key, obj, config); in add_config()
203 add_uint_config(key, obj, config, type, UINT8_MAX); in add_config()
205 add_uint_config(key, obj, config, type, UINT16_MAX); in add_config()
207 add_uint_config(key, obj, config, type, UINT32_MAX); in add_config()
209 add_uint_config(key, obj, config, type, UINT64_MAX); in add_config()
210 else if (strcasecmp(type, "unicast-mac") == 0) in add_config()
211 add_unicast_mac_config(key, obj, config); in add_config()
213 add_vlan_config(key, obj, config); in add_config()
220 * validates that the key/value pair is valid in the schema, and then adds
221 * the key/value pair to the correct subsystem in the config.
231 const char *key; in parse_device_config() local
254 key = ucl_object_key(obj); in parse_device_config()
256 if (nvlist_exists_nvlist(iov_schema, key)) in parse_device_config()
257 add_config(key, obj, iov_config, in parse_device_config()
258 nvlist_get_nvlist(iov_schema, key)); in parse_device_config()
259 else if (nvlist_exists_nvlist(driver_schema, key)) in parse_device_config()
260 add_config(key, obj, driver_config, in parse_device_config()
261 nvlist_get_nvlist(driver_schema, key)); in parse_device_config()
263 errx(1, "%s: Invalid config key '%s'", subsystem, key); in parse_device_config()
286 const char *errmsg, *key; in parse_config_file() local
290 regex_err = regcomp(&vf_pat, "^"VF_PREFIX"([1-9][0-9]*|0)$", in parse_config_file()
317 key = ucl_object_key(obj); in parse_config_file()
319 if (strcasecmp(key, PF_CONFIG_NAME) == 0) in parse_config_file()
320 parse_device_config(obj, config, key, pf_schema); in parse_config_file()
321 else if (strcasecmp(key, DEFAULT_SCHEMA_NAME) == 0) { in parse_config_file()
325 * the user by having a default value apply to a VF in parse_config_file()
337 parse_device_config(obj, config, key, vf_schema); in parse_config_file()
338 } else if (regexec(&vf_pat, key, 0, NULL, 0) == 0) { in parse_config_file()
340 parse_device_config(obj, config, key, vf_schema); in parse_config_file()
342 errx(1, "Unexpected top-level node: %s", key); in parse_config_file()
355 * Parse the PF configuration section for and return the value specified for
363 const char *key, *device; in find_pf_device() local
367 key = ucl_object_key(obj); in find_pf_device()
369 if (strcasecmp(key, "device") == 0) { in find_pf_device()
399 const char *errmsg, *key; in find_device() local
419 key = ucl_object_key(obj); in find_device()
421 if (strcasecmp(key, PF_CONFIG_NAME) == 0) { in find_device()