### Description
I forward a sip message multiple times. I expect the sip messages that are forwarded after
previous ones, to look the same. In stead, multiple via-headers are added for the host. If
I modify the sip message after forwarding it, I expect the modifications to be correctly
processed for subsequent forwards, in stead the modifications are mixed with elements from
the previously forwarded sip message. For example setting $td to value x, forwarding,
setting $td to value y, and forwarding again, results in a sip message with a to-domain of
xy, in stead of just y.
#### Reproduction
To reproduce, add this to your main route and enable dispatching. For the example sip
messages below, I ran this code on CANCEL messages.
```
ds_select_domain("2", "6");
$td = $nh(d);
forward();
ds_next_domain();
$td = $nh(d);
forward();
```
Run wireshark to see the resulting sip-messages on the wire.
#### SIP Traffic
As an example of a 'double' forward along with modification of $td to send the
initial sip message to both [a::3] and [b::4] (anonymized hosts):
Part of the initial sip message (anonymized)
CANCEL sip:x@x SIP/2.0
Via: SIP/2.0/UDP [x::1]:5060;rport;branch=z9hG4bK152CABB1BC44E9A0
From: <sip:y@x>;tag=00623356EBD9772B
To: <sip:x@x>
Part of the first forwarded sip message (anonymized)
CANCEL sip:x@a:5060 SIP/2.0
Record-Route: <sip:[x];lr=on>
Via: SIP/2.0/UDP [x:4A];branch=z9hG4bK9a21.932b3551ed4f18f509d1bfaeecb65ea5.0
Via: SIP/2.0/UDP [x::1]:5060;received=x:1;rport=5060;branch=z9hG4bK152CABB1BC44E9A0
From: <sip:y@x>;tag=00623356EBD9772B
To: <sip:x@[a::3]>
Part of the second forwarded sip message (anonymized)
CANCEL sip:x@b:5060 SIP/2.0
Record-Route: <sip:[x];lr=on>
Via: SIP/2.0/UDP [x:4A];branch=z9hG4bK9a21.932b3551ed4f18f509d1bfaeecb65ea5.0
Via: SIP/2.0/UDP [x:4A];branch=z9hG4bK9a21.932b3551ed4f18f509d1bfaeecb65ea5.0
Via: SIP/2.0/UDP
[x::1]:5060;received=x:1;rport=5060;received=x:1;rport=5060;branch=z9hG4bK152CABB1BC44E9A0
From: <sip:y@x>;tag=00623356EBD9772B
To: <sip:x@[a::3][b::4]>
### Additional Information
* **Kamailio Version** - output of `kamailio -v`
```
version: kamailio 4.4.4 (x86_64/linux) 852c47
flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, DISABLE_NAGLE, USE_MCAST,
DNS_IP_HACK, SHM_MEM, SHM_MMAP, PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC,
DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER,
USE_NAPTR, USE_DST_BLACKLIST, HAVE_RESOLV_RES
ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16, MAX_URI_SIZE 1024,
BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: 852c47
compiled on 14:05:47 Mar 7 2017 with gcc 4.9.2
```
* **Operating System**:
Debian 8.7
```
Linux x.x 3.16.0-4-amd64 #1 SMP Debian 3.16.39-1+deb8u2 (2017-03-07) x86_64 GNU/Linux
```
--
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/1108