Re: [SR-Users] Dispatcher Failover algorithm

2015-01-09 Thread Yuriy Gorlichenko
Priority bassed? I've read about all algorithms of disatcher and can not
find that anone use priority...


   -

   “0” - hash over callid
   -

   “1” - hash over from URI.
   -

   “2” - hash over to URI.
   -

   “3” - hash over request-URI.
   -

   “4” - round-robin (next destination).
   -

   “5” - hash over authorization-username (Proxy-Authorization or normal
   authorization). If no username is found, round robin is used.
   -

   “6” - random (using rand()).
   -

   “7” - hash over the content of PVs string. Note: This works only when
   the parameter hash_pvar is set.
   -

   “8” - use first destination (good for failover).
   -

   “9” - use weight based load distribution. You have to set the attribute
   'weight' per each address in destination set.
   -

   “10” - use call load distribution. You have to set the attribute 'duid'
   (as an unique string id) per each address in destination set. Also, you
   must set parameters 'dstid_avp' and 'ds_hash_size'.

   The algorithm can be used even with stateless proxy mode, there is no
   SIP dialog tracking depending on other modules, just an internal
   lightweight call tracking by Call-Id, thus is fast and suitable even for
   embedded systems.

   The first destination selected by this algorithm is the one that has the
   least number of calls associated. The rest of the destination list is taken
   in order of the entries in set - anyhow, until a re-route to next
   destination happens, the load on each address can change.

   This algorithm can be used only for dispatching INVITE requests as it is
   the only SIP method creating a SIP call.
   -

   “X” - if the algorithm is not implemented, the first entry in set is
   chosen.


2015-01-09 20:23 GMT+03:00 Daniel-Constantin Mierla mico...@gmail.com:

  You probably look for priority based routing -- see the readme of
 dispatcher module.

 Cheers,
 Daniel


 On 09/01/15 17:52, Yuriy Gorlichenko wrote:

 I as wrote before - we find dispatcher algorithm than can do mechanism
 something like this:
 Try call to fist server with max priority or weight. OIf this server
 unavailible then call second server with less weight and etc.

 Does anyone know what ling of algorithm we can use for this?


 ___
 SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing 
 listsr-us...@lists.sip-router.orghttp://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


 --
 Daniel-Constantin Mierlahttp://twitter.com/#!/miconda - 
 http://www.linkedin.com/in/miconda


 ___
 SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
 sr-users@lists.sip-router.org
 http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] Dispatcher Failover algorithm

2015-01-09 Thread Daniel-Constantin Mierla
You probably look for priority based routing -- see the readme of
dispatcher module.

Cheers,
Daniel

On 09/01/15 17:52, Yuriy Gorlichenko wrote:
 I as wrote before - we find dispatcher algorithm than can do mechanism
 something like this:
 Try call to fist server with max priority or weight. OIf this server
 unavailible then call second server with less weight and etc.

 Does anyone know what ling of algorithm we can use for this?


 ___
 SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
 sr-users@lists.sip-router.org
 http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda

___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] pua_subscribe and force_send_socket trouble

2015-01-09 Thread Mikko Lehto
Some additional information:

OS is Linux Debian Wheezy 7.6 on amd64

pua_subscribe is launched like this:
kamcmd mi pua_subscribe sip:+35812345789@A.B.C.D:5041 sip:myproxy.fqdn.invalid 
presence 3600

-- 
Mikko

___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] Can't start Kamailio with both db_postgres and tls

2015-01-09 Thread Daniel-Constantin Mierla
Do you have a testbed server where I can login and try couple of
patches? It might be faster to try to get it solved this way ... Or
maybe someone can make one server available with postgress and you
configure it there in a similar way -- I am not a postgres user and no
resourse to setup something new at this moment.

If not, I will try to give some other steps to try to fix it this way,
just is going to be probably slow ...

Daniel

On 09/01/15 16:02, Øyvind Kolbu wrote:

 On 07.01.2015 14:27, Daniel-Constantin Mierla wrote:
 So it complains that the ssl lib is not initialized completely.

 Can you try the following:

 - edit modules/tls/tls_init.c and add at the beginning of function 'int
 init_tls_h(void)':

 if(tls_mod_initialized  0) return 0;

 - in modules/db_postgres/km_pg_con.c, add:

 #include ../../tls_hooks_init.h

 - then in same file, before the line you added with PQinitSSL(0); add:

 init_tls();

 Recompile, reinstall, restart and test only with tls module loaded
 before the db_postgres.

 Let's see the results and then I will make a proper patch if works.


 Crashed again, this time with core dump. Used the following patch:
 --- modules/db_postgres/km_pg_con.c.orig2015-01-09
 15:39:02.411067822 +0100
 +++ modules/db_postgres/km_pg_con.c 2015-01-09 15:40:32.980577115
 +0100
 @@ -29,6 +29,7 @@
  #include ../../mem/mem.h
  #include ../../dprint.h
  #include ../../ut.h
 +#include ../../tls_hooks_init.h
  #include string.h
  #include time.h

 @@ -74,6 +75,9 @@
 ZSW(id-database));
 }

 +init_tls();
 +PQinitSSL(0);
 +
 ptr-con = PQsetdbLogin(id-host, ports, NULL, NULL,
 id-database, id-username, id-password);
 LM_DBG(PQsetdbLogin(%p)\n, ptr-con);

 --- modules/tls/tls_init.c.orig 2015-01-09 15:37:16.268298551 +0100
 +++ modules/tls/tls_init.c  2015-01-09 15:38:31.924559696 +0100
 @@ -498,6 +498,8 @@
 str s;
 cfg_ctx_t* cfg_ctx;

 +if(tls_mod_initialized  0) return 0;
 +
  #if OPENSSL_VERSION_NUMBER  0x00907000L
 WARN(You are using an old version of OpenSSL ( 0.9.7).
 Upgrade!\n);
  #endif

 And got this message:
 /usr/sbin/kamailio[22789]: INFO: tls [tls_mod.c:346]: mod_init(): With
 ECDH-Support!
 /usr/sbin/kamailio[22789]: INFO: tls [tls_mod.c:349]: mod_init(): With
 Diffie Hellman
 /usr/sbin/kamailio[22789]: INFO: ldap [ldap_mod.c:246]: mod_init():
 OpenLDAP - 20439
 /usr/sbin/kamailio[22789]: INFO: rr [../outbound/api.h:54]:
 ob_load_api(): Failed to import bind_ob
 /usr/sbin/kamailio[22789]: INFO: rr [rr_mod.c:159]: mod_init():
 outbound module not available
 /usr/sbin/kamailio[22789]: INFO: usrloc [hslot.c:53]: ul_init_locks():
 locks array size 512
 /usr/sbin/kamailio[22789]: INFO: tls [tls_init.c:551]: init_tls_h():
 tls: _init_tls_h:  compiled  with  openssl  version OpenSSL
 1.0.1e-fips 11 Feb 2013 (0x1000105f), kerberos support: on,
 compression: on [...]
 /usr/sbin/kamailio[22789]: : core [pt.c:164]: get_max_procs(): BUG:
 get_max_procs() called too early (it must _not_ be called from
 mod_init())

 and the following backtrace:
 #0  0x003196e32625 in raise () from /lib64/libc.so.6
 #1  0x003196e33e05 in abort () from /lib64/libc.so.6
 #2  0x0049138f in get_max_procs () at pt.c:165
 #3  0x7f8ca8655106 in init_tls_h () at tls_init.c:598
 #4  0x005372b9 in init_tls () at tls_hooks.c:70
 #5  0x7f8c9fffb655 in db_postgres_new_connection (id=0x7f8ca8d7d0b0)
 at km_pg_con.c:78
 #6  0x7f8c9fbd0eaa in db_do_init2 (url=0x7f8c9ca52cd0,
 new_connection=0x7f8c9fffac47 db_postgres_new_connection,
 pooling=DB_POOLING_PERMITTED) at db.c:320
 #7  0x7f8c9fbd06d5 in db_do_init (url=0x7f8c9ca52cd0,
 new_connection=0x7f8c9fffac47 db_postgres_new_connection) at
 db.c:273
 #8  0x7f8c9fff4bbc in db_postgres_init (_url=0x7f8c9ca52cd0)
 at km_dbase.c:133
 #9  0x7f8c9c81429f in dlg_connect_db (db_url=0x7f8c9ca52cd0)
 at dlg_db_handler.c:132
 #10 0x7f8c9c814457 in init_dlg_db (db_url=0x7f8c9ca52cd0,
 dlg_hash_size=4096, db_update_period=60, fetch_num_rows=200)
 at dlg_db_handler.c:146
 #11 0x7f8c9c80c7cd in mod_init () at dialog.c:700
 #12 0x004f884d in init_mod (m=0x7f8ca88e82d8) at sr_module.c:967
 #13 0x004f8703 in init_mod (m=0x7f8ca88e8f98) at sr_module.c:964
 #14 0x004f8703 in init_mod (m=0x7f8ca88e94c0) at sr_module.c:964


 (gdb) bt full
 #0  0x003196e32625 in raise () from /lib64/libc.so.6
 No symbol table info available.
 #1  0x003196e33e05 in abort () from /lib64/libc.so.6
 No symbol table info available.
 #2  0x0049138f in get_max_procs () at pt.c:165
 __FUNCTION__ = get_max_procs
 #3  0x7f8ca8655106 in init_tls_h () at tls_init.c:598
 ssl_version = 268439647
 lib_kerberos = 1
 lib_zlib = 1
 kerberos_support = 1
 comp_support = 1
 lib_cflags = 0x319a1dede0 compiler: gcc -fPIC -DOPENSSL_PIC
 -DZLIB 

[SR-Users] Dispatcher Failover algorithm

2015-01-09 Thread Yuriy Gorlichenko
I as wrote before - we find dispatcher algorithm than can do mechanism
something like this:
Try call to fist server with max priority or weight. OIf this server
unavailible then call second server with less weight and etc.

Does anyone know what ling of algorithm we can use for this?
___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


[SR-Users] pua_subscribe and force_send_socket trouble

2015-01-09 Thread Mikko Lehto
Hi

I am having strange behavior on local port assignment when
proxying out locally generated request. Kamailio is 4.2.1 from git.


I use MI pua_subscribe to create subscription to be handled by
external presence server.

In event_route[tm:local-request] I set $du to point back to proxy itself.

When request hits initial request_route, I add some headers, change
request URI and prepare failure_route for later uac_auth() processing.
So far so good and TLS packets are flying to correct destination.

Here is the trouble:
when I observe outgoing TLS traffic with tcpdump, I can see that local
source port is not following what I set with force_send_socket(). I tried to
place force_send_socket() in request_route, branch_route, and
tm:local-request, but it is always some random high port (3), never
the intended one. I am trying to set it to same as my TLS listening socket.

Is my usage somehow incorrect?
What should I try next to make Kamailio use constant source port?

Relevant config snippet below (IP address and domain part is obscured).
---
mhomed=1
listen=udp:A.B.C.D:5041
listen=tls:A.B.C.D:5041

request_route {
route(REQINIT);
if ( blahblah...  ) {
$ru = sip: + $rU + @domain.part.invalid;transport=tls;
$avp(uac_auth) = 0;
route(PR_HDRS);
route(PR_TRIGGERS);
force_send_socket(A.B.C.D:5041);
t_newtran();
route(RELAY);
}
}
route[PR_HDRS] {
remove_hf(User-Agent);
insert_hf(User-Agent: pua_subscribe\r\n,Call-ID);
}
route[PR_TRIGGERS] {
t_on_branch(PR_BRANCH);
t_on_failure(PR_FAILURE);
}
branch_route[PR_BRANCH] {
force_send_socket(A.B.C.D:5041);
}
failure_route[PR_FAILURE]  {
if ( $avp(uac_auth) == 0  ($T_reply_code == 401 or $T_reply_code == 
407) ) {
uac_auth();
$avp(uac_auth) = 1;
route(PR_TRIGGERS);
route(RELAY);
}
}
event_route [tm:local-request] {
force_send_socket(A.B.C.D:5041);
$du = sip:A.B.C.D:5041;
}
route[RELAY] { is from default config }
---


I found these recent commits, bugs and threads somehow relating
to force_send_socket and tm:local-request:

http://sip-router.org/tracker/index.php?do=detailstask_id=462
http://lists.sip-router.org/pipermail/sr-users/2014-August/084459.html

dbd8ea9b1fa216e59d4c36e2eb4b671202824259
http://lists.sip-router.org/pipermail/sr-dev/2014-September/024984.html

e404d123610b63ddd1c75d39667b373c40071eab
http://lists.sip-router.org/pipermail/sr-dev/2014-September/024977.html

-- 
Mikko Lehto

___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] Problem with tag field with using a custom table for the permissions module.

2015-01-09 Thread Jan Hazenberg

Daniel,

Thanks, i will try to configure that table as well.

Jan

Daniel-Constantin Mierla schreef op 2015-01-09 15:25:

Looking closer at the log messages, the error is when loading the
'address' table. Apparently the tag column name parameter is shared
between address and trusted tables.

Cheers,
Daniel

On 07/01/15 19:27, Jan Hazenberg wrote:

Daniel,

No i do not use the lcr module. It is kamailio 4.2.1 running on ubuntu
server Ubuntu 14.04.1 LTS

Packages are installed from from the http://deb.kamailio.org/kamailio
repository

Jan

Daniel-Constantin Mierla schreef op 2015-01-07 00:29:

Hello,

what operating system are you using? How did you install kamailio, 
from

sources or packages?

Is lcr module used as well?

Cheers,
Daniel

On 06/01/15 21:53, Jan Hazenberg wrote:

Hi,

I'm trying to use a custom table for the permissions module and run
into a issue with the tag field, all other fields seem to work fine.

Here is my config:

modparam(permissions, db_url, DBURL)
modparam(permissions, db_mode, 1)
modparam(permissions, peer_tag_avp, $avp(permissions_tag))
modparam(permissions, trusted_table, trunks)
modparam(permissions, source_col, ip)
modparam(permissions, proto_col, transport)
modparam(permissions, from_col, from_pattern)
modparam(permissions, tag_col, trunk_uuid)

When i start kamailio i see the following error in the log:

Jan  6 21:49:57 sip /usr/sbin/kamailio[24327]: ERROR: db_mysql
[km_dbase.c:123]: db_mysql_submit_query(): driver error on query:
Unknown column 'trunk_uuid' in 'field list'
Jan  6 21:49:57 sip /usr/sbin/kamailio[24327]: ERROR: core
[db_query.c:132]: db_do_query_internal(): error while submitting 
query

Jan  6 21:49:57 sip /usr/sbin/kamailio[24327]: ERROR: permissions
[address.c:112]: reload_address_table(): failed to query database
Jan  6 21:49:57 sip /usr/sbin/kamailio[24327]: CRITICAL: permissions
[address.c:363]: init_addresses(): reload of address table failed
Jan  6 21:49:57 sip /usr/sbin/kamailio[24327]: ERROR: permissions
[permissions.c:631]: mod_init(): failed to initialize the
allow_address function
Jan  6 21:49:57 sip /usr/sbin/kamailio[24327]: ERROR: core
[sr_module.c:968]: init_mod(): Error while initializing module
permissions 
(/usr/lib/x86_64-linux-gnu/kamailio/modules/permissions.so)

Jan  6 21:49:58 sip kamailio: ERROR: core [daemonize.c:315]:
daemonize(): Main process exited before writing to pipe


If i change the tag_col to tag it works fine, both fields are
varchar(64). And the field trunk_uuid exists in the trunks table.

I'm running kamailio 4.2.1

Thanks,

Jan Hazenberg

___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing 
list

sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing 
list

sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] Camarillo 4.2 as outbound proxy with TLS support

2015-01-09 Thread Daniel-Constantin Mierla
You have to run rtpproxy (or rtpengine) in bridging mode and instruct it
to do bridging from kamailio cfg using 'e' and 'i' flags (iirc, there is
an alg.cfg inside nathelper examples folder that gives some hints, good
for starting -- also searching on web for rtpproxy in brdige mode may
reveal some useful info).

Cheers,
Daniel

On 09/01/15 03:50, CK Lee wrote:
 I do have a similar setup and encounter the audio problem

 My Kamailio sits behind a router listening to the public ip sip port
 5060 and use internal lan ip to communicate with other service,
 Asterisk. Rtpproxy and WITH_NAT are set up according to instruction.

 However, I notice when kamailio communicates with Asterisk (which is
 on the same LAN subnet), a lan IP is passed to Asterisk.My sip client
 on outside public network does not receive any audio stream.

 Is it wrong with the Kamailio setup?



 On Fri, Jan 9, 2015 at 2:30 AM, Daniel-Constantin Mierla
 mico...@gmail.com mailto:mico...@gmail.com wrote:

 Hello,

 if the users are behind nat, install rtpproxy and enable WITH_NAT
 in default config file. Read the comments at the top of
 kamailio.cfg to see how to set the control socket for rtpproxy.

 Cheers,
 Daniel


 On 05/01/15 14:05, Maqbul Khan - Reform InfoTech wrote:
 Hello,

 I just installed Kamailio for the first time 4.2 on Debian
 Wheezy.  Everything went alright, I created two users, both can
 register and make calls, but with no audio.

 So the problems are:
 1. No audio
 2. I want to setup Kamailio as Outbound Proxy
 3. I wish to have this proxy with TLS support.

 Please suggest solution

 Maq Khan



 ___
 SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
 sr-users@lists.sip-router.org mailto:sr-users@lists.sip-router.org
 http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

 -- 
 Daniel-Constantin Mierla
 http://twitter.com/#!/miconda http://twitter.com/#%21/miconda - 
 http://www.linkedin.com/in/miconda


 ___
 SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing
 list
 sr-users@lists.sip-router.org mailto:sr-users@lists.sip-router.org
 http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users



-- 
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda

___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] Redirect Server Including Path/Recieved Information

2015-01-09 Thread Daniel-Constantin Mierla
Hello,

where is the media server located and the signaling flow for it?

Cheers,
Daniel

On 09/01/15 14:41, Asgaroth wrote:
 Hi,

 I am hoping to have the redirect server not be in the signalling path,
 so when a media server asterisk/freeswitch sends an invite over to the
 redirect server, I need to respond with the 302 and include the
 contact information, outbound path (via proxy loadbalancer) and the
 recieved information to let the proxy/loadbalancer know where to
 forward to.

 So when a client registers it comes in like this:

 UAC -- Firewall -- Proxy -- Registrar

 At this point the registrar stores the recieved host:port of firewall,
 and path via the proxy.

 When I send a redirect, I want the media server to travers the path
 via the route the uac registered with:

 uas invite -- redirect server
 uas-- 302
 uas invite -- proxy (path) -- firewall (recieved) -- uac

 I am not sure how to provide the path information in the 302 response.
 I tried to add it as a madd parameter in the contact header but it
 then uses the port defined in the host part of the uri as the proxy
 port. I cant seem to find a reference as to how to do this.

 for example, uac is registered with following info (info manipulated
 to protect the poor :) ) and pulled from location table:

 Contact:
 sip:username@192.168.1.150:55023;rinstance=9dc7a3f0e662b2cd;transport=UDP
 Recieved: sip:213.146.165.189:20185
 Path: sip:77.87.89.91;lr;received=sip:213.146.165.189:20185

 I tried to perform a redirect with the following information in the
 contact

 Contact:
 sip:username@192.168.1.150:55023;rinstance=9dc7a3f0e662b2cd;transport=UDP;received=sip:213.146.165.189:20185,maddr=77.87.89.91

 The problem here is that the media server attempts to send the new
 invite to port 55023 at the host specified by the maddr (77.87.89.91)
 parameter.

 I did some more reading this morning and I can see that the rfc says
 that the new invite should be relayed in this manner.

 How would I specify the equivilent of $du in a 302 response message?

 I hope that explains it a little better.

 Thanks


 On 09/01/2015 13:14, Daniel-Constantin Mierla wrote:
 Hello,

 I am not sure if path and received from location will be of any
 information for the redirect. At least received is the proto, source and
 port of incoming REGISTER. Then, the Path is to be used by location
 server when forwarding requests.

 Can you give more details of how path and received from location should
 be used by the one receiving the 30x redirect?

 Cheers,
 Daniel

 On 08/01/15 22:09, Asgaroth wrote:
 Hi All,

 I am attempting to setup a standalone redirect server which will
 lookup contact info and redirect to appropriate outbound proxy.

 The problem I am having is that the registrar is storing the path and
 recieved information, however, when I perform a lookup and reply with
 302, the recieved and path information is not included.

 Are there module parameters in the registrar module that will include
 these contact parameters (recieved) or create the appropriate headers
 (path/route) in the 302 response, or, is this something I need to do
 manually.

 Currently I have the following lookup code:

 route {

t_check_trans();

if ( method == INVITE ) {
  xlog(route[MAIN] : $rm : ruri=$ru);
  xlog(route[MAIN] : $rm : lookup=sip:$rU@registered.domain);
  if ( lookup(location, sip:$rU@registered.domain) ) {
send_reply(302, Moved Temporarily);
exit;
  }
}
 }

 I had a look at the path_mode parameter but this looks like it only
 takes affect for REGISTER methods.

 The INVITE that comes in supports the PATH header but I dont see this
 being passed back. In fact, I'm not entirely sure if the path header
 is a supported header in the 302 response message. I had a quick
 google and I cant seem to easily find what headers are suported in the
 302 message, and where I need to put the path/recieved information. I
 presume I can add the recieved info as a parameter to the contact
 header, but how would i specify the outbound proxy to use, would that
 be in a route or a path header in the 302 response?

 I can see that the $du pseudo variable is set with the appropriate
 outbound path and received information, now I just need to include
 this information in the 302 response.

 Any suggestions/comments to assist in how I get this info into the 302
 message would be greatly appreciated.

 Thanks in advance.


 ___
 SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
 sr-users@lists.sip-router.org
 http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


-- 
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda


___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] Problem with tag field with using a custom table for the permissions module.

2015-01-09 Thread Daniel-Constantin Mierla
Looking closer at the log messages, the error is when loading the
'address' table. Apparently the tag column name parameter is shared
between address and trusted tables.

Cheers,
Daniel

On 07/01/15 19:27, Jan Hazenberg wrote:
 Daniel,

 No i do not use the lcr module. It is kamailio 4.2.1 running on ubuntu
 server Ubuntu 14.04.1 LTS

 Packages are installed from from the http://deb.kamailio.org/kamailio
 repository

 Jan

 Daniel-Constantin Mierla schreef op 2015-01-07 00:29:
 Hello,

 what operating system are you using? How did you install kamailio, from
 sources or packages?

 Is lcr module used as well?

 Cheers,
 Daniel

 On 06/01/15 21:53, Jan Hazenberg wrote:
 Hi,

 I'm trying to use a custom table for the permissions module and run
 into a issue with the tag field, all other fields seem to work fine.

 Here is my config:

 modparam(permissions, db_url, DBURL)
 modparam(permissions, db_mode, 1)
 modparam(permissions, peer_tag_avp, $avp(permissions_tag))
 modparam(permissions, trusted_table, trunks)
 modparam(permissions, source_col, ip)
 modparam(permissions, proto_col, transport)
 modparam(permissions, from_col, from_pattern)
 modparam(permissions, tag_col, trunk_uuid)

 When i start kamailio i see the following error in the log:

 Jan  6 21:49:57 sip /usr/sbin/kamailio[24327]: ERROR: db_mysql
 [km_dbase.c:123]: db_mysql_submit_query(): driver error on query:
 Unknown column 'trunk_uuid' in 'field list'
 Jan  6 21:49:57 sip /usr/sbin/kamailio[24327]: ERROR: core
 [db_query.c:132]: db_do_query_internal(): error while submitting query
 Jan  6 21:49:57 sip /usr/sbin/kamailio[24327]: ERROR: permissions
 [address.c:112]: reload_address_table(): failed to query database
 Jan  6 21:49:57 sip /usr/sbin/kamailio[24327]: CRITICAL: permissions
 [address.c:363]: init_addresses(): reload of address table failed
 Jan  6 21:49:57 sip /usr/sbin/kamailio[24327]: ERROR: permissions
 [permissions.c:631]: mod_init(): failed to initialize the
 allow_address function
 Jan  6 21:49:57 sip /usr/sbin/kamailio[24327]: ERROR: core
 [sr_module.c:968]: init_mod(): Error while initializing module
 permissions (/usr/lib/x86_64-linux-gnu/kamailio/modules/permissions.so)
 Jan  6 21:49:58 sip kamailio: ERROR: core [daemonize.c:315]:
 daemonize(): Main process exited before writing to pipe


 If i change the tag_col to tag it works fine, both fields are
 varchar(64). And the field trunk_uuid exists in the trunks table.

 I'm running kamailio 4.2.1

 Thanks,

 Jan Hazenberg

 ___
 SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
 sr-users@lists.sip-router.org
 http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

 ___
 SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
 sr-users@lists.sip-router.org
 http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda


___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] Redirect Server Including Path/Recieved Information

2015-01-09 Thread Asgaroth

Hi,

I am hoping to have the redirect server not be in the signalling path, 
so when a media server asterisk/freeswitch sends an invite over to the 
redirect server, I need to respond with the 302 and include the contact 
information, outbound path (via proxy loadbalancer) and the recieved 
information to let the proxy/loadbalancer know where to forward to.


So when a client registers it comes in like this:

UAC -- Firewall -- Proxy -- Registrar

At this point the registrar stores the recieved host:port of firewall, 
and path via the proxy.


When I send a redirect, I want the media server to travers the path via 
the route the uac registered with:


uas invite -- redirect server
uas-- 302
uas invite -- proxy (path) -- firewall (recieved) -- uac

I am not sure how to provide the path information in the 302 response. I 
tried to add it as a madd parameter in the contact header but it then 
uses the port defined in the host part of the uri as the proxy port. I 
cant seem to find a reference as to how to do this.


for example, uac is registered with following info (info manipulated to 
protect the poor :) ) and pulled from location table:


Contact: 
sip:username@192.168.1.150:55023;rinstance=9dc7a3f0e662b2cd;transport=UDP

Recieved: sip:213.146.165.189:20185
Path: sip:77.87.89.91;lr;received=sip:213.146.165.189:20185

I tried to perform a redirect with the following information in the contact

Contact: 
sip:username@192.168.1.150:55023;rinstance=9dc7a3f0e662b2cd;transport=UDP;received=sip:213.146.165.189:20185,maddr=77.87.89.91


The problem here is that the media server attempts to send the new 
invite to port 55023 at the host specified by the maddr (77.87.89.91) 
parameter.


I did some more reading this morning and I can see that the rfc says 
that the new invite should be relayed in this manner.


How would I specify the equivilent of $du in a 302 response message?

I hope that explains it a little better.

Thanks


On 09/01/2015 13:14, Daniel-Constantin Mierla wrote:

Hello,

I am not sure if path and received from location will be of any
information for the redirect. At least received is the proto, source and
port of incoming REGISTER. Then, the Path is to be used by location
server when forwarding requests.

Can you give more details of how path and received from location should
be used by the one receiving the 30x redirect?

Cheers,
Daniel

On 08/01/15 22:09, Asgaroth wrote:

Hi All,

I am attempting to setup a standalone redirect server which will
lookup contact info and redirect to appropriate outbound proxy.

The problem I am having is that the registrar is storing the path and
recieved information, however, when I perform a lookup and reply with
302, the recieved and path information is not included.

Are there module parameters in the registrar module that will include
these contact parameters (recieved) or create the appropriate headers
(path/route) in the 302 response, or, is this something I need to do
manually.

Currently I have the following lookup code:

route {

   t_check_trans();

   if ( method == INVITE ) {
 xlog(route[MAIN] : $rm : ruri=$ru);
 xlog(route[MAIN] : $rm : lookup=sip:$rU@registered.domain);
 if ( lookup(location, sip:$rU@registered.domain) ) {
   send_reply(302, Moved Temporarily);
   exit;
 }
   }
}

I had a look at the path_mode parameter but this looks like it only
takes affect for REGISTER methods.

The INVITE that comes in supports the PATH header but I dont see this
being passed back. In fact, I'm not entirely sure if the path header
is a supported header in the 302 response message. I had a quick
google and I cant seem to easily find what headers are suported in the
302 message, and where I need to put the path/recieved information. I
presume I can add the recieved info as a parameter to the contact
header, but how would i specify the outbound proxy to use, would that
be in a route or a path header in the 302 response?

I can see that the $du pseudo variable is set with the appropriate
outbound path and received information, now I just need to include
this information in the 302 response.

Any suggestions/comments to assist in how I get this info into the 302
message would be greatly appreciated.

Thanks in advance.


___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users



___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] Redirect Server Including Path/Recieved Information

2015-01-09 Thread Daniel-Constantin Mierla
Hello,

I am not sure if path and received from location will be of any
information for the redirect. At least received is the proto, source and
port of incoming REGISTER. Then, the Path is to be used by location
server when forwarding requests.

Can you give more details of how path and received from location should
be used by the one receiving the 30x redirect?

Cheers,
Daniel

On 08/01/15 22:09, Asgaroth wrote:
 Hi All,

 I am attempting to setup a standalone redirect server which will
 lookup contact info and redirect to appropriate outbound proxy.

 The problem I am having is that the registrar is storing the path and
 recieved information, however, when I perform a lookup and reply with
 302, the recieved and path information is not included.

 Are there module parameters in the registrar module that will include
 these contact parameters (recieved) or create the appropriate headers
 (path/route) in the 302 response, or, is this something I need to do
 manually.

 Currently I have the following lookup code:

 route {

   t_check_trans();

   if ( method == INVITE ) {
 xlog(route[MAIN] : $rm : ruri=$ru);
 xlog(route[MAIN] : $rm : lookup=sip:$rU@registered.domain);
 if ( lookup(location, sip:$rU@registered.domain) ) {
   send_reply(302, Moved Temporarily);
   exit;
 }
   }
 }

 I had a look at the path_mode parameter but this looks like it only
 takes affect for REGISTER methods.

 The INVITE that comes in supports the PATH header but I dont see this
 being passed back. In fact, I'm not entirely sure if the path header
 is a supported header in the 302 response message. I had a quick
 google and I cant seem to easily find what headers are suported in the
 302 message, and where I need to put the path/recieved information. I
 presume I can add the recieved info as a parameter to the contact
 header, but how would i specify the outbound proxy to use, would that
 be in a route or a path header in the 302 response?

 I can see that the $du pseudo variable is set with the appropriate
 outbound path and received information, now I just need to include
 this information in the 302 response.

 Any suggestions/comments to assist in how I get this info into the 302
 message would be greatly appreciated.

 Thanks in advance.


 ___
 SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
 sr-users@lists.sip-router.org
 http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

-- 
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda


___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] dialog timeout reinvite

2015-01-09 Thread Daniel-Constantin Mierla
Hello,

ok, thanks for reporting. I backported the patch to 4.2 branch.

Cheers,
Daniel


On 09/01/15 03:37, Kelvin Chua wrote:
 Hi Daniel,

 Thanks for the patch. working perfectly
 Kelvin Chua


 On Thu, Jan 8, 2015 at 5:32 AM, Daniel-Constantin Mierla
 mico...@gmail.com wrote:
 On 07/01/15 12:24, Kelvin Chua wrote:
 thanks for the tip, i'm using 4.1
 what i did was to catch the reinvite and compute the remaining timeout
 and set it again using dlg_set_timeout
 tedious but does the job well.

 i am struggling with another dialog timeout related issue though.
 when i set dlg_manage(), t_relay, then the call fails, i retry using
 another route.
 rates are not the same so i need to update the timeout.
 but this time, i am not able to update the timeout using the avp,
 dialog module ignores the new timeout
 and uses the old timeout. I tried using is_known_dialog and
 dlg_set_timeout but it complains of bogus dialog.
 any ideas?
 Can you try with the next patch and dlg_set_timeout()?

 https://github.com/kamailio/kamailio/commit/a41eab6bedf670f9f34f069b82a85c3a49c5e1bd

 It proves to work fine, it will be backported.

 Cheers,
 Daniel

 Kelvin Chua


 On Fri, Jan 2, 2015 at 1:35 AM, Federico Cabiddu
 federico.cabi...@gmail.com wrote:
 Hi,
 You can use the timeout_noreset parameter of the dialog module:
 http://www.kamailio.org/docs/modules/devel/modules/dialog.html#idp16963672.

 Regards,

 Federico

 On 1 Jan 2015 17:27, Kelvin Chua kel...@gmail.com wrote:
 Happy new year everyone! :)

 I have stumbled into a case where a switch would send a reinvite to my
 kamailio server every 15 minutes.

 I am setting dialog timeout using avp for prepaid purposes. now i think it
 resets the timer upon processing of the reinvite. what is the best way to
 work around this?

 ___
 SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
 sr-users@lists.sip-router.org
 http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

 ___
 SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
 sr-users@lists.sip-router.org
 http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

 ___
 SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
 sr-users@lists.sip-router.org
 http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
 --
 Daniel-Constantin Mierla
 http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda


-- 
Daniel-Constantin Mierla
http://twitter.com/#!/miconda - http://www.linkedin.com/in/miconda


___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] Redirect Server Including Path/Recieved Information

2015-01-09 Thread Ben Langfeld
For the ease of future reference, it would appear that post was
http://sr-dev.sip-router.narkive.com/bfyDpQ36/git-alexh-master-core-modules-tm-modules-sl-make-adding-path-and-flags-to-redirected-contacts#post4

On 9 January 2015 at 09:32, Alex Hermann a...@speakup.nl wrote:

 On Thursday 08 January 2015, Asgaroth wrote:
  I am attempting to setup a standalone redirect server which will lookup
  contact info and redirect to appropriate outbound proxy.
 
  The problem I am having is that the registrar is storing the path and
  recieved information, however, when I perform a lookup and reply with
  302, the recieved and path information is not included.

 snip

  Any suggestions/comments to assist in how I get this info into the 302
  message would be greatly appreciated.

 See my messages from 2011-08-08 on sr-dev mailinglist. It has an
 implementation for this.

 [sr-dev] git:alexh/master: core modules/tm modules/sl: Make adding path and
 flags to redirected contacts optional

 --
 Greetings,

 Alex Hermann


 ___
 SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
 sr-users@lists.sip-router.org
 http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users


Re: [SR-Users] Redirect Server Including Path/Recieved Information

2015-01-09 Thread Asgaroth

Hi,

The media server, redirect server and proxy/loadbalancer are all on the 
same local LAN, signaling is direct in local LAN, between media server 
and redirect server, and again from media server to proxy loadbalancer.


Thanks


On 09/01/2015 14:22, Daniel-Constantin Mierla wrote:

Hello,

where is the media server located and the signaling flow for it?

Cheers,
Daniel

On 09/01/15 14:41, Asgaroth wrote:

Hi,

I am hoping to have the redirect server not be in the signalling path,
so when a media server asterisk/freeswitch sends an invite over to the
redirect server, I need to respond with the 302 and include the
contact information, outbound path (via proxy loadbalancer) and the
recieved information to let the proxy/loadbalancer know where to
forward to.

So when a client registers it comes in like this:

UAC -- Firewall -- Proxy -- Registrar

At this point the registrar stores the recieved host:port of firewall,
and path via the proxy.

When I send a redirect, I want the media server to travers the path
via the route the uac registered with:

uas invite -- redirect server
uas-- 302
uas invite -- proxy (path) -- firewall (recieved) -- uac

I am not sure how to provide the path information in the 302 response.
I tried to add it as a madd parameter in the contact header but it
then uses the port defined in the host part of the uri as the proxy
port. I cant seem to find a reference as to how to do this.

for example, uac is registered with following info (info manipulated
to protect the poor :) ) and pulled from location table:

Contact:
sip:username@192.168.1.150:55023;rinstance=9dc7a3f0e662b2cd;transport=UDP
Recieved: sip:213.146.165.189:20185
Path: sip:77.87.89.91;lr;received=sip:213.146.165.189:20185

I tried to perform a redirect with the following information in the
contact

Contact:
sip:username@192.168.1.150:55023;rinstance=9dc7a3f0e662b2cd;transport=UDP;received=sip:213.146.165.189:20185,maddr=77.87.89.91

The problem here is that the media server attempts to send the new
invite to port 55023 at the host specified by the maddr (77.87.89.91)
parameter.

I did some more reading this morning and I can see that the rfc says
that the new invite should be relayed in this manner.

How would I specify the equivilent of $du in a 302 response message?

I hope that explains it a little better.

Thanks


On 09/01/2015 13:14, Daniel-Constantin Mierla wrote:

Hello,

I am not sure if path and received from location will be of any
information for the redirect. At least received is the proto, source and
port of incoming REGISTER. Then, the Path is to be used by location
server when forwarding requests.

Can you give more details of how path and received from location should
be used by the one receiving the 30x redirect?

Cheers,
Daniel

On 08/01/15 22:09, Asgaroth wrote:

Hi All,

I am attempting to setup a standalone redirect server which will
lookup contact info and redirect to appropriate outbound proxy.

The problem I am having is that the registrar is storing the path and
recieved information, however, when I perform a lookup and reply with
302, the recieved and path information is not included.

Are there module parameters in the registrar module that will include
these contact parameters (recieved) or create the appropriate headers
(path/route) in the 302 response, or, is this something I need to do
manually.

Currently I have the following lookup code:

route {

t_check_trans();

if ( method == INVITE ) {
  xlog(route[MAIN] : $rm : ruri=$ru);
  xlog(route[MAIN] : $rm : lookup=sip:$rU@registered.domain);
  if ( lookup(location, sip:$rU@registered.domain) ) {
send_reply(302, Moved Temporarily);
exit;
  }
}
}

I had a look at the path_mode parameter but this looks like it only
takes affect for REGISTER methods.

The INVITE that comes in supports the PATH header but I dont see this
being passed back. In fact, I'm not entirely sure if the path header
is a supported header in the 302 response message. I had a quick
google and I cant seem to easily find what headers are suported in the
302 message, and where I need to put the path/recieved information. I
presume I can add the recieved info as a parameter to the contact
header, but how would i specify the outbound proxy to use, would that
be in a route or a path header in the 302 response?

I can see that the $du pseudo variable is set with the appropriate
outbound path and received information, now I just need to include
this information in the 302 response.

Any suggestions/comments to assist in how I get this info into the 302
message would be greatly appreciated.

Thanks in advance.


___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users@lists.sip-router.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users



___
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users 

Re: [SR-Users] Redirect Server Including Path/Recieved Information

2015-01-09 Thread Daniel-Constantin Mierla
Hello,

I saw others commenting regarding some patch -- not sure if merged or not.

But, if there is no other specific requirement to get the 30x to media
server (like extra processing on received contact), an option could be
to just forward on the 'redirect' server without doing the
record_route(). It means the 'redirect' server is involved only for
first INVITE of the call, everything else is media server to proxy load
balancer.

Cheers,
Daniel

On 09/01/15 15:43, Asgaroth wrote:
 Hi,

 The media server, redirect server and proxy/loadbalancer are all on
 the same local LAN, signaling is direct in local LAN, between media
 server and redirect server, and again from media server to proxy
 loadbalancer.

 Thanks


 On 09/01/2015 14:22, Daniel-Constantin Mierla wrote:
 Hello,

 where is the media server located and the signaling flow for it?

 Cheers,
 Daniel

 On 09/01/15 14:41, Asgaroth wrote:
 Hi,

 I am hoping to have the redirect server not be in the signalling path,
 so when a media server asterisk/freeswitch sends an invite over to the
 redirect server, I need to respond with the 302 and include the
 contact information, outbound path (via proxy loadbalancer) and the
 recieved information to let the proxy/loadbalancer know where to
 forward to.

 So when a client registers it comes in like this:

 UAC -- Firewall -- Proxy -- Registrar

 At this point the registrar stores the recieved host:port of firewall,
 and path via the proxy.

 When I send a redirect, I want the media server to travers the path
 via the route the uac registered with:

 uas invite -- redirect server
 uas-- 302
 uas invite -- proxy (path) -- firewall (recieved) -- uac

 I am not sure how to provide the path information in the 302 response.
 I tried to add it as a madd parameter in the contact header but it
 then uses the port defined in the host part of the uri as the proxy
 port. I cant seem to find a reference as to how to do this.

 for example, uac is registered with following info (info manipulated
 to protect the poor :) ) and pulled from location table:

 Contact:
 sip:username@192.168.1.150:55023;rinstance=9dc7a3f0e662b2cd;transport=UDP

 Recieved: sip:213.146.165.189:20185
 Path: sip:77.87.89.91;lr;received=sip:213.146.165.189:20185

 I tried to perform a redirect with the following information in the
 contact

 Contact:
 sip:username@192.168.1.150:55023;rinstance=9dc7a3f0e662b2cd;transport=UDP;received=sip:213.146.165.189:20185,maddr=77.87.89.91


 The problem here is that the media server attempts to send the new
 invite to port 55023 at the host specified by the maddr (77.87.89.91)
 parameter.

 I did some more reading this morning and I can see that the rfc says
 that the new invite should be relayed in this manner.

 How would I specify the equivilent of $du in a 302 response message?

 I hope that explains it a little better.

 Thanks


 On 09/01/2015 13:14, Daniel-Constantin Mierla wrote:
 Hello,

 I am not sure if path and received from location will be of any
 information for the redirect. At least received is the proto,
 source and
 port of incoming REGISTER. Then, the Path is to be used by location
 server when forwarding requests.

 Can you give more details of how path and received from location
 should
 be used by the one receiving the 30x redirect?

 Cheers,
 Daniel

 On 08/01/15 22:09, Asgaroth wrote:
 Hi All,

 I am attempting to setup a standalone redirect server which will
 lookup contact info and redirect to appropriate outbound proxy.

 The problem I am having is that the registrar is storing the path and
 recieved information, however, when I perform a lookup and reply with
 302, the recieved and path information is not included.

 Are there module parameters in the registrar module that will include
 these contact parameters (recieved) or create the appropriate headers
 (path/route) in the 302 response, or, is this something I need to do
 manually.

 Currently I have the following lookup code:

 route {

 t_check_trans();

 if ( method == INVITE ) {
   xlog(route[MAIN] : $rm : ruri=$ru);
   xlog(route[MAIN] : $rm : lookup=sip:$rU@registered.domain);
   if ( lookup(location, sip:$rU@registered.domain) ) {
 send_reply(302, Moved Temporarily);
 exit;
   }
 }
 }

 I had a look at the path_mode parameter but this looks like it only
 takes affect for REGISTER methods.

 The INVITE that comes in supports the PATH header but I dont see this
 being passed back. In fact, I'm not entirely sure if the path header
 is a supported header in the 302 response message. I had a quick
 google and I cant seem to easily find what headers are suported in
 the
 302 message, and where I need to put the path/recieved information. I
 presume I can add the recieved info as a parameter to the contact
 header, but how would i specify the outbound proxy to use, would that
 be in a route or a path header in the 302 response?

 I can see that the $du pseudo variable is set 

Re: [SR-Users] Can't start Kamailio with both db_postgres and tls

2015-01-09 Thread Øyvind Kolbu


On 07.01.2015 14:27, Daniel-Constantin Mierla wrote:

So it complains that the ssl lib is not initialized completely.

Can you try the following:

- edit modules/tls/tls_init.c and add at the beginning of function 'int
init_tls_h(void)':

if(tls_mod_initialized  0) return 0;

- in modules/db_postgres/km_pg_con.c, add:

#include ../../tls_hooks_init.h

- then in same file, before the line you added with PQinitSSL(0); add:

init_tls();

Recompile, reinstall, restart and test only with tls module loaded
before the db_postgres.

Let's see the results and then I will make a proper patch if works.



Crashed again, this time with core dump. Used the following patch:
--- modules/db_postgres/km_pg_con.c.orig2015-01-09 
15:39:02.411067822 +0100

+++ modules/db_postgres/km_pg_con.c 2015-01-09 15:40:32.980577115 +0100
@@ -29,6 +29,7 @@
 #include ../../mem/mem.h
 #include ../../dprint.h
 #include ../../ut.h
+#include ../../tls_hooks_init.h
 #include string.h
 #include time.h

@@ -74,6 +75,9 @@
ZSW(id-database));
}

+init_tls();
+PQinitSSL(0);
+
ptr-con = PQsetdbLogin(id-host, ports, NULL, NULL, 
id-database, id-username, id-password);

LM_DBG(PQsetdbLogin(%p)\n, ptr-con);

--- modules/tls/tls_init.c.orig 2015-01-09 15:37:16.268298551 +0100
+++ modules/tls/tls_init.c  2015-01-09 15:38:31.924559696 +0100
@@ -498,6 +498,8 @@
str s;
cfg_ctx_t* cfg_ctx;

+if(tls_mod_initialized  0) return 0;
+
 #if OPENSSL_VERSION_NUMBER  0x00907000L
WARN(You are using an old version of OpenSSL ( 0.9.7). 
Upgrade!\n);

 #endif

And got this message:
/usr/sbin/kamailio[22789]: INFO: tls [tls_mod.c:346]: mod_init(): With 
ECDH-Support!
/usr/sbin/kamailio[22789]: INFO: tls [tls_mod.c:349]: mod_init(): With 
Diffie Hellman
/usr/sbin/kamailio[22789]: INFO: ldap [ldap_mod.c:246]: mod_init(): 
OpenLDAP - 20439
/usr/sbin/kamailio[22789]: INFO: rr [../outbound/api.h:54]: 
ob_load_api(): Failed to import bind_ob
/usr/sbin/kamailio[22789]: INFO: rr [rr_mod.c:159]: mod_init(): outbound 
module not available
/usr/sbin/kamailio[22789]: INFO: usrloc [hslot.c:53]: ul_init_locks(): 
locks array size 512
/usr/sbin/kamailio[22789]: INFO: tls [tls_init.c:551]: init_tls_h(): 
tls: _init_tls_h:  compiled  with  openssl  version OpenSSL 1.0.1e-fips 
11 Feb 2013 (0x1000105f), kerberos support: on, compression: on [...]
/usr/sbin/kamailio[22789]: : core [pt.c:164]: get_max_procs(): BUG: 
get_max_procs() called too early (it must _not_ be called from mod_init())


and the following backtrace:
#0  0x003196e32625 in raise () from /lib64/libc.so.6
#1  0x003196e33e05 in abort () from /lib64/libc.so.6
#2  0x0049138f in get_max_procs () at pt.c:165
#3  0x7f8ca8655106 in init_tls_h () at tls_init.c:598
#4  0x005372b9 in init_tls () at tls_hooks.c:70
#5  0x7f8c9fffb655 in db_postgres_new_connection (id=0x7f8ca8d7d0b0)
at km_pg_con.c:78
#6  0x7f8c9fbd0eaa in db_do_init2 (url=0x7f8c9ca52cd0,
new_connection=0x7f8c9fffac47 db_postgres_new_connection,
pooling=DB_POOLING_PERMITTED) at db.c:320
#7  0x7f8c9fbd06d5 in db_do_init (url=0x7f8c9ca52cd0,
new_connection=0x7f8c9fffac47 db_postgres_new_connection) at db.c:273
#8  0x7f8c9fff4bbc in db_postgres_init (_url=0x7f8c9ca52cd0)
at km_dbase.c:133
#9  0x7f8c9c81429f in dlg_connect_db (db_url=0x7f8c9ca52cd0)
at dlg_db_handler.c:132
#10 0x7f8c9c814457 in init_dlg_db (db_url=0x7f8c9ca52cd0,
dlg_hash_size=4096, db_update_period=60, fetch_num_rows=200)
at dlg_db_handler.c:146
#11 0x7f8c9c80c7cd in mod_init () at dialog.c:700
#12 0x004f884d in init_mod (m=0x7f8ca88e82d8) at sr_module.c:967
#13 0x004f8703 in init_mod (m=0x7f8ca88e8f98) at sr_module.c:964
#14 0x004f8703 in init_mod (m=0x7f8ca88e94c0) at sr_module.c:964


(gdb) bt full
#0  0x003196e32625 in raise () from /lib64/libc.so.6
No symbol table info available.
#1  0x003196e33e05 in abort () from /lib64/libc.so.6
No symbol table info available.
#2  0x0049138f in get_max_procs () at pt.c:165
__FUNCTION__ = get_max_procs
#3  0x7f8ca8655106 in init_tls_h () at tls_init.c:598
ssl_version = 268439647
lib_kerberos = 1
lib_zlib = 1
kerberos_support = 1
comp_support = 1
lib_cflags = 0x319a1dede0 compiler: gcc -fPIC -DOPENSSL_PIC 
-DZLIB -DOPENSSL_THREADS -D_REENTRANT -DDSO_DLFCN -DHAVE_DLFCN_H 
-DKRB5_MIT -m64 -DL_ENDIAN -DTERMIO -Wall -O2 -g -pipe -Wall 
-Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fs...

low_mem_threshold1 = -1
low_mem_threshold2 = -1
tls_grp = {s = 0x7fffcec76560 \025, len = 0}
s = {s = 0x7f8ca0010660 db_postgres_new_connection,
  len = -1462250968}
cfg_ctx = 0x7f8ca0010378
__FUNCTION__ = init_tls_h
#4  0x005372b9 in init_tls () at tls_hooks.c:70


#5  0x7f8c9fffb655 in db_postgres_new_connection (id=0x7f8ca8d7d0b0)