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

Author: Raphael Coeffic <[email protected]>
Committer: Raphael Coeffic <[email protected]>
Date:   Wed Feb  1 12:45:13 2012 +0100

sip: moved rseq storage to trans_layer::send_reply

---

 core/SipCtrlInterface.cpp |   45 ---------------------------------------------
 core/sip/trans_layer.cpp  |   42 +++++++++++++++++++++++++++++++++++++++---
 core/sip/trans_layer.h    |    2 --
 3 files changed, 39 insertions(+), 50 deletions(-)

diff --git a/core/SipCtrlInterface.cpp b/core/SipCtrlInterface.cpp
index 184d8b0..8f0b0a3 100644
--- a/core/SipCtrlInterface.cpp
+++ b/core/SipCtrlInterface.cpp
@@ -37,7 +37,6 @@
 #include "sip/parse_header.h"
 #include "sip/parse_from_to.h"
 #include "sip/parse_cseq.h"
-#include "sip/parse_extensions.h"
 #include "sip/parse_100rel.h"
 #include "sip/parse_route.h"
 #include "sip/trans_table.h"
@@ -341,50 +340,6 @@ int SipCtrlInterface::send(const AmSipReply &rep,
        }
     }
 
-
-    /* check if we need to store RSeq. */
-    // FIXME: shouldn't the global "100rel==on?" check be present here??
-    if(100 < rep.code && rep.code < 200 && rep.cseq_method == SIP_METH_INVITE) 
{
-        unsigned ext = 0;
-        unsigned rseq = 0;
-        for(list<sip_header*>::iterator it = msg.hdrs.begin();
-                !(ext && rseq) && it != msg.hdrs.end(); ++it) {
-            // check if there's a Require field containing 100rel; if there
-            // is, look for RSeq and store it's value in transaction;
-            DBG("HT:%d, ext:%d, rseq:%d.\n", (*it)->type, ext, rseq);
-            switch ((*it)->type) {
-            case sip_header::H_REQUIRE:
-                if (ext)
-                    // there was alrady a(nother?) Require HF
-                    continue;
-                if(!parse_extensions(&ext, (*it)->value.s, (*it)->value.len)) {
-                    ERROR("failed to parse(own?)'" SIP_HDR_REQUIRE "' hdr.\n");
-                    continue;
-                }
-                if (rseq) { // our RSeq's are never 0
-                    rep.tt._t->last_rseq = rseq;
-                    continue; // the end.
-                }
-                break;
-
-            case sip_header::H_RSEQ:
-                if (rseq) {
-                    ERROR("multiple '" SIP_HDR_RSEQ "' headers in reply.\n");
-                    continue;
-                }
-                if (! parse_rseq(&rseq, (*it)->value.s, (*it)->value.len)) {
-                    ERROR("failed to parse (own?) '" SIP_HDR_RSEQ "' hdr.\n");
-                    continue;
-                }
-                if (ext) {
-                    rep.tt._t->last_rseq = rseq;
-                    continue; // the end.
-                }
-            }
-        }
-    }
-
-
     unsigned int hdrs_len = copy_hdrs_len(msg.hdrs);
 
     if(!rep.body.empty()) {
diff --git a/core/sip/trans_layer.cpp b/core/sip/trans_layer.cpp
index e2003a6..d730b80 100644
--- a/core/sip/trans_layer.cpp
+++ b/core/sip/trans_layer.cpp
@@ -34,19 +34,20 @@
 #include "parse_from_to.h"
 #include "parse_route.h"
 #include "parse_100rel.h"
+#include "parse_extensions.h"
 #include "sip_trans.h"
 #include "msg_fline.h"
 #include "msg_hdrs.h"
 #include "udp_trsp.h"
 #include "resolver.h"
-#include "log.h"
+#include "sip_ua.h"
 
 #include "wheeltimer.h"
 #include "sip_timers.h"
 
-#include "SipCtrlInterface.h"
+#include "log.h"
+
 #include "AmUtils.h"
-#include "AmSipMsg.h"
 #include "AmConfig.h"
 #include "AmSipEvent.h"
 
@@ -155,6 +156,9 @@ int _trans_layer::send_reply(trans_ticket* tt,
        }
     }
 
+    unsigned int rel100_ext = 0;
+    unsigned int rseq = 0;
+    
     // copy necessary headers
     for(list<sip_header*>::iterator it = req->hdrs.begin();
        it != req->hdrs.end(); ++it) {
@@ -192,6 +196,38 @@ int _trans_layer::send_reply(trans_ticket* tt,
        case sip_header::H_RECORD_ROUTE:
            reply_len += copy_hdr_len(*it);
            break;
+
+       case sip_header::H_REQUIRE:
+           if (rel100_ext)
+               // there was already a(nother?) Require HF
+               continue;
+           if(!parse_extensions(&rel100_ext, (*it)->value.s, 
(*it)->value.len)) {
+               ERROR("failed to parse(own?) 'Require' hdr.\n");
+               continue;
+           }
+
+           rel100_ext = rel100_ext & SIP_EXTENSION_100REL;
+
+           if (rel100_ext && rseq) { // our RSeq's are never 0
+               t->last_rseq = rseq;
+               continue; // the end.
+           }
+           break;
+
+       case sip_header::H_RSEQ:
+           if (rseq) {
+               ERROR("multiple 'RSeq' headers in reply.\n");
+               continue;
+           }
+           if (!parse_rseq(&rseq, (*it)->value.s, (*it)->value.len)) {
+               ERROR("failed to parse (own?) 'RSeq' hdr.\n");
+               continue;
+           }
+           if (rel100_ext) {
+               t->last_rseq = rseq;
+               continue; // the end.
+           }
+           break;
        }
     }
 
diff --git a/core/sip/trans_layer.h b/core/sip/trans_layer.h
index e5d72a2..4462202 100644
--- a/core/sip/trans_layer.h
+++ b/core/sip/trans_layer.h
@@ -197,8 +197,6 @@ class trans_ticket
     trans_bucket* _bucket;
     
     friend class _trans_layer;
-    friend class AmSipDialog;
-    friend class SipCtrlInterface; //TODO: make _t, _bucket public??
 
 public:
     trans_ticket()

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

Reply via email to