Merge tag 'upstream/4.4.5'

Upstream version 4.4.5
changes/29/11029/1
Victor Seva 9 years ago
commit 431c151165

@ -1,3 +1,420 @@
===================== 2017-01-18 Version 4.4.5 Released =====================
===================== Changes Since Version 4.4.4 ===========================
commit d0e563e23a1e45111d8236482abd7733fb1f0a28
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Wed Jan 18 15:54:15 2017 +0100
Makefile.defs: version set to 4.4.5
commit 388b441bbff120d3643b22d6084e87c3843df6c0
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Wed Jan 18 15:15:24 2017 +0100
pkg: version set to 4.4.5 in deb specs
commit 91f2bf0bba902638788ba13c77cfc57d582d73cc
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Wed Jan 18 14:43:37 2017 +0100
pkg: set version to 4.4.5 in rpm specs
commit fafbc5c78d8f1456a1da28fed68778377524e5e7
Merge: 6dbadcb 18c64d2
Author: lazedo <luis.azedo@factorlusitano.com>
Date: Wed Jan 18 13:23:35 2017 +0000
Merge pull request #940 from kamailio/lazedo/db_text_fetch
db_text: implement fetch and memory constraints
commit 6dbadcbc076a78c8ace46af3215a503084eab848
Merge: aa27479 1114fe0
Author: lazedo <luis.azedo@factorlusitano.com>
Date: Wed Jan 18 13:09:12 2017 +0000
Merge pull request #938 from kamailio/lazedo/kazoo-patch-44
kazoo: fix kz_amqp_get_zones
commit 18c64d2c9ff1527655055f75aa22e7d68c307874
Author: lazedo <luis.azedo@factorlusitano.com>
Date: Wed Jan 18 10:00:22 2017 +0000
db_text: implement fetch and memory constraints
when dealing with large db_text files, pkg_memory is not suitable for
operating the database.
implementing fetch allows modules like presence & registrar & usrloc
to query large tables without constraints on pkg_memory.
creates tmp tables in shared memory for query results
commit 1114fe01abdb791379274b4f388317d600d72e38
Author: lazedo <luis.azedo@factorlusitano.com>
Date: Wed Jan 18 09:19:44 2017 +0000
kazoo: fix kz_amqp_add_zone
commit c84e8c5269f4823a3dce078bee4afcf583d8ef44
Author: lazedo <luis.azedo@factorlusitano.com>
Date: Wed Jan 18 08:45:14 2017 +0000
kazoo: extra logs in hash lookup
commit d4156e946e4ac99f968b8d065932a9d7570404ac
Author: lazedo <luis.azedo@factorlusitano.com>
Date: Wed Jan 18 08:42:44 2017 +0000
kazoo: initialize pointers and return default zones
commit aa27479ad204b6826aea03d777af9401ffd26a11
Author: Charles Chance <charles.chance@sipcentric.com>
Date: Tue Jan 17 22:46:57 2017 +0000
presence: delay aux_body_processing until after subscription has been updated
- fixes out-of-sequence version when subs_db_mode <> 3 and fast_notify is enabled
commit df5ef6183350d99f77087dd83950ef35466e84a1
Author: Robert Boisvert <rdbprog@gmail.com>
Date: Tue Oct 18 18:00:42 2016 -0400
mohqueue: fix pointer for RTP statistics error
(cherry picked from commit dc96dfdee3c6a8e56ed9e5929e444bf8ee2f5cdd)
Conflicts:
modules/mohqueue/mohq.c
commit 124b6d1b1a614eb6a8cf9c7b5281b4eb038751f4
Author: Kamailio Dev <kamailio.dev@kamailio.org>
Date: Tue Jan 17 14:16:11 2017 +0100
modules: readme files regenerated - dispatcher ...
commit 3e5def30a8eeae76ac7352a5b9ba4e4a2f83fe9c
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Thu Jan 12 16:34:35 2017 +0100
dialog: handle replies to local cancel for cseq updates
(cherry picked from commit fab1b5dc4edc74555b965a6c305d7643629e0225)
commit 869b496334373c7a43b6412d05d446d582be5112
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Wed Jan 11 15:22:50 2017 +0100
dialog: increase cseq after uac auth for local acks
- related to GH #918, #919
(cherry picked from commit b75d4ca219d7185e0a73cc9132760fe05227faa4)
commit 3c53097213f686833a953e69aca0c66c7021b441
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Tue Jan 10 14:26:27 2017 +0100
dialog: use uac cseq header names from cfg env
(cherry picked from commit a1189074af0946b1a4b57dff795d0f642818ad35)
commit 49370420039936554d87950cec85d5fd22bcdaca
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Tue Jan 10 14:27:06 2017 +0100
tm: if transaction had an uac auth, propagate cseq headers for local ACK and CANCEL
- related to GH #870, #918, #919
(cherry picked from commit 526ec68fa56cb8066db9da3a4b82f9e20aebf8c3)
commit 693e70cdd787beccc6edb7ed1c721a2960536cc1
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Tue Jan 10 14:25:13 2017 +0100
core: keep names for uac cseq helper headers in cfg env
- shared by dialog and tm for cseq updates after uac auth
(cherry picked from commit 391dce68f712d7b38eb48188f3ae2413da0f70c6)
commit 6dd3f8c7c0c42a25871e15a56e751d36eb305e97
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Tue Jan 17 11:54:57 2017 +0100
tm: generate from tag if not provided for request_within()
- related to GH #931
(cherry picked from commit 96ca5c95e9380a56d886fad699a5966b7b00f5b6)
commit 035ed5d420cfd46ab5af0aa37ec52fa1c4836fe0
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Tue Jan 17 13:40:26 2017 +0100
statsd: include usr_avp.h instead of usr_avp.c
- backport of commit 344baa0bae643f235e85ad8f670f412acadab0f1
commit 9902d21f5f3f76ee93cd1a9a0a63c981b1c9eb88
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Mon Dec 12 18:32:34 2016 +0100
xmlrpc: init delayed context for rpc_fault()
- may fix the GH #878, reported by Juha Heinanen
(cherry picked from commit 6b3ce6376258211d317620d4d96bd3d88788b6a3)
commit 0f7a688d8670f171be0d4f4f36c5c7a005f946a0
Author: Guilherme C Pilon <gpilon@daitangroup.com>
Date: Wed Nov 30 13:41:12 2016 -0200
ratelimit module not working properly when FEEDBACK algorithm is used - deleting unused lines
(cherry picked from commit 22b040c944228cfc7795f4481465dd230bff6f99)
commit 864c29081177204d238006f6308a6b09f982d6f5
Author: Guilherme C Pilon <gpilon@daitangroup.com>
Date: Wed Nov 30 13:33:44 2016 -0200
ratelimit module not working properly when FEEDBACK algorithm is used
(cherry picked from commit bb768faae3367c1209e735de71ab9fdcd5d068d5)
commit 125eab75cc5febcea92eddadca4be2a83f70d7a1
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Tue Jan 17 13:32:05 2017 +0100
kamctl: regenerated db creation script to update default datetime value
commit 7de5934632c0b00387c3ebc004cd86eb677711ab
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Sun Nov 27 15:38:56 2016 +0100
lib/srdb1 - set default datetime value to 2000-01-01
- 1900 is before the start of epoch and can result in unexpected
behaviour with some time related functions
(cherry picked from commit 3efa32c9cdfc7a7bdc913724fba92f7b7a76434c)
commit bc5d67854da18c1535abf2a54c7b8a5e21eea0cc
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Mon Nov 21 12:15:54 2016 +0100
rtpproxy: added note about rtpproxy_manage() afte t_continue()
- or after any other function that does suspend/resume of the
transaction
- it behaves as used in failure_route
(cherry picked from commit e128d46e6a675b8cf5f8b584850c08cd16328af4)
commit 7918a50ce645eb09d77e701526392a638f703cda
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Mon Nov 21 12:12:10 2016 +0100
rtpengine: added note about rtpproxy_manage() afte t_continue()
- or after any other function that does suspend/resume of the
transaction
- it behaves as used in failure_route
- related to GH #855
(cherry picked from commit 63f3e24ba2c0b9749f5c5d3268c633c629e20f89)
commit 95ed5f71854e747b2336b8bd3b0e7f0c4b1b5a5b
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Thu Nov 17 11:00:51 2016 +0100
tmx: added note to t_continue() docs about failure context of executed route block
(cherry picked from commit 29635011f94a142fe5cde32558b8dfd095dd7820)
commit 676b0bedfd045d7e7ffbfa5e5ecb137f8603e643
Author: Mikko Lehto <mslehto@iki.fi>
Date: Mon Nov 14 15:50:54 2016 +0200
modules/dispatcher: fixed typo in documentation
(cherry picked from commit 72f28fdcfd88b4f915156a992a6b1f12db79edc5)
commit b1502145939ca9aec0ae73d93477eb5492e8536b
Author: Armen Babikyan <armen@firespotter.com>
Date: Sat Nov 12 22:57:41 2016 -0800
memcached: fix deletion bug
(cherry picked from commit c5f6cce69d7cae48f0769d89e9098a8526089055)
commit 97d70c15a35195f0345c4143f29962b2bd0632de
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Fri Nov 11 14:32:31 2016 +0100
jsonrpc-s: added section to show examples with rpc commands over jsonrpc
(cherry picked from commit cdd703dcae172ad0692877addaa9fea80c06defc)
commit 61a30f8432100118a1b9d3ed731f986900f80352
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Thu Nov 10 09:45:02 2016 +0100
async: updated to the name of functions for timers instead of macros
(cherry picked from commit 60269ead4973b745f529e42c6e2c60287a040c64)
commit 1e2dcd44036577377dce14bd71a9f238d4c7e355
Author: Kamailio Dev <kamailio.dev@kamailio.org>
Date: Tue Jan 17 10:31:12 2017 +0100
modules: readme files regenerated - lcr ...
commit 078fc57346efaa2944aa234166f21fd0a03c76bc
Author: Victor Seva <linuxmaniac@torreviejawireless.org>
Date: Tue Jan 17 10:26:05 2017 +0100
lcr: fix documentation
'dont_strip_or_tag_flag' module parameter was renamed to
'dont_strip_or_prefix_flag' at 8c0501bfaa27acab9721953e8c1551687c96edf2.
commit 2250b3e562d6dbcab1477c7ed5a71daa7e462bb9
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Thu Dec 22 09:15:22 2016 +0100
rtjson: enforce send socket with the attribute from json
- reported by Diego Nadares
(backport of 1d23f81353dd7a68b0f537e9a064587a5f733bb7)
commit 39874e415c754263e6c847bb19d89c5ef615e376
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Tue Dec 20 08:36:20 2016 +0100
dialplan: safe checks for match expression
- test if null to avoid invalid use in comparison functions
- reported by Julia Boudniatsky
(backport of commit 3a48835cf68f583ff2fbd7cec9bd76ddc0a1b6fc)
commit 30f53f1484144d2069f5d3724a65e160bbb6adb5
Author: Victor Seva <linuxmaniac@torreviejawireless.org>
Date: Thu Dec 15 09:33:45 2016 +0100
dialplan: fix avp values when using PV_IDX_ITR
manual backport from cc2c3de5e859861b59265cc5a0d41ae968a08149
commit ad00a617dec57073a1e9facc64cf3a64904c6592
Author: Federico Cabiddu <fcabiddu@libon.com>
Date: Tue Nov 29 12:10:36 2016 +0100
sipcapture: fix captid extraction from hep header for v3
(cherry picked from commit 969f4600193139d95b5f876378e0c92d4eab9a7a)
commit 6291792ecaee0bfb1855bf6ba4560e4d6af09f3e
Author: Federico Cabiddu <fcabiddu@libon.com>
Date: Tue Nov 29 11:35:14 2016 +0100
sipcapture: perform ntohs on src and dst port when payload is not SIP
(cherry picked from commit 1fbca28c3a6e90ca478d152e116aca5e64780e9e)
commit 689d12741b86f101d00b1bcd348c3093f47d5158
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Thu Dec 1 12:19:49 2016 +0100
tm: fix wrong CRLF position when building local request when reusing received buffer
- should affect only configs when tm parameters for reparsing request
were changed from their default value
- reported by Helio Okuyama
(cherry picked from commit 6db0e6b5a0b8ef48250abd7bfaedd15fc4860ddd)
commit ae7f6d49ed1caf4a133f72012196a876d258e159
Merge: b1e3d39 973e8ef
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Wed Nov 30 11:14:08 2016 +0100
Merge pull request #869 from giavac/gv/correlation_id_backport
sipcapture: remove workaround of correlation_id
commit 973e8ef6e2f0323168f42ff9f77a86862604b51d
Author: Giacomo Vacca <giacomo.vacca@gmail.com>
Date: Wed Sep 28 14:49:42 2016 +0200
sipcapture: remove workaround of correlation_id
- Compatible with Asterisk >= 10
(cherry picked from commit 6cb0bec7d2491ed3365dc237fc1d8608af246c3a)
commit b1e3d396bb8ef8989895d9017bc8a98a85ce307f
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Wed Nov 30 07:39:00 2016 +0100
rtjson: fix for replacing to header based on json document
- reported by GH #868
(cherry picked from commit 1d5f39a23f1b92575153c5bb2ba87f15f80fa827)
commit 91dcaafcc02af38754e8ceab3f7164595975a6d7
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Tue Nov 29 15:14:52 2016 +0100
kamctl: regenerated database schema
commit 954b298097dcaba9cc0b26f9020ab585f299dceb
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Thu Nov 24 17:46:36 2016 +0100
lib/srdb1: schema - don't set default value for text/blob columns of topos
- not allowed by newer versions of mysql
(cherry picked from commit 0eea31b4b934de45e8bc5091f7ba5a9d486dd16f)
commit e292e044800611eb3f27a17193af6a3ec66fdd83
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Mon Nov 28 19:09:03 2016 +0100
pua_dialoginfo: safety check of paramters for __dialog_sendpublish()
- reported by Davy Van De Moere, GH #865
(cherry picked from commit 1d1d2246c8f89aa6eda52bda479014be0a10b937)
commit c5d3bd8f48bc333dbf63584f463c02e9f546a54b
Author: Kamailio Dev <kamailio.dev@kamailio.org>
Date: Fri Nov 11 12:31:18 2016 +0100
modules: readme files regenerated - dispatcher ...
commit c959ae301d6cc771e4d9e24a63ce77794ae6faac
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Fri Nov 11 12:21:46 2016 +0100
dispatcher: docs - removed extra spaces and rephrased sample config text
(cherry picked from commit 74581f3a500f0f5eca408991a99dc687ad4bf425)
commit 1d1e7c87c117dae367b3dc476fe1bbe6aa5aeef5
Author: Daniel-Constantin Mierla <miconda@gmail.com>
Date: Fri Nov 11 12:15:59 2016 +0100
dispatcher: updates to sameple config file
(cherry picked from commit 0b3d6ad3238d28c1c3aaf8c39052405ffdaa21df)
===================== 2016-11-09 Version 4.4.4 Released =====================
===================== Changes Since Version 4.4.3 ===========================

@ -101,7 +101,7 @@ INSTALL_FLAVOUR=$(FLAVOUR)
# version number
VERSION = 4
PATCHLEVEL = 4
SUBLEVEL = 4
SUBLEVEL = 5
# memory manager switcher
# 0 - f_malloc (fast malloc)

@ -2,6 +2,6 @@
* DO NOT EDIT IT
*/
#define REPO_VER "852c47"
#define REPO_HASH "852c47"
#define REPO_VER "f98162"
#define REPO_HASH "f98162"
#define REPO_STATE ""

@ -26,6 +26,6 @@
<!ENTITY DEFAULT_Q "1.0">
<!ENTITY DEFAULT_CALLID "Default-Call-ID">
<!ENTITY DEFAULT_CSEQ "1">
<!ENTITY DEFAULT_DATETIME "1900-01-01 00:00:01"> <!-- postgresql doesn't like 0000-00-00 00:00:00 -->
<!ENTITY DEFAULT_DATETIME "2000-01-01 00:00:01"> <!-- postgresql doesn't like 0000-00-00 00:00:00 -->
<!ENTITY DEFAULT_FLAGS "0">
<!ENTITY KAMAILIO_MOD_DOC "http://www.kamailio.org/docs/modules/devel/">

@ -128,21 +128,21 @@
<column id="a_rr">
<name>a_rr</name>
<type>largetext</type>
<default/>
<null/>
<description>Record route - A side</description>
</column>
<column id="b_rr">
<name>b_rr</name>
<type>largetext</type>
<default/>
<null/>
<description>Record route - B side</description>
</column>
<column id="s_rr">
<name>s_rr</name>
<type>largetext</type>
<default/>
<null/>
<description>Record route - S side</description>
</column>

@ -88,7 +88,7 @@
<column id="x_via">
<name>x_via</name>
<type>largetext</type>
<default/>
<null/>
<description>Via stack - A or B side</description>
</column>
@ -104,21 +104,21 @@
<column id="x_rr">
<name>x_rr</name>
<type>largetext</type>
<default/>
<null/>
<description>RR stack - incoming A or B side</description>
</column>
<column id="y_rr">
<name>y_rr</name>
<type>largetext</type>
<default/>
<null/>
<description>RR stack - the other A or B side</description>
</column>
<column id="s_rr">
<name>s_rr</name>
<type>largetext</type>
<default/>
<null/>
<description>RR stack - the S side</description>
</column>

@ -106,7 +106,7 @@ static int mod_init(void)
return -1;
}
register_dummy_timers(async_workers);
register_basic_timers(async_workers);
return 0;
}
@ -125,7 +125,7 @@ static int child_init(int rank)
return 0;
for(i=0; i<async_workers; i++) {
if(fork_dummy_timer(PROC_TIMER, "ASYNC MOD TIMER", 1 /*socks flag*/,
if(fork_basic_timer(PROC_TIMER, "ASYNC MOD TIMER", 1 /*socks flag*/,
async_timer_exec, NULL, 1 /*sec*/)<0) {
LM_ERR("failed to register timer routine as process (%d)\n", i);
return -1; /* error */

@ -39,7 +39,7 @@ int dbt_use_table(db1_con_t* _h, const str* _t)
/*
* Get and convert columns from a result
*/
static int dbt_get_columns(db1_res_t* _r, dbt_result_p _dres)
static int dbt_get_columns(db1_res_t* _r, dbt_table_p _dres)
{
int col;
@ -73,10 +73,10 @@ static int dbt_get_columns(db1_res_t* _r, dbt_result_p _dres)
LM_DBG("allocate %d bytes for RES_NAMES[%d] at %p\n",
(int)sizeof(str), col,
RES_NAMES(_r)[col]);
RES_NAMES(_r)[col]->s = _dres->colv[col].name.s;
RES_NAMES(_r)[col]->len = _dres->colv[col].name.len;
RES_NAMES(_r)[col]->s = _dres->colv[col]->name.s;
RES_NAMES(_r)[col]->len = _dres->colv[col]->name.len;
switch(_dres->colv[col].type)
switch(_dres->colv[col]->type)
{
case DB1_STR:
case DB1_STRING:
@ -84,12 +84,12 @@ static int dbt_get_columns(db1_res_t* _r, dbt_result_p _dres)
case DB1_INT:
case DB1_DATETIME:
case DB1_DOUBLE:
RES_TYPES(_r)[col] = _dres->colv[col].type;
RES_TYPES(_r)[col] = _dres->colv[col]->type;
break;
default:
LM_WARN("unhandled data type column (%.*s) type id (%d), "
"use STR as default\n", RES_NAMES(_r)[col]->len,
RES_NAMES(_r)[col]->s, _dres->colv[col].type);
RES_NAMES(_r)[col]->s, _dres->colv[col]->type);
RES_TYPES(_r)[col] = DB1_STR;
break;
}
@ -173,7 +173,7 @@ static int dbt_convert_row(db1_res_t* _res, db_row_t* _r, dbt_row_p _r1)
break;
default:
LM_ERR("val type [%d] not supported\n", RES_TYPES(_res)[i]);
LM_ERR("val type [%d] for column %i not supported\n", RES_TYPES(_res)[i], i);
return -1;
}
}
@ -184,25 +184,31 @@ static int dbt_convert_row(db1_res_t* _res, db_row_t* _r, dbt_row_p _r1)
/*
* Convert rows from internal to db API representation
*/
static int dbt_convert_rows(db1_res_t* _r, dbt_result_p _dres)
static int dbt_convert_rows(db1_res_t* _r, dbt_table_p _dres, int offset, int nrows)
{
int row;
int row = 0, c = 0;
dbt_row_p _rp = NULL;
if (!_r || !_dres) {
LM_ERR("invalid parameter\n");
return -1;
}
RES_ROW_N(_r) = _dres->nrrows;
if (!RES_ROW_N(_r)) {
if (nrows == 0) {
return 0;
}
if (db_allocate_rows(_r) < 0) {
LM_ERR("could not allocate rows\n");
return -2;
}
row = 0;
_rp = _dres->rows;
while(_rp) {
while(_rp && c < offset) {
c++;
_rp = _rp->next;
}
while(_rp && row < nrows) {
if (dbt_convert_row(_r, &(RES_ROWS(_r)[row]), _rp) < 0) {
LM_ERR("failed to convert row #%d\n", row);
RES_ROW_N(_r) = row;
@ -212,36 +218,76 @@ static int dbt_convert_rows(db1_res_t* _r, dbt_result_p _dres)
row++;
_rp = _rp->next;
}
RES_ROW_N(_r) = row;
RES_LAST_ROW(_r) = c + row;
return 0;
}
static int dbt_convert_all_rows(db1_res_t* _r, dbt_table_p _dres)
{
if (!_r || !_dres) {
LM_ERR("invalid parameter\n");
return -1;
}
RES_ROW_N(_r) = _dres->nrrows;
return dbt_convert_rows(_r, _dres, 0, _dres->nrrows);
}
/*
* Fill the structure with data from database
*/
static int dbt_convert_result(db1_res_t* _r, dbt_result_p _dres)
//static int dbt_convert_result(db1_res_t* _r, dbt_table_p _dres)
//{
// if (!_r || !_dres) {
// LM_ERR("invalid parameter\n");
// return -1;
// }
// if (dbt_get_columns(_r, _dres) < 0) {
// LM_ERR("failed to get column names\n");
// return -2;
// }
//
// if (dbt_convert_all_rows(_r, _dres) < 0) {
// LM_ERR("failed to convert rows\n");
// db_free_columns(_r);
// return -3;
// }
// return 0;
//}
/*
* Retrieve result set
*/
int dbt_get_result(db1_res_t** _r, dbt_table_p _dres)
{
if (!_r || !_dres) {
LM_ERR("invalid parameter\n");
return -1;
int res = dbt_init_result(_r, _dres);
if ( res != 0) {
return res;
}
if (dbt_get_columns(_r, _dres) < 0) {
LM_ERR("failed to get column names\n");
return -2;
if (dbt_convert_all_rows(*_r, _dres) < 0) {
LM_ERR("failed to convert rows\n");
db_free_columns(*_r);
return -3;
}
if (dbt_convert_rows(_r, _dres) < 0) {
return 0;
}
int dbt_get_next_result(db1_res_t** _r, int offset, int rows)
{
dbt_table_p _dres = (dbt_table_p)(*_r)->ptr;
if (dbt_convert_rows(*_r, _dres, offset, rows) < 0) {
LM_ERR("failed to convert rows\n");
db_free_columns(_r);
db_free_columns(*_r);
return -3;
}
return 0;
}
/*
* Retrieve result set
*/
int dbt_get_result(db1_res_t** _r, dbt_result_p _dres)
int dbt_init_result(db1_res_t** _r, dbt_table_p _dres)
{
if ( !_r) {
LM_ERR("invalid parameter value\n");
@ -262,13 +308,12 @@ int dbt_get_result(db1_res_t** _r, dbt_result_p _dres)
return -2;
}
if (dbt_convert_result(*_r, _dres) < 0)
{
LM_ERR("failed to convert result\n");
pkg_free(*_r);
return -4;
if (dbt_get_columns(*_r, _dres) < 0) {
LM_ERR("failed to get column names\n");
return -2;
}
RES_NUM_ROWS(*_r) = _dres->nrrows;
(*_r)->ptr = _dres;
return 0;
}

@ -34,7 +34,11 @@
/*
* Retrieve result set
*/
int dbt_get_result(db1_res_t** _r, dbt_result_p _dres);
//int dbt_get_result(db1_res_t** _r, dbt_result_p _dres);
int dbt_get_result(db1_res_t** _r, dbt_table_p _dres);
int dbt_init_result(db1_res_t** _r, dbt_table_p _dres);
int dbt_get_next_result(db1_res_t** _r, int offset, int rows);
int dbt_use_table(db1_con_t* _h, const str* _t);

@ -131,7 +131,7 @@ int dbt_free_result(db1_con_t* _h, db1_res_t* _r)
if (!_r)
return 0;
if(dbt_result_free((dbt_result_p)_r->ptr) < 0)
if(dbt_result_free(_h, (dbt_table_p)_r->ptr) < 0)
{
LM_ERR("unable to free internal structure\n");
}
@ -145,6 +145,7 @@ int dbt_free_result(db1_con_t* _h, db1_res_t* _r)
return 0;
}
static dbt_table_p last_temp_table = NULL;
/*
* Query table for specified rows
@ -157,30 +158,34 @@ int dbt_free_result(db1_con_t* _h, db1_res_t* _r)
* _nc: number of columns to return
* _o: order by the specified column
*/
int dbt_query(db1_con_t* _h, db_key_t* _k, db_op_t* _op, db_val_t* _v,
int dbt_query(db1_con_t* _h, db_key_t* _k, db_op_t* _op, db_val_t* _v,
db_key_t* _c, int _n, int _nc, db_key_t _o, db1_res_t** _r)
{
dbt_table_p _tbc = NULL;
dbt_table_p _tbc_temp = NULL;
dbt_row_p _drp = NULL;
dbt_result_p _dres = NULL;
dbt_row_p *_res = NULL;
// dbt_result_p _dres = NULL;
int result = 0;
int counter = 0;
int i=0;
int *lkey=NULL, *lres=NULL;
db_key_t *_o_k=NULL; /* columns in order-by */
char *_o_op=NULL; /* operators for oder-by */
int _o_n; /* no of elements in order-by */
int *_o_l=NULL; /* column selection for order-by */
int _o_nc; /* no of elements in _o_l but not lres */
// int _o_nc; /* no of elements in _o_l but not lres */
if ((!_h) || (!_r) || !CON_TABLE(_h))
if(_r)
*_r = NULL;
if ((!_h) || !CON_TABLE(_h))
{
LM_ERR("invalid parameters\n");
return -1;
}
*_r = NULL;
if (_o)
{
@ -188,11 +193,19 @@ int dbt_query(db1_con_t* _h, db_key_t* _k, db_op_t* _op, db_val_t* _v,
return -1;
}
_tbc_temp = dbt_db_get_temp_table(DBT_CON_CONNECTION(_h));
if(!_tbc_temp)
{
LM_ERR("unable to allocate temp table\n");
return -1;
}
/* lock database */
_tbc = dbt_db_get_table(DBT_CON_CONNECTION(_h), CON_TABLE(_h));
if(!_tbc)
{
LM_ERR("table %.*s does not exist!\n", CON_TABLE(_h)->len, CON_TABLE(_h)->s);
dbt_db_del_table(DBT_CON_CONNECTION(_h), &_tbc_temp->name, 0);
return -1;
}
@ -220,51 +233,88 @@ int dbt_query(db1_con_t* _h, db_key_t* _k, db_op_t* _op, db_val_t* _v,
if (!_o_l)
goto error;
/* enlarge select-columns lres by all order-by columns, _o_nc is how many */
if (dbt_mangle_columnselection(&lres, &_nc, &_o_nc, _o_l, _o_n) < 0)
goto error;
// if (dbt_mangle_columnselection(&lres, &_nc, &_o_nc, _o_l, _o_n) < 0)
// goto error;
}
/*
LM_DBG("new res with %d cols\n", _nc);
_dres = dbt_result_new(_tbc, lres, _nc);
if(!_dres)
goto error;
*/
dbt_column_p pPrevCol = NULL;
_tbc_temp->colv = (dbt_column_p*) shm_malloc(_nc*sizeof(dbt_column_p));
for(i=0; i < _nc; i++) {
dbt_column_p pCol = dbt_column_new(_tbc->colv[ lres[i] ]->name.s, _tbc->colv[ lres[i] ]->name.len);
pCol->type = _tbc->colv[ lres[i] ]->type;
pCol->flag = _tbc->colv[ lres[i] ]->flag;
if(pPrevCol)
{
pCol->prev = pPrevCol;
pPrevCol->next = pCol;
}
else
_tbc_temp->cols = pCol;
_tbc_temp->colv[i] = pCol;
pPrevCol = pCol;
_tbc_temp->nrcols++;
}
_res = (dbt_row_p*) pkg_malloc(_db_text_max_result_rows * sizeof(dbt_row_p));
if(!_res) {
LM_ERR("no more space to allocate for query rows\n");
goto error;
}
_drp = _tbc->rows;
while(_drp)
while(_drp && counter < _db_text_max_result_rows)
{
if(dbt_row_match(_tbc, _drp, lkey, _op, _v, _n))
{
if(dbt_result_extract_fields(_tbc, _drp, lres, _dres))
{
LM_ERR("failed to extract result fields!\n");
goto clean;
}
_res[counter] = _drp;
// if(dbt_result_extract_fields(_tbc, _drp, lres, _dres))
// {
// LM_ERR("failed to extract result fields!\n");
// goto clean;
// }
counter++;
}
_drp = _drp->next;
}
dbt_table_update_flags(_tbc, DBT_TBFL_ZERO, DBT_FL_IGN, 1);
/* unlock database */
dbt_release_table(DBT_CON_CONNECTION(_h), CON_TABLE(_h));
if (_o_l)
{
if (_dres->nrrows > 1)
if (counter > 1)
{
if (dbt_sort_result(_dres, _o_l, _o_op, _o_n, lres, _nc) < 0)
goto error_nounlock;
if (dbt_sort_result_temp(_res, counter, _o_l, _o_op, _o_n) < 0)
goto error;
}
/* last but not least, remove surplus columns */
if (_o_nc)
dbt_project_result(_dres, _o_nc);
// if (_o_nc)
// dbt_project_result(_dres, _o_nc);
}
// copy results to temp table
_tbc_temp->rows = dbt_result_extract_results(_tbc, _res, counter, lres, _nc);
_tbc_temp->nrrows = (_tbc_temp->rows == NULL ? 0 : counter);
dbt_table_update_flags(_tbc, DBT_TBFL_ZERO, DBT_FL_IGN, 1);
/* unlock database */
dbt_release_table(DBT_CON_CONNECTION(_h), CON_TABLE(_h));
// DBT_CON_TEMP_TABLE(_h) = _tbc_temp;
last_temp_table = _tbc_temp;
// dbt_release_table(DBT_CON_CONNECTION(_h), &_tbc_temp->name);
// dbt_result_print(_tbc_temp);
/* dbt_result_print(_dres); */
if(lkey)
pkg_free(lkey);
if(lres)
@ -275,17 +325,25 @@ int dbt_query(db1_con_t* _h, db_key_t* _k, db_op_t* _op, db_val_t* _v,
pkg_free(_o_op);
if(_o_l)
pkg_free(_o_l);
if(_res)
pkg_free(_res);
result = dbt_get_result(_r, _dres);
if(result != 0)
dbt_result_free(_dres);
if(_r) {
result = dbt_get_result(_r, _tbc_temp);
// dbt_db_del_table(DBT_CON_CONNECTION(_h), &_tbc_temp->name, 1);
if(result != 0)
dbt_result_free(_h, _tbc_temp);
}
return result;
error:
/* unlock database */
dbt_release_table(DBT_CON_CONNECTION(_h), CON_TABLE(_h));
error_nounlock:
/* unlock database */
dbt_release_table(DBT_CON_CONNECTION(_h), CON_TABLE(_h));
/* delete temp table */
dbt_db_del_table(DBT_CON_CONNECTION(_h), &_tbc_temp->name, 1);
if(_res)
pkg_free(_res);
if(lkey)
pkg_free(lkey);
if(lres)
@ -296,14 +354,12 @@ error_nounlock:
pkg_free(_o_op);
if(_o_l)
pkg_free(_o_l);
if(_dres)
dbt_result_free(_dres);
LM_ERR("failed to query the table!\n");
return -1;
/*
clean:
/* unlock database */
dbt_release_table(DBT_CON_CONNECTION(_h), CON_TABLE(_h));
if(lkey)
pkg_free(lkey);
@ -315,10 +371,54 @@ clean:
pkg_free(_o_op);
if(_o_l)
pkg_free(_o_l);
if(_dres)
dbt_result_free(_dres);
return -1;
*/
}
int dbt_fetch_result(db1_con_t* _h, db1_res_t** _r, const int nrows)
{
int rows;
if (!_h || !_r || nrows < 0) {
LM_ERR("Invalid parameter value\n");
return -1;
}
/* exit if the fetch count is zero */
if (nrows == 0) {
dbt_free_result(_h, *_r);
*_r = 0;
return 0;
}
if(*_r==0) {
/* Allocate a new result structure */
dbt_init_result(_r, last_temp_table);
} else {
/* free old rows */
if(RES_ROWS(*_r)!=0)
db_free_rows(*_r);
RES_ROWS(*_r) = 0;
RES_ROW_N(*_r) = 0;
}
/* determine the number of rows remaining to be processed */
rows = RES_NUM_ROWS(*_r) - RES_LAST_ROW(*_r);
/* If there aren't any more rows left to process, exit */
if(rows<=0)
return 0;
/* if the fetch count is less than the remaining rows to process */
/* set the number of rows to process (during this call) equal to the fetch count */
if(nrows < rows)
rows = nrows;
RES_ROW_N(*_r) = rows;
return dbt_get_next_result(_r, RES_LAST_ROW(*_r), rows);
}
/*

@ -40,6 +40,8 @@ static gen_lock_t *_dbt_cachesem = NULL;
static dbt_tbl_cachel_p _dbt_cachetbl = NULL;
extern int is_main;
#define DBT_CACHETBL_SIZE 16
/**
@ -265,6 +267,7 @@ dbt_table_p dbt_db_get_table(dbt_cache_p _dc, const str *_s)
hash = core_hash(&_dc->name, _s, DBT_CACHETBL_SIZE);
hashidx = hash % DBT_CACHETBL_SIZE;
if(!is_main)
lock_get(&_dbt_cachetbl[hashidx].sem);
_tbc = _dbt_cachetbl[hashidx].dtp;
@ -380,7 +383,7 @@ int dbt_cache_destroy(void)
/**
*
*/
int dbt_cache_print(int _f)
int dbt_cache_print2(int _f, int _lock)
{
int i;
dbt_table_p _tbc;
@ -390,10 +393,12 @@ int dbt_cache_print(int _f)
for(i=0; i< DBT_CACHETBL_SIZE; i++)
{
lock_get(&_dbt_cachetbl[i].sem);
if(_lock)
lock_get(&_dbt_cachetbl[i].sem);
_tbc = _dbt_cachetbl[i].dtp;
while(_tbc)
{
if(! (_tbc->flag & DBT_TBFL_TEMP)) {
if(_f)
fprintf(stdout, "\n--- Database [%.*s]\n", _tbc->dbname.len,
_tbc->dbname.s);
@ -412,14 +417,21 @@ int dbt_cache_print(int _f)
dbt_table_update_flags(_tbc,DBT_TBFL_MODI, DBT_FL_UNSET, 0);
}
}
}
_tbc = _tbc->next;
}
lock_release(&_dbt_cachetbl[i].sem);
if(_lock)
lock_release(&_dbt_cachetbl[i].sem);
}
return 0;
}
int dbt_cache_print(int _f)
{
return dbt_cache_print2(_f, !is_main);
}
int dbt_is_neq_type(db_type_t _t0, db_type_t _t1)
{
// LM_DBG("t0=%d t1=%d!\n", _t0, _t1);
@ -461,3 +473,47 @@ int dbt_is_neq_type(db_type_t _t0, db_type_t _t1)
return 1;
}
static int tmp_table_number = 0;
dbt_table_p dbt_db_get_temp_table(dbt_cache_p _dc)
{
dbt_table_p _tbc = NULL;
str _s;
char buf[30];
int hash;
int hashidx;
if(!_dbt_cachetbl || !_dc) {
LM_ERR("invalid parameter\n");
return NULL;
}
sprintf(buf, "tmp-%i-%i", my_pid(), ++tmp_table_number);
_s.s = buf;
_s.len = strlen(buf);
hash = core_hash(&_dc->name, &_s, DBT_CACHETBL_SIZE);
hashidx = hash % DBT_CACHETBL_SIZE;
lock_get(&_dbt_cachetbl[hashidx].sem);
_tbc = _dbt_cachetbl[hashidx].dtp;
_tbc = dbt_table_new(&_s, &(_dc->name), NULL);
_tbc->hash = hash;
_tbc->next = _dbt_cachetbl[hashidx].dtp;
if(_dbt_cachetbl[hashidx].dtp)
_dbt_cachetbl[hashidx].dtp->prev = _tbc;
_dbt_cachetbl[hashidx].dtp = _tbc;
dbt_table_update_flags(_tbc, DBT_TBFL_TEMP, DBT_FL_SET, 0);
lock_release(&_dbt_cachetbl[hashidx].sem);
return _tbc;
}

@ -35,6 +35,7 @@
#define DBT_TBFL_ZERO 0
#define DBT_TBFL_MODI 1
#define DBT_TBFL_TEMP 2
#define DBT_FL_IGN -1
#define DBT_FL_SET 0
@ -50,6 +51,7 @@
extern int db_mode; /* Database usage mode: 0 = no cache, 1 = cache */
extern int empty_string; /* If TRUE, an empty string is an empty string, otherwise NULL */
extern int _db_text_read_buffer_size; /* size of the buffer to allocate when reading file */
extern int _db_text_max_result_rows; /* max result rows */
typedef db_val_t dbt_val_t, *dbt_val_p;
@ -109,6 +111,7 @@ typedef struct _dbt_cache
int dbt_init_cache(void);
int dbt_cache_destroy(void);
int dbt_cache_print(int);
int dbt_cache_print2(int, int);
dbt_cache_p dbt_cache_get_db(str*);
int dbt_cache_check_db(str*);
@ -121,12 +124,13 @@ int dbt_cache_free(dbt_cache_p);
dbt_column_p dbt_column_new(char*, int);
dbt_row_p dbt_row_new(int);
dbt_table_p dbt_table_new(const str*, const str*, const char*);
dbt_table_p dbt_db_get_temp_table(dbt_cache_p _dc);
int dbt_row_free(dbt_table_p, dbt_row_p);
int dbt_column_free(dbt_column_p);
int dbt_table_free_rows(dbt_table_p);
int dbt_table_free(dbt_table_p);
int dbt_db_del_table(dbt_cache_p _dc, const str *_s, int sync);
int dbt_row_set_val(dbt_row_p, dbt_val_p, int, int);
int dbt_row_update_val(dbt_row_p, dbt_val_p, int, int);

@ -92,7 +92,7 @@ clean:
return NULL;
}
int dbt_result_free(dbt_result_p _dres)
int _dbt_result_free(dbt_result_p _dres)
{
dbt_row_p _rp=NULL, _rp0=NULL;
int i;
@ -134,6 +134,22 @@ int dbt_result_free(dbt_result_p _dres)
return 0;
}
int dbt_result_free(db1_con_t* _h, dbt_table_p _dres)
{
if ((!_h))
{
LM_ERR("invalid parameter value\n");
return -1;
}
if (!_dres)
return 0;
dbt_db_del_table(DBT_CON_CONNECTION(_h), &_dres->name, 1);
return 0;
}
int dbt_result_add_row(dbt_result_p _dres, dbt_row_p _drp)
{
if(!_dres || !_drp)
@ -316,45 +332,48 @@ clean:
return -1;
}
int dbt_result_print(dbt_result_p _dres)
int dbt_result_print(dbt_table_p _dres)
{
#if 0
int i;
FILE *fout = stdout;
FILE *fout = stderr;
dbt_row_p rowp = NULL;
char *p;
if(!_dres || _dres->nrcols<=0)
if(!_dres || _dres->nrcols<=0) {
LM_INFO("NO PRINT\n");
return -1;
}
fprintf(fout, "\nContent of result\n");
for(i=0; i<_dres->nrcols; i++)
{
switch(_dres->colv[i].type)
switch(_dres->colv[i]->type)
{
case DB1_INT:
fprintf(fout, "%.*s(int", _dres->colv[i].name.len,
_dres->colv[i].name.s);
if(_dres->colv[i].flag & DBT_FLAG_NULL)
fprintf(fout, "%.*s(int", _dres->colv[i]->name.len,
_dres->colv[i]->name.s);
if(_dres->colv[i]->flag & DBT_FLAG_NULL)
fprintf(fout, ",null");
fprintf(fout, ") ");
break;
case DB1_DOUBLE:
fprintf(fout, "%.*s(double", _dres->colv[i].name.len,
_dres->colv[i].name.s);
if(_dres->colv[i].flag & DBT_FLAG_NULL)
fprintf(fout, "%.*s(double", _dres->colv[i]->name.len,
_dres->colv[i]->name.s);
if(_dres->colv[i]->flag & DBT_FLAG_NULL)
fprintf(fout, ",null");
fprintf(fout, ") ");
break;
case DB1_STR:
fprintf(fout, "%.*s(str", _dres->colv[i].name.len,
_dres->colv[i].name.s);
if(_dres->colv[i].flag & DBT_FLAG_NULL)
case DB1_STRING:
fprintf(fout, "%.*s(str", _dres->colv[i]->name.len,
_dres->colv[i]->name.s);
if(_dres->colv[i]->flag & DBT_FLAG_NULL)
fprintf(fout, ",null");
fprintf(fout, ") ");
break;
default:
LM_INFO("TYPE NOT HANDLED %i\n", _dres->colv[i]->type);
return -1;
}
}
@ -364,7 +383,7 @@ int dbt_result_print(dbt_result_p _dres)
{
for(i=0; i<_dres->nrcols; i++)
{
switch(_dres->colv[i].type)
switch(_dres->colv[i]->type)
{
case DB1_INT:
if(rowp->fields[i].nul)
@ -381,6 +400,7 @@ int dbt_result_print(dbt_result_p _dres)
rowp->fields[i].val.double_val);
break;
case DB1_STR:
case DB1_STRING:
fprintf(fout, "\"");
if(!rowp->fields[i].nul)
{
@ -423,7 +443,6 @@ int dbt_result_print(dbt_result_p _dres)
fprintf(fout, "\n");
rowp = rowp->next;
}
#endif
return 0;
}
@ -526,6 +545,29 @@ dbt_row_p dbt_result_new_row(dbt_result_p _dres)
return _drp;
}
//dbt_row_p dbt_result_new_rows(dbt_row_p* _res, int rows, int cols)
//{
// dbt_row_p _drp = NULL;
// if(!_dres || _dres->nrcols<=0)
// return NULL;
//
// _drp = (dbt_row_p)shm_malloc(sizeof(dbt_row_t) * rows);
// if(!_drp)
// return NULL;
// memset(_drp, 0, sizeof(dbt_row_t));
// _drp->fields = (dbt_val_p)shm_malloc(_dres->nrcols*sizeof(dbt_val_t));
// if(!_drp->fields)
// {
// shm_free(_drp);
// return NULL;
// }
// memset(_drp->fields, 0, _dres->nrcols*sizeof(dbt_val_t));
//
// _drp->next = _drp->prev = NULL;
//
// return _drp;
//}
/* The _o clause to query is not really a db_key_t, it is SQL (str).
* db_mysql and db_postgres simply paste it into SQL, we need to parse it. */
@ -824,3 +866,129 @@ void dbt_project_result(dbt_result_p _dres, int _o_nc)
_dres->nrcols -= _o_nc;
}
/* comparison function for qsort */
int dbt_qsort_compare_temp(const void *_a, const void *_b)
{
int _i, _j, _r;
for (_i=0; _i<dbt_sort_o_n; _i++)
{
_j = dbt_sort_o_l[_i];
_r = dbt_cmp_val(&(*(dbt_row_p *)_a)->fields[_j], &(*(dbt_row_p *)_b)->fields[_j]);
if (_r == 0)
continue; /* no result yet, compare next column */
if (_r == +1 || _r == -1)
return (dbt_sort_o_op[_i] == '<') ? _r : -_r; /* ASC OR DESC */
/* error */
longjmp(dbt_sort_jmpenv, _r);
}
/* no result after comparing all columns, same */
return 0;
}
int dbt_sort_result_temp(dbt_row_p *_res, int count, int *_o_l, char *_o_op, int _o_n)
{
int _i;
/* set globals */
dbt_sort_o_l = _o_l;
dbt_sort_o_op = _o_op;
dbt_sort_o_n = _o_n;
_i = setjmp(dbt_sort_jmpenv); /* exception handling */
if (_i)
{
/* error occured during qsort */
LM_ERR("qsort aborted\n");
return _i;
}
qsort(_res, count, sizeof(dbt_row_p), &dbt_qsort_compare_temp);
return 0;
}
dbt_row_p dbt_result_extract_results(dbt_table_p _dtp, dbt_row_p* pRows, int _nrows, int* _lres, int _ncols)
{
dbt_row_p pRow=NULL;
dbt_row_p pTopRow=NULL;
dbt_row_p pPrvRow=NULL;
int i, n, r;
if(!_dtp || !pRows || _ncols<=0)
return NULL;
for(r=0; r < _nrows; r++) {
pRow = dbt_row_new(_ncols);
for(i=0; i<_ncols; i++)
{
n = _lres[i];
pRow->fields[i].nul = pRows[r]->fields[n].nul;
if(pRow->fields[i].nul)
{
memset(&(pRow->fields[i].val), 0, sizeof(pRow->fields[i].val));
continue;
}
switch(_dtp->colv[n]->type)
{
case DB1_INT:
case DB1_DATETIME:
case DB1_BITMAP:
pRow->fields[i].type = _dtp->colv[n]->type;
pRow->fields[i].val.int_val = pRows[r]->fields[n].val.int_val;
break;
case DB1_DOUBLE:
pRow->fields[i].type = DB1_DOUBLE;
pRow->fields[i].val.double_val=pRows[r]->fields[n].val.double_val;
break;
case DB1_STRING:
case DB1_STR:
case DB1_BLOB:
pRow->fields[i].type = _dtp->colv[n]->type;
pRow->fields[i].val.str_val.len =
pRows[r]->fields[n].val.str_val.len;
pRow->fields[i].val.str_val.s =(char*)shm_malloc(sizeof(char)*
(pRows[r]->fields[n].val.str_val.len+1));
if(!pRow->fields[i].val.str_val.s)
goto clean;
memcpy(pRow->fields[i].val.str_val.s,
pRows[r]->fields[n].val.str_val.s,
pRows[r]->fields[n].val.str_val.len);
pRow->fields[i].val.str_val.s[pRows[r]->fields[n].val.str_val.len]=0;
break;
default:
goto clean;
}
}
if(pTopRow == NULL) {
pTopRow = pRow;
} else {
pRow->prev = pPrvRow;
pPrvRow->next = pRow;
}
pPrvRow = pRow;
}
return pTopRow;
clean:
LM_DBG("make clean!\n");
while(i>=0)
{
if((pRow->fields[i].type == DB1_STRING
|| pRow->fields[i].type == DB1_STR
|| pRow->fields[i].type == DB1_BLOB)
&& !pRow->fields[i].nul
&& pRow->fields[i].val.str_val.s)
shm_free(pRow->fields[i].val.str_val.s);
i--;
}
shm_free(pRow->fields);
shm_free(pRow);
return pTopRow;
}

@ -34,6 +34,7 @@ typedef struct _dbt_result
{
int nrcols;
int nrrows;
int last_row;
dbt_column_p colv;
dbt_row_p rows;
} dbt_result_t, *dbt_result_p;
@ -42,17 +43,22 @@ typedef struct _dbt_con
{
dbt_cache_p con;
int affected;
dbt_table_p last_query;
} dbt_con_t, *dbt_con_p;
#define DBT_CON_CONNECTION(db_con) (((dbt_con_p)((db_con)->tail))->con)
#define DBT_CON_TEMP_TABLE(db_con) (((dbt_con_p)((db_con)->tail))->last_query)
dbt_result_p dbt_result_new(dbt_table_p, int*, int);
int dbt_result_free(dbt_result_p);
//int dbt_result_free(dbt_result_p);
int dbt_result_free(db1_con_t* _h, dbt_table_p _dres);
int dbt_row_match(dbt_table_p _dtp, dbt_row_p _drp, int* _lkey,
db_op_t* _op, db_val_t* _v, int _n);
int dbt_result_extract_fields(dbt_table_p _dtp, dbt_row_p _drp,
int* lres, dbt_result_p _dres);
int dbt_result_print(dbt_result_p _dres);
int dbt_result_print(dbt_table_p _dres);
int* dbt_get_refs(dbt_table_p, db_key_t*, int);
int dbt_cmp_val(dbt_val_p _vp, db_val_t* _v);
@ -63,5 +69,9 @@ int dbt_mangle_columnselection(int **_lres, int *_nc, int *_o_nc, int *_o_l, int
int dbt_sort_result(dbt_result_p _dres, int *_o_l, char *_o_op, int _o_n, int *_lres, int _nc);
void dbt_project_result(dbt_result_p _dres, int _o_nc);
int dbt_qsort_compare_temp(const void *_a, const void *_b);
int dbt_sort_result_temp(dbt_row_p *_res, int count, int *_o_l, char *_o_op, int _o_n);
dbt_row_p dbt_result_extract_results(dbt_table_p _dtp, dbt_row_p* pRows, int _nrows, int* _lres, int _ncols);
#endif

@ -137,7 +137,7 @@ dbt_table_p dbt_table_new(const str *_tbname, const str *_dbname, const char *pa
{
struct stat s;
dbt_table_p dtp = NULL;
if(!_tbname || !_dbname || !path)
if(!_tbname || !_dbname)
return NULL;
dtp = (dbt_table_p)shm_malloc(sizeof(dbt_table_t));
@ -175,7 +175,7 @@ dbt_table_p dbt_table_new(const str *_tbname, const str *_dbname, const char *pa
dtp->nrrows = dtp->nrcols = dtp->auto_val = 0;
dtp->auto_col = -1;
dtp->mt = 0;
if(stat(path, &s) == 0)
if(path && stat(path, &s) == 0)
{
dtp->mt = s.st_mtime;
LM_DBG("mtime is %d\n", (int)s.st_mtime);

@ -38,6 +38,7 @@ static int mod_init(void);
static void destroy(void);
#define DEFAULT_DB_TEXT_READ_BUFFER_SIZE 16384
#define DEFAULT_MAX_RESULT_ROWS 100000;
/*
* Module parameter variables
@ -45,6 +46,7 @@ static void destroy(void);
int db_mode = 0; /* Database usage mode: 0 = cache, 1 = no cache */
int empty_string = 0; /* Treat empty string as "" = 0, 1 = NULL */
int _db_text_read_buffer_size = DEFAULT_DB_TEXT_READ_BUFFER_SIZE;
int _db_text_max_result_rows = DEFAULT_MAX_RESULT_ROWS;
int dbt_bind_api(db_func_t *dbb);
@ -64,6 +66,7 @@ static param_export_t params[] = {
{"db_mode", INT_PARAM, &db_mode},
{"emptystring", INT_PARAM, &empty_string},
{"file_buffer_size", INT_PARAM, &_db_text_read_buffer_size},
{"max_result_rows", INT_PARAM, &_db_text_max_result_rows},
{0, 0, 0}
};
@ -108,7 +111,7 @@ static int mod_init(void)
static void destroy(void)
{
LM_DBG("destroy ...\n");
dbt_cache_print(0);
dbt_cache_print2(0, 0);
dbt_cache_destroy();
}
@ -125,6 +128,7 @@ int dbt_bind_api(db_func_t *dbb)
dbb->init = dbt_init;
dbb->close = dbt_close;
dbb->query = (db_query_f)dbt_query;
dbb->fetch_result = (db_fetch_result_f) dbt_fetch_result;
dbb->free_result = dbt_free_result;
dbb->insert = (db_insert_f)dbt_insert;
dbb->delete = (db_delete_f)dbt_delete;
@ -132,7 +136,7 @@ int dbt_bind_api(db_func_t *dbb)
dbb->replace = (db_replace_f)dbt_replace;
dbb->affected_rows = (db_affected_rows_f) dbt_affected_rows;
dbb->raw_query = (db_raw_query_f) dbt_raw_query;
dbb->cap = DB_CAP_ALL | DB_CAP_AFFECTED_ROWS | DB_CAP_RAW_QUERY | DB_CAP_REPLACE;
dbb->cap = DB_CAP_ALL | DB_CAP_AFFECTED_ROWS | DB_CAP_RAW_QUERY | DB_CAP_REPLACE | DB_CAP_FETCH;
return 0;
}

@ -56,6 +56,10 @@ int dbt_free_result(db1_con_t* _h, db1_res_t* _r);
int dbt_query(db1_con_t* _h, db_key_t* _k, db_op_t* _op, db_val_t* _v,
db_key_t* _c, int _n, int _nc, db_key_t _o, db1_res_t** _r);
/*
* fetch result
*/
int dbt_fetch_result(db1_con_t* _h, db1_res_t** _r, const int nrows);
/*
* Raw SQL query

@ -40,6 +40,7 @@
#include "../../parser/parse_to.h"
#include "../../parser/parse_from.h"
#include "../../parser/parse_cseq.h"
#include "../../srapi.h"
#include "../../modules/tm/tm_load.h"
#include "dlg_handlers.h"
@ -77,25 +78,24 @@ static int dlg_cseq_prepare_msg(sip_msg_t *msg)
/* reply to local transaction -- nothing to do */
if (parse_headers(msg, HDR_VIA2_F, 0)==-1
|| (msg->via2==0) || (msg->via2->error!=PARSE_OK)) {
LM_DBG("no second via in this message \n");
return 3;
if(get_cseq(msg)->method_id != METHOD_CANCEL) {
LM_DBG("no second via in this message \n");
return 3;
}
}
}
if(parse_from_header(msg)<0)
{
if(parse_from_header(msg)<0) {
LM_ERR("cannot parse FROM header\n");
return 3;
}
if(parse_to_header(msg)<0 || msg->to==NULL)
{
if(parse_to_header(msg)<0 || msg->to==NULL) {
LM_ERR("cannot parse TO header\n");
return 3;
}
if(get_to(msg)==NULL)
{
if(get_to(msg)==NULL) {
LM_ERR("cannot get TO header\n");
return 3;
}
@ -127,6 +127,7 @@ int dlg_cseq_update(sip_msg_t *msg)
unsigned int vinc = 0;
str nval;
str *pval;
sr_cfgenv_t *cenv = NULL;
if(dlg_cseq_prepare_msg(msg)!=0) {
goto error;
@ -152,6 +153,7 @@ int dlg_cseq_update(sip_msg_t *msg)
goto done;
}
cenv = sr_cfgenv_get();
ninc = 1;
/* take the increment value from dialog */
@ -185,7 +187,7 @@ int dlg_cseq_update(sip_msg_t *msg)
LM_DBG("adding auth cseq header value: %.*s\n", nval.len, nval.s);
parse_headers(msg, HDR_EOH_F, 0);
sr_hdr_add_zs(msg, "P-K-Auth-CSeq", &nval);
sr_hdr_add_zs(msg, cenv->uac_cseq_auth.s, &nval);
done:
if(dlg!=NULL) dlg_release(dlg);
@ -207,6 +209,7 @@ int dlg_cseq_refresh(sip_msg_t *msg, dlg_cell_t *dlg,
unsigned int vinc = 0;
str nval;
str *pval;
sr_cfgenv_t *cenv = NULL;
if(dlg_cseq_prepare_msg(msg)!=0) {
goto error;
@ -254,7 +257,8 @@ int dlg_cseq_refresh(sip_msg_t *msg, dlg_cell_t *dlg,
LM_DBG("adding cseq refresh header value: %.*s\n", nval.len, nval.s);
parse_headers(msg, HDR_EOH_F, 0);
sr_hdr_add_zs(msg, "P-K-CSeq-Refresh", &nval);
cenv = sr_cfgenv_get();
sr_hdr_add_zs(msg, cenv->uac_cseq_refresh.s, &nval);
done:
return 0;
@ -354,11 +358,13 @@ int dlg_cseq_msg_sent(void *data)
int tbuf_len = 0;
struct via_body *via;
hdr_field_t *hfk = NULL;
sr_cfgenv_t *cenv = NULL;
obuf = (str*)data;
memset(&msg, 0, sizeof(sip_msg_t));
msg.buf = obuf->s;
msg.len = obuf->len;
cenv = sr_cfgenv_get();
if(dlg_cseq_prepare_new_msg(&msg)!=0) {
goto done;
@ -394,23 +400,23 @@ int dlg_cseq_msg_sent(void *data)
parse_headers(&msg, HDR_EOH_F, 0);
/* check if transaction is marked for a new increment */
if(get_cseq(&msg)->method_id!=METHOD_ACK) {
hfk = sr_hdr_get_z(&msg, "P-K-Auth-CSeq");
if(hfk!=NULL) {
LM_DBG("new cseq inc requested\n");
nval = hfk->body;
trim(&nval);
} else {
LM_DBG("new cseq inc not requested\n");
}
hfk = sr_hdr_get_z(&msg, cenv->uac_cseq_auth.s);
if(hfk!=NULL) {
LM_DBG("new cseq inc requested\n");
nval = hfk->body;
trim(&nval);
} else {
LM_DBG("new cseq inc not requested\n");
}
if(nval.len<=0) {
hfk = sr_hdr_get_z(&msg, "P-K-CSeq-Refresh");
hfk = sr_hdr_get_z(&msg, cenv->uac_cseq_refresh.s);
if(hfk!=NULL) {
LM_DBG("cseq refresh requested\n");
nval = hfk->body;
trim(&nval);
} else {
LM_DBG("cseq refresh not requested\n");
}
}
if(nval.len<=0) {

@ -67,9 +67,10 @@ int dpl_dyn_printf_s(sip_msg_t *msg, const pv_elem_p elem,
pv_elem_p e = NULL;
pv_elem_p t = NULL;
str s = STR_NULL;
str v = STR_NULL;
int ret = -1;
if(elem==NULL||avp_elem==NULL||elem_prev==NULL) return -1;
if(elem==NULL||avp_elem==NULL||elem_prev==NULL||vexpr==NULL) return -1;
if(str_append(&(avp_elem->text), val, &s)<0) return -1;
if(pv_parse_format(&s, &e)<0) {
@ -86,10 +87,18 @@ int dpl_dyn_printf_s(sip_msg_t *msg, const pv_elem_p elem,
}
if(*elem_prev) (*elem_prev)->next = e;
e->next = avp_elem->next;
if(pv_printf_s(msg, e, vexpr)<0){
if(pv_printf_s(msg, e, &v)<0){
LM_ERR("cannot get avp pcre dynamic expression value\n");
goto clean;
}
/* pv_printf_s uses pv_get_buffer() we do need to copy */
vexpr->len = v.len;
vexpr->s = pkg_malloc(sizeof(char)*(v.len+1));
if(vexpr->s==NULL) {
PKG_MEM_ERROR;
goto clean;
}
strcpy(vexpr->s, v.s);
ret = 0;
clean:
if(s.s) pkg_free(s.s);
@ -282,7 +291,12 @@ error:
}
clean:
if(elem) pv_elem_free_all(elem);
while(l) { t = l->next; pkg_free(l); l = t;}
while(l) {
t = l->next;
if(l->s.s) pkg_free(l->s.s);
pkg_free(l);
l = t;
}
return re_list;
}
@ -569,7 +583,7 @@ int translate(sip_msg_t *msg, str input, str *output, dpl_id_p idp,
dpl_dyn_pcre_p rt = NULL;
if(!input.s || !input.len) {
LM_ERR("invalid input string\n");
LM_WARN("invalid or empty input string to be matched\n");
return -1;
}
@ -621,7 +635,8 @@ search_rule:
case DP_EQUAL_OP:
LM_DBG("equal operator testing\n");
if(rulep->match_exp.len != input.len) {
if(rulep->match_exp.s==NULL
|| rulep->match_exp.len != input.len) {
rez = -1;
} else {
rez = strncmp(rulep->match_exp.s,input.s,input.len);
@ -631,11 +646,15 @@ search_rule:
case DP_FNMATCH_OP:
LM_DBG("fnmatch operator testing\n");
b = input.s[input.len];
input.s[input.len] = '\0';
rez = fnmatch(rulep->match_exp.s, input.s, 0);
input.s[input.len] = b;
rez = (rez==0)?0:-1;
if(rulep->match_exp.s!=NULL) {
b = input.s[input.len];
input.s[input.len] = '\0';
rez = fnmatch(rulep->match_exp.s, input.s, 0);
input.s[input.len] = b;
rez = (rez==0)?0:-1;
} else {
rez = -1;
}
break;
default:

@ -959,7 +959,7 @@ ds_select_dst("1", "4", "3");
* "p" and "P" - this has to be used in addition to one of the
previous flags - the last destination will be set to probing. This
mean the destination will be pinged with SIP OPTIONS requests from
time to time to detect if it is up running or down.
time to time to detect if it is up or down.
This function can be used from REQUEST_ROUTE, FAILURE_ROUTE.
@ -1299,7 +1299,7 @@ r,opt)
7.2. Kamailio config file
Next picture shows a sample usage of the dispatcher module.
Next listing shows a sample config for using the dispatcher module.
Example 1.41. Kamailio config script - sample dispatcher usage
...
@ -1310,9 +1310,9 @@ r,opt)
# - no TPC listening
# - don't dispatch REGISTER and presence requests
#
# Kamailio (OpenSER) SIP Server v3.2
# Kamailio SIP Server
# - web: http://www.kamailio.org
# - git: http://sip-router.org
# - git: http://github.com/kamailio/
#
# Direct your questions about this file to: sr-users@lists.sip-router.org
#
@ -1329,6 +1329,13 @@ r,opt)
#!define DBURL "mysql://kamailio:kamailiorw@localhost/kamailio"
#!endif
# - flags
# FLT_ - per transaction (message) flags
# FLB_ - per branch flags
#!define FLT_ACC 1
#!define FLT_ACCMISSED 2
#!define FLT_ACCFAILED 3
####### Global Parameters #########
#!ifdef WITH_DEBUG
@ -1367,8 +1374,8 @@ sip_warning=no
####### Modules Section ########
#set module path
mpath="/usr/local/lib/kamailio/modules_k/:/usr/local/lib/kamailio/modules/"
# set module path
mpath="/usr/local/lib/kamailio/modules/"
loadmodule "db_mysql.so"
loadmodule "mi_fifo.so"
@ -1392,10 +1399,6 @@ loadmodule "dispatcher.so"
# ----------------- setting module-specific parameters ---------------
# ----- mi_fifo params -----
modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")
# ----- rr params -----
# add value to ;lr param to cope with most of the UAs
modparam("rr", "enable_full_lr", 1)
@ -1404,8 +1407,8 @@ modparam("rr", "append_fromtag", 0)
# ----- acc params -----
modparam("acc", "log_flag", 1)
modparam("acc", "failed_transaction_flag", 3)
modparam("acc", "log_flag", FLT_ACC)
modparam("acc", "failed_transaction_flag", FLT_ACCFAILED)
modparam("acc", "log_extra",
"src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd;s
rc_ip=$si")
@ -1428,7 +1431,7 @@ modparam("dispatcher", "sock_avp", "$avp(AVP_SOCK)")
# main request routing logic
route {
request_route {
# per request initial checks
route(REQINIT);
@ -1446,6 +1449,11 @@ route {
exit;
}
# handle retransmissions
if(t_precheck_trans()) {
t_check_trans();
exit;
}
t_check_trans();
# record routing for dialog forming requests (in case they are routed)
@ -1455,9 +1463,8 @@ route {
record_route();
# account only INVITEs
if (is_method("INVITE"))
{
setflag(1); # do accounting
if (is_method("INVITE")) {
setflag(FLT_ACC); # do accounting
}
# handle presence related requests
@ -1466,8 +1473,7 @@ route {
# handle registrations
route(REGISTRAR);
if ($rU==$null)
{
if ($rU==$null) {
# request with no Username in RURI
sl_send_reply("484","Address Incomplete");
exit;
@ -1492,8 +1498,7 @@ route[REQINIT] {
exit;
}
if(!sanity_check("1511", "7"))
{
if(!sanity_check("1511", "7")) {
xlog("Malformed SIP message from $si:$sp\n");
exit;
}
@ -1506,8 +1511,9 @@ route[WITHINDLG] {
# take the path determined by record-routing
if (loose_route()) {
if (is_method("BYE")) {
setflag(1); # do accounting ...
setflag(3); # ... even if the transaction fails
setflag(FLT_ACC); # do accounting ...
setflag(FLT_ACCFAILED); # ... even if the transa
ction fails
}
route(RELAY);
} else {
@ -1555,8 +1561,7 @@ route[PRESENCE] {
# Dispatch requests
route[DISPATCH] {
# round robin dispatching on gateways group '1'
if(!ds_select_dst("1", "4"))
{
if(!ds_select_dst("1", "4")) {
send_reply("404", "No destination");
exit;
}
@ -1566,17 +1571,15 @@ route[DISPATCH] {
exit;
}
# Sample failure route
# Try next destionations in failure route
failure_route[RTF_DISPATCH] {
if (t_is_canceled()) {
exit;
}
# next DST - only for 500 or local timeout
if (t_check_status("500")
or (t_branch_timeout() and !t_branch_replied()))
{
if(ds_next_dst())
{
or (t_branch_timeout() and !t_branch_replied())) {
if(ds_next_dst()) {
t_on_failure("RTF_DISPATCH");
route(RELAY);
exit;
@ -1584,8 +1587,6 @@ failure_route[RTF_DISPATCH] {
}
}
...
8. Event routes

@ -5,9 +5,9 @@
# - no TPC listening
# - don't dispatch REGISTER and presence requests
#
# Kamailio (OpenSER) SIP Server v3.2
# Kamailio SIP Server
# - web: http://www.kamailio.org
# - git: http://sip-router.org
# - git: http://github.com/kamailio/
#
# Direct your questions about this file to: sr-users@lists.sip-router.org
#
@ -16,7 +16,7 @@
#
# Several features can be enabled using '#!define WITH_FEATURE' directives:
#
# *** To run in debug mode:
# *** To run in debug mode:
# - define WITH_DEBUG
#
@ -24,6 +24,13 @@
#!define DBURL "mysql://kamailio:kamailiorw@localhost/kamailio"
#!endif
# - flags
# FLT_ - per transaction (message) flags
# FLB_ - per branch flags
#!define FLT_ACC 1
#!define FLT_ACCMISSED 2
#!define FLT_ACCFAILED 3
####### Global Parameters #########
#!ifdef WITH_DEBUG
@ -54,7 +61,7 @@ auto_aliases=no
port=5060
/* uncomment and configure the following line if you want Kamailio to
/* uncomment and configure the following line if you want Kamailio to
bind on a specific interface/port/proto (default bind on all available) */
# listen=udp:127.0.0.1:5060
@ -62,8 +69,8 @@ sip_warning=no
####### Modules Section ########
#set module path
mpath="/usr/local/lib/kamailio/modules_k/:/usr/local/lib/kamailio/modules/"
# set module path
mpath="/usr/local/lib/kamailio/modules/"
loadmodule "db_mysql.so"
loadmodule "mi_fifo.so"
@ -87,10 +94,6 @@ loadmodule "dispatcher.so"
# ----------------- setting module-specific parameters ---------------
# ----- mi_fifo params -----
modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")
# ----- rr params -----
# add value to ;lr param to cope with most of the UAs
modparam("rr", "enable_full_lr", 1)
@ -99,9 +102,9 @@ modparam("rr", "append_fromtag", 0)
# ----- acc params -----
modparam("acc", "log_flag", 1)
modparam("acc", "failed_transaction_flag", 3)
modparam("acc", "log_extra",
modparam("acc", "log_flag", FLT_ACC)
modparam("acc", "failed_transaction_flag", FLT_ACCFAILED)
modparam("acc", "log_extra",
"src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd;src_ip=$si")
# ----- tm params -----
@ -122,7 +125,7 @@ modparam("dispatcher", "sock_avp", "$avp(AVP_SOCK)")
# main request routing logic
route {
request_route {
# per request initial checks
route(REQINIT);
@ -140,6 +143,11 @@ route {
exit;
}
# handle retransmissions
if(t_precheck_trans()) {
t_check_trans();
exit;
}
t_check_trans();
# record routing for dialog forming requests (in case they are routed)
@ -149,9 +157,8 @@ route {
record_route();
# account only INVITEs
if (is_method("INVITE"))
{
setflag(1); # do accounting
if (is_method("INVITE")) {
setflag(FLT_ACC); # do accounting
}
# handle presence related requests
@ -160,8 +167,7 @@ route {
# handle registrations
route(REGISTRAR);
if ($rU==$null)
{
if ($rU==$null) {
# request with no Username in RURI
sl_send_reply("484","Address Incomplete");
exit;
@ -186,8 +192,7 @@ route[REQINIT] {
exit;
}
if(!sanity_check("1511", "7"))
{
if(!sanity_check("1511", "7")) {
xlog("Malformed SIP message from $si:$sp\n");
exit;
}
@ -200,8 +205,8 @@ route[WITHINDLG] {
# take the path determined by record-routing
if (loose_route()) {
if (is_method("BYE")) {
setflag(1); # do accounting ...
setflag(3); # ... even if the transaction fails
setflag(FLT_ACC); # do accounting ...
setflag(FLT_ACCFAILED); # ... even if the transaction fails
}
route(RELAY);
} else {
@ -247,8 +252,7 @@ route[PRESENCE] {
# Dispatch requests
route[DISPATCH] {
# round robin dispatching on gateways group '1'
if(!ds_select_dst("1", "4"))
{
if(!ds_select_dst("1", "4")) {
send_reply("404", "No destination");
exit;
}
@ -258,22 +262,18 @@ route[DISPATCH] {
exit;
}
# Sample failure route
# Try next destionations in failure route
failure_route[RTF_DISPATCH] {
if (t_is_canceled()) {
exit;
}
# next DST - only for 500 or local timeout
if (t_check_status("500")
or (t_branch_timeout() and !t_branch_replied()))
{
if(ds_next_dst())
{
or (t_branch_timeout() and !t_branch_replied())) {
if(ds_next_dst()) {
t_on_failure("RTF_DISPATCH");
route(RELAY);
exit;
}
}
}

@ -10,7 +10,7 @@
<!-- Module User's Guide -->
<chapter xmlns:xi="http://www.w3.org/2001/XInclude">
<title>&adminguide;</title>
<section>
@ -29,7 +29,7 @@
</para>
<para>
It is very lightweight, therefore suitable for handling heavy SIP
traffic. As the module has a small footprint and the ability to load
traffic. As the module has a small footprint and the ability to load
balancing rules from a plain text file, it is suitable for embedded systems.
</para>
</section>
@ -537,11 +537,11 @@ modparam("dispatcher", "force_dst", 1)
...
</programlisting>
</example>
</section>
</section>
<section id="dispatcher.p.ds_ping_from">
<title><varname>ds_ping_from</varname> (string)</title>
<para>
With this Method you can define the "From:"-Line for the request, sent to the failed gateways.
With this Method you can define the "From:"-Line for the request, sent to the failed gateways.
This method is only available, if compiled with the probing of failed gateways enabled.
</para>
<para>
@ -557,7 +557,7 @@ modparam("dispatcher", "force_dst", 1)
...
</programlisting>
</example>
</section>
</section>
<section id="dispatcher.p.ds_ping_interval">
<title><varname>ds_ping_interval</varname> (int)</title>
@ -580,8 +580,8 @@ modparam("dispatcher", "force_dst", 1)
...
</programlisting>
</example>
</section>
</section>
<section id="dispatcher.p.ds_probing_threshold">
<title><varname>ds_probing_threshold</varname> (int)</title>
<para>
@ -640,7 +640,7 @@ modparam("dispatcher", "force_dst", 1)
PING-Method are not only the ones generated from the remote servers, but also those
that are generated locally. E.g.: setting code=408 or class=400 will never set
a backend down even if it is, because internally the Kamailio transaction layer
generates a 408 in the case of no response from the remote server, and this
generates a 408 in the case of no response from the remote server, and this
internal code 408 is accepted as valid value.
</para>
<para>
@ -656,11 +656,11 @@ modparam("dispatcher", "force_dst", 1)
...
</programlisting>
</example>
</section>
</section>
<section id="dispatcher.p.ds_probing_mode">
<title><varname>ds_probing_mode</varname> (int)</title>
<para>
Controls what gateways are tested to see if they are reachable.
Controls what gateways are tested to see if they are reachable.
</para>
<itemizedlist>
@ -827,7 +827,7 @@ modparam("dispatcher", "force_dst", 1)
<title><varname>ds_timer_mode</varname> (int)</title>
<para>
Specify the timer process to be used by the module for
keepalives and active dialogs tracking.
keepalives and active dialogs tracking.
</para>
<para>
It can be set to:
@ -984,17 +984,17 @@ modparam("dispatcher", "force_dst", 1)
<para>
<quote>11</quote> - use relative weight based load distribution.
You have to set the attribute 'rweight' per each address in
destination set. Active host usage probability is
rweight/(SUM of all active host rweights in destination group).
destination set. Active host usage probability is
rweight/(SUM of all active host rweights in destination group).
</para>
<para>
The major difference from the weight distribution is the
probability recalculation according to rweight value in case of
probability recalculation according to rweight value in case of
host enabling/disabling
</para>
<para>
For example, 100 calls in 3-hosts group with rweight params 1/2/1
will be distributed as 25/50/25. After third host failing
For example, 100 calls in 3-hosts group with rweight params 1/2/1
will be distributed as 25/50/25. After third host failing
distribution will be changed to 33/67/0.
</para>
</listitem>
@ -1122,7 +1122,7 @@ ds_select_dst("1", "4", "3");
addition to one of the previous flags - the last destination
will be set to probing. This mean the destination will be pinged
with SIP OPTIONS requests from time to time to detect if it is
up running or down.</para>
up or down.</para>
</listitem>
</itemizedlist>
<para>
@ -1314,7 +1314,7 @@ onreply_route {
<function moreinfo="none">ds_set_state</function>
</title>
<para>
Sets the status for a destination address (can be use to mark the destination
Sets the status for a destination address (can be use to mark the destination
as active or inactive).
</para>
<para>
@ -1325,17 +1325,17 @@ onreply_route {
<listitem><para>_state_ : state of the destination address</para>
<itemizedlist>
<listitem><para> <quote>a</quote>: active</para></listitem>
<listitem><para> <quote>i</quote>: inactive</para></listitem>
<listitem><para> <quote>t</quote>: trying</para></listitem>
<listitem><para> <quote>d</quote>: disabled</para></listitem>
<listitem><para> <quote>i</quote>: inactive</para></listitem>
<listitem><para> <quote>t</quote>: trying</para></listitem>
<listitem><para> <quote>d</quote>: disabled</para></listitem>
</itemizedlist>
<para>The states <quote>a</quote>, <quote>i</quote> or
<quote>t</quote> can be followed by <quote>p</quote>
to set probing mode (e.g. 'ap', 'ip' or 'tp').</para>
</listitem>
</listitem>
<listitem><para>_group_: destination group id</para></listitem>
<listitem><para>_address_: address of the destination in the _group_</para></listitem>
</itemizedlist>
<para>
@ -1568,10 +1568,10 @@ onreply_route {
sent to that gateways.
</listitem>
<listitem>
'rweight' - used for relative weight based load
distribution. It must be set to a positive integer value
between 1 and 100 (otherwise host will be excluded from
relative weight distribution type).
'rweight' - used for relative weight based load
distribution. It must be set to a positive integer value
between 1 and 100 (otherwise host will be excluded from
relative weight distribution type).
</listitem>
<listitem>
'socket' - used to set the sending socket for the gateway.
@ -1615,11 +1615,11 @@ setid(int) destination(sip uri) flags(int,opt) priority(int,opt) attrs(str,opt)
</example>
</section>
</section>
<section id="dispatcher.ex.config">
<title>&kamailio; config file</title>
<para>
Next picture shows a sample usage of the dispatcher module.
Next listing shows a sample config for using the dispatcher module.
</para>
<example>
<title>&kamailio; config script - sample dispatcher usage</title>

@ -41,10 +41,11 @@ Daniel-Constantin Mierla
4.1. jsonrpc_dispatch()
4.2. jsonrpc_exec(cmd)
5. JSONRPC Transports
5. JSONRPC Commands
6. JSONRPC Transports
5.1. JSONRPC Over HTTP
5.2. JSONRPC Over FIFO
6.1. JSONRPC Over HTTP
6.2. JSONRPC Over FIFO
List of Examples
@ -57,8 +58,9 @@ Daniel-Constantin Mierla
1.7. Set fifo_reply_dir parameter
1.8. jsonrpc_dispatch usage
1.9. jsonrpc_exec usage
1.10. JSONRPC Over Fifo Command
1.11. JSONRPC Over Fifo Command From Termina
1.10. JSONRPC Commands - Examples
1.11. JSONRPC Over Fifo Command
1.12. JSONRPC Over Fifo Command From Termina
Chapter 1. Admin Guide
@ -88,10 +90,11 @@ Chapter 1. Admin Guide
4.1. jsonrpc_dispatch()
4.2. jsonrpc_exec(cmd)
5. JSONRPC Transports
5. JSONRPC Commands
6. JSONRPC Transports
5.1. JSONRPC Over HTTP
5.2. JSONRPC Over FIFO
6.1. JSONRPC Over HTTP
6.2. JSONRPC Over FIFO
1. Overview
@ -293,17 +296,59 @@ event_route[xhttp:request] {
jsonrpc_exec({"jsonrpc": "2.0", "method": "dispatcher.reload", "id": 1}');
...
5. JSONRPC Transports
5. JSONRPC Commands
5.1. JSONRPC Over HTTP
5.2. JSONRPC Over FIFO
Here are some examples of RPC commands with the equivalent of running
them with kamcmd and the corresponding JSON document for them. It is
important to be aware that the name of the parameters doesn't matter,
only the order of the values must be the one expected by Kamailio RPC
command.
Example 1.10. JSONRPC Commands - Examples
...
# kamcmd core.psx
{
"jsonrpc": "2.0",
"method": "core.psx",
"id": 1
}
...
## - prototype: kamcmd dispatcher.set_state _state_ _group_ _address_
# kamcmd dispatcher.set_state ip 2 sip:127.0.0.1:5080
{
"jsonrpc": "2.0",
"method": "dispatcher.set_state",
"params": ["ip", 2, "sip:127.0.0.1:5080"],
"id": 1
}
## - or:
{
"jsonrpc": "2.0",
"method": "dispatcher.set_state",
"params": {
"state": "ip",
"grpup": 2,
"address": "sip:127.0.0.1:5080"
},
"id": 1
}
...
6. JSONRPC Transports
6.1. JSONRPC Over HTTP
6.2. JSONRPC Over FIFO
JSONRPC specifications do not enforce a specific transport to carry the
JSON documents. Very common is JSONRPC over HTTP or HTTPS, and they are
supported by Kamailio. In addition, Kamailio supports receiving JSON
documents via a local FIFO file.
5.1. JSONRPC Over HTTP
6.1. JSONRPC Over HTTP
It requires that XHTTP module is loaded. HTTPS can be used if you
enable TLS for Kamailio. The JSONRPC requests have to be sent to the
@ -313,7 +358,7 @@ jsonrpc_exec({"jsonrpc": "2.0", "method": "dispatcher.reload", "id": 1}');
The format of the JSON document must follow the JSONRPC specifications.
5.2. JSONRPC Over FIFO
6.2. JSONRPC Over FIFO
This module can retrive JSONRPC requests via a local FIFO file. To
enable this feature, 'fifo_name' parameter must be set and 'transport'
@ -326,7 +371,7 @@ jsonrpc_exec({"jsonrpc": "2.0", "method": "dispatcher.reload", "id": 1}');
'fifo_reply_dir'. Next is an example showing a JSONRPC command to be
sent via FIFO transport.
Example 1.10. JSONRPC Over Fifo Command
Example 1.11. JSONRPC Over Fifo Command
...
{
"jsonrpc": "2.0",
@ -339,7 +384,7 @@ jsonrpc_exec({"jsonrpc": "2.0", "method": "dispatcher.reload", "id": 1}');
Next is an example of how to test it from a terminal, assuming that the
parameter 'fifo_name' is set to '/tmp/kamailio_jsonrpc_fifo'.
Example 1.11. JSONRPC Over Fifo Command From Termina
Example 1.12. JSONRPC Over Fifo Command From Termina
...
mkfifo /tmp/kamailio_jsonrpc_reply_fifo
cat /tmp/kamailio_jsonrpc_reply_fifo &

@ -10,9 +10,9 @@
<!-- Module User's Guide -->
<chapter>
<title>&adminguide;</title>
<section>
<title>Overview</title>
<para>
@ -85,7 +85,7 @@
<section id="jsonrpc-s.p.pretty_format">
<title><varname>pretty_format</varname> (int)</title>
<para>
Pretty format for JSON-RPC response document.
Pretty format for JSON-RPC response document.
</para>
<para>
<emphasis>
@ -137,7 +137,7 @@ modparam("jsonrpc-s", "transport", 1)
<section id="jsonrpc-s.p.fifo_name">
<title><varname>fifo_name</varname> (str)</title>
<para>
The name of the FIFO file to be created for listening and
The name of the FIFO file to be created for listening and
reading external commands. If the given path is not absolute,
the fifo file is created relative to run_dir (global parameter).
</para>
@ -159,7 +159,7 @@ modparam("jsonrpc-s", "fifo_name", "/tmp/kamailio_jsonrpc_fifo")
<section id="jsonrpc-s.p.fifo_mode">
<title><varname>fifo_mode</varname> (int)</title>
<para>
Permission to be used for creating the listening FIFO file. It
Permission to be used for creating the listening FIFO file. It
follows the UNIX conventions.
</para>
<para>
@ -321,13 +321,61 @@ jsonrpc_exec({"jsonrpc": "2.0", "method": "dispatcher.reload", "id": 1}');
</section>
<section>
<title>JSONRPC Commands</title>
<para>
Here are some examples of RPC commands with the equivalent of running them
with &kamcmd; and the corresponding JSON document for them. It is important
to be aware that the name of the parameters doesn't matter, only the order
of the values must be the one expected by &kamailio; RPC command.
</para>
<example>
<title>JSONRPC Commands - Examples</title>
<programlisting format="linespecific">
...
# kamcmd core.psx
{
"jsonrpc": "2.0",
"method": "core.psx",
"id": 1
}
...
## - prototype: kamcmd dispatcher.set_state _state_ _group_ _address_
# kamcmd dispatcher.set_state ip 2 sip:127.0.0.1:5080
{
"jsonrpc": "2.0",
"method": "dispatcher.set_state",
"params": ["ip", 2, "sip:127.0.0.1:5080"],
"id": 1
}
## - or:
{
"jsonrpc": "2.0",
"method": "dispatcher.set_state",
"params": {
"state": "ip",
"grpup": 2,
"address": "sip:127.0.0.1:5080"
},
"id": 1
}
...
</programlisting>
</example>
</section>
<section>
<title>JSONRPC Transports</title>
<para>
JSONRPC specifications do not enforce a specific transport to carry the
JSON documents. Very common is JSONRPC over HTTP or HTTPS, and they are
supported by &kamailio;. In addition, &kamailio; supports receiving JSON
documents via a local FIFO file.
documents via a local FIFO file.
</para>
<section>
<title>JSONRPC Over HTTP</title>

@ -424,6 +424,7 @@ kz_amqp_zone_ptr kz_amqp_get_primary_zone() {
strcpy(kz_primary_zone->zone, dbk_primary_zone_name.s);
kz_primary_zone->zone[dbk_primary_zone_name.len] = '\0';
kz_primary_zone->servers = (kz_amqp_servers_ptr) shm_malloc(sizeof(kz_amqp_servers));
memset(kz_primary_zone->servers, 0, sizeof(kz_amqp_servers));
}
return kz_primary_zone;
}
@ -451,6 +452,7 @@ kz_amqp_zone_ptr kz_amqp_add_zone(char* zone) {
strcpy(zone_ptr->zone, zone);
zone_ptr->zone[strlen(zone)] = '\0';
zone_ptr->servers = (kz_amqp_servers_ptr) shm_malloc(sizeof(kz_amqp_servers));
memset(zone_ptr->servers, 0, sizeof(kz_amqp_servers));
kz_zones->tail->next = zone_ptr;
kz_zones->tail = zone_ptr;
return zone_ptr;
@ -657,7 +659,7 @@ int kz_amqp_add_connection(modparam_t type, void* val)
url = ++ptr;
} else {
zone_ptr = kz_amqp_get_primary_zone();
zone_ptr = kz_amqp_get_zones();
}

@ -153,7 +153,7 @@ kz_amqp_cmd_ptr kz_cmd_retrieve(str* message_id)
p = kz_search_cmd_table(message_id, hash_code);
if(p== NULL)
{
LM_DBG("command pointer hash entry not found\n");
LM_DBG("command pointer hash entry not found - %s\n", message_id->s);
lock_release(&kz_cmd_htable[hash_code].lock);
return NULL;
}
@ -167,7 +167,7 @@ kz_amqp_cmd_ptr kz_cmd_retrieve(str* message_id)
}
if(prev_p->next== NULL)
{
LM_ERR("command pointer not found\n");
LM_ERR("command pointer not found - %s\n", message_id->s);
lock_release(&kz_cmd_htable[hash_code].lock);
return NULL;
}

@ -61,7 +61,7 @@ Juha Heinanen
3.34. defunct_gw_avp (AVP string)
3.35. lcr_rule_hash_size (integer)
3.36. lcr_gw_count (integer)
3.37. dont_strip_or_tag_flag (integer)
3.37. dont_strip_or_prefix_flag (integer)
3.38. priority_ordering (integer)
3.39. fetch_rows (integer)
3.40. ping_interval (integer)
@ -128,7 +128,7 @@ Juha Heinanen
1.34. Setting defunct_gw_avp module parameter
1.35. Setting lcr_rule_hash_size module parameter
1.36. Setting lcr_gw_count module parameter
1.37. Setting dont_strip_or_tag_flag module parameter
1.37. Setting dont_strip_or_prefix_flag module parameter
1.38. Setting priority_ordering module parameter
1.39. Set fetch_rows parameter
1.40. Set ping_interval parameter
@ -198,7 +198,7 @@ Chapter 1. Admin Guide
3.34. defunct_gw_avp (AVP string)
3.35. lcr_rule_hash_size (integer)
3.36. lcr_gw_count (integer)
3.37. dont_strip_or_tag_flag (integer)
3.37. dont_strip_or_prefix_flag (integer)
3.38. priority_ordering (integer)
3.39. fetch_rows (integer)
3.40. ping_interval (integer)
@ -280,8 +280,8 @@ Chapter 1. Admin Guide
be done with command 'kamctl eval_weights'.
The function next_gw() can then be used to select one gateway at a time
for forwarding. Upon each call, unless "dont_strip_or_tag_flag" flag is
set, user part of the original Request-URI is first stripped by the
for forwarding. Upon each call, unless "dont_strip_or_prefix_flag" flag
is set, user part of the original Request-URI is first stripped by the
number of characters as specified by the gateway's strip count and then
prefixed by the gateway's prefix. Upon each call, if a gateway's
hostname is NULL, Request-URI will be rewritten based on gateway's URI
@ -356,7 +356,7 @@ Chapter 1. Admin Guide
3.34. defunct_gw_avp (AVP string)
3.35. lcr_rule_hash_size (integer)
3.36. lcr_gw_count (integer)
3.37. dont_strip_or_tag_flag (integer)
3.37. dont_strip_or_prefix_flag (integer)
3.38. priority_ordering (integer)
3.39. fetch_rows (integer)
3.40. ping_interval (integer)
@ -793,16 +793,16 @@ modparam("lcr", "lcr_rule_hash_size", 1024)
modparam("lcr", "lcr_gw_count", 1024)
...
3.37. dont_strip_or_tag_flag (integer)
3.37. dont_strip_or_prefix_flag (integer)
Defines the flag number used to tell if stripping and tagging is done
for the selected gateway.
Default value is -1 meaning that the flag is not defined.
Example 1.37. Setting dont_strip_or_tag_flag module parameter
Example 1.37. Setting dont_strip_or_prefix_flag module parameter
...
modparam("lcr", "dont_strip_or_tag_flag", 10)
modparam("lcr", "dont_strip_or_prefix_flag", 10)
...
3.38. priority_ordering (integer)

@ -99,7 +99,7 @@
<para>
The function <emphasis>next_gw()</emphasis> can then be used to
select one gateway at a
time for forwarding. Upon each call, unless "dont_strip_or_tag_flag"
time for forwarding. Upon each call, unless "dont_strip_or_prefix_flag"
flag is set, user part of the original Request-URI is first
stripped by the number of characters as specified by the
gateway's strip count and then prefixed by
@ -961,7 +961,7 @@ modparam("lcr", "lcr_gw_count", 1024)
</section>
<section>
<title><varname>dont_strip_or_tag_flag</varname> (integer)</title>
<title><varname>dont_strip_or_prefix_flag</varname> (integer)</title>
<para>
Defines the flag number used to tell if stripping and
tagging is done for the selected gateway.
@ -974,12 +974,12 @@ modparam("lcr", "lcr_gw_count", 1024)
</para>
<example>
<title>
Setting <varname>dont_strip_or_tag_flag</varname> module
Setting <varname>dont_strip_or_prefix_flag</varname> module
parameter
</title>
<programlisting format="linespecific">
...
modparam("lcr", "dont_strip_or_tag_flag", 10)
modparam("lcr", "dont_strip_or_prefix_flag", 10)
...
</programlisting>
</example>

@ -258,13 +258,13 @@ errout:
if (pv_mcd_key_check(msg, param, &key, &expiry) < 0)
return -1;
if (val == NULL) {
if (val == NULL || val->flags&PV_VAL_NULL) {
if (memcached_delete(memcached_h, key.s, key.len, 0) != MEMCACHED_SUCCESS) {
LM_ERR("could not delete key %.*s\n", param->pvn.u.isname.name.s.len,
param->pvn.u.isname.name.s.s);
return -1;
}
LM_WARN("delete key %.*s\n", key.len, key.s);
LM_DBG("delete key %.*s\n", key.len, key.s);
return 0;
}

@ -449,7 +449,7 @@ if(rtplen != prtpstat->len)
LM_ERR ("Unable to find RTPSTAT pv!\n");
goto initerr;
}
prtp_pv = pv_cache_get (&prtpstat);
prtp_pv = pv_cache_get (prtpstat);
if(!prtp_pv)
{
LM_ERR ("Unable to find pv spec for RTPSTAT!\n");
@ -479,4 +479,4 @@ if (pmod_data->pcall_lock->plock)
shm_free (pmod_data);
pmod_data = NULL;
return -1;
}
}

@ -1264,7 +1264,7 @@ error:
int publ_notify(presentity_t* p, str pres_uri, str* body, str* offline_etag, str* rules_doc)
{
str *notify_body = NULL, *aux_body = NULL;
str *notify_body = NULL;
subs_t* subs_array= NULL, *s= NULL;
int ret_code= -1;
@ -1291,22 +1291,13 @@ int publ_notify(presentity_t* p, str pres_uri, str* body, str* offline_etag, str
while(s)
{
s->auth_rules_doc= rules_doc;
if (p->event->aux_body_processing) {
aux_body = p->event->aux_body_processing(s, notify_body?notify_body:body);
}
if(notify(s, NULL, aux_body?aux_body:(notify_body?notify_body:body), 0)< 0 )
if(notify(s, NULL, notify_body?notify_body:body, 0, p->event->aux_body_processing)< 0 )
{
LM_ERR("Could not send notify for %.*s\n",
p->event->name.len, p->event->name.s);
}
if(aux_body!=NULL) {
if(aux_body->s) {
p->event->aux_free_body(aux_body->s);
}
pkg_free(aux_body);
}
s= s->next;
}
ret_code= 0;
@ -1454,7 +1445,7 @@ int query_db_notify(str* pres_uri, pres_ev_t* event, subs_t* watcher_subs )
aux_body = event->aux_body_processing(s, notify_body);
}
if(notify(s, watcher_subs, aux_body?aux_body:notify_body, 0)< 0 )
if(notify(s, watcher_subs, aux_body?aux_body:notify_body, 0, 0)< 0 )
{
LM_ERR("Could not send notify for [event]=%.*s\n",
event->name.len, event->name.s);
@ -1667,8 +1658,11 @@ error:
}
int notify(subs_t* subs, subs_t * watcher_subs,str* n_body,int force_null_body)
int notify(subs_t* subs, subs_t * watcher_subs,str* n_body,int force_null_body, aux_body_processing_t* aux_body_processing)
{
str* aux_body = NULL;
/* update first in hash table and the send Notify */
if(subs->expires!= 0 && subs->status != TERMINATED_STATUS)
{
@ -1705,11 +1699,29 @@ int notify(subs_t* subs, subs_t * watcher_subs,str* n_body,int force_null_body)
force_null_body = 1;
}
if(send_notify_request(subs, watcher_subs, n_body, force_null_body)< 0)
if (!force_null_body && aux_body_processing)
{
aux_body = aux_body_processing(subs, n_body);
}
if(send_notify_request(subs, watcher_subs, aux_body?aux_body:n_body, force_null_body)< 0)
{
LM_ERR("sending Notify not successful\n");
if(aux_body!=NULL) {
if(aux_body->s) {
subs->event->aux_free_body(aux_body->s);
}
pkg_free(aux_body);
}
return -1;
}
if(aux_body!=NULL) {
if(aux_body->s) {
subs->event->aux_free_body(aux_body->s);
}
pkg_free(aux_body);
}
return 0;
}
@ -2731,7 +2743,7 @@ static int notifier_notify(subs_t *sub, int *updated, int *end_transaction)
goto done;
}
if (notify(sub, NULL, nbody, 0) < 0)
if (notify(sub, NULL, nbody, 0, 0) < 0)
{
LM_ERR("could not send notify\n");
goto error;

@ -116,7 +116,7 @@ int publ_notify_notifier(str pres_uri, pres_ev_t *event);
int set_updated(subs_t *sub);
int set_wipeer_subs_updated(str *pres_uri, pres_ev_t *event, int full);
int notify(subs_t* subs, subs_t* watcher_subs, str* n_body,int force_null_body);
int notify(subs_t* subs, subs_t* watcher_subs, str* n_body,int force_null_body, aux_body_processing_t* aux_body_processing);
int send_notify_request(subs_t* subs, subs_t * watcher_subs,
str* n_body,int force_null_body);

@ -1171,7 +1171,7 @@ send_notify:
while(s)
{
if(notify(s, NULL, NULL, 0)< 0)
if(notify(s, NULL, NULL, 0, 0)< 0)
{
LM_ERR( "sending Notify request\n");
goto done;

@ -610,7 +610,7 @@ int update_subscription(struct sip_msg* msg, subs_t* subs, int to_tag_gen,
*sent_reply= 1;
}
if(notify(subs, NULL, NULL, 0)< 0)
if(notify(subs, NULL, NULL, 0, 0)< 0)
{
LM_ERR("Could not send notify\n");
goto error;
@ -697,7 +697,7 @@ int update_subscription(struct sip_msg* msg, subs_t* subs, int to_tag_gen,
}
if(subs->send_on_cback== 0)
{
if(notify(subs, NULL, NULL, 0)< 0)
if(notify(subs, NULL, NULL, 0, 0)< 0)
{
LM_ERR("Could not send notify\n");
goto error;
@ -706,7 +706,7 @@ int update_subscription(struct sip_msg* msg, subs_t* subs, int to_tag_gen,
}
else
{
if(send_fast_notify && (notify(subs, NULL, NULL, 0)< 0))
if(send_fast_notify && (notify(subs, NULL, NULL, 0, 0)< 0))
{
LM_ERR("Could not send notify\n");
goto error;
@ -724,7 +724,7 @@ int update_subscription(struct sip_msg* msg, subs_t* subs, int to_tag_gen,
}
*sent_reply= 1;
if(send_fast_notify && (notify(subs, NULL, NULL, 0 )< 0))
if(send_fast_notify && (notify(subs, NULL, NULL, 0, 0)< 0))
{
LM_ERR("sending notify request\n");
goto error;

@ -254,10 +254,15 @@ __dialog_sendpublish(struct dlg_cell *dlg, int type, struct dlg_cb_params *_para
str tag = {0,0};
str uri = {0,0};
str target = {0,0};
struct dlginfo_cell *dlginfo = NULL;
dlginfo = (struct dlginfo_cell*)*_params->param;
struct dlginfo_cell *dlginfo = (struct dlginfo_cell*)*_params->param;
if(dlg==NULL || dlginfo==NULL) {
LM_WARN("execution with null parameters - type %d, dlg %p, info %p\n",
type, dlg, dlginfo);
return;
}
if(include_req_uri) {
uri = dlginfo->req_uri;
} else {

@ -359,9 +359,6 @@ static int get_cpuload(double * load)
vload = ((double)d_idle) / (double)d_total;
/* divide by numbers of cpu */
ncpu = get_num_cpus();
vload = vload/ncpu;
vload = 1.0 - vload;
if(vload<0.0) vload = 0.0;
else if (vload>1.0) vload = 1.0;

@ -318,6 +318,7 @@ int rtjson_init_serial(sip_msg_t *msg, srjson_doc_t *jdoc, sr_xavp_t *iavp)
str val;
unsigned int bflags = 0;
unsigned int old_bflags = 0;
struct socket_info* fsocket = NULL;
tj = srjson_GetObjectItem(jdoc, jdoc->root, "routes");
if(tj==NULL || tj->type!=srjson_Array || tj->child==NULL) {
@ -370,6 +371,17 @@ int rtjson_init_serial(sip_msg_t *msg, srjson_doc_t *jdoc, sr_xavp_t *iavp)
}
}
rj = srjson_GetObjectItem(jdoc, nj, "socket");
if(rj!=NULL && rj->type==srjson_String && rj->valuestring!=NULL) {
val.s = rj->valuestring;
val.len = strlen(val.s);
LM_DBG("trying to set send socket to: [%.*s]\n", val.len, val.s);
fsocket = lookup_local_socket(&val);
if(fsocket) {
set_force_socket(msg, fsocket);
}
}
rj = srjson_GetObjectItem(jdoc, nj, "branch_flags");
if(rj!=NULL && rj->type==srjson_Number && SRJSON_GET_UINT(rj)!=0) {
bflags = SRJSON_GET_UINT(rj);
@ -481,7 +493,7 @@ int rtjson_prepare_branch(sip_msg_t *msg, srjson_doc_t *jdoc, srjson_t *nj)
xuri.len = strlen(xuri.s);
}
if(xdsp.len>0 || xuri.len>0) {
uacb.replace_from(msg, &xdsp, &xuri);
uacb.replace_to(msg, &xdsp, &xuri);
}
}
}
@ -498,6 +510,7 @@ int rtjson_append_branch(sip_msg_t *msg, srjson_doc_t *jdoc, srjson_t *nj)
str uri = {0};
str duri = {0};
str path = {0};
str socket = {0};
struct socket_info* fsocket = NULL;
unsigned int bflags = 0;
@ -519,7 +532,12 @@ int rtjson_append_branch(sip_msg_t *msg, srjson_doc_t *jdoc, srjson_t *nj)
path.s = rj->valuestring;
path.len = strlen(path.s);
}
rj = srjson_GetObjectItem(jdoc, nj, "socket");
if(rj!=NULL && rj->type==srjson_String && rj->valuestring!=NULL) {
socket.s = rj->valuestring;
socket.len = strlen(socket.s);
fsocket = lookup_local_socket(&socket);
}
if (append_branch(msg, &uri, &duri, &path, 0, bflags,
fsocket, 0 /*instance*/, 0,
0, 0) <0) {

@ -965,8 +965,12 @@ rtpengine_delete();
with internal flag FL_SDP_BODY to know that the 1xx and 2xx are for
rtpengine_answer()
* If ACK with SDP, then do rtpengine_answer()
* If BYE or CANCEL, or called within a FAILURE_ROUTE[], then do
rtpengine_delete()
* If BYE or CANCEL, or called within a FAILURE_ROUTE[], then call
rtpengine_delete(). Be careful with calling this function after
resuming a suspended transaction (e.g., after t_continue()),
because the context of executed route is FAILURE ROUTE (in other
words, rtpengine_manage() in the route block of t_continue() does
the same as in failure_route).
* If reply to INVITE with code >= 300 do rtpengine_delete()
* If reply with SDP to INVITE having code 1xx and 2xx, then do
rtpengine_answer() if the request had SDP or tm is not loaded,

@ -1080,7 +1080,12 @@ rtpengine_delete();
</listitem>
<listitem>
<para>
If BYE or CANCEL, or called within a FAILURE_ROUTE[], then do <function>rtpengine_delete()</function>
If BYE or CANCEL, or called within a FAILURE_ROUTE[], then call
<function>rtpengine_delete()</function>. Be careful with calling
this function after resuming a suspended transaction (e.g., after
t_continue()), because the context of executed route is FAILURE
ROUTE (in other words, rtpengine_manage() in the route block of
t_continue() does the same as in failure_route).
</para>
</listitem>
<listitem>

@ -640,8 +640,12 @@ rtpproxy_destroy();
with internal flag FL_SDP_BODY to know that the 1xx and 2xx are for
rtpproxy_answer()
* If ACK with SDP, then do rtpproxy_answer()
* If BYE or CANCEL, or called within a FAILURE_ROUTE[], then do
unforce_rtpproxy()
* If BYE or CANCEL, or called within a FAILURE_ROUTE[], then call
unforce_rtpproxy(). Be careful with calling this function after
resuming a suspended transaction (e.g., after t_continue()),
because the context of executed route is FAILURE ROUTE (in other
words, rtpproxy_manage() in the route block of t_continue() does
the same as in failure_route).
* If reply to INVITE with code >= 300 do unforce_rtpproxy()
* If reply with SDP to INVITE having code 1xx and 2xx, then do
rtpproxy_answer() if the request had SDP or tm is not loaded,

@ -680,7 +680,12 @@ rtpproxy_destroy();
</listitem>
<listitem>
<para>
If BYE or CANCEL, or called within a FAILURE_ROUTE[], then do <function>unforce_rtpproxy()</function>
If BYE or CANCEL, or called within a FAILURE_ROUTE[], then call
<function>unforce_rtpproxy()</function>. Be careful with calling
this function after resuming a suspended transaction (e.g., after
t_continue()), because the context of executed route is FAILURE
ROUTE (in other words, rtpproxy_manage() in the route block of
t_continue() does the same as in failure_route).
</para>
</listitem>
<listitem>

@ -38,12 +38,13 @@
static int count = 0;
struct hep_timehdr* heptime;
struct hep_timeinfo* heptime;
/* HEPv2 HEPv3 */
int hepv2_received(char *buf, unsigned int len, struct receive_info *ri);
int hepv3_received(char *buf, unsigned int len, struct receive_info *ri);
int parsing_hepv3_message(char *buf, unsigned int len);
/**
* HEP message
*/
@ -100,7 +101,7 @@ int hepv2_received(char *buf, unsigned int len, struct receive_info *ri){
struct hep_iphdr *hepiph = NULL;
struct hep_timehdr* heptime_tmp = NULL;
memset(heptime, 0, sizeof(struct hep_timehdr));
memset(heptime, 0, sizeof(struct hep_timeinfo));
struct hep_ip6hdr *hepip6h = NULL;
@ -139,7 +140,7 @@ int hepv2_received(char *buf, unsigned int len, struct receive_info *ri){
else if(heph->hp_p == IPPROTO_SCTP) ri->proto=PROTO_SCTP;
#endif
else {
LOG(L_ERR, "ERROR: sipcapture:hep_msg_received: unknow protocol [%d]\n",heph->hp_p);
LOG(L_ERR, "ERROR: sipcapture:hep_msg_received: unknown protocol [%d]\n",heph->hp_p);
ri->proto = PROTO_NONE;
}
@ -262,7 +263,7 @@ int parsing_hepv3_message(char *buf, unsigned int len) {
memset(hg, 0, sizeof(struct hep_generic_recv));
memset(heptime, 0, sizeof(struct hep_timehdr));
memset(heptime, 0, sizeof(struct hep_timeinfo));
/* HEADER */
@ -394,7 +395,7 @@ int parsing_hepv3_message(char *buf, unsigned int len) {
case 12:
hg->capt_id = (hep_chunk_uint32_t *) (tmp);
i+=chunk_length;
heptime->captid = ntohs(hg->capt_id->data);
heptime->captid = ntohl(hg->capt_id->data);
totelem++;
break;
@ -486,7 +487,7 @@ int parsing_hepv3_message(char *buf, unsigned int len) {
/*TIME*/
heptime->tv_sec = hg->time_sec->data;
heptime->tv_usec = hg->time_usec->data;
heptime->captid = ntohs(hg->capt_id->data);
heptime->captid = ntohl(hg->capt_id->data);
if(payload != NULL ) {
@ -514,6 +515,3 @@ error:
}

@ -61,6 +61,12 @@ struct hep_timehdr{
u_int16_t captid; /* Capture ID node */
};
struct hep_timeinfo{
u_int32_t tv_sec; /* seconds */
u_int32_t tv_usec; /* useconds */
u_int32_t captid; /* Capture ID node */
};
struct hep_ip6hdr {
struct in6_addr hp6_src; /* source address */
struct in6_addr hp6_dst; /* destination address */

@ -1606,7 +1606,7 @@ static int sip_capture(struct sip_msg *msg, str *_table, _capture_mode_data_t *
if(heptime && heptime->tv_sec != 0) {
sco.tmstamp = (unsigned long long)heptime->tv_sec*1000000+heptime->tv_usec; /* micro ts */
snprintf(tmp_node, 100, "%.*s:%i", capture_node.len, capture_node.s, heptime->captid);
snprintf(tmp_node, 100, "%.*s:%lu", capture_node.len, capture_node.s, (unsigned long)heptime->captid);
sco.node.s = tmp_node;
sco.node.len = strlen(tmp_node);
}
@ -2285,15 +2285,15 @@ int receive_logging_json_msg(char * buf, unsigned int len, struct hep_generic_re
/*source ip*/
sco.source_ip.s = ipstr_src;
sco.source_ip.len = strlen(ipstr_src);
sco.source_port = hg->src_port->data;
sco.source_port = ntohs(hg->src_port->data);
sco.destination_ip.s = ipstr_dst;
sco.destination_ip.len = strlen(ipstr_dst);
sco.destination_port = hg->dst_port->data;
sco.destination_port = ntohs(hg->dst_port->data);
if(heptime && heptime->tv_sec != 0) {
sco.tmstamp = (unsigned long long)heptime->tv_sec*1000000+heptime->tv_usec; /* micro ts */
snprintf(tmp_node, 100, "%.*s:%i", capture_node.len, capture_node.s, heptime->captid);
snprintf(tmp_node, 100, "%.*s:%lu", capture_node.len, capture_node.s, (unsigned long)heptime->captid);
sco.node.s = tmp_node;
sco.node.len = strlen(tmp_node);
epoch_time_as_time_t = heptime->tv_sec;;
@ -2307,7 +2307,6 @@ int receive_logging_json_msg(char * buf, unsigned int len, struct hep_generic_re
if(correlation_id) {
corrtmp.s = correlation_id;
corrtmp.len = strlen(correlation_id);
if(!strncmp(log_table, "rtcp_capture",12)) corrtmp.len--;
}
db_keys[0] = &date_column;
@ -2464,7 +2463,7 @@ static int report_capture(struct sip_msg *msg, str *_table, str* _corr, str *_d
if(heptime && heptime->tv_sec != 0) {
sco.tmstamp = (unsigned long long)heptime->tv_sec*1000000+heptime->tv_usec; /* micro ts */
snprintf(tmp_node, 100, "%.*s:%i", capture_node.len, capture_node.s, heptime->captid);
snprintf(tmp_node, 100, "%.*s:%lu", capture_node.len, capture_node.s, (unsigned long)heptime->captid);
sco.node.s = tmp_node;
sco.node.len = strlen(tmp_node);
epoch_time_as_time_t = heptime->tv_sec;;
@ -2482,7 +2481,6 @@ static int report_capture(struct sip_msg *msg, str *_table, str* _corr, str *_d
else if(correlation_id) {
corrtmp.s = correlation_id;
corrtmp.len = strlen(correlation_id);
if(!strncmp(_table->s, "rtcp_capture",12)) corrtmp.len--;
}
db_keys[0] = &date_column;

@ -3,7 +3,7 @@
#include <stdlib.h>
#include "../../sr_module.h"
#include "../../usr_avp.c"
#include "../../usr_avp.h"
#include "../../pvar.h"
#include "../../lvalue.h"
#include "lib_statsd.h"

@ -37,6 +37,7 @@
#include "../../ut.h"
#include "../../parser/msg_parser.h"
#include "../../parser/contact/parse_contact.h"
#include "../../srapi.h"
#include "lw_parser.h"
#include "t_msgbuilder.h"
#include "uac.h"
@ -198,8 +199,8 @@ char *build_local(struct cell *Trans,unsigned int branch,
append_str( p, Trans->cseq_n.s, Trans->cseq_n.len );
append_str( p, " ", 1 );
append_str( p, method, method_len );
append_str( p, MAXFWD_HEADER, MAXFWD_HEADER_LEN );
append_str( p, CRLF, CRLF_LEN );
append_str( p, MAXFWD_HEADER, MAXFWD_HEADER_LEN );
if (!is_local(Trans)) {
for ( hdr=Trans->uas.request->headers ; hdr ; hdr=hdr->next )
@ -279,6 +280,8 @@ char *build_local_reparse(struct cell *Trans,unsigned int branch,
int reason_len, code_len;
struct hdr_field *reas1, *reas_last, *hdr;
#endif /* CANCEL_REASON_SUPPORT */
int hadded = 0;
sr_cfgenv_t *cenv = NULL;
invite_buf = Trans->uac[branch].request.buffer;
invite_len = Trans->uac[branch].request.buffer_len;
@ -356,6 +359,8 @@ char *build_local_reparse(struct cell *Trans,unsigned int branch,
s = eat_line(s, invite_buf_end - s);
append_str(d, s1, s - s1);
cenv = sr_cfgenv_get();
/* check every header field name,
we must exclude and modify some of the headers */
first_via = 1;
@ -473,15 +478,35 @@ char *build_local_reparse(struct cell *Trans,unsigned int branch,
default:
s = lw_next_line(s, invite_buf_end);
hadded = 0;
/* uac auth headers */
if(Trans->uas.request &&
(Trans->uas.request->msg_flags & FL_UAC_AUTH)) {
if(s1 + cenv->uac_cseq_auth.len + 2 < invite_buf_end) {
if(s1[cenv->uac_cseq_auth.len]==':'
&& strncmp(s1, cenv->uac_cseq_auth.s,
cenv->uac_cseq_auth.len)==0) {
hadded = 1;
append_str(d, s1, s - s1);
} else if(s1[cenv->uac_cseq_refresh.len]==':'
&& strncmp(s1, cenv->uac_cseq_refresh.s,
cenv->uac_cseq_refresh.len)==0) {
hadded = 1;
append_str(d, s1, s - s1);
}
}
}
if (cfg_get(tm, tm_cfg, ac_extra_hdrs).len
&& (s1 + cfg_get(tm, tm_cfg, ac_extra_hdrs).len < invite_buf_end)
&& (strncasecmp(s1,
cfg_get(tm, tm_cfg, ac_extra_hdrs).s,
cfg_get(tm, tm_cfg, ac_extra_hdrs).len) == 0)
) {
append_str(d, s1, s - s1);
} /* else skip this line */
if(likely(hadded==0)) {
if (cfg_get(tm, tm_cfg, ac_extra_hdrs).len
&& (s1 + cfg_get(tm, tm_cfg, ac_extra_hdrs).len < invite_buf_end)
&& (strncasecmp(s1,
cfg_get(tm, tm_cfg, ac_extra_hdrs).s,
cfg_get(tm, tm_cfg, ac_extra_hdrs).len) == 0)) {
append_str(d, s1, s - s1);
}
}
break;
}
}
@ -1467,11 +1492,20 @@ char* build_uac_req(str* method, str* headers, str* body, dlg_t* dialog, int bra
str content_length, cseq, via;
unsigned int maxfwd_len;
int tbracket, fbracket;
str fromtag = STR_NULL;
str loc_tag = STR_NULL;
if (!method || !dialog) {
LOG(L_ERR, "build_uac_req(): Invalid parameter value\n");
return 0;
}
if (dialog->id.loc_tag.len<=0) {
/* From Tag is mandatory in RFC3261 - generate one if not provided */
generate_fromtag(&fromtag, &dialog->id.call_id);
loc_tag = dialog->id.loc_tag;
dialog->id.loc_tag = fromtag;
}
if (print_content_length(&content_length, body) < 0) {
LOG(L_ERR, "build_uac_req(): Error while printing content-length\n");
return 0;
@ -1552,6 +1586,9 @@ char* build_uac_req(str* method, str* headers, str* body, dlg_t* dialog, int bra
memapp(w, via.s, via.len); /* Top-most Via */
w = print_to(w, dialog, t, tbracket); /* To */
w = print_from(w, dialog, t, fbracket); /* From */
if(fromtag.len>0) {
dialog->id.loc_tag = loc_tag;
}
w = print_cseq(w, &cseq, method, t); /* CSeq */
w = print_callid(w, dialog, t); /* Call-ID */
w = print_routeset(w, dialog); /* Route set */

@ -381,12 +381,21 @@ if(t_suspend())
* rtname - the name of the route block to execute. Can be a static
string value or a dynamic string with pseudo-variables.
Important note: the route[rtname] is executed in the context of a
failure (same behaviour for functions as they were used in a
failure_route block).
This function can be used in ANY_ROUTE.
Example 1.11. t_continue usage
...
t_continue('123', '456', 'MYROUTE');
...
route[MYROUTE] {
xlog("executed by t continue\n");
...
}
...
4.11. t_reuse_branch()

@ -379,6 +379,11 @@ if(t_suspend())
pseudo-variables.
</para></listitem>
</itemizedlist>
<para>
Important note: the route[rtname] is executed in the context of
a failure (same behaviour for functions as they were used in a
failure_route block).
</para>
<para>
This function can be used in ANY_ROUTE.
</para>
@ -388,6 +393,11 @@ if(t_suspend())
...
t_continue('123', '456', 'MYROUTE');
...
route[MYROUTE] {
xlog("executed by t continue\n");
...
}
...
</programlisting>
</example>
</section>

@ -907,6 +907,7 @@ static void rpc_fault(rpc_ctx_t* ctx, int code, char* fmt, ...)
static char buf[REASON_BUF_LEN];
va_list ap;
fix_delayed_reply_ctx(ctx);
ctx->reply.code = code;
va_start(ap, fmt);
vsnprintf(buf, REASON_BUF_LEN, fmt, ap);

@ -1,5 +1,5 @@
%define name kamailio
%define ver 4.4.4
%define ver 4.4.5
%define rel 0.0%{dist}

@ -1,3 +1,9 @@
kamailio (4.4.5) unstable; urgency=medium
* version set to 4.4.5
-- Victor Seva <vseva@debian.org> Wed, 18 Jan 2017 15:09:42 +0100
kamailio (4.4.4) unstable; urgency=medium
* version set to 4.4.4

@ -1,3 +1,9 @@
kamailio (4.4.5) unstable; urgency=medium
* version set to 4.4.5
-- Victor Seva <vseva@debian.org> Wed, 18 Jan 2017 15:09:42 +0100
kamailio (4.4.4) unstable; urgency=medium
* version set to 4.4.4

@ -1,3 +1,9 @@
kamailio (4.4.5) unstable; urgency=medium
* version set to 4.4.5
-- Victor Seva <vseva@debian.org> Wed, 18 Jan 2017 15:09:42 +0100
kamailio (4.4.4) unstable; urgency=medium
* version set to 4.4.4

@ -1,3 +1,9 @@
kamailio (4.4.5) unstable; urgency=medium
* version set to 4.4.5
-- Victor Seva <vseva@debian.org> Wed, 18 Jan 2017 15:09:42 +0100
kamailio (4.4.4) unstable; urgency=medium
* version set to 4.4.4

@ -1,3 +1,9 @@
kamailio (4.4.5) unstable; urgency=medium
* version set to 4.4.5
-- Victor Seva <vseva@debian.org> Wed, 18 Jan 2017 15:09:42 +0100
kamailio (4.4.4) unstable; urgency=medium
* version set to 4.4.4

@ -1,3 +1,9 @@
kamailio (4.4.5) unstable; urgency=medium
* version set to 4.4.5
-- Victor Seva <vseva@debian.org> Wed, 18 Jan 2017 15:09:42 +0100
kamailio (4.4.4) unstable; urgency=medium
* version set to 4.4.4

@ -1,3 +1,9 @@
kamailio (4.4.5) unstable; urgency=medium
* version set to 4.4.5
-- Victor Seva <vseva@debian.org> Wed, 18 Jan 2017 15:09:42 +0100
kamailio (4.4.4) unstable; urgency=medium
* version set to 4.4.4

@ -1,3 +1,9 @@
kamailio (4.4.5) unstable; urgency=medium
* version set to 4.4.5
-- Victor Seva <vseva@debian.org> Wed, 18 Jan 2017 15:09:42 +0100
kamailio (4.4.4) unstable; urgency=medium
* version set to 4.4.4

@ -1,3 +1,9 @@
kamailio (4.4.5) unstable; urgency=medium
* version set to 4.4.5
-- Victor Seva <vseva@debian.org> Wed, 18 Jan 2017 15:09:42 +0100
kamailio (4.4.4) unstable; urgency=medium
* version set to 4.4.4

@ -1,5 +1,5 @@
%define name kamailio
%define ver 4.4.4
%define ver 4.4.5
%define rel 0%{dist}

@ -1,5 +1,5 @@
%define name kamailio
%define ver 4.4.4
%define ver 4.4.5
%define rel 0
%define _sharedir %{_prefix}/share

@ -1,5 +1,5 @@
%define name kamailio
%define ver 4.4.4
%define ver 4.4.5
%define rel 0
%define _sharedir %{_prefix}/share

@ -1,5 +1,5 @@
%define name kamailio
%define ver 4.4.4
%define ver 4.4.5
%define rel 0
%define EXCLUDED_MODULES mysql jabber cpl-c avp_radius auth_radius group_radius uri_radius pa postgres osp tlsops unixodbc

@ -1,5 +1,5 @@
%define name kamailio
%define ver 4.4.4
%define ver 4.4.5
%define rel 0
%define _sharedir %{_prefix}/share

@ -1,5 +1,5 @@
%define name kamailio
%define ver 4.4.4
%define ver 4.4.5
%define rel 0
%define EXCLUDED_MODULES mysql jabber cpl-c auth_radius misc_radius peering postgress pa unixodbc osp tlsops

@ -56,6 +56,10 @@ static sr_cfgenv_t _sr_cfgenv;
void sr_cfgenv_init(void)
{
memset(&_sr_cfgenv, 0, sizeof(sr_cfgenv_t));
_sr_cfgenv.uac_cseq_auth.s = "P-K-CSeq-Auth";
_sr_cfgenv.uac_cseq_auth.len = strlen(_sr_cfgenv.uac_cseq_auth.s);
_sr_cfgenv.uac_cseq_refresh.s = "P-K-CSeq-Refresh";
_sr_cfgenv.uac_cseq_refresh.len = strlen(_sr_cfgenv.uac_cseq_refresh.s);
}
/**

@ -31,6 +31,8 @@ sr_generate_callid_f sr_get_callid_func(void);
typedef int (*sr_cseq_update_f)(sip_msg_t*);
typedef struct sr_cfgenv {
sr_cseq_update_f cb_cseq_update;
str uac_cseq_auth;
str uac_cseq_refresh;
} sr_cfgenv_t;
void sr_cfgenv_init(void);

@ -7,4 +7,4 @@ METADATA_READONLY
METADATA_LOGFLAGS
0
METADATA_DEFAULTS
NIL|''|''|NULL|''|NULL|NULL|'2030-05-28 21:32:15'|1.0|'Default-Call-ID'|1|'1900-01-01 00:00:01'|0|0|''|NULL|NULL|NULL|0|0|0|0|0
NIL|''|''|NULL|''|NULL|NULL|'2030-05-28 21:32:15'|1.0|'Default-Call-ID'|1|'2000-01-01 00:00:01'|0|0|''|NULL|NULL|NULL|0|0|0|0|0

@ -7,4 +7,4 @@ METADATA_READONLY
METADATA_LOGFLAGS
0
METADATA_DEFAULTS
NIL|NIL|NULL|'1900-01-01 00:00:01'
NIL|NIL|NULL|'2000-01-01 00:00:01'

@ -7,4 +7,4 @@ METADATA_READONLY
METADATA_LOGFLAGS
0
METADATA_DEFAULTS
NIL|NIL|NIL|NIL|NIL|'1900-01-01 00:00:01'
NIL|NIL|NIL|NIL|NIL|'2000-01-01 00:00:01'

@ -7,4 +7,4 @@ METADATA_READONLY
METADATA_LOGFLAGS
0
METADATA_DEFAULTS
NIL|''|''|''|'1900-01-01 00:00:01'
NIL|''|''|''|'2000-01-01 00:00:01'

@ -7,4 +7,4 @@ METADATA_READONLY
METADATA_LOGFLAGS
0
METADATA_DEFAULTS
NIL|''|''|NULL|''|NULL|NULL|'2030-05-28 21:32:15'|1.0|'Default-Call-ID'|1|'1900-01-01 00:00:01'|0|0|''|NULL|NULL|NULL|0|0|0|0|0
NIL|''|''|NULL|''|NULL|NULL|'2030-05-28 21:32:15'|1.0|'Default-Call-ID'|1|'2000-01-01 00:00:01'|0|0|''|NULL|NULL|NULL|0|0|0|0|0

@ -7,4 +7,4 @@ METADATA_READONLY
METADATA_LOGFLAGS
0
METADATA_DEFAULTS
NIL|''|''|NULL|''|0|''|'1900-01-01 00:00:01'
NIL|''|''|NULL|''|0|''|'2000-01-01 00:00:01'

@ -7,4 +7,4 @@ METADATA_READONLY
METADATA_LOGFLAGS
0
METADATA_DEFAULTS
NIL|'1900-01-01 00:00:01'|0|''|''|NIL|''|''|''|''|''|''|''
NIL|'2000-01-01 00:00:01'|0|''|''|NIL|''|''|''|''|''|''|''

@ -7,4 +7,4 @@ METADATA_READONLY
METADATA_LOGFLAGS
0
METADATA_DEFAULTS
NIL|NIL|''|''|''|''|''|''|''|''|''|''|''|''|''|''|0|''|''|''|''|''|''|''
NIL|NIL|''|''|''|''|''|''|''|''|''|''|''|NIL|NIL|NIL|0|''|''|''|''|''|''|''

@ -7,4 +7,4 @@ METADATA_READONLY
METADATA_LOGFLAGS
0
METADATA_DEFAULTS
NIL|NIL|''|''|''|''|''|0|''|''|''|''|''|''|''|''|''|''|''|''|''|''|''|''|''
NIL|NIL|''|''|''|''|''|0|NIL|''|NIL|NIL|NIL|''|''|''|''|''|''|''|''|''|''|''|''

@ -7,4 +7,4 @@ METADATA_READONLY
METADATA_LOGFLAGS
0
METADATA_DEFAULTS
NIL|''|''|''|'1900-01-01 00:00:01'
NIL|''|''|''|'2000-01-01 00:00:01'

@ -7,4 +7,4 @@ METADATA_READONLY
METADATA_LOGFLAGS
0
METADATA_DEFAULTS
NIL|''|0|''|''|0|''|'1900-01-01 00:00:01'
NIL|''|0|''|''|0|''|'2000-01-01 00:00:01'

@ -6,7 +6,7 @@ CREATE TABLE usr_preferences (
attribute VARCHAR(32) DEFAULT '' NOT NULL,
type INTEGER DEFAULT 0 NOT NULL,
value VARCHAR(128) DEFAULT '' NOT NULL,
last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '1900-01-01 00:00:01' NOT NULL
last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '2000-01-01 00:00:01' NOT NULL
);
CREATE INDEX usr_preferences_ua_idx ON usr_preferences (uuid, attribute);

@ -2,7 +2,7 @@ CREATE TABLE domain (
id INTEGER PRIMARY KEY NOT NULL,
domain VARCHAR(64) NOT NULL,
did VARCHAR(64) DEFAULT NULL,
last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '1900-01-01 00:00:01' NOT NULL,
last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '2000-01-01 00:00:01' NOT NULL,
CONSTRAINT domain_domain_idx UNIQUE (domain)
);
@ -14,7 +14,7 @@ CREATE TABLE domain_attrs (
name VARCHAR(32) NOT NULL,
type INTEGER NOT NULL,
value VARCHAR(255) NOT NULL,
last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '1900-01-01 00:00:01' NOT NULL,
last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '2000-01-01 00:00:01' NOT NULL,
CONSTRAINT domain_attrs_domain_attrs_idx UNIQUE (did, name, value)
);

@ -3,7 +3,7 @@ CREATE TABLE grp (
username VARCHAR(64) DEFAULT '' NOT NULL,
domain VARCHAR(64) DEFAULT '' NOT NULL,
grp VARCHAR(64) DEFAULT '' NOT NULL,
last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '1900-01-01 00:00:01' NOT NULL,
last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '2000-01-01 00:00:01' NOT NULL,
CONSTRAINT grp_account_group_idx UNIQUE (username, domain, grp)
);

@ -10,7 +10,7 @@ CREATE TABLE aliases (
q REAL DEFAULT 1.0 NOT NULL,
callid VARCHAR(255) DEFAULT 'Default-Call-ID' NOT NULL,
cseq INTEGER DEFAULT 1 NOT NULL,
last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '1900-01-01 00:00:01' NOT NULL,
last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '2000-01-01 00:00:01' NOT NULL,
flags INTEGER DEFAULT 0 NOT NULL,
cflags INTEGER DEFAULT 0 NOT NULL,
user_agent VARCHAR(255) DEFAULT '' NOT NULL,

@ -1,6 +1,6 @@
CREATE TABLE sip_trace (
id INTEGER PRIMARY KEY NOT NULL,
time_stamp TIMESTAMP WITHOUT TIME ZONE DEFAULT '1900-01-01 00:00:01' NOT NULL,
time_stamp TIMESTAMP WITHOUT TIME ZONE DEFAULT '2000-01-01 00:00:01' NOT NULL,
time_us INTEGER DEFAULT 0 NOT NULL,
callid VARCHAR(255) DEFAULT '' NOT NULL,
traced_user VARCHAR(128) DEFAULT '' NOT NULL,

@ -12,9 +12,9 @@ CREATE TABLE topos_d (
bs_contact VARCHAR(128) DEFAULT '' NOT NULL,
a_tag VARCHAR(255) DEFAULT '' NOT NULL,
b_tag VARCHAR(255) DEFAULT '' NOT NULL,
a_rr TEXT DEFAULT '' NOT NULL,
b_rr TEXT DEFAULT '' NOT NULL,
s_rr TEXT DEFAULT '' NOT NULL,
a_rr TEXT,
b_rr TEXT,
s_rr TEXT,
iflags INTEGER DEFAULT 0 NOT NULL,
a_uri VARCHAR(128) DEFAULT '' NOT NULL,
b_uri VARCHAR(128) DEFAULT '' NOT NULL,
@ -39,11 +39,11 @@ CREATE TABLE topos_t (
a_uuid VARCHAR(255) DEFAULT '' NOT NULL,
b_uuid VARCHAR(255) DEFAULT '' NOT NULL,
direction INTEGER DEFAULT 0 NOT NULL,
x_via TEXT DEFAULT '' NOT NULL,
x_via TEXT,
x_vbranch VARCHAR(255) DEFAULT '' NOT NULL,
x_rr TEXT DEFAULT '' NOT NULL,
y_rr TEXT DEFAULT '' NOT NULL,
s_rr TEXT DEFAULT '' NOT NULL,
x_rr TEXT,
y_rr TEXT,
s_rr TEXT,
x_uri VARCHAR(128) DEFAULT '' NOT NULL,
a_contact VARCHAR(128) DEFAULT '' NOT NULL,
b_contact VARCHAR(128) DEFAULT '' NOT NULL,

@ -3,7 +3,7 @@ CREATE TABLE uri (
username VARCHAR(64) DEFAULT '' NOT NULL,
domain VARCHAR(64) DEFAULT '' NOT NULL,
uri_user VARCHAR(64) DEFAULT '' NOT NULL,
last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '1900-01-01 00:00:01' NOT NULL,
last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '2000-01-01 00:00:01' NOT NULL,
CONSTRAINT uri_account_idx UNIQUE (username, domain, uri_user)
);

@ -10,7 +10,7 @@ CREATE TABLE location (
q REAL DEFAULT 1.0 NOT NULL,
callid VARCHAR(255) DEFAULT 'Default-Call-ID' NOT NULL,
cseq INTEGER DEFAULT 1 NOT NULL,
last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '1900-01-01 00:00:01' NOT NULL,
last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '2000-01-01 00:00:01' NOT NULL,
flags INTEGER DEFAULT 0 NOT NULL,
cflags INTEGER DEFAULT 0 NOT NULL,
user_agent VARCHAR(255) DEFAULT '' NOT NULL,
@ -39,7 +39,7 @@ CREATE TABLE location_attrs (
aname VARCHAR(64) DEFAULT '' NOT NULL,
atype INTEGER DEFAULT 0 NOT NULL,
avalue VARCHAR(255) DEFAULT '' NOT NULL,
last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '1900-01-01 00:00:01' NOT NULL
last_modified TIMESTAMP WITHOUT TIME ZONE DEFAULT '2000-01-01 00:00:01' NOT NULL
);
CREATE INDEX location_attrs_account_record_idx ON location_attrs (username, domain, ruid);

@ -1 +1 @@
id(int,auto) rectime(int) s_method(string) s_cseq(string) a_callid(string) a_uuid(string) b_uuid(string) a_contact(string) b_contact(string) as_contact(string) bs_contact(string) a_tag(string) b_tag(string) a_rr(string) b_rr(string) s_rr(string) iflags(int) a_uri(string) b_uri(string) r_uri(string) a_srcaddr(string) b_srcaddr(string) a_socket(string) b_socket(string)
id(int,auto) rectime(int) s_method(string) s_cseq(string) a_callid(string) a_uuid(string) b_uuid(string) a_contact(string) b_contact(string) as_contact(string) bs_contact(string) a_tag(string) b_tag(string) a_rr(string,null) b_rr(string,null) s_rr(string,null) iflags(int) a_uri(string) b_uri(string) r_uri(string) a_srcaddr(string) b_srcaddr(string) a_socket(string) b_socket(string)

@ -1 +1 @@
id(int,auto) rectime(int) s_method(string) s_cseq(string) a_callid(string) a_uuid(string) b_uuid(string) direction(int) x_via(string) x_vbranch(string) x_rr(string) y_rr(string) s_rr(string) x_uri(string) a_contact(string) b_contact(string) as_contact(string) bs_contact(string) x_tag(string) a_tag(string) b_tag(string) a_srcaddr(string) b_srcaddr(string) a_socket(string) b_socket(string)
id(int,auto) rectime(int) s_method(string) s_cseq(string) a_callid(string) a_uuid(string) b_uuid(string) direction(int) x_via(string,null) x_vbranch(string) x_rr(string,null) y_rr(string,null) s_rr(string,null) x_uri(string) a_contact(string) b_contact(string) as_contact(string) bs_contact(string) x_tag(string) a_tag(string) b_tag(string) a_srcaddr(string) b_srcaddr(string) a_socket(string) b_socket(string)

@ -6,7 +6,7 @@ CREATE TABLE `usr_preferences` (
`attribute` VARCHAR(32) DEFAULT '' NOT NULL,
`type` INT(11) DEFAULT 0 NOT NULL,
`value` VARCHAR(128) DEFAULT '' NOT NULL,
`last_modified` DATETIME DEFAULT '1900-01-01 00:00:01' NOT NULL
`last_modified` DATETIME DEFAULT '2000-01-01 00:00:01' NOT NULL
);
CREATE INDEX ua_idx ON usr_preferences (`uuid`, `attribute`);

@ -2,7 +2,7 @@ CREATE TABLE `domain` (
`id` INT(10) UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,
`domain` VARCHAR(64) NOT NULL,
`did` VARCHAR(64) DEFAULT NULL,
`last_modified` DATETIME DEFAULT '1900-01-01 00:00:01' NOT NULL,
`last_modified` DATETIME DEFAULT '2000-01-01 00:00:01' NOT NULL,
CONSTRAINT domain_idx UNIQUE (`domain`)
);
@ -14,7 +14,7 @@ CREATE TABLE `domain_attrs` (
`name` VARCHAR(32) NOT NULL,
`type` INT UNSIGNED NOT NULL,
`value` VARCHAR(255) NOT NULL,
`last_modified` DATETIME DEFAULT '1900-01-01 00:00:01' NOT NULL,
`last_modified` DATETIME DEFAULT '2000-01-01 00:00:01' NOT NULL,
CONSTRAINT domain_attrs_idx UNIQUE (`did`, `name`, `value`)
);

@ -3,7 +3,7 @@ CREATE TABLE `grp` (
`username` VARCHAR(64) DEFAULT '' NOT NULL,
`domain` VARCHAR(64) DEFAULT '' NOT NULL,
`grp` VARCHAR(64) DEFAULT '' NOT NULL,
`last_modified` DATETIME DEFAULT '1900-01-01 00:00:01' NOT NULL,
`last_modified` DATETIME DEFAULT '2000-01-01 00:00:01' NOT NULL,
CONSTRAINT account_group_idx UNIQUE (`username`, `domain`, `grp`)
);

@ -10,7 +10,7 @@ CREATE TABLE `aliases` (
`q` FLOAT(10,2) DEFAULT 1.0 NOT NULL,
`callid` VARCHAR(255) DEFAULT 'Default-Call-ID' NOT NULL,
`cseq` INT(11) DEFAULT 1 NOT NULL,
`last_modified` DATETIME DEFAULT '1900-01-01 00:00:01' NOT NULL,
`last_modified` DATETIME DEFAULT '2000-01-01 00:00:01' NOT NULL,
`flags` INT(11) DEFAULT 0 NOT NULL,
`cflags` INT(11) DEFAULT 0 NOT NULL,
`user_agent` VARCHAR(255) DEFAULT '' NOT NULL,

@ -1,6 +1,6 @@
CREATE TABLE `sip_trace` (
`id` INT(10) UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,
`time_stamp` DATETIME DEFAULT '1900-01-01 00:00:01' NOT NULL,
`time_stamp` DATETIME DEFAULT '2000-01-01 00:00:01' NOT NULL,
`time_us` INT UNSIGNED DEFAULT 0 NOT NULL,
`callid` VARCHAR(255) DEFAULT '' NOT NULL,
`traced_user` VARCHAR(128) DEFAULT '' NOT NULL,

@ -12,9 +12,9 @@ CREATE TABLE `topos_d` (
`bs_contact` VARCHAR(128) DEFAULT '' NOT NULL,
`a_tag` VARCHAR(255) DEFAULT '' NOT NULL,
`b_tag` VARCHAR(255) DEFAULT '' NOT NULL,
`a_rr` MEDIUMTEXT DEFAULT '' NOT NULL,
`b_rr` MEDIUMTEXT DEFAULT '' NOT NULL,
`s_rr` MEDIUMTEXT DEFAULT '' NOT NULL,
`a_rr` MEDIUMTEXT,
`b_rr` MEDIUMTEXT,
`s_rr` MEDIUMTEXT,
`iflags` INT(10) UNSIGNED DEFAULT 0 NOT NULL,
`a_uri` VARCHAR(128) DEFAULT '' NOT NULL,
`b_uri` VARCHAR(128) DEFAULT '' NOT NULL,
@ -39,11 +39,11 @@ CREATE TABLE `topos_t` (
`a_uuid` VARCHAR(255) DEFAULT '' NOT NULL,
`b_uuid` VARCHAR(255) DEFAULT '' NOT NULL,
`direction` INT DEFAULT 0 NOT NULL,
`x_via` MEDIUMTEXT DEFAULT '' NOT NULL,
`x_via` MEDIUMTEXT,
`x_vbranch` VARCHAR(255) DEFAULT '' NOT NULL,
`x_rr` MEDIUMTEXT DEFAULT '' NOT NULL,
`y_rr` MEDIUMTEXT DEFAULT '' NOT NULL,
`s_rr` MEDIUMTEXT DEFAULT '' NOT NULL,
`x_rr` MEDIUMTEXT,
`y_rr` MEDIUMTEXT,
`s_rr` MEDIUMTEXT,
`x_uri` VARCHAR(128) DEFAULT '' NOT NULL,
`a_contact` VARCHAR(128) DEFAULT '' NOT NULL,
`b_contact` VARCHAR(128) DEFAULT '' NOT NULL,

@ -3,7 +3,7 @@ CREATE TABLE `uri` (
`username` VARCHAR(64) DEFAULT '' NOT NULL,
`domain` VARCHAR(64) DEFAULT '' NOT NULL,
`uri_user` VARCHAR(64) DEFAULT '' NOT NULL,
`last_modified` DATETIME DEFAULT '1900-01-01 00:00:01' NOT NULL,
`last_modified` DATETIME DEFAULT '2000-01-01 00:00:01' NOT NULL,
CONSTRAINT account_idx UNIQUE (`username`, `domain`, `uri_user`)
);

@ -10,7 +10,7 @@ CREATE TABLE `location` (
`q` FLOAT(10,2) DEFAULT 1.0 NOT NULL,
`callid` VARCHAR(255) DEFAULT 'Default-Call-ID' NOT NULL,
`cseq` INT(11) DEFAULT 1 NOT NULL,
`last_modified` DATETIME DEFAULT '1900-01-01 00:00:01' NOT NULL,
`last_modified` DATETIME DEFAULT '2000-01-01 00:00:01' NOT NULL,
`flags` INT(11) DEFAULT 0 NOT NULL,
`cflags` INT(11) DEFAULT 0 NOT NULL,
`user_agent` VARCHAR(255) DEFAULT '' NOT NULL,
@ -39,7 +39,7 @@ CREATE TABLE `location_attrs` (
`aname` VARCHAR(64) DEFAULT '' NOT NULL,
`atype` INT(11) DEFAULT 0 NOT NULL,
`avalue` VARCHAR(255) DEFAULT '' NOT NULL,
`last_modified` DATETIME DEFAULT '1900-01-01 00:00:01' NOT NULL
`last_modified` DATETIME DEFAULT '2000-01-01 00:00:01' NOT NULL
);
CREATE INDEX account_record_idx ON location_attrs (`username`, `domain`, `ruid`);

@ -6,7 +6,7 @@ CREATE TABLE usr_preferences (
attribute VARCHAR2(32) DEFAULT '',
type NUMBER(10) DEFAULT 0 NOT NULL,
value VARCHAR2(128) DEFAULT '',
last_modified DATE DEFAULT to_date('1900-01-01 00:00:01','yyyy-mm-dd hh24:mi:ss')
last_modified DATE DEFAULT to_date('2000-01-01 00:00:01','yyyy-mm-dd hh24:mi:ss')
);
CREATE OR REPLACE TRIGGER usr_preferences_tr

@ -2,7 +2,7 @@ CREATE TABLE domain (
id NUMBER(10) PRIMARY KEY,
domain VARCHAR2(64),
did VARCHAR2(64) DEFAULT NULL,
last_modified DATE DEFAULT to_date('1900-01-01 00:00:01','yyyy-mm-dd hh24:mi:ss'),
last_modified DATE DEFAULT to_date('2000-01-01 00:00:01','yyyy-mm-dd hh24:mi:ss'),
CONSTRAINT domain_domain_idx UNIQUE (domain)
);
@ -22,7 +22,7 @@ CREATE TABLE domain_attrs (
name VARCHAR2(32),
type NUMBER(10),
value VARCHAR2(255),
last_modified DATE DEFAULT to_date('1900-01-01 00:00:01','yyyy-mm-dd hh24:mi:ss'),
last_modified DATE DEFAULT to_date('2000-01-01 00:00:01','yyyy-mm-dd hh24:mi:ss'),
CONSTRAINT domain_attrs_domain_attrs_idx UNIQUE (did, name, value)
);

@ -3,7 +3,7 @@ CREATE TABLE grp (
username VARCHAR2(64) DEFAULT '',
domain VARCHAR2(64) DEFAULT '',
grp VARCHAR2(64) DEFAULT '',
last_modified DATE DEFAULT to_date('1900-01-01 00:00:01','yyyy-mm-dd hh24:mi:ss'),
last_modified DATE DEFAULT to_date('2000-01-01 00:00:01','yyyy-mm-dd hh24:mi:ss'),
CONSTRAINT grp_account_group_idx UNIQUE (username, domain, grp)
);

@ -10,7 +10,7 @@ CREATE TABLE aliases (
q NUMBER(10,2) DEFAULT 1.0 NOT NULL,
callid VARCHAR2(255) DEFAULT 'Default-Call-ID',
cseq NUMBER(10) DEFAULT 1 NOT NULL,
last_modified DATE DEFAULT to_date('1900-01-01 00:00:01','yyyy-mm-dd hh24:mi:ss'),
last_modified DATE DEFAULT to_date('2000-01-01 00:00:01','yyyy-mm-dd hh24:mi:ss'),
flags NUMBER(10) DEFAULT 0 NOT NULL,
cflags NUMBER(10) DEFAULT 0 NOT NULL,
user_agent VARCHAR2(255) DEFAULT '',

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save