Skip to content

Commit

Permalink
topoh: discover local request direction from th cookie
Browse files Browse the repository at this point in the history
- l can be used to mark local requests for topoh handling
  • Loading branch information
miconda committed Jan 4, 2015
1 parent 0739e26 commit 0219d5a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
9 changes: 9 additions & 0 deletions modules/topoh/th_msg.c
Expand Up @@ -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;
Expand Down
15 changes: 13 additions & 2 deletions modules/topoh/topoh_mod.c
Expand Up @@ -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;
Expand Down

0 comments on commit 0219d5a

Please sign in to comment.