Skip to content

Commit

Permalink
topos: proper detection of direction for requests within dialog
Browse files Browse the repository at this point in the history
- related to GH #1005
  • Loading branch information
miconda committed Mar 1, 2017
1 parent 3c773fd commit a43d846
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/modules/topos/tps_msg.c
Expand Up @@ -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;

Expand Down Expand Up @@ -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 */
Expand Down

0 comments on commit a43d846

Please sign in to comment.