cr_domain.c File Reference

Contains the functions to manage routing domains.

More...

#include <stdlib.h>
#include "../../mem/shm_mem.h"
#include "../../ut.h"
#include "cr_domain.h"
#include "cr_rule.h"
#include "carrierroute.h"

Include dependency graph for cr_domain.c:

Go to the source code of this file.

Functions

int add_failure_route_to_tree (struct dtrie_node_t *failure_node, const str *scan_prefix, const str *full_prefix, const str *host, const str *reply_code, const flag_t flags, const flag_t mask, const int next_domain, const str *comment)
int add_route_to_tree (struct dtrie_node_t *node, const str *scan_prefix, flag_t flags, flag_t mask, const str *full_prefix, 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)
int compare_domain_data (const void *v1, const void *v2)
struct domain_data_tcreate_domain_data (int domain_id, str *domain_name)
void destroy_domain_data (struct domain_data_t *domain_data)
static void destroy_failure_route_rule_list (void *data)
static void destroy_route_flags_list (void *data)


Detailed Description

Contains the functions to manage routing domains.

Definition in file cr_domain.c.


Function Documentation

int add_failure_route_to_tree ( struct dtrie_node_t *  failure_node,
const str scan_prefix,
const str full_prefix,
const str host,
const str reply_code,
const flag_t  flags,
const flag_t  mask,
const int  next_domain,
const str comment 
)

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

Parameters:
failure_node the root of the failure routing tree
scan_prefix the prefix for which to add the rule (must not contain non-digits)
full_prefix the whole scan prefix
host the hostname last tried
reply_code the reply code
flags user defined flags
mask mask for user defined flags
next_domain continue routing with this domain id
comment a comment for the route rule
Returns:
0 on success, -1 on failure
See also:
add_route()

Definition at line 200 of file cr_domain.c.

References add_failure_route_rule(), cr_match_mode, _str::len, LM_ERR, NULL, and _str::s.

Referenced by add_failure_route().

int add_route_to_tree ( struct dtrie_node_t *  node,
const str scan_prefix,
flag_t  flags,
flag_t  mask,
const str full_prefix,
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 prefix tree identified by node. scan_prefix identifies the number for which the information is. 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:
node the root of the routing tree
scan_prefix the prefix for which to add the rule (must not contain non-digits)
flags user defined flags
mask mask for user defined flags
full_prefix the whole scan prefix
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 failure
See also:
add_route()

Definition at line 149 of file cr_domain.c.

References add_route_flags(), add_route_rule(), cr_match_mode, _str::len, LM_ERR, NULL, and _str::s.

Referenced by add_route().

int compare_domain_data ( const void *  v1,
const void *  v2 
)

Compares the IDs of two domain data structures. A NULL pointer is always greater than any ID.

Returns:
-1 if v1 < v2, 0 if v1 == v2, 1 if v1 > v2

Definition at line 232 of file cr_domain.c.

References domain_data_t::id, and NULL.

Referenced by get_domain_data(), get_domain_data_or_add(), and reload_route_data().

struct domain_data_t* create_domain_data ( int  domain_id,
str domain_name 
) [read]

Create a new domain in shared memory and set it up.

Parameters:
domain_id the id of the domain
domain_name the name of the domain
Returns:
a pointer to the newly allocated domain data or NULL on error, in which case it LOGs an error message.

Definition at line 81 of file cr_domain.c.

References cr_match_mode, domain_data_t::failure_tree, domain_data_t::id, domain_data_t::name, NULL, shm_free, shm_malloc(), SHM_MEM_ERROR, and domain_data_t::tree.

Referenced by get_domain_data_or_add().

void destroy_domain_data ( struct domain_data_t domain_data  ) 

Destroys the given domain and frees the used memory.

Parameters:
domain_data the structure to be destroyed.

Definition at line 108 of file cr_domain.c.

References cr_match_mode, destroy_failure_route_rule_list(), destroy_route_flags_list(), domain_data_t::failure_tree, shm_free, and domain_data_t::tree.

Referenced by destroy_carrier_data(), and get_domain_data_or_add().

static void destroy_failure_route_rule_list ( void *  data  )  [static]

Destroys failure_route_rule list in shared memory by freing all its memory.

Parameters:
data the start of the failure_route_rule list to be destroyed

Definition at line 60 of file cr_domain.c.

References destroy_failure_route_rule(), failure_route_rule::next, and NULL.

Referenced by destroy_domain_data().

static void destroy_route_flags_list ( void *  data  )  [static]

Destroys route_flags list in shared memory by freing all its memory.

Parameters:
data the start of the route_flags list to be destroyed

Definition at line 43 of file cr_domain.c.

References destroy_route_flags(), route_flags::next, and NULL.

Referenced by destroy_domain_data().


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