Module: kamailio
Branch: master
Commit: 37830f53b1f21fba5beef5d8e22913c431dcd708
URL: 
https://github.com/kamailio/kamailio/commit/37830f53b1f21fba5beef5d8e22913c431dcd708

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2017-08-07T13:52:45+02:00

topos: use branch attributes to handle PRACK

---

Modified: src/modules/topos/tps_msg.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/37830f53b1f21fba5beef5d8e22913c431dcd708.diff
Patch: 
https://github.com/kamailio/kamailio/commit/37830f53b1f21fba5beef5d8e22913c431dcd708.patch

---

diff --git a/src/modules/topos/tps_msg.c b/src/modules/topos/tps_msg.c
index 37b075ae94..23cfb07412 100644
--- a/src/modules/topos/tps_msg.c
+++ b/src/modules/topos/tps_msg.c
@@ -735,6 +735,7 @@ int tps_request_received(sip_msg_t *msg, int dialog)
        str nuri;
        uint32_t direction = TPS_DIR_DOWNSTREAM;
        int ret;
+       int use_branch = 0;
 
        LM_DBG("handling incoming request\n");
 
@@ -761,8 +762,15 @@ int tps_request_received(sip_msg_t *msg, int dialog)
 
        tps_storage_lock_get(&lkey);
 
-       if(tps_storage_load_dialog(msg, &mtsd, &stsd)<0) {
-               goto error;
+       if((get_cseq(msg)->method_id)&(METHOD_PRACK)) {
+               if(tps_storage_load_branch(msg, &mtsd, &stsd)<0) {
+                       goto error;
+               }
+               use_branch = 1;
+       } else {
+               if(tps_storage_load_dialog(msg, &mtsd, &stsd)<0) {
+                       goto error;
+               }
        }
 
        /* detect direction - via from-tag */
@@ -791,14 +799,28 @@ int tps_request_received(sip_msg_t *msg, int dialog)
                return -1;
        }
        if(direction == TPS_DIR_UPSTREAM) {
-               if(tps_reappend_route(msg, &stsd, &stsd.a_rr, 0)<0) {
-                       LM_ERR("failed to reappend a-route\n");
-                       return -1;
+               if(use_branch) {
+                       if(tps_reappend_route(msg, &stsd, &stsd.x_rr, 0)<0) {
+                               LM_ERR("failed to reappend x-route\n");
+                               return -1;
+                       }
+               } else {
+                       if(tps_reappend_route(msg, &stsd, &stsd.a_rr, 0)<0) {
+                               LM_ERR("failed to reappend a-route\n");
+                               return -1;
+                       }
                }
        } else {
-               if(tps_reappend_route(msg, &stsd, &stsd.b_rr, 1)<0) {
-                       LM_ERR("failed to reappend b-route\n");
-                       return -1;
+               if(use_branch) {
+                       if(tps_reappend_route(msg, &stsd, &stsd.y_rr, 1)<0) {
+                               LM_ERR("failed to reappend b-route\n");
+                               return -1;
+                       }
+               } else {
+                       if(tps_reappend_route(msg, &stsd, &stsd.b_rr, 1)<0) {
+                               LM_ERR("failed to reappend b-route\n");
+                               return -1;
+                       }
                }
        }
        if(dialog!=0) {


_______________________________________________
Kamailio (SER) - Development Mailing List
sr-dev@lists.kamailio.org
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to