Browse code

sbc:add option next_hop_fixed=[yes|no], for fixing the next_hop

if set to yes, the next_hop will not be updated by remote IP
caution: DNS SRV may resolve to something else next time

Stefan Sayer authored on 22/11/2013 20:12:26
Showing 5 changed files
... ...
@@ -170,6 +170,7 @@ bool SBCCallProfile::readFromConfiguration(const string& name,
170 170
   next_hop = cfg.getParameter("next_hop");
171 171
   next_hop_1st_req = cfg.getParameter("next_hop_1st_req") == "yes";
172 172
   patch_ruri_next_hop = cfg.getParameter("patch_ruri_next_hop") == "yes";
173
+  next_hop_fixed = cfg.getParameter("next_hop_fixed") == "yes";
173 174
 
174 175
   aleg_next_hop = cfg.getParameter("aleg_next_hop");
175 176
 
... ...
@@ -421,8 +422,8 @@ bool SBCCallProfile::readFromConfiguration(const string& name,
421 422
     INFO("SBC:      A leg outbound proxy = '%s'\n", aleg_outbound_proxy.c_str());
422 423
 
423 424
     if (!next_hop.empty()) {
424
-      INFO("SBC:      next hop = %s (%s)\n", next_hop.c_str(),
425
-	   next_hop_1st_req ? "1st req" : "all reqs");
425
+      INFO("SBC:      next hop = %s (%s, %s)\n", next_hop.c_str(),
426
+	   next_hop_1st_req ? "1st req" : "all reqs", next_hop_fixed?"fixed":"not fixed");
426 427
     }
427 428
 
428 429
     if (!aleg_next_hop.empty()) {
... ...
@@ -581,6 +582,7 @@ bool SBCCallProfile::operator==(const SBCCallProfile& rhs) const {
581 582
     aleg_force_outbound_proxy == rhs.aleg_force_outbound_proxy &&
582 583
     next_hop == rhs.next_hop &&
583 584
     next_hop_1st_req == rhs.next_hop_1st_req &&
585
+    next_hop_fixed == rhs.next_hop_fixed &&
584 586
     patch_ruri_next_hop == rhs.patch_ruri_next_hop &&
585 587
     aleg_next_hop == rhs.aleg_next_hop &&
586 588
     headerfilter == rhs.headerfilter &&
... ...
@@ -638,6 +640,7 @@ string SBCCallProfile::print() const {
638 640
   res += "aleg_force_outbound_proxy: " + string(aleg_force_outbound_proxy?"true":"false") + "\n";
639 641
   res += "next_hop:             " + next_hop + "\n";
640 642
   res += "next_hop_1st_req:     " + string(next_hop_1st_req ? "true":"false") + "\n";
643
+  res += "next_hop_fixed:       " + string(next_hop_fixed ? "true":"false") + "\n";
641 644
   res += "aleg_next_hop:        " + aleg_next_hop + "\n";
642 645
   // res += "headerfilter:         " + string(FilterType2String(headerfilter)) + "\n";
643 646
   // res += "headerfilter_list:    " + stringset_print(headerfilter_list) + "\n";
... ...
@@ -922,6 +925,7 @@ int SBCCallProfile::apply_b_routing(ParamReplacerCtx& ctx,
922 925
     DBG("set next hop ip to '%s'\n", nh.c_str());
923 926
     dlg.setNextHop(nh);
924 927
     dlg.setNextHop1stReq(next_hop_1st_req);
928
+    dlg.setNextHopFixed(next_hop_fixed);
925 929
   }
926 930
 
927 931
   DBG("patch_ruri_next_hop = %i",patch_ruri_next_hop);
... ...
@@ -143,6 +143,7 @@ struct SBCCallProfile
143 143
   string next_hop;
144 144
   bool next_hop_1st_req;
145 145
   bool patch_ruri_next_hop;
146
+  bool next_hop_fixed;
146 147
 
147 148
   string aleg_next_hop;
148 149
 
... ...
@@ -21,6 +21,8 @@
21 21
 #next_hop=192.168.5.106:5060
22 22
 # set RURI to (calculated) next_hop
23 23
 #patch_ruri_next_hop=yes
24
+# update next_hop from remote destination? (e.g. from SRV)
25
+#next_hop_fixed=yes
24 26
 # outbound interface to use (interface ID)
25 27
 #outbound_interface=extern
26 28
 
... ...
@@ -30,6 +30,7 @@ AmBasicSipDialog::AmBasicSipDialog(AmBasicSipEventHandler* h)
30 30
     next_hop(AmConfig::NextHop),
31 31
     next_hop_1st_req(AmConfig::NextHop1stReq),
32 32
     patch_ruri_next_hop(false),
33
+    next_hop_fixed(false),
33 34
     outbound_interface(-1),
34 35
     nat_handling(AmConfig::SipNATHandling),
35 36
     usages(0)
... ...
@@ -469,7 +470,9 @@ void AmBasicSipDialog::updateDialogTarget(const AmSipReply& reply)
469 470
        (reply.cseq_method == SIP_METH_SUBSCRIBE)) ) {
470 471
     
471 472
     setRemoteUri(reply.to_uri);
472
-    if(!getNextHop().empty()) {
473
+    if(!getNextHop().empty() && !next_hop_fixed) {
474
+      DBG("updating next_hop from reply to %s:%u\n",
475
+	  reply.remote_ip, reply.remote_port);
473 476
       setNextHop(reply.remote_ip + ":"
474 477
 		 + int2str(reply.remote_port));
475 478
     }
... ...
@@ -115,6 +115,7 @@ protected:
115 115
   string next_hop;
116 116
   bool next_hop_1st_req;
117 117
   bool patch_ruri_next_hop;
118
+  bool next_hop_fixed;
118 119
 
119 120
   int outbound_interface;
120 121
 
... ...
@@ -301,6 +302,10 @@ public:
301 302
   virtual void setPatchRURINextHop(bool patch_nh)
302 303
   { patch_ruri_next_hop = patch_nh; }
303 304
 
305
+  bool getNextHopFixed() const { return next_hop_fixed; }
306
+  virtual void setNextHopFixed(bool nh_fixed)
307
+  { next_hop_fixed = nh_fixed; }
308
+
304 309
   /**
305 310
    * Compute the Contact-HF for the next request
306 311
    */