Hi,

o Jeremy A [01/29/09 00:45]:
Andrew Radke wrote:
Hi,

I would like to use auth_b2bua to allow calls from our IP PBX to use
the internet. The thing is it seems that auth_b2bua wants the custom
header "P-App-Param:u=user;d=domainb;p=passwd" which I can't get the
PBX to send. Is there a way to pass these parameters from a config
file instead?


The simplest way to get the extra header is to use an instance of SER
that receives the call, inserts the header, and then passes the call to
SEMS.
you can also simply read the values from config file (user=.../domain=.../pwd=.../) like in the attached (untested) patch.

Regards
Stefan


Jeremy

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

--
Stefan Sayer
VoIP Services

[email protected]
www.iptego.com

IPTEGO GmbH
Am Borsigturm 40
13507 Berlin
Germany

Amtsgericht Charlottenburg, HRB 101010
Geschaeftsfuehrer: Alexander Hoffmann
Index: AuthB2B.cpp
===================================================================
--- AuthB2B.cpp (revision 1212)
+++ AuthB2B.cpp (working copy)
@@ -34,9 +34,13 @@
 #include "AmAudio.h"
 #include "AmPlugIn.h"
 #include "AmMediaProcessor.h"
-//#include "AmConfigReader.h"
+#include "AmConfigReader.h"
 #include "AmSessionContainer.h"
 
+string AuthB2BFactory::user;
+string AuthB2BFactory::domain;
+string AuthB2BFactory::pwd;
+
 EXPORT_SESSION_FACTORY(AuthB2BFactory,MOD_NAME);
 
 AuthB2BFactory::AuthB2BFactory(const string& _app_name)
@@ -48,9 +52,16 @@
 
 int AuthB2BFactory::onLoad()
 {
-//   AmConfigReader cfg;
-//   if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf")))
-//     return -1;
+   AmConfigReader cfg;
+   if(cfg.loadFile(AmConfig::ModConfigPath + string(MOD_NAME ".conf"))) {
+     INFO("No configuration for auth_b2b present (%s)\n",
+         (AmConfig::ModConfigPath + string(MOD_NAME ".conf")).c_str()
+         );
+   } else {
+     user = cfg.getParameter("user");
+     domain = cfg.getParameter("domain");
+     pwd = cfg.getParameter("pwd");
+   }
 
 //   user_timer_fact = AmPlugIn::instance()->getFactory4Di("user_timer");
 //   if(!user_timer_fact) {
@@ -101,16 +112,22 @@
   setReceiving(false);
   AmMediaProcessor::instance()->removeSession(this);
 
-  string app_param = getHeader(req.hdrs, PARAM_HDR);
+  if (AuthB2BFactory::user.empty()) {
+    string app_param = getHeader(req.hdrs, PARAM_HDR);
 
-  if (!app_param.length()) {
-    AmSession::Exception(500, "auth_b2b: parameters not found");
+    if (!app_param.length()) {
+      AmSession::Exception(500, "auth_b2b: parameters not found");
+    }
+    
+    domain = get_header_keyvalue(app_param,"d");
+    user = get_header_keyvalue(app_param,"u");
+    password = get_header_keyvalue(app_param,"p");
+  } else {
+    domain = AuthB2BFactory::domain;
+    user = AuthB2BFactory::user;
+    password = AuthB2BFactory::pwd;
   }
 
-  domain = get_header_keyvalue(app_param,"d");
-  user = get_header_keyvalue(app_param,"u");
-  password = get_header_keyvalue(app_param,"p");
-
   from = "sip:"+user+"@"+domain;
   to = "sip:"+req.user+"@"+domain;
 
Index: AuthB2B.h
===================================================================
--- AuthB2B.h   (revision 1212)
+++ AuthB2B.h   (working copy)
@@ -44,6 +44,10 @@
   
   int onLoad();
   AmSession* onInvite(const AmSipRequest& req);
+  static string user;
+  static string domain;
+  static string pwd;
+
 };
 
 class AuthB2BDialog : public AmB2BCallerSession
_______________________________________________
Sems mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/sems

Reply via email to