| 2140 | } |
| 2141 | |
| 2142 | char * build_req_buf_from_sip_req( struct sip_msg* msg, |
| 2143 | unsigned int *returned_len, |
| 2144 | const struct socket_info* send_sock, int proto, |
| 2145 | str *via_params, unsigned int flags) |
| 2146 | { |
| 2147 | unsigned int len, new_len, received_len, rport_len, uri_len, via_len, body_delta; |
| 2148 | char *line_buf, *received_buf, *rport_buf, *new_buf, *buf, *id_buf; |
| 2149 | unsigned int offset, s_offset, size, id_len; |
| 2150 | struct lump *anchor, *via_insert_param; |
| 2151 | str branch, extra_params, body = STR_NULL; |
| 2152 | struct hostport hp; |
| 2153 | |
| 2154 | id_buf=0; |
| 2155 | id_len=0; |
| 2156 | via_insert_param=0; |
| 2157 | extra_params.len=0; |
| 2158 | extra_params.s=0; |
| 2159 | uri_len=0; |
| 2160 | buf=msg->buf; |
| 2161 | len=msg->len; |
| 2162 | received_len=0; |
| 2163 | rport_len=0; |
| 2164 | new_buf=0; |
| 2165 | received_buf=0; |
| 2166 | rport_buf=0; |
| 2167 | line_buf=0; |
| 2168 | int via1_deleted = 0; |
| 2169 | |
| 2170 | if (msg->path_vec.len) { |
| 2171 | if (insert_path_as_route(msg, &msg->path_vec) < 0) { |
| 2172 | LM_ERR("adding path lumps failed\n"); |
| 2173 | goto error; |
| 2174 | } |
| 2175 | } |
| 2176 | |
| 2177 | /* Calculate message body difference and adjust |
| 2178 | * Content-Length |
| 2179 | */ |
| 2180 | body_delta = calculate_body_diff( msg, send_sock); |
| 2181 | if (adjust_clen(msg, body_delta, proto) < 0) { |
| 2182 | LM_ERR("failed to adjust Content-Length\n"); |
| 2183 | goto error; |
| 2184 | } |
| 2185 | |
| 2186 | if (flags&MSG_TRANS_NOVIA_FLAG) |
| 2187 | goto build_msg; |
| 2188 | |
| 2189 | /* add id if tcp-based protocol */ |
| 2190 | if (is_tcp_based_proto(msg->rcv.proto)) { |
| 2191 | if ((id_buf=id_builder(msg, &id_len))==0){ |
| 2192 | LM_ERR("id_builder failed\n"); |
| 2193 | goto error; /* we don't need to free anything, |
| 2194 | nothing alloc'ed yet*/ |
| 2195 | } |
| 2196 | LM_DBG("id added: <%.*s>, rcv proto=%d\n", |
| 2197 | (int)id_len, id_buf, msg->rcv.proto); |
| 2198 | /* if there was already something there, simply copy them */ |
| 2199 | if (via_params && via_params->len != 0) { |
no test coverage detected