Module: sems
Branch: master
Commit: c1456e6cfcd26c513d67943bae82a0020de58943
URL:    
http://git.sip-router.org/cgi-bin/gitweb.cgi/sems/?a=commit;h=c1456e6cfcd26c513d67943bae82a0020de58943

Author: Raphael Coeffic <[email protected]>
Committer: Raphael Coeffic <[email protected]>
Date:   Fri May 20 09:06:23 2011 +0200

b/f: fixes the ACK/200 matching for transaction looped back to SEMS.

Filtering by transaction type in trans_table::match_request() is necessary to 
avoid matching the ACK/200 UAC transaction when receiving a self-crafted 
ACK/200 and looking for the UAS transaction.

---

 core/sip/trans_layer.cpp |    4 ++--
 core/sip/trans_table.cpp |   14 ++++++++------
 core/sip/trans_table.h   |    6 +++---
 3 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/core/sip/trans_layer.cpp b/core/sip/trans_layer.cpp
index 9e46ddd..fbe5229 100644
--- a/core/sip/trans_layer.cpp
+++ b/core/sip/trans_layer.cpp
@@ -1105,7 +1105,7 @@ void _trans_layer::received_msg(sip_msg* msg)
     switch(msg->type){
     case SIP_REQUEST: 
        
-       if((t = bucket->match_request(msg)) != NULL){
+       if((t = bucket->match_request(msg,TT_UAS)) != NULL){
            if(msg->u.request->method != t->msg->u.request->method){
                
                // ACK matched INVITE transaction
@@ -1417,7 +1417,7 @@ int _trans_layer::update_uac_request(trans_bucket* 
bucket, sip_trans*& t, sip_ms
     }
     else {
        // 200 ACK
-       t = bucket->match_request(msg);
+       t = bucket->match_request(msg,TT_UAC);
        if(t == NULL){
            DBG("While sending 200 ACK: no matching transaction\n");
            return -1;
diff --git a/core/sip/trans_table.cpp b/core/sip/trans_table.cpp
index 4ac6be4..f1442fd 100644
--- a/core/sip/trans_table.cpp
+++ b/core/sip/trans_table.cpp
@@ -57,7 +57,7 @@ trans_bucket::~trans_bucket()
 {
 }
 
-sip_trans* trans_bucket::match_request(sip_msg* msg)
+sip_trans* trans_bucket::match_request(sip_msg* msg, unsigned int ttype)
 {
     // assert(msg && msg->cseq && msg->callid);
     // sip_cseq* cseq  = dynamic_cast<sip_cseq*>(msg->cseq->p);
@@ -93,7 +93,8 @@ sip_trans* trans_bucket::match_request(sip_msg* msg)
        trans_list::iterator it = elmts.begin();
        for(;it!=elmts.end();++it) {
            
-           if( (*it)->msg->type != SIP_REQUEST ){
+           if( ((*it)->msg->type != SIP_REQUEST) ||
+               ((*it)->type != ttype)){
                continue;
            }
 
@@ -168,10 +169,11 @@ sip_trans* trans_bucket::match_request(sip_msg* msg)
            // Cseq (number only)
            // top Via
            // + To-tag of reply
-           
-           if( ((*it)->type != TT_UAS) || 
-               ((*it)->msg->type != SIP_REQUEST))
+
+           if( ((*it)->msg->type != SIP_REQUEST) ||
+               ((*it)->type != ttype)){
                continue;
+           }
 
            if( (msg->u.request->method != (*it)->msg->u.request->method) &&
                ( (msg->u.request->method != sip_request::ACK) ||
@@ -394,7 +396,7 @@ sip_trans* trans_bucket::match_1xx_prack(sip_msg* msg)
     return NULL;
 }
 
-sip_trans* trans_bucket::add_trans(sip_msg* msg, int ttype)
+sip_trans* trans_bucket::add_trans(sip_msg* msg, unsigned int ttype)
 {
     sip_trans* t = new sip_trans();
 
diff --git a/core/sip/trans_table.h b/core/sip/trans_table.h
index c7f5fe6..52e1e3d 100644
--- a/core/sip/trans_table.h
+++ b/core/sip/trans_table.h
@@ -21,9 +21,9 @@ public:
     typedef ht_bucket<sip_trans>::value_list trans_list;
 
     
-    // Match a request to UAS transactions
+    // Match a request to UAS/UAC transactions
     // in this bucket
-    sip_trans* match_request(sip_msg* msg);
+    sip_trans* match_request(sip_msg* msg, unsigned int ttype);
 
     // Match a PRACK request against transactions
     // in this bucket
@@ -33,7 +33,7 @@ public:
     // in this bucket
     sip_trans* match_reply(sip_msg* msg);
 
-    sip_trans* add_trans(sip_msg* msg, int ttype);
+    sip_trans* add_trans(sip_msg* msg, unsigned int ttype);
 
 private:
     sip_trans* match_200_ack(sip_trans* t,sip_msg* msg);

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to