![]() |
The FreeRADIUS server $Id: a4e7f8c94e8038b7627bcf52356b7ed15955c1d7 $
|
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 <freeradius-devel/util/hash.h>#include <ctype.h>#include <dirent.h>#include <stdlib.h>#include <sys/stat.h>#include <unistd.h>
Include dependency graph for radict.c:Go to the source code of this file.
Data Structures | |
| struct | raddict_stats_t |
| Totals gathered while exporting a dictionary. More... | |
Macros | |
| #define | CHECK_TYPE(_parent) |
| #define | DEBUG(fmt, ...) if (fr_log_fp && (fr_debug_lvl > 1)) fr_fprintf(fr_log_fp , fmt "\n", ## __VA_ARGS__) |
| #define | DEBUG2(fmt, ...) if (fr_log_fp && (fr_debug_lvl > 2)) fr_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)) fr_fprintf(fr_log_fp , fmt "\n", ## __VA_ARGS__) |
| #define | RADICT_POOL_MAX_SIZE ((size_t)64 * 1000 * 1000) |
| Largest pool that radict -P loads a dictionary with. | |
| #define | RADICT_POOL_STEP_SIZE ((size_t)10 * 1000 * 1000) |
| Bytes that radict -P adds to the largest overflowed pool to set the minimum pool size for the next reload. | |
Typedefs | |
| typedef void(* | da_print_func_t) (FILE *fp, fr_dict_attr_t const *da) |
Enumerations | |
| enum | radict_out_t : uint8_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 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 *2+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 | dicts_free (fr_dict_gctx_t *gctx) |
| Release radict's references to the dictionaries, then free the global dictionary context. | |
| static int | dicts_load (fr_dict_gctx_t **gctx_out, char const *dict_dir, char const *protocol, size_t pool_size_min) |
| Load the internal dictionary, then the protocol dictionaries. | |
| static size_t | dicts_overflow_max (fr_dict_gctx_t *gctx) |
| Find the size of the largest overflowed pool among the loaded protocol dictionaries. | |
| static int | dicts_pool_grow (fr_dict_gctx_t **gctx_p, char const *dict_dir, char const *protocol) |
| Reload the dictionaries with larger pools until no pool overflows. | |
| static int | file_replace (char const *filename, mode_t mode, char const *data, size_t len) |
| Write data to a temporary file, then rename the temporary file over filename. | |
| static bool | line_field_is (char const *field, char const *field_end, char const *keyword) |
| Check whether a field is a dictionary keyword. | |
| static char const * | line_field_next (char const **field_end, char const *p, char const *end) |
| Find the next whitespace-separated field on a dictionary line. | |
| static int | load_dicts (char const *dict_dir, char const *protocol) |
| int | main (int argc, char *argv[]) |
| static int | protocol_line_pool_set (fr_dict_t const *dict, size_t pool_mb) |
| Set pool=<size> on the PROTOCOL line that defines a dictionary. | |
| static int | protocol_lines_pool_set (fr_dict_gctx_t *gctx, unsigned int overhead) |
| Set pool= on the PROTOCOL line of every loaded protocol dictionary. | |
| static int | protocol_pools_check (fr_dict_gctx_t *gctx) |
| Print the pool size and the bytes used for every loaded protocol dictionary. | |
| static void | raddict_export (raddict_stats_t *stats, fr_dict_t const *dict, fr_dict_attr_t const *da) |
| static void | usage (void) |
Variables | |
| static fr_dict_t ** | dict_end = dicts |
| static fr_dict_t * | dicts [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 [] |
Utility to print attribute data in tab delimited format.
Definition in file radict.c.
| struct raddict_stats_t |
| #define CHECK_TYPE | ( | _parent | ) |
| #define DEBUG | ( | fmt, | |
| ... | |||
| ) | if (fr_log_fp && (fr_debug_lvl > 1)) fr_fprintf(fr_log_fp , fmt "\n", ## __VA_ARGS__) |
| #define DEBUG2 | ( | fmt, | |
| ... | |||
| ) | if (fr_log_fp && (fr_debug_lvl > 2)) fr_fprintf(fr_log_fp , fmt "\n", ## __VA_ARGS__) |
| #define INFO | ( | fmt, | |
| ... | |||
| ) | if (fr_log_fp && (fr_debug_lvl > 0)) fr_fprintf(fr_log_fp , fmt "\n", ## __VA_ARGS__) |
| typedef void(* da_print_func_t) (FILE *fp, fr_dict_attr_t const *da) |
| enum radict_out_t : uint8_t |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
Release radict's references to the dictionaries, then free the global dictionary context.
fr_dict_free() does not set the entry to NULL, so dicts_free() does. The release at the end of main() always visits dicts[0], even after a failed reload, and fr_dict_free() ignores a NULL entry.
| [in] | gctx | to free. |
Definition at line 1182 of file radict.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Load the internal dictionary, then the protocol dictionaries.
| [out] | gctx_out | The new global dictionary context. |
| [in] | dict_dir | to load the dictionaries from. |
| [in] | protocol | to load, or NULL to load every protocol. |
| [in] | pool_size_min | Smallest pool, in bytes, that dict_alloc() creates. |
Definition at line 1140 of file radict.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Find the size of the largest overflowed pool among the loaded protocol dictionaries.
| [in] | gctx | holding the loaded dictionaries. |
Definition at line 786 of file radict.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Reload the dictionaries with larger pools until no pool overflows.
Each reload sets the minimum pool size to the size of the largest overflowed pool plus RADICT_POOL_STEP_SIZE bytes.
| [in,out] | gctx_p | Global dictionary context. dicts_pool_grow() replaces *gctx_p on each reload. |
| [in] | dict_dir | to load the dictionaries from. |
| [in] | protocol | to load, or NULL to load every protocol. |
Definition at line 1214 of file radict.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
|
static |
|
static |
Find the next whitespace-separated field on a dictionary line.
| [out] | field_end | First byte after the field. |
| [in] | p | Position on the line to start the search from. |
| [in] | end | End of the line. |
Definition at line 817 of file radict.c.
Here is the caller graph for this function:
|
static |
Set pool=<size> on the PROTOCOL line that defines a dictionary.
protocol_line_pool_set() replaces any pool= option already on the PROTOCOL line, and keeps every other option, the whitespace between fields, and any comment.
Worked example: BEGIN PROTOCOL RADIUS 1 verify=lib keyword: BEGIN PROTOCOL, name: RADIUS, number: 1, options: verify=lib The line becomes: BEGIN PROTOCOL RADIUS 1 verify=lib,pool=12MB
| [in] | dict | whose PROTOCOL line to rewrite. |
| [in] | pool_mb | New pool size in megabytes (MB) of 1,000,000 bytes. |
Definition at line 915 of file radict.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Set pool= on the PROTOCOL line of every loaded protocol dictionary.
The new pool= is the measured size plus overhead percent, rounded up to whole megabytes (MB) of 1,000,000 bytes. The overhead covers space that loading used at the top of the pool and freed again, which talloc_pool_used() does not count.
Call protocol_lines_pool_set() only after dicts_pool_grow() returns 0, so that no pool has overflowed.
| [in] | gctx | holding the loaded dictionaries. |
| [in] | overhead | Percentage to add to the measured size. |
Definition at line 1040 of file radict.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
Print the pool size and the bytes used for every loaded protocol dictionary.
| [in] | gctx | holding the loaded dictionaries. |
Definition at line 1091 of file radict.c.
Here is the call graph for this function:
Here is the caller graph for this function:
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
1.9.8