| 675 | |
| 676 | |
| 677 | static void replace_callback(struct dlg_cell *dlg, int type, |
| 678 | struct dlg_cb_params *_params) |
| 679 | { |
| 680 | struct lump* l; |
| 681 | struct sip_msg *msg; |
| 682 | struct hdr_field *old_hdr; |
| 683 | str *rr_param; |
| 684 | str old_uri; |
| 685 | int_str new_uri; |
| 686 | int to, flag; |
| 687 | char *p; |
| 688 | int val_type; |
| 689 | |
| 690 | if (!dlg || !_params || _params->direction == DLG_DIR_NONE || !_params->msg) |
| 691 | return; |
| 692 | |
| 693 | msg = _params->msg; |
| 694 | |
| 695 | to = *(_params->param) ? 1 : 0; |
| 696 | |
| 697 | /* check the request direction */ |
| 698 | if ((to && _params->direction == DLG_DIR_DOWNSTREAM) || |
| 699 | (!to && _params->direction == DLG_DIR_UPSTREAM)) { |
| 700 | /* replace the TO URI */ |
| 701 | if ( msg->to==0 && (parse_headers(msg,HDR_TO_F,0)!=0 || msg->to==0) ) { |
| 702 | LM_ERR("failed to parse TO hdr\n"); |
| 703 | return; |
| 704 | } |
| 705 | old_uri = ((struct to_body*)msg->to->parsed)->uri; |
| 706 | old_hdr = msg->to; |
| 707 | flag = FL_USE_UAC_TO; |
| 708 | } else { |
| 709 | /* replace the FROM URI */ |
| 710 | if ( parse_from_header(msg)<0 ) { |
| 711 | LM_ERR("failed to find/parse FROM hdr\n"); |
| 712 | return; |
| 713 | } |
| 714 | old_uri = ((struct to_body*)msg->from->parsed)->uri; |
| 715 | old_hdr = msg->from; |
| 716 | flag = FL_USE_UAC_FROM; |
| 717 | } |
| 718 | |
| 719 | if (msg->msg_flags & flag) |
| 720 | return; |
| 721 | |
| 722 | if (_params->direction == DLG_DIR_DOWNSTREAM) { |
| 723 | /* not upstream */ |
| 724 | rr_param = to ? &rr_to_param_new : &rr_from_param_new; |
| 725 | LM_DBG("DOWNSTREAM direction detected - replacing %s header" |
| 726 | " with the uac_replace_%s() parameters\n", |
| 727 | to ? "TO" : "FROM", to ? "to": "from"); |
| 728 | } else { |
| 729 | rr_param = to ? &rr_to_param : &rr_from_param; |
| 730 | LM_DBG("UPSTREAM direction detected - replacing %s header" |
| 731 | " with the original headers\n", to ? "TO" : "FROM"); |
| 732 | } |
| 733 | |
| 734 | if (dlg_api.fetch_dlg_value(dlg, rr_param, &val_type, &new_uri, 0) < 0) { |
nothing calls this directly
no test coverage detected