t_reply.c File Reference

TM :: Reply handling. More...

#include "../../hash_func.h"
#include "../../dprint.h"
#include "../../config.h"
#include "../../parser/parser_f.h"
#include "../../ut.h"
#include "../../timer.h"
#include "../../error.h"
#include "../../action.h"
#include "../../dset.h"
#include "../../tags.h"
#include "../../data_lump.h"
#include "../../data_lump_rpl.h"
#include "../../usr_avp.h"
#include "h_table.h"
#include "t_hooks.h"
#include "t_funcs.h"
#include "t_reply.h"
#include "t_cancel.h"
#include "t_msgbuilder.h"
#include "t_lookup.h"
#include "t_fwd.h"
#include "fix_lumps.h"
#include "t_stats.h"
#include "uac.h"

Include dependency graph for t_reply.c:

Go to the source code of this file.

Functions

static int _reply (struct cell *trans, struct sip_msg *p_msg, unsigned int code, str *text, int lock)
 Send a UAS reply.
static int _reply_light (struct cell *trans, char *buf, unsigned int len, unsigned int code, char *to_tag, unsigned int to_tag_len, int lock, struct bookmark *bm)
void cleanup_uac_timers (struct cell *t)
 Cleanup UAC timers on a transaction.
static int do_dns_failover (struct cell *t)
 Do DNS failover.
static int fake_req (struct sip_msg *faked_req, struct sip_msg *shm_msg, struct ua_server *uas, struct ua_client *uac)
 Fake a request.
static void faked_env (struct cell *t, struct sip_msg *msg)
 Setup or restore a faked environment conforming with the message.
static void free_faked_req (struct sip_msg *faked_req, struct cell *t)
 Free faked requests.
unsigned int get_on_negative (void)
unsigned int get_on_reply (void)
static int is_3263_failure (struct cell *t)
 Test for DNS failover according RFC 3363 and 3261.
enum rps local_reply (struct cell *t, struct sip_msg *p_msg, int branch, unsigned int msg_status, branch_bm_t *cancel_bitmap)
 "UAC" above transaction layer
enum rps relay_reply (struct cell *t, struct sip_msg *p_msg, int branch, unsigned int msg_status, branch_bm_t *cancel_bitmap)
 Decide what and when shall be relayed upstream.
int reply_received (struct sip_msg *p_msg)
 Called whenever a reply for our module is received.
static int run_failure_handlers (struct cell *t)
 Run failure handlers.
static int send_ack (struct sip_msg *rpl, struct cell *trans, int branch)
 Build and send an ACK to a negative reply.
void set_final_timer (struct cell *t)
 Set final timer on a transaction.
static int store_reply (struct cell *trans, int branch, struct sip_msg *rpl)
int t_get_picked_branch (void)
 returns the picked branch
int t_get_reply_totag (struct sip_msg *msg, str *totag)
void t_on_negative (unsigned int go_to)
 Set which 'reply' structure to take if only negative replies arrive.
void t_on_reply (unsigned int go_to)
static int t_pick_branch (struct cell *t, int *res_code)
 Select a branch for forwarding.
int t_reply (struct cell *t, struct sip_msg *p_msg, unsigned int code, str *text)
 Small wrapper around _reply with locking.
int t_reply_unsafe (struct cell *t, struct sip_msg *p_msg, unsigned int code, str *text)
 Small wrapper around _reply without locking.
int t_reply_with_body (struct cell *trans, unsigned int code, str *text, str *body, str *new_header, str *to_tag)
int t_retransmit_reply (struct cell *t)
 Retransmits the last sent inbound reply.
static enum rps t_should_relay_response (struct cell *Trans, int new_code, int branch, int *should_store, int *should_relay, branch_bm_t *cancel_bitmap, struct sip_msg *reply)
 Decide about reply processing and resulting transaction state.
void tm_init_tags (void)
int unmatched_totag (struct cell *t, struct sip_msg *ack)
 Checks if the message was previously acknowledged.
static void update_local_tags (struct cell *trans, struct bookmark *bm, char *dst_buffer, char *src_buffer)
 Update local tags in transaction.
static int update_totag_set (struct cell *t, struct sip_msg *ok)
 Append a newly received tag from a 200/INVITE to transaction's set.

Variables

int _tm_branch_index
int disable_6xx_block = 0
int drop_stateless_replies = 0
static int goto_on_negative = 0
static int goto_on_reply = 0
int onreply_avp_mode = 0
static int picked_branch = -1
int restart_fr_on_each_reply = 1
static str tm_tag = {tm_tags,TOTAG_VALUE_LEN}
char * tm_tag_suffix
char tm_tags [TOTAG_VALUE_LEN]


Detailed Description

TM :: Reply handling.

Definition in file t_reply.c.


Function Documentation

static int _reply ( struct cell trans,
struct sip_msg p_msg,
unsigned int  code,
str text,
int  lock 
) [static]

Send a UAS reply.

Returns:
1 if everything was OK or -1 for errors

Definition at line 454 of file t_reply.c.

References _reply_light(), add_lump_rpl(), buf, build_res_buf_from_sip_req(), calc_crc_suffix(), get_to, len, LUMP_RPL_HDR, print_dset(), REQ_RPLD, _str::s, set_kr(), tm_tag_suffix, sip_msg::to, and TOTAG_VALUE_LEN.

Referenced by t_reply(), and t_reply_unsafe().

static int _reply_light ( struct cell trans,
char *  buf,
unsigned int  len,
unsigned int  code,
char *  to_tag,
unsigned int  to_tag_len,
int  lock,
struct bookmark bm 
) [static]

void cleanup_uac_timers ( struct cell t  ) 

Cleanup UAC timers on a transaction.

Definition at line 1073 of file t_reply.c.

References cell::first_branch, retr_buf::fr_timer, LM_DBG, ua_client::request, reset_timer(), retr_buf::retr_timer, and cell::uac.

Referenced by _reply_light(), local_reply(), reply_received(), and t_release_transaction().

static int do_dns_failover ( struct cell t  )  [inline, static]

static int fake_req ( struct sip_msg faked_req,
struct sip_msg shm_msg,
struct ua_server uas,
struct ua_client uac 
) [inline, static]

static void faked_env ( struct cell t,
struct sip_msg msg 
) [inline, static]

Setup or restore a faked environment conforming with the message.

If msg is set -> it will fake the envinronmental vars conforming with the message, if NULL the environment will be restored to the original

Parameters:
t transaction
msg SIP message or NULL

Definition at line 499 of file t_reply.c.

References bind_address, retr_buf::dst, FAILURE_ROUTE, get_t(), ua_client::request, dest_info::send_sock, set_avp_list(), set_route_type, set_t(), swap_route_type, cell::uac, and cell::user_avps.

Referenced by do_dns_failover(), and run_failure_handlers().

static void free_faked_req ( struct sip_msg faked_req,
struct cell t 
) [inline, static]

Free faked requests.

Parameters:
faked_req SIP message with faked request
t transaction

Definition at line 604 of file t_reply.c.

References sip_msg::add_rm, sip_msg::body_lumps, clean_msg_clone(), del_nonshm_lump_rpl(), del_notflaged_lumps(), sip_msg::dst_uri, ua_server::end_request, LUMPFLAG_SHMEM, sip_msg::new_uri, pkg_free, sip_msg::reply_lump, ua_server::request, _str::s, and cell::uas.

Referenced by do_dns_failover(), and run_failure_handlers().

unsigned int get_on_negative ( void   ) 

Definition at line 180 of file t_reply.c.

References goto_on_negative.

Referenced by init_new_t().

unsigned int get_on_reply ( void   ) 

Definition at line 184 of file t_reply.c.

References goto_on_reply.

Referenced by init_new_t().

static int is_3263_failure ( struct cell t  )  [inline, static]

Test for DNS failover according RFC 3363 and 3261.

Test for DNS failover, according to RFC 3263 and RFC 3261, this means a 503 reply with Retr-After header or timeout with no reply.

Parameters:
t transaction
Returns:
1 if this is a RFC 3263 failure, 0 otherwise

Definition at line 696 of file t_reply.c.

References FAKED_REPLY, ua_client::flags, HDR_RETRY_AFTER_T, sip_msg::headers, ua_client::last_received, LM_DBG, hdr_field::next, NULL, picked_branch, ua_client::reply, T_UAC_HAS_RECV_REPLY, hdr_field::type, and cell::uac.

Referenced by t_should_relay_response().

enum rps local_reply ( struct cell t,
struct sip_msg p_msg,
int  branch,
unsigned int  msg_status,
branch_bm_t cancel_bitmap 
)

"UAC" above transaction layer

This is the "UAC" above transaction layer; if a final reply is received, it triggers a callback.

Note:
It assumes it is entered locked with REPLY_LOCK and it returns unlocked!
Returns:
reply_status

Definition at line 1306 of file t_reply.c.

References cancel_uacs(), cleanup_uac_timers(), FAKED_REPLY, get_cseq, has_tran_tmcbs, is_invite, ua_client::last_received, LM_DBG, METHOD_INVITE, put_on_wait(), ua_client::reply, RPS_ERROR, run_trans_callbacks(), stats_trans_rpl, ua_server::status, store_reply(), t_should_relay_response(), TMCB_E2EACK_IN, TMCB_LOCAL_COMPLETED, TMCB_LOCAL_RESPONSE_OUT, TMCB_RESPONSE_OUT, TMCB_RESPONSE_PRE_OUT, cell::uac, cell::uas, UNLOCK_REPLIES, update_totag_set(), and which_cancel().

Referenced by fake_reply(), and reply_received().

enum rps relay_reply ( struct cell t,
struct sip_msg p_msg,
int  branch,
unsigned int  msg_status,
branch_bm_t cancel_bitmap 
)

int reply_received ( struct sip_msg p_msg  ) 

static int run_failure_handlers ( struct cell t  )  [inline, static]

static int send_ack ( struct sip_msg rpl,
struct cell trans,
int  branch 
) [static]

Build and send an ACK to a negative reply.

Returns:
0 on success, -1 for errors

Definition at line 302 of file t_reply.c.

References ACK, ACK_LEN, build_dlg_ack(), build_local(), HDR_EOH_F, HDR_TO_F, is_local, hdr_field::len, _str::len, LM_ERR, hdr_field::name, parse_headers(), ua_client::request, _str::s, SEND_PR_BUFFER, shm_free, sip_msg::to, and cell::uac.

Referenced by reply_received().

void set_final_timer ( struct cell t  ) 

static int store_reply ( struct cell trans,
int  branch,
struct sip_msg rpl 
) [static]

Definition at line 1086 of file t_reply.c.

References FAKED_REPLY, LM_ERR, ua_client::reply, sip_msg_cloner(), and cell::uac.

Referenced by local_reply(), and relay_reply().

int t_get_picked_branch ( void   ) 

returns the picked branch

Definition at line 134 of file t_reply.c.

References picked_branch.

Referenced by load_tm(), pv_get_tm_reply_code(), pv_t_update_rpl(), t_check_status(), and t_local_replied().

int t_get_reply_totag ( struct sip_msg msg,
str totag 
)

Definition at line 124 of file t_reply.c.

References calc_crc_suffix(), NULL, and tm_tag_suffix.

Referenced by load_tm().

void t_on_negative ( unsigned int  go_to  ) 

Set which 'reply' structure to take if only negative replies arrive.

Definition at line 152 of file t_reply.c.

References get_t(), goto_on_negative, cell::on_negative, and T_UNDEFINED.

Referenced by script_init(), and w_t_on_negative().

void t_on_reply ( unsigned int  go_to  ) 

Definition at line 166 of file t_reply.c.

References get_t(), goto_on_reply, cell::on_reply, and T_UNDEFINED.

Referenced by script_init(), and w_t_on_reply().

static int t_pick_branch ( struct cell t,
int *  res_code 
) [inline, static]

Select a branch for forwarding.

Returns:
0..X ... branch number, -1 for errors, -2 can't decide yet -- incomplete branches present

Definition at line 770 of file t_reply.c.

References retr_buf::buffer, cell::first_branch, ua_client::last_received, LM_DBG, ua_client::request, _str::s, cell::uac, and was_cancelled.

Referenced by t_should_relay_response().

int t_reply ( struct cell t,
struct sip_msg p_msg,
unsigned int  code,
str text 
)

Small wrapper around _reply with locking.

Definition at line 1029 of file t_reply.c.

References _reply().

Referenced by cancel_invite(), kill_transaction(), t_relay_to(), and w_t_reply().

int t_reply_unsafe ( struct cell t,
struct sip_msg p_msg,
unsigned int  code,
str text 
)

Small wrapper around _reply without locking.

Definition at line 1039 of file t_reply.c.

References _reply().

Referenced by relay_reply(), and w_t_reply().

int t_reply_with_body ( struct cell trans,
unsigned int  code,
str text,
str body,
str new_header,
str to_tag 
)

int t_retransmit_reply ( struct cell t  ) 

Retransmits the last sent inbound reply.

Parameters:
t request for which I want to retransmit an associated reply
Returns:
1 on succes, -1 on errors

Definition at line 986 of file t_reply.c.

References BUF_SIZE, retr_buf::buffer, retr_buf::dst, _str::len, len, LM_CRIT, LM_DBG, LOCK_REPLIES, ua_server::response, _str::s, SEND_PR_BUFFER, dest_info::send_sock, cell::uas, and UNLOCK_REPLIES.

Referenced by retransmission_handler(), t_check_trans(), and t_newtran().

static enum rps t_should_relay_response ( struct cell Trans,
int  new_code,
int  branch,
int *  should_store,
int *  should_relay,
branch_bm_t cancel_bitmap,
struct sip_msg reply 
) [static]

Decide about reply processing and resulting transaction state.

Decide about reply processing and resulting transaction state. This is the neurological point of reply processing -- called from within a REPLY_LOCK, t_should_relay_response decides how a reply shall be processed and how transaction state is affected. Checks if the new reply (with new_code status) should be sent or not based on the current transaction status.

Returns:
the branch number (0,1,...) which should be relayed, -1 if nothing to be relayed

Definition at line 812 of file t_reply.c.

References disable_6xx_block, do_dns_failover(), cell::flags, has_tran_tmcbs, is_3263_failure(), is_hopbyhop_cancel, is_invite, ua_client::last_received, LM_CRIT, LM_DBG, cell::nr_of_outgoings, NULL, cell::on_negative, picked_branch, ua_client::proxy, ua_client::reply, RPS_COMPLETED, RPS_DISCARDED, RPS_PROVISIONAL, RPS_PUSHED_AFTER_COMPLETION, RPS_STORE, run_failure_handlers(), ua_server::status, T_NO_DNS_FAILOVER_FLAG, T_NO_NEW_BRANCHES_FLAG, t_pick_branch(), TMCB_ON_FAILURE, cell::uac, cell::uas, and which_cancel().

Referenced by local_reply(), and relay_reply().

void tm_init_tags ( void   ) 

Definition at line 189 of file t_reply.c.

References init_tags(), TM_TAG_SEPARATOR, tm_tag_suffix, and tm_tags.

Referenced by mod_init().

int unmatched_totag ( struct cell t,
struct sip_msg ack 
)

Checks if the message was previously acknowledged.

Returns:
0 if the message was previously acknowledged (i.e., no E2EACK callback is needed) and 1 if the callback shall be executed

Definition at line 200 of file t_reply.c.

References totag_elem::acked, cell::fwded_totags, get_to, HDR_TO_F, _str::len, LM_DBG, LM_ERR, totag_elem::next, parse_headers(), _str::s, totag_elem::tag, and sip_msg::to.

Referenced by t_newtran().

static void update_local_tags ( struct cell trans,
struct bookmark bm,
char *  dst_buffer,
char *  src_buffer 
) [inline, static]

Update local tags in transaction.

Definition at line 230 of file t_reply.c.

References _str::len, ua_server::local_totag, _str::s, bookmark::to_tag_val, and cell::uas.

Referenced by _reply_light(), and relay_reply().

static int update_totag_set ( struct cell t,
struct sip_msg ok 
) [inline, static]

Append a newly received tag from a 200/INVITE to transaction's set.

Append a newly received tag from a 200/INVITE to transaction's set, (only safe if called from within a REPLY_LOCK).

Returns:
1 if such a to tag already exists, 0 on errors and if a new TO tag was created

Definition at line 249 of file t_reply.c.

References cell::fwded_totags, get_to, _str::len, LM_CRIT, LM_DBG, LM_ERR, totag_elem::next, hdr_field::parsed, _str::s, s, shm_free, shm_lock, shm_malloc_unsafe, shm_unlock, totag_elem::tag, and sip_msg::to.

Referenced by local_reply(), and relay_reply().


Variable Documentation

Definition at line 73 of file t_fwd.c.

disable the 6xx fork-blocking - default no (as per RFC3261)

Definition at line 108 of file t_reply.c.

Referenced by t_should_relay_response().

drop responses matching no client transaction (draft-sparks-sip-invfix-03)

Definition at line 105 of file t_reply.c.

Referenced by reply_received().

int goto_on_negative = 0 [static]

where to go if there is no positive reply

Definition at line 118 of file t_reply.c.

Referenced by get_on_negative(), and t_on_negative().

int goto_on_reply = 0 [static]

where to go on receipt of reply

Definition at line 120 of file t_reply.c.

Referenced by get_on_reply(), and t_on_reply().

Definition at line 103 of file t_reply.c.

Referenced by reply_received().

int picked_branch = -1 [static]

restart fr timer on each provisional reply, default yes

Definition at line 102 of file t_reply.c.

Referenced by reply_received().

str tm_tag = {tm_tags,TOTAG_VALUE_LEN} [static]

Definition at line 112 of file t_reply.c.

Definition at line 113 of file t_reply.c.

Referenced by _reply(), new_dlg_uas(), relay_reply(), t_get_reply_totag(), and tm_init_tags().

char tm_tags[TOTAG_VALUE_LEN]

private place where we create to-tags for replies

Definition at line 111 of file t_reply.c.

Referenced by new_dlg_uas(), and tm_init_tags().


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