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

Author: Raphael Coeffic <[email protected]>
Committer: Raphael Coeffic <[email protected]>
Date:   Sat Feb 19 15:19:55 2011 +0100

b/f: fixes last route for strict routing.

---

 core/sip/trans_layer.cpp |   44 ++++++++++++++++++++++----------------------
 1 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/core/sip/trans_layer.cpp b/core/sip/trans_layer.cpp
index f2da53e..0d3dcdc 100644
--- a/core/sip/trans_layer.cpp
+++ b/core/sip/trans_layer.cpp
@@ -573,20 +573,24 @@ int _trans_layer::send_sl_reply(sip_msg* req, int 
reply_code,
     return err;
 }
 
-static void prepare_strict_routing(sip_msg* msg)
+
+static void prepare_strict_routing(sip_msg* msg, string& ext_uri_buffer)
 {
-    assert(!msg->route.empty());
+    if(msg->route.empty())
+       return;
 
     sip_header* fr = msg->route.front();
-    assert(fr->p);
-
-    assert(!((sip_route*)(fr->p))->elmts.empty());
-    sip_nameaddr* fr_na = ((sip_route*)(fr->p))->elmts.front();
-    
-    // place a cursor at the end of the 
-    const char* c = fr_na->addr.s + fr_na->addr.len;
+    sip_uri* route_uri = get_first_route_uri(fr);
+
+    // Loose routing is used,
+    // no need for further processing
+    if(!route_uri || is_loose_route(route_uri))
+       return;
+        
+    // place a cursor at the end of the 1st name-addr
+    cstring fr_na_addr = ((sip_route*)(fr->p))->elmts.front()->addr;
+    const char* c = fr_na_addr.s + fr_na_addr.len;
     const char* end = fr->value.s + fr->value.len;
-
     assert(c<=end);
 
     // detect beginning of next route
@@ -669,12 +673,13 @@ static void prepare_strict_routing(sip_msg* msg)
        break;
     }
 
-    // copy r_uri at the end of 
-    // the route set.
-    msg->hdrs.push_back(new sip_header(0,"Route",msg->u.request->ruri_str)); 
// BUG: must include <>!!!
+    // copy r_uri at the end of the route set.
+    // ext_uri_buffer must have the same scope as 'msg'
+    ext_uri_buffer = "<" + c2stlstr(msg->u.request->ruri_str) + ">";
+    msg->hdrs.push_back(new sip_header(0,"Route",stl2cstr(ext_uri_buffer)));
 
     // and replace the R-URI with the first route URI 
-    msg->u.request->ruri_str = fr_na->addr;
+    msg->u.request->ruri_str = fr_na_addr;
 }
 
 
@@ -705,14 +710,6 @@ int _trans_layer::set_next_hop(sip_msg* msg,
            if(route_uri->port_str.len)
                *next_port = route_uri->port;
        }
-
-       if(is_loose_route(route_uri)){
-           // loose routing is used,
-           // no need for further processing
-           return 0;
-       }
-    
-       prepare_strict_routing(msg);
     }
     else {
 
@@ -843,6 +840,9 @@ int _trans_layer::send_request(sip_msg* msg, trans_ticket* 
tt,
        next_port = _next_port ? _next_port : 5060;
     }
 
+    string uri_buffer; // must have the same scope as 'msg'
+    prepare_strict_routing(msg,uri_buffer);
+
     if(set_destination_ip(msg,&next_hop,next_port) < 0){
        DBG("set_destination_ip failed\n");
        return -1;

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

Reply via email to