core: skip to-tag when computing via branch for invite, ack and cancel
authorDaniel-Constantin Mierla <miconda@gmail.com>
Mon, 29 Jul 2019 11:51:57 +0000 (13:51 +0200)
committerDaniel-Constantin Mierla <miconda@gmail.com>
Mon, 29 Jul 2019 11:51:57 +0000 (13:51 +0200)
- proper functionality for stateless proxy in case of negative ACK (in
this case the INVITE has no To-tag, but ACK has it and resulted in
different via branch, making downstream proxy to not match transaction)

src/core/char_msg_val.h

index 79461cd..436f58b 100644 (file)
@@ -38,6 +38,7 @@
 inline static int char_msg_val( struct sip_msg *msg, char *cv )
 {
        str src[8];
+       str sempty = str_init("");
 
        if (unlikely(!check_transaction_quadruple(msg))) {
                LM_ERR("can't calculate char_value due to a parsing error\n");
@@ -55,7 +56,12 @@ inline static int char_msg_val( struct sip_msg *msg, char *cv )
        }
        /* use only the from & to tags */
        src[0]=get_from(msg)->tag_value;
-       src[1]=get_to(msg)->tag_value;
+       if(msg->first_line.u.request.method_value
+                       & (METHOD_INVITE|METHOD_ACK|METHOD_CANCEL)) {
+               src[1]=sempty;
+       } else {
+               src[1]=get_to(msg)->tag_value;
+       }
        src[2]= msg->callid->body;
        src[3]= msg->first_line.u.request.uri;
        src[4]= get_cseq( msg )->number;