#include <string.h>
#include "../../ut.h"
#include "../../str.h"
#include "../../dprint.h"
#include "../../forward.h"
#include "../../data_lump.h"
#include "../../socket_info.h"
#include "../../parser/parse_rr.h"
#include "../../parser/parse_uri.h"
#include "../../parser/parse_from.h"
#include "../../mem/mem.h"
#include "../../dset.h"
#include "loose.h"
#include "rr_cb.h"
#include "rr_mod.h"

Go to the source code of this file.
Defines | |
| #define | NOT_RR_DRIVEN -1 |
| #define | ROUTE_PREFIX "Route: <" |
| #define | ROUTE_PREFIX_LEN (sizeof(ROUTE_PREFIX)-1) |
| #define | ROUTE_SUFFIX ">\r\n" |
| #define | ROUTE_SUFFIX_LEN (sizeof(ROUTE_SUFFIX)-1) |
| #define | RR_DRIVEN 1 |
| #define | RR_ERROR -1 |
Functions | |
| static int | after_loose (struct sip_msg *_m, int preloaded) |
| Previous hop was a loose router, handle this case. | |
| static int | after_strict (struct sip_msg *_m) |
| Previous hop was a strict router, handle this case. | |
| int | check_route_param (struct sip_msg *msg, regex_t *re) |
| Check if the route hdr has the required parameter. | |
| static int | find_first_route (struct sip_msg *_m) |
| Parse the message and find first occurrence of Route header field. | |
| static int | find_next_route (struct sip_msg *_m, struct hdr_field **_hdr) |
| Find and parse next Route header field. | |
| static int | find_rem_target (struct sip_msg *_m, struct hdr_field **_h, rr_t **_l, rr_t **_p) |
| Find last route in the last Route header field. | |
| static int | get_maddr_uri (str *uri, struct sip_uri *puri) |
| Parse URI and check if it has a maddr parameter. | |
| int | get_route_param (struct sip_msg *msg, str *name, str *val) |
| Gets the value of a route parameter. | |
| static int | handle_sr (struct sip_msg *_m, struct hdr_field *_hdr, rr_t *_r) |
| Necessary logic to forward request to strict routers. | |
| static int | is_2rr (str *_params) |
| Find out if a URI contains r2 parameter which indicates that we put 2 record routes. | |
| int | is_direction (struct sip_msg *msg, int dir) |
| Check the direction of the message. | |
| static int | is_myself (str *_host, unsigned short _port) |
| Check if URI is myself. | |
| static int | is_preloaded (struct sip_msg *msg) |
| Test whether we are processing pre-loaded route set by looking at the To tag. | |
| static int | is_strict (str *_params) |
| Check if the given uri contains lr parameter which marks loose routers. | |
| int | loose_route (struct sip_msg *_m, char *_s1, char *_s2) |
| Do loose routing as per RFC3261. | |
| static int | save_ruri (struct sip_msg *_m) |
| Set Request-URI as last Route header of a SIP. | |
Variables | |
| static unsigned int | routed_msg_id |
| static str | routed_params = {0,0} |
Definition in file loose.c.
| #define NOT_RR_DRIVEN -1 |
The next hop is not determined from the route set
Definition at line 50 of file loose.c.
Referenced by after_loose(), and after_strict().
| #define ROUTE_PREFIX "Route: <" |
SIP header prefix
Definition at line 52 of file loose.c.
Referenced by print_routeset(), print_rs(), and save_ruri().
| #define ROUTE_PREFIX_LEN (sizeof(ROUTE_PREFIX)-1) |
Definition at line 53 of file loose.c.
Referenced by calc_routeset_len(), calculate_routeset_length(), print_routeset(), print_rs(), and save_ruri().
| #define ROUTE_SUFFIX ">\r\n" |
| #define ROUTE_SUFFIX_LEN (sizeof(ROUTE_SUFFIX)-1) |
| #define RR_DRIVEN 1 |
The next hop is determined from the route set
Definition at line 49 of file loose.c.
Referenced by after_loose(), and after_strict().
| #define RR_ERROR -1 |
An error occured while processing route set
Definition at line 48 of file loose.c.
Referenced by after_loose(), after_strict(), get_maddr_uri(), and handle_sr().
| static int after_loose | ( | struct sip_msg * | _m, | |
| int | preloaded | |||
| ) | [inline, static] |
Previous hop was a loose router, handle this case.
| _m | SIP message | |
| preloaded | do we have a preloaded route set |
Definition at line 752 of file loose.c.
References hdr_field::body, sip_msg::buf, del_lump(), enable_double_rr, find_next_route(), sip_msg::force_send_socket, get_maddr_uri(), grep_sock_info(), handle_sr(), sip_uri::host, sip_msg::id, is_2rr(), is_myself(), is_strict(), hdr_field::len, _str::len, LM_DBG, LM_ERR, LM_WARN, hdr_field::name, NOT_RR_DRIVEN, sip_uri::params, parse_uri(), hdr_field::parsed, sip_uri::port_no, sip_uri::proto, sip_msg::route, routed_msg_id, RR_DRIVEN, RR_ERROR, run_rr_callbacks(), _str::s, set_dst_uri(), sip_uri::user, and ZSW.
Referenced by loose_route().
| static int after_strict | ( | struct sip_msg * | _m | ) | [inline, static] |
Previous hop was a strict router, handle this case.
| _m | SIP message |
Definition at line 572 of file loose.c.
References hdr_field::body, sip_msg::buf, del_lump(), enable_double_rr, find_next_route(), find_rem_target(), sip_msg::force_send_socket, get_maddr_uri(), grep_sock_info(), sip_uri::host, sip_msg::id, is_2rr(), is_myself(), is_strict(), hdr_field::len, _str::len, LM_DBG, LM_ERR, LM_WARN, hdr_field::name, NOT_RR_DRIVEN, sip_uri::params, parse_uri(), hdr_field::parsed, sip_msg::parsed_uri, sip_uri::port_no, sip_uri::proto, rewrite_uri(), sip_msg::route, routed_msg_id, RR_DRIVEN, RR_ERROR, run_rr_callbacks(), _str::s, set_dst_uri(), sip_uri::user, and ZSW.
Referenced by loose_route().
| int check_route_param | ( | struct sip_msg * | msg, | |
| regex_t * | re | |||
| ) |
Check if the route hdr has the required parameter.
The function checks for the request "msg" if the URI parameters of the local Route header (corresponding to the local server) matches the given regular expression "re". It must be call after the loose_route was done.
| msg | SIP message request that will has the Route header parameters checked | |
| re | compiled regular expression to be checked against the Route header parameters |
Definition at line 950 of file loose.c.
References sip_msg::id, _str::len, LM_DBG, params, routed_msg_id, and _str::s.
Referenced by load_rr(), and w_check_route_param().
| static int find_first_route | ( | struct sip_msg * | _m | ) | [inline, static] |
Parse the message and find first occurrence of Route header field.
| _m | SIP message |
Definition at line 98 of file loose.c.
References HDR_ROUTE_F, LM_DBG, LM_ERR, parse_headers(), parse_rr(), and sip_msg::route.
Referenced by loose_route().
Find and parse next Route header field.
| _m | SIP message | |
| _hdr | SIP header |
Definition at line 238 of file loose.c.
References HDR_ROUTE_F, HDR_ROUTE_T, sip_msg::last_header, LM_DBG, LM_ERR, hdr_field::next, parse_headers(), parse_rr(), and hdr_field::type.
Referenced by after_loose(), and after_strict().
| static int find_rem_target | ( | struct sip_msg * | _m, | |
| struct hdr_field ** | _h, | |||
| rr_t ** | _l, | |||
| rr_t ** | _p | |||
| ) | [inline, static] |
Find last route in the last Route header field.
Find last route in the last Route header field, if there was a previous route in the last Route header field, it will be saved in _p parameter
| _m | SIP message | |
| _h | SIP header field | |
| _l | Route & Record-Route header field body | |
| _p | Route & Record-Route header field body |
Definition at line 529 of file loose.c.
References HDR_EOH_F, HDR_ROUTE_T, LM_ERR, rr::next, hdr_field::next, parse_headers(), parse_rr(), hdr_field::parsed, sip_msg::route, and hdr_field::type.
Referenced by after_strict().
Parse URI and check if it has a maddr parameter.
| uri | URI to be checked if it has maddr, and also the output URI | |
| puri | parsed URI |
Definition at line 424 of file loose.c.
References _str::len, LM_DBG, LM_ERR, sip_uri::maddr, sip_uri::maddr_val, NULL, parse_uri(), sip_uri::port, RR_ERROR, and _str::s.
Referenced by after_loose(), after_strict(), and handle_sr().
Gets the value of a route parameter.
The function search in to the "msg"'s Route header parameters the parameter called "name" and returns its value into "val". It must be call only after the loose_route is done.
| msg | - request that will have the Route header parameter searched | |
| name | - contains the Route header parameter to be serached | |
| val | returns the value of the searched Route header parameter if found. It might be an empty string if the parameter had no value. |
Definition at line 994 of file loose.c.
References sip_msg::id, len, _str::len, routed_msg_id, and _str::s.
Referenced by is_direction(), and load_rr().
Necessary logic to forward request to strict routers.
| _m | SIP message | |
| _hdr | SIP header field | |
| _r | Route & Record-Route header field body |
Definition at line 478 of file loose.c.
References hdr_field::body, sip_msg::buf, del_lump(), get_maddr_uri(), hdr_field::len, LM_ERR, name_addr::name, hdr_field::name, rr::nameaddr, rr::next, rewrite_uri(), RR_ERROR, _str::s, save_ruri(), and name_addr::uri.
Referenced by after_loose().
| static int is_2rr | ( | str * | _params | ) | [inline, static] |
Find out if a URI contains r2 parameter which indicates that we put 2 record routes.
| _params | URI |
Definition at line 123 of file loose.c.
References _str::len, _str::s, and s.
Referenced by after_loose(), and after_strict().
| int is_direction | ( | struct sip_msg * | msg, | |
| int | dir | |||
| ) |
Check the direction of the message.
The function checks the flow direction of the request "msg". As for checking it's used the "ftag" Route header parameter, the append_fromtag module parameter must be enables. Also this must be call only after the loose_route is done.
| msg | SIP message request that will have the direction checked | |
| dir | direction to be checked against. It may be RR_FLOW_UPSTREAM or RR_FLOW_DOWNSTREAM |
Definition at line 1086 of file loose.c.
References sip_msg::from, get_route_param(), sip_msg::id, _str::len, LM_DBG, parse_from_header(), hdr_field::parsed, RR_FLOW_DOWNSTREAM, RR_FLOW_UPSTREAM, and _str::s.
Referenced by load_rr(), and w_is_direction().
| static int is_myself | ( | str * | _host, | |
| unsigned short | _port | |||
| ) | [inline, static] |
Check if URI is myself.
| _host | host | |
| _port | port |
Definition at line 210 of file loose.c.
References check_self(), _str::len, LM_DBG, _str::s, and SIP_PORT.
Referenced by after_loose(), after_strict(), and loose_route().
| static int is_preloaded | ( | struct sip_msg * | msg | ) | [static] |
Test whether we are processing pre-loaded route set by looking at the To tag.
| msg | SIP message |
Definition at line 68 of file loose.c.
References get_to, HDR_TO_F, _str::len, LM_DBG, LM_ERR, parse_headers(), _str::s, and sip_msg::to.
Referenced by loose_route().
| static int is_strict | ( | str * | _params | ) | [inline, static] |
Check if the given uri contains lr parameter which marks loose routers.
| _params | URI string |
Definition at line 281 of file loose.c.
References _str::len, _str::s, and s.
Referenced by after_loose(), and after_strict().
| int loose_route | ( | struct sip_msg * | _m, | |
| char * | _s1, | |||
| char * | _s2 | |||
| ) |
Do loose routing as per RFC3261.
| _m | SIP message | |
| _s1 | unused | |
| _s2 | unused |
Definition at line 904 of file loose.c.
References after_loose(), after_strict(), find_first_route(), sip_uri::host, is_myself(), is_preloaded(), LM_DBG, LM_ERR, parse_sip_msg_uri(), sip_msg::parsed_uri, sip_uri::port_no, and sip_uri::user.
| static int save_ruri | ( | struct sip_msg * | _m | ) | [inline, static] |
Set Request-URI as last Route header of a SIP.
Set Request-URI as last Route header of a SIP message, this is necessary when forwarding to a strict router. Allocates memory for message lump in private memory.
| _m | SIP message |
Definition at line 371 of file loose.c.
References anchor_lump(), sip_msg::buf, sip_msg::first_line, HDR_EOH_F, insert_new_lump_before(), len, LM_DBG, LM_ERR, parse_headers(), pkg_free, pkg_malloc, msg_start::request, ROUTE_PREFIX, ROUTE_PREFIX_LEN, ROUTE_SUFFIX, ROUTE_SUFFIX_LEN, s, msg_start::u, sip_msg::unparsed, and ZSW.
Referenced by handle_sr().
unsigned int routed_msg_id [static] |
variables used to hook the param part of the local route
Definition at line 59 of file loose.c.
Referenced by after_loose(), after_strict(), check_route_param(), and get_route_param().
str routed_params = {0,0} [static] |
1.5.6