* Create a request */
| 771 | * Create a request |
| 772 | */ |
| 773 | char* build_uac_req(str* method, str* headers, str* body, dlg_t* dialog, |
| 774 | int branch, struct cell *t, int* len) |
| 775 | { |
| 776 | char* buf, *w; |
| 777 | str content_length, cseq, via, mf; |
| 778 | str *cid = tm_via_cid(); |
| 779 | |
| 780 | if (!method || !dialog) { |
| 781 | LM_ERR("inalid parameter value\n"); |
| 782 | return 0; |
| 783 | } |
| 784 | if (print_content_length(&content_length, body) < 0) { |
| 785 | LM_ERR("failed to print content-length\n"); |
| 786 | return 0; |
| 787 | } |
| 788 | if (print_cseq_num(&cseq, dialog) < 0) { |
| 789 | LM_ERR("failed to print CSeq number\n"); |
| 790 | return 0; |
| 791 | } |
| 792 | *len = method->len + 1 + dialog->hooks.request_uri->len + 1 + |
| 793 | SIP_VERSION_LEN + CRLF_LEN; |
| 794 | |
| 795 | if (assemble_via(&via, t, dialog->send_sock, branch, cid) < 0) { |
| 796 | LM_ERR("failed to assemble Via\n"); |
| 797 | return 0; |
| 798 | } |
| 799 | *len += via.len; |
| 800 | |
| 801 | /* To */ |
| 802 | *len += TO_LEN |
| 803 | + (dialog->rem_dname.len ? dialog->rem_dname.len+1 : 0) |
| 804 | + dialog->rem_uri.len |
| 805 | + (dialog->id.rem_tag.len ? TOTAG_LEN + dialog->id.rem_tag.len : 0) |
| 806 | + 2 /* <> for URI */ + CRLF_LEN; |
| 807 | /* From */ |
| 808 | *len += FROM_LEN |
| 809 | + (dialog->loc_dname.len ? dialog->loc_dname.len+1 : 0) |
| 810 | + dialog->loc_uri.len |
| 811 | + (dialog->id.loc_tag.len ? FROMTAG_LEN + dialog->id.loc_tag.len : 0) |
| 812 | + 2 /* <> for URI */ + CRLF_LEN; |
| 813 | /* Call-ID */ |
| 814 | *len += CALLID_LEN + dialog->id.call_id.len + CRLF_LEN; |
| 815 | /* CSeq */ |
| 816 | *len += CSEQ_LEN + cseq.len + 1 + method->len + CRLF_LEN; |
| 817 | /* Route set */ |
| 818 | *len += calculate_routeset_length(dialog); |
| 819 | /* Max-Forwards */ |
| 820 | if (dialog->mf_enforced) { |
| 821 | mf.s = int2str( dialog->mf_value, &mf.len); |
| 822 | *len += LOCAL_MAXFWD_PREFIX_LEN + mf.len + CRLF_LEN; |
| 823 | } else { |
| 824 | mf.len = 0; mf.s = NULL; |
| 825 | *len += LOCAL_MAXFWD_HEADER_LEN; |
| 826 | } |
| 827 | /* Content-Length */ |
| 828 | *len += CONTENT_LENGTH_LEN + content_length.len + CRLF_LEN; |
| 829 | /* Signature */ |
| 830 | *len += (server_signature ? (user_agent_header->len + CRLF_LEN) : 0); |
no test coverage detected