From 37830f53b1f21fba5beef5d8e22913c431dcd708 Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Mon, 7 Aug 2017 13:52:45 +0200 Subject: [PATCH] topos: use branch attributes to handle PRACK --- src/modules/topos/tps_msg.c | 38 +++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/src/modules/topos/tps_msg.c b/src/modules/topos/tps_msg.c index 37b075ae943..23cfb074127 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) {