MCPcopy Create free account
hub / github.com/OpenSIPS/opensips / t_should_relay_response

Function t_should_relay_response

modules/tm/t_reply.c:885–1095  ·  view source on GitHub ↗

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 - branch number (0,1,...) which should be relayed * -1 if

Source from the content-addressed store, hash-verified

883 * -1 if nothing to be relayed
884 */
885static enum rps t_should_relay_response( struct cell *Trans , int new_code,
886 int branch , int *should_store, int *should_relay,
887 branch_bm_t cancel_bitmap, struct sip_msg *reply )
888{
889 int branch_cnt;
890 int picked_code;
891 int inv_through;
892 int do_cancel;
893
894 /* note: this code never lets replies to CANCEL go through;
895 we generate always a local 200 for CANCEL; 200s are
896 not relayed because it's not an INVITE transaction;
897 >= 300 are not relayed because 200 was already sent
898 out
899 */
900 LM_DBG("T_code=%d, new_code=%d\n", Trans->uas.status,new_code);
901
902 /* a final reply after 200 OK on a transaction with multi branch 200 OK */
903 if ( is_invite(Trans) && new_code>=200
904 && Trans->flags&T_MULTI_200OK_FLAG
905 && Trans->uas.status>=200 && Trans->uas.status<300) {
906 *should_store=0;
907 picked_branch=-1;
908 TM_BRANCH(Trans,branch).last_received=new_code;
909 if (new_code>=300) {
910 /* negative reply, we simply discard (no relay, no save) */
911 *should_relay = -1;
912 return RPS_DISCARDED;
913 }
914 /* 2xx reply - is this the last branch to complete?? */
915 if (tran_is_completed(Trans)) {
916 /* last branch gets also a 200OK, no more pending branches */
917 *should_relay = branch;
918 return RPS_COMPLETED;
919 } else {
920 /* 200 OK, but still having ongoing branches */
921 *should_relay = branch;
922 return RPS_RELAY;
923 }
924 }
925
926 inv_through=new_code>=200 && new_code<300 && is_invite(Trans);
927 /* if final response sent out, allow only INVITE 2xx */
928 if ( Trans->uas.status >= 200 ) {
929 if (inv_through) {
930 LM_DBG("200 OK for INVITE after final sent\n");
931 *should_store=0;
932 TM_BRANCH(Trans,branch).last_received=new_code;
933 *should_relay=branch;
934 return RPS_PUSHED_AFTER_COMPLETION;
935 }
936 if ( is_hopbyhop_cancel(Trans) && new_code>=200) {
937 *should_store=0;
938 *should_relay=-1;
939 picked_branch=-1;
940 return RPS_COMPLETED;
941 }
942 /* except the exception above, too late messages will

Callers 2

relay_replyFunction · 0.85
local_replyFunction · 0.85

Calls 10

tran_is_completedFunction · 0.85
which_cancelFunction · 0.85
t_pick_branchFunction · 0.85
cleanup_uac_timersFunction · 0.85
cancel_uacsFunction · 0.85
reset_krFunction · 0.85
is_3263_failureFunction · 0.85
do_dns_failoverFunction · 0.85
run_failure_handlersFunction · 0.85
get_krFunction · 0.85

Tested by

no test coverage detected