The FreeRADIUS server $Id: 15bac2a4c627c01d1aa2047687b3418955ac7f00 $
Loading...
Searching...
No Matches
Macros | Typedefs | Enumerations | Functions | Variables
radict.c File Reference

Utility to print attribute data in tab delimited format. More...

#include <freeradius-devel/util/conf.h>
#include <freeradius-devel/util/syserror.h>
#include <freeradius-devel/util/atexit.h>
#include <freeradius-devel/util/dict_priv.h>
#include <dirent.h>
#include <sys/stat.h>
#include <stdbool.h>
+ Include dependency graph for radict.c:

Go to the source code of this file.

Macros

#define CHECK_TYPE(_parent)
 
#define DEBUG(fmt, ...)   if (fr_log_fp && (fr_debug_lvl > 1)) fprintf(fr_log_fp , fmt "\n", ## __VA_ARGS__)
 
#define DEBUG2(fmt, ...)   if (fr_log_fp && (fr_debug_lvl > 2)) fprintf(fr_log_fp , fmt "\n", ## __VA_ARGS__)
 
#define ENUM_NAME(_x)   [_x] = STRINGIFY(_x)
 Map data types to enum names representing those types.
 
#define INFO(fmt, ...)   if (fr_log_fp && (fr_debug_lvl > 0)) fprintf(fr_log_fp , fmt "\n", ## __VA_ARGS__)
 

Typedefs

typedef void(* da_print_func_t) (FILE *fp, fr_dict_attr_t const *da)
 

Enumerations

enum  radict_out_t {
  RADICT_OUT_INVALID = 0 ,
  RADICT_OUT_FANCY ,
  RADICT_OUT_CSV ,
  RADICT_OUT_DICT ,
  RADICT_OUT_STRUCT ,
  RADICT_OUT_STATS_LINK ,
  RADICT_OUT_BASE_C_DA_DEF ,
  RADICT_OUT_ATTR_AUTOLOAD ,
  RADICT_OUT_STATS_H
}
 

Functions

static void _raddict_export (fr_dict_t const *dict, uint64_t *count, uintptr_t *low, uintptr_t *high, fr_dict_attr_t const *da, unsigned int lvl)
 
static bool children_ok (fr_dict_attr_t const *parent)
 
static void da_normalize_name (fr_dict_attr_t const *da, char buffer[static FR_DICT_ATTR_MAX_NAME_LEN+1])
 
static void da_print_attr_autoload (FILE *fp, fr_dict_attr_t const *parent)
 
static void da_print_base_c_da_def (FILE *fp, fr_dict_attr_t const *parent)
 
static void da_print_info (fr_dict_t const *dict, fr_dict_attr_t const *da, int depth)
 
static void da_print_name (FILE *fp, fr_dict_attr_t const *da)
 
static void da_print_stats_h (FILE *fp, fr_dict_attr_t const *parent)
 
static void da_print_stats_link (FILE *fp, fr_dict_attr_t const *parent)
 
static void da_print_struct (FILE *fp, fr_dict_attr_t const *parent)
 Print structures and mappings, mainly for statistics.
 
static int load_dicts (char const *dict_dir, char const *protocol)
 
int main (int argc, char *argv[])
 
static void raddict_export (uint64_t *count, uintptr_t *low, uintptr_t *high, fr_dict_t *dict)
 
static void usage (void)
 

Variables

static fr_dict_t ** dict_end = dicts
 
static fr_dict_tdicts [255]
 
static fr_table_num_ordered_t const format_table []
 
static size_t format_table_len = NUM_ELEMENTS(format_table)
 
static char const * fr_type_to_enum_name []
 
static fr_table_ptr_ordered_t const function_table []
 
static size_t function_table_len = NUM_ELEMENTS(function_table)
 
static char const * length_to_c_type []
 
static char const * mib = NULL
 
static radict_out_t output_format = RADICT_OUT_FANCY
 
static char const * parent_oid = NULL
 
static bool print_headers = false
 
static bool print_recursive = false
 
static bool print_values = false
 
static const char * spaces = " "
 
static const bool type_allowed [FR_TYPE_MAX]
 
static char const * type_to_c_type []
 

Detailed Description

Utility to print attribute data in tab delimited format.

Id
646c727293efc6c076dc809c408f2a914fdbb3aa

Definition in file radict.c.

Macro Definition Documentation

◆ CHECK_TYPE

#define CHECK_TYPE (   _parent)
Value:
do { \
if ((parent->type != FR_TYPE_STRUCT) && (parent->type != FR_TYPE_TLV)) { \
fprintf(stderr, "%s is not a struct or tlv\n", parent->name); \
return; \
} \
if (!children_ok(parent)) fr_exit(EXIT_FAILURE); \
} while (0)
#define fr_exit(_x)
Exit, producing a log message in debug builds.
Definition debug.h:220
@ FR_TYPE_TLV
Contains nested attributes.
@ FR_TYPE_STRUCT
like TLV, but without T or L, and fixed-width children
static bool children_ok(fr_dict_attr_t const *parent)
Definition radict.c:407
static fr_slen_t parent
Definition pair.h:859

Definition at line 419 of file radict.c.

◆ DEBUG

#define DEBUG (   fmt,
  ... 
)    if (fr_log_fp && (fr_debug_lvl > 1)) fprintf(fr_log_fp , fmt "\n", ## __VA_ARGS__)

Definition at line 63 of file radict.c.

◆ DEBUG2

#define DEBUG2 (   fmt,
  ... 
)    if (fr_log_fp && (fr_debug_lvl > 2)) fprintf(fr_log_fp , fmt "\n", ## __VA_ARGS__)

Definition at line 62 of file radict.c.

◆ ENUM_NAME

#define ENUM_NAME (   _x)    [_x] = STRINGIFY(_x)

Map data types to enum names representing those types.

Definition at line 528 of file radict.c.

◆ INFO

#define INFO (   fmt,
  ... 
)    if (fr_log_fp && (fr_debug_lvl > 0)) fprintf(fr_log_fp , fmt "\n", ## __VA_ARGS__)

Definition at line 64 of file radict.c.

Typedef Documentation

◆ da_print_func_t

typedef void(* da_print_func_t) (FILE *fp, fr_dict_attr_t const *da)

Definition at line 752 of file radict.c.

Enumeration Type Documentation

◆ radict_out_t

Enumerator
RADICT_OUT_INVALID 
RADICT_OUT_FANCY 
RADICT_OUT_CSV 
RADICT_OUT_DICT 
RADICT_OUT_STRUCT 
RADICT_OUT_STATS_LINK 
RADICT_OUT_BASE_C_DA_DEF 
RADICT_OUT_ATTR_AUTOLOAD 
RADICT_OUT_STATS_H 

Definition at line 40 of file radict.c.

Function Documentation

◆ _raddict_export()

static void _raddict_export ( fr_dict_t const *  dict,
uint64_t *  count,
uintptr_t *  low,
uintptr_t *  high,
fr_dict_attr_t const *  da,
unsigned int  lvl 
)
static

Definition at line 678 of file radict.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ children_ok()

static bool children_ok ( fr_dict_attr_t const *  parent)
static

Definition at line 407 of file radict.c.

+ Here is the call graph for this function:

◆ da_normalize_name()

static void da_normalize_name ( fr_dict_attr_t const *  da,
char  buffer[static FR_DICT_ATTR_MAX_NAME_LEN+1] 
)
static

Definition at line 322 of file radict.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ da_print_attr_autoload()

static void da_print_attr_autoload ( FILE *  fp,
fr_dict_attr_t const *  parent 
)
static

Definition at line 626 of file radict.c.

+ Here is the call graph for this function:

◆ da_print_base_c_da_def()

static void da_print_base_c_da_def ( FILE *  fp,
fr_dict_attr_t const *  parent 
)
static

Definition at line 504 of file radict.c.

+ Here is the call graph for this function:

◆ da_print_info()

static void da_print_info ( fr_dict_t const *  dict,
fr_dict_attr_t const *  da,
int  depth 
)
static

Definition at line 180 of file radict.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ da_print_name()

static void da_print_name ( FILE *  fp,
fr_dict_attr_t const *  da 
)
static

Definition at line 383 of file radict.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ da_print_stats_h()

static void da_print_stats_h ( FILE *  fp,
fr_dict_attr_t const *  parent 
)
static

Definition at line 657 of file radict.c.

+ Here is the call graph for this function:

◆ da_print_stats_link()

static void da_print_stats_link ( FILE *  fp,
fr_dict_attr_t const *  parent 
)
static

Definition at line 575 of file radict.c.

+ Here is the call graph for this function:

◆ da_print_struct()

static void da_print_struct ( FILE *  fp,
fr_dict_attr_t const *  parent 
)
static

Print structures and mappings, mainly for statistics.

Definition at line 430 of file radict.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ load_dicts()

static int load_dicts ( char const *  dict_dir,
char const *  protocol 
)
static

Definition at line 87 of file radict.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ main()

int main ( int  argc,
char *  argv[] 
)

Definition at line 759 of file radict.c.

◆ raddict_export()

static void raddict_export ( uint64_t *  count,
uintptr_t *  low,
uintptr_t *  high,
fr_dict_t dict 
)
static

Definition at line 719 of file radict.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ usage()

static void usage ( void  )
static

Definition at line 67 of file radict.c.

+ Here is the caller graph for this function:

Variable Documentation

◆ dict_end

fr_dict_t** dict_end = dicts
static

Definition at line 59 of file radict.c.

◆ dicts

fr_dict_t* dicts[255]
static

Definition at line 52 of file radict.c.

◆ format_table

fr_table_num_ordered_t const format_table[]
static
Initial value:
= {
{ L("fancy"), RADICT_OUT_FANCY },
{ L("csv"), RADICT_OUT_CSV },
{ L("dict"), RADICT_OUT_DICT },
{ L("struct"), RADICT_OUT_STRUCT },
{ L("stats_link"), RADICT_OUT_STATS_LINK },
{ L("da_def"), RADICT_OUT_BASE_C_DA_DEF },
{ L("attr_autoload"), RADICT_OUT_ATTR_AUTOLOAD },
{ L("stats.h"), RADICT_OUT_STATS_H },
}
#define L(_str)
Helper for initialising arrays of string literals.
Definition build.h:209
@ RADICT_OUT_STRUCT
Definition radict.c:45
@ RADICT_OUT_DICT
Definition radict.c:44
@ RADICT_OUT_STATS_H
Definition radict.c:49
@ RADICT_OUT_ATTR_AUTOLOAD
Definition radict.c:48
@ RADICT_OUT_BASE_C_DA_DEF
Definition radict.c:47
@ RADICT_OUT_STATS_LINK
Definition radict.c:46
@ RADICT_OUT_FANCY
Definition radict.c:42
@ RADICT_OUT_CSV
Definition radict.c:43

Definition at line 728 of file radict.c.

◆ format_table_len

size_t format_table_len = NUM_ELEMENTS(format_table)
static

Definition at line 738 of file radict.c.

◆ fr_type_to_enum_name

char const* fr_type_to_enum_name[]
static

Definition at line 530 of file radict.c.

◆ function_table

fr_table_ptr_ordered_t const function_table[]
static
Initial value:
= {
{ L("fancy"), NULL },
{ L("csv"), NULL },
{ L("dict"), NULL },
{ L("struct"), (void *) da_print_struct },
{ L("stats_link"), (void *) da_print_stats_link },
{ L("da_def"), (void *) da_print_base_c_da_def },
{ L("attr_autoload"), (void *) da_print_attr_autoload },
{ L("stats.h"), (void *) da_print_stats_h },
}
static void da_print_struct(FILE *fp, fr_dict_attr_t const *parent)
Print structures and mappings, mainly for statistics.
Definition radict.c:430
static void da_print_stats_link(FILE *fp, fr_dict_attr_t const *parent)
Definition radict.c:575
static void da_print_stats_h(FILE *fp, fr_dict_attr_t const *parent)
Definition radict.c:657
static void da_print_attr_autoload(FILE *fp, fr_dict_attr_t const *parent)
Definition radict.c:626
static void da_print_base_c_da_def(FILE *fp, fr_dict_attr_t const *parent)
Definition radict.c:504

Definition at line 740 of file radict.c.

◆ function_table_len

size_t function_table_len = NUM_ELEMENTS(function_table)
static

Definition at line 750 of file radict.c.

◆ length_to_c_type

char const* length_to_c_type[]
static
Initial value:
= {
[2] = "uint16_t",
[4] = "uint32_t",
[8] = "uint64_t",
}

Definition at line 316 of file radict.c.

◆ mib

char const* mib = NULL
static

Definition at line 56 of file radict.c.

◆ output_format

radict_out_t output_format = RADICT_OUT_FANCY
static

Definition at line 58 of file radict.c.

◆ parent_oid

char const* parent_oid = NULL
static

Definition at line 57 of file radict.c.

◆ print_headers

bool print_headers = false
static

Definition at line 54 of file radict.c.

◆ print_recursive

bool print_recursive = false
static

Definition at line 55 of file radict.c.

◆ print_values

bool print_values = false
static

Definition at line 53 of file radict.c.

◆ spaces

const char* spaces = " "
static

Definition at line 178 of file radict.c.

◆ type_allowed

const bool type_allowed[FR_TYPE_MAX]
static
Initial value:
= {
[FR_TYPE_STRING] = true,
[FR_TYPE_OCTETS] = true,
[FR_TYPE_UINT16] = true,
[FR_TYPE_UINT32] = true,
[FR_TYPE_UINT64] = true,
[FR_TYPE_DATE] = true,
}
@ FR_TYPE_TIME_DELTA
A period of time measured in nanoseconds.
@ FR_TYPE_IPV4_ADDR
32 Bit IPv4 Address.
@ FR_TYPE_STRING
String of printable characters.
@ FR_TYPE_UINT16
16 Bit unsigned integer.
@ FR_TYPE_DATE
Unix time stamp, always has value >2^31.
@ FR_TYPE_UINT32
32 Bit unsigned integer.
@ FR_TYPE_UINT64
64 Bit unsigned integer.
@ FR_TYPE_IPV6_ADDR
128 Bit IPv6 Address.
@ FR_TYPE_OCTETS
Raw octets.

Definition at line 391 of file radict.c.

◆ type_to_c_type

char const* type_to_c_type[]
static
Initial value:
= {
[FR_TYPE_STRING] = "char",
[FR_TYPE_OCTETS] = "uint8_t",
[FR_TYPE_IPV4_ADDR] = "struct in_addr",
[FR_TYPE_IPV6_ADDR] = "struct in6_addr",
[FR_TYPE_UINT8] = "uint8_t",
[FR_TYPE_UINT16] = "uint16_t",
[FR_TYPE_UINT32] = "uint32_t",
[FR_TYPE_UINT64] = "uint64_t",
[FR_TYPE_INT8] = "int8_t",
[FR_TYPE_INT16] = "int16_t",
[FR_TYPE_INT32] = "int32_t",
[FR_TYPE_INT64] = "int64_t",
[FR_TYPE_DATE] = "fr_time_t",
[FR_TYPE_TIME_DELTA] = "fr_time_delta_t",
[FR_TYPE_MAX] = 0
}
@ FR_TYPE_INT8
8 Bit signed integer.
@ FR_TYPE_MAX
Number of defined data types.
@ FR_TYPE_INT64
64 Bit signed integer.
@ FR_TYPE_INT16
16 Bit signed integer.
@ FR_TYPE_UINT8
8 Bit unsigned integer.
@ FR_TYPE_INT32
32 Bit signed integer.

Definition at line 290 of file radict.c.