* Send a request using data from the dialog structure */
| 411 | * Send a request using data from the dialog structure |
| 412 | */ |
| 413 | int t_uac(str* method, str* headers, str* body, dlg_t* dialog, |
| 414 | transaction_cb cb, void* cbp,release_tmcb_param release_func) |
| 415 | { |
| 416 | union sockaddr_union to_su; |
| 417 | struct cell *new_cell; |
| 418 | struct retr_buf *request; |
| 419 | struct sip_msg *req = NULL; |
| 420 | char *buf_req = NULL; |
| 421 | struct usr_avp **backup; |
| 422 | char *buf; |
| 423 | int buf_len; |
| 424 | int ret, flags; |
| 425 | unsigned int hi, method_id; |
| 426 | struct proxy_l *proxy; |
| 427 | struct tm_callback *it; |
| 428 | struct ua_client* uac; |
| 429 | |
| 430 | ret=-1; |
| 431 | |
| 432 | /*** added by dcm |
| 433 | * - needed by external ua to send a request within a dlg |
| 434 | */ |
| 435 | if(!dialog->hooks.next_hop && w_calculate_hooks(dialog)<0) |
| 436 | goto error_out; |
| 437 | |
| 438 | if(dialog->obp.s) |
| 439 | dialog->hooks.next_hop = &dialog->obp; |
| 440 | |
| 441 | LM_DBG("next_hop=<%.*s>\n",dialog->hooks.next_hop->len, |
| 442 | dialog->hooks.next_hop->s); |
| 443 | |
| 444 | /* calculate the socket corresponding to next hop ; here we take |
| 445 | * into consideration the protocol forced by the "send_sock" */ |
| 446 | proxy = uri2proxy( dialog->hooks.next_hop, |
| 447 | dialog->send_sock ? dialog->send_sock->proto : PROTO_NONE ); |
| 448 | if (proxy==0) { |
| 449 | ret=E_BAD_ADDRESS; |
| 450 | goto error_out; |
| 451 | } |
| 452 | /* use the first address */ |
| 453 | hostent2su( &to_su, |
| 454 | &proxy->host, proxy->addr_idx, proxy->port ? proxy->port:SIP_PORT); |
| 455 | |
| 456 | /* check/discover the send socket */ |
| 457 | if (dialog->send_sock) { |
| 458 | /* if already set, the protocol of send sock must have the |
| 459 | the same type as the proto required by destination URI */ |
| 460 | if (proxy->proto != dialog->send_sock->proto) |
| 461 | dialog->send_sock = NULL; |
| 462 | } |
| 463 | if (dialog->send_sock==NULL) { |
| 464 | if (dialog->pref_sock && proxy->proto == dialog->pref_sock->proto) { |
| 465 | dialog->send_sock = dialog->pref_sock; |
| 466 | } else { |
| 467 | /* get the send socket */ |
| 468 | dialog->send_sock = get_send_socket(NULL/*msg*/, &to_su, |
| 469 | proxy->proto); |
| 470 | if (!dialog->send_sock) { |
no test coverage detected