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

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2017-03-01T23:41:12+01:00

topos: proper detection of direction for requests within dialog

- related to GH #1005

---

Modified: src/modules/topos/tps_msg.c

---

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

---

diff --git a/src/modules/topos/tps_msg.c b/src/modules/topos/tps_msg.c
index 8c976b3..aa470e2 100644
--- a/src/modules/topos/tps_msg.c
+++ b/src/modules/topos/tps_msg.c
@@ -867,6 +867,7 @@ int tps_request_sent(sip_msg_t *msg, int dialog, int local)
        tps_data_t stsd;
        tps_data_t *ptsd;
        str lkey;
+       str ftag;
        str xuuid;
        int direction = TPS_DIR_DOWNSTREAM;
 
@@ -907,6 +908,23 @@ int tps_request_sent(sip_msg_t *msg, int dialog, int local)
                if(tps_storage_load_dialog(msg, &mtsd, &stsd)==0) {
                        ptsd = &stsd;
                }
+               /* detect direction - get from-tag */
+               if(parse_from_header(msg)<0 || msg->from==NULL) {
+                       LM_ERR("failed getting 'from' header!\n");
+                       goto error;
+               }
+               ftag = get_from(msg)->tag_value;
+
+               if(stsd.a_tag.len!=ftag.len) {
+                       direction = TPS_DIR_UPSTREAM;
+               } else {
+                       if(memcmp(stsd.a_tag.s, ftag.s, ftag.len)==0) {
+                               direction = TPS_DIR_DOWNSTREAM;
+                       } else {
+                               direction = TPS_DIR_UPSTREAM;
+                       }
+               }
+               mtsd.direction = direction;
        }
 
        /* local generated requests */


_______________________________________________
sr-dev mailing list
sr-dev@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to