cr_fifo.c File Reference

Functions for modifying routing data via fifo commands.

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"

Include dependency graph for cr_fifo.c:

Go to the source code of this file.

Functions

struct mi_rootactivate_host (struct mi_root *cmd_tree, void *param)
struct mi_rootadd_host (struct mi_root *cmd_tree, void *param)
struct mi_rootdeactivate_host (struct mi_root *cmd_tree, void *param)
struct mi_rootdelete_host (struct mi_root *cmd_tree, void *param)
struct mi_rootdump_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_rootprint_fifo_err (void)
static struct mi_rootprint_replace_help (void)
struct mi_rootreload_fifo (struct mi_root *cmd_tree, void *param)
struct mi_rootreplace_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


Detailed Description

Functions for modifying routing data via fifo commands.

Definition in file cr_fifo.c.


Function Documentation

struct mi_root* activate_host ( struct mi_root cmd_tree,
void *  param 
) [read]

activates the host given in the command line options, can be used only in file mode expect one mi node that contains the command

Parameters:
cmd_tree the MI command tree
param the parameter
Returns:
code 200 on success, code 400 or 500 on failure

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.

struct mi_root* add_host ( struct mi_root cmd_tree,
void *  param 
) [read]

adds the host specified by the command line args, can be used only in file mode expect one mi node that contains the command

Parameters:
cmd_tree the MI command tree
param the parameter
Returns:
code 200 on success, code 400 or 500 on failure

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.

struct mi_root* deactivate_host ( struct mi_root cmd_tree,
void *  param 
) [read]

deactivates the host given in the command line options, can be used only in file mode expect one mi node that contains the command

Parameters:
cmd_tree the MI command tree
param the parameter
Returns:
code 200 on success, code 400 or 500 on failure

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.

struct mi_root* delete_host ( struct mi_root cmd_tree,
void *  param 
) [read]

deletes the host specified by the command line args, can be used only in file mode expect one mi node that contains the command

Parameters:
cmd_tree the MI command tree
param the parameter
Returns:
code 200 on success, code 400 or 500 on failure

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.

struct mi_root* dump_fifo ( struct mi_root cmd_tree,
void *  param 
) [read]

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.

Parameters:
msg MI node that is used to append the informations
node pointer to the routing tree node
prefix carries the current scan prefix
Returns:
mi node containing the route rules

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]

struct mi_root * print_fifo_err ( void   )  [static, read]

static struct mi_root * print_replace_help ( void   )  [static, read]

struct mi_root* reload_fifo ( struct mi_root cmd_tree,
void *  param 
) [read]

reloads the routing data

Parameters:
cmd_tree the MI command tree
param the parameter
Returns:
code 200 on success, code 500 on failure

Definition at line 104 of file cr_fifo.c.

References init_mi_tree(), MI_OK_LEN, MI_OK_S, NULL, and reload_route_data().

struct mi_root* replace_host ( struct mi_root cmd_tree,
void *  param 
) [read]

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

Parameters:
cmd_tree the MI command tree
param the parameter
Returns:
code 200 on success, code 400 or 500 on failure

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]

Definition at line 75 of file cr_fifo.c.

References len, NULL, and _str::s.

Referenced by get_fifo_opts().

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.

Parameters:
opts pointer to the option structure which contains data to be modified or to be added
Returns:
0 on success, -1 on failure

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]


Variable Documentation

int fifo_err

Definition at line 58 of file cr_fifo.c.

Referenced by print_fifo_err().

unsigned int opt_settings[5][3] [static]

Initial value:

Defines the option set for the different fifo commands Every line is for a command, The first field defines the required options, the second field defines the optional options and the third field defines the invalid options.

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().


Generated on Mon May 21 18:00:38 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6