Module: kamailio Branch: master Commit: 0219d5a9090366292671eedc5e25f6c8434989c8 URL: https://github.com/kamailio/kamailio/commit/0219d5a9090366292671eedc5e25f6c8...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2015-01-04T23:54:23+01:00
topoh: discover local request direction from th cookie
- l can be used to mark local requests for topoh handling
---
Modified: modules/topoh/th_msg.c Modified: modules/topoh/topoh_mod.c
---
Diff: https://github.com/kamailio/kamailio/commit/0219d5a9090366292671eedc5e25f6c8... Patch: https://github.com/kamailio/kamailio/commit/0219d5a9090366292671eedc5e25f6c8...
---
diff --git a/modules/topoh/th_msg.c b/modules/topoh/th_msg.c index 3a68f3f..098510e 100644 --- a/modules/topoh/th_msg.c +++ b/modules/topoh/th_msg.c @@ -1002,6 +1002,15 @@ int th_del_cookie(sip_msg_t *msg) }
+/** + * return the special topoh cookie + * - TH header of TH Via parame + * - value is 3 chars + * [0] - direction: d - downstream; u - upstream + * [1] - request type: i - initial; c - in-dialog; l - local in-dialog + * [2] - location: h - header; v - via param + * - if not found, returns 'xxx' + */ char* th_get_cookie(sip_msg_t *msg, int *clen) { hdr_field_t *hf; diff --git a/modules/topoh/topoh_mod.c b/modules/topoh/topoh_mod.c index ff64b6c..a8d9b63 100644 --- a/modules/topoh/topoh_mod.c +++ b/modules/topoh/topoh_mod.c @@ -401,13 +401,24 @@ int th_msg_sent(void *data) { direction = (th_cookie_value.s[0]=='u')?1:0; /* upstream/downstram */ dialog = (get_to(&msg)->tag_value.len>0)?1:0; - local = (th_cookie_value.s[0]!='d'&&th_cookie_value.s[0]!='u')?1:0; + + if(msg.via2==0) { + local = 1; + if(direction==0 && th_cookie_value.s[1]=='l') { + /* downstream local request (e.g., dlg bye) */ + local = 2; + } + } else { + /* more than one Via, but no received th cookie */ + local = (th_cookie_value.s[0]!='d' && th_cookie_value.s[0]!='u')?1:0; + } /* local generated requests */ if(local) { /* ACK and CANCEL go downstream */ if(get_cseq(&msg)->method_id==METHOD_ACK - || get_cseq(&msg)->method_id==METHOD_CANCEL) + || get_cseq(&msg)->method_id==METHOD_CANCEL + || local==2) { th_mask_callid(&msg); goto ready;