Hi,

Andreas Granig wrote:
Uh, turns out I had a typo in my config (public_sip instead of public_ip) :)

And that's because in sems.conf.sample the example is set to public_sip=... instead of public_ip

However, I've attached a patch against trunk that renames this parameter anyways :)

So what I did was splitting up public_ip config option into advertised_media_ip and advertised_sip_ip.

In sipctrl I changed Via and Contact creation to take into account the advertised_sip_ip parameter.

I also changed the previous public_ip handling throughout sems (replacing advertisedIP() by advertisedMediaIP()), and call-id creation (use advertised_sip_ip by calling advertisedSIPIP() if set).

I although noted in conference module that public_ip was not handled there (AmConfig::LocalIP was used instead of AmSession::advertisedIP()), but I let it as is because I don't know the implications of changing that one.

Looks pretty promising so far using auth_b2b, and I'll do more tests tomorrow using b2b_connect.

Andreas
Index: apps/auth_b2b/AuthB2B.cpp
===================================================================
--- apps/auth_b2b/AuthB2B.cpp	(revision 1465)
+++ apps/auth_b2b/AuthB2B.cpp	(working copy)
@@ -267,7 +267,7 @@
   other_id = AmSession::getNewId();
   
   callee_dlg.local_tag    = other_id;
-  callee_dlg.callid       = AmSession::getNewId() + "@" + AmConfig::LocalIP;
+  callee_dlg.callid       = AmSession::getNewId() + "@" + AmConfig::advertisedSIPIP();
   
   // this will be overwritten by ConnectLeg event 
   callee_dlg.remote_party = dlg.local_party;
Index: apps/ivr/Ivr.cpp
===================================================================
--- apps/ivr/Ivr.cpp	(revision 1465)
+++ apps/ivr/Ivr.cpp	(working copy)
@@ -817,7 +817,7 @@
   other_id = AmSession::getNewId();
   
   callee_dlg.local_tag    = other_id;
-  callee_dlg.callid       = AmSession::getNewId() + "@" + AmConfig::LocalIP;
+  callee_dlg.callid       = AmSession::getNewId() + "@" + AmConfig::advertisedSIPIP();
   
   // this will be overwritten by ConnectLeg event 
   callee_dlg.remote_party = dlg.local_party;
Index: apps/click2dial/Click2Dial.cpp
===================================================================
--- apps/click2dial/Click2Dial.cpp	(revision 1465)
+++ apps/click2dial/Click2Dial.cpp	(working copy)
@@ -242,7 +242,7 @@
   other_id = AmSession::getNewId();
 
   callee_dlg.local_tag    = other_id;
-  callee_dlg.callid       = AmSession::getNewId() + "@" + AmConfig::LocalIP;
+  callee_dlg.callid       = AmSession::getNewId() + "@" + AmConfig::advertisedSIPIP();
   callee_dlg.local_party  = dlg.local_party;
   callee_dlg.remote_party = dlg.remote_party;
   callee_dlg.remote_uri   = dlg.remote_uri;
Index: apps/conference/Conference.cpp
===================================================================
--- apps/conference/Conference.cpp	(revision 1465)
+++ apps/conference/Conference.cpp	(working copy)
@@ -752,7 +752,7 @@
   AmSipDialog& dialout_dlg = dialout_session->dlg;
 
   dialout_dlg.local_tag    = dialout_id;
-  dialout_dlg.callid       = AmSession::getNewId() + "@" + AmConfig::LocalIP;
+  dialout_dlg.callid       = AmSession::getNewId() + "@" + AmConfig::advertisedSIPIP();
 
   if (from_header.length() > 0) {
     dialout_dlg.local_party  = from_header;
Index: apps/registrar_client/SIPRegistrarClient.cpp
===================================================================
--- apps/registrar_client/SIPRegistrarClient.cpp	(revision 1465)
+++ apps/registrar_client/SIPRegistrarClient.cpp	(working copy)
@@ -76,7 +76,7 @@
   req.from_tag = handle;
   req.to       = req.from;
   req.to_tag   = "";
-  req.callid   = AmSession::getNewId() + "@" + AmConfig::LocalIP; 
+  req.callid   = AmSession::getNewId() + "@" + AmConfig::advertisedSIPIP();
   //
 
   // clear dlg.callid? ->reregister?
Index: core/AmSession.cpp
===================================================================
--- core/AmSession.cpp	(revision 1465)
+++ core/AmSession.cpp	(working copy)
@@ -286,7 +286,7 @@
   unlockAudio();
 
   if(sdp_reply)
-    sdp.genResponse(advertisedIP(), rtp_str.getLocalPort(), *sdp_reply, AmConfig::SingleCodecInOK);
+    sdp.genResponse(AmConfig::advertisedMediaIP(), rtp_str.getLocalPort(), *sdp_reply, AmConfig::SingleCodecInOK);
 }
 
 void AmSession::run()
@@ -818,7 +818,7 @@
   if (updateSDP) {
     rtp_str.setLocalIP(AmConfig::LocalIP);
     string sdp_body;
-    sdp.genResponse(advertisedIP(), rtp_str.getLocalPort(), sdp_body);
+    sdp.genResponse(AmConfig::advertisedMediaIP(), rtp_str.getLocalPort(), sdp_body);
     dlg.reinvite(headers, "application/sdp", sdp_body);
   } else {
     dlg.reinvite(headers, "", "");
@@ -833,7 +833,7 @@
   
   // Generate SDP.
   string sdp_body;
-  sdp.genRequest(advertisedIP(), rtp_str.getLocalPort(), sdp_body);
+  sdp.genRequest(AmConfig::advertisedMediaIP(), rtp_str.getLocalPort(), sdp_body);
   return dlg.invite(headers, "application/sdp", sdp_body);
 }
 
@@ -847,18 +847,6 @@
   unlockAudio();
 }
 
-// Utility for basic NAT handling: allow the config file to specify the IP
-// address to use in SDP bodies and Contact header.
-// TODO: Contact header! :)
-string AmSession::advertisedIP()
-{
-  string set_ip = AmConfig::PublicIP; // "public_ip" parameter. 
-  DBG("AmConfig::PublicIP is %s.\n", set_ip.c_str());
-  if (set_ip.empty())
-    return AmConfig::LocalIP;           // "listen" parameter.
-  return set_ip;
-}  
- 
 #ifdef WITH_ZRTP
 void AmSession::onZRTPEvent(zrtp_event_t event, zrtp_stream_ctx_t *stream_ctx) {
   DBG("AmSession::onZRTPEvent \n");
Index: core/sems.cpp
===================================================================
--- core/sems.cpp	(revision 1465)
+++ core/sems.cpp	(working copy)
@@ -279,9 +279,10 @@
 	  "       plug-in path:        %s\n"
 	  "       daemon mode:         %i\n"
 	  "       local SIP IP:        %s\n"
-          "       public media IP:     %s\n"
 	  "       local SIP port:      %i\n"
+	  "       advertised SIP IP:   %s\n"
 	  "       local media IP:      %s\n"
+          "       advertised media IP: %s\n"
 	  "       outbound proxy:      %s\n"
 	  "       application:         %s\n"
 	  "\n",
@@ -289,9 +290,10 @@
 	  AmConfig::PlugInPath.c_str(),
 	  AmConfig::DaemonMode,
 	  AmConfig::LocalSIPIP.c_str(),
-	  AmConfig::PublicIP.c_str(),
 	  AmConfig::LocalSIPPort,
+	  AmConfig::advertisedSIPIP().c_str(),
 	  AmConfig::LocalIP.c_str(),
+	  AmConfig::advertisedMediaIP().c_str(),
 	  AmConfig::OutboundProxy.c_str(),
 	  AmConfig::Application.empty()?
 	  "<not set>":AmConfig::Application.c_str()
Index: core/AmUAC.cpp
===================================================================
--- core/AmUAC.cpp	(revision 1465)
+++ core/AmUAC.cpp	(working copy)
@@ -56,7 +56,7 @@
     req.from_tag   = local_tag;
   req.to       = to;
   req.to_tag   = "";
-  req.callid   = AmSession::getNewId() + "@" + AmConfig::LocalIP;
+  req.callid   = AmSession::getNewId() + "@" + AmConfig::advertisedSIPIP();
   req.hdrs     = hdrs;
     
   // set outbound proxy as next hop 
Index: core/AmConfig.h
===================================================================
--- core/AmConfig.h	(revision 1465)
+++ core/AmConfig.h	(working copy)
@@ -66,8 +66,12 @@
   static string LocalIP;
   
   /** public IP for SDP media advertising; we actually
-   *  bind to local IP, but advertise public IP. */ 
-  static string PublicIP;
+   *  bind to local IP, but advertise public IP. */
+  static string AdvertisedMediaIP;
+
+  /** public IP for SIP advertising; we actually
+   *  bind to local IP, but advertise public IP. */
+  static string AdvertisedSIPIP;
   
   /** Separator character for uri application prefix (ex: [email protected]) */
   static string PrefixSep;
@@ -151,6 +155,10 @@
   static int setMediaProcessorThreads(const string& th);
   /** Setter for parameter DeadRtpTime, returns 0 on invalid value */
   static int setDeadRtpTime(const string& drt);
+  /** Getter for the IP address to put as c= in SDP bodies */
+  static string advertisedMediaIP();
+  /** Getter for the IP address to put in Contact and Via */
+  static string advertisedSIPIP();
 };
 
 #endif
Index: core/plug-in/sipctrl/SipCtrlInterface.cpp
===================================================================
--- core/plug-in/sipctrl/SipCtrlInterface.cpp	(revision 1465)
+++ core/plug-in/sipctrl/SipCtrlInterface.cpp	(working copy)
@@ -185,7 +185,7 @@
     localUri += hostName;
   else {
 
-      localUri += AmConfig::LocalSIPIP;
+      localUri += AmConfig::advertisedSIPIP();
       localUri += ":" + int2str(AmConfig::LocalSIPPort);
   }
 
Index: core/plug-in/sipctrl/trans_layer.cpp
===================================================================
--- core/plug-in/sipctrl/trans_layer.cpp	(revision 1465)
+++ core/plug-in/sipctrl/trans_layer.cpp	(working copy)
@@ -478,7 +478,7 @@
     compute_branch(branch_buf,msg->callid->value,msg->cseq->value);
     cstring branch(branch_buf,BRANCH_BUF_LEN);
     
-    string via(transport->get_local_ip());
+    string via(AmConfig::advertisedSIPIP());
     if(transport->get_local_port() != 5060)
 	via += ":" + int2str(transport->get_local_port());
 
Index: core/AmConfig.cpp
===================================================================
--- core/AmConfig.cpp	(revision 1465)
+++ core/AmConfig.cpp	(working copy)
@@ -47,7 +47,8 @@
 string       AmConfig::ExcludePayloads         = "";
 int          AmConfig::DaemonMode              = DEFAULT_DAEMON_MODE;
 string       AmConfig::LocalIP                 = "";
-string       AmConfig::PublicIP                = "";
+string       AmConfig::AdvertisedMediaIP       = "";
+string       AmConfig::AdvertisedSIPIP         = "";
 string       AmConfig::PrefixSep               = PREFIX_SEPARATOR;
 int          AmConfig::RtpLowPort              = RTP_LOWPORT;
 int          AmConfig::RtpHighPort             = RTP_HIGHPORT;
@@ -184,16 +185,26 @@
     LocalIP = cfg.getParameter("media_ip");
   }
 
-  // public_ip
-  if(cfg.hasParameter("public_ip")){
-    string p_ip = cfg.getParameter("public_ip");
-    DBG("Setting public_ip parameter to %s.\n", p_ip.c_str());
-    PublicIP = p_ip;
+  // advertised_media_ip
+  if(cfg.hasParameter("advertised_media_ip")){
+    string p_ip = cfg.getParameter("advertised_media_ip");
+    DBG("Setting advertised_media_ip parameter to %s.\n", p_ip.c_str());
+    AdvertisedMediaIP = p_ip;
   }
   else {
-    DBG("Config file has no public_ip parameter.");
+    DBG("Config file has no advertised_media_ip parameter.");
   }
   
+ // advertised_sip_ip
+  if(cfg.hasParameter("advertised_sip_ip")){
+    string p_ip = cfg.getParameter("advertised_sip_ip");
+    DBG("Setting advertised_sip_ip parameter to %s.\n", p_ip.c_str());
+    AdvertisedSIPIP = p_ip;
+  }
+  else {
+    DBG("Config file has no advertised_sip_ip parameter.");
+  }
+  
   // outbound_proxy
   OutboundProxy = cfg.getParameter("outbound_proxy");
   
@@ -374,3 +385,24 @@
   return 0;
 }
 
+// Utility for basic NAT handling: allow the config file to specify the IP
+// address to use in SDP bodies
+string AmConfig::advertisedMediaIP()
+{
+  string set_ip = AmConfig::AdvertisedMediaIP; // "advertised_media_ip" parameter. 
+  DBG("AmConfig::AdvertisedMediaIP is %s.\n", set_ip.c_str());
+  if (set_ip.empty())
+    return AmConfig::LocalIP;           // "listen" parameter.
+  return set_ip;
+}
+
+// Utility for basic NAT handling: allow the config file to specify the IP
+// address to use in Contact and Via
+string AmConfig::advertisedSIPIP()
+{
+  string set_ip = AmConfig::AdvertisedSIPIP; // "advertised_sip_ip" parameter. 
+  DBG("AmConfig::AdvertisedSIPIP is %s.\n", set_ip.c_str());
+  if (set_ip.empty())
+    return AmConfig::LocalIP;           // "listen" parameter.
+  return set_ip;
+}
Index: core/AmSession.h
===================================================================
--- core/AmSession.h	(revision 1465)
+++ core/AmSession.h	(working copy)
@@ -462,8 +462,6 @@
    */
   virtual void onBeforeDestroy() { }
 
-  // The IP address to put as c= in SDP bodies and to use for Contact:.
-  string advertisedIP();
 };
 
 #endif
Index: core/AmB2BSession.cpp
===================================================================
--- core/AmB2BSession.cpp	(revision 1465)
+++ core/AmB2BSession.cpp	(working copy)
@@ -381,7 +381,7 @@
   other_id = AmSession::getNewId();
   
   callee_dlg.local_tag    = other_id;
-  callee_dlg.callid       = AmSession::getNewId() + "@" + AmConfig::LocalIP;
+  callee_dlg.callid       = AmSession::getNewId() + "@" + AmConfig::advertisedSIPIP();
 
   callee_dlg.local_party  = dlg.remote_party;
   callee_dlg.remote_party = dlg.local_party;
Index: core/AmB2ABSession.cpp
===================================================================
--- core/AmB2ABSession.cpp	(revision 1465)
+++ core/AmB2ABSession.cpp	(working copy)
@@ -248,7 +248,7 @@
   assert(callee_session);
 
   AmSipDialog& callee_dlg = callee_session->dlg;
-  callee_dlg.callid       = AmSession::getNewId() + "@" + AmConfig::LocalIP;
+  callee_dlg.callid       = AmSession::getNewId() + "@" + AmConfig::advertisedSIPIP();
   callee_dlg.local_tag    = other_id; 
 
 
Index: core/etc/sems.conf.sample
===================================================================
--- core/etc/sems.conf.sample	(revision 1465)
+++ core/etc/sems.conf.sample	(working copy)
@@ -41,20 +41,32 @@
 #  sip_ip=10.0.0.34
 #
 
-# optional parameter: public_ip=<ip_address>
+# optional parameter: advertised_media_ip=<ip_address>
 # 
 # - when running SEMS behind certain simple NAT configurations,
 #   you can use this parameter to inform SEMS of its public IP
-#   address. If this parameter is set, SEMS will write this value
-#   into SDP bodies.
+#   address to be advertised in the SDP body.
 #   If this parameter is not set, the local IP address is used.
 #   N.B., there is no support for port translation; the local 
 #   RTP port is advertised in SDP in either case.
 #   
 # Example:
-#  public_sip=75.101.219.48
+#  advertised_media_ip=75.101.219.48
 #  
-  
+
+# optional parameter: advertised_sip_ip=<ip_address>
+# 
+# - when running SEMS behind certain simple NAT configurations,
+#   you can use this parameter to inform SEMS of its public IP
+#   address to be advertised in the Via and Contact headers.
+#   If this parameter is not set, the local IP address is used.
+#   N.B., there is no support for port translation; the local 
+#   SIP port is advertised in either case.
+#   
+# Example:
+#  advertised_media_ip=75.101.219.48
+#  
+
 # optional parameter: sip_port=<port_number>
 #
 # - this informs SEMS about the port where its SIP stack is 
_______________________________________________
Sems mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/sems

Reply via email to