#define PW_BASE_TYPE(_t) (0xff & (_t))
/* @} **/
+typedef enum {
+ CF_DATA_TYPE_DEFAULT = 0,
+ CF_DATA_TYPE_CLIENT,
+ CF_DATA_TYPE_HOME_SERVER_POOL,
+ CF_DATA_TYPE_UNLANG,
+ CF_DATA_TYPE_PROTOCOL,
+ CF_DATA_TYPE_MODULE_INSTANCE,
+ CF_DATA_TYPE_CONNECTION_POOL,
+ CF_DATA_TYPE_TLS
+} cf_data_type_t;
+
#define FR_SIZE_COND_CHECK(_name, _var, _cond, _new)\
do {\
if (!(_cond)) {\
* If the client list already exists, use that.
* Otherwise, create a new client list.
*/
- clients = cf_data_find(cs, 0, "clients");
+ clients = cf_data_find(cs, CF_DATA_TYPE_CLIENT, "clients");
if (!clients) {
clients = client_list_init(cs);
if (!clients) {
return false;
}
- if (cf_data_add(cs, 0, "clients", clients, (void (*)(void *)) client_list_free) < 0) {
+ if (cf_data_add(cs, CF_DATA_TYPE_CLIENT,
+ "clients", clients, (void (*)(void *)) client_list_free) < 0) {
ERROR("Failed to associate clients with virtual server %s", client->server);
client_list_free(clients);
return false;
/*
* Associate the clients structure with the section.
*/
- if (cf_data_add(section, 0, "clients", clients, NULL) < 0) {
+ if (cf_data_add(section, CF_DATA_TYPE_CLIENT, "clients", clients, NULL) < 0) {
cf_log_err_cs(section, "Failed to associate clients with section %s", cf_section_name1(section));
client_list_free(clients);
return NULL;
FILE *fp;
top = cf_top_section(cs);
- tree = cf_data_find(top, 0, "filename");
+ tree = cf_data_find(top, CF_DATA_TYPE_DEFAULT, "filename");
if (!tree) return NULL;
fp = fopen(filename, "r");
int fd;
top = cf_top_section(cs);
- tree = cf_data_find(top, 0, "filename");
+ tree = cf_data_find(top, CF_DATA_TYPE_DEFAULT, "filename");
if (!tree) return false;
file = talloc(tree, cf_file_t);
rbtree_t *tree;
top = cf_top_section(cs);
- tree = cf_data_find(top, 0, "filename");
+ tree = cf_data_find(top, CF_DATA_TYPE_DEFAULT, "filename");
if (!tree) return true;
cb.rcode = CF_FILE_NONE;
talloc_free(p);
css->name2 = talloc_typed_strdup(css, buff[2]);
- cf_data_add(css, 0, "if", cond, NULL);
+ cf_data_add(css, CF_DATA_TYPE_UNLANG, "if", cond, NULL);
add_section:
cf_item_add(this, &(css->item));
tree = rbtree_create(cs, filename_cmp, NULL, 0);
if (!tree) return -1;
- cf_data_add(cs, 0, "filename", tree, NULL);
+ cf_data_add(cs, CF_DATA_TYPE_DEFAULT, "filename", tree, NULL);
/*
* Allocate temporary buffers on the heap (so we don't use *all* the stack space)
* FIXME: check for "if" or "elsif". And if so, print
* out the parsed condition, instead of the input text
*
- * cf_data_find(cs, 0, "if");
+ * cf_data_find(cs, CF_DATA_TYPE_UNLANG, "if");
*/
if (cs->name2) {
fputs(" ", fp);
- c = cf_data_find(cs, 0, "if");
+ c = cf_data_find(cs, CF_DATA_TYPE_UNLANG, "if");
if (c) {
char buffer[1024];
* associated with sections.
*/
if (cs) {
- instruction = cf_data_find(cs, 0, "unlang");
+ instruction = cf_data_find(cs, CF_DATA_TYPE_UNLANG, "unlang");
if (!instruction) {
REDEBUG("Failed to find pre-compiled unlang for section %s %s { ... }",
cf_section_name1(cs), cf_section_name2(cs));
{
rad_protocol_t const *proto;
- proto = cf_data_find(cs, 0, "proto");
+ proto = cf_data_find(cs, CF_DATA_TYPE_PROTOCOL, "proto");
if (!proto || !proto->compile) return 0;
if (proto->compile(server, cs) < 0) {
return -1;
}
- if (cf_data_find(cs, 0, "proto") != NULL) {
+ if (cf_data_find(cs, CF_DATA_TYPE_PROTOCOL, "proto") != NULL) {
cf_log_err_cs(cs, "Virtual server cannot have two protocols");
talloc_const_free(module);
return -1;
}
- cf_data_add(cs, 0, "proto", proto, NULL);
+ cf_data_add(cs, CF_DATA_TYPE_PROTOCOL, "proto", proto, NULL);
}
/*
g->map = talloc_steal(g, head);
#ifdef WITH_CONF_WRITE
-// cf_data_add(cs, 0, "update", g->map, NULL); /* for output normalization */
+// cf_data_add(cs, CF_DATA_TYPE_UNLANG, "update", g->map, NULL); /* for output normalization */
#endif
if (!pass2_fixup_update(g)) {
/*
* Skip precompiled blocks.
*/
- if (cf_data_find(subcs, 0, "unlang")) continue;
+ if (cf_data_find(subcs, CF_DATA_TYPE_UNLANG, "unlang")) continue;
/*
* "actions" apply to the current group.
return NULL;
}
- cond = cf_data_find(cs, 0, "if");
+ cond = cf_data_find(cs, CF_DATA_TYPE_UNLANG, "if");
rad_assert(cond != NULL);
if (cond->type == COND_TYPE_FALSE) {
/*
* Associate the unlang with the configuration section.
*/
- cf_data_add(cs, 0, "unlang", c, NULL);
+ cf_data_add(cs, CF_DATA_TYPE_UNLANG, "unlang", c, NULL);
dump_tree(c, c->debug_name);
return 0;
cp = cf_pair_find(module, name);
if (!cp) return 0;
- if (cf_data_find(module, 0, FIND_SIBLING_CF_KEY)) {
+ if (cf_data_find(module, CF_DATA_TYPE_CONNECTION_POOL, FIND_SIBLING_CF_KEY)) {
cf_log_err_cp(cp, "Module reference loop found");
return -1;
}
- cf_data_add(module, 0, FIND_SIBLING_CF_KEY, &loop, NULL);
+ cf_data_add(module, CF_DATA_TYPE_CONNECTION_POOL, FIND_SIBLING_CF_KEY, &loop, NULL);
/*
* Item found, resolve it to a module instance.
* Remove the config data we added for loop
* detection.
*/
- cf_data_remove(module, 0, FIND_SIBLING_CF_KEY);
+ cf_data_remove(module, CF_DATA_TYPE_CONNECTION_POOL, FIND_SIBLING_CF_KEY);
if (!inst) {
cf_log_err_cp(cp, "Unknown module instance \"%s\"", inst_name);
* This allows modules to pass in the config sections
* they would like to use the connection pool from.
*/
- pool = cf_data_find(cs, 0, CONNECTION_POOL_CF_KEY);
+ pool = cf_data_find(cs, CF_DATA_TYPE_CONNECTION_POOL, CONNECTION_POOL_CF_KEY);
if (!pool) {
DEBUG4("%s: No pool reference found for config item \"%s.pool\"", log_prefix, parent_name(cs));
pool = fr_connection_pool_init(cs, cs, opaque, c, a, log_prefix);
fr_connection_pool_enable_triggers(pool, trigger_prefix, trigger_args);
DEBUG4("%s: Adding pool reference %p to config item \"%s.pool\"", log_prefix, pool, parent_name(cs));
- cf_data_add(cs, 0, CONNECTION_POOL_CF_KEY, pool, NULL);
+ cf_data_add(cs, CF_DATA_TYPE_CONNECTION_POOL, CONNECTION_POOL_CF_KEY, pool, NULL);
return pool;
}
fr_connection_pool_ref(pool);
if (mycs != cs) {
DEBUG4("%s: Copying pool reference %p from config item \"%s.pool\" to config item \"%s.pool\"",
log_prefix, pool, parent_name(cs), parent_name(mycs));
- cf_data_add(mycs, 0, CONNECTION_POOL_CF_KEY, pool, NULL);
+ cf_data_add(mycs, CF_DATA_TYPE_CONNECTION_POOL, CONNECTION_POOL_CF_KEY, pool, NULL);
}
return pool;
instance_name = asked_name;
if (instance_name[0] == '-') instance_name++;
- return (module_instance_t *)cf_data_find(modules, 0, instance_name);
+ return (module_instance_t *)cf_data_find(modules, CF_DATA_TYPE_CONNECTION_POOL, instance_name);
}
/** Find an existing module instance and verify it implements the specified method
/*
* Remember the module for later.
*/
- cf_data_add(modules, 0, instance->name, instance, NULL);
+ cf_data_add(modules, CF_DATA_TYPE_CONNECTION_POOL, instance->name, instance, NULL);
return instance;
}
/*
* Mark it as already processed
*/
- cf_data_add(home->cs, 0, "home_server", (void *)null_free, null_free);
+ cf_data_add(home->cs, CF_DATA_TYPE_HOME_SERVER_POOL, "home_server", (void *)null_free, null_free);
return true;
}
if (do_print) cf_log_info(cs, " }");
- cf_data_add(cs, 0, "home_server_pool", pool, NULL);
+ cf_data_add(cs, CF_DATA_TYPE_HOME_SERVER_POOL, "home_server_pool", pool, NULL);
(void) talloc_steal(cs, pool);
rad_assert(pool->server_type != 0);
/*
* Pool was already loaded.
*/
- if (cf_data_find(cs, 0, "home_server_pool")) continue;
+ if (cf_data_find(cs, CF_DATA_TYPE_HOME_SERVER_POOL, "home_server_pool")) continue;
type = pool_peek_type(config, cs);
if (type == HOME_TYPE_INVALID) goto error;
* If cs has already been parsed there should be a cached copy
* of conf already stored, so just return that.
*/
- conf = cf_data_find(cs, 0, "tls-conf");
+ conf = cf_data_find(cs, CF_DATA_TYPE_TLS, "tls-conf");
if (conf) {
DEBUG("Using cached TLS configuration from previous invocation");
return conf;
/*
* Cache conf in cs in case we're asked to parse this again.
*/
- cf_data_add(cs, 0, "tls-conf", conf, NULL);
+ cf_data_add(cs, CF_DATA_TYPE_TLS, "tls-conf", conf, NULL);
return conf;
}
fr_tls_conf_t *conf;
uint32_t i;
- conf = cf_data_find(cs, 0, "tls-conf");
+ conf = cf_data_find(cs, CF_DATA_TYPE_TLS, "tls-conf");
if (conf) {
DEBUG2("Using cached TLS configuration from previous invocation");
return conf;