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

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] |
Definition in file t_reply.c.
| static int _reply | ( | struct cell * | trans, | |
| struct sip_msg * | p_msg, | |||
| unsigned int | code, | |||
| str * | text, | |||
| int | lock | |||
| ) | [static] |
Send a UAS reply.
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] |
Definition at line 333 of file t_reply.c.
References retr_buf::activ_type, buf_len, retr_buf::buffer, cancel_uacs(), cleanup_uac_timers(), retr_buf::dst, FAKED_REPLY, has_tran_tmcbs, is_hopbyhop_cancel, is_invite, is_local, _str::len, LM_CRIT, LM_DBG, LM_ERR, LOCK_REPLIES, pkg_free, put_on_wait(), rb, cell::relayed_reply_branch, REPLY_OVERBUFFER_LEN, ua_server::request, ua_server::response, run_trans_callbacks(), _str::s, SEND_PR_BUFFER, dest_info::send_sock, set_extra_tmcb_params(), set_final_timer(), shm_resize, stats_trans_rpl, ua_server::status, TMCB_LOCAL_COMPLETED, TMCB_RESPONSE_OUT, TMCB_RESPONSE_PRE_OUT, cell::uas, UNLOCK_REPLIES, update_local_tags(), and which_cancel().
Referenced by _reply(), and t_reply_with_body().
| 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] |
Do DNS failover.
Definition at line 726 of file t_reply.c.
References append_branch(), ua_client::br_flags, retr_buf::dst, fake_req(), faked_env(), sip_msg::force_send_socket, free_faked_req(), get_next_su(), LM_DBG, LM_ERR, picked_branch, ua_client::proxy, ua_client::request, ua_server::request, t_forward_nonack(), dest_info::to, cell::uac, cell::uas, and ua_client::uri.
Referenced by t_should_relay_response().
| static int fake_req | ( | struct sip_msg * | faked_req, | |
| struct sip_msg * | shm_msg, | |||
| struct ua_server * | uas, | |||
| struct ua_client * | uac | |||
| ) | [inline, static] |
Fake a request.
Definition at line 538 of file t_reply.c.
References ua_client::br_flags, sip_msg::dst_uri, sip_msg::flags, sip_msg::id, _str::len, LM_ERR, sip_msg::new_uri, sip_msg::parsed_uri_ok, pkg_free, pkg_malloc, ua_server::request, _str::s, setb0flags(), and ua_client::uri.
Referenced by do_dns_failover(), and run_failure_handlers().
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
| 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().
Free faked requests.
| 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 | ) |
| unsigned int get_on_reply | ( | void | ) |
| 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.
| t | transaction |
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.
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 | |||
| ) |
Decide what and when shall be relayed upstream.
This is the code which decides what and when shall be relayed upstream.
Definition at line 1120 of file t_reply.c.
References retr_buf::activ_type, sip_msg::add_rm, buf, retr_buf::buffer, build_res_buf_from_sip_req(), build_res_buf_from_sip_res(), calc_crc_suffix(), cancel_uacs(), retr_buf::dst, error_text(), FAKED_REPLY, free_via_clen_lump(), get_to, has_tran_tmcbs, is_invite, ua_client::last_received, _str::len, LM_DBG, LM_ERR, NULL, pkg_free, cell::relayed_reply_branch, ua_client::reply, REPLY_OVERBUFFER_LEN, ua_server::request, ua_server::response, RPS_COMPLETED, RPS_ERROR, run_trans_callbacks(), _str::s, SEND_PR_BUFFER, set_extra_tmcb_params(), set_final_timer(), shm_resize, sip_msg_free, stats_trans_rpl, ua_server::status, store_reply(), t_reply_unsafe(), t_should_relay_response(), tm_tag_suffix, TMCB_E2EACK_IN, TMCB_RESPONSE_FWDED, TMCB_RESPONSE_OUT, TMCB_RESPONSE_PRE_OUT, sip_msg::to, cell::uac, cell::uas, UNLOCK_REPLIES, update_local_tags(), and update_totag_set().
Referenced by cancel_invite(), fake_reply(), and reply_received().
| int reply_received | ( | struct sip_msg * | p_msg | ) |
Called whenever a reply for our module is received.
This function is called whenever a reply for our module is received, we need to register this function on module initialization.
| p_msg | SIP message |
Definition at line 1384 of file t_reply.c.
References _tm_branch_index, ACT_FL_DROP, ua_client::br_flags, sip_msg::branch_index, retr_buf::buffer, cancel_branch(), cancel_uacs(), cleanup_uac_timers(), drop_stateless_replies, ua_client::flags, sip_msg::flags, cell::flags, fr_inv_avp2timer(), FR_INV_TIMER_LIST, retr_buf::fr_timer, get_cseq, get_t(), getb0flags(), HDR_RETRY_AFTER_F, if_update_stat, is_invite, is_local, ua_client::last_received, LM_DBG, LM_ERR, ua_client::local_cancel, local_reply(), LOCK_REPLIES, METHOD_CANCEL, no_autoack, NULL, cell::on_reply, onreply_avp_mode, onreply_rlist, parse_headers(), put_on_wait(), relay_reply(), ua_server::request, ua_client::request, reset_timer(), restart_fr_on_each_reply, retr_buf::retr_list, retr_buf::retr_timer, RPS_COMPLETED, RPS_PROVISIONAL, RT_T2, run_top_route(), _str::s, send_ack(), set_avp_list(), set_t(), set_timer(), setb0flags(), ua_server::status, t_check(), T_NO_DNS_FAILOVER_FLAG, T_UAC_HAS_RECV_REPLY, T_UAC_TO_CANCEL_FLAG, T_UNDEFINED, t_unref(), tm_enable_stats, tm_rcv_rpls, cell::uac, cell::uas, UNLOCK_REPLIES, and cell::user_avps.
| static int run_failure_handlers | ( | struct cell * | t | ) | [inline, static] |
Run failure handlers.
Definition at line 628 of file t_reply.c.
References check_hdrs_changes(), failure_rlist, fake_req(), faked_env(), sip_msg::flags, free_faked_req(), has_tran_tmcbs, ua_client::last_received, LM_ERR, LM_WARN, METHOD_CANCEL, sip_msg::msg_flags, cell::on_negative, picked_branch, tmcb_head_list::reg_types, ua_client::reply, REQ_LINE, ua_server::request, run_top_route(), run_trans_callbacks(), cell::tmcb_hl, TMCB_ON_FAILURE, cell::uac, and cell::uas.
Referenced by t_should_relay_response().
Build and send an ACK to a negative reply.
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 | ) |
Set final timer on a transaction.
Definition at line 1049 of file t_reply.c.
References force_retr(), is_local, METHOD_INVITE, put_on_wait(), cell::relayed_reply_branch, ua_server::request, ua_server::response, start_retr(), ua_server::status, and cell::uas.
Referenced by _reply_light(), and relay_reply().
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().
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.
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().
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().
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 | |||
| ) |
Definition at line 1586 of file t_reply.c.
References _reply_light(), add_lump_rpl(), build_res_buf_from_sip_req(), free_lump_rpl(), _str::len, LM_DBG, LM_ERR, LUMP_RPL_BODY, LUMP_RPL_HDR, REQ_RPLD, ua_server::request, _str::s, set_kr(), cell::uas, unlink_lump_rpl(), and UNREF.
Referenced by load_tm(), and mi_tm_reply().
| int t_retransmit_reply | ( | struct cell * | t | ) |
Retransmits the last sent inbound reply.
| t | request for which I want to retransmit an associated reply |
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.
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().
Checks if the message was previously acknowledged.
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().
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).
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().
| int _tm_branch_index |
| int disable_6xx_block = 0 |
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().
| int drop_stateless_replies = 0 |
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().
| int onreply_avp_mode = 0 |
int picked_branch = -1 [static] |
Definition at line 115 of file t_reply.c.
Referenced by do_dns_failover(), is_3263_failure(), run_failure_handlers(), t_get_picked_branch(), and t_should_relay_response().
| int restart_fr_on_each_reply = 1 |
restart fr timer on each provisional reply, default yes
Definition at line 102 of file t_reply.c.
Referenced by reply_received().
| char* tm_tag_suffix |
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().
1.5.6