#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>
#include <string.h>
#include <stdio.h>
#include <stdlib.h>
#include "msg_translator.h"
#include "globals.h"
#include "error.h"
#include "mem/mem.h"
#include "dprint.h"
#include "config.h"
#include "md5utils.h"
#include "data_lump.h"
#include "data_lump_rpl.h"
#include "ip_addr.h"
#include "resolve.h"
#include "ut.h"
#include "pt.h"

Go to the source code of this file.
Defines | |
| #define | get_ip_port_proto |
| #define | ROUTE_LEN (sizeof(ROUTE_STR)-1) |
| #define | ROUTE_STR "Route: " |
| Save given Path body as Route header in message. | |
| #define | str_int_print(string, intval) |
| #define | str_ipaddr_print(string, ipaddr_val) |
| #define | str_lenpair_print(string, string_len, string2, string2_len) |
| #define | str_pair_print(string, string2, string2_len) str_lenpair_print((string), strlen((string)), (string2), (string2_len)) |
| #define | str_print(string, string_len) |
| #define | SUBST_LUMP(subst_l) |
| #define | SUBST_LUMP_LEN(subst_l) |
Functions | |
| static int | adjust_clen (struct sip_msg *msg, int body_delta, int proto) |
| Adjust/insert Content-Length if necessary. | |
| int | branch_builder (unsigned int hash_index, unsigned int label, char *char_v, int branch, char *branch_str, int *len) |
| return number of chars printed or 0 if space exceeded; assumes buffer size of at least MAX_BRANCH_PARAM_LEN | |
| char * | build_req_buf_from_sip_req (struct sip_msg *msg, unsigned int *returned_len, struct socket_info *send_sock, int proto, unsigned int flags) |
| char * | build_res_buf_from_sip_req (unsigned int code, str *text, str *new_tag, struct sip_msg *msg, unsigned int *returned_len, struct bookmark *bmark) |
| char * | build_res_buf_from_sip_res (struct sip_msg *msg, unsigned int *returned_len) |
| static int | check_via_address (struct ip_addr *ip, str *name, unsigned short port, unsigned short proto, int resolver) |
| checks if ip is in host(name) and ?host(ip)=name? ip must be in network byte order! resolver = DO_DNS | DO_REV_DNS; if 0 no dns check is made | |
| char * | clen_builder (struct sip_msg *msg, int *clen_len, int diff) |
| char * | id_builder (struct sip_msg *msg, unsigned int *id_len) |
| static int | insert_path_as_route (struct sip_msg *msg, str *path) |
| static int | lump_check_opt (struct lump *l, struct sip_msg *msg, struct socket_info *snd_s) |
| * checks if a lump opt condition returns 1 if cond is true, 0 if false | |
| static int | lumps_len (struct sip_msg *msg, struct lump *lumps, struct socket_info *send_sock) |
| computes the "unpacked" len of a lump list, code moved from build_req_from_req | |
| static void | process_lumps (struct sip_msg *msg, struct lump *lumps, char *new_buf, unsigned int *new_buf_offs, unsigned int *orig_offs, struct socket_info *send_sock) |
| another helper functions, adds/Removes the lump, code moved form build_req_from_req | |
| char * | received_builder (struct sip_msg *msg, unsigned int *received_len) |
| int | received_test (struct sip_msg *msg) |
| check if IP address in Via != source IP address of signaling | |
| char * | rport_builder (struct sip_msg *msg, unsigned int *rport_len) |
| char * | via_builder (unsigned int *len, struct socket_info *send_sock, str *branch, str *extra_params, int proto, struct hostport *hp) |
| static char * | warning_builder (struct sip_msg *msg, unsigned int *returned_len) |
Variables | |
| char | version [] |
| int | version_len |
Definition in file msg_translator.c.
| #define get_ip_port_proto |
Referenced by lump_check_opt().
| #define ROUTE_LEN (sizeof(ROUTE_STR)-1) |
| #define ROUTE_STR "Route: " |
Save given Path body as Route header in message.
If another Route HF is found, it's placed right before that. Otherwise, it's placed after the last Via HF. If also no Via HF is found, it's placed as first HF.
Definition at line 1221 of file msg_translator.c.
Referenced by insert_path_as_route().
| #define str_int_print | ( | string, | |||
| intval | ) |
Value:
do{\ t=int2str((intval), &print_len); \ str_pair_print(string, t, print_len);\ } while(0)
Referenced by warning_builder().
| #define str_ipaddr_print | ( | string, | |||
| ipaddr_val | ) |
Value:
do{\ t=ip_addr2a((ipaddr_val)); \ print_len=strlen(t); \ str_pair_print(string, t, print_len);\ } while(0)
Referenced by warning_builder().
| #define str_lenpair_print | ( | string, | |||
| string_len, | |||||
| string2, | |||||
| string2_len | ) |
Value:
Referenced by warning_builder().
| #define str_pair_print | ( | string, | |||
| string2, | |||||
| string2_len | ) | str_lenpair_print((string), strlen((string)), (string2), (string2_len)) |
Referenced by warning_builder().
| #define str_print | ( | string, | |||
| string_len | ) |
Referenced by warning_builder().
| #define SUBST_LUMP | ( | subst_l | ) |
Referenced by process_lumps().
| #define SUBST_LUMP_LEN | ( | subst_l | ) |
Referenced by lumps_len().
| static int adjust_clen | ( | struct sip_msg * | msg, | |
| int | body_delta, | |||
| int | proto | |||
| ) | [inline, static] |
Adjust/insert Content-Length if necessary.
Definition at line 1121 of file msg_translator.c.
References anchor_lump(), sip_msg::buf, clen_builder(), sip_msg::content_length, del_lump(), HDR_CONTENTLENGTH_F, HDR_CONTENTLENGTH_T, insert_new_lump_after(), hdr_field::len, LM_DBG, LM_ERR, hdr_field::name, parse_headers(), pkg_free, PROTO_TCP, PROTO_TLS, PROTO_UDP, _str::s, and sip_msg::unparsed.
Referenced by build_req_buf_from_sip_req(), and build_res_buf_from_sip_res().
| int branch_builder | ( | unsigned int | hash_index, | |
| unsigned int | label, | |||
| char * | char_v, | |||
| int | branch, | |||
| char * | branch_str, | |||
| int * | len | |||
| ) |
return number of chars printed or 0 if space exceeded; assumes buffer size of at least MAX_BRANCH_PARAM_LEN
Definition at line 1855 of file msg_translator.c.
References BRANCH_SEPARATOR, int2reverse_hex(), MAX_BRANCH_PARAM_LEN, MCOOKIE, MCOOKIE_LEN, and MD5_LEN.
Referenced by t_calc_branch().
| char* build_req_buf_from_sip_req | ( | struct sip_msg * | msg, | |
| unsigned int * | returned_len, | |||
| struct socket_info * | send_sock, | |||
| int | proto, | |||
| unsigned int | flags | |||
| ) |
Definition at line 1275 of file msg_translator.c.
References sip_msg::add_rm, sip_msg::add_to_branch_len, sip_msg::add_to_branch_s, adjust_clen(), anchor_lump(), sip_msg::body_lumps, sip_msg::buf, buf, del_lump(), E_OUT_OF_MEM, sip_msg::first_line, FL_FORCE_LOCAL_RPORT, FL_FORCE_RPORT, via_body::hdr, HDR_VIA_T, via_body::host, id_builder(), insert_new_lump_after(), insert_new_lump_before(), insert_path_as_route(), sip_msg::len, _str::len, len, LM_DBG, LM_ERR, lumps_len(), sip_msg::msg_flags, MSG_TRANS_NOVIA_FLAG, MSG_TRANS_SHM_FLAG, sip_msg::new_uri, via_body::params, sip_msg::path_vec, pkg_free, pkg_malloc, via_body::port, via_body::port_str, process_lumps(), receive_info::proto, PROTO_TCP, PROTO_TLS, sip_msg::rcv, via_body::received, received_builder(), received_test(), msg_start::request, via_body::rport, RPORT, rport_builder(), RPORT_LEN, _str::s, ser_error, set_hostport, shm_malloc(), via_param::size, via_param::start, msg_start::u, sip_msg::via1, via_builder(), and via_len.
Referenced by forward_request(), print_uac_request(), and t_uac().
| char* build_res_buf_from_sip_req | ( | unsigned int | code, | |
| str * | text, | |||
| str * | new_tag, | |||
| struct sip_msg * | msg, | |||
| unsigned int * | returned_len, | |||
| struct bookmark * | bmark | |||
| ) |
Definition at line 1579 of file msg_translator.c.
References append_str, hdr_field::body, buf, CONTENT_LENGTH, CONTENT_LENGTH_LEN, CRLF, CRLF_LEN, FL_FORCE_RPORT, lump_rpl::flags, get_to, sip_msg::h_via1, HDR_CALLID_T, HDR_CSEQ_T, HDR_EOH_F, HDR_FROM_T, HDR_RECORDROUTE_T, HDR_TO_T, HDR_VIA_T, sip_msg::headers, int2str(), hdr_field::len, _str::len, len, LM_CRIT, LM_ERR, LM_WARN, LUMP_RPL_BODY, LUMP_RPL_HDR, sip_msg::msg_flags, hdr_field::name, lump_rpl::next, hdr_field::next, NULL, parse_headers(), hdr_field::parsed, pkg_free, pkg_malloc, received_builder(), received_test(), sip_msg::reply_lump, via_body::rport, rport_builder(), _str::s, server_header, server_signature, SIP_VERSION, SIP_VERSION_LEN, sip_warning, via_param::size, via_param::start, to_body::tag_value, lump_rpl::text, bookmark::to_tag_val, TOTAG_TOKEN, TOTAG_TOKEN_LEN, hdr_field::type, sip_msg::via1, and warning_builder().
Referenced by _reply(), relay_reply(), sl_send_reply_helper(), and t_reply_with_body().
| char* build_res_buf_from_sip_res | ( | struct sip_msg * | msg, | |
| unsigned int * | returned_len | |||
| ) |
Definition at line 1510 of file msg_translator.c.
References sip_msg::add_rm, adjust_clen(), hdr_field::body, sip_msg::body_lumps, via_body::bsize, sip_msg::buf, buf, del_lump(), sip_msg::first_line, sip_msg::h_via1, HDR_VIA_T, hdr_field::len, sip_msg::len, len, LM_DBG, LM_ERR, lumps_len(), hdr_field::name, via_body::next, pkg_malloc, process_lumps(), via_body::proto, PROTO_UDP, msg_start::reply, _str::s, msg_start::u, sip_msg::via1, sip_msg::via2, and via_len.
Referenced by forward_reply(), and relay_reply().
| static int check_via_address | ( | struct ip_addr * | ip, | |
| str * | name, | |||
| unsigned short | port, | |||
| unsigned short | proto, | |||
| int | resolver | |||
| ) | [static] |
checks if ip is in host(name) and ?host(ip)=name? ip must be in network byte order! resolver = DO_DNS | DO_REV_DNS; if 0 no dns check is made
Definition at line 147 of file msg_translator.c.
References ip_addr::addr, ip_addr::af, DO_DNS, DO_REV_DNS, ip_addr2a(), ip_addr::len, _str::len, len, LM_CRIT, LM_DBG, rev_resolvehost, _str::s, s, SIP_PORT, sip_resolvehost(), and ip_addr::u.
Referenced by received_test().
| char* clen_builder | ( | struct sip_msg * | msg, | |
| int * | clen_len, | |||
| int | diff | |||
| ) |
Definition at line 387 of file msg_translator.c.
References sip_msg::buf, buf, CONTENT_LENGTH, CONTENT_LENGTH_LEN, CRLF, CRLF_LEN, E_BAD_REQ, E_OUT_OF_MEM, get_body(), int2str(), sip_msg::len, len, LM_DBG, LM_ERR, pkg_malloc, and ser_error.
Referenced by adjust_clen().
| char* id_builder | ( | struct sip_msg * | msg, | |
| unsigned int * | id_len | |||
| ) |
Definition at line 358 of file msg_translator.c.
References buf, E_OUT_OF_MEM, ID_PARAM, ID_PARAM_LEN, int2reverse_hex(), len, LM_CRIT, LM_ERR, pkg_malloc, receive_info::proto_reserved1, sip_msg::rcv, and ser_error.
Referenced by build_req_buf_from_sip_req().
Definition at line 1223 of file msg_translator.c.
References anchor_lump(), sip_msg::buf, CRLF, CRLF_LEN, HDR_ROUTE_T, HDR_VIA_T, sip_msg::headers, insert_new_lump_before(), _str::len, LM_ERR, hdr_field::name, hdr_field::next, pkg_malloc, ROUTE_LEN, ROUTE_STR, _str::s, hdr_field::type, and sip_msg::unparsed.
Referenced by build_req_buf_from_sip_req().
| static int lump_check_opt | ( | struct lump * | l, | |
| struct sip_msg * | msg, | |||
| struct socket_info * | snd_s | |||
| ) | [inline, static] |
* checks if a lump opt condition returns 1 if cond is true, 0 if false
Definition at line 421 of file msg_translator.c.
References socket_info::address, ip_addr::af, lump::cond, COND_FALSE, COND_IF_DIFF_AF, COND_IF_DIFF_IP, COND_IF_DIFF_PORT, COND_IF_DIFF_PROTO, COND_IF_DIFF_REALMS, COND_TRUE, lump::flags, get_ip_port_proto, ip_addr_cmp, LM_CRIT, LUMPFLAG_COND_TRUE, port, socket_info::port_no, socket_info::proto, and lump::u.
Referenced by lumps_len(), and process_lumps().
| static int lumps_len | ( | struct sip_msg * | msg, | |
| struct lump * | lumps, | |||
| struct socket_info * | send_sock | |||
| ) | [inline, static] |
computes the "unpacked" len of a lump list, code moved from build_req_from_req
Definition at line 489 of file msg_translator.c.
References socket_info::address_str, lump::after, lump::before, lump::len, _str::len, LM_CRIT, LUMP_ADD, LUMP_ADD_OPT, LUMP_ADD_SUBST, lump_check_opt(), LUMP_DEL, LUMP_NOP, lump::next, lump::offset, lump::op, socket_info::port_no_str, sip_msg::set_global_address, sip_msg::set_global_port, SUBST_LUMP_LEN, and lump::u.
Referenced by build_req_buf_from_sip_req(), and build_res_buf_from_sip_res().
| static void process_lumps | ( | struct sip_msg * | msg, | |
| struct lump * | lumps, | |||
| char * | new_buf, | |||
| unsigned int * | new_buf_offs, | |||
| unsigned int * | orig_offs, | |||
| struct socket_info * | send_sock | |||
| ) | [inline, static] |
another helper functions, adds/Removes the lump, code moved form build_req_from_req
Definition at line 738 of file msg_translator.c.
References socket_info::address_str, lump::after, lump::before, sip_msg::buf, lump::len, _str::len, LM_CRIT, LM_WARN, LUMP_ADD, LUMP_ADD_OPT, LUMP_ADD_SUBST, lump_check_opt(), LUMP_DEL, LUMP_NOP, lump::next, lump::offset, lump::op, socket_info::port_no_str, sip_msg::set_global_address, sip_msg::set_global_port, SUBST_LUMP, lump::u, and lump::value.
Referenced by build_req_buf_from_sip_req(), and build_res_buf_from_sip_res().
| char* received_builder | ( | struct sip_msg * | msg, | |
| unsigned int * | received_len | |||
| ) |
Definition at line 305 of file msg_translator.c.
References buf, E_OUT_OF_MEM, ip_addr2a(), len, LM_ERR, MAX_RECEIVED_SIZE, pkg_malloc, sip_msg::rcv, RECEIVED, RECEIVED_LEN, ser_error, and receive_info::src_ip.
Referenced by build_req_buf_from_sip_req(), and build_res_buf_from_sip_req().
| int received_test | ( | struct sip_msg * | msg | ) |
check if IP address in Via != source IP address of signaling
Definition at line 209 of file msg_translator.c.
References check_via_address(), via_body::host, via_body::maddr, NULL, via_body::port, via_body::proto, sip_msg::rcv, via_body::received, received_dns, receive_info::src_ip, via_param::value, and sip_msg::via1.
Referenced by build_req_buf_from_sip_req(), build_res_buf_from_sip_req(), nat_uac_test_f(), and test_source_address().
| char* rport_builder | ( | struct sip_msg * | msg, | |
| unsigned int * | rport_len | |||
| ) |
Definition at line 334 of file msg_translator.c.
References buf, E_OUT_OF_MEM, int2str(), len, LM_ERR, pkg_malloc, sip_msg::rcv, RPORT, RPORT_LEN, ser_error, and receive_info::src_port.
Referenced by build_req_buf_from_sip_req(), and build_res_buf_from_sip_req().
| char* via_builder | ( | unsigned int * | len, | |
| struct socket_info * | send_sock, | |||
| str * | branch, | |||
| str * | extra_params, | |||
| int | proto, | |||
| struct hostport * | hp | |||
| ) |
Definition at line 1905 of file msg_translator.c.
References socket_info::address_str, CRLF, CRLF_LEN, E_OUT_OF_MEM, hostport::host, _str::len, LM_CRIT, LM_ERR, MY_BRANCH, MY_BRANCH_LEN, MY_VIA, MY_VIA_LEN, pkg_malloc, hostport::port, socket_info::port_no, socket_info::port_no_str, PROTO_SCTP, PROTO_TCP, PROTO_TLS, PROTO_UDP, _str::s, ser_error, SIP_PORT, and via_len.
Referenced by assemble_via(), build_dlg_ack(), build_local(), build_req_buf_from_sip_req(), and build_uac_cancel().
| static char* warning_builder | ( | struct sip_msg * | msg, | |
| unsigned int * | returned_len | |||
| ) | [static] |
Definition at line 228 of file msg_translator.c.
References receive_info::bind_address, buf, sip_msg::first_line, HDR_EOH_F, _str::len, LM_ERR, MAX_WARNING_LEN, my_pid(), socket_info::name, sip_msg::new_uri, sip_msg::parsed_flag, socket_info::port_no_str, sip_msg::rcv, msg_start::request, _str::s, receive_info::src_ip, receive_info::src_port, str_int_print, str_ipaddr_print, str_lenpair_print, str_pair_print, str_print, msg_start::u, via_cnt, WARNING, WARNING_LEN, WARNING_PHRASE, and WARNING_PHRASE_LEN.
Referenced by build_res_buf_from_sip_req().
| char version[] |
| int version_len |
1.5.6