### Description
I used sip_p_charging_vector() function of siputils with flag f (remove + generate). This function works fine if call is received without a P-Charging-Vector and only generate needs to be done. But if the INVITE already contains a P-Charging-Vector and this vector needs to be removed and replaced by a new generated P-Charging-Vector the output is messed up. The sip_p_charging_vector() function with flag r (remove) works fine too. P-Charging-Vector is removed if INVITE contains one. So for me this looks like an issue with the combination of remove + generate.
See SIP Traffic attached. The "old" P-Charging-Vector is not deleted and additionaly instead of a new P-Charging-Vector the "old" P-Charging-Vector is added again above SDP. Also some part of the next line "Session-Exp" is added and "TH: dih".
----- TH: dih icid-value=0d702d06-5700-103e-00-00-00-10-6b-03-dd-04;icid-generated-at=213.xxx.xxx.xxx Session-Exp -----
### Troubleshooting
#### Reproduction
It looks like the issue is triggered always a p-charging-vector is received by kamailio and sip_p_charging_vector() with flag f is called.
#### Log Messages
<!-- Check the syslog file and if there are relevant log messages printed by Kamailio, add them next, or attach to issue, or provide a link to download them (e.g., to a pastebin site). -->
``` (paste your log messages here) ```
#### SIP Traffic
``` **This message is received by kamailio (Incoming):** INVITE sip:+49xxxxxxxx;npdi;rn=+49xxxxxxxx@bob.com:5060;user=phone SIP/2.0 Via: SIP/2.0/UDP 213.xxx.xxx.xxx:5060;branch=z9hG4bK08Bf3722bac16f3e05b From: sip:+43xxxxxxxx@alice.com;user=phone;tag=gK085abca7 To: sip:+49xxxxxxxx0@92.xxx.xxx.xxx:5060;user=phone Call-ID: 168341746_132086108@213.xxx.xxx.xxx CSeq: 373279 INVITE Max-Forwards: 67 Allow: INVITE,ACK,CANCEL,BYE,REGISTER,REFER,INFO,SUBSCRIBE,NOTIFY,PRACK,UPDATE,OPTIONS,MESSAGE,PUBLISH Accept: application/sdp, application/isup, application/dtmf, application/dtmf-relay, multipart/mixed Contact: sip:+43xxxxxxxx@213.xxx.xxx.xxx:5060 P-Asserted-Identity: sip:+43xxxxxxxx@alice.com:5060;user=phone Supported: timer,100rel,histinfo P-Charging-Vector: icid-value=0d702d06-5700-103e-00-00-00-10-6b-03-dd-04;icid-generated-at=213.xxx.xxx.xxx Session-Expires: 1800 Min-SE: 90 Content-Length: 236 Content-Disposition: session; handling=required Content-Type: application/sdp
v=0 o=Sonus_UAC 278609 22801 IN IP4 213.xxx.xxx.xxx s=SIP Media Capabilities c=IN IP4 213.xxx.xxx.xxx t=0 0 m=audio 29020 RTP/AVP 8 101 a=rtpmap:8 PCMA/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-15 a=sendrecv a=ptime:20
**This message is send out by kamailio (outgoing):** INVITE sip:+49xxxxxxxx;npdi;rn=+49xxxxxxxx@bob.com:5060;user=phone SIP/2.0 Record-Route: sip:172.xxx.xxx.xxx;r2=on;lr=on;ftag=gK085abca7 Record-Route: sip:92.xxx.xxx.xxx9;r2=on;lr=on;ftag=gK085abca7 Via: SIP/2.0/UDP 172.xxx.xxx.xxx;branch=z9hG4bKc451.940fa2c220f96c1ef968de3c156db262.0 Via: SIP/2.0/UDP 213.xxx.xxx.xxx:5060;TH=div;branch=z9hG4bK08Bf3722bac16f3e05b From: sip:+43xxxxxxxx@alice.com;user=phone;tag=gK085abca7 To: sip:+49xxxxxxxx@92.xxx.xxx.xxx:5060;user=phone Call-ID: 168341746_132086108@213.xxx.xxx.xxx CSeq: 373279 INVITE Max-Forwards: 66 Allow: INVITE,ACK,CANCEL,BYE,REGISTER,REFER,INFO,SUBSCRIBE,NOTIFY,PRACK,UPDATE,OPTIONS,MESSAGE,PUBLISH Accept: application/sdp, application/isup, application/dtmf, application/dtmf-relay, multipart/mixed Contact: sip:+43xxxxxxxx@213.xxx.xxx.xxx:5060 P-Asserted-Identity: sip:+43xxxxxxxx@alice.com:5060;user=phone Supported: timer,100rel,histinfo P-Charging-Vector: icid-value=0d702d06-5700-103e-00-00-00-10-6b-03-dd-04;icid-generated-at=213.xxx.xxx.xxx Session-Expires: 1800 Min-SE: 90 Content-Length: 252 Content-Disposition: session; handling=required Content-Type: application/sdp **_TH: dih icid-value=0d702d06-5700-103e-00-00-00-10-6b-03-dd-04;icid-generated-at=213.xxx.xxx.xxx Session-Exp_** v=0 o=Sonus_UAC 278609 22801 IN IP4 92.xxx.xxx.xxx s=SIP Media Capabilities c=IN IP4 92.xxx.xxx.xxx t=0 0 m=audio 34622 RTP/AVP 8 101 a=rtpmap:8 PCMA/8000 a=rtpmap:101 telephone-event/8000 a=fmtp:101 0-15 a=sendrecv a=rtcp:34623 a=ptime:20 ```
### Additional Information
``` version: kamailio 5.8.2 (x86_64/linux) 3fa5f4 flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, MEM_JOIN_FREE, 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_BLOCKLIST, HAVE_RESOLV_RES, TLS_PTHREAD_MUTEX_SHARED ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_SEND_BUFFER_SIZE 262144, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB poll method support: poll, epoll_lt, epoll_et, sigio_rt, select. id: 3fa5f4 compiled on 15:54:29 Jul 22 2024 with gcc 10.2.1 ```
* **Operating System**:
``` Debian GNU/Linux 11 5.10.0-26-amd64 #1 SMP Debian 5.10.197-1 (2023-09-29) x86_64 GNU/Linux ```