cr_data.h File Reference

Contains the functions to manage routing data.

More...

#include <sys/types.h>
#include "../../locking.h"
#include "../../flags.h"
#include "cr_map.h"

Include dependency graph for cr_data.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  route_data_t

Functions

int add_carrier_data (struct route_data_t *rd, struct carrier_data_t *carrier_data)
int add_failure_route (struct route_data_t *rd, int carrier_id, int domain_id, const str *scan_prefix, const str *host, const str *reply_code, flag_t flags, flag_t mask, int next_domain_id, const str *comment)
int add_route (struct route_data_t *rd, int carrier_id, int domain_id, const str *scan_prefix, flag_t flags, flag_t mask, int max_targets, double prob, const str *rewrite_hostpart, int strip, const str *rewrite_local_prefix, const str *rewrite_local_suffix, int status, int hash_index, int backup, int *backed_up, const str *comment)
void clear_route_data (struct route_data_t *data)
void destroy_route_data (void)
struct carrier_data_tget_carrier_data (struct route_data_t *rd, int carrier_id)
struct route_data_tget_data (void)
int init_route_data (void)
void release_data (struct route_data_t *data)
int reload_route_data (void)
int rule_fixup (struct route_data_t *rd)


Detailed Description

Contains the functions to manage routing data.

Definition in file cr_data.h.


Function Documentation

int add_carrier_data ( struct route_data_t rd,
struct carrier_data_t carrier_data 
)

adds a carrier_data struct for given carrier

Parameters:
rd route data to be searched
carrier_data the carrier data struct to be inserted
Returns:
0 on success, -1 on failure
adds a carrier_data struct for given carrier.

Parameters:
rd route data to be searched
carrier_data the carrier data struct to be inserted
Returns:
0 on success, -1 on failure

Definition at line 143 of file cr_data.c.

References route_data_t::carrier_num, route_data_t::carriers, route_data_t::first_empty_carrier, and LM_ERR.

Referenced by load_config(), and load_route_data_db().

int add_failure_route ( struct route_data_t rd,
int  carrier_id,
int  domain_id,
const str scan_prefix,
const str host,
const str reply_code,
flag_t  flags,
flag_t  mask,
int  next_domain_id,
const str comment 
)

Adds the given failure route information to the failure routing domain identified by domain. scan_prefix, host, reply_code and flags identifies the number for which the information is and the next_domain parameter defines where to continue routing in case of a match.

Parameters:
rd the route data to which the route shall be added
carrier_id the carrier id of the route to be added
domain_id the routing domain id of the new route
scan_prefix the number prefix
host the hostname last tried
reply_code the reply code
flags user defined flags
mask for user defined flags
next_domain_id continue routing with this domain id
comment a comment for the failure route rule
Returns:
0 on success, -1 on error in which case it LOGs a message.

Definition at line 496 of file cr_data.c.

References add_failure_route_to_tree(), domain_data_t::failure_tree, get_carrier_data(), get_domain_data_or_add(), _str::len, LM_ERR, LM_INFO, NULL, and _str::s.

Referenced by load_route_data_db().

int add_route ( struct route_data_t rd,
int  carrier_id,
int  domain_id,
const str scan_prefix,
flag_t  flags,
flag_t  mask,
int  max_targets,
double  prob,
const str rewrite_hostpart,
int  strip,
const str rewrite_local_prefix,
const str rewrite_local_suffix,
int  status,
int  hash_index,
int  backup,
int *  backed_up,
const str comment 
)

Adds the given route information to the routing domain identified by domain. scan_prefix identifies the number for which the information is and the rewrite_* parameters define what to do in case of a match. prob gives the probability with which this rule applies if there are more than one for a given prefix.

Parameters:
rd the route data to which the route shall be added
carrier_id the carrier id of the route to be added
domain_id the routing domain id of the new route
scan_prefix the number prefix
flags user defined flags
mask mask for user defined flags
max_targets the number of targets
prob the weight of the rule
strip the number of digits to be stripped off userpart before prepending prefix
rewrite_hostpart the rewrite_host of the rule
rewrite_local_prefix the rewrite prefix
rewrite_local_suffix the rewrite suffix
status the status of the rule
hash_index the hash index of the rule
backup indicates if the route is backed up by another. only useful if status==0, if set, it is the hash value of another rule
backed_up an -1-termintated array of hash indices of the route for which this route is backup
comment a comment for the route rule
Returns:
0 on success, -1 on error in which case it LOGs a message.
Adds the given route information to the routing domain identified by domain. scan_prefix identifies the number for which the information is and the rewrite_* parameters define what to do in case of a match. prob gives the probability with which this rule applies if there are more than one for a given prefix.

Parameters:
rd the route data to which the route shall be added
carrier_id the carrier id of the route to be added
domain_id the routing domain id of the new route
scan_prefix the number prefix
flags user defined flags
mask mask for user defined flags
max_targets the number of targets
prob the weight of the rule
rewrite_hostpart the rewrite_host of the rule
strip the number of digits to be stripped off userpart before prepending prefix
rewrite_local_prefix the rewrite prefix
rewrite_local_suffix the rewrite suffix
status the status of the rule
hash_index the hash index of the rule
backup indicates if the route is backed up by another. only useful if status==0, if set, it is the hash value of another rule
backed_up an -1-termintated array of hash indices of the route for which this route is backup
comment a comment for the route rule
Returns:
0 on success, -1 on error in which case it LOGs a message.

Definition at line 451 of file cr_data.c.

References add_route_to_tree(), get_carrier_data(), get_domain_data_or_add(), _str::len, LM_ERR, LM_INFO, NULL, _str::s, and domain_data_t::tree.

Referenced by load_config(), load_route_data_db(), and update_route_data().

void clear_route_data ( struct route_data_t data  ) 

Clears the complete routing data.

Parameters:
data route data to be cleared

Definition at line 104 of file cr_data.c.

References route_data_t::carrier_map, route_data_t::carrier_num, route_data_t::carriers, destroy_carrier_data(), route_data_t::domain_map, route_data_t::domain_num, name_map_t::name, NULL, _str::s, and shm_free.

Referenced by destroy_route_data(), reload_route_data(), and update_route_data().

void destroy_route_data ( void   ) 

Frees the routing data

Definition at line 88 of file cr_data.c.

References clear_route_data(), get_data(), NULL, and shm_free.

Referenced by mod_destroy().

struct carrier_data_t* get_carrier_data ( struct route_data_t rd,
int  carrier_id 
) [read]

Returns the carrier data for the given id by doing a binary search.

Note:
The carrier array must be sorted!
Parameters:
rd route data to be searched
carrier_id the id of the desired carrier
Returns:
a pointer to the desired carrier data, NULL if not found.

Definition at line 289 of file cr_data.c.

References route_data_t::carrier_num, route_data_t::carriers, compare_carrier_data(), carrier_data_t::id, LM_ERR, and NULL.

Referenced by add_failure_route(), add_route(), cr_do_route(), and cr_load_next_domain().

struct route_data_t* get_data ( void   )  [read]

Increases lock counter and returns a pointer to the current routing data

Returns:
pointer to the global routing data on success, NULL on failure

Definition at line 248 of file cr_data.c.

References route_data_t::lock, NULL, and route_data_t::proc_cnt.

Referenced by carrier_name_2_id(), cr_do_route(), cr_load_next_domain(), destroy_route_data(), domain_name_2_id(), and dump_fifo().

int init_route_data ( void   ) 

initialises the routing data, initialises the global data pointer

Returns:
0 on success, -1 on failure

Definition at line 71 of file cr_data.c.

References NULL, shm_malloc(), and SHM_MEM_ERROR.

Referenced by mod_init().

void release_data ( struct route_data_t data  ) 

decrements the lock counter of the routing data

Parameters:
data data to be released

Definition at line 273 of file cr_data.c.

References route_data_t::lock, and route_data_t::proc_cnt.

Referenced by carrier_name_2_id(), cr_do_route(), cr_load_next_domain(), domain_name_2_id(), and dump_fifo().

int reload_route_data ( void   ) 

Loads the routing data into the routing trees and sets the global_data pointer to the new data. The old_data is removed when it is not locked anymore.

Returns:
0 on success, -1 on failure

Definition at line 167 of file cr_data.c.

References carrier_data_fixup(), route_data_t::carrier_num, CARRIERROUTE_MODE_DB, CARRIERROUTE_MODE_FILE, route_data_t::carriers, clear_route_data(), compare_carrier_data(), compare_domain_data(), carrier_data_t::domain_num, carrier_data_t::domains, LM_ERR, load_config(), load_route_data_db(), mode, NULL, route_data_t::proc_cnt, rule_fixup(), shm_malloc(), SHM_MEM_ERROR, and sleep_us().

Referenced by mod_init(), reload_fifo(), and update_route_data().

int rule_fixup ( struct route_data_t rd  ) 

Fixes the route rules by creating an array for accessing route rules by hash index directly

Parameters:
rd route data to be fixed
Returns:
0 on success, -1 on failure

Definition at line 650 of file cr_data.c.

References route_data_t::carrier_num, route_data_t::carriers, carrier_data_t::domain_num, carrier_data_t::domains, _str::len, LM_INFO, LM_NOTICE, domain_data_t::name, rule_fixup_recursor(), _str::s, and domain_data_t::tree.

Referenced by reload_route_data(), and update_route_data().


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