*
* @{
*/
+void fr_dict_namespace_debug(fr_dict_attr_t const *da);
+
void fr_dict_attr_debug(fr_dict_attr_t const *da);
void fr_dict_debug(fr_dict_t const *dict);
/** Print extension debug information for attributes
*
*/
-static inline void dict_attr_ext_debug(fr_dict_attr_t const *da)
+static inline void dict_attr_ext_debug(char const *name, fr_dict_attr_t const *da)
{
- fr_ext_debug(&fr_dict_attr_ext_def, da->name, da);
+ fr_ext_debug(&fr_dict_attr_ext_def, name, da);
}
/** @} */
typedef struct {
fr_dict_t const *dict;
- char buff[256];
+ char prefix[256];
+ char flags[256];
unsigned int start_depth;
} fr_dict_attr_debug_t;
fr_dict_enum_t const *enumv;
fr_dict_attr_ext_enumv_t *ext;
- fr_dict_snprint_flags(&FR_SBUFF_OUT(our_uctx->buff, sizeof(our_uctx->buff)),
+ fr_dict_snprint_flags(&FR_SBUFF_OUT(our_uctx->flags, sizeof(our_uctx->flags)),
our_uctx->dict, da->type, &da->flags);
- FR_FAULT_LOG("[%02i] 0x%016" PRIxPTR "%*s %s(%u) %s %s",
- da->depth,
- (unsigned long)da,
- (da->depth - our_uctx->start_depth) * 4, "",
+ snprintf(our_uctx->prefix, sizeof(our_uctx->prefix),
+ "[%02i] 0x%016" PRIxPTR "%*s",
+ da->depth,
+ (unsigned long)da,
+ (da->depth - our_uctx->start_depth) * 4, "");
+
+ FR_FAULT_LOG("%s%s(%u) %s %s",
+ our_uctx->prefix,
da->name,
da->attr,
fr_table_str_by_value(fr_value_box_type_table, da->type, "<INVALID>"),
- our_uctx->buff);
+ our_uctx->flags);
- dict_attr_ext_debug(da); /* Print all the extension debug info */
+ dict_attr_ext_debug(our_uctx->prefix, da); /* Print all the extension debug info */
ext = fr_dict_attr_ext(da, FR_DICT_ATTR_EXT_ENUMV);
if (!ext || !ext->name_by_value) return 0;
for (enumv = fr_hash_table_iter_init(ext->name_by_value, &iter);
enumv;
enumv = fr_hash_table_iter_next(ext->name_by_value, &iter)) {
- FR_FAULT_LOG("[%02i] 0x%016" PRIxPTR "%*s%s -> %pV",
- da->depth,
- (unsigned long)da,
- ((da->depth + 1) - our_uctx->start_depth) * 4, "",
+ char *value = fr_asprintf(NULL, "%pV", enumv->value);
+
+ FR_FAULT_LOG("%s %s -> %s",
+ our_uctx->prefix,
enumv->name,
- enumv->value);
+ value);
+ talloc_free(value);
}
return 0;
}
+void fr_dict_namespace_debug(fr_dict_attr_t const *da)
+{
+ fr_dict_attr_debug_t uctx = { .dict = fr_dict_by_da(da), .start_depth = da->depth };
+ fr_hash_table_t *namespace;
+
+ namespace = dict_attr_namespace(da);
+ if (!namespace) FR_FAULT_LOG("%s does not have namespace", da->name);
+
+ fr_hash_table_walk(namespace, (fr_hash_table_walk_t)dict_attr_debug, &uctx);
+}
+
void fr_dict_attr_debug(fr_dict_attr_t const *da)
{
fr_dict_attr_debug_t uctx = { .dict = fr_dict_by_da(da), .start_depth = da->depth };
/** Search for an attribute name in all dictionaries
*
- * @param[in] ctx Attribute to search for.
* @param[in] data Dictionary to search in.
+ * @param[in] uctx Attribute to search for.
* @return
* - 0 if attribute not found in dictionary.
* - 1 if attribute found in dictionary.
*/
-static int _dict_attr_find_in_dicts(void *ctx, void *data)
+static int _dict_attr_find_in_dicts(void *data, void *uctx)
{
- dict_attr_search_t *search = ctx;
+ dict_attr_search_t *search = uctx;
fr_dict_t *dict;
fr_hash_table_t *namespace;
return 0;
}
-static int _dict_free_autoref(UNUSED void *ctx, void *data)
+static int _dict_free_autoref(void *data, UNUSED void *uctx)
{
fr_dict_t *dict = talloc_get_type_abort(data, fr_dict_t);
{
int i;
- FR_FAULT_LOG("ext: %s - total len = %zu", name, talloc_get_size(chunk));
+ FR_FAULT_LOG("%sext total_len=%zu", name, talloc_get_size(chunk));
for (i = 0; i < (int)def->max; i++) {
uint8_t *chunk_ext = CHUNK_EXT(def->info, def->offset_of_exts);
if (chunk_ext[i]) {
i, "<INVALID>");
if (ext_len > 1024) {
- FR_FAULT_LOG("ext: %s - possibly bad length %zu - limiting dump to 1024",
- ext_name, ext_len);
+ FR_FAULT_LOG("%sext id=%s - possibly bad length %zu - limiting dump to 1024",
+ name, ext_name, ext_len);
ext_len = 1024;
}
- FR_FAULT_LOG("ext: %s - start=%p end=%p len=%zu",
- ext_name, ext, ((uint8_t *)ext) + ext_len, ext_len);
+ FR_FAULT_LOG("%sext id=%s start=%p end=%p len=%zu",
+ name, ext_name, ext, ((uint8_t *)ext) + ext_len, ext_len);
FR_FAULT_LOG_HEX(ext, ext_len);
}
}
*/
int fr_hash_table_walk(fr_hash_table_t *ht,
fr_hash_table_walk_t callback,
- void *context)
+ void *uctx)
{
int i, ret;
for (node = ht->buckets[i]; node != &ht->null; node = next) {
next = node->next;
- ret = callback(context, node->data);
+ ret = callback(node->data, uctx);
if (ret != 0) return ret;
}
typedef void (*fr_hash_table_free_t)(void *);
typedef uint32_t (*fr_hash_table_hash_t)(void const *);
typedef int (*fr_hash_table_cmp_t)(void const *, void const *);
-typedef int (*fr_hash_table_walk_t)(void * /* ctx */, void * /* data */);
+typedef int (*fr_hash_table_walk_t)(void *data, void *uctx);
fr_hash_table_t *fr_hash_table_create(TALLOC_CTX *ctx,
fr_hash_table_hash_t hashNode,
int fr_hash_table_walk(fr_hash_table_t *ht,
fr_hash_table_walk_t callback,
- void *ctx);
+ void *uctx);
void *fr_hash_table_iter_next(fr_hash_table_t *ht, fr_hash_iter_t *iter);