Author: sayer
Date: 2009-10-13 22:05:33 +0200 (Tue, 13 Oct 2009)
New Revision: 1538

Modified:
   trunk/apps/reg_agent/RegistrationAgent.cpp
   trunk/apps/reg_agent/RegistrationAgent.h
   trunk/apps/reg_agent/etc/reg_agent.conf
   trunk/apps/registrar_client/SIPRegistrarClient.cpp
   trunk/apps/registrar_client/SIPRegistrarClient.h
Log:
optionally add proxy (next_hop) to registration (host:port)


Modified: trunk/apps/reg_agent/RegistrationAgent.cpp
===================================================================
--- trunk/apps/reg_agent/RegistrationAgent.cpp  2009-10-13 17:55:22 UTC (rev 
1537)
+++ trunk/apps/reg_agent/RegistrationAgent.cpp  2009-10-13 20:05:33 UTC (rev 
1538)
@@ -61,6 +61,7 @@
   ri.display_name = cfg.getParameter("display_name","");
   ri.auth_user = cfg.getParameter("auth_user","");
   ri.passwd = cfg.getParameter("pwd","");
+  ri.proxy = cfg.getParameter("proxy","");
 
   if (!ri.domain.length() || 
       !ri.user.length() || 
@@ -72,8 +73,8 @@
     return 0;
   }
 
-  DBG("Adding registration #%d (%s %s %s %s)\n", 0, 
-      ri.domain.c_str(), ri.user.c_str(), ri.display_name.c_str(), 
ri.auth_user.c_str());
+  DBG("Adding registration #%d (%s %s %s %s %s)\n", 0, 
+      ri.domain.c_str(), ri.user.c_str(), ri.display_name.c_str(), 
ri.auth_user.c_str(), ri.proxy.c_str());
 
   dialer.add_reg(ri);
 
@@ -85,6 +86,7 @@
     ri.display_name = cfg.getParameter("display_name"+int2str(ri_index),"");
     ri.auth_user = cfg.getParameter("auth_user"+int2str(ri_index),"");
     ri.passwd = cfg.getParameter("pwd"+int2str(ri_index),"");
+    ri.proxy = cfg.getParameter("proxy"+int2str(ri_index),"");
       
     if (!ri.domain.length() || 
        !ri.user.length() || 
@@ -93,8 +95,8 @@
        !ri.passwd.length())
       break;
        
-    DBG("Adding registration #%d (%s %s %s %s)\n", ri_index, 
-       ri.domain.c_str(), ri.user.c_str(), ri.display_name.c_str(), 
ri.auth_user.c_str());
+    DBG("Adding registration #%d (%s %s %s %s %s)\n", ri_index, 
+       ri.domain.c_str(), ri.user.c_str(), ri.display_name.c_str(), 
ri.auth_user.c_str(), ri.proxy.c_str());
     dialer.add_reg(ri);
     ri_index++;
   }
@@ -134,6 +136,7 @@
       di_args.push(ri.auth_user.c_str());  // auth_user
       di_args.push(ri.passwd.c_str());    // pwd
       di_args.push("reg_agent"); //sess_link
+      di_args.push(ri.proxy.c_str()); 
                        
       uac_auth_i->invoke("createRegistration", di_args, reg_handle);
       if (reg_handle.size()) 
@@ -181,6 +184,7 @@
     for (vector<RegInfo>::iterator it = registrations.begin(); 
         it != registrations.end(); it++) {
       if (!check_registration(*it)) {
+       // todo: this is very crude... should adjust retry time
        DBG("Registration %d does not exist or timeout. Creating 
registration.\n",
            (int)(it - registrations.begin()));
        create_registration(*it);

Modified: trunk/apps/reg_agent/RegistrationAgent.h
===================================================================
--- trunk/apps/reg_agent/RegistrationAgent.h    2009-10-13 17:55:22 UTC (rev 
1537)
+++ trunk/apps/reg_agent/RegistrationAgent.h    2009-10-13 20:05:33 UTC (rev 
1538)
@@ -42,7 +42,8 @@
   string display_name;
   string auth_user;
   string passwd;
-       
+  string proxy;
+
   string handle;
 };
 

Modified: trunk/apps/reg_agent/etc/reg_agent.conf
===================================================================
--- trunk/apps/reg_agent/etc/reg_agent.conf     2009-10-13 17:55:22 UTC (rev 
1537)
+++ trunk/apps/reg_agent/etc/reg_agent.conf     2009-10-13 20:05:33 UTC (rev 
1538)
@@ -10,6 +10,8 @@
 #display_name=myuser
 #auth_user=myuser
 #pwd=verysecret
+# optional:
+#proxy=sip.mydomain.net:5060
 
 #
 # For multiple registrations add more entries
@@ -19,4 +21,14 @@
 #display_name1=xyz
 #auth_user1=xyz
 #pwd1=ppp
+# optional:
+#proxy1=sip.iptel.org:5060
 
+#domain2=iptel.org
+#user2=xyz
+#display_name2=xyz
+#auth_user2=xyz
+#pwd2=ppp
+# optional:
+#proxy2=sip.iptel.org:5060
+

Modified: trunk/apps/registrar_client/SIPRegistrarClient.cpp
===================================================================
--- trunk/apps/registrar_client/SIPRegistrarClient.cpp  2009-10-13 17:55:22 UTC 
(rev 1537)
+++ trunk/apps/registrar_client/SIPRegistrarClient.cpp  2009-10-13 20:05:33 UTC 
(rev 1538)
@@ -105,7 +105,11 @@
   req.r_uri    = "sip:"+info.domain;
   dlg.remote_uri = req.r_uri;
   // set outbound proxy as next hop 
-  if (!AmConfig::OutboundProxy.empty()) 
+  DBG("proxy is '%s' <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<\n",
+      info.proxy.c_str());
+  if (!info.proxy.empty()) {
+    dlg.next_hop = info.proxy;
+  } else if (!AmConfig::OutboundProxy.empty()) 
     dlg.next_hop = AmConfig::OutboundProxy;
   else 
     dlg.next_hop = "";
@@ -126,7 +130,9 @@
   dlg.remote_uri = req.r_uri;
 
   // set outbound proxy as next hop 
-  if (!AmConfig::OutboundProxy.empty()) 
+  if (!info.proxy.empty()) {
+    dlg.next_hop = info.proxy;
+  } else if (!AmConfig::OutboundProxy.empty()) 
     dlg.next_hop = AmConfig::OutboundProxy;
   else 
     dlg.next_hop = "";
@@ -589,12 +595,14 @@
                                              const string& name,
                                              const string& auth_user,
                                              const string& pwd,
-                                             const string& sess_link) {
+                                             const string& sess_link,
+                                             const string& proxy) {
        
   string handle = AmSession::getNewId();
   instance()->
     postEvent(new SIPNewRegistrationEvent(SIPRegistrationInfo(domain, user, 
-                                                             name, auth_user, 
pwd),
+                                                             name, auth_user, 
pwd, 
+                                                             proxy),
                                          handle, sess_link));
   return handle;
 }
@@ -626,12 +634,17 @@
                                AmArg& ret)
 {
   if(method == "createRegistration"){
+    string proxy;
+    if (args.size() > 6)
+      proxy = args.get(6).asCStr();
+
     ret.push(createRegistration(args.get(0).asCStr(),
                                args.get(1).asCStr(),
                                args.get(2).asCStr(),
                                args.get(3).asCStr(),
                                args.get(4).asCStr(),
-                               args.get(5).asCStr()
+                               args.get(5).asCStr(),
+                               proxy
                                ).c_str());
   }
   else if(method == "removeRegistration"){

Modified: trunk/apps/registrar_client/SIPRegistrarClient.h
===================================================================
--- trunk/apps/registrar_client/SIPRegistrarClient.h    2009-10-13 17:55:22 UTC 
(rev 1537)
+++ trunk/apps/registrar_client/SIPRegistrarClient.h    2009-10-13 20:05:33 UTC 
(rev 1538)
@@ -48,13 +48,16 @@
   string name;
   string auth_user;
   string pwd;
+  string proxy;
+
   SIPRegistrationInfo(const string& domain,
                      const string& user,
                      const string& name,
                      const string& auth_user,
-                     const string& pwd)
+                     const string& pwd,
+                     const string& proxy)
     : domain(domain),user(user),name(name),
-       auth_user(auth_user),pwd(pwd)
+    auth_user(auth_user),pwd(pwd),proxy(proxy)
   { }
 };
 
@@ -193,7 +196,8 @@
                            const string& name,
                            const string& auth_user,
                            const string& pwd,
-                           const string& sess_link);
+                           const string& sess_link,
+                           const string& proxy);
   void removeRegistration(const string& handle);
 
   bool hasRegistration(const string& handle);

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

Reply via email to