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"

Go to the source code of this file.
Enumerations | |
| enum | hash_algorithm { alg_crc32 = 1, alg_prime, alg_error } |
Functions | |
| static int | actually_rewrite (const struct route_rule *rs, str *dest, const struct sip_msg *msg, const str *user, gparam_t *descavp) |
| 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) |
| static int | cr_gp2id (struct sip_msg *_msg, gparam_t *gp, struct name_map_t *map, int size) |
| 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) |
| int | cr_load_user_carrier (struct sip_msg *_msg, gparam_t *_user, gparam_t *_domain, gparam_t *_dstavp) |
| int | cr_prime_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) |
| 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 *_dstavp) |
| static struct route_rule * | get_rule_by_hash (const struct route_flags *rf, const int prob) |
| static int | reply_code_matcher (const str *rcw, const str *rc) |
| 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 *dstavp) |
| 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 *dstavp) |
| 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 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) |
Variables | |
| static const str | AT_SIGN = { .s="@", .len=1 } |
| static const str | SIP_URI = { .s="sip:", .len=4 } |
| static const str | SIPS_URI = { .s="sips:", .len=5 } |
Definition in file cr_func.c.
| enum hash_algorithm |
| static int actually_rewrite | ( | const struct route_rule * | rs, | |
| str * | dest, | |||
| const struct sip_msg * | msg, | |||
| const str * | user, | |||
| gparam_t * | descavp | |||
| ) | [static] |
does the work for rewrite_on_rule, writes the new URI into dest
| rs | the route rule used for rewriting | |
| dest | the returned new destination URI | |
| msg | the sip message | |
| user | the localpart of the uri to be rewritten | |
| descavp | the name of the AVP where the description is stored |
Definition at line 278 of file cr_func.c.
References add_avp(), AVP_VAL_STR, route_rule::comment, route_rule::host, _pv_name::isname, _str::len, len, LM_ERR, route_rule::local_prefix, route_rule::local_suffix, NULL, sip_msg::parsed_uri, pkg_free, pkg_malloc, PKG_MEM_ERROR, _gparam::pve, _pv_param::pvn, _pv_spec::pvp, int_str::s, _str::s, SIPS_URI_T, _pv_elem::spec, route_rule::strip, sip_uri::type, _pv_name::u, and _gparam::v.
Referenced by rewrite_on_rule().
| 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 | |||
| ) |
rewrites the request URI of msg after determining the new destination URI
| _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 |
Definition at line 487 of file cr_func.c.
References route_data_t::carrier_map, route_data_t::carrier_num, cr_gp2id(), route_data_t::default_carrier_id, do_action(), route_data_t::domain_map, route_data_t::domain_num, action::elem, fallback_default, fixup_get_svalue(), sip_msg::flags, get_carrier_data(), get_data(), get_domain_data(), _str::len, LM_ERR, LM_INFO, LM_NOTICE, action::next, NULL, pkg_free, release_data(), rewrite_uri_recursor(), _str::s, SET_URI_T, action_elem_::string, STRING_ST, domain_data_t::tree, action_elem_::type, action::type, and action_elem_::u.
Referenced by cr_prime_route(), and cr_route().
| 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.
Get the id that belongs to a string name from gparam_t structure, use the search_id function for the lookup.
| _msg | SIP message | |
| gp | id as integer, pseudo-variable or AVP name of carrier | |
| map | lookup function | |
| size | size of the list |
Definition at line 75 of file cr_func.c.
References AVP_VAL_STR, fixup_get_svalue(), usr_avp::flags, GPARAM_TYPE_INT, GPARAM_TYPE_PVE, id, _pv_name::isname, _gparam::ival, _str::len, LM_ERR, map_name2id(), int_str::n, _gparam::pve, _pv_param::pvn, _pv_spec::pvp, PVT_AVP, _str::s, int_str::s, search_first_avp(), _pv_elem::spec, _pv_spec::type, _gparam::type, _pv_name::u, and _gparam::v.
Referenced by cr_do_route(), and cr_load_next_domain().
| 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 | |||
| ) |
Loads next domain from failure routing table and stores it in an AVP.
| _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 |
Definition at line 686 of file cr_func.c.
References route_data_t::carrier_map, route_data_t::carrier_num, cr_gp2id(), route_data_t::default_carrier_id, route_data_t::domain_map, route_data_t::domain_num, domain_data_t::failure_tree, fallback_default, fixup_get_svalue(), sip_msg::flags, get_carrier_data(), get_data(), get_domain_data(), _str::len, LM_ERR, LM_INFO, LM_NOTICE, NULL, release_data(), _str::s, and set_next_domain_recursor().
| int cr_load_user_carrier | ( | struct sip_msg * | _msg, | |
| gparam_t * | _user, | |||
| gparam_t * | _domain, | |||
| gparam_t * | _dstavp | |||
| ) |
Loads user carrier from subscriber table and stores it in an AVP.
| _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 |
Definition at line 595 of file cr_func.c.
References add_avp(), domain, fixup_get_svalue(), _pv_name::isname, LM_ERR, load_user_carrier(), int_str::n, _gparam::pve, _pv_param::pvn, _pv_spec::pvp, _pv_elem::spec, _pv_name::u, user, and _gparam::v.
| int cr_prime_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 | |||
| ) |
rewrites the request URI of msg after determining the new destination URI with the prime hash algorithm.
| _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 |
Definition at line 663 of file cr_func.c.
References alg_prime, and cr_do_route().
| 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 * | _dstavp | |||
| ) |
rewrites the request URI of msg after determining the new destination URI with the crc32 hash algorithm.
| _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 |
Definition at line 639 of file cr_func.c.
References alg_crc32, and cr_do_route().
| static struct route_rule* get_rule_by_hash | ( | const struct route_flags * | rf, | |
| const int | prob | |||
| ) | [static, read] |
searches for a rule int rt with hash_index prob - 1 If the rule with the desired hash index is deactivated, the next working rule is used.
| rf | the route_flags node to search for rule | |
| prob | the hash index |
Definition at line 243 of file cr_func.c.
References route_rule::backup, route_rule::hash_index, LM_INFO, LM_WARN, NULL, route_rule_p_list::rr, route_flags::rule_num, route_flags::rules, and route_rule::status.
Referenced by rewrite_on_rule().
Try to match the reply code rc to the reply code with wildcards.
| rcw | reply code specifier with wildcards | |
| rc | the current reply code |
Definition at line 135 of file cr_func.c.
References _str::len, and _str::s.
Referenced by set_next_domain_on_rule().
| 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 * | dstavp | |||
| ) | [static] |
writes the uri dest using the flags and rule list of rf_head
| 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 | |
| dstavp | the name of the destination AVP where the used host name is stored |
Definition at line 358 of file cr_func.c.
References actually_rewrite(), alg_crc32, alg_prime, route_rule::backup, route_flags::dice_max, route_rule::dice_to, route_flags::flags, get_rule_by_hash(), hash_func(), LM_CRIT, LM_DBG, LM_ERR, LM_INFO, route_flags::mask, route_flags::max_targets, route_rule::next, route_flags::next, NULL, prime_hash_func(), route_rule::prob, route_rule_p_list::rr, route_flags::rule_list, and route_rule::status.
Referenced by rewrite_uri_recursor().
| 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 * | dstavp | |||
| ) | [static] |
traverses the routing tree until a matching rule is found The longest match is taken, so it is possible to define route rules for a single number
| 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 | |
| dstavp | the name of the destination AVP where the used host name is stored |
Definition at line 450 of file cr_func.c.
References cr_match_mode, _str::len, LM_INFO, NULL, rewrite_on_rule(), and _str::s.
Referenced by cr_do_route().
| 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] |
writes the next_domain avp using the rule list of failure_tree
| 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 |
Definition at line 161 of file cr_func.c.
References add_avp(), failure_route_rule::flags, failure_route_rule::host, _pv_name::isname, _str::len, LM_DBG, LM_ERR, LM_INFO, failure_route_rule::mask, int_str::n, failure_route_rule::next, failure_route_rule::next_domain, NULL, _gparam::pve, _pv_param::pvn, _pv_spec::pvp, failure_route_rule::reply_code, reply_code_matcher(), _str::s, _pv_elem::spec, str_strcmp(), _pv_name::u, and _gparam::v.
Referenced by set_next_domain_recursor().
| 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] |
traverses the failure routing tree until a matching rule is found. The longest match is taken, so it is possible to define failure route rules for a single number
| 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 |
Definition at line 212 of file cr_func.c.
References cr_match_mode, _str::len, LM_INFO, NULL, _str::s, and set_next_domain_on_rule().
Referenced by cr_load_next_domain().
1.5.6