| 1786 | } |
| 1787 | |
| 1788 | static int _reply_with_body( struct cell *trans, unsigned int code, str *text, |
| 1789 | str *body, str *new_header, str *to_tag, int lock_replies) |
| 1790 | { |
| 1791 | struct lump_rpl *hdr_lump; |
| 1792 | struct lump_rpl *body_lump; |
| 1793 | str rpl; |
| 1794 | int ret; |
| 1795 | struct bookmark bm; |
| 1796 | struct sip_msg* p_msg = trans->uas.request; |
| 1797 | str to_tag_rpl= {0, 0}; |
| 1798 | |
| 1799 | /* add the lumps for new_header and for body (by bogdan) */ |
| 1800 | if (new_header && new_header->len) { |
| 1801 | hdr_lump = add_lump_rpl( p_msg, new_header->s, |
| 1802 | new_header->len, LUMP_RPL_HDR ); |
| 1803 | if ( !hdr_lump ) { |
| 1804 | LM_ERR("failed to add hdr lump\n"); |
| 1805 | goto error; |
| 1806 | } |
| 1807 | } else { |
| 1808 | hdr_lump = 0; |
| 1809 | } |
| 1810 | |
| 1811 | /* body lump */ |
| 1812 | if(body && body->len) { |
| 1813 | body_lump = add_lump_rpl( p_msg, body->s, body->len, |
| 1814 | LUMP_RPL_BODY ); |
| 1815 | if (body_lump==0) { |
| 1816 | LM_ERR("failed add body lump\n"); |
| 1817 | goto error_1; |
| 1818 | } |
| 1819 | } else { |
| 1820 | body_lump = 0; |
| 1821 | } |
| 1822 | if (has_tran_tmcbs(trans, TMCB_LOCAL_RESPONSE)) { |
| 1823 | set_extra_tmcb_params(body, NULL); |
| 1824 | run_trans_callbacks(TMCB_LOCAL_RESPONSE, |
| 1825 | trans, p_msg, 0, code); |
| 1826 | } |
| 1827 | |
| 1828 | if(to_tag && to_tag->len) { |
| 1829 | rpl.s = build_res_buf_from_sip_req(code, text, to_tag, p_msg, |
| 1830 | (unsigned int*)&rpl.len, &bm); |
| 1831 | to_tag_rpl = *to_tag; |
| 1832 | } |
| 1833 | else |
| 1834 | if (code>=180 && p_msg->to && (get_to(p_msg)->tag_value.s==0 |
| 1835 | || get_to(p_msg)->tag_value.len==0)) { |
| 1836 | calc_tag_suffix( p_msg, tm_tag_suffix ); |
| 1837 | rpl.s = build_res_buf_from_sip_req(code,text, &tm_tag, p_msg, |
| 1838 | (unsigned int*)&rpl.len, &bm); |
| 1839 | to_tag_rpl.s = tm_tag.s; |
| 1840 | to_tag_rpl.len = TOTAG_VALUE_LEN; |
| 1841 | } else { |
| 1842 | rpl.s = build_res_buf_from_sip_req(code,text, 0 /*no to-tag*/, |
| 1843 | p_msg, (unsigned int*)&rpl.len, &bm); |
| 1844 | } |
| 1845 |
no test coverage detected