Enumerations | Functions

cr_func.c File Reference

Routing and balancing functions. More...

#include <ctype.h>
#include <assert.h>
#include <stdlib.h>
#include "cr_func.h"
#include "cr_db.h"
#include "../../sr_module.h"
#include "../../action.h"
#include "../../parser/parse_uri.h"
#include "../../parser/parse_from.h"
#include "../../ut.h"
#include "../../parser/digest/digest.h"
#include "../../parser/hf.h"
#include "../../mem/mem.h"
#include "../../qvalue.h"
#include "../../dset.h"
#include "cr_map.h"
#include "cr_rule.h"
#include "cr_domain.h"
#include "cr_carrier.h"
#include "carrierroute.h"
#include "config.h"
Include dependency graph for cr_func.c:

Go to the source code of this file.

Enumerations

Functions


Detailed Description

Definition in file cr_func.c.


Enumeration Type Documentation

Enumerator:
alg_crc32 

hashing algorithm is CRC32

alg_crc32_nofallback 

same algorithm as alg_crc32, with only a backup rule, but no fallback tree is chosen if there is something wrong.

Definition at line 52 of file cr_func.c.


Function Documentation

static int actually_rewrite ( const struct route_rule rs,
str dest,
const struct sip_msg msg,
const str user,
gparam_t *  descavp 
) [static]
Parameters:
rs the route rule used for rewriting, not NULL
dest the returned new destination URI, not NULL
msg the sip message, not NULL
user the localpart of the uri to be rewritten, not NULL
Returns:
0 on success, -1 on failure
See also:
rewrite_on_rule()

Definition at line 285 of file cr_func.c.

References route_rule::comment, route_rule::host, _str::len, route_rule::local_prefix, route_rule::local_suffix, MAX_URI_SIZE, sip_msg::parsed_uri, _str::s, route_rule::strip, and sip_uri::type.

Referenced by rewrite_on_rule().

Here is the caller graph for this function:

int cr_do_route ( struct sip_msg _msg,
gparam_t *  _carrier,
gparam_t *  _domain,
gparam_t *  _prefix_matching,
gparam_t *  _rewrite_user,
enum hash_source  _hsrc,
enum hash_algorithm  _halg,
gparam_t *  _dstavp 
)
Parameters:
_msg the current SIP message
_carrier the requested carrier
_domain the requested routing domain
_prefix_matching the user to be used for prefix matching
_rewrite_user the localpart of the URI to be rewritten
_hsrc the SIP header used for hashing
_halg the hash algorithm used for hashing
_dstavp the name of the destination AVP where the used host name is stored
Returns:
1 on success, -1 on failure

Definition at line 515 of file cr_func.c.

References route_data_t::carrier_map, route_data_t::carrier_num, cr_gp2id(), route_data_t::domain_map, route_data_t::domain_num, fixup_get_svalue, get_carrier_data(), get_data(), get_domain_data(), _str::len, release_data(), rewrite_uri_recursor(), _str::s, and domain_data_t::tree.

Referenced by cr_nofallback_route(), and cr_route().

Here is the call graph for this function:

Here is the caller graph for this function:

static int cr_gp2id ( struct sip_msg _msg,
gparam_t *  gp,
struct name_map_t map,
int  size 
) [inline, static]

Get the id that belongs to a string name from gparam_t structure, use the search_id function for the lookup.

Parameters:
_msg SIP message
gp id as integer, pseudo-variable or AVP name of carrier
map lookup function
size size of the list
Returns:
id on success, -1 otherwise

Definition at line 76 of file cr_func.c.

References fixup_get_svalue, _str::len, map_name2id(), and _str::s.

Referenced by cr_do_route(), and cr_load_next_domain().

Here is the call graph for this function:

Here is the caller graph for this function:

int cr_load_next_domain ( struct sip_msg _msg,
gparam_t *  _carrier,
gparam_t *  _domain,
gparam_t *  _prefix_matching,
gparam_t *  _host,
gparam_t *  _reply_code,
gparam_t *  _dstavp 
)
Parameters:
_msg the current SIP message
_carrier the requested carrier
_domain the requested routing domain
_prefix_matching the user to be used for prefix matching
_host the host name to be used for rule matching
_reply_code the reply code to be used for rule matching
_dstavp the name of the destination AVP
Returns:
1 on success, -1 on failure

Definition at line 731 of file cr_func.c.

References route_data_t::carrier_map, route_data_t::carrier_num, cr_gp2id(), route_data_t::domain_map, route_data_t::domain_num, domain_data_t::failure_tree, fixup_get_svalue, get_carrier_data(), get_data(), get_domain_data(), _str::len, release_data(), _str::s, and set_next_domain_recursor().

Here is the call graph for this function:

int cr_load_user_carrier ( struct sip_msg _msg,
gparam_t *  _user,
gparam_t *  _domain,
gparam_t *  _dstavp 
)
Parameters:
_msg the current SIP message
_user the user to determine the carrier data
_domain the domain to determine the domain data
_dstavp the name of the AVP where to store the carrier id
Returns:
1 on success, -1 on failure

Definition at line 623 of file cr_func.c.

References fixup_get_svalue.

int cr_nofallback_route ( struct sip_msg _msg,
gparam_t *  _carrier,
gparam_t *  _domain,
gparam_t *  _prefix_matching,
gparam_t *  _rewrite_user,
enum hash_source  _hsrc,
gparam_t *  _dstavp 
)

The difference to cr_route is that no fallback rule is chosen if there is something wrong (like now obselete cr_prime_route)

Parameters:
_msg the current SIP message
_carrier the requested carrier
_domain the requested routing domain
_prefix_matching the user to be used for prefix matching
_rewrite_user the localpart of the URI to be rewritten
_hsrc the SIP header used for hashing
_dstavp the name of the destination AVP where the used host name is stored
Returns:
1 on success, -1 on failure

Definition at line 700 of file cr_func.c.

References alg_crc32_nofallback, and cr_do_route().

Here is the call graph for this function:

int cr_route ( struct sip_msg _msg,
gparam_t *  _carrier,
gparam_t *  _domain,
gparam_t *  _prefix_matching,
gparam_t *  _rewrite_user,
enum hash_source  _hsrc,
gparam_t *  _descavp 
)

rewrites the request URI of msg after determining the new destination URI

Parameters:
_msg the current SIP message
_carrier the requested carrier
_domain the requested routing domain
_prefix_matching the user to be used for prefix matching
_rewrite_user the localpart of the URI to be rewritten
_hsrc the SIP header used for hashing
_descavp the name of the AVP where the description is stored
Returns:
1 on success, -1 on failure

Definition at line 666 of file cr_func.c.

References alg_crc32, and cr_do_route().

Here is the call graph for this function:

static struct route_rule* get_rule_by_hash ( const struct route_flags rf,
const int  prob 
) [static, read]
Parameters:
rf the route_flags node to search for rule
prob the hash index
Returns:
pointer to route rule on success, NULL on failure

Definition at line 251 of file cr_func.c.

References route_rule::backup, route_rule::hash_index, route_flags::rule_num, route_flags::rules, and route_rule::status.

Referenced by rewrite_on_rule().

Here is the caller graph for this function:

static int reply_code_matcher ( const str rcw,
const str rc 
) [inline, static]
Parameters:
rcw reply code specifier with wildcards
rc the current reply code
Returns:
0 on match, -1 otherwise

Definition at line 143 of file cr_func.c.

References _str::len, and _str::s.

Referenced by set_next_domain_on_rule().

Here is the caller graph for this function:

static int rewrite_on_rule ( struct route_flags rf_head,
flag_t  flags,
str dest,
struct sip_msg msg,
const str user,
const enum hash_source  hash_source,
const enum hash_algorithm  alg,
gparam_t *  descavp 
) [static]
Parameters:
rf_head the head of the route flags list
flags user defined flags
dest the returned new destination URI
msg the sip message
user the localpart of the uri to be rewritten
hash_source the SIP header used for hashing
alg the algorithm used for hashing
descavp the name of the AVP where the description is stored
Returns:
0 on success, -1 on failure, 1 on empty rule list

Definition at line 382 of file cr_func.c.

References actually_rewrite(), alg_crc32, alg_crc32_nofallback, route_rule::backup, route_flags::dice_max, route_rule::dice_to, route_flags::flags, get_rule_by_hash(), hash_func(), route_flags::mask, route_flags::max_targets, route_rule::next, route_flags::next, route_rule::prob, route_flags::rule_list, and route_rule::status.

Referenced by rewrite_uri_recursor().

Here is the call graph for this function:

Here is the caller graph for this function:

static int rewrite_uri_recursor ( struct dtrie_node_t node,
const str pm,
flag_t  flags,
str dest,
struct sip_msg msg,
const str user,
const enum hash_source  hash_source,
const enum hash_algorithm  alg,
gparam_t *  descavp 
) [static]
Parameters:
node the current routing tree node
pm the user to be used for prefix matching
flags user defined flags
dest the returned new destination URI
msg the sip message
user the localpart of the uri to be rewritten
hash_source the SIP header used for hashing
alg the algorithm used for hashing
descavp the name of the AVP where the description is stored
Returns:
0 on success, -1 on failure, 1 on no more matching child node and no rule list

Definition at line 478 of file cr_func.c.

References dtrie_longest_match(), _str::len, rewrite_on_rule(), and _str::s.

Referenced by cr_do_route().

Here is the call graph for this function:

Here is the caller graph for this function:

static int set_next_domain_on_rule ( struct failure_route_rule frr_head,
const str host,
const str reply_code,
const flag_t  flags,
const gparam_t *  dstavp 
) [static]
Parameters:
frr_head the head of the failure route rule list
host last tried host
reply_code the last reply code
flags flags for the failure route rule
dstavp the name of the AVP where to store the next domain
Returns:
0 on success, -1 on failure

Definition at line 169 of file cr_func.c.

References failure_route_rule::flags, failure_route_rule::host, _str::len, failure_route_rule::mask, failure_route_rule::next, failure_route_rule::next_domain, failure_route_rule::reply_code, reply_code_matcher(), _str::s, and str_strcmp().

Referenced by set_next_domain_recursor().

Here is the call graph for this function:

Here is the caller graph for this function:

static int set_next_domain_recursor ( struct dtrie_node_t failure_node,
const str uri,
const str host,
const str reply_code,
const flag_t  flags,
const gparam_t *  dstavp 
) [static]

The longest match is taken, so it is possible to define failure route rules for a single number

Parameters:
failure_node the current routing tree node
uri the uri to be rewritten at the current position
host last tried host
reply_code the last reply code
flags flags for the failure route rule
dstavp the name of the AVP where to store the next domain
Returns:
0 on success, -1 on failure, 1 on no more matching child node and no rule list

Definition at line 220 of file cr_func.c.

References dtrie_longest_match(), _str::len, _str::s, and set_next_domain_on_rule().

Referenced by cr_load_next_domain().

Here is the call graph for this function:

Here is the caller graph for this function: