This function is called whenever a reply for our module is received; * we need to register this function on module initialization; * Returns : 0 - core router stops * 1 - core router relay statelessly */
| 1604 | * 1 - core router relay statelessly |
| 1605 | */ |
| 1606 | int reply_received( struct sip_msg *p_msg ) |
| 1607 | { |
| 1608 | int msg_status; |
| 1609 | int last_uac_status; |
| 1610 | int branch; |
| 1611 | /* has the transaction completed now and we need to clean-up? */ |
| 1612 | struct ua_client *uac; |
| 1613 | struct cell *t; |
| 1614 | struct usr_avp **backup_list; |
| 1615 | unsigned int has_reply_route; |
| 1616 | int old_route_type, ack_sent = 0; |
| 1617 | str ack_buf; |
| 1618 | |
| 1619 | set_t(T_UNDEFINED); |
| 1620 | |
| 1621 | profiling_proc_enter( LEVEL_SIP, "TM_reply_received", 0 ); |
| 1622 | |
| 1623 | /* make sure we know the associated transaction ... */ |
| 1624 | switch (t_check(p_msg, &branch )) { |
| 1625 | case -1: goto not_found; |
| 1626 | case -2: return 0; /* reply forwarded elsewhere */ |
| 1627 | } |
| 1628 | |
| 1629 | /*... if there is none, tell the core router to fwd statelessly */ |
| 1630 | t = get_t(); |
| 1631 | if ((t == 0) || (t == T_UNDEFINED)) goto not_found; |
| 1632 | |
| 1633 | msg_status=p_msg->REPLY_STATUS; |
| 1634 | |
| 1635 | uac=&TM_BRANCH(t,branch); |
| 1636 | LM_DBG("org. status uas=%d, uac[%d]=%d local=%d is_invite=%d)\n", |
| 1637 | t->uas.status, branch, uac->last_received, |
| 1638 | is_local(t), is_invite(t)); |
| 1639 | last_uac_status=uac->last_received; |
| 1640 | if_update_stat( tm_enable_stats, tm_rcv_rpls , 1); |
| 1641 | |
| 1642 | /* it's a cancel which is not e2e ? */ |
| 1643 | if ( get_cseq(p_msg)->method_id==METHOD_CANCEL && is_invite(t) ) { |
| 1644 | /* ... then just stop timers */ |
| 1645 | reset_timer( &uac->local_cancel.retr_timer); |
| 1646 | if ( msg_status >= 200 ) { |
| 1647 | reset_timer( &uac->local_cancel.fr_timer); |
| 1648 | } |
| 1649 | LM_DBG("reply to local CANCEL processed\n"); |
| 1650 | |
| 1651 | if (has_tran_tmcbs( t, TMCB_MSG_MATCHED_IN) ) |
| 1652 | run_trans_callbacks( TMCB_MSG_MATCHED_IN, t, 0, |
| 1653 | p_msg, p_msg->REPLY_STATUS); |
| 1654 | |
| 1655 | goto done; |
| 1656 | } |
| 1657 | |
| 1658 | /* *** stop timers *** */ |
| 1659 | /* stop retransmission */ |
| 1660 | reset_timer(&uac->request.retr_timer); |
| 1661 | |
| 1662 | /* stop final response timer only if I got a final response */ |
| 1663 | if ( msg_status >= 200 ) { |
nothing calls this directly
no test coverage detected