#include <stdlib.h>
#include <sys/types.h>
#include <regex.h>
#include <netdb.h>
#include <string.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include "route.h"
#include "forward.h"
#include "dprint.h"
#include "proxy.h"
#include "action.h"
#include "sr_module.h"
#include "ip_addr.h"
#include "resolve.h"
#include "socket_info.h"
#include "blacklists.h"
#include "parser/parse_uri.h"
#include "parser/parse_from.h"
#include "parser/parse_to.h"
#include "mem/mem.h"

Go to the source code of this file.
Functions | |
| int | add_actions (struct action *a, struct action **head) |
| Add actions to the list. | |
| static int | check_actions (struct action *a, int r_type) |
| Check actions on list. | |
| int | check_rls (void) |
| Check all routing tables for compatiblity between route types and called module functions. | |
| static int | check_self_op (int op, str *s, unsigned short p) |
| check_self wrapper -- it checks also for the operation | |
| static int | comp_ip (struct sip_msg *msg, int op, struct ip_addr *ip, operand_t *opd) |
| eval_elem helping function, compare a IP address | |
| static int | comp_n2n (int op, int n1, int n2) |
| Compare two numbers. | |
| static int | comp_no (int port, void *param, int op, int subtype) |
| Compare port number to parameter. | |
| static int | comp_s2r (int op, str *s1, regex_t *re) |
| Compare str to regexp. | |
| static int | comp_s2s (int op, str *s1, str *s2) |
| Compare str to str. | |
| static int | comp_scriptvar (struct sip_msg *msg, int op, operand_t *left, operand_t *right) |
| Compare two script variables. | |
| static int | comp_str (char *str, void *param, int op, int subtype) |
| eval_elem helping function, compare a string value | |
| static int | comp_strval (struct sip_msg *msg, int op, str *ival, operand_t *opd) |
| eval_elem helping function, compare a str value | |
| static int | eval_elem (struct expr *e, struct sip_msg *msg, pv_value_t *val) |
| Evaluate expression element. | |
| int | eval_expr (struct expr *e, struct sip_msg *msg, pv_value_t *val) |
| Evaluate expression. | |
| static int | fix_actions (struct action *a) |
| Adds the proxies in the proxy list & resolves the hostnames. | |
| static int | fix_expr (struct expr *exp) |
| Traverses an expression tree and compiles the REs where necessary. | |
| int | fix_rls (void) |
| Fixes all action tables. | |
| void | init_route_lists (void) |
| Initialize routing lists. | |
| void | print_rl (void) |
| Debug function, prints main routing table. | |
| void | push (struct action *a, struct action **head) |
| Adds an action list to head. | |
Variables | |
| struct action * | branch_rlist [BRANCH_RT_NO] |
| struct action * | error_rlist |
| struct action * | failure_rlist [FAILURE_RT_NO] |
| struct action * | onreply_rlist [ONREPLY_RT_NO] |
| static int | rcheck_stack [RT_NO] |
| static int | rcheck_stack_p = 0 |
| static int | rcheck_status = 0 |
| int | return_code |
| struct action * | rlist [RT_NO] |
| int | route_type = REQUEST_ROUTE |
Definition in file route.c.
| static int check_actions | ( | struct action * | a, | |
| int | r_type | |||
| ) | [static] |
Check actions on list.
Definition at line 1610 of file route.c.
References action_elem_::data, action::elem, cmd_export_::flags, IF_T, LM_CRIT, LM_ERR, MODULE_T, cmd_export_::name, action::next, action_elem_::number, rcheck_stack, rcheck_stack_p, rcheck_status, ROUTE_T, RT_NO, SWITCH_T, action::type, action_elem_::u, and WHILE_T.
Referenced by check_rls().
| int check_rls | ( | void | ) |
Check all routing tables for compatiblity between route types and called module functions.
Definition at line 1681 of file route.c.
References BRANCH_ROUTE, BRANCH_RT_NO, check_actions(), ERROR_ROUTE, FAILURE_ROUTE, FAILURE_RT_NO, LM_ERR, LOCAL_ROUTE, ONREPLY_ROUTE, ONREPLY_RT_NO, rcheck_status, and REQUEST_ROUTE.
Referenced by main().
| static int check_self_op | ( | int | op, | |
| str * | s, | |||
| unsigned short | p | |||
| ) | [inline, static] |
check_self wrapper -- it checks also for the operation
| op | compare operation | |
| s | host | |
| p | port |
Definition at line 651 of file route.c.
References check_self(), DIFF_OP, EQUAL_OP, and LM_CRIT.
Referenced by comp_ip(), and eval_elem().
| static int comp_ip | ( | struct sip_msg * | msg, | |
| int | op, | |||
| struct ip_addr * | ip, | |||
| operand_t * | opd | |||
| ) | [inline, static] |
eval_elem helping function, compare a IP address
| msg | SIP message | |
| op | compare operation | |
| ip | IP address | |
| opd | operand type and data |
Definition at line 677 of file route.c.
References ip_addr::addr, ip_addr::af, check_self_op(), comp_str(), operand::operand_val::data, DIFF_OP, DO_REV_DNS, EQUAL_OP, ip_addr2a(), _str::len, ip_addr::len, LM_CRIT, LM_DBG, MATCH_OP, matchnet(), MYSELF_ST, NET_ST, print_ip(), RE_ST, received_dns, resolvehost(), rev_resolvehost, _str::s, STRING_ST, operand::type, ip_addr::u, and operand::v.
Referenced by eval_elem().
| static int comp_n2n | ( | int | op, | |
| int | n1, | |||
| int | n2 | |||
| ) | [inline, static] |
Compare two numbers.
| op | compare operation | |
| n1 | first number | |
| n2 | second number |
Definition at line 900 of file route.c.
References DIFF_OP, EQUAL_OP, GT_OP, GTE_OP, LM_CRIT, LT_OP, LTE_OP, MATCH_OP, MATCHD_OP, NOTMATCH_OP, and NOTMATCHD_OP.
Referenced by comp_scriptvar().
| static int comp_no | ( | int | port, | |
| void * | param, | |||
| int | op, | |||
| int | subtype | |||
| ) | [inline, static] |
Compare port number to parameter.
| port | port number | |
| param | parameter | |
| op | compare operation | |
| subtype | type of the parameter, should be NUMBER_ST |
Definition at line 467 of file route.c.
References DIFF_OP, E_BUG, EQUAL_OP, GT_OP, GTE_OP, LM_CRIT, LT_OP, LTE_OP, and NUMBER_ST.
Referenced by eval_elem().
| static int comp_s2r | ( | int | op, | |
| str * | s1, | |||
| regex_t * | re | |||
| ) | [inline, static] |
Compare str to regexp.
| op | compare operation | |
| s1 | string | |
| re | reqular expression |
Definition at line 772 of file route.c.
References _str::len, LM_CRIT, MATCH_OP, NOTMATCH_OP, NULL, and _str::s.
Referenced by comp_scriptvar().
Compare str to str.
| op | compare operation | |
| s1 | first string | |
| s2 | second string |
Definition at line 805 of file route.c.
References DIFF_OP, EQUAL_OP, GT_OP, GTE_OP, _str::len, LM_CRIT, LT_OP, LTE_OP, MATCHD_OP, NOTMATCHD_OP, NULL, pkg_free, pkg_malloc, and _str::s.
Referenced by comp_scriptvar().
| static int comp_scriptvar | ( | struct sip_msg * | msg, | |
| int | op, | |||
| operand_t * | left, | |||
| operand_t * | right | |||
| ) | [inline, static] |
Compare two script variables.
| msg | SIP message | |
| op | compare operation | |
| left | left type and data | |
| right | right type and data |
Definition at line 946 of file route.c.
References comp_n2n(), comp_s2r(), comp_s2s(), DIFF_OP, EQUAL_OP, operand::operand_val::expr, _pv_value::flags, _str::len, LM_CRIT, LM_DBG, MATCH_OP, MATCHD_OP, operand::operand_val::n, NOTMATCH_OP, NOTMATCHD_OP, NULLV_ST, NUMBER_ST, pv_get_spec_value(), PV_VAL_INT, PV_VAL_NULL, PV_VAL_STR, RE_ST, _pv_value::ri, _pv_value::rs, operand::operand_val::s, _str::s, SCRIPTVAR_ST, operand::operand_val::spec, STRING_ST, operand::type, operand::v, and ZSW.
Referenced by eval_elem().
| static int comp_str | ( | char * | str, | |
| void * | param, | |||
| int | op, | |||
| int | subtype | |||
| ) | [inline, static] |
eval_elem helping function, compare a string value
| str | string | |
| param | compared parameter | |
| op | compare operation | |
| subtype | type of the value |
Definition at line 600 of file route.c.
References DIFF_OP, EQUAL_OP, LM_CRIT, MATCH_OP, NOTMATCH_OP, RE_ST, and STRING_ST.
Referenced by comp_ip().
| static int comp_strval | ( | struct sip_msg * | msg, | |
| int | op, | |||
| str * | ival, | |||
| operand_t * | opd | |||
| ) | [inline, static] |
eval_elem helping function, compare a str value
| msg | SIP message | |
| op | compare operation | |
| ival | str value | |
| opd | operand type and data |
Definition at line 502 of file route.c.
References operand::operand_val::data, DIFF_OP, EQUAL_OP, _pv_value::flags, _str::len, LM_CRIT, MATCH_OP, operand::operand_val::n, NOTMATCH_OP, NULL, NUMBER_ST, pkg_free, pkg_malloc, pv_get_spec_value(), PV_VAL_STR, RE_ST, _pv_value::ri, _pv_value::rs, operand::operand_val::s, _str::s, SCRIPTVAR_ST, sint2str(), operand::operand_val::spec, STRING_ST, operand::type, and operand::v.
Referenced by eval_elem().
| static int eval_elem | ( | struct expr * | e, | |
| struct sip_msg * | msg, | |||
| pv_value_t * | val | |||
| ) | [static] |
Evaluate expression element.
| e | expression | |
| msg | SIP message | |
| val | pseudo-variable value |
Definition at line 1079 of file route.c.
References ACTION_O, ip_addr::af, AF_O, BAND_OP, BLSHIFT_OP, BNOT_OP, BOR_OP, BRSHIFT_OP, BXOR_OP, check_self_op(), comp_ip(), comp_no(), comp_scriptvar(), comp_strval(), operand::operand_val::data, DIV_OP, receive_info::dst_ip, receive_info::dst_port, DSTIP_O, DSTPORT_O, E_BUG, ELEM_T, eval_expr(), EXPR_DROP, EXPR_O, sip_msg::first_line, _pv_value::flags, FROM_URI_O, get_from, get_to, HDR_TO_F, sip_uri::host, expr::left, sip_msg::len, _str::len, LM_CRIT, LM_ERR, METHOD_O, MINUS_OP, MODULO_OP, MSGLEN_O, MULT_OP, MYSELF_ST, operand::operand_val::n, sip_msg::new_uri, NO_OP, NULL, NUMBER_O, NUMBERV_O, expr::op, parse_from_header(), parse_headers(), parse_sip_msg_uri(), parse_uri(), sip_msg::parsed_uri, pkg_malloc, PLUS_OP, sip_uri::port_no, receive_info::proto, PROTO_O, pv_get_spec_value(), PV_TYPE_INT, PV_VAL_EMPTY, PV_VAL_INT, PV_VAL_NONE, PV_VAL_NULL, PV_VAL_PKG, PV_VAL_SHM, PV_VAL_STR, pv_value_destroy(), sip_msg::rcv, msg_start::request, RETCODE_O, return_code, _pv_value::ri, expr::right, _pv_value::rs, run_action_list(), operand::operand_val::s, _str::s, SCRIPTVAR_O, SIP_PORT, operand::operand_val::spec, receive_info::src_ip, receive_info::src_port, SRCIP_O, SRCPORT_O, STRINGV_O, sip_msg::to, TO_URI_O, operand::type, expr::type, msg_start::u, URI_O, operand::v, and VALUE_OP.
Referenced by eval_expr().
| int eval_expr | ( | struct expr * | e, | |
| struct sip_msg * | msg, | |||
| pv_value_t * | val | |||
| ) |
Evaluate expression.
| e | expression | |
| msg | SIP message | |
| val | pseudo-variable |
Definition at line 1459 of file route.c.
References AND_OP, ELEM_T, eval_elem(), eval_expr(), EVAL_OP, EXP_T, operand::operand_val::expr, expr::left, LM_CRIT, MAX_REC_LEV, NOT_OP, expr::op, OR_OP, rec_lev, expr::right, expr::type, and operand::v.
Referenced by do_action(), do_assign(), eval_elem(), and eval_expr().
| static int fix_actions | ( | struct action * | a | ) | [static] |
Adds the proxies in the proxy list & resolves the hostnames.
| a | list of actions |
Definition at line 196 of file route.c.
References ACTIONS_ST, add_proxy(), BANDEQ_T, BLACKLIST_ST, BOREQ_T, BXOREQ_T, CASE_T, COLONEQ_T, action_elem_::data, DEFAULT_T, DIVEQ_T, E_BAD_ADDRESS, E_BUG, E_CFG, action::elem, EQ_T, EXPR_ST, find_si(), fix_expr(), cmd_export_::fixup, fixup_flag(), flag_in_range(), FORCE_SEND_SOCKET_T, FORWARD_T, get_bl_head_by_name(), hostent2ip_addr, IF_T, ISBFLAGSET_T, ISFLAGSET_T, ISSFLAGSET_T, L_ALERT, L_DBG, _str::len, action::line, LM_CRIT, LM_DBG, LM_ERR, LM_WARN, MINUSEQ_T, MODFIXUP_ST, MODULE_T, MODULOEQ_T, MULTEQ_T, cmd_export_::name, action::next, NOSUBTYPE, NULL, action_elem_::number, NUMBER_ST, cmd_export_::param_no, parse_phostport(), PLUSEQ_T, port, PROTO_NONE, PROXY_ST, RESETBFLAG_T, RESETFLAG_T, RESETSFLAG_T, resolvehost(), ROUTE_T, _str::s, SEND_T, SET_DEBUG_T, SETBFLAG_T, SETFLAG_T, SETSFLAG_T, SOCKETINFO_ST, SOCKID_ST, action_elem_::string, STRING_ST, SWITCH_T, action_elem_::type, action::type, action_elem_::u, UNUSE_BLACKLIST_T, USE_BLACKLIST_T, and WHILE_T.
Referenced by add_actions(), fix_expr(), and fix_rls().
| static int fix_expr | ( | struct expr * | exp | ) | [static] |
Traverses an expression tree and compiles the REs where necessary.
| exp | expression tree |
Definition at line 115 of file route.c.
References ACTION_O, AND_OP, operand::operand_val::data, E_BAD_RE, E_BUG, E_OUT_OF_MEM, ELEM_T, EVAL_OP, EXP_T, operand::operand_val::expr, EXPR_O, EXPR_ST, fix_actions(), expr::left, LM_CRIT, MATCH_OP, NOT_OP, NOTMATCH_OP, expr::op, OR_OP, pkg_free, pkg_malloc, RE_ST, expr::right, SCRIPTVAR_ST, STRING_ST, operand::type, expr::type, and operand::v.
Referenced by fix_actions().
| int fix_rls | ( | void | ) |
Fixes all action tables.
Definition at line 1552 of file route.c.
References BRANCH_RT_NO, FAILURE_RT_NO, fix_actions(), ONREPLY_RT_NO, and RT_NO.
Referenced by main().
| void init_route_lists | ( | void | ) |
| void print_rl | ( | void | ) |
Debug function, prints main routing table.
Definition at line 1738 of file route.c.
References BRANCH_RT_NO, FAILURE_RT_NO, LM_DBG, ONREPLY_RT_NO, print_actions(), and RT_NO.
Referenced by main().
| struct action* branch_rlist[BRANCH_RT_NO] |
| struct action* error_rlist |
| struct action* failure_rlist[FAILURE_RT_NO] |
| struct action* onreply_rlist[ONREPLY_RT_NO] |
main reply route table
Definition at line 80 of file route.c.
Referenced by receive_msg(), and reply_received().
int rcheck_stack[RT_NO] [static] |
int rcheck_stack_p = 0 [static] |
int rcheck_status = 0 [static] |
| int return_code |
main "script table"
Definition at line 78 of file route.c.
Referenced by cpl_proxy_to_loc_set(), dlg_ontimeout(), do_action(), and receive_msg().
| int route_type = REQUEST_ROUTE |
default route type
Definition at line 88 of file route.c.
Referenced by dp_apply_policy(), dp_can_connect(), dp_update(), ds_update_dst(), get_current_dialog(), is_uri_host_local(), next_gw(), pv_get_spec_value(), pv_get_tm_reply_code(), pv_set_spec_value(), run_action_list(), save(), set_dlg_profile(), t_check_status(), t_local_replied(), t_next_contacts(), t_on_branch(), unset_dlg_profile(), w_t_relay(), and w_t_reply().
1.5.6