More...
#include <ctype.h>
#include <stdlib.h>
#include "../../mem/mem.h"
#include "../../mem/shm_mem.h"
#include "../../str.h"
#include "../../ut.h"
#include "cr_fifo.h"
#include "carrierroute.h"
#include "cr_config.h"
#include "cr_carrier.h"
#include "cr_domain.h"
#include "cr_rule.h"

Go to the source code of this file.
Functions | |
| struct mi_root * | activate_host (struct mi_root *cmd_tree, void *param) |
| struct mi_root * | add_host (struct mi_root *cmd_tree, void *param) |
| struct mi_root * | deactivate_host (struct mi_root *cmd_tree, void *param) |
| struct mi_root * | delete_host (struct mi_root *cmd_tree, void *param) |
| struct mi_root * | dump_fifo (struct mi_root *cmd_tree, void *param) |
| static int | dump_tree_recursor (struct mi_node *msg, struct dtrie_node_t *node, char *prefix) |
| static int | get_fifo_opts (str *buf, fifo_opt_t *opts, unsigned int opt_set[]) |
| static struct mi_root * | print_fifo_err (void) |
| static struct mi_root * | print_replace_help (void) |
| struct mi_root * | reload_fifo (struct mi_root *cmd_tree, void *param) |
| struct mi_root * | replace_host (struct mi_root *cmd_tree, void *param) |
| static int | str_toklen (str *str, const char *delims) |
| static int | update_route_data (fifo_opt_t *opts) |
| static int | update_route_data_recursor (struct dtrie_node_t *node, str *act_domain, fifo_opt_t *opts) |
Variables | |
| int | fifo_err |
| static unsigned int | opt_settings [5][3] |
| static int | updated |
Definition in file cr_fifo.c.
activates the host given in the command line options, can be used only in file mode expect one mi node that contains the command
| cmd_tree | the MI command tree | |
| param | the parameter |
Definition at line 272 of file cr_fifo.c.
References CARRIERROUTE_MODE_FILE, fifo_opt::cmd, get_fifo_opts(), init_mi_tree(), mi_node::kids, MI_MISSING_PARM_LEN, MI_MISSING_PARM_S, MI_OK_LEN, MI_OK_S, mode, mi_node::next, mi_root::node, NULL, OPT_ACTIVATE, opt_settings, print_fifo_err(), _str::s, fifo_opt::status, update_route_data(), and mi_node::value.
adds the host specified by the command line args, can be used only in file mode expect one mi node that contains the command
| cmd_tree | the MI command tree | |
| param | the parameter |
Definition at line 316 of file cr_fifo.c.
References CARRIERROUTE_MODE_FILE, fifo_opt::cmd, get_fifo_opts(), init_mi_tree(), mi_node::kids, MI_MISSING_PARM_LEN, MI_MISSING_PARM_S, MI_OK_LEN, MI_OK_S, mode, mi_node::next, mi_root::node, NULL, OPT_ADD, opt_settings, print_fifo_err(), _str::s, fifo_opt::status, update_route_data(), and mi_node::value.
deactivates the host given in the command line options, can be used only in file mode expect one mi node that contains the command
| cmd_tree | the MI command tree | |
| param | the parameter |
Definition at line 228 of file cr_fifo.c.
References CARRIERROUTE_MODE_FILE, fifo_opt::cmd, get_fifo_opts(), init_mi_tree(), mi_node::kids, MI_MISSING_PARM_LEN, MI_MISSING_PARM_S, MI_OK_LEN, MI_OK_S, mode, mi_node::next, mi_root::node, NULL, OPT_DEACTIVATE, opt_settings, print_fifo_err(), _str::s, fifo_opt::status, update_route_data(), and mi_node::value.
deletes the host specified by the command line args, can be used only in file mode expect one mi node that contains the command
| cmd_tree | the MI command tree | |
| param | the parameter |
Definition at line 356 of file cr_fifo.c.
References CARRIERROUTE_MODE_FILE, fifo_opt::cmd, get_fifo_opts(), init_mi_tree(), mi_node::kids, MI_MISSING_PARM_LEN, MI_MISSING_PARM_S, MI_OK_LEN, MI_OK_S, mode, mi_node::next, mi_root::node, NULL, OPT_REMOVE, opt_settings, print_fifo_err(), _str::s, update_route_data(), and mi_node::value.
prints the routing data
| cmd_tree | the MI command tree | |
| param | the parameter |
Definition at line 125 of file cr_fifo.c.
References addf_mi_node_child(), route_data_t::carrier_num, route_data_t::carriers, carrier_data_t::domain_num, carrier_data_t::domains, dump_tree_recursor(), free_mi_tree(), get_data(), domain_data_t::id, carrier_data_t::id, init_mi_tree(), _str::len, LM_DBG, LM_ERR, MI_OK_LEN, MI_OK_S, domain_data_t::name, carrier_data_t::name, mi_root::node, NULL, release_data(), _str::s, str_init, and domain_data_t::tree.
| static int dump_tree_recursor | ( | struct mi_node * | msg, | |
| struct dtrie_node_t * | node, | |||
| char * | prefix | |||
| ) | [static] |
does the work for dump_fifo, traverses the routing tree and prints route rules if present.
| msg | MI node that is used to append the informations | |
| node | pointer to the routing tree node | |
| prefix | carries the current scan prefix |
Definition at line 399 of file cr_fifo.c.
References addf_mi_node_child(), route_rule::backed_up, route_rule::backup, route_rule::comment, cr_match_mode, DICE_MAX, route_flags::dice_max, route_rule::host, _str::len, route_rule::local_prefix, route_rule::local_suffix, route_rule_p_list::next, route_rule::next, route_flags::next, mi_node::next, NULL, route_rule::prob, route_rule_p_list::rr, route_flags::rule_list, _str::s, s, route_rule::status, and route_rule::strip.
Referenced by dump_fifo().
| static int get_fifo_opts | ( | str * | buf, | |
| fifo_opt_t * | opts, | |||
| unsigned int | opt_set[] | |||
| ) | [static] |
parses the command line argument for options
| buf | the command line argument | |
| opts | fifo options | |
| opt_set | set of the options |
Definition at line 462 of file cr_fifo.c.
References CR_EMPTY_PREFIX, fifo_opt::domain, E_HELP, E_INVALIDOPT, E_MISSOPT, E_NOOPT, E_WRONGOPT, FIFO_ERR, fifo_opt::hash_index, fifo_opt::host, len, _str::len, LM_DBG, fifo_opt::new_host, NULL, O_DOMAIN, O_H_INDEX, O_HOST, O_NEW_TARGET, O_PREFIX, O_PROB, O_R_PREFIX, O_R_SUFFIX, OPT_DOMAIN, OPT_DOMAIN_CHR, OPT_HASH_INDEX, OPT_HASH_INDEX_CHR, OPT_HELP_CHR, OPT_HOST, OPT_HOST_CHR, OPT_INVALID, OPT_MANDATORY, OPT_NEW_TARGET, OPT_NEW_TARGET_CHR, OPT_PREFIX, OPT_PREFIX_CHR, OPT_PROB, OPT_PROB_CHR, OPT_R_PREFIX, OPT_R_PREFIX_CHR, OPT_R_SUFFIX, OPT_R_SUFFIX_CHR, OPT_STRIP, fifo_opt::prefix, fifo_opt::prob, fifo_opt::rewrite_prefix, fifo_opt::rewrite_suffix, s, _str::s, str2sint(), str_strcasecmp(), str_toklen(), and fifo_opt::strip.
Referenced by activate_host(), add_host(), deactivate_host(), delete_host(), and replace_host().
| struct mi_root * print_fifo_err | ( | void | ) | [static, read] |
interpret the fifo errors, creates a mi tree
Definition at line 934 of file cr_fifo.c.
References E_ADDBACKUP, E_DELBACKUP, E_HELP, E_INVALIDOPT, E_LOADCONF, E_MISC, E_MISSOPT, E_NOAUTOBACKUP, E_NOHASHBACKUP, E_NOHOSTBACKUP, E_NOMEM, E_NOOPT, E_NOUPDATE, E_RESET, E_RULEFIXUP, E_SAVECONF, E_WRONGOPT, fifo_err, init_mi_tree(), MI_BAD_PARM_LEN, MI_BAD_PARM_S, MI_MISSING_PARM_LEN, MI_MISSING_PARM_S, NULL, and print_replace_help().
Referenced by activate_host(), add_host(), deactivate_host(), delete_host(), and replace_host().
| static struct mi_root * print_replace_help | ( | void | ) | [static, read] |
prints a short help text for fifo command usage
Definition at line 883 of file cr_fifo.c.
References addf_mi_node_child(), free_mi_tree(), init_mi_tree(), MI_OK_LEN, MI_OK_S, mi_root::node, NULL, OPT_DOMAIN_CHR, OPT_HASH_INDEX_CHR, OPT_HELP_CHR, OPT_HOST_CHR, OPT_NEW_TARGET_CHR, OPT_PREFIX_CHR, OPT_PROB_CHR, OPT_R_PREFIX_CHR, and OPT_R_SUFFIX_CHR.
Referenced by print_fifo_err().
reloads the routing data
| cmd_tree | the MI command tree | |
| param | the parameter |
Definition at line 104 of file cr_fifo.c.
References init_mi_tree(), MI_OK_LEN, MI_OK_S, NULL, and reload_route_data().
replaces the host specified by parameters in the fifo command, can be used only in file mode expect one mi node that contains the command
| cmd_tree | the MI command tree | |
| param | the parameter |
Definition at line 184 of file cr_fifo.c.
References CARRIERROUTE_MODE_FILE, fifo_opt::cmd, get_fifo_opts(), init_mi_tree(), mi_node::kids, MI_MISSING_PARM_LEN, MI_MISSING_PARM_S, MI_OK_LEN, MI_OK_S, mode, mi_node::next, mi_root::node, NULL, OPT_REPLACE, opt_settings, print_fifo_err(), _str::s, fifo_opt::status, update_route_data(), and mi_node::value.
| static int str_toklen | ( | str * | str, | |
| const char * | delims | |||
| ) | [static] |
| static int update_route_data | ( | fifo_opt_t * | opts | ) | [static] |
loads the config data into shared memory (but doesn't really share it), updates the routing data and writes it to the config file. Afterwards, the global routing data is reloaded.
| opts | pointer to the option structure which contains data to be modified or to be added |
Definition at line 605 of file cr_fifo.c.
References add_route(), route_data_t::carrier_num, route_data_t::carriers, clear_route_data(), fifo_opt::cmd, fifo_opt::domain, route_data_t::domain_map, carrier_data_t::domain_num, route_data_t::domain_num, carrier_data_t::domains, E_LOADCONF, E_NOUPDATE, E_RULEFIXUP, E_SAVECONF, FIFO_ERR, fifo_opt::hash_index, fifo_opt::host, _str::len, LM_ERR, load_config(), map_name2id(), domain_data_t::name, NULL, OPT_ADD, fifo_opt::prefix, fifo_opt::prob, reload_route_data(), fifo_opt::rewrite_prefix, fifo_opt::rewrite_suffix, rule_fixup(), _str::s, save_config(), shm_malloc(), SHM_MEM_ERROR, fifo_opt::status, str_init, fifo_opt::strip, domain_data_t::tree, update_route_data_recursor(), and updated.
Referenced by activate_host(), add_host(), deactivate_host(), delete_host(), and replace_host().
| static int update_route_data_recursor | ( | struct dtrie_node_t * | node, | |
| str * | act_domain, | |||
| fifo_opt_t * | opts | |||
| ) | [static] |
Does the work for update_route_data by recursively traversing the routing tree
| node | points to the current routing tree node | |
| act_domain | routing domain which is currently searched | |
| opts | points to the fifo command option structure |
Definition at line 731 of file cr_fifo.c.
References add_backup_rule(), route_rule::backed_up, route_rule::backup, fifo_opt::cmd, cr_match_mode, destroy_route_rule(), fifo_opt::domain, E_ADDBACKUP, E_DELBACKUP, E_NOAUTOBACKUP, E_NOHASHBACKUP, E_NOHOSTBACKUP, E_NOMEM, E_RESET, FIFO_ERR, find_auto_backup(), find_rule_by_hash(), find_rule_by_host(), hash, route_rule::host, fifo_opt::host, _str::len, LM_ERR, LM_INFO, route_flags::max_targets, fifo_opt::new_host, route_rule::next, NULL, OPT_ACTIVATE, OPT_DEACTIVATE, OPT_REMOVE, OPT_REPLACE, OPT_STAR, route_rule::prefix, fifo_opt::prefix, route_rule::prob, fifo_opt::prob, remove_backed_up(), route_flags::rule_list, route_flags::rule_num, _str::s, shm_free, shm_malloc(), SHM_MEM_ERROR, fifo_opt::status, route_rule::status, and updated.
Referenced by update_route_data().
| int fifo_err |
unsigned int opt_settings[5][3] [static] |
Initial value:
{{O_PREFIX|O_DOMAIN|O_HOST|O_PROB, O_R_PREFIX|O_R_SUFFIX|O_H_INDEX, O_NEW_TARGET},
{O_HOST|O_DOMAIN|O_PREFIX, O_PROB, O_R_PREFIX|O_R_SUFFIX|O_NEW_TARGET|O_H_INDEX},
{O_HOST|O_NEW_TARGET, O_PREFIX|O_DOMAIN|O_PROB, O_R_PREFIX|O_R_SUFFIX|O_H_INDEX},
{O_HOST|O_DOMAIN|O_PREFIX, O_PROB|O_NEW_TARGET, O_R_PREFIX|O_R_SUFFIX|O_H_INDEX},
{O_HOST|O_DOMAIN|O_PREFIX, O_PROB, O_R_PREFIX|O_R_SUFFIX|O_NEW_TARGET|O_H_INDEX}}
Definition at line 52 of file cr_fifo.c.
Referenced by activate_host(), add_host(), deactivate_host(), delete_host(), and replace_host().
int updated [static] |
Definition at line 60 of file cr_fifo.c.
Referenced by update_contacts(), update_route_data(), and update_route_data_recursor().
1.5.6