### Description
I put a dispatcher between PCSCF and UE. When I tried to register, Pcscf's save
function saved dispatcher's via IP and via port instead of UE's via IP and via
port.
When I checked save function of ims_registrar_pcscf module , I saw that cscf_get_ue_via
function is used for that. And It gives wrong via value. Instead of giving last via , it
gives the first via in the via list.
Here is the function:
https://github.com/kamailio/kamailio/blob/master/src/lib/ims/ims_getters.c
```
/**
* Looks for the UE Via in First Via header if its a request
* or in the last if its a response and returns its body
* @param msg - the SIP message
* @returns the via of the UE
*/
struct via_body* cscf_get_ue_via(struct sip_msg *msg)
{
struct via_body *vb=0;
if (msg->first_line.type==SIP_REQUEST) vb = cscf_get_first_via(msg,0);
else vb = cscf_get_last_via(msg);
if (!vb) return 0;
if (vb->port == 0) vb->port=5060;
return vb;
}
```
### Troubleshooting
I corrected the code as below:
```
/**
* Looks for the UE Via in Last Via header and returns its body
* @param msg - the SIP message
* @returns the via of the UE
*/
struct via_body* cscf_get_ue_via(struct sip_msg *msg)
{
struct via_body *vb=0;
vb = cscf_get_last_via(msg);
if (!vb) return 0;
if (vb->port == 0) vb->port=5060;
return vb;
}
```
#### Reproduction
Try to put a dispatcher between PCSCF and UE. save function of ims_registrar_pcscf module
saves dispatcher's IP and port as UE's IP and port.
#### Debugging Data
```
(paste your debugging data here)
```
#### Log Messages
```
(paste your log messages here)
```
#### SIP Traffic
<!--
If the issue is exposed by processing specific SIP messages, grab them with ngrep or save
in a pcap file, then add them next, or attach to issue, or provide a link to download them
(e.g., to a pastebin site).
-->
```
(paste your sip traffic here)
```
### Possible Solutions
<!--
If you found a solution or workaround for the issue, describe it. Ideally, provide a pull
request with a fix.
-->
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
```
(paste your output here)
```
* **Operating System**:
<!--
Details about the operating system, the type: Linux (e.g.,: Debian 8.4, Ubuntu 16.04,
CentOS 7.1, ...), MacOS, xBSD, Solaris, ...;
Kernel details (output of `lsb_release -a` and `uname -a`)
-->
```
(paste your output here)
```
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/2864