aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rw-r--r--main/kamailio/0001-musl-fixes.patch22
-rw-r--r--main/kamailio/0002-mohqueue-v0-11.patch828
-rw-r--r--main/kamailio/0003-kamdbctl-backslash.patch (renamed from main/kamailio/kamailio-4.2-backslash.patch)9
-rw-r--r--main/kamailio/APKBUILD87
-rw-r--r--main/kamailio/DMQ-multi-notify.patch370
-rw-r--r--main/kamailio/default_ctl.patch91
-rw-r--r--main/kamailio/kamailio-4.2-ipops-srv-query.patch659
7 files changed, 436 insertions, 1630 deletions
diff --git a/main/kamailio/0001-musl-fixes.patch b/main/kamailio/0001-musl-fixes.patch
index 752469e20..0b1da859f 100644
--- a/main/kamailio/0001-musl-fixes.patch
+++ b/main/kamailio/0001-musl-fixes.patch
@@ -1,8 +1,8 @@
diff --git a/modules/ldap/ld_session.h b/modules/ldap/ld_session.h
-index 03a4ea5..de7bc0b 100644
+index 08a752c..0591f79 100644
--- a/modules/ldap/ld_session.h
+++ b/modules/ldap/ld_session.h
-@@ -33,6 +33,7 @@
+@@ -28,6 +28,7 @@
#ifndef LD_SESSION_H
#define LD_SESSION_H
@@ -11,7 +11,7 @@ index 03a4ea5..de7bc0b 100644
#include "iniparser.h"
diff --git a/modules/seas/event_dispatcher.c b/modules/seas/event_dispatcher.c
-index d10cffe..8e1a56a 100644
+index e0e79c7..6a3f800 100644
--- a/modules/seas/event_dispatcher.c
+++ b/modules/seas/event_dispatcher.c
@@ -25,7 +25,7 @@
@@ -24,10 +24,10 @@ index d10cffe..8e1a56a 100644
#include <time.h>/*time*/
#include <string.h>/*memcmp*/
diff --git a/modules/tls/tls_server.c b/modules/tls/tls_server.c
-index cfd09c4..0a27433 100644
+index 3f87fc8..68185ad 100644
--- a/modules/tls/tls_server.c
+++ b/modules/tls/tls_server.c
-@@ -33,7 +33,7 @@
+@@ -26,7 +26,7 @@
*/
@@ -37,10 +37,10 @@ index cfd09c4..0a27433 100644
#include <openssl/ssl.h>
#include "../../dprint.h"
diff --git a/tsend.c b/tsend.c
-index 3a18502..99f0c21 100644
+index f6f39f4..ce1e5f0 100644
--- a/tsend.c
+++ b/tsend.c
-@@ -43,7 +43,7 @@
+@@ -27,7 +27,7 @@
#include <string.h>
#include <errno.h>
@@ -49,10 +49,10 @@ index 3a18502..99f0c21 100644
#include <sys/types.h>
#include <sys/socket.h>
-diff --git a/utils/sercmd/sercmd.c b/utils/sercmd/sercmd.c
-index fb9c0a3..717a78d 100644
---- a/utils/sercmd/sercmd.c
-+++ b/utils/sercmd/sercmd.c
+diff --git a/utils/kamcmd/kamcmd.c b/utils/kamcmd/kamcmd.c
+index 86d8fc4..ae16743 100644
+--- a/utils/kamcmd/kamcmd.c
++++ b/utils/kamcmd/kamcmd.c
@@ -49,6 +49,7 @@
#include <netdb.h> /* gethostbyname */
#include <fcntl.h>
diff --git a/main/kamailio/0002-mohqueue-v0-11.patch b/main/kamailio/0002-mohqueue-v0-11.patch
index f6285a56b..f47e9f682 100644
--- a/main/kamailio/0002-mohqueue-v0-11.patch
+++ b/main/kamailio/0002-mohqueue-v0-11.patch
@@ -1,38 +1,44 @@
+diff --git a/modules/mohqueue/Makefile b/modules/mohqueue/Makefile
+index 8351c02..f10bb40 100644
+--- a/modules/mohqueue/Makefile
++++ b/modules/mohqueue/Makefile
+@@ -1,5 +1,6 @@
++# $Id$
+ #
+-# mohqueue module makefile
++# msgqueue module makefile
+ #
+ #
+ # WARNING: do not run this directly, it should be run by the master Makefile
+diff --git a/modules/mohqueue/NOTES b/modules/mohqueue/NOTES
+index 0741d9f..ef2fbb6 100644
--- a/modules/mohqueue/NOTES
+++ b/modules/mohqueue/NOTES
@@ -1,6 +1,9 @@
--Things to look into:
--
--* RFC3261, section 12.1.1 requires UAS to copy Record-Route
--* Check to see if any memory leaks.
--* Should probably respond when caller says BYE after queue says BYE.
--* check RAck number
-+Things to look into:
-+
-+* RFC3261, section 12.1.1 requires UAS to copy Record-Route
+ Things to look into:
+
+ * RFC3261, section 12.1.1 requires UAS to copy Record-Route
+
-+* Check to see if any memory leaks.
+ * Check to see if any memory leaks.
+
-+* Should probably respond when caller says BYE after queue says BYE.
+ * Should probably respond when caller says BYE after queue says BYE.
+-* check RAck number
+
+* check RAck number
\ No newline at end of file
+diff --git a/modules/mohqueue/mohq.c b/modules/mohqueue/mohq.c
+index 711f3fe..bc54aca 100644
--- a/modules/mohqueue/mohq.c
+++ b/modules/mohqueue/mohq.c
-@@ -1,10 +1,8 @@
+@@ -1,6 +1,5 @@
/*
-- * $Id$
+- *
+- * Copyright (C) 2013 Robert Boisvert
+ * Copyright (C) 2013-15 Robert Boisvert
*
-- * Copyright (C) 2013 Robert Boisvert
-+ * This file is part of the mohqueue module for Kamailio, a free SIP server.
+ * This file is part of the mohqueue module for Kamailio, a free SIP server.
*
-- * This file is part of the mohqueue module for sip-router, a free SIP server.
-- *
- * The mohqueue module is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
-@@ -61,9 +59,9 @@
+@@ -60,9 +59,9 @@ static cmd_export_t mod_cmds [] = {
};
/* PARAMETERS */
@@ -45,75 +51,93 @@
char *mohdir = "";
int moh_maxcalls = 50;
-@@ -134,81 +132,84 @@
+@@ -133,83 +132,87 @@ return 0;
static int init_cfg (void)
{
+- int error = 0;
+- int bfnd = 0;
+- struct stat psb [1];
+-
+- /**********
+- * db_url, db_ctable, db_qtable exist?
+- **********/
+-
+- if (!db_url.s || db_url.len<=0)
+int bfnd = 0;
+int berror = 0;
+struct stat psb [1];
+
- /**********
- * db_url, db_ctable, db_qtable exist?
- **********/
-
-- if (!db_url.s || db_url.len<=0)
++/**********
++* db_url, db_ctable, db_qtable exist?
++**********/
++
+if (!db_url.s || db_url.len <= 0)
{
-- LM_ERR ("db_url parameter not set!");
-- return 0;
+- LM_ERR ("db_url parameter not set!\n");
+- error = 1;
+ LM_ERR ("db_url parameter not set!\n");
+ berror = 1;
}
-- pmod_data->pcfg->db_url = db_url;
-
- if (!db_ctable.s || db_ctable.len<=0)
+if (!db_ctable.s || db_ctable.len <= 0)
{
-- LM_ERR ("db_ctable parameter not set!");
-- return 0;
+- LM_ERR ("db_ctable parameter not set!\n");
+- error = 1;
+ LM_ERR ("db_ctable parameter not set!\n");
+ berror = 1;
}
-- pmod_data->pcfg->db_ctable = db_ctable;
-
- if (!db_qtable.s || db_qtable.len<=0)
+if (!db_qtable.s || db_qtable.len <= 0)
{
-- LM_ERR ("db_qtable parameter not set!");
-- return 0;
+- LM_ERR ("db_qtable parameter not set!\n");
+- error = 1;
+- }
+-
+- /**********
+- * mohdir
+- * o exists?
+- * o directory?
+- **********/
+-
+- if (!*mohdir) {
+- LM_ERR ("mohdir parameter not set!\n");
+- error = 1;
+- } else if (strlen(mohdir) > MOHDIRLEN) {
+- LM_ERR ("mohdir too long!");
+- error = 1;
+ LM_ERR ("db_qtable parameter not set!\n");
+ berror = 1;
}
-- pmod_data->pcfg->db_qtable = db_qtable;
-
--
- /**********
- * mohdir
- * o exists?
- * o directory?
- **********/
-
-- if (!*mohdir)
+- if (moh_maxcalls < 1 || moh_maxcalls > 5000)
++
++/**********
++* mohdir
++* o exists?
++* o directory?
++**********/
++
+if (!*mohdir)
{
-- LM_ERR ("mohdir parameter not set!");
-- return 0;
+- LM_ERR ("moh_maxcalls not in range of 1-5000!");
+- error = 1;
+ LM_ERR ("mohdir parameter not set!\n");
+ berror = 1;
}
-- if (strlen(mohdir) > MOHDIRLEN)
+- if (error == 1) {
+- return 0;
+else if (strlen (mohdir) > MOHDIRLEN)
- {
-- LM_ERR ("mohdir too long!");
-- return 0;
++ {
+ LM_ERR ("mohdir too long!\n");
+ berror = 1;
}
+- pmod_data->pcfg->db_qtable = db_qtable;
+- pmod_data->pcfg->db_ctable = db_ctable;
+- pmod_data->pcfg->db_url = db_url;
- pmod_data->pcfg->mohdir = mohdir;
-
-- int bfnd = 0;
-- struct stat psb [1];
- if (!lstat (mohdir, psb))
+else
{
@@ -125,48 +149,56 @@
+ }
if (!bfnd)
- {
-- LM_ERR ("mohdir is not a directory!");
-- return 0;
+ {
-+ LM_ERR ("mohdir is not a directory!\n");
+ LM_ERR ("mohdir is not a directory!\n");
+- return 0;
+ berror = 1;
+ }
}
- /**********
--* max calls
--* o valid count?
+- /**********
+- * max calls
+- * o valid count?
+- * o alloc memory
+- **********/
++/**********
+* o max calls valid?
- * o alloc memory
++* o alloc memory
+* o save data
- **********/
++**********/
- if (moh_maxcalls < 1 || moh_maxcalls > 5000)
- {
-- LM_ERR ("moh_maxcalls not in range of 1-5000!");
-- return 0;
+- pmod_data->pcall_lst = (call_lst *) shm_malloc (sizeof (call_lst) * moh_maxcalls);
+- if (!pmod_data->pcall_lst) {
+- LM_ERR ("Unable to allocate shared memory");
+- return -1;
++if (moh_maxcalls < 1 || moh_maxcalls > 5000)
++ {
+ LM_ERR ("moh_maxcalls not in range of 1-5000!\n");
+ berror = 1;
}
+- memset (pmod_data->pcall_lst, 0, sizeof (call_lst) * moh_maxcalls);
+- pmod_data->call_cnt = moh_maxcalls;
+- return -1;
+if (berror)
+ { return 0; }
- pmod_data->pcall_lst =
- (call_lst *) shm_malloc (sizeof (call_lst) * moh_maxcalls);
- if (!pmod_data->pcall_lst)
- {
-- LM_ERR ("Unable to allocate shared memory");
-- return -1;
++pmod_data->pcall_lst =
++ (call_lst *) shm_malloc (sizeof (call_lst) * moh_maxcalls);
++if (!pmod_data->pcall_lst)
++ {
+ LM_ERR ("Unable to allocate shared memory!\n");
+ return 0;
- }
++ }
+pmod_data->pcfg->db_url = db_url;
+pmod_data->pcfg->db_ctable = db_ctable;
+pmod_data->pcfg->db_qtable = db_qtable;
+pmod_data->pcfg->mohdir = mohdir;
- memset (pmod_data->pcall_lst, 0, sizeof (call_lst) * moh_maxcalls);
- pmod_data->call_cnt = moh_maxcalls;
- return -1;
-@@ -234,13 +235,13 @@
++memset (pmod_data->pcall_lst, 0, sizeof (call_lst) * moh_maxcalls);
++pmod_data->call_cnt = moh_maxcalls;
++return -1;
+ }
+
+ /**********
+@@ -232,13 +235,13 @@ static int init_db (void)
str *pdb_url = &pmod_data->pcfg->db_url;
if (db_bind_mod (pdb_url, pmod_data->pdb))
{
@@ -182,7 +214,7 @@
return 0;
}
db1_con_t *pconn = mohq_dbconnect ();
-@@ -256,14 +257,14 @@
+@@ -254,14 +257,14 @@ if (!pconn)
if (db_check_table_version (pdb, pconn,
&pmod_data->pcfg->db_ctable, MOHQ_CTABLE_VERSION) < 0)
{
@@ -199,7 +231,7 @@
pmod_data->pcfg->db_qtable.s, pdb_url->s, MOHQ_QTABLE_VERSION);
goto dberr;
}
-@@ -303,7 +304,7 @@
+@@ -301,7 +304,7 @@ if (rank == PROC_INIT || rank == PROC_TCP_MAIN || rank == PROC_MAIN)
{ return 0; }
if (!pmod_data->pdb->init)
{
@@ -208,7 +240,7 @@
return -1;
}
return 0;
-@@ -357,7 +358,7 @@
+@@ -355,7 +358,7 @@ int mod_init (void)
pmod_data = (mod_data *) shm_malloc (sizeof (mod_data));
if (!pmod_data)
{
@@ -217,54 +249,54 @@
return -1;
}
memset (pmod_data, 0, sizeof (mod_data));
-@@ -373,47 +374,59 @@
+@@ -371,47 +374,59 @@ if (!init_db ())
if (sl_load_api (pmod_data->psl))
{
-- LM_ERR ("Unable to load SL module");
+- LM_ERR ("Unable to load SL module\n");
+ LM_ERR ("Unable to load SL module!\n");
goto initerr;
}
if (load_tm_api (pmod_data->ptm))
{
-- LM_ERR ("Unable to load TM module");
+- LM_ERR ("Unable to load TM module\n");
+ LM_ERR ("Unable to load TM module!\n");
goto initerr;
}
if (load_rr_api (pmod_data->prr))
{
-- LM_ERR ("Unable to load RR module");
+- LM_ERR ("Unable to load RR module\n");
+ LM_ERR ("Unable to load RR module!\n");
goto initerr;
}
pmod_data->fn_rtp_answer = find_export ("rtpproxy_answer", 0, 0);
if (!pmod_data->fn_rtp_answer)
{
-- LM_ERR ("Unable to load rtpproxy_answer");
+- LM_ERR ("Unable to load rtpproxy_answer\n");
+ LM_ERR ("Unable to load rtpproxy_answer!\n");
goto initerr;
}
pmod_data->fn_rtp_offer = find_export ("rtpproxy_offer", 0, 0);
if (!pmod_data->fn_rtp_offer)
{
-- LM_ERR ("Unable to load rtpproxy_offer");
+- LM_ERR ("Unable to load rtpproxy_offer\n");
+ LM_ERR ("Unable to load rtpproxy_offer!\n");
goto initerr;
}
pmod_data->fn_rtp_stream_c = find_export ("rtpproxy_stream2uac", 2, 0);
if (!pmod_data->fn_rtp_stream_c)
{
-- LM_ERR ("Unable to load rtpproxy_stream2uac");
+- LM_ERR ("Unable to load rtpproxy_stream2uac\n");
+ LM_ERR ("Unable to load rtpproxy_stream2uac!\n");
goto initerr;
}
pmod_data->fn_rtp_stream_s = find_export ("rtpproxy_stream2uas", 2, 0);
if (!pmod_data->fn_rtp_stream_s)
{
-- LM_ERR ("Unable to load rtpproxy_stream2uas");
+- LM_ERR ("Unable to load rtpproxy_stream2uas\n");
+ LM_ERR ("Unable to load rtpproxy_stream2uas!\n");
- goto initerr;
- }
++ goto initerr;
++ }
+pmod_data->fn_rtp_stop_c = find_export ("rtpproxy_stop_stream2uac", 0, 0);
+if (!pmod_data->fn_rtp_stop_c)
+ {
@@ -275,39 +307,35 @@
+if (!pmod_data->fn_rtp_stop_s)
+ {
+ LM_ERR ("Unable to load rtpproxy_stop_stream2uas!\n");
-+ goto initerr;
-+ }
+ goto initerr;
+ }
pmod_data->fn_rtp_destroy = find_export ("rtpproxy_destroy", 0, 0);
if (!pmod_data->fn_rtp_destroy)
{
-- LM_ERR ("Unable to load rtpproxy_destroy");
+- LM_ERR ("Unable to load rtpproxy_destroy\n");
+ LM_ERR ("Unable to load rtpproxy_destroy!\n");
goto initerr;
}
-@@ -440,4 +453,4 @@
+@@ -438,4 +453,4 @@ if (pmod_data->pcall_lock->plock)
shm_free (pmod_data);
pmod_data = NULL;
return -1;
-}
+}
\ No newline at end of file
+diff --git a/modules/mohqueue/mohq.h b/modules/mohqueue/mohq.h
+index b23e6a3..3d5346b 100644
--- a/modules/mohqueue/mohq.h
+++ b/modules/mohqueue/mohq.h
-@@ -1,10 +1,8 @@
+@@ -1,5 +1,5 @@
/*
-- * $Id$
+- * Copyright (C) 2013 Robert Boisvert
+ * Copyright (C) 2013-15 Robert Boisvert
*
-- * Copyright (C) 2013 Robert Boisvert
-+ * This file is part of the mohqueue module for Kamailio, a free SIP server.
+ * This file is part of the mohqueue module for Kamailio, a free SIP server.
*
-- * This file is part of the mohqueue module for sip-router, a free SIP server.
-- *
- * The mohqueue module is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
-@@ -63,31 +61,35 @@
+@@ -61,31 +61,35 @@ typedef struct
/* call_state values */
#define CLSTA_ENTER 100
@@ -352,7 +380,7 @@
unsigned int call_hash;
unsigned int call_label;
sip_msg_t *call_pmsg;
-@@ -120,6 +122,8 @@
+@@ -118,6 +122,8 @@ typedef struct
cmd_function fn_rtp_offer;
cmd_function fn_rtp_stream_c;
cmd_function fn_rtp_stream_s;
@@ -361,22 +389,26 @@
} mod_data;
/**********
+@@ -127,4 +133,4 @@ typedef struct
+ extern mod_data *pmod_data;
+ extern rtpmap prtpmap [];
+
+-#endif /* MOHQ_H */
++#endif /* MOHQ_H */
+\ No newline at end of file
+diff --git a/modules/mohqueue/mohq_common.h b/modules/mohqueue/mohq_common.h
+index 9103323..10f6249 100644
--- a/modules/mohqueue/mohq_common.h
+++ b/modules/mohqueue/mohq_common.h
-@@ -1,10 +1,8 @@
+@@ -1,6 +1,5 @@
/*
-- * $Id$
+- *
+- * Copyright (C) 2013 Robert Boisvert
+ * Copyright (C) 2013-15 Robert Boisvert
*
-- * Copyright (C) 2013 Robert Boisvert
-+ * This file is part of the mohqueue module for Kamailio, a free SIP server.
+ * This file is part of the mohqueue module for Kamailio, a free SIP server.
*
-- * This file is part of the mohqueue module for sip-router, a free SIP server.
-- *
- * The mohqueue module is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
-@@ -53,6 +51,7 @@
+@@ -52,6 +51,7 @@
#include "../../parser/contact/parse_contact.h"
#include "../../parser/parse_expires.h"
#include "../../parser/parse_from.h"
@@ -384,7 +416,7 @@
#include "../../parser/sdp/sdp.h"
/* convenience macros */
-@@ -69,7 +68,7 @@
+@@ -68,7 +68,7 @@
#define MOHQ_STR_APPEND_L( str1, str1_lim, s2, s2_len ) \
if ((str1)->len + (s2_len) >= (str1_lim)) { \
@@ -393,7 +425,7 @@
} else { \
MOHQ_STR_APPEND((str1), (s2), (s2_len)); \
(str1_lim) -= (s2_len); \
-@@ -84,7 +83,7 @@
+@@ -83,7 +83,7 @@
#define MOHQ_STR_APPEND_CSTR_L( str1, str1_lim, cstr1 ) \
if ((str1)->len + strlen(cstr1) >= (str1_lim)) { \
@@ -402,22 +434,25 @@
} else { \
MOHQ_STR_APPEND_CSTR((str1), (cstr1)); \
}
+@@ -100,4 +100,4 @@
+ #define MOHQ_HEADER_EMPTY( hdr1 ) \
+ ((hdr1) == NULL || MOHQ_STR_EMPTY( &(hdr1)->body ))
+
+-#endif /* MOHQ_COMMON_H */
++#endif /* MOHQ_COMMON_H */
+\ No newline at end of file
+diff --git a/modules/mohqueue/mohq_db.c b/modules/mohqueue/mohq_db.c
+index 64ac90e..56e420f 100644
--- a/modules/mohqueue/mohq_db.c
+++ b/modules/mohqueue/mohq_db.c
-@@ -1,10 +1,8 @@
+@@ -1,5 +1,5 @@
/*
-- * $Id$
+- * Copyright (C) 2013 Robert Boisvert
+ * Copyright (C) 2013-15 Robert Boisvert
*
-- * Copyright (C) 2013 Robert Boisvert
-+ * This file is part of the mohqueue module for Kamailio, a free SIP server.
+ * This file is part of the mohqueue module for Kamailio, a free SIP server.
*
-- * This file is part of the mohqueue module for sip-router, a free SIP server.
-- *
- * The mohqueue module is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
-@@ -216,7 +214,7 @@
+@@ -214,7 +214,7 @@ pcall->call_time = time (0);
fill_call_vals (prvals, pcall, CALL_COLCNT);
if (pdb->insert (pconn, prkeys, prvals, CALL_COLCNT) < 0)
{
@@ -426,7 +461,7 @@
pmod_data->pcfg->db_ctable.s);
}
mohq_dbdisconnect (pconn);
-@@ -243,7 +241,7 @@
+@@ -241,7 +241,7 @@ db_func_t *pdb = pmod_data->pdb;
pdb->use_table (pconn, &pmod_data->pcfg->db_ctable);
if (pdb->delete (pconn, 0, 0, 0, 0) < 0)
{
@@ -435,7 +470,7 @@
pmod_data->pcfg->db_ctable.s);
}
return;
-@@ -277,7 +275,7 @@
+@@ -275,7 +275,7 @@ db_val_t prvals [1];
set_call_val (prvals, 0, CALLCOL_CALL, pcall->call_id);
if (pdb->delete (pconn, prkeys, 0, prvals, 1) < 0)
{
@@ -444,16 +479,16 @@
pmod_data->pcfg->db_ctable.s);
}
mohq_dbdisconnect (pconn);
-@@ -297,7 +295,7 @@
+@@ -295,7 +295,7 @@ db1_con_t *mohq_dbconnect (void)
str *pdb_url = &pmod_data->pcfg->db_url;
db1_con_t *pconn = pmod_data->pdb->init (pdb_url);
if (!pconn)
-- { LM_ERR ("Unable to connect to DB %s", pdb_url->s); }
+- { LM_ERR ("Unable to connect to DB %s\n", pdb_url->s); }
+ { LM_ERR ("Unable to connect to DB %s!\n", pdb_url->s); }
return pconn;
}
-@@ -348,7 +346,7 @@
+@@ -346,7 +346,7 @@ db_val_t puvals [1];
fill_call_vals (puvals, pcall, CALLCOL_STATE);
if (pdb->update (pconn, pqkeys, 0, pqvals, pukeys, puvals, 1, 1) < 0)
{
@@ -462,7 +497,7 @@
pmod_data->pcfg->db_ctable.s);
}
mohq_dbdisconnect (pconn);
-@@ -390,7 +388,7 @@
+@@ -388,7 +388,7 @@ puvals->type = DB1_INT;
puvals->nul = 0;
if (pdb->update (pconn, pqkeys, 0, pqvals, pukeys, puvals, 1, 1) < 0)
{
@@ -471,52 +506,7 @@
pmod_data->pcfg->db_qtable.s);
}
mohq_dbdisconnect (pconn);
-@@ -428,7 +426,7 @@
- db1_res_t *presult = NULL;
- if (pdb->query (pconn, 0, 0, 0, prkeys, 0, MOHQ_COLCNT, 0, &presult))
- {
-- LM_ERR ("%stable query (%s) failed!", pfncname,
-+ LM_ERR ("%stable query (%s) failed!\n", pfncname,
- pmod_data->pcfg->db_qtable.s);
- return;
- }
-@@ -449,7 +447,7 @@
- struct sip_uri puri_parsed [1];
- if (parse_uri (puri, strlen (puri), puri_parsed))
- {
-- LM_ERR ("Queue,Field (%s,%.*s): %s is not a valid URI!", pqname,
-+ LM_ERR ("Queue,Field (%s,%.*s): %s is not a valid URI!\n", pqname,
- STR_FMT (&MOHQCSTR_URI), puri);
- continue;
- }
-@@ -477,7 +475,7 @@
- struct stat psb [1];
- if (lstat (pmohdir, psb))
- {
-- LM_ERR ("Queue,Field (%s,%.*s): Unable to find %s!", pqname,
-+ LM_ERR ("Queue,Field (%s,%.*s): Unable to find %s!\n", pqname,
- STR_FMT (&MOHQCSTR_MDIR), pmohdir);
- continue;
- }
-@@ -485,7 +483,7 @@
- {
- if ((psb->st_mode & S_IFMT) != S_IFDIR)
- {
-- LM_ERR ("Queue,Field (%s,%.*s): %s is not a directory!", pqname,
-+ LM_ERR ("Queue,Field (%s,%.*s): %s is not a directory!\n", pqname,
- STR_FMT (&MOHQCSTR_MDIR), pmohdir);
- continue;
- }
-@@ -501,7 +499,7 @@
- (char *)VAL_STRING (prowvals + MOHQCOL_MFILE));
- if (!pmohfiles [0])
- {
-- LM_ERR ("Queue,Field (%s,%.*s): Unable to find MOH files (%s/%s.*)!",
-+ LM_ERR ("Queue,Field (%s,%.*s): Unable to find MOH files (%s/%s.*)!\n",
- pqname, STR_FMT (&MOHQCSTR_MDIR), pmohdir,
- (char *)VAL_STRING (prowvals + MOHQCOL_MFILE));
- continue;
-@@ -525,21 +523,21 @@
+@@ -523,21 +523,21 @@ for (nidx = 0; nidx < nrows; nidx++)
if (strcmp (pqlst [nidx2].mohq_mohdir, pmohdir))
{
strcpy (pqlst [nidx2].mohq_mohdir, pmohdir);
@@ -541,7 +531,7 @@
STR_FMT (&MOHQCSTR_NAME));
}
int bdebug = VAL_INT (prowvals + MOHQCOL_DEBUG) ? MOHQF_DBG : 0;
-@@ -549,7 +547,7 @@
+@@ -547,7 +547,7 @@ for (nidx = 0; nidx < nrows; nidx++)
{ pqlst [nidx2].mohq_flags |= MOHQF_DBG; }
else
{ pqlst [nidx2].mohq_flags &= ~MOHQF_DBG; }
@@ -550,16 +540,7 @@
STR_FMT (&MOHQCSTR_DEBUG));
}
bfnd = -1;
-@@ -576,7 +574,7 @@
- pnewlst = (mohq_lst *) shm_malloc (sizeof (mohq_lst) * nsize);
- if (!pnewlst)
- {
-- LM_ERR ("%sUnable to allocate shared memory!", pfncname);
-+ LM_ERR ("%sUnable to allocate shared memory!\n", pfncname);
- return;
- }
- pmod_data->mohq_cnt = nsize;
-@@ -592,7 +590,7 @@
+@@ -590,7 +590,7 @@ for (nidx = 0; nidx < nrows; nidx++)
(char *)VAL_STRING (prowvals + MOHQCOL_NAME));
if (VAL_INT (prowvals + MOHQCOL_DEBUG))
{ pnewlst [nsize].mohq_flags |= MOHQF_DBG; }
@@ -568,7 +549,7 @@
if (nsize)
{ shm_free (pmod_data->pmohq_lst); }
pmod_data->pmohq_lst = pnewlst;
-@@ -613,7 +611,7 @@
+@@ -611,7 +611,7 @@ for (nidx = 0; nidx < pmod_data->mohq_cnt; nidx++)
if (pqlst [nidx].mohq_flags & MOHQF_CHK)
{ continue; }
@@ -577,36 +558,43 @@
if (nidx != (pmod_data->mohq_cnt - 1))
{
memcpy (&pqlst [nidx], &pqlst [pmod_data->mohq_cnt - 1],
+@@ -621,4 +621,4 @@ for (nidx = 0; nidx < pmod_data->mohq_cnt; nidx++)
+ --nidx;
+ }
+ return;
+-}
++}
+\ No newline at end of file
+diff --git a/modules/mohqueue/mohq_db.h b/modules/mohqueue/mohq_db.h
+index 611d455..c343601 100644
--- a/modules/mohqueue/mohq_db.h
+++ b/modules/mohqueue/mohq_db.h
-@@ -1,9 +1,7 @@
+@@ -1,5 +1,5 @@
/*
-- * $Id$
+- * Copyright (C) 2013 Robert Boisvert
+ * Copyright (C) 2013-15 Robert Boisvert
*
-- * Copyright (C) 2013 Robert Boisvert
-- *
-- * This file is part of the mohqueue module for sip-router, a free SIP server.
-+ * This file is part of the mohqueue module for Kamailio, a free SIP server.
+ * This file is part of the mohqueue module for Kamailio, a free SIP server.
*
- * The mohqueue module is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+@@ -61,4 +61,4 @@ void update_call_rec (call_lst *);
+ void update_debug (mohq_lst *, int);
+ void update_mohq_lst (db1_con_t *pconn);
+
+-#endif /* MOHQ_DB_H */
++#endif /* MOHQ_DB_H */
+\ No newline at end of file
+diff --git a/modules/mohqueue/mohq_funcs.c b/modules/mohqueue/mohq_funcs.c
+index 1d023e6..210f14e 100644
--- a/modules/mohqueue/mohq_funcs.c
+++ b/modules/mohqueue/mohq_funcs.c
-@@ -1,10 +1,8 @@
+@@ -1,5 +1,5 @@
/*
-- * $Id$
+- * Copyright (C) 2013 Robert Boisvert
+ * Copyright (C) 2013-15 Robert Boisvert
*
-- * Copyright (C) 2013 Robert Boisvert
-+ * This file is part of the mohqueue module for Kamailio, a free SIP server.
+ * This file is part of the mohqueue module for Kamailio, a free SIP server.
*
-- * This file is part of the mohqueue module for sip-router, a free SIP server.
-- *
- * The mohqueue module is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
-@@ -34,7 +32,7 @@
+@@ -32,7 +32,7 @@
#define ALLOWHDR "Allow: INVITE, ACK, BYE, CANCEL, NOTIFY, PRACK"
#define CLENHDR "Content-Length"
#define SIPEOL "\r\n"
@@ -615,7 +603,7 @@
/**********
* local constants
-@@ -48,6 +46,7 @@
+@@ -46,6 +46,7 @@ str pinvite [1] = {STR_STATIC_INIT ("INVITE")};
str pmi_nolock [1] = {STR_STATIC_INIT ("Unable to lock queue")};
str pmi_noqueue [1] = {STR_STATIC_INIT ("No matching queue name found")};
str prefer [1] = {STR_STATIC_INIT ("REFER")};
@@ -623,7 +611,7 @@
str presp_noaccept [1] = {STR_STATIC_INIT ("Not Acceptable Here")};
str presp_noallow [1] = {STR_STATIC_INIT ("Method Not Allowed")};
str presp_nocall [1] = {STR_STATIC_INIT ("Call/Transaction Does Not Exist")};
-@@ -57,6 +56,7 @@
+@@ -55,6 +56,7 @@ str presp_reqterm [1] = {STR_STATIC_INIT ("Request Terminated")};
str presp_ring [1] = {STR_STATIC_INIT ("Ringing")};
str psipfrag [1] = {STR_STATIC_INIT ("message/sipfrag")};
str presp_srverr [1] = {STR_STATIC_INIT ("Server Internal Error")};
@@ -631,7 +619,7 @@
str presp_unsupp [1] = {STR_STATIC_INIT ("Unsupported Media Type")};
rtpmap prtpmap [] =
-@@ -88,9 +88,9 @@
+@@ -86,9 +88,9 @@ str pallowhdr [1] = { STR_STATIC_INIT (ALLOWHDR SIPEOL) };
char pbyemsg [] =
{
"%s"
@@ -642,7 +630,7 @@
};
str pextrahdr [1] =
-@@ -100,7 +100,6 @@
+@@ -98,7 +100,6 @@ str pextrahdr [1] =
"Supported: 100rel" SIPEOL
"Accept-Language: en" SIPEOL
"Content-Type: application/sdp" SIPEOL
@@ -650,7 +638,7 @@
)
};
-@@ -118,10 +117,11 @@
+@@ -116,10 +117,11 @@ char pinvitesdp [] =
char prefermsg [] =
{
"%s"
@@ -664,7 +652,7 @@
};
char preinvitemsg [] =
-@@ -131,7 +131,6 @@
+@@ -129,7 +131,6 @@ char preinvitemsg [] =
"Contact: <%s>" SIPEOL
ALLOWHDR SIPEOL
"Supported: 100rel" SIPEOL
@@ -672,7 +660,7 @@
"Accept-Language: en" SIPEOL
"Content-Type: application/sdp" SIPEOL
};
-@@ -153,8 +152,7 @@
+@@ -151,8 +152,7 @@ char prtpsdp [] =
**********/
void delete_call (call_lst *);
@@ -682,7 +670,7 @@
dlg_t *form_dialog (call_lst *, struct to_body *);
int form_rtp_SDP (str *, call_lst *, char *);
static void invite_cb (struct cell *, int, struct tmcb_params *);
-@@ -164,6 +162,7 @@
+@@ -162,6 +162,7 @@ int send_prov_rsp (sip_msg_t *, call_lst *);
int send_rtp_answer (sip_msg_t *, call_lst *);
int search_hdr_ext (struct hdr_field *, str *);
int start_stream (sip_msg_t *, call_lst *, int);
@@ -690,7 +678,7 @@
/**********
* local functions
-@@ -175,10 +174,10 @@
+@@ -173,10 +174,10 @@ int start_stream (sip_msg_t *, call_lst *, int);
* INPUT:
* Arg (1) = SIP message pointer
* Arg (2) = call pointer
@@ -703,16 +691,8 @@
{
/**********
-@@ -195,13 +194,13 @@
- **********/
-
- if (pcall->call_state != CLSTA_INQUEUE)
-- { LM_ERR ("%sUnexpected ACK (%s)!", pfncname, pcall->call_from); }
-+ { LM_ERR ("%sUnexpected ACK (%s)!\n", pfncname, pcall->call_from); }
- else
- {
-- mohq_debug (pcall->pmohq, "%sACK from refused re-INVITE (%s)!",
-+ mohq_debug (pcall->pmohq, "%sACK from refused re-INVITE (%s)!\n",
+@@ -199,7 +200,7 @@ if (pcall->call_state != CLSTA_INVITED)
+ mohq_debug (pcall->pmohq, "%sACK from refused re-INVITE (%s)!\n",
pfncname, pcall->call_from);
}
- return 1;
@@ -720,29 +700,25 @@
}
/**********
-@@ -212,17 +211,17 @@
-
- if (ptm->t_lookup_ident (&ptrans, pcall->call_hash, pcall->call_label) < 0)
+@@ -212,7 +213,7 @@ if (ptm->t_lookup_ident (&ptrans, pcall->call_hash, pcall->call_label) < 0)
{
-- LM_ERR ("%sINVITE transaction missing for call (%s)!",
-+ LM_ERR ("%sINVITE transaction missing for call (%s)!\n",
+ LM_ERR ("%sINVITE transaction missing for call (%s)!\n",
pfncname, pcall->call_from);
- return 1;
+ return;
}
else
{
- if (ptm->t_release (pcall->call_pmsg) < 0)
+@@ -220,7 +221,7 @@ else
{
-- LM_ERR ("%sRelease transaction failed for call (%s)!",
-+ LM_ERR ("%sRelease transaction failed for call (%s)!\n",
+ LM_ERR ("%sRelease transaction failed for call (%s)!\n",
pfncname, pcall->call_from);
- return 1;
+ return;
}
}
pcall->call_hash = pcall->call_label = 0;
-@@ -235,6 +234,47 @@
+@@ -233,6 +234,47 @@ pcall->call_cseq = 1;
mohq_debug (pcall->pmohq,
"%sACK received for call (%s); placed in queue (%s)",
pfncname, pcall->call_from, pcall->pmohq->mohq_name);
@@ -790,25 +766,25 @@
return 1;
}
-@@ -261,7 +301,7 @@
+@@ -259,7 +301,7 @@ char *pfncname = "bye_cb: ";
call_lst *pcall = (call_lst *)*pcbp->param;
if (ntype == TMCB_ON_FAILURE)
{
-- LM_ERR ("%sCall (%s) did not respond to BYE", pfncname,
+- LM_ERR ("%sCall (%s) did not respond to BYE\n", pfncname,
+ LM_ERR ("%sCall (%s) did not respond to BYE!\n", pfncname,
pcall->call_from);
}
else
-@@ -269,7 +309,7 @@
+@@ -267,7 +309,7 @@ else
int nreply = pcbp->code;
if ((nreply / 100) != 2)
{
-- LM_ERR ("%sCall (%s) BYE error (%d)", pfncname,
+- LM_ERR ("%sCall (%s) BYE error (%d)\n", pfncname,
+ LM_ERR ("%sCall (%s) BYE error (%d)!\n", pfncname,
pcall->call_from, nreply);
}
else
-@@ -288,33 +328,43 @@
+@@ -286,33 +328,43 @@ return;
* INPUT:
* Arg (1) = SIP message pointer
* Arg (2) = call pointer
@@ -833,7 +809,7 @@
+ { return; }
+if (pcall->call_state >= CLSTA_INQUEUE)
{
-- LM_ERR ("%sUnable to create reply to call (%s)", pfncname,
+- LM_ERR ("%sUnable to create reply to call (%s)\n", pfncname,
- pcall->call_from);
- return 1;
+ pcall->call_state = CLSTA_BYEOK;
@@ -843,8 +819,7 @@
- { drop_call (pmsg, pcall); }
else
{
-- LM_ERR ("%sEnding call (%s) before placed in queue!",
-+ LM_ERR ("%sEnding call (%s) before placed in queue!\n",
+ LM_ERR ("%sEnding call (%s) before placed in queue!\n",
pfncname, pcall->call_from);
- delete_call (pcall);
}
@@ -865,7 +840,7 @@
}
/**********
-@@ -323,14 +373,15 @@
+@@ -321,14 +373,15 @@ return 1;
* INPUT:
* Arg (1) = SIP message pointer
* Arg (2) = call pointer
@@ -884,28 +859,16 @@
**********/
char *pfncname = "cancel_msg: ";
-@@ -340,16 +391,16 @@
- mohq_debug (pcall->pmohq, "%sCANCELed call (%s)",
- pfncname, pcall->call_from);
- if (pmod_data->psl->freply (pmsg, 487, presp_reqterm) < 0)
-- { LM_ERR ("%sUnable to create reply!", pfncname); }
-+ { LM_ERR ("%sUnable to create reply!\n", pfncname); }
- }
- else
- {
-- LM_ERR ("%sUnable to CANCEL because accepted INVITE for call (%s)!",
-+ LM_ERR ("%sUnable to CANCEL because accepted INVITE for call (%s)!\n",
- pfncname, pcall->call_from);
+@@ -347,7 +400,7 @@ else
if (pmod_data->psl->freply (pmsg, 481, presp_nocall) < 0)
-- { LM_ERR ("%sUnable to create reply!", pfncname); }
-+ { LM_ERR ("%sUnable to create reply!\n", pfncname); }
+ { LM_ERR ("%sUnable to create reply!\n", pfncname); }
}
-return 1;
+return;
}
/**********
-@@ -365,23 +416,14 @@
+@@ -363,23 +416,14 @@ void close_call (sip_msg_t *pmsg, call_lst *pcall)
{
/**********
@@ -923,7 +886,7 @@
- pfncname, pcall->call_from);
- if (pmod_data->fn_rtp_destroy (pmsg, 0, 0) != 1)
- {
-- LM_ERR ("%srtpproxy_destroy refused for call (%s)!",
+- LM_ERR ("%srtpproxy_destroy refused for call (%s)!\n",
- pfncname, pcall->call_from);
- }
- }
@@ -931,7 +894,7 @@
struct to_body ptob [2];
dlg_t *pdlg = form_dialog (pcall, ptob);
if (!pdlg)
-@@ -398,15 +440,17 @@
+@@ -396,6 +440,7 @@ tm_api_t *ptm = pmod_data->ptm;
char *pquri = pcall->pmohq->mohq_uri;
int npos1 = sizeof (pbyemsg) // BYE template
+ strlen (pcall->call_via) // Via
@@ -939,10 +902,7 @@
+ strlen (pquri); // Contact
phdr = pkg_malloc (npos1);
if (!phdr)
- {
-- LM_ERR ("%sNo more memory!", pfncname);
-+ LM_ERR ("%sNo more memory!\n", pfncname);
- goto bye_err;
+@@ -405,6 +450,7 @@ if (!phdr)
}
sprintf (phdr, pbyemsg,
pcall->call_via, // Via
@@ -950,16 +910,16 @@
pquri); // Contact
str phdrs [1];
phdrs->s = phdr;
-@@ -422,7 +466,7 @@
- pcall->call_state = CLSTA_BYE;
- if (ptm->t_request_within (puac) < 0)
- {
-- LM_ERR ("%sUnable to create BYE request for call (%s)!",
-+ LM_ERR ("%sUnable to create BYE request for call (%s)!\n",
+@@ -424,7 +470,7 @@ if (ptm->t_request_within (puac) < 0)
pfncname, pcall->call_from);
goto bye_err;
}
-@@ -449,138 +493,127 @@
+-mohq_debug (pcall->pmohq, "%sSent BYE request for call (%s)\n",
++mohq_debug (pcall->pmohq, "%sSent BYE request for call (%s)",
+ pfncname, pcall->call_from);
+ bsent = 1;
+
+@@ -447,138 +493,127 @@ return;
* Create New Call Record
*
* INPUT:
@@ -987,7 +947,7 @@
-char *pfncname = "create_call: ";
-if (!mohq_lock_set (pmod_data->pcall_lock, 1, 2000))
- {
-- LM_ERR ("%sUnable to lock calls!", pfncname);
+- LM_ERR ("%sUnable to lock calls!\n", pfncname);
- return -1;
- }
-call_lst *pcall;
@@ -995,7 +955,7 @@
-if (pcall)
- {
- mohq_lock_release (pmod_data->pcall_lock);
-- LM_ERR ("%sCall already in use (%s)!", pfncname, pcall->call_from);
+- LM_ERR ("%sCall already in use (%s)!\n", pfncname, pcall->call_from);
- return -1;
- }
-for (ncall_idx = 0; ncall_idx < pmod_data->call_cnt; ncall_idx++)
@@ -1006,7 +966,7 @@
-if (ncall_idx == pmod_data->call_cnt)
- {
- mohq_lock_release (pmod_data->pcall_lock);
-- LM_ERR ("%sNo call slots available!", pfncname);
+- LM_ERR ("%sNo call slots available!\n", pfncname);
- return -1;
- }
-
@@ -1129,8 +1089,8 @@
-* o update DB
-* o lock MOH queue
+* extract Route headers
- **********/
-
++**********/
++
+pcall->call_route = pbuf;
+struct hdr_field *proute;
+for (proute = pmsg->record_route; proute; proute = next_sibling_hdr (proute))
@@ -1154,8 +1114,8 @@
+
+/**********
+* update DB
-+**********/
-+
+ **********/
+
pcall->call_state = CLSTA_ENTER;
-mohq_lock_release (pmod_data->pcall_lock);
add_call_rec (ncall_idx);
@@ -1167,11 +1127,11 @@
}
/**********
-@@ -605,15 +638,15 @@
+@@ -603,15 +638,15 @@ if (pcall->call_hash || pcall->call_label)
{
if (ptm->t_lookup_ident (&ptrans, pcall->call_hash, pcall->call_label) < 0)
{
-- LM_ERR ("%sLookup transaction failed for call (%s)!", pfncname,
+- LM_ERR ("%sLookup transaction failed for call (%s)!\n", pfncname,
- pcall->call_from);
+ LM_ERR ("%sLookup transaction failed for call (%s) from queue (%s)!\n",
+ pfncname, pcall->call_from, pcall->pmohq->mohq_name);
@@ -1180,14 +1140,14 @@
{
if (ptm->t_release (pcall->call_pmsg) < 0)
{
-- LM_ERR ("%sRelease transaction failed for call (%s)!",
+- LM_ERR ("%sRelease transaction failed for call (%s)!\n",
- pfncname, pcall->call_from);
+ LM_ERR ("%sRelease transaction failed for call (%s) from queue (%s)!\n",
+ pfncname, pcall->call_from, pcall->pmohq->mohq_name);
}
}
pcall->call_hash = pcall->call_label = 0;
-@@ -622,14 +655,21 @@
+@@ -620,14 +655,21 @@ if (pcall->call_hash || pcall->call_label)
/**********
* o update DB
* o inactivate slot
@@ -1215,33 +1175,16 @@
return;
}
-@@ -655,28 +695,28 @@
- tm_api_t *ptm = pmod_data->ptm;
- if (ptm->t_newtran (pmsg) < 0)
- {
-- LM_ERR ("%sUnable to create new transaction!", pfncname);
-+ LM_ERR ("%sUnable to create new transaction!\n", pfncname);
- if (pmod_data->psl->freply (pmsg, 500, presp_srverr) < 0)
- {
-- LM_ERR ("%sUnable to create reply to %.*s!", pfncname,
-+ LM_ERR ("%sUnable to create reply to %.*s!\n", pfncname,
- STR_FMT (&REQ_LINE (pmsg).method));
- }
- return;
+@@ -663,7 +705,7 @@ if (ptm->t_newtran (pmsg) < 0)
}
if (!add_lump_rpl2 (pmsg, pallowhdr->s, pallowhdr->len, LUMP_RPL_HDR))
-- { LM_ERR ("%sUnable to add Allow header!", pfncname); }
+ { LM_ERR ("%sUnable to add Allow header!\n", pfncname); }
-LM_ERR ("%sRefused %.*s for call (%s)!", pfncname,
-+ { LM_ERR ("%sUnable to add Allow header!\n", pfncname); }
+LM_ERR ("%sRefused %.*s for call (%s)!\n", pfncname,
STR_FMT (&REQ_LINE (pmsg).method), pcall->call_from);
if (ptm->t_reply (pmsg, 405, presp_noallow->s) < 0)
{
-- LM_ERR ("%sUnable to create reply to %.*s!", pfncname,
-+ LM_ERR ("%sUnable to create reply to %.*s!\n", pfncname,
- STR_FMT (&REQ_LINE (pmsg).method));
- }
- return;
+@@ -674,7 +716,7 @@ return;
}
/**********
@@ -1250,7 +1193,7 @@
*
* INPUT:
* Arg (1) = SIP message pointer
-@@ -684,26 +724,24 @@
+@@ -682,16 +724,15 @@ return;
* OUTPUT: none
**********/
@@ -1271,10 +1214,7 @@
{
mohq_debug (pcall->pmohq, "%sDestroying RTP link for call (%s)",
pfncname, pcall->call_from);
- if (pmod_data->fn_rtp_destroy (pmsg, 0, 0) != 1)
- {
-- LM_ERR ("%srtpproxy_destroy refused for call (%s)!",
-+ LM_ERR ("%srtpproxy_destroy refused for call (%s)!\n",
+@@ -701,7 +742,6 @@ if (pmsg != FAKED_REPLY)
pfncname, pcall->call_from);
}
}
@@ -1282,7 +1222,7 @@
return;
}
-@@ -712,62 +750,37 @@
+@@ -710,62 +750,37 @@ return;
*
* INPUT:
* Arg (1) = SIP message pointer
@@ -1361,7 +1301,7 @@
for (nidx = 0; nidx < pmod_data->call_cnt; nidx++)
{
/**********
-@@ -775,21 +788,25 @@
+@@ -773,21 +788,25 @@ for (nidx = 0; nidx < pmod_data->call_cnt; nidx++)
* o call timed out on ACK?
* o callID matches?
* o to tag matches?
@@ -1382,7 +1322,7 @@
{
if ((pcall->call_time + 32) < time (0))
{
-- LM_ERR ("find_call: No ACK response for call (%s)", pcall->call_from);
+- LM_ERR ("find_call: No ACK response for call (%s)\n", pcall->call_from);
+ LM_ERR ("%sNo ACK response for call (%s)!\n", pfncname, pcall->call_from);
delete_call (pcall);
continue;
@@ -1392,7 +1332,7 @@
str tmpstr [1];
tmpstr->s = pcall->call_id;
tmpstr->len = strlen (tmpstr->s);
-@@ -802,36 +819,101 @@
+@@ -800,31 +819,96 @@ for (nidx = 0; nidx < pmod_data->call_cnt; nidx++)
if (!STR_EQ (*tmpstr, *ptotag))
{ continue; }
}
@@ -1496,22 +1436,7 @@
int nidx;
str tmpstr;
if (!mohq_lock_set (pmod_data->pmohq_lock, 0, 500))
- {
-- LM_ERR ("%sUnable to lock queues!", pfncname);
-+ LM_ERR ("%sUnable to lock queues!\n", pfncname);
- return -1;
- }
- for (nidx = 0; nidx < pmod_data->mohq_cnt; nidx++)
-@@ -843,7 +925,7 @@
- }
- if (nidx == pmod_data->mohq_cnt)
- {
-- LM_ERR ("%sUnable to find queue (%.*s)!", pfncname, STR_FMT (pqname));
-+ LM_ERR ("%sUnable to find queue (%.*s)!\n", pfncname, STR_FMT (pqname));
- nidx = -1;
- }
- mohq_lock_release (pmod_data->pmohq_lock);
-@@ -871,7 +953,7 @@
+@@ -869,7 +953,7 @@ parse_to (pvalue->s, &pvalue->s [pvalue->len + 1], pref);
if (pref->error != PARSE_OK)
{
// should never happen
@@ -1520,7 +1445,7 @@
return -1;
}
if (pref->param_lst)
-@@ -886,7 +968,7 @@
+@@ -884,7 +968,7 @@ str tmpstr;
struct to_body pfrom [1];
for (nidx = 0; nidx < pmod_data->call_cnt; nidx++)
{
@@ -1529,7 +1454,7 @@
{ continue; }
tmpstr.s = pmod_data->pcall_lst [nidx].call_from;
tmpstr.len = strlen (tmpstr.s);
-@@ -894,7 +976,7 @@
+@@ -892,7 +976,7 @@ for (nidx = 0; nidx < pmod_data->call_cnt; nidx++)
if (pfrom->error != PARSE_OK)
{
// should never happen
@@ -1538,7 +1463,7 @@
continue;
}
if (pfrom->param_lst)
-@@ -910,55 +992,65 @@
+@@ -908,55 +992,65 @@ return -1;
*
* INPUT:
* Arg (1) = SIP message pointer
@@ -1625,7 +1550,7 @@
}
/**********
-@@ -971,10 +1063,11 @@
+@@ -969,10 +1063,11 @@ if (pmod_data->fn_rtp_offer (pmsg, 0, 0) != 1)
tm_api_t *ptm = pmod_data->ptm;
if (ptm->t_newtran (pmsg) < 0)
{
@@ -1639,7 +1564,7 @@
}
struct cell *ptrans = ptm->t_gett ();
pcall->call_hash = ptrans->hash_index;
-@@ -982,28 +1075,53 @@
+@@ -980,28 +1075,53 @@ pcall->call_label = ptrans->label;
str ptotag [1];
if (ptm->t_get_reply_totag (pmsg, ptotag) != 1)
{
@@ -1653,9 +1578,7 @@
delete_call (pcall);
- return 1;
+ return;
- }
--strncpy (pcall->call_tag, ptotag->s, ptotag->len);
--pcall->call_tag [ptotag->len] = '\0';
++ }
+char *pbuf = &pcall->call_buffer [pcall->call_bufpos];
+pcall->call_tag = pbuf;
+if (!addstrbfr (ptotag->s, ptotag->len, &pbuf, &pcall->call_bufpos, 1))
@@ -1667,7 +1590,9 @@
+ end_RTP (pmsg, pcall);
+ delete_call (pcall);
+ return;
-+ }
+ }
+-strncpy (pcall->call_tag, ptotag->s, ptotag->len);
+-pcall->call_tag [ptotag->len] = '\0';
pcall->call_cseq = 1;
if (ptm->register_tmcb (pmsg, 0, TMCB_DESTROY | TMCB_ON_FAILURE,
invite_cb, pcall, 0) < 0)
@@ -1701,7 +1626,7 @@
* o add contact to reply
* o supports/requires PRACK? (RFC 3262 section 3)
* o exit if not ringing
-@@ -1011,19 +1129,20 @@
+@@ -1009,19 +1129,20 @@ if (ptm->register_tmcb (pmsg, 0, TMCB_DESTROY | TMCB_ON_FAILURE,
str pcontact [1];
char *pcontacthdr = "Contact: <%s>" SIPEOL;
@@ -1728,7 +1653,7 @@
pfncname, pcontact->s, pcall->call_from);
}
pkg_free (pcontact->s);
-@@ -1032,42 +1151,30 @@
+@@ -1030,42 +1151,30 @@ if (search_hdr_ext (pmsg->require, p100rel))
{
if (!send_prov_rsp (pmsg, pcall))
{
@@ -1745,16 +1670,16 @@
{
- LM_ERR ("%sUnable to reply to INVITE!", pfncname);
- return 1;
-+ end_RTP (pmsg, pcall);
-+ delete_call (pcall);
-+ return;
- }
+- }
- else
- {
- pcall->call_state = CLSTA_RINGING;
- mohq_debug (pcall->pmohq, "%sSent RINGING for call (%s)",
- pfncname, pcall->call_from);
-- }
++ end_RTP (pmsg, pcall);
++ delete_call (pcall);
++ return;
+ }
}
/**********
@@ -1781,7 +1706,7 @@
}
/**********
-@@ -1087,6 +1194,9 @@
+@@ -1085,6 +1194,9 @@ dlg_t *form_dialog (call_lst *pcall, struct to_body *pto_body)
**********/
char *pfncname = "form_dialog: ";
@@ -1791,7 +1716,7 @@
struct to_body *ptob = &pto_body [0];
struct to_body *pcontact = &pto_body [1];
parse_to (pcall->call_from,
-@@ -1094,12 +1204,49 @@
+@@ -1092,12 +1204,49 @@ parse_to (pcall->call_from,
if (ptob->error != PARSE_OK)
{
// should never happen
@@ -1843,7 +1768,7 @@
if (!*pcall->call_contact)
{
ptarget->s = ptob->uri.s;
-@@ -1112,7 +1259,7 @@
+@@ -1110,7 +1259,7 @@ else
if (pcontact->error != PARSE_OK)
{
// should never happen
@@ -1852,7 +1777,7 @@
pcall->call_contact, pcall->call_from);
return 0;
}
-@@ -1129,7 +1276,7 @@
+@@ -1127,7 +1276,7 @@ else
dlg_t *pdlg = (dlg_t *)pkg_malloc (sizeof (dlg_t));
if (!pdlg)
{
@@ -1861,7 +1786,7 @@
return 0;
}
memset (pdlg, 0, sizeof (dlg_t));
-@@ -1147,6 +1294,11 @@
+@@ -1145,6 +1294,11 @@ pdlg->loc_uri.s = pcall->pmohq->mohq_uri;
pdlg->loc_uri.len = strlen (pdlg->loc_uri.s);
pdlg->rem_uri.s = ptob->uri.s;
pdlg->rem_uri.len = ptob->uri.len;
@@ -1873,7 +1798,7 @@
return pdlg;
}
-@@ -1173,7 +1325,7 @@
+@@ -1171,7 +1325,7 @@ rtpmap **pmohfiles = find_MOH (pcall->pmohq->mohq_mohdir,
pcall->pmohq->mohq_mohfile);
if (!pmohfiles [0])
{
@@ -1882,7 +1807,7 @@
pcall->pmohq->mohq_name);
return 0;
}
-@@ -1193,7 +1345,7 @@
+@@ -1191,7 +1345,7 @@ for (nidx = 0; pmohfiles [nidx]; nidx++)
pstr->s = pkg_malloc (nsize + 1);
if (!pstr->s)
{
@@ -1891,7 +1816,7 @@
return 0;
}
strcpy (pstr->s, pSDP);
-@@ -1240,7 +1392,7 @@
+@@ -1238,7 +1392,7 @@ static void
call_lst *pcall = (call_lst *)*pcbp->param;
if (ntype == TMCB_DESTROY)
{ pcall->call_hash = pcall->call_label = 0; }
@@ -1900,7 +1825,7 @@
delete_call (pcall);
return;
}
-@@ -1251,10 +1403,10 @@
+@@ -1249,10 +1403,10 @@ return;
* INPUT:
* Arg (1) = SIP message pointer
* Arg (2) = call pointer
@@ -1913,7 +1838,7 @@
{
/**********
-@@ -1264,11 +1416,11 @@
+@@ -1262,11 +1416,11 @@ int notify_msg (sip_msg_t *pmsg, call_lst *pcall)
char *pfncname = "notify_msg: ";
if (pcall->call_state != CLSTA_RFRWAIT)
{
@@ -1928,7 +1853,7 @@
}
/**********
-@@ -1279,28 +1431,28 @@
+@@ -1277,28 +1431,28 @@ if (pcall->call_state != CLSTA_RFRWAIT)
if (!search_hdr_ext (pmsg->content_type, psipfrag))
{
@@ -1965,7 +1890,7 @@
}
strncpy (pbody->s, pfrag, pbody->len);
if (pbody->s [pbody->len - 1] != '\n')
-@@ -1313,10 +1465,10 @@
+@@ -1311,10 +1465,10 @@ parse_first_line (pbody->s, pbody->len + 1, pstart);
pkg_free (pbody->s);
if (pstart->type != SIP_REPLY)
{
@@ -1979,7 +1904,7 @@
}
/**********
-@@ -1324,32 +1476,34 @@
+@@ -1322,32 +1476,34 @@ if (pstart->type != SIP_REPLY)
* o REFER done?
**********/
@@ -2021,7 +1946,7 @@
}
/**********
-@@ -1360,7 +1514,7 @@
+@@ -1358,7 +1514,7 @@ switch (nreply / 100)
update_call_rec (pcall);
break;
}
@@ -2030,7 +1955,7 @@
}
/**********
-@@ -1369,10 +1523,10 @@
+@@ -1367,10 +1523,10 @@ return 1;
* INPUT:
* Arg (1) = SIP message pointer
* Arg (2) = call pointer
@@ -2043,7 +1968,7 @@
{
/**********
-@@ -1383,10 +1537,10 @@
+@@ -1381,10 +1537,10 @@ char *pfncname = "prack_msg: ";
tm_api_t *ptm = pmod_data->ptm;
if (pcall->call_state != CLSTA_PRACKSTRT)
{
@@ -2057,7 +1982,7 @@
}
/**********
-@@ -1396,20 +1550,20 @@
+@@ -1394,20 +1550,20 @@ if (pcall->call_state != CLSTA_PRACKSTRT)
if (ptm->t_newtran (pmsg) < 0)
{
@@ -2084,7 +2009,7 @@
}
/**********
-@@ -1450,18 +1604,22 @@
+@@ -1448,18 +1604,22 @@ puri->s = pcall->call_referto;
puri->len = strlen (puri->s);
int npos1 = sizeof (prefermsg) // REFER template
+ strlen (pcall->call_via) // Via
@@ -2110,7 +2035,7 @@
/**********
* send REFER request
-@@ -1474,13 +1632,14 @@
+@@ -1472,13 +1632,14 @@ phdrs->s = pbuf;
phdrs->len = strlen (pbuf);
set_uac_req (puac, prefer, phdrs, 0, pdlg,
TMCB_LOCAL_COMPLETED | TMCB_ON_FAILURE, refer_cb, pcall);
@@ -2126,7 +2051,7 @@
pfncname, pcall->call_from);
update_call_rec (pcall);
goto refererr;
-@@ -1514,21 +1673,23 @@
+@@ -1512,21 +1673,23 @@ char *pfncname = "refer_cb: ";
call_lst *pcall = (call_lst *)*pcbp->param;
if ((ntype == TMCB_ON_FAILURE) || (pcbp->req == FAKED_REPLY))
{
@@ -2153,7 +2078,7 @@
pcall->call_from, nreply);
if (nreply == 481)
{ delete_call (pcall); }
-@@ -1547,10 +1708,10 @@
+@@ -1545,10 +1708,10 @@ return;
* INPUT:
* Arg (1) = SIP message pointer
* Arg (2) = call pointer
@@ -2166,7 +2091,7 @@
{
/**********
-@@ -1565,17 +1726,17 @@
+@@ -1563,17 +1726,17 @@ if ((pcall->call_state / 100) < 2)
mohq_debug (pcall->pmohq, "%sINVITE still pending for call (%s)",
pfncname, pcall->call_from);
if (pmod_data->psl->freply (pmsg, 491, presp_reqpend) < 0)
@@ -2189,7 +2114,7 @@
}
}
-@@ -1645,12 +1806,12 @@
+@@ -1643,12 +1806,12 @@ if (!bhold)
{
if (!bmatch)
{
@@ -2205,7 +2130,7 @@
}
}
else
-@@ -1659,26 +1820,26 @@
+@@ -1657,26 +1820,26 @@ if (!bhold)
pfncname, pcall->call_from);
if (pmod_data->psl->freply (pmsg, 200, presp_ok) < 0)
{
@@ -2239,7 +2164,7 @@
}
/**********
-@@ -1746,22 +1907,21 @@
+@@ -1744,22 +1907,21 @@ char *phdrtmplt =
"Accept-Language: en" SIPEOL
"Require: 100rel" SIPEOL
"RSeq: %d" SIPEOL
@@ -2265,7 +2190,7 @@
pfncname, pcall->call_from);
return 0;
}
-@@ -1782,7 +1942,7 @@
+@@ -1780,7 +1942,7 @@ while (1)
{ break; }
if (nstart < time (0))
{
@@ -2274,7 +2199,7 @@
pfncname, pcall->call_from);
break;
}
-@@ -1822,7 +1982,7 @@
+@@ -1820,7 +1982,7 @@ pbuf->s = build_res_buf_from_sip_req (200, presp_ok, ptotag, ptrans->uas.request
(unsigned int *)&pbuf->len, pBM);
if (!pbuf->s || !pbuf->len)
{
@@ -2283,7 +2208,7 @@
pfncname, pcall->call_from);
return 0;
}
-@@ -1895,7 +2055,7 @@
+@@ -1893,7 +2055,7 @@ npos1 += pextrahdr->len + strlen (pbodylen) + pSDP->len + 1;
char *pnewbuf = pkg_malloc (npos1);
if (!pnewbuf)
{
@@ -2292,7 +2217,7 @@
goto answer_done;
}
for (npos1 = npos2 = 0; npos2 < nhdrcnt; npos2++)
-@@ -1925,7 +2085,7 @@
+@@ -1923,7 +2085,7 @@ build_sip_msg_from_buf (pnmsg, pbuf->s, pbuf->len, 0);
memcpy (&pnmsg->rcv, &pmsg->rcv, sizeof (struct receive_info));
/**********
@@ -2301,7 +2226,7 @@
* o form stream file
* o send stream
**********/
-@@ -1934,7 +2094,7 @@
+@@ -1932,7 +2094,7 @@ mohq_debug (pcall->pmohq, "%sAnswering RTP link for call (%s)",
pfncname, pcall->call_from);
if (pmod_data->fn_rtp_answer (pnmsg, 0, 0) != 1)
{
@@ -2310,7 +2235,7 @@
pfncname, pcall->call_from);
goto answer_done;
}
-@@ -1951,7 +2111,7 @@
+@@ -1949,7 +2111,7 @@ pkg_free (pnewbuf);
free_sip_msg (pnmsg);
if (!pbuf->s || !pbuf->len)
{
@@ -2319,7 +2244,7 @@
pfncname, pcall->call_from);
goto answer_done;
}
-@@ -1975,26 +2135,26 @@
+@@ -1973,26 +2135,26 @@ char *pfnd = strstr (pnewSDP->s, "m=audio ");
if (!pfnd)
{
// should not happen
@@ -2350,19 +2275,19 @@
pfncname, pcall->call_from);
goto answer_done;
}
-@@ -2043,7 +2203,7 @@
+@@ -2041,7 +2203,34 @@ mohq_debug (pcall->pmohq, "%sStarting RTP link for call (%s)",
pfncname, pcall->call_from);
if (fn_stream (pmsg, (char *)pmodel, (char *)-1) != 1)
{
- LM_ERR ("%srtpproxy_stream refused for call (%s)!",
+ LM_ERR ("%srtpproxy_stream refused for call (%s)!\n",
- pfncname, pcall->call_from);
- return 0;
- }
-@@ -2051,6 +2211,33 @@
- }
-
- /**********
++ pfncname, pcall->call_from);
++ return 0;
++ }
++return 1;
++}
++
++/**********
+* Stop Streaming
+*
+* INPUT:
@@ -2383,17 +2308,10 @@
+if (fn_stop (pmsg, (char *)-1, (char *)-1) != 1)
+ {
+ LM_ERR ("%srtpproxy_stop refused for call (%s)!\n",
-+ pfncname, pcall->call_from);
-+ return 0;
-+ }
-+return 1;
-+}
-+
-+/**********
- * Form Char Array from STR
- *
- * INPUT:
-@@ -2064,7 +2251,7 @@
+ pfncname, pcall->call_from);
+ return 0;
+ }
+@@ -2062,7 +2251,7 @@ char *form_tmpstr (str *pstr)
char *pcstr = malloc (pstr->len + 1);
if (!pcstr)
{
@@ -2402,7 +2320,7 @@
return NULL;
}
memcpy (pcstr, pstr->s, pstr->len);
-@@ -2164,7 +2351,7 @@
+@@ -2162,7 +2351,7 @@ struct mi_root *mi_debug (struct mi_root *pcmd_tree, void *parms)
struct mi_node *pnode = pcmd_tree->node.kids;
if (!pnode || !pnode->next || pnode->next->next)
{ return init_mi_tree (400, MI_MISSING_PARM_S, MI_MISSING_PARM_LEN); }
@@ -2411,7 +2329,7 @@
if (nq_idx == -1)
{ return init_mi_tree (400, pmi_noqueue->s, pmi_noqueue->len); }
char pint [20];
-@@ -2217,7 +2404,7 @@
+@@ -2215,7 +2404,7 @@ struct mi_root *mi_drop_call (struct mi_root *pcmd_tree, void *parms)
struct mi_node *pnode = pcmd_tree->node.kids;
if (!pnode || !pnode->next || pnode->next->next)
{ return init_mi_tree (400, MI_MISSING_PARM_S, MI_MISSING_PARM_LEN); }
@@ -2420,7 +2338,7 @@
if (nq_idx == -1)
{ return init_mi_tree (400, pmi_noqueue->s, pmi_noqueue->len); }
if (!mohq_lock_set (pmod_data->pcall_lock, 0, 5000))
-@@ -2240,7 +2427,7 @@
+@@ -2238,7 +2427,7 @@ for (nidx = 0; nidx < pmod_data->call_cnt; nidx++)
**********/
call_lst *pcall = &pmod_data->pcall_lst [nidx];
@@ -2429,7 +2347,7 @@
{ continue; }
if (pqueue->mohq_id != pcall->pmohq->mohq_id)
{ continue; }
-@@ -2279,12 +2466,12 @@
+@@ -2277,12 +2466,12 @@ char *pfncname = "mohq_count: ";
str pqname [1];
if (!pqueue || !presult)
{
@@ -2444,7 +2362,7 @@
return -1;
}
-@@ -2294,12 +2481,12 @@
+@@ -2292,12 +2481,12 @@ if (fixup_get_svalue (pmsg, (gparam_p)pqueue, pqname))
* o count items in queue
**********/
@@ -2459,7 +2377,7 @@
else
{
if (nq_idx != -1)
-@@ -2307,7 +2494,7 @@
+@@ -2305,7 +2494,7 @@ else
mohq_id = pmod_data->pmohq_lst [nq_idx].mohq_id;
for (ncall_idx = 0; ncall_idx < pmod_data->call_cnt; ncall_idx++)
{
@@ -2468,7 +2386,7 @@
{ continue; }
if (pcalls [ncall_idx].pmohq->mohq_id == mohq_id
&& pcalls [ncall_idx].call_state == CLSTA_INQUEUE)
-@@ -2328,7 +2515,7 @@
+@@ -2326,7 +2515,7 @@ pavp_val->ri = ncount;
pavp_val->flags = PV_TYPE_INT | PV_VAL_INT;
if (presult->setf (pmsg, &presult->pvp, (int)EQ_T, pavp_val) < 0)
{
@@ -2477,7 +2395,7 @@
return -1;
}
return 1;
-@@ -2366,7 +2553,7 @@
+@@ -2364,7 +2553,7 @@ va_list ap;
va_start (ap, pfmt);
vsnprintf (ptext, sizeof (ptext), pfmt, ap);
va_end (ap);
@@ -2486,7 +2404,7 @@
if (nsys_log < nmohq_log)
{ reset_local_debug_level (); }
return;
-@@ -2377,39 +2564,28 @@
+@@ -2375,39 +2564,28 @@ return;
*
* INPUT:
* Arg (1) = SIP message pointer
@@ -2507,17 +2425,17 @@
char *pfncname = "mohq_process: ";
-if (parse_headers (pmsg, HDR_EOH_F, 0) < 0)
+- {
+- LM_ERR ("%sUnable to parse header!", pfncname);
+- return -1;
+- }
+-if (!mohq_lock_set (pmod_data->pmohq_lock, 0, 2000))
+if (!mohq_lock_set (pmod_data->pmohq_lock, 0, 500))
{
-- LM_ERR ("%sUnable to parse header!", pfncname);
+- LM_ERR ("%sUnable to lock calls!", pfncname);
+ LM_ERR ("%sUnable to read lock queue!\n", pfncname);
return -1;
}
--if (!mohq_lock_set (pmod_data->pmohq_lock, 0, 2000))
-- {
-- LM_ERR ("%sUnable to lock calls!", pfncname);
-- return -1;
-- }
-call_lst *pcall;
-int mohq_idx = find_call (pmsg, &pcall);
db1_con_t *pconn = mohq_dbconnect ();
@@ -2531,7 +2449,7 @@
**********/
if (pmod_data->mohq_update + 60 < time (0))
-@@ -2423,22 +2599,51 @@
+@@ -2421,22 +2599,51 @@ if (pconn)
}
mohq_dbdisconnect (pconn);
}
@@ -2585,7 +2503,7 @@
switch (pmsg->REQ_METHOD)
{
case METHOD_INVITE:
-@@ -2446,33 +2651,35 @@
+@@ -2444,33 +2651,35 @@ switch (pmsg->REQ_METHOD)
* initial INVITE?
**********/
@@ -2631,7 +2549,7 @@
}
/**********
-@@ -2497,28 +2704,28 @@
+@@ -2495,28 +2704,28 @@ char *pfncname = "mohq_retrieve: ";
str puri [1], pqname [1];
if (!pqueue || !pURI)
{
@@ -2665,7 +2583,7 @@
return -1;
}
-@@ -2528,12 +2735,12 @@
+@@ -2526,12 +2735,12 @@ if (parse_uri (puri->s, puri->len, puri_parsed))
* o find oldest call
**********/
@@ -2680,7 +2598,7 @@
return -1;
}
call_lst *pcall = 0;
-@@ -2546,15 +2753,27 @@
+@@ -2544,15 +2753,27 @@ for (ncall_idx = 0; ncall_idx < pmod_data->call_cnt; ncall_idx++)
/**********
* o active call?
* o matching queue?
@@ -2709,7 +2627,7 @@
if (pcall->call_state != CLSTA_INQUEUE)
{ continue; }
if (!ntime)
-@@ -2573,7 +2792,7 @@
+@@ -2571,7 +2792,7 @@ for (ncall_idx = 0; ncall_idx < pmod_data->call_cnt; ncall_idx++)
}
if (nfound == -1)
{
@@ -2718,7 +2636,7 @@
mohq_lock_release (pmod_data->pcall_lock);
return -1;
}
-@@ -2588,7 +2807,7 @@
+@@ -2586,7 +2807,7 @@ strncpy (pcall->call_referto, puri->s, puri->len);
pcall->call_referto [puri->len] = '\0';
if (refer_call (pcall, pmod_data->pcall_lock))
{ return 1; }
@@ -2727,7 +2645,7 @@
return -1;
}
-@@ -2612,24 +2831,24 @@
+@@ -2610,24 +2831,24 @@ int mohq_send (sip_msg_t *pmsg, char *pqueue)
char *pfncname = "mohq_send: ";
if (pmsg->REQ_METHOD != METHOD_INVITE)
{
@@ -2756,7 +2674,7 @@
return -1;
}
-@@ -2639,14 +2858,14 @@
+@@ -2637,14 +2858,14 @@ if (fixup_get_svalue (pmsg, (gparam_p)pqueue, pqname))
* o relay message
**********/
@@ -2773,7 +2691,7 @@
return -1;
}
strcpy (pruri->s, pmod_data->pmohq_lst [nq_idx].mohq_uri);
-@@ -2658,7 +2877,7 @@
+@@ -2656,8 +2877,8 @@ pmsg->parsed_uri_ok = 0;
pmsg->parsed_orig_ruri_ok = 0;
if (pmod_data->ptm->t_relay (pmsg, 0, 0) < 0)
{
@@ -2782,36 +2700,39 @@
return -1;
}
return 1;
+-}
++}
+\ No newline at end of file
+diff --git a/modules/mohqueue/mohq_funcs.h b/modules/mohqueue/mohq_funcs.h
+index dbe02c5..5d4dfd1 100644
--- a/modules/mohqueue/mohq_funcs.h
+++ b/modules/mohqueue/mohq_funcs.h
-@@ -1,9 +1,7 @@
+@@ -1,5 +1,5 @@
/*
-- * $Id$
+- * Copyright (C) 2013 Robert Boisvert
+ * Copyright (C) 2013-15 Robert Boisvert
*
-- * Copyright (C) 2013 Robert Boisvert
-- *
-- * This file is part of the mohqueue module for sip-router, a free SIP server.
-+ * This file is part of the mohqueue module for Kamailio, a free SIP server.
+ * This file is part of the mohqueue module for Kamailio, a free SIP server.
*
- * The mohqueue module is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+@@ -35,4 +35,4 @@ int mohq_process (sip_msg_t *);
+ int mohq_retrieve (sip_msg_t *, char *, char *);
+ int mohq_send (sip_msg_t *, char *);
+
+-#endif /* MOHQ_FUNCS_H */
++#endif /* MOHQ_FUNCS_H */
+\ No newline at end of file
+diff --git a/modules/mohqueue/mohq_locks.c b/modules/mohqueue/mohq_locks.c
+index 7adb04b..50ecb1c 100644
--- a/modules/mohqueue/mohq_locks.c
+++ b/modules/mohqueue/mohq_locks.c
-@@ -1,10 +1,8 @@
+@@ -1,5 +1,5 @@
/*
-- * $Id$
+- * Copyright (C) 2013 Robert Boisvert
+ * Copyright (C) 2013-15 Robert Boisvert
*
-- * Copyright (C) 2013 Robert Boisvert
-+ * This file is part of the mohqueue module for Kamailio, a free SIP server.
+ * This file is part of the mohqueue module for Kamailio, a free SIP server.
*
-- * This file is part of the mohqueue module for sip-router, a free SIP server.
-- *
- * The mohqueue module is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
-@@ -103,12 +101,12 @@
+@@ -101,12 +101,12 @@ char *pfncname = "mohq_lock_init: ";
plock->plock = lock_alloc ();
if (!plock->plock)
{
@@ -2826,7 +2747,7 @@
lock_dealloc (plock->plock);
return 0;
}
-@@ -140,7 +138,7 @@
+@@ -138,7 +138,7 @@ switch (plock->lock_cnt)
plock->lock_cnt = 0;
break;
case 0:
@@ -2835,17 +2756,28 @@
break;
default:
plock->lock_cnt--;
+@@ -194,4 +194,4 @@ do
+ }
+ while (!nret && --nms_cnt >= 0);
+ return nret;
+-}
++}
+\ No newline at end of file
+diff --git a/modules/mohqueue/mohq_locks.h b/modules/mohqueue/mohq_locks.h
+index 6f95c65..18c23fe 100644
--- a/modules/mohqueue/mohq_locks.h
+++ b/modules/mohqueue/mohq_locks.h
-@@ -1,9 +1,7 @@
+@@ -1,5 +1,5 @@
/*
-- * $Id$
+- * Copyright (C) 2013 Robert Boisvert
+ * Copyright (C) 2013-15 Robert Boisvert
*
-- * Copyright (C) 2013 Robert Boisvert
-- *
-- * This file is part of the mohqueue module for sip-router, a free SIP server.
-+ * This file is part of the mohqueue module for Kamailio, a free SIP server.
+ * This file is part of the mohqueue module for Kamailio, a free SIP server.
*
- * The mohqueue module is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
+@@ -44,4 +44,4 @@ int mohq_lock_init (mohq_lock *);
+ void mohq_lock_release (mohq_lock *);
+ int mohq_lock_set (mohq_lock *, int, int);
+
+-#endif /* MOHQ_LOCKS_H */
++#endif /* MOHQ_LOCKS_H */
+\ No newline at end of file
diff --git a/main/kamailio/kamailio-4.2-backslash.patch b/main/kamailio/0003-kamdbctl-backslash.patch
index 52d04efc2..085b22b21 100644
--- a/main/kamailio/kamailio-4.2-backslash.patch
+++ b/main/kamailio/0003-kamdbctl-backslash.patch
@@ -1,5 +1,5 @@
diff --git a/utils/kamctl/kamdbctl.base b/utils/kamctl/kamdbctl.base
-index b4ed9ad..9552e91 100644
+index bb74810..20780ef 100644
--- a/utils/kamctl/kamdbctl.base
+++ b/utils/kamctl/kamdbctl.base
@@ -33,18 +33,18 @@ INSTALL_DBUID_TABLES=${INSTALL_DBUID_TABLES:-ask}
@@ -18,11 +18,12 @@ index b4ed9ad..9552e91 100644
-EXTRA_TABLES=${EXTRA_TABLES:-imc_members imc_rooms cpl sip_trace domainpolicy
- carrierroute carrier_name domain_name carrierfailureroute userblacklist
- globalblacklist htable purplemap uacreg pl_pipes mtree mtrees
+- sca_subscriptions mohqcalls mohqueues rtpproxy}
+-PRESENCE_TABLES=${PRESENCE_TABLES:-presentity active_watchers watchers xcap
+EXTRA_TABLES=${EXTRA_TABLES:-imc_members imc_rooms cpl sip_trace domainpolicy \
+ carrierroute carrier_name domain_name carrierfailureroute userblacklist \
+ globalblacklist htable purplemap uacreg pl_pipes mtree mtrees \
- sca_subscriptions mohqcalls mohqueues rtpproxy}
--PRESENCE_TABLES=${PRESENCE_TABLES:-presentity active_watchers watchers xcap
++ sca_subscriptions mohqcalls mohqueues rtpproxy}
+PRESENCE_TABLES=${PRESENCE_TABLES:-presentity active_watchers watchers xcap \
pua rls_presentity rls_watchers}
-DBUID_TABLES=${UID_TABLES:-uid_credentials uid_domain uid_domain_attrs
@@ -30,7 +31,7 @@ index b4ed9ad..9552e91 100644
uid_global_attrs uid_uri uid_uri_attrs uid_user_attrs}
# SQL definitions
-@@ -74,17 +74,17 @@ GREP=${GREP:-grep}
+@@ -68,17 +68,17 @@ GREP=${GREP:-grep}
SED=${SED:-sed}
# define what modules should be installed
diff --git a/main/kamailio/APKBUILD b/main/kamailio/APKBUILD
index 32721634b..3b7006b3f 100644
--- a/main/kamailio/APKBUILD
+++ b/main/kamailio/APKBUILD
@@ -5,15 +5,15 @@
pkgname=kamailio
# If building from a git snapshot, specify the gitcommit
-# abuild snapshot, then abuild as normal
+# run "abuild snapshot", then abuild as normal
# If building a proper release, leave gitcommit blank
-#_gitcommit=f9c248a6
+#_gitcommit=e27802533cee
_giturl="git://github.com/$pkgname/$pkgname.git"
_gittag=HEAD
-pkgver=4.2.5
-pkgrel=1
+pkgver=4.3.0
+pkgrel=0
[ -z "${_gitcommit}" ] && _suffix="_src" || _suffix="-${_gitcommit}"
pkgdesc="Open Source SIP Server"
@@ -27,7 +27,8 @@ depends=""
makedepends="bison flex expat-dev postgresql-dev pcre-dev mariadb-dev
libxml2-dev curl-dev unixodbc-dev confuse-dev ncurses-dev sqlite-dev
lua-dev openldap-dev openssl-dev net-snmp-dev libuuid libev-dev
- json-c-dev libevent-dev linux-headers libmemcached-dev hiredis-dev"
+ jansson-dev json-c-dev libevent-dev linux-headers libmemcached-dev
+ hiredis-dev libmaxminddb-dev"
install="$pkgname.pre-install $pkgname.pre-upgrade"
# See Makefile.groups for the list of recommended modules for
@@ -53,7 +54,8 @@ _mod_list_basic="avp async auth benchmark blst cfg_rpc cfgutils corex counters \
# - extra used modules, with no extra dependency
_mod_list_extras="auth_diameter call_control cnxcc dmq domainpolicy msrp pdb \
qos sca seas sms sst timer tmrec tsilo uac_redirect xhttp \
- xhttp_rpc xprint nosip"
+ xhttp_rpc xprint nosip dmq_usrloc statsd rtjson tcpops \
+ auth_xkeys"
# - common modules depending on database
_mod_list_db="acc alias_db auth_db avpops cfg_db db_flatstore \
@@ -155,8 +157,8 @@ _mod_list_perl="app_perl db_perlvdb"
# - modules depending on python library
_mod_list_python="app_python"
-# - modules depending on geoip library
-_mod_list_geoip="geoip"
+# - modules depending on geoip2 library
+_mod_list_geoip2="geoip2"
# - modules depending on sqlite library
_mod_list_sqlite="db_sqlite"
@@ -202,6 +204,10 @@ _mod_list_kazoo="kazoo"
# - modules depending on mongodb
_mod_list_mongodb="db_mongodb ndb_mongodb"
+# - modules depending on jansson library
+_mod_list_jansson="jansson janssonrpc-c"
+
+
# Alpine Specific
_mod_list_debugger="$_mod_list_devel benchmark debugger"
@@ -216,27 +222,20 @@ for _i in db postgres sqlite dbtext mysql \
cpl xml unixodbc snmpstats xmpp carrierroute \
ldap utils tls presence lua ims outbound debugger \
extras json websocket authephemeral \
- uuid ev memcached redis; do
+ uuid ev memcached redis geoip2 jansson; do
subpackages="$subpackages $pkgname-$_i"
eval "_modules=\"\$_modules \$_mod_list_$_i\""
done
-source="http://www.kamailio.org/pub/kamailio/$pkgver/src/kamailio-${pkgver}${_suffix}.tar.gz
- kamailio-4.2-backslash.patch
+source="http://www.kamailio.org/pub/kamailio/$pkgver/src/${pkgname}-${pkgver}${_suffix}.tar.gz
0001-musl-fixes.patch
- kamailio-4.2-ipops-srv-query.patch
- DMQ-multi-notify.patch
0002-mohqueue-v0-11.patch
- default_ctl.patch
- kamctl_build.patch
-
+ 0003-kamdbctl-backslash.patch
kamailio.cfg
kamailio.initd
"
-_builddir="$srcdir"/${pkgname}-fb-${_ver}
-
snapshot() {
mkdir -p "$srcdir"
cd "${SRCDEST:-$srcdir}"
@@ -247,7 +246,7 @@ snapshot() {
cd $pkgname.git
git fetch || return 1
fi
- git archive --prefix=$pkgname-$pkgver/ -o "$SRCDEST"/$pkgname-$_ver.tar.gz $_gittag
+ git archive --prefix=$pkgname-$pkgver/ -o "$SRCDEST"/${pkgname}-${pkgver}${_suffix}.tar.gz $_gittag
}
@@ -291,6 +290,7 @@ build() {
PREFIX=/usr \
CC_EXTRA_OPTS="$CFLAGS -D_GNU_SOURCE" \
cfg_target=/etc/kamailio/ \
+ run_prefix=$_builddir/var/run/kamailio \
include_modules="$_modules" \
LIBDIR=lib \
DESTDIR="$pkgdir" \
@@ -467,10 +467,15 @@ json() {
"$_mod_list_json"
}
-#geoip() {
-# _generic_pkg "MaxMind GeoIP lookup support" \
-# "$_mod_list_geoip"
-#}
+jansson() {
+ _generic_pkg "Operations on json strings using jansson library" \
+ "$_mod_list_jansson"
+}
+
+geoip2() {
+ _generic_pkg "MaxMind GeoIP lookup support" \
+ "$_mod_list_geoip2"
+}
ev() {
_generic_pkg "Network event broadcast API" \
@@ -492,33 +497,21 @@ redis() {
"$_mod_list_redis"
}
-md5sums="5c10c9f12188ce90321fdc5f69398c32 kamailio-4.2.5_src.tar.gz
-bad1ac2d4c95043df271d2ea6d37627a kamailio-4.2-backslash.patch
-4685288dc54680597b00f956dc95d4d6 0001-musl-fixes.patch
-e9c0ba8192a1a4f2a08a2e2add20e3d7 kamailio-4.2-ipops-srv-query.patch
-7df723eb9e14df28adfff8643d99a1a9 DMQ-multi-notify.patch
-09270d91b68d88b44e043d58d68d5691 0002-mohqueue-v0-11.patch
-841fa62c432c5d8aeb57ad70d2ec3030 default_ctl.patch
-d0052e6054884b9cec955af4480c7c85 kamctl_build.patch
+md5sums="4a6bd2f70f14d94a4ed9a8e6b18f89d7 kamailio-4.3.0_src.tar.gz
+18863791d386659eae6ef0c82a2517ae 0001-musl-fixes.patch
+3b1a7b9e21d5af55827514cadd7cbf71 0002-mohqueue-v0-11.patch
+fe8f61c73264cd1c360f3876f664464d 0003-kamdbctl-backslash.patch
299706d97e30a4f0d9b4c873df422866 kamailio.cfg
39dc9355fa7d8fec425d3b17c2fb26e0 kamailio.initd"
-sha256sums="bc19d7a7cc0c3aceb68ac9bb64c2169d8713fe73a2267509954bd36f037810cc kamailio-4.2.5_src.tar.gz
-d7e59be721ed0ad4621d404493b9a519708d801e9d4914b0164b819fa1abcd13 kamailio-4.2-backslash.patch
-b98555ff304b51b82c6cf7e01d757b15ea4f05bd2e603c84d4384df6a6be62b6 0001-musl-fixes.patch
-7e33c95bdb942e4ed6d54e14476cad2ee7edfc256b1f250e5f133d9e8a9b2a67 kamailio-4.2-ipops-srv-query.patch
-384eeaa5b253228341dc7a74ec61314db4b8f2f1c9c2f3bdf9ba189d2d56911d DMQ-multi-notify.patch
-45b111be159037b9d96cf6fbc7b0643e8528f99dcd8604a52fbc64656de2c0d3 0002-mohqueue-v0-11.patch
-755efa4ad126c672bc67c53268260b57f7da1f454cdc1a1601778ed7c7d5f0e5 default_ctl.patch
-e00eefed792acbc1ee6eca8fa7389f9973bd53b68fa7abc573f19f1ff26812a1 kamctl_build.patch
+sha256sums="e4bd1d166a58817237809f754b39f3039c60ac0ab60794bb0f7627b6890caec4 kamailio-4.3.0_src.tar.gz
+254ea5d4699417aec49e1aae45398a802067a8967060f2a469e278779d876d22 0001-musl-fixes.patch
+e4cfb439d2969801ca1e0bf890643b4a906c36f8ce7aa08d52a15a10525619b6 0002-mohqueue-v0-11.patch
+46026949a3a367ebaf0c8a7d1ffeeaa3dc67588c94dd8d558991a54996877c1f 0003-kamdbctl-backslash.patch
8b742ff710ef67ff59ec07a260690ebcdda24fb6f0b7b64dc50433a1bacf99f2 kamailio.cfg
ba928fa914feea2b95b8c659832e3fbea25eb6ac1ce56e4c23ff58c09f1ec3b8 kamailio.initd"
-sha512sums="737303478eb69da8f0b9782005130a11ef8a9cefb1cb77b5d76e6c066121106e08398861e6096000522d7ddfd7dabd36238d1fdfd4b1e5631048955402393d26 kamailio-4.2.5_src.tar.gz
-a9bb1e8f9f373264b8351ddae099a36a46ddd46fdec09e468d297ba4f64bb4896e7d6e599da70a424e8a28695ab3f3b4ac940afab534593a6b9d08ae462f001a kamailio-4.2-backslash.patch
-dea7ef2ccf01357576045ba375d41301e2447b4454324007c7ca1862322835c57045852017192ca5434b32dd1b7a2e9669209b7111889dab335b74f042d0f11f 0001-musl-fixes.patch
-b5c048b6e06de0c7514c14d0ec99bbe939eaa956d9d9d3dd5f48b1bcbcff06dbd6498d384427253fb655997a10ec5fa31dcc5cfd2f8cc5c64dcd531649133781 kamailio-4.2-ipops-srv-query.patch
-7ddf6444c15f7338e7aab779ea5b75f4fd936b51cf5d9ba0d09e813566e527f74e59e100661d2b27db99e5fa042614c83e8145e999a8b6bfcfab71c9595bb626 DMQ-multi-notify.patch
-a77e9abdf957a4704477873f57805b07df6390bc2fd24498258c97e6c15b074938d5b7ef6d1cec51b3418ec08e82babdc99d89b51b8c2c440d15f05d5439a261 0002-mohqueue-v0-11.patch
-2321d8afe29b53057ce21e0552dfb80fd6a0e7dc0caf3c4798a8b253518f4c8c546797302933373f4b055a4531329a36ee2d7117b0a88fe39cf153bfef91a656 default_ctl.patch
-4c2c9bde3a4c44feca2863bb03cb031aa55e1c3df21dc7c0acb3a392c34cb36d9a132bcbdf451a0624f8ec202152f1cf238c89280c32f1c04312ce80427a18c6 kamctl_build.patch
+sha512sums="f0964b31eb6b3bc56ec6d45d1f6e94b8016f741d7bf28cf3148ca9525f74a212fb29ee742742fd191df0b363a55e6e31ad8cc4f6339f331b2df7462894ee02de kamailio-4.3.0_src.tar.gz
+32c8e723ee858b24a3bd1313537e9348bdd895e709041d52199b7d2c4054565f3f8d203458b5a7bd5f4b09a782a972cf87f931de5bb8199e6f9786a3c9bfb3ba 0001-musl-fixes.patch
+dbc230e39b2dc4fbf14f2649a50065947688c55e4d697fdafb8afa70e4ffdd2de91d1ac60d107ee494f59399aa27eaacf3e8411aa6f22459ade2f16a1bd5e232 0002-mohqueue-v0-11.patch
+d96600f1047eac65c0eba34030baa26ee6ee953434ae5808b203cba979fbed616289d40fc588939222371d832f54cbda0a5e8ba9baa16913363e204490758167 0003-kamdbctl-backslash.patch
c1abf69b48847dc8c7ab0d11ef9adb531aa4635f9d44db6933981edc5a47df374664fb24867b19aa64abbcc9777bf1cd0360d9aea54e27b081065928c61e0f0b kamailio.cfg
cd6e3b677d803cd78561ad14d9b2589fd35ad0096f48047fdcb4ddc7d9103871357efba3b350946844cb53dbb081210746421fc420c22ac845b90251168a628e kamailio.initd"
diff --git a/main/kamailio/DMQ-multi-notify.patch b/main/kamailio/DMQ-multi-notify.patch
deleted file mode 100644
index 8fa20c550..000000000
--- a/main/kamailio/DMQ-multi-notify.patch
+++ /dev/null
@@ -1,370 +0,0 @@
-diff --git a/modules/dmq/dmq.c b/modules/dmq/dmq.c
-index fcbd8f8..8deed9b 100644
---- a/modules/dmq/dmq.c
-+++ b/modules/dmq/dmq.c
-@@ -65,6 +65,7 @@ str dmq_server_socket = {0, 0};
- struct sip_uri dmq_server_uri;
-
- str dmq_notification_address = {0, 0};
-+int multi_notify = 0;
- struct sip_uri dmq_notification_uri;
- int ping_interval = MIN_PING_INTERVAL;
-
-@@ -112,6 +113,7 @@ static param_export_t params[] = {
- {"ping_interval", INT_PARAM, &ping_interval},
- {"server_address", PARAM_STR, &dmq_server_address},
- {"notification_address", PARAM_STR, &dmq_notification_address},
-+ {"multi_notify", INT_PARAM, &multi_notify},
- {0, 0, 0}
- };
-
-diff --git a/modules/dmq/dmq.h b/modules/dmq/dmq.h
-index eedadb3..f96ac03 100644
---- a/modules/dmq/dmq.h
-+++ b/modules/dmq/dmq.h
-@@ -47,6 +47,7 @@ extern str dmq_request_method;
- extern str dmq_server_socket;
- extern struct sip_uri dmq_server_uri;
- extern str dmq_notification_address;
-+extern int multi_notify;
- extern struct sip_uri dmq_notification_uri;
- /* sl and tm */
- extern struct tm_binds tmb;
-diff --git a/modules/dmq/doc/dmq_admin.xml b/modules/dmq/doc/dmq_admin.xml
-index 7eabc1a..7e9c048 100644
---- a/modules/dmq/doc/dmq_admin.xml
-+++ b/modules/dmq/doc/dmq_admin.xml
-@@ -101,6 +101,26 @@ modparam("dmq", "notification_address", "sip:10.0.0.21:5060")
- </programlisting>
- </example>
- </section>
-+ <section id="dmq.p.multi_notify">
-+ <title><varname>multi_notify</varname>(int)</title>
-+ <para>
-+ Enables the ability to resolve multiple IPv4/IPv6 addresses for a single notification address.
-+ </para>
-+ <para>
-+ A value of zero resolves to the first IP address found. A non-zero value resolves to all IP addresses associated with the host. This includes addresses from DNS SRV records, A and AAAA records.
-+ </para>
-+ <para>
-+ <emphasis>Default value is <quote>0</quote>.</emphasis>
-+ </para>
-+ <example>
-+ <title>Set <varname>multi_notify</varname> parameter</title>
-+ <programlisting format="linespecific">
-+...
-+modparam("dmq", "multi_notify", 1)
-+...
-+</programlisting>
-+ </example>
-+ </section>
- <section id="dmq.p.num_workers">
- <title><varname>num_workers</varname>(int)</title>
- <para>
-diff --git a/modules/dmq/notification_peer.c b/modules/dmq/notification_peer.c
-index 2acb9a8..2f281c5 100644
---- a/modules/dmq/notification_peer.c
-+++ b/modules/dmq/notification_peer.c
-@@ -26,6 +26,9 @@
-
- #include "notification_peer.h"
-
-+#define MAXDMQURILEN 255
-+#define MAXDMQHOSTS 30
-+
- str notification_content_type = str_init("text/plain");
- dmq_resp_cback_t notification_callback = {&notification_resp_callback_f, 0};
-
-@@ -58,27 +61,277 @@ error:
- return -1;
- }
-
-+/**********
-+* Create IP URI
-+*
-+* INPUT:
-+* Arg (1) = container for hosts
-+* Arg (2) = host index
-+* Arg (3) = host name pointer
-+* Arg (4) = host name length
-+* Arg (5) = parsed URI pointer
-+* OUTPUT: 0=unable to create URI
-+**********/
-+
-+int create_IP_uri (char **puri_list, int host_index, char *phost,
-+ int hostlen, sip_uri_t *puri)
-+
-+{
-+ int pos;
-+ char *plist;
-+ char *perr = "notification host count reached max!\n";
-+
-+ /**********
-+ * insert
-+ * o scheme
-+ * o user name/password
-+ * o host
-+ * o port
-+ * o parameters
-+ **********/
-+
-+ plist = puri_list [host_index];
-+ if (puri->type == SIPS_URI_T) {
-+ strncpy (plist, "sips:", 5);
-+ pos = 5;
-+ } else {
-+ strncpy (plist, "sip:", 4);
-+ pos = 4;
-+ }
-+ if (puri->user.s) {
-+ strncpy (&plist [pos], puri->user.s, puri->user.len);
-+ pos += puri->user.len;
-+ if (puri->passwd.s) {
-+ plist [pos++] = ':';
-+ strncpy (&plist [pos], puri->passwd.s, puri->passwd.len);
-+ pos += puri->passwd.len;
-+ }
-+ plist [pos++] = '@';
-+ }
-+ if ((pos + hostlen) > MAXDMQURILEN) {
-+ LM_WARN ("%s", perr);
-+ return 0;
-+ }
-+ strncpy (&plist [pos], phost, hostlen);
-+ pos += hostlen;
-+ if (puri->port_no) {
-+ if ((pos + 6) > MAXDMQURILEN) {
-+ LM_WARN ("%s", perr);
-+ return 0;
-+ }
-+ plist [pos++] = ':';
-+ pos += ushort2sbuf (puri->port_no, &plist [pos], 5);
-+ }
-+ if (puri->params.s) {
-+ if ((pos + puri->params.len) >= MAXDMQURILEN) {
-+ LM_WARN ("%s", perr);
-+ return 0;
-+ }
-+ plist [pos++] = ';';
-+ strncpy (&plist [pos], puri->params.s, puri->params.len);
-+ pos += puri->params.len;
-+ }
-+ plist [pos] = '\0';
-+ return 1;
-+}
-+
-+/**********
-+* Get DMQ Host List
-+*
-+* INPUT:
-+* Arg (1) = container for hosts
-+* Arg (2) = maximum number of hosts
-+* Arg (3) = host string pointer
-+* Arg (4) = parsed URI pointer
-+* Arg (5) = search SRV flag
-+* OUTPUT: number of hosts found
-+**********/
-+
-+int get_dmq_host_list (char **puri_list, int max_hosts, str *phost,
-+ sip_uri_t *puri, int bSRV)
-+
-+{
-+ int host_cnt, len;
-+ unsigned short origport, port;
-+ str pstr [1];
-+ char pname [256], pIP [IP6_MAX_STR_SIZE + 2];
-+ struct rdata *phead, *prec;
-+ struct srv_rdata *psrv;
-+
-+ /**********
-+ * o IP address?
-+ * o make null terminated name
-+ * o search SRV?
-+ **********/
-+
-+ if (str2ip (phost) || str2ip6 (phost)) {
-+ if (!create_IP_uri (puri_list, 0, phost->s, phost->len, puri)) {
-+ LM_DBG ("adding DMQ node IP host %.*s=%s\n",
-+ phost->len, phost->s, puri_list [0]);
-+ return 0;
-+ }
-+ return 1;
-+ }
-+ strncpy (pname, phost->s, phost->len);
-+ pname [phost->len] = '\0';
-+ host_cnt = 0;
-+ if (bSRV) {
-+ /**********
-+ * get SRV records
-+ **********/
-+
-+ port = puri->port_no;
-+ phead = get_record (pname, T_SRV, RES_ONLY_TYPE);
-+ for (prec = phead; prec; prec = prec->next) {
-+ /**********
-+ * o matching port?
-+ * o check max
-+ * o save original port
-+ * o check target
-+ * o restore port
-+ **********/
-+
-+ psrv = (struct srv_rdata *) prec->rdata;
-+ if (port && (port != psrv->port))
-+ { continue; }
-+ if (host_cnt == max_hosts) {
-+ LM_WARN ("notification host count reached max!\n");
-+ free_rdata_list (phead);
-+ return host_cnt;
-+ }
-+ pstr->s = psrv->name;
-+ pstr->len = psrv->name_len;
-+ origport = puri->port_no;
-+ puri->port_no = psrv->port;
-+ host_cnt += get_dmq_host_list (&puri_list [host_cnt],
-+ MAXDMQHOSTS - host_cnt, pstr, puri, 0);
-+ puri->port_no = origport;
-+ }
-+ if (phead)
-+ free_rdata_list (phead);
-+ }
-+
-+ /**********
-+ * get A records
-+ **********/
-+
-+ phead = get_record (pname, T_A, RES_ONLY_TYPE);
-+ for (prec = phead; prec; prec = prec->next) {
-+ /**********
-+ * o check max
-+ * o create URI
-+ **********/
-+
-+ if (host_cnt == max_hosts) {
-+ LM_WARN ("notification host count reached max!\n");
-+ free_rdata_list (phead);
-+ return host_cnt;
-+ }
-+ len = ip4tosbuf (((struct a_rdata *) prec->rdata)->ip,
-+ pIP, IP4_MAX_STR_SIZE);
-+ pIP [len] = '\0';
-+ if (create_IP_uri (puri_list, host_cnt, pIP, len, puri)) {
-+ LM_DBG ("adding DMQ node A host %s=%s\n", pname, puri_list [host_cnt]);
-+ host_cnt++;
-+ }
-+ }
-+ if (phead)
-+ free_rdata_list (phead);
-+
-+ /**********
-+ * get AAAA records
-+ **********/
-+
-+ phead = get_record (pname, T_AAAA, RES_ONLY_TYPE);
-+ for (prec = phead; prec; prec = prec->next) {
-+ /**********
-+ * o check max
-+ * o create URI
-+ **********/
-+
-+ if (host_cnt == max_hosts) {
-+ LM_WARN ("notification host count reached max!\n");
-+ free_rdata_list (phead);
-+ return host_cnt;
-+ }
-+ pIP [0] = '[';
-+ len = ip6tosbuf (((struct aaaa_rdata *) prec->rdata)->ip6,
-+ &pIP [1], IP6_MAX_STR_SIZE) + 1;
-+ pIP [len++] = ']';
-+ pIP [len] = '\0';
-+ if (create_IP_uri (puri_list, host_cnt, pIP, len, puri)) {
-+ LM_DBG
-+ ("adding DMQ node AAAA host %s=%s\n", pname, puri_list [host_cnt]);
-+ host_cnt++;
-+ }
-+ }
-+ if (phead)
-+ free_rdata_list (phead);
-+ return host_cnt;
-+}
-+
- /**
- * @brief add a server node and notify it
- */
--dmq_node_t* add_server_and_notify(str* server_address)
-+dmq_node_t* add_server_and_notify (str *paddr)
-+
- {
-- /* add the notification server to the node list - if any */
-- dmq_node_t* node;
--
-- node = add_dmq_node(node_list, server_address);
-- if(!node) {
-- LM_ERR("error adding notification node\n");
-- goto error;
-+ char puri_data [MAXDMQHOSTS * (MAXDMQURILEN + 1)];
-+ char *puri_list [MAXDMQHOSTS];
-+ dmq_node_t *pfirst, *pnode;
-+ int host_cnt, index;
-+ sip_uri_t puri [1];
-+ str pstr [1];
-+
-+ /**********
-+ * o init data area
-+ * o get list of hosts
-+ * o process list
-+ **********/
-+
-+ if (!multi_notify) {
-+ pfirst = add_dmq_node (node_list, paddr);
-+ } else {
-+ /**********
-+ * o init data area
-+ * o get list of hosts
-+ * o process list
-+ **********/
-+
-+ for (index = 0; index < MAXDMQHOSTS; index++) {
-+ puri_list [index] = &puri_data [index * (MAXDMQURILEN + 1)];
-+ }
-+ if (parse_uri (paddr->s, paddr->len, puri) < 0) {
-+ /* this is supposed to be good but just in case... */
-+ LM_ERR ("add_server_and_notify address invalid\n");
-+ return 0;
-+ }
-+ pfirst = NULL;
-+ host_cnt =
-+ get_dmq_host_list (puri_list, MAXDMQHOSTS, &puri->host, puri, 1);
-+ for (index = 0; index < host_cnt; index++) {
-+ pstr->s = puri_list [index];
-+ pstr->len = strlen (puri_list [index]);
-+ pnode = add_dmq_node (node_list, pstr);
-+ if (pnode && !pfirst)
-+ { pfirst = pnode; }
-+ }
- }
-- /* request initial list from the notification server */
-- if(request_nodelist(node, 2) < 0) {
-- LM_ERR("error requesting initial nodelist\n");
-- goto error;
-+
-+ /**********
-+ * o found at least one?
-+ * o request node list
-+ **********/
-+
-+ if (!pfirst) {
-+ LM_ERR ("error adding notification node\n");
-+ return NULL;
- }
-- return node;
--error:
-- return NULL;
-+ if (request_nodelist (pfirst, 2) < 0) {
-+ LM_ERR ("error requesting initial nodelist\n");
-+ return NULL;
-+ }
-+ return pfirst;
- }
-
- /**
diff --git a/main/kamailio/default_ctl.patch b/main/kamailio/default_ctl.patch
deleted file mode 100644
index c33e16049..000000000
--- a/main/kamailio/default_ctl.patch
+++ /dev/null
@@ -1,91 +0,0 @@
---- kamailio-4.2.3.orig/etc/kamailio-basic.cfg
-+++ kamailio-4.2.3/etc/kamailio-basic.cfg
-@@ -191,8 +191,10 @@
-
-
- # ----- mi_fifo params -----
--modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")
-+modparam("mi_fifo", "fifo_name", "/var/run/kamailio/kamailio_fifo")
-
-+# ----- ctl params -----
-+modparam("ctl", "binrpc", "unix:/var/run/kamailio/kamailio_ctl")
-
- # ----- tm params -----
- # auto-discard branches from previous serial forking leg
-Only in kamailio-4.2.3: etc/kamailio-basic.cfg.orig
---- kamailio-4.2.3.orig/etc/kamailio-oob.cfg
-+++ kamailio-4.2.3/etc/kamailio-oob.cfg
-@@ -315,8 +315,10 @@
-
-
- # ----- mi_fifo params -----
--modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")
-+modparam("mi_fifo", "fifo_name", "/var/run/kamailio/kamailio_fifo")
-
-+# ----- ctl params -----
-+modparam("ctl", "binrpc", "unix:/var/run/kamailio/kamailio_ctl")
-
- # ----- tm params -----
- # auto-discard branches from previous serial forking leg
-Only in kamailio-4.2.3: etc/kamailio-oob.cfg.orig
---- kamailio-4.2.3.orig/etc/kamailio.cfg
-+++ kamailio-4.2.3/etc/kamailio.cfg
-@@ -288,8 +288,10 @@
-
-
- # ----- mi_fifo params -----
--modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")
-+modparam("mi_fifo", "fifo_name", "/var/run/kamailio/kamailio_fifo")
-
-+# ----- ctl params -----
-+modparam("ctl", "binrpc", "unix:/var/run/kamailio/kamailio_ctl")
-
- # ----- tm params -----
- # auto-discard branches from previous serial forking leg
-Only in kamailio-4.2.3: etc/kamailio.cfg.orig
---- kamailio-4.2.3.orig/modules/ctl/ctl_defaults.h
-+++ kamailio-4.2.3/modules/ctl/ctl_defaults.h
-@@ -6,10 +6,10 @@
- /*listen by default on: */
- #ifdef SRNAME
- /* this is used when compiling sercmd tool */
--#define DEFAULT_CTL_SOCKET "unixs:/tmp/" SRNAME "_ctl"
-+#define DEFAULT_CTL_SOCKET "unixs:/var/run/" SRNAME "/" SRNAME "_ctl"
- #else
- /* this is used when compiling sip server */
--#define DEFAULT_CTL_SOCKET "unixs:/tmp/" NAME "_ctl"
-+#define DEFAULT_CTL_SOCKET "unixs:/var/run/" NAME "/" NAME "_ctl"
- #endif
- /* port used by default for tcp/udp if no port is explicitely specified */
- #define DEFAULT_CTL_PORT 2049
---- kamailio-4.2.3.orig/modules/mi_fifo/README
-+++ kamailio-4.2.3/modules/mi_fifo/README
-@@ -117,7 +117,7 @@
-
- Example 1.1. Set fifo_name parameter
- ...
--modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")
-+modparam("mi_fifo", "fifo_name", "/var/run/kamailio/kamailio_fifo")
- ...
-
- 4.2. fifo_mode (integer)
-@@ -160,7 +160,7 @@
-
- Directory to be used for creating the reply FIFO files.
-
-- Default value is "/tmp/"
-+ Default value is "/var/run/kamailio/"
-
- Example 1.5. Set reply_dir parameter
- ...
---- kamailio-4.2.3.orig/modules/mi_fifo/mi_fifo.h
-+++ kamailio-4.2.3/modules/mi_fifo/mi_fifo.h
-@@ -34,7 +34,7 @@
- #ifndef _MI_FIFO_H_
- #define _MI_FIFO_H_
-
--#define DEFAULT_MI_REPLY_DIR "/tmp/"
-+#define DEFAULT_MI_REPLY_DIR "/var/run/kamailio/"
-
- #define DEFAULT_MI_REPLY_IDENT "\t"
-
diff --git a/main/kamailio/kamailio-4.2-ipops-srv-query.patch b/main/kamailio/kamailio-4.2-ipops-srv-query.patch
deleted file mode 100644
index cdae3e628..000000000
--- a/main/kamailio/kamailio-4.2-ipops-srv-query.patch
+++ /dev/null
@@ -1,659 +0,0 @@
-Only in b: ipops.patch
---- a/modules/ipops/ipops_mod.c
-+++ b/modules/ipops/ipops_mod.c
-@@ -21,6 +21,7 @@
- *
- * History:
- * -------
-+ * 2015-02-04: Added srv_query function (rboisvert)
- * 2011-07-29: Added a function to detect RFC1918 private IPv4 addresses (ibc)
- * 2011-04-27: Initial version (ibc)
- */
-@@ -92,10 +93,13 @@
- static int w_dns_int_match_ip(sip_msg_t*, char*, char*);
-
- static int w_dns_query(struct sip_msg* msg, char* str1, char* str2);
-+static int w_srv_query(struct sip_msg* msg, char* str1, char* str2);
-
- static pv_export_t mod_pvs[] = {
- { {"dns", sizeof("dns")-1}, PVT_OTHER, pv_get_dns, 0,
- pv_parse_dns_name, 0, 0, 0 },
-+ { {"srvquery", sizeof("srvquery")-1}, PVT_OTHER, pv_get_srv, 0,
-+ pv_parse_srv_name, 0, 0, 0 },
- { {"HN", sizeof("HN")-1}, PVT_OTHER, pv_get_hn, 0,
- pv_parse_hn_name, 0, 0, 0 },
- { {0, 0}, 0, 0, 0, 0, 0, 0, 0 }
-@@ -132,6 +136,8 @@
- ANY_ROUTE },
- { "dns_query", (cmd_function)w_dns_query, 2, fixup_spve_spve, 0,
- ANY_ROUTE },
-+ { "srv_query", (cmd_function)w_srv_query, 2, fixup_spve_spve, 0,
-+ ANY_ROUTE },
- { "bind_ipops", (cmd_function)bind_ipops, 0, 0, 0, 0},
- { 0, 0, 0, 0, 0, 0 }
- };
-@@ -772,4 +778,32 @@
- }
-
- return dns_update_pv(&hostname, &name);
-+}
-+
-+/**
-+ *
-+ */
-+static int w_srv_query(struct sip_msg* msg, char* str1, char* str2)
-+{
-+ str srvcname;
-+ str name;
-+
-+ if(msg==NULL)
-+ {
-+ LM_ERR("received null msg\n");
-+ return -1;
-+ }
-+
-+ if(fixup_get_svalue(msg, (gparam_t*)str1, &srvcname)<0)
-+ {
-+ LM_ERR("cannot get the srvcname\n");
-+ return -1;
-+ }
-+ if(fixup_get_svalue(msg, (gparam_t*)str2, &name)<0)
-+ {
-+ LM_ERR("cannot get the pvid name\n");
-+ return -1;
-+ }
-+
-+ return srv_update_pv(&srvcname, &name);
- }
---- a/modules/ipops/ipops_pv.c
-+++ b/modules/ipops/ipops_pv.c
-@@ -32,6 +32,7 @@
- #include <netinet/in.h>
-
- #include "../../dprint.h"
-+#include "../../rand/fastrand.h"
- #include "../../hashes.h"
- #include "../../resolve.h"
- #include "../../pvar.h"
-@@ -66,7 +67,6 @@
- int nidx;
- } dns_pv_t;
-
--
- static sr_dns_item_t *_sr_dns_list = NULL;
-
- /**
-@@ -132,7 +132,6 @@
- return it;
- }
-
--
- /**
- *
- */
-@@ -431,7 +430,6 @@
- return 1;
- }
-
--
- struct _hn_pv_data {
- str data;
- str fullname;
-@@ -594,4 +592,544 @@
- return pv_get_null(msg, param, res);;
- return pv_get_strval(msg, param, res, &_hn_data->hostname);
- }
-+}
-+
-+/**********
-+* srvquery PV
-+**********/
-+
-+static char *srvqrylst []
-+ = {"count", "port", "priority", "target", "weight", NULL};
-+
-+#define PV_SRV_MAXSTR 64
-+#define PV_SRV_MAXRECS 32
-+
-+typedef struct _sr_srv_record {
-+ unsigned short priority;
-+ unsigned short weight;
-+ unsigned short port;
-+ char target [PV_SRV_MAXSTR + 1];
-+} sr_srv_record_t;
-+
-+typedef struct _sr_srv_item {
-+ str pvid;
-+ unsigned int hashid;
-+ int count;
-+ sr_srv_record_t rr [PV_SRV_MAXRECS];
-+ struct _sr_srv_item *next;
-+} sr_srv_item_t;
-+
-+typedef struct _srv_pv {
-+ sr_srv_item_t *item;
-+ int type;
-+ int flags;
-+ pv_spec_t *pidx;
-+ int nidx;
-+} srv_pv_t;
-+
-+static sr_srv_item_t *_sr_srv_list = NULL;
-+
-+/**********
-+* Add srvquery Item
-+*
-+* INPUT:
-+* Arg (1) = pvid string pointer
-+* Arg (2) = find flag; <>0=search only
-+* OUTPUT: srv record pointer; NULL=not found
-+**********/
-+
-+sr_srv_item_t *sr_srv_add_item (str *pvid, int findflg)
-+
-+{
-+sr_srv_item_t *pitem;
-+unsigned int hashid;
-+
-+/**********
-+* o get hash
-+* o already exists?
-+**********/
-+
-+hashid = get_hash1_raw (pvid->s, pvid->len);
-+for (pitem = _sr_srv_list; pitem; pitem = pitem->next) {
-+ if (pitem->hashid == hashid
-+ && pitem->pvid.len == pvid->len
-+ && !strncmp (pitem->pvid.s, pvid->s, pvid->len))
-+ return pitem;
-+}
-+if (findflg)
-+ return NULL;
-+
-+/**********
-+* o alloc/init item structure
-+* o link in new item
-+**********/
-+
-+pitem = (sr_srv_item_t *) pkg_malloc (sizeof (sr_srv_item_t));
-+if (!pitem) {
-+ LM_ERR ("No more pkg memory!\n");
-+ return NULL;
-+}
-+memset (pitem, 0, sizeof (sr_srv_item_t));
-+pitem->pvid.s = (char *) pkg_malloc (pvid->len + 1);
-+if (!pitem->pvid.s) {
-+ LM_ERR ("No more pkg memory!\n");
-+ pkg_free (pitem);
-+ return NULL;
-+}
-+memcpy (pitem->pvid.s, pvid->s, pvid->len);
-+pitem->pvid.len = pvid->len;
-+pitem->hashid = hashid;
-+pitem->next = _sr_srv_list;
-+_sr_srv_list = pitem;
-+return pitem;
-+}
-+
-+/**********
-+* Skip Over
-+*
-+* INPUT:
-+* Arg (1) = string pointer
-+* Arg (2) = starting position
-+* Arg (3) = whitespace flag
-+* OUTPUT: position past skipped
-+**********/
-+
-+int skip_over (str *pstr, int pos, int bWS)
-+
-+{
-+char *pchar;
-+
-+/**********
-+* o string exists?
-+* o skip over
-+**********/
-+
-+if (pos >= pstr->len)
-+ return pstr->len;
-+for (pchar = &pstr->s [pos]; pos < pstr->len; pchar++, pos++) {
-+ if (*pchar == ' ' || *pchar == '\t' || *pchar == '\n' || *pchar == '\r') {
-+ if (bWS)
-+ continue;
-+ }
-+ if ((*pchar>='A' && *pchar<='Z') || (*pchar>='a' && *pchar<='z')
-+ || (*pchar>='0' && *pchar<='9')) {
-+ if (!bWS)
-+ continue;
-+ }
-+ break;
-+}
-+return pos;
-+}
-+
-+/**********
-+* Sort SRV Records by Weight (RFC 2782)
-+*
-+* INPUT:
-+* Arg (1) = pointer to array of SRV records
-+* Arg (2) = first record in range
-+* Arg (3) = last record in range
-+* OUTPUT: position past skipped
-+**********/
-+
-+void sort_weights (struct srv_rdata **plist, int pos1, int pos2)
-+
-+{
-+int idx1, idx2, lastfound;
-+struct srv_rdata *wlist [PV_SRV_MAXRECS];
-+unsigned int rand, sum, sums [PV_SRV_MAXRECS];
-+
-+/**********
-+* place zero weights in the unordered list and then non-zero
-+**********/
-+
-+idx2 = 0;
-+for (idx1 = pos1; idx1 <= pos2; idx1++) {
-+ if (!plist [idx1]->weight) {
-+ wlist [idx2++] = plist [idx1];
-+ }
-+}
-+for (idx1 = pos1; idx1 <= pos2; idx1++) {
-+ if (plist [idx1]->weight) {
-+ wlist [idx2++] = plist [idx1];
-+ }
-+}
-+
-+/**********
-+* generate running sum list
-+**********/
-+
-+sum = 0;
-+for (idx1 = 0; idx1 < idx2; idx1++) {
-+ sum += wlist [idx1]->weight;
-+ sums [idx1] = sum;
-+}
-+
-+/**********
-+* resort randomly
-+**********/
-+
-+lastfound = 0;
-+for (idx1 = pos1; idx1 <= pos2; idx1++) {
-+ /**********
-+ * o calculate a random number in range
-+ * o find first unsorted
-+ **********/
-+
-+ rand = fastrand_max (sum);
-+ for (idx2 = 0; idx2 <= pos2 - pos1; idx2++) {
-+ if (!wlist [idx2]) {
-+ continue;
-+ }
-+ if (sums [idx2] >= rand) {
-+ plist [idx1] = wlist [idx2];
-+ wlist [idx2] = 0;
-+ break;
-+ }
-+ lastfound = idx2;
-+ }
-+ if (idx2 > pos2 - pos1) {
-+ plist [idx1] = wlist [lastfound];
-+ wlist [lastfound] = 0;
-+ }
-+}
-+return;
-+}
-+
-+/**********
-+* Sort SRV Records by Priority/Weight
-+*
-+* INPUT:
-+* Arg (1) = pointer to array of SRV records
-+* Arg (2) = record count
-+* OUTPUT: position past skipped
-+**********/
-+
-+void sort_srv (struct srv_rdata **plist, int rcount)
-+
-+{
-+int idx1, idx2;
-+struct srv_rdata *pswap;
-+
-+/**********
-+* sort by priority
-+**********/
-+
-+for (idx1 = 1; idx1 < rcount; idx1++) {
-+ pswap = plist [idx1];
-+ for (idx2 = idx1;
-+ idx2 && (plist [idx2 - 1]->priority > pswap->priority); --idx2) {
-+ plist [idx2] = plist [idx2 - 1];
-+ }
-+ plist [idx2] = pswap;
-+}
-+
-+/**********
-+* check for multiple priority
-+**********/
-+
-+idx2 = 0;
-+pswap = plist [0];
-+for (idx1 = 1; idx1 <= rcount; idx1++) {
-+ if ((idx1 == rcount) || (pswap->priority != plist [idx1]->priority)) {
-+ /**********
-+ * o range has more than one element?
-+ * o restart range
-+ **********/
-+
-+ if (idx1 - idx2 - 1) {
-+ sort_weights (plist, idx2, idx1 - 1);
-+ }
-+ idx2 = idx1;
-+ pswap = plist [idx2];
-+ }
-+}
-+return;
-+}
-+
-+/**********
-+* Parse srvquery Name
-+*
-+* INPUT:
-+* Arg (1) = pv spec pointer
-+* Arg (2) = input string pointer
-+* OUTPUT: 0=success
-+**********/
-+
-+int pv_parse_srv_name (pv_spec_t *sp, str *in)
-+
-+{
-+char *pstr;
-+int i, pos, sign;
-+srv_pv_t *dpv;
-+str pvi, pvk, pvn;
-+
-+/**********
-+* o alloc/init pvid structure
-+* o extract pvid name
-+* o check separator
-+**********/
-+
-+if (!sp || !in || in->len<=0)
-+ return -1;
-+dpv = (srv_pv_t *) pkg_malloc (sizeof (srv_pv_t));
-+if (!dpv) {
-+ LM_ERR ("No more pkg memory!\n");
-+ return -1;
-+}
-+memset (dpv, 0, sizeof (srv_pv_t));
-+pos = skip_over (in, 0, 1);
-+if (pos == in->len)
-+ goto error;
-+pvn.s = &in->s [pos];
-+pvn.len = pos;
-+pos = skip_over (in, pos, 0);
-+pvn.len = pos - pvn.len;
-+if (!pvn.len)
-+ goto error;
-+pos = skip_over (in, pos, 1);
-+if ((pos + 2) > in->len)
-+ goto error;
-+if (strncmp (&in->s [pos], "=>", 2))
-+ goto error;
-+
-+/**********
-+* o extract key name
-+* o check key name
-+* o count?
-+**********/
-+
-+pos = skip_over (in, pos + 2, 1);
-+pvk.s = &in->s [pos];
-+pvk.len = pos;
-+pos = skip_over (in, pos, 0);
-+pvk.len = pos - pvk.len;
-+if (!pvk.len)
-+ goto error;
-+for (i = 0; srvqrylst [i]; i++) {
-+ if (strlen (srvqrylst [i]) != pvk.len)
-+ continue;
-+ if (!strncmp (pvk.s, srvqrylst [i], pvk.len)) {
-+ dpv->type = i;
-+ break;
-+ }
-+}
-+if (!srvqrylst [i])
-+ goto error;
-+if (!i)
-+ goto noindex;
-+
-+/**********
-+* o check for array
-+* o extract array index and check
-+**********/
-+
-+pos = skip_over (in, pos, 1);
-+if ((pos + 3) > in->len)
-+ goto error;
-+if (in->s [pos] != '[')
-+ goto error;
-+pos = skip_over (in, pos + 1, 1);
-+if ((pos + 2) > in->len)
-+ goto error;
-+pvi.s = &in->s [pos];
-+pvi.len = pos;
-+if (in->s [pos] == PV_MARKER) {
-+ /**********
-+ * o search from the end back to array close
-+ * o get PV value
-+ **********/
-+
-+ for (i = in->len - 1; i != pos; --i) {
-+ if (in->s [i] == ']')
-+ break;
-+ }
-+ if (i == pos)
-+ goto error;
-+ pvi.len = i - pvi.len;
-+ pos = i + 1;
-+ dpv->pidx = pv_cache_get (&pvi);
-+ if (!dpv->pidx)
-+ goto error;
-+ dpv->flags |= SR_DNS_PVIDX;
-+} else {
-+ /**********
-+ * o get index value
-+ * o check for reverse index
-+ * o convert string to number
-+ **********/
-+
-+ pos = skip_over (in, pos, 0);
-+ pvi.len = pos - pvi.len;
-+ sign = 1;
-+ i = 0;
-+ pstr = pvi.s;
-+ if (*pstr == '-') {
-+ sign = -1;
-+ i++;
-+ pstr++;
-+ }
-+ for (dpv->nidx = 0; i < pvi.len; i++) {
-+ if (*pstr >= '0' && *pstr <= '9')
-+ dpv->nidx = (dpv->nidx * 10) + *pstr++ - '0';
-+ }
-+ if (i != pvi.len)
-+ goto error;
-+ dpv->nidx *= sign;
-+ pos = skip_over (in, pos, 1);
-+ if (pos == in->len)
-+ goto error;
-+ if (in->s [pos++] != ']')
-+ goto error;
-+}
-+
-+/**********
-+* o check for trailing whitespace
-+* o add data to PV
-+**********/
-+
-+noindex:
-+if (skip_over (in, pos, 1) != in->len)
-+ goto error;
-+LM_DBG ("srvquery (%.*s => %.*s [%.*s])\n",
-+ pvn.len, pvn.s, pvk.len, pvk.s, pvi.len, pvi.s);
-+dpv->item = sr_srv_add_item (&pvn, 0);
-+if (!dpv->item)
-+ goto error;
-+sp->pvp.pvn.u.dname = (void *)dpv;
-+sp->pvp.pvn.type = PV_NAME_OTHER;
-+return 0;
-+
-+error:
-+LM_ERR ("error at PV srvquery: %.*s@%d\n", in->len, in->s, pos);
-+pkg_free (dpv);
-+return -1;
-+}
-+
-+int srv_update_pv (str *srvcname, str *pvid)
-+
-+{
-+int idx1, idx2, rcount;
-+struct rdata *phead, *psrv;
-+struct srv_rdata *plist [PV_SRV_MAXRECS];
-+sr_srv_item_t *pitem;
-+sr_srv_record_t *prec;
-+
-+/**********
-+* o service name missing?
-+* o find pvid
-+**********/
-+
-+if (!srvcname->len) {
-+ LM_DBG ("service name missing: %.*s\n", srvcname->len, srvcname->s);
-+ return -2;
-+}
-+pitem = sr_srv_add_item (pvid, 1);
-+if (!pitem) {
-+ LM_DBG ("pvid not found: %.*s\n", pvid->len, pvid->s);
-+ return -3;
-+}
-+
-+/**********
-+* o get records
-+* o sort by priority/weight
-+* o save to PV
-+**********/
-+
-+LM_DBG ("attempting to query: %.*s\n", srvcname->len, srvcname->s);
-+phead = get_record (srvcname->s, T_SRV, RES_ONLY_TYPE);
-+rcount = 0;
-+for (psrv = phead; psrv; psrv = psrv->next) {
-+ if (rcount < PV_SRV_MAXRECS) {
-+ plist [rcount++] = (struct srv_rdata *) psrv->rdata;
-+ } else {
-+ LM_WARN ("truncating srv_query list to %d records!", PV_SRV_MAXRECS);
-+ break;
-+ }
-+}
-+pitem->count = rcount;
-+if (rcount)
-+ sort_srv (plist, rcount);
-+for (idx1 = 0; idx1 < rcount; idx1++) {
-+ prec = &pitem->rr [idx1];
-+ prec->priority = plist [idx1]->priority;
-+ prec->weight = plist [idx1]->weight;
-+ prec->port = plist [idx1]->port;
-+ idx2 = plist [idx1]->name_len;
-+ if (idx2 > PV_SRV_MAXSTR) {
-+ LM_WARN ("truncating srv_query target (%.*s)!", idx2, plist [idx1]->name);
-+ idx2 = PV_SRV_MAXSTR;
-+ }
-+ strncpy (prec->target, plist [idx1]->name, idx2);
-+ prec->target [idx2] = '\0';
-+}
-+if (phead)
-+ free_rdata_list (phead);
-+LM_DBG ("srvquery PV updated for: %.*s (%d)\n",
-+ srvcname->len, srvcname->s, rcount);
-+return 1;
-+}
-+
-+/**********
-+* Get srvquery Values
-+*
-+* INPUT:
-+* Arg (1) = SIP message pointer
-+* Arg (2) = parameter pointer
-+* Arg (3) = PV value pointer
-+* OUTPUT: 0=success
-+**********/
-+
-+int pv_get_srv (sip_msg_t *pmsg, pv_param_t *param, pv_value_t *res)
-+
-+{
-+pv_value_t val;
-+srv_pv_t *dpv;
-+
-+/**********
-+* o sipmsg and param exist?
-+* o PV name exists?
-+* o count?
-+**********/
-+
-+if(!pmsg || !param)
-+ return -1;
-+dpv = (srv_pv_t *) param->pvn.u.dname;
-+if(!dpv || !dpv->item)
-+ return -1;
-+if (!dpv->type)
-+ return pv_get_sintval (pmsg, param, res, dpv->item->count);
-+
-+/**********
-+* o get index value
-+* o reverse index?
-+* o extract data
-+**********/
-+
-+if (!dpv->pidx) {
-+ val.ri = dpv->nidx;
-+} else {
-+ if (pv_get_spec_value (pmsg, dpv->pidx, &val) < 0
-+ || !(val.flags & PV_VAL_INT)) {
-+ LM_ERR ("failed to evaluate index variable!\n");
-+ return pv_get_null (pmsg, param, res);
-+ }
-+}
-+if (val.ri < 0) {
-+ if ((dpv->item->count + val.ri) < 0)
-+ return pv_get_null (pmsg, param, res);
-+ val.ri = dpv->item->count + val.ri;
-+}
-+if (val.ri >= dpv->item->count)
-+ return pv_get_null(pmsg, param, res);
-+switch (dpv->type) {
-+ case 1: /* port */
-+ return pv_get_sintval (pmsg, param, res, dpv->item->rr [val.ri].port);
-+ case 2: /* priority */
-+ return pv_get_sintval (pmsg, param, res, dpv->item->rr [val.ri].priority);
-+ case 3: /* target */
-+ return pv_get_strzval (pmsg, param, res, dpv->item->rr [val.ri].target);
-+ case 4: /* weight */
-+ return pv_get_sintval (pmsg, param, res, dpv->item->rr [val.ri].weight);
-+}
-+return pv_get_null (pmsg, param, res);
- }
---- a/modules/ipops/ipops_pv.h
-+++ b/modules/ipops/ipops_pv.h
-@@ -39,5 +39,9 @@
- int pv_get_hn(struct sip_msg *msg, pv_param_t *param,
- pv_value_t *res);
-
-+int pv_parse_srv_name(pv_spec_t *, str *);
-+int pv_get_srv(sip_msg_t *, pv_param_t *, pv_value_t *);
-+int srv_update_pv(str *, str *);
-+
- #endif
-
-Only in b: modules/ipops/locate_sip_server.txt