| 163 | |
| 164 | |
| 165 | static int run_local_route( struct cell *new_cell, char **buf, int *buf_len, |
| 166 | dlg_t *dialog, struct sip_msg **ret_req, char **ret_req_buf) |
| 167 | { |
| 168 | struct sip_msg *req = NULL; |
| 169 | struct cell *backup_cell; |
| 170 | int backup_route_type; |
| 171 | struct retr_buf *request; |
| 172 | struct proxy_l *new_proxy = NULL; |
| 173 | union sockaddr_union new_to_su; |
| 174 | const struct socket_info *new_send_sock; |
| 175 | unsigned short dst_changed; |
| 176 | char *buf1=NULL, *sipmsg_buf; |
| 177 | int buf_len1, sip_msg_len; |
| 178 | str h_to, h_from, h_cseq, h_callid; |
| 179 | struct ua_client* uac; |
| 180 | |
| 181 | /* do not build buffer if callbacks are not needed and |
| 182 | * there are no local routes */ |
| 183 | if (!has_tran_tmcbs(new_cell, TMCB_LOCAL_REQUEST_OUT) && |
| 184 | !sroutes->local.a) |
| 185 | return 0; |
| 186 | |
| 187 | LM_DBG("building sip_msg from buffer\n"); |
| 188 | sipmsg_buf = *buf; /* remember the buffer used to get the sip_msg */ |
| 189 | req = buf_to_sip_msg( *buf, *buf_len, dialog); |
| 190 | if (req==NULL) { |
| 191 | LM_ERR("failed to build sip_msg from buffer\n"); |
| 192 | return -1; |
| 193 | } |
| 194 | |
| 195 | /* set this transaction as active one */ |
| 196 | backup_cell = get_t(); |
| 197 | set_t( new_cell ); |
| 198 | /* disable parallel forking */ |
| 199 | set_dset_state( 0 /*disable*/); |
| 200 | |
| 201 | /* run the route */ |
| 202 | swap_route_type( backup_route_type, LOCAL_ROUTE); |
| 203 | if (sroutes && sroutes->local.a) |
| 204 | run_top_route( sroutes->local, req); |
| 205 | if (has_tran_tmcbs(new_cell, TMCB_LOCAL_REQUEST_OUT) ) { |
| 206 | run_trans_callbacks(TMCB_LOCAL_REQUEST_OUT, new_cell, |
| 207 | req, 0, 0); |
| 208 | } |
| 209 | set_route_type( backup_route_type ); |
| 210 | |
| 211 | uac = & TM_BRANCH( new_cell, 0); |
| 212 | |
| 213 | /* transfer current message context back to t */ |
| 214 | uac->br_flags = getb0flags(req); |
| 215 | /* restore the prevoius active transaction */ |
| 216 | set_t( backup_cell ); |
| 217 | |
| 218 | set_dset_state( 1 /*enable*/); |
| 219 | |
| 220 | /* check for changes - if none, do not regenerate the buffer */ |
| 221 | dst_changed = 1; |
| 222 | if (req->new_uri.s || req->force_send_socket!=dialog->send_sock || |
no test coverage detected