@@ -1696,37 +1696,8 @@ int reply_received( struct sip_msg *p_msg )
1696
1696
return 1 ;
1697
1697
}
1698
1698
1699
- int w_t_reply_body (struct sip_msg * msg , unsigned int * code , str * text ,
1700
- str * body )
1701
- {
1702
- struct cell * t ;
1703
- int r ;
1704
-
1705
- t = get_t ();
1706
- if ( t == 0 || t == T_UNDEFINED ) {
1707
- /* t_reply_with_body() is a bit of a weird function as it
1708
- * receiving as parameter the actual msg, but the transaction
1709
- * (and uses the saved msg from transaction).
1710
- * So we need to take care and save everything into transaction,
1711
- * otherwise we will loose the rpl lumps. --bogdan */
1712
- r = t_newtran ( msg , 1 /*full uas cloning*/ );
1713
- if (r == 0 ) {
1714
- /* retransmission -> break the script */
1715
- return 0 ;
1716
- } else if (r < 0 ) {
1717
- LM_ERR ("could not create a new transaction\n" );
1718
- return -1 ;
1719
- }
1720
- t = get_t ();
1721
- } else {
1722
- update_cloned_msg_from_msg ( t -> uas .request , msg );
1723
- }
1724
- return t_reply_with_body (t , * code , text , body , 0 , 0 );
1725
- }
1726
-
1727
-
1728
- int t_reply_with_body ( struct cell * trans , unsigned int code , str * text ,
1729
- str * body , str * new_header , str * to_tag )
1699
+ static int _reply_with_body ( struct cell * trans , unsigned int code , str * text ,
1700
+ str * body , str * new_header , str * to_tag , int lock_replies )
1730
1701
{
1731
1702
struct lump_rpl * hdr_lump ;
1732
1703
struct lump_rpl * body_lump ;
@@ -1795,7 +1766,7 @@ int t_reply_with_body( struct cell *trans, unsigned int code, str *text,
1795
1766
goto error ;
1796
1767
}
1797
1768
ret = _reply_light ( trans , rpl .s , rpl .len , code , to_tag_rpl .s , to_tag_rpl .len ,
1798
- 1 /* lock replies */ , & bm );
1769
+ lock_replies , & bm );
1799
1770
1800
1771
/* mark the transaction as replied */
1801
1772
if (code >=200 ) set_kr (REQ_RPLD );
@@ -1810,3 +1781,59 @@ int t_reply_with_body( struct cell *trans, unsigned int code, str *text,
1810
1781
return -1 ;
1811
1782
}
1812
1783
1784
+
1785
+ int w_t_reply_body (struct sip_msg * msg , unsigned int * code , str * text ,
1786
+ str * body )
1787
+ {
1788
+ struct cell * t ;
1789
+ int r , lock_replies = 1 ;
1790
+
1791
+ if (msg -> REQ_METHOD == METHOD_ACK ) {
1792
+ LM_DBG ("ACKs are not replied\n" );
1793
+ return 0 ;
1794
+ }
1795
+
1796
+ switch (route_type ) {
1797
+ case FAILURE_ROUTE :
1798
+ t = get_t ();
1799
+ if ( t == 0 || t == T_UNDEFINED ) {
1800
+ LM_BUG ("no transaction found in Failure Route\n" );
1801
+ return -1 ;
1802
+ }
1803
+ lock_replies = 0 ;
1804
+ break ;
1805
+ case REQUEST_ROUTE :
1806
+ t = get_t ();
1807
+ if ( t == 0 || t == T_UNDEFINED ) {
1808
+ /* t_reply_with_body() is a bit of a weird function as it is
1809
+ * receiving as parameter the actual msg, but the transaction
1810
+ * (and uses the saved msg from transaction).
1811
+ * So we need to take care and save everything into transaction,
1812
+ * otherwise we will loose the rpl lumps. --bogdan */
1813
+ r = t_newtran ( msg , 1 /*full uas cloning*/ );
1814
+ if (r == 0 ) {
1815
+ /* retransmission -> break the script */
1816
+ return 0 ;
1817
+ } else if (r < 0 ) {
1818
+ LM_ERR ("could not create a new transaction\n" );
1819
+ return -1 ;
1820
+ }
1821
+ t = get_t ();
1822
+ } else {
1823
+ update_cloned_msg_from_msg ( t -> uas .request , msg );
1824
+ }
1825
+ break ;
1826
+ default :
1827
+ LM_CRIT ("unsupported route_type (%d)\n" , route_type );
1828
+ return -1 ;
1829
+ }
1830
+ return _reply_with_body (t , * code , text , body , 0 , 0 , lock_replies );
1831
+ }
1832
+
1833
+
1834
+ int t_reply_with_body ( struct cell * trans , unsigned int code , str * text ,
1835
+ str * body , str * new_header , str * to_tag )
1836
+ {
1837
+ return _reply_with_body (trans , code , text , body , new_header ,
1838
+ to_tag , 1 /* lock replies */ );
1839
+ }
0 commit comments