#include <unistd.h>#include <string.h>#include <arpa/inet.h>#include <sys/types.h>#include <signal.h>#include <poll.h>#include <assert.h>#include "../../mem/mem.h"#include "../../dprint.h"#include "../../str.h"#include "../../pt.h"#include "../../ip_addr.h"#include "../../tags.h"#include "../../error.h"#include "../../ut.h"#include "../../parser/hf.h"#include "../../parser/parse_fline.h"#include "../../parser/parser_f.h"#include "../../parser/parse_to.h"#include "../../parser/parse_from.h"#include "../../parser/parse_cseq.h"#include "../../parser/parse_content.h"#include "../../parser/parse_rr.h"#include "../../parser/parse_via.h"#include "../../parser/parse_param.h"#include "../../parser/parse_uri.h"#include "../../parser/msg_parser.h"#include "encode_msg.h"#include "../tm/t_lookup.h"#include "../tm/h_table.h"#include "../tm/dlg.h"#include "seas.h"#include "statistics.h"#include "seas_action.h"#include "seas_error.h"#include "ha.h"

Go to the source code of this file.
Defines | |
| #define | MAX_HEADER 1024 |
| #define | RECORD_ROUTE "Record-Route: " |
| #define | RECORD_ROUTE_LEN (sizeof(RECORD_ROUTE)-1) |
| #define | SPIRAL_HDR "X-WeSIP-SPIRAL: true" |
| #define | SPIRAL_HDR_LEN (sizeof(SPIRAL_HDR)-1) |
| #define | VIA "Via: " |
| #define | VIA_LEN (sizeof(VIA)-1) |
Functions | |
| int | ac_cancel (as_p the_as, char *action, int len) |
| static int | ac_jain_pong (as_p the_as, char *action, int len) |
| int | ac_reply (as_p the_as, char *action, int len) |
| int | ac_sl_msg (as_p the_as, char *action, int len) |
| int | ac_uac_req (as_p the_as, char *action, int len) |
| int | as_action_fail_resp (int uac_id, int sip_error, char *err_buf, int i) |
| static int | calculate_hooks (dlg_t *_d) |
| char * | create_as_action_reply (struct cell *c, struct tmcb_params *params, int uac_id, char processor_id, int *evt_len) |
| int | dispatch_actions (void) |
| int | extract_allowed_headers (struct sip_msg *my_msg, int strip_top_vias, int allow_top_Rroutes, hdr_flags_t forbidden_hdrs, char *headers, int headers_len) |
| int | forward_sl_request (struct sip_msg *msg, struct proxy_l *proxy, int proto) |
| static void | free_sip_msg_lite (struct sip_msg *my_msg) |
| void | get_raw_uri (str *_s) |
| static struct sip_msg * | parse_ac_msg (hdr_flags_t flags, char *start, int len) |
| int | print_local_uri (as_p as, char processor_id, char *where, int len) |
| int | process_action (as_p the_as) |
| static int | process_input (int fd) |
| static int | process_pings (struct ha *the_table) |
| int | process_pong (struct ha *the_table, unsigned int seqno) |
| int | recordroute_diff (struct sip_msg *req, struct sip_msg *resp) |
| void | uac_cb (struct cell *t, int type, struct tmcb_params *rcvd_params) |
| void | uac_cleanup_cb (struct cell *t, int type, struct tmcb_params *rcvd_params) |
| int | via_diff (struct sip_msg *req, struct sip_msg *resp) |
Variables | |
| int | fifo_pid |
| pid_t | my_parent |
| char * | seas_tag_suffix |
| char | seas_tags [] |
| #define MAX_HEADER 1024 |
Definition at line 66 of file seas_action.c.
Referenced by ac_cancel(), ac_reply(), ac_uac_req(), and t_lookup_callid().
| #define RECORD_ROUTE "Record-Route: " |
Definition at line 71 of file seas_action.c.
| #define RECORD_ROUTE_LEN (sizeof(RECORD_ROUTE)-1) |
Definition at line 72 of file seas_action.c.
| #define SPIRAL_HDR "X-WeSIP-SPIRAL: true" |
| #define SPIRAL_HDR_LEN (sizeof(SPIRAL_HDR)-1) |
| #define VIA "Via: " |
| #define VIA_LEN (sizeof(VIA)-1) |
| int ac_cancel | ( | as_p | the_as, | |
| char * | action, | |||
| int | len | |||
| ) |
ac_cancel:
| the_as | Application Server structure which sent this action | |
| action | action payload | |
| len | the length of the payload |
Returns:
Definition at line 393 of file seas_action.c.
References as_action_fail_resp(), sip_msg::buf, CRLF, CRLF_LEN, as_uac_param::destroy_cb_set, extract_allowed_headers(), sip_msg::first_line, free_hdr_field_lst(), get_body(), get_content_length, HDR_CALLID_F, HDR_CONTENTLENGTH_F, HDR_CSEQ_F, HDR_EOH_F, HDR_FROM_F, HDR_ROUTE_F, HDR_TO_F, sip_msg::headers, sip_msg::len, _str::len, LM_DBG, LM_ERR, MAX_HEADER, my_as, net2hostL, NULL, parse_headers(), parse_msg(), pkg_free, pkg_malloc, as_uac_param::processor_id, _str::s, SE_CANCEL, SE_CANCEL_MSG, SE_CANCEL_MSG_LEN, seas_f, shm_free, shm_malloc(), SIP_REPLY, SPIRAL_FLAG, SPIRAL_HDR, SPIRAL_HDR_LEN, tm_binds::t_cancel_uac, tm_binds::t_lookup_ident, seas_functions::tmb, msg_start::type, uac_cb(), as_uac_param::uac_id, tm_binds::unref_cell, and as_uac_param::who.
Referenced by process_action().
| static int ac_jain_pong | ( | as_p | the_as, | |
| char * | action, | |||
| int | len | |||
| ) | [inline, static] |
Definition at line 334 of file seas_action.c.
References app_server::jain_pings, net2hostL, and process_pong().
Referenced by process_action().
| int ac_reply | ( | as_p | the_as, | |
| char * | action, | |||
| int | len | |||
| ) |
ac_reply: UAS transaction Reply action. It replies to an incoming request with a response.
function descriptionReturns: what
Definition at line 644 of file seas_action.c.
References action_stat(), to_body::body, sip_msg::content_length, to_body::error, extract_allowed_headers(), sip_msg::first_line, cell::flags, free_sip_msg_lite(), get_body(), HDR_CALLID_F, HDR_CONTENTLENGTH_F, HDR_CSEQ_F, HDR_EOH_F, HDR_FROM_F, HDR_TO_F, HDR_VIA_F, is_invite, _str::len, LM_DBG, LM_ERR, MAX_HEADER, net2hostL, NULL, parse_ac_msg(), hdr_field::parsed, pkg_free, recordroute_diff(), msg_start::reply, REQ_LINE, ua_server::request, _str::s, seas_f, ua_server::status, T_IS_LOCAL_FLAG, tm_binds::t_lookup_ident, tm_binds::t_reply_with_body, to_body::tag_value, seas_functions::tmb, sip_msg::to, msg_start::u, cell::uas, tm_binds::unref_cell, and use_stats.
Referenced by process_action().
| int ac_sl_msg | ( | as_p | the_as, | |
| char * | action, | |||
| int | len | |||
| ) |
Definition at line 781 of file seas_action.c.
References sip_msg::first_line, sip_msg::force_send_socket, forward_sl_request(), free_proxy(), free_sip_msg_lite(), GET_RURI, grep_sock_info(), HDR_EOH_F, via_body::host, LM_DBG, LM_ERR, rr::nameaddr, net2hostL, NULL, parse_ac_msg(), parse_rr(), hdr_field::parsed, pkg_free, via_body::port, via_body::proto, proxy_l::proto, PROTO_NONE, proxy, msg_start::reply, msg_start::request, sip_msg::route, SIP_REQUEST, msg_start::type, msg_start::u, name_addr::uri, uri2proxy(), and sip_msg::via1.
Referenced by process_action().
| int ac_uac_req | ( | as_p | the_as, | |
| char * | action, | |||
| int | len | |||
| ) |
we trick req_within
Awful hack: to be able to set our own CSeq, from_tag and call-ID we have to use req_within instead of req_outside (it sets it's own CSeq,Call-ID and ftag), so we have to simulate that the dialog is already in completed state so...
this SHOULD be: shm_duplicate_rr(&my_dlg->route_set,my_msg->route->parsed); but it will last more...
now undo all the fakes we have put in my_dlg
Definition at line 912 of file seas_action.c.
References as_action_fail_resp(), hdr_field::body, calculate_hooks(), sip_msg::callid, check_transaction_quadruple(), sip_msg::content_length, CRLF, CRLF_LEN, sip_msg::cseq, as_uac_param::destroy_cb_set, to_body::display, tm_binds::dlg_add_extra, DLG_CONFIRMED, E_UNSPEC, err2reason_phrase(), extract_allowed_headers(), sip_msg::first_line, tm_binds::free_dlg, free_hdr_field_lst(), sip_msg::from, get_body(), get_content_length, get_from, HDR_CALLID_F, HDR_CONTENTLENGTH_F, HDR_CSEQ_F, HDR_EOH_F, HDR_FROM_F, HDR_ROUTE_F, HDR_TO_F, sip_msg::headers, dlg::hooks, dlg::id, _str::len, LM_DBG, LM_ERR, MAX_HEADER, MAX_REASON_LEN, METHOD_ACK, METHOD_CANCEL, my_as, net2hostL, tm_binds::new_dlg_uac, dlg_hooks::next_hop, NULL, cseq_body::number, parse_ac_msg(), parse_from_header(), parse_headers(), parse_rr(), hdr_field::parsed, pkg_free, pkg_malloc, print_local_uri(), as_uac_param::processor_id, dlg_id::rem_tag, dlg::rem_target, msg_start::request, sip_msg::route, dlg::route_set, _str::s, SE_UAC, seas_f, server_signature, shm_free, shm_malloc(), shm_str_dup(), SIP_REPLY, SPIRAL_FLAG, SPIRAL_HDR, SPIRAL_HDR_LEN, dlg::state, str2int(), dlg::T_flags, T_NO_AUTOACK_FLAG, T_PASS_PROVISIONAL_FLAG, tm_binds::t_request_within, to_body::tag_value, seas_functions::tmb, sip_msg::to, msg_start::type, msg_start::u, uac_cb(), as_uac_param::uac_id, to_body::uri, and as_uac_param::who.
Referenced by process_action().
| int as_action_fail_resp | ( | int | uac_id, | |
| int | sip_error, | |||
| char * | err_buf, | |||
| int | i | |||
| ) |
ERROR action responses are composed of: 4: the length of the event 1: the event type (AC_RES_FAIL) 4: NBO of the uac-action-request identification (uac_id) 4: the sip_error code in NBO. 1: (unsigned) the length of the string. N: the string
Definition at line 1358 of file seas_action.c.
References AC_RES_FAIL, app_server::action_fd, as_entry::as, LM_ERR, MAX_REASON_LEN, my_as, and as_entry::u.
Referenced by ac_cancel(), and ac_uac_req().
| static int calculate_hooks | ( | dlg_t * | _d | ) | [inline, static] |
Definition at line 1200 of file seas_action.c.
References dlg_hooks::first_route, get_raw_uri(), dlg::hooks, dlg_hooks::last_route, _str::len, LM_ERR, sip_uri::lr, rr::nameaddr, rr::next, dlg_hooks::next_hop, dlg_hooks::nh, parse_uri(), dlg::rem_target, dlg::rem_uri, dlg_hooks::request_uri, dlg::route_set, dlg_hooks::ru, _str::s, and name_addr::uri.
Referenced by ac_uac_req(), dlg_early_resp_uac(), dlg_new_resp_uac(), new_dlg_uac(), new_dlg_uas(), and w_calculate_hooks().
| char* create_as_action_reply | ( | struct cell * | c, | |
| struct tmcb_params * | params, | |||
| int | uac_id, | |||
| char | processor_id, | |||
| int * | evt_len | |||
| ) |
Definition at line 1469 of file seas_action.c.
References tmcb_params::code, receive_info::dst_ip, receive_info::dst_port, encode_msg(), ENCODED_MSG_SIZE, FAKED_REPLY, FAKED_REPLY_FLAG, cell::hash_index, cell::label, ip_addr::len, len, LM_ERR, cell::method, tmcb_params::param, port, receive_info::proto, sip_msg::rcv, RES_IN, tmcb_params::rpl, _str::s, shm_malloc(), receive_info::src_ip, receive_info::src_port, and ip_addr::u.
Referenced by uac_cb().
| int dispatch_actions | ( | void | ) |
Action Dispatcher process functions
Definition at line 93 of file seas_action.c.
References app_server::ac_buffer, app_server::action_fd, as_entry::as, AS_BUF_SIZE, jain_ping_timeout, app_server::jain_pings, _str::len, LM_ERR, MAX_WHOAMI_LEN, my_as, my_parent, as_entry::name, NULL, pkg_malloc, print_pingtable(), process_input(), process_pings(), pt, _str::s, servlet_ping_timeout, snprintf, timeout, as_entry::u, use_ha, and whoami.
Referenced by spawn_action_dispatcher().
| int extract_allowed_headers | ( | struct sip_msg * | my_msg, | |
| int | strip_top_vias, | |||
| int | allow_top_Rroutes, | |||
| hdr_flags_t | forbidden_hdrs, | |||
| char * | headers, | |||
| int | headers_len | |||
| ) |
Strips the "<strip_top_vias>" topmost via headers. Leaves only the topmost "<allow_top_routes>" Record-Route headers.
All vias MUST be parsed !!
skip this via header
is this dangerous ? because the rtcnt is the control variable for this conditional 'if' so if I change rtcnt value in one of the statements... what then ???
Definition at line 1250 of file seas_action.c.
References hdr_field::body, CRLF, CRLF_LEN, via_body::error, free_rr(), HDR_RECORDROUTE_T, HDR_T2F, HDR_VIA_T, sip_msg::headers, via_body::i, rr::len, hdr_field::len, _str::len, len, LM_DBG, LM_ERR, LM_WARN, name_addr::name, via_body::name, hdr_field::name, rr::nameaddr, rr::next, via_body::next, hdr_field::next, NULL, parse_rr(), hdr_field::parsed, rb, _str::s, hdr_field::type, VIA, and VIA_LEN.
Referenced by ac_cancel(), ac_reply(), and ac_uac_req().
Utility functions
Definition at line 867 of file seas_action.c.
References proxy_l::addr_idx, sip_msg::buf, get_next_su(), get_send_socket(), proxy_l::host, hostent2su(), sip_msg::len, LM_DBG, LM_ERR, msg_send(), pkg_free, pkg_malloc, proxy_l::port, sockaddr_union::s, and SIP_PORT.
Referenced by ac_sl_msg().
| static void free_sip_msg_lite | ( | struct sip_msg * | my_msg | ) | [inline, static] |
should do the same as in free_sip_msg() but w/o freeing my_msg->buf
Definition at line 850 of file seas_action.c.
References sip_msg::add_rm, sip_msg::body_lumps, sip_msg::dst_uri, free_hdr_field_lst(), free_lump_list(), sip_msg::headers, _str::len, sip_msg::new_uri, sip_msg::path_vec, pkg_free, and _str::s.
Referenced by ac_reply(), ac_sl_msg(), and parse_ac_msg().
| void get_raw_uri | ( | str * | _s | ) |
Definition at line 1182 of file seas_action.c.
References find_not_quoted(), _str::len, and _str::s.
Referenced by calculate_hooks().
| static struct sip_msg * parse_ac_msg | ( | hdr_flags_t | flags, | |
| char * | start, | |||
| int | len | |||
| ) | [static, read] |
Definition at line 744 of file seas_action.c.
References sip_msg::buf, free_sip_msg_lite(), sip_msg::len, LM_DBG, LM_ERR, NULL, parse_headers(), parse_msg(), pkg_free, and pkg_malloc.
Referenced by ac_reply(), ac_sl_msg(), and ac_uac_req().
| int print_local_uri | ( | as_p | as, | |
| char | processor_id, | |||
| char * | where, | |||
| int | len | |||
| ) |
len MUST be >0
Definition at line 1113 of file seas_action.c.
References ip_addr::addr, ip_addr::addr16, socket_info::address, ip_addr::af, app_server::binds, app_server::bound_processor, _str::len, LM_DBG, LM_ERR, MAX_BINDS, NULL, socket_info::port_no, socket_info::proto, PROTO_SCTP, PROTO_TCP, PROTO_TLS, PROTO_UDP, _str::s, snprintf, TRANSPORT_PARAM, TRANSPORT_PARAM_LEN, and ip_addr::u.
Referenced by ac_uac_req().
| int process_action | ( | as_p | the_as | ) |
Processes the actions received from the socket. returns -1 on error 0 on success
Definition at line 276 of file seas_action.c.
References app_server::ac_buffer, ac_cancel(), AC_CANCEL, ac_jain_pong(), ac_reply(), ac_sl_msg(), ac_uac_req(), AS_BUF_SIZE, JAIN_PONG, _str::len, LM_DBG, LM_WARN, app_server::name, REPLY_FIN, REPLY_PROV, _str::s, SL_MSG, stats_reply(), UAC_REQ, and use_stats.
Referenced by process_input().
| static int process_input | ( | int | fd | ) | [inline, static] |
we return, so we will exit, so our parent (Event Dispatcher) will receive a sigchld and know it should tear down the corresponding AS what still is not clear is what will happen to events that were put in the pipe...
Definition at line 167 of file seas_action.c.
References app_server::ac_buffer, as_entry::as, AS_BUF_SIZE, _str::len, LM_DBG, LM_ERR, my_as, as_entry::name, pkg_free, process_action(), receivedplus, _str::s, as_entry::u, and use_stats.
Referenced by dispatch_actions().
| static int process_pings | ( | struct ha * | the_table | ) | [inline, static] |
The ha structure (high availability) uses a circular (ring) buffer. A linked list could be used, but it would involve a lot of shm_malloc/free, and this would involve a lot of shm-lock_get/release, which would interfere a lot with all the SER processes. With a this ring buffer, the lock_get/release only involve the SEAS processes. This function scans the ping structures in the buffer, computing the elapsed time from when the ping was sent, so if the ping has timed out, it increases the timed_out_pings counter. All the timed-out pings are removed from the buffer (the begin index is incremented). Because the pings are added always at the end of the buffer, they will always be ordered in increasing time, so when we find one ping that has not timed out, the following pings will neither be.
Definition at line 213 of file seas_action.c.
References ha::begin, ha::count, LM_DBG, ha::mutex, NULL, ha::pings, print_pingtable(), ha::size, ha::timed_out_pings, and ha::timeout.
Referenced by dispatch_actions().
| int process_pong | ( | struct ha * | the_table, | |
| unsigned int | seqno | |||
| ) |
Definition at line 345 of file seas_action.c.
References ha::begin, ha::count, ping::id, LM_DBG, ha::mutex, NULL, ha::pings, print_pingtable(), ping::sent, ha::size, ha::timed_out_pings, and ha::timeout.
Referenced by ac_jain_pong().
Definition at line 524 of file seas_action.c.
References free_rr(), HDR_RECORDROUTE_T, sip_msg::headers, rr::next, hdr_field::next, NULL, parse_rr(), hdr_field::parsed, and hdr_field::type.
Referenced by ac_reply().
| void uac_cb | ( | struct cell * | t, | |
| int | type, | |||
| struct tmcb_params * | rcvd_params | |||
| ) |
This function will be called from a SER process when a reply is received for the transaction. The SER processes only have acces to the EventDispatcher fifo (not to the ActionDispatcher) so EventDispatcher will be the one who will send the event to the AppServer. TODO WARNING !!! there's a clear MEMORY LEAK here, see exit: at the bottom of the function... it should free ev_info !!!!!!!! I have disabled the free() because It may be that we receive a retransmitted 200 OK if the ACK gets lost, that 200 OK will make SER invoke this callback a second,third, etc time...
Definition at line 1412 of file seas_action.c.
References as_msg::as, tmcb_params::code, create_as_action_reply(), as_uac_param::destroy_cb_set, is_local, ua_client::last_received, as_msg::len, _str::len, LM_DBG, LM_ERR, as_msg::msg, as_entry::name, cell::nr_of_outgoings, NULL, tmcb_params::param, as_uac_param::processor_id, tm_binds::register_tmcb, RES_IN, tmcb_params::rpl, _str::s, seas_f, shm_free, shm_malloc(), seas_functions::tmb, TMCB_LOCAL_COMPLETED, TMCB_TRANS_DELETED, as_msg::transaction, as_msg::type, cell::uac, uac_cleanup_cb(), as_uac_param::uac_id, as_uac_param::who, and write_pipe.
Referenced by ac_cancel(), and ac_uac_req().
| void uac_cleanup_cb | ( | struct cell * | t, | |
| int | type, | |||
| struct tmcb_params * | rcvd_params | |||
| ) |
Definition at line 1389 of file seas_action.c.
References NULL, tmcb_params::param, and shm_free.
Referenced by uac_cb().
Definition at line 574 of file seas_action.c.
References hdr_field::body, via_body::error, free_via_list(), sip_msg::h_via1, via_body::i, _str::len, LM_ERR, via_body::next, NULL, parse_via(), hdr_field::parsed, pkg_free, pkg_malloc, _str::s, and hdr_field::sibling.
| int fifo_pid |
| pid_t my_parent |
| char* seas_tag_suffix |
| char seas_tags[] |
1.5.6