seas_action.c File Reference

#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"

Include dependency graph for seas_action.c:

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_msgparse_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 Documentation

#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"

Definition at line 68 of file seas_action.c.

Referenced by ac_cancel(), and ac_uac_req().

#define SPIRAL_HDR_LEN   (sizeof(SPIRAL_HDR)-1)

Definition at line 69 of file seas_action.c.

Referenced by ac_cancel(), and ac_uac_req().

#define VIA   "Via: "

Definition at line 74 of file seas_action.c.

Referenced by extract_allowed_headers().

#define VIA_LEN   (sizeof(VIA)-1)

Definition at line 75 of file seas_action.c.

Referenced by extract_allowed_headers().


Function Documentation

int ac_cancel ( as_p  the_as,
char *  action,
int  len 
)

ac_cancel:

Parameters:
the_as Application Server structure which sent this action
action action payload
len the length of the payload
This function cancels a previously initiated UAC Transaction. it receives the HashIndex and Label of the cell being cancelled and invokes t_cancel_uac from the transactionModule API which cancels the transaction.

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 
)

int ac_sl_msg ( as_p  the_as,
char *  action,
int  len 
)

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]

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 
)

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().

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  )  [inline, static]

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]

int print_local_uri ( as_p  as,
char  processor_id,
char *  where,
int  len 
)

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 
)

int recordroute_diff ( struct sip_msg req,
struct sip_msg resp 
)

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().

int via_diff ( struct sip_msg req,
struct sip_msg resp 
)


Variable Documentation

int fifo_pid

pid_t my_parent

Definition at line 79 of file seas_action.c.

Referenced by dispatch_actions().

Definition at line 68 of file seas.c.

Referenced by seas_init_tags().

char seas_tags[]

Definition at line 67 of file seas.c.

Referenced by seas_init_tags().


Generated on Thu May 24 12:00:42 2012 for Kamailio - The Open Source SIP Server by  doxygen 1.5.6