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

Function local_reply

modules/tm/t_reply.c:1458–1530  ·  view source on GitHub ↗

this is the "UAC" above transaction layer; if a final reply is received, it triggers a callback; note well -- it assumes it is entered locked with REPLY_LOCK and it returns unlocked! */

Source from the content-addressed store, hash-verified

1456 it is entered locked with REPLY_LOCK and it returns unlocked!
1457*/
1458enum rps local_reply( struct cell *t, struct sip_msg *p_msg, int branch,
1459 unsigned int msg_status, branch_bm_t cancel_bitmap)
1460{
1461 /* how to deal with replies for local transaction */
1462 int local_store, local_winner;
1463 enum rps reply_status;
1464 struct sip_msg *winning_msg;
1465 int winning_code;
1466 int totag_retr;
1467 /* branch_bm_t cancel_bitmap; */
1468
1469 /* keep warning 'var might be used un-inited' silent */
1470 winning_msg=0;
1471 winning_code=0;
1472 totag_retr=0;
1473
1474 // *cancel_bitmap=0; <- no need, it is received fully zero'ed
1475
1476 reply_status=t_should_relay_response( t, msg_status, branch,
1477 &local_store, &local_winner, cancel_bitmap, p_msg );
1478 LM_DBG("branch=%d, save=%d, winner=%d\n",
1479 branch, local_store, local_winner );
1480 if (local_store) {
1481 if (!store_reply(t, branch, p_msg))
1482 goto error;
1483 }
1484 if (local_winner>=0) {
1485 winning_msg= branch==local_winner
1486 ? p_msg : TM_BRANCH(t,local_winner).reply;
1487 if (winning_msg==FAKED_REPLY) {
1488 winning_code = branch==local_winner
1489 ? msg_status : TM_BRANCH(t,local_winner).last_received;
1490 } else {
1491 winning_code=winning_msg->REPLY_STATUS;
1492 }
1493 t->uas.status = winning_code;
1494 stats_trans_rpl( winning_code, (winning_msg==FAKED_REPLY)?1:0 );
1495 if (is_invite(t) && winning_msg!=FAKED_REPLY
1496 && winning_code>=200 && winning_code <300
1497 && has_tran_tmcbs(t,
1498 TMCB_RESPONSE_OUT|TMCB_RESPONSE_PRE_OUT) ) {
1499 totag_retr=update_totag_set(t, winning_msg);
1500 }
1501 }
1502 UNLOCK_REPLIES(t);
1503
1504 if ( local_winner >= 0 ) {
1505 if (winning_code < 200) {
1506 if (!totag_retr && has_tran_tmcbs(t,TMCB_LOCAL_RESPONSE_OUT)) {
1507 LM_DBG("Passing provisional reply %d to FIFO application\n",
1508 winning_code);
1509 run_trans_callbacks( TMCB_LOCAL_RESPONSE_OUT, t, 0,
1510 winning_msg, winning_code);
1511 }
1512 } else {
1513 LM_DBG("local transaction completed\n");
1514 if (!totag_retr && has_tran_tmcbs(t,TMCB_LOCAL_COMPLETED) ) {
1515 run_trans_callbacks( TMCB_LOCAL_COMPLETED, t, t->uas.request,

Callers 2

process_reply_and_timerFunction · 0.85
fake_replyFunction · 0.85

Calls 9

t_should_relay_responseFunction · 0.85
store_replyFunction · 0.85
stats_trans_rplFunction · 0.85
update_totag_setFunction · 0.85
run_trans_callbacksFunction · 0.85
which_cancelFunction · 0.85
cleanup_uac_timersFunction · 0.85
cancel_uacsFunction · 0.85
put_on_waitFunction · 0.85

Tested by

no test coverage detected