diff options
author | Nathan Angelacos <nangel@alpinelinux.org> | 2015-06-10 18:22:31 +0000 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2015-06-10 18:55:11 +0000 |
commit | 511cca363682351ea02856bece3378503e33b30c (patch) | |
tree | b09e0ab88a71c43f60f4c6a36e04f94613a8be65 /main/kamailio/0002-mohqueue-v0-11.patch | |
parent | 34077cda99974a8bf769d0a11e9e9fb2db1bf4ad (diff) | |
download | aports-511cca363682351ea02856bece3378503e33b30c.tar.bz2 aports-511cca363682351ea02856bece3378503e33b30c.tar.xz |
main/kamailio: upgrade to version 4.3.0
subpackages:
kamailio-db - mohqueue v0.11 from github
kamailio-extras - new modules dmq_usrloc statsd
rtjson tcpops auth_xkeys
(new) kamailio-geoip2 - geoip2
(new) kamailio-jansson - jansson janssonrpc-c
Diffstat (limited to 'main/kamailio/0002-mohqueue-v0-11.patch')
-rw-r--r-- | main/kamailio/0002-mohqueue-v0-11.patch | 828 |
1 files changed, 380 insertions, 448 deletions
diff --git a/main/kamailio/0002-mohqueue-v0-11.patch b/main/kamailio/0002-mohqueue-v0-11.patch index f6285a56b0..f47e9f682e 100644 --- a/main/kamailio/0002-mohqueue-v0-11.patch +++ b/main/kamailio/0002-mohqueue-v0-11.patch @@ -1,38 +1,44 @@ +diff --git a/modules/mohqueue/Makefile b/modules/mohqueue/Makefile +index 8351c02..f10bb40 100644 +--- a/modules/mohqueue/Makefile ++++ b/modules/mohqueue/Makefile +@@ -1,5 +1,6 @@ ++# $Id$ + # +-# mohqueue module makefile ++# msgqueue module makefile + # + # + # WARNING: do not run this directly, it should be run by the master Makefile +diff --git a/modules/mohqueue/NOTES b/modules/mohqueue/NOTES +index 0741d9f..ef2fbb6 100644 --- a/modules/mohqueue/NOTES +++ b/modules/mohqueue/NOTES @@ -1,6 +1,9 @@ --Things to look into: -- --* RFC3261, section 12.1.1 requires UAS to copy Record-Route --* Check to see if any memory leaks. --* Should probably respond when caller says BYE after queue says BYE. --* check RAck number -+Things to look into: -+ -+* RFC3261, section 12.1.1 requires UAS to copy Record-Route + Things to look into: + + * RFC3261, section 12.1.1 requires UAS to copy Record-Route + -+* Check to see if any memory leaks. + * Check to see if any memory leaks. + -+* Should probably respond when caller says BYE after queue says BYE. + * Should probably respond when caller says BYE after queue says BYE. +-* check RAck number + +* check RAck number \ No newline at end of file +diff --git a/modules/mohqueue/mohq.c b/modules/mohqueue/mohq.c +index 711f3fe..bc54aca 100644 --- a/modules/mohqueue/mohq.c +++ b/modules/mohqueue/mohq.c -@@ -1,10 +1,8 @@ +@@ -1,6 +1,5 @@ /* -- * $Id$ +- * +- * Copyright (C) 2013 Robert Boisvert + * Copyright (C) 2013-15 Robert Boisvert * -- * Copyright (C) 2013 Robert Boisvert -+ * This file is part of the mohqueue module for Kamailio, a free SIP server. + * This file is part of the mohqueue module for Kamailio, a free SIP server. * -- * This file is part of the mohqueue module for sip-router, a free SIP server. -- * - * The mohqueue module is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or -@@ -61,9 +59,9 @@ +@@ -60,9 +59,9 @@ static cmd_export_t mod_cmds [] = { }; /* PARAMETERS */ @@ -45,75 +51,93 @@ char *mohdir = ""; int moh_maxcalls = 50; -@@ -134,81 +132,84 @@ +@@ -133,83 +132,87 @@ return 0; static int init_cfg (void) { +- int error = 0; +- int bfnd = 0; +- struct stat psb [1]; +- +- /********** +- * db_url, db_ctable, db_qtable exist? +- **********/ +- +- if (!db_url.s || db_url.len<=0) +int bfnd = 0; +int berror = 0; +struct stat psb [1]; + - /********** - * db_url, db_ctable, db_qtable exist? - **********/ - -- if (!db_url.s || db_url.len<=0) ++/********** ++* db_url, db_ctable, db_qtable exist? ++**********/ ++ +if (!db_url.s || db_url.len <= 0) { -- LM_ERR ("db_url parameter not set!"); -- return 0; +- LM_ERR ("db_url parameter not set!\n"); +- error = 1; + LM_ERR ("db_url parameter not set!\n"); + berror = 1; } -- pmod_data->pcfg->db_url = db_url; - - if (!db_ctable.s || db_ctable.len<=0) +if (!db_ctable.s || db_ctable.len <= 0) { -- LM_ERR ("db_ctable parameter not set!"); -- return 0; +- LM_ERR ("db_ctable parameter not set!\n"); +- error = 1; + LM_ERR ("db_ctable parameter not set!\n"); + berror = 1; } -- pmod_data->pcfg->db_ctable = db_ctable; - - if (!db_qtable.s || db_qtable.len<=0) +if (!db_qtable.s || db_qtable.len <= 0) { -- LM_ERR ("db_qtable parameter not set!"); -- return 0; +- LM_ERR ("db_qtable parameter not set!\n"); +- error = 1; +- } +- +- /********** +- * mohdir +- * o exists? +- * o directory? +- **********/ +- +- if (!*mohdir) { +- LM_ERR ("mohdir parameter not set!\n"); +- error = 1; +- } else if (strlen(mohdir) > MOHDIRLEN) { +- LM_ERR ("mohdir too long!"); +- error = 1; + LM_ERR ("db_qtable parameter not set!\n"); + berror = 1; } -- pmod_data->pcfg->db_qtable = db_qtable; - -- - /********** - * mohdir - * o exists? - * o directory? - **********/ - -- if (!*mohdir) +- if (moh_maxcalls < 1 || moh_maxcalls > 5000) ++ ++/********** ++* mohdir ++* o exists? ++* o directory? ++**********/ ++ +if (!*mohdir) { -- LM_ERR ("mohdir parameter not set!"); -- return 0; +- LM_ERR ("moh_maxcalls not in range of 1-5000!"); +- error = 1; + LM_ERR ("mohdir parameter not set!\n"); + berror = 1; } -- if (strlen(mohdir) > MOHDIRLEN) +- if (error == 1) { +- return 0; +else if (strlen (mohdir) > MOHDIRLEN) - { -- LM_ERR ("mohdir too long!"); -- return 0; ++ { + LM_ERR ("mohdir too long!\n"); + berror = 1; } +- pmod_data->pcfg->db_qtable = db_qtable; +- pmod_data->pcfg->db_ctable = db_ctable; +- pmod_data->pcfg->db_url = db_url; - pmod_data->pcfg->mohdir = mohdir; - -- int bfnd = 0; -- struct stat psb [1]; - if (!lstat (mohdir, psb)) +else { @@ -125,48 +149,56 @@ + } if (!bfnd) - { -- LM_ERR ("mohdir is not a directory!"); -- return 0; + { -+ LM_ERR ("mohdir is not a directory!\n"); + LM_ERR ("mohdir is not a directory!\n"); +- return 0; + berror = 1; + } } - /********** --* max calls --* o valid count? +- /********** +- * max calls +- * o valid count? +- * o alloc memory +- **********/ ++/********** +* o max calls valid? - * o alloc memory ++* o alloc memory +* o save data - **********/ ++**********/ - if (moh_maxcalls < 1 || moh_maxcalls > 5000) - { -- LM_ERR ("moh_maxcalls not in range of 1-5000!"); -- return 0; +- pmod_data->pcall_lst = (call_lst *) shm_malloc (sizeof (call_lst) * moh_maxcalls); +- if (!pmod_data->pcall_lst) { +- LM_ERR ("Unable to allocate shared memory"); +- return -1; ++if (moh_maxcalls < 1 || moh_maxcalls > 5000) ++ { + LM_ERR ("moh_maxcalls not in range of 1-5000!\n"); + berror = 1; } +- memset (pmod_data->pcall_lst, 0, sizeof (call_lst) * moh_maxcalls); +- pmod_data->call_cnt = moh_maxcalls; +- return -1; +if (berror) + { return 0; } - pmod_data->pcall_lst = - (call_lst *) shm_malloc (sizeof (call_lst) * moh_maxcalls); - if (!pmod_data->pcall_lst) - { -- LM_ERR ("Unable to allocate shared memory"); -- return -1; ++pmod_data->pcall_lst = ++ (call_lst *) shm_malloc (sizeof (call_lst) * moh_maxcalls); ++if (!pmod_data->pcall_lst) ++ { + LM_ERR ("Unable to allocate shared memory!\n"); + return 0; - } ++ } +pmod_data->pcfg->db_url = db_url; +pmod_data->pcfg->db_ctable = db_ctable; +pmod_data->pcfg->db_qtable = db_qtable; +pmod_data->pcfg->mohdir = mohdir; - memset (pmod_data->pcall_lst, 0, sizeof (call_lst) * moh_maxcalls); - pmod_data->call_cnt = moh_maxcalls; - return -1; -@@ -234,13 +235,13 @@ ++memset (pmod_data->pcall_lst, 0, sizeof (call_lst) * moh_maxcalls); ++pmod_data->call_cnt = moh_maxcalls; ++return -1; + } + + /********** +@@ -232,13 +235,13 @@ static int init_db (void) str *pdb_url = &pmod_data->pcfg->db_url; if (db_bind_mod (pdb_url, pmod_data->pdb)) { @@ -182,7 +214,7 @@ return 0; } db1_con_t *pconn = mohq_dbconnect (); -@@ -256,14 +257,14 @@ +@@ -254,14 +257,14 @@ if (!pconn) if (db_check_table_version (pdb, pconn, &pmod_data->pcfg->db_ctable, MOHQ_CTABLE_VERSION) < 0) { @@ -199,7 +231,7 @@ pmod_data->pcfg->db_qtable.s, pdb_url->s, MOHQ_QTABLE_VERSION); goto dberr; } -@@ -303,7 +304,7 @@ +@@ -301,7 +304,7 @@ if (rank == PROC_INIT || rank == PROC_TCP_MAIN || rank == PROC_MAIN) { return 0; } if (!pmod_data->pdb->init) { @@ -208,7 +240,7 @@ return -1; } return 0; -@@ -357,7 +358,7 @@ +@@ -355,7 +358,7 @@ int mod_init (void) pmod_data = (mod_data *) shm_malloc (sizeof (mod_data)); if (!pmod_data) { @@ -217,54 +249,54 @@ return -1; } memset (pmod_data, 0, sizeof (mod_data)); -@@ -373,47 +374,59 @@ +@@ -371,47 +374,59 @@ if (!init_db ()) if (sl_load_api (pmod_data->psl)) { -- LM_ERR ("Unable to load SL module"); +- LM_ERR ("Unable to load SL module\n"); + LM_ERR ("Unable to load SL module!\n"); goto initerr; } if (load_tm_api (pmod_data->ptm)) { -- LM_ERR ("Unable to load TM module"); +- LM_ERR ("Unable to load TM module\n"); + LM_ERR ("Unable to load TM module!\n"); goto initerr; } if (load_rr_api (pmod_data->prr)) { -- LM_ERR ("Unable to load RR module"); +- LM_ERR ("Unable to load RR module\n"); + LM_ERR ("Unable to load RR module!\n"); goto initerr; } pmod_data->fn_rtp_answer = find_export ("rtpproxy_answer", 0, 0); if (!pmod_data->fn_rtp_answer) { -- LM_ERR ("Unable to load rtpproxy_answer"); +- LM_ERR ("Unable to load rtpproxy_answer\n"); + LM_ERR ("Unable to load rtpproxy_answer!\n"); goto initerr; } pmod_data->fn_rtp_offer = find_export ("rtpproxy_offer", 0, 0); if (!pmod_data->fn_rtp_offer) { -- LM_ERR ("Unable to load rtpproxy_offer"); +- LM_ERR ("Unable to load rtpproxy_offer\n"); + LM_ERR ("Unable to load rtpproxy_offer!\n"); goto initerr; } pmod_data->fn_rtp_stream_c = find_export ("rtpproxy_stream2uac", 2, 0); if (!pmod_data->fn_rtp_stream_c) { -- LM_ERR ("Unable to load rtpproxy_stream2uac"); +- LM_ERR ("Unable to load rtpproxy_stream2uac\n"); + LM_ERR ("Unable to load rtpproxy_stream2uac!\n"); goto initerr; } pmod_data->fn_rtp_stream_s = find_export ("rtpproxy_stream2uas", 2, 0); if (!pmod_data->fn_rtp_stream_s) { -- LM_ERR ("Unable to load rtpproxy_stream2uas"); +- LM_ERR ("Unable to load rtpproxy_stream2uas\n"); + LM_ERR ("Unable to load rtpproxy_stream2uas!\n"); - goto initerr; - } ++ goto initerr; ++ } +pmod_data->fn_rtp_stop_c = find_export ("rtpproxy_stop_stream2uac", 0, 0); +if (!pmod_data->fn_rtp_stop_c) + { @@ -275,39 +307,35 @@ +if (!pmod_data->fn_rtp_stop_s) + { + LM_ERR ("Unable to load rtpproxy_stop_stream2uas!\n"); -+ goto initerr; -+ } + goto initerr; + } pmod_data->fn_rtp_destroy = find_export ("rtpproxy_destroy", 0, 0); if (!pmod_data->fn_rtp_destroy) { -- LM_ERR ("Unable to load rtpproxy_destroy"); +- LM_ERR ("Unable to load rtpproxy_destroy\n"); + LM_ERR ("Unable to load rtpproxy_destroy!\n"); goto initerr; } -@@ -440,4 +453,4 @@ +@@ -438,4 +453,4 @@ if (pmod_data->pcall_lock->plock) shm_free (pmod_data); pmod_data = NULL; return -1; -} +} \ No newline at end of file +diff --git a/modules/mohqueue/mohq.h b/modules/mohqueue/mohq.h +index b23e6a3..3d5346b 100644 --- a/modules/mohqueue/mohq.h +++ b/modules/mohqueue/mohq.h -@@ -1,10 +1,8 @@ +@@ -1,5 +1,5 @@ /* -- * $Id$ +- * Copyright (C) 2013 Robert Boisvert + * Copyright (C) 2013-15 Robert Boisvert * -- * Copyright (C) 2013 Robert Boisvert -+ * This file is part of the mohqueue module for Kamailio, a free SIP server. + * This file is part of the mohqueue module for Kamailio, a free SIP server. * -- * This file is part of the mohqueue module for sip-router, a free SIP server. -- * - * The mohqueue module is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or -@@ -63,31 +61,35 @@ +@@ -61,31 +61,35 @@ typedef struct /* call_state values */ #define CLSTA_ENTER 100 @@ -352,7 +380,7 @@ unsigned int call_hash; unsigned int call_label; sip_msg_t *call_pmsg; -@@ -120,6 +122,8 @@ +@@ -118,6 +122,8 @@ typedef struct cmd_function fn_rtp_offer; cmd_function fn_rtp_stream_c; cmd_function fn_rtp_stream_s; @@ -361,22 +389,26 @@ } mod_data; /********** +@@ -127,4 +133,4 @@ typedef struct + extern mod_data *pmod_data; + extern rtpmap prtpmap []; + +-#endif /* MOHQ_H */ ++#endif /* MOHQ_H */ +\ No newline at end of file +diff --git a/modules/mohqueue/mohq_common.h b/modules/mohqueue/mohq_common.h +index 9103323..10f6249 100644 --- a/modules/mohqueue/mohq_common.h +++ b/modules/mohqueue/mohq_common.h -@@ -1,10 +1,8 @@ +@@ -1,6 +1,5 @@ /* -- * $Id$ +- * +- * Copyright (C) 2013 Robert Boisvert + * Copyright (C) 2013-15 Robert Boisvert * -- * Copyright (C) 2013 Robert Boisvert -+ * This file is part of the mohqueue module for Kamailio, a free SIP server. + * This file is part of the mohqueue module for Kamailio, a free SIP server. * -- * This file is part of the mohqueue module for sip-router, a free SIP server. -- * - * The mohqueue module is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or -@@ -53,6 +51,7 @@ +@@ -52,6 +51,7 @@ #include "../../parser/contact/parse_contact.h" #include "../../parser/parse_expires.h" #include "../../parser/parse_from.h" @@ -384,7 +416,7 @@ #include "../../parser/sdp/sdp.h" /* convenience macros */ -@@ -69,7 +68,7 @@ +@@ -68,7 +68,7 @@ #define MOHQ_STR_APPEND_L( str1, str1_lim, s2, s2_len ) \ if ((str1)->len + (s2_len) >= (str1_lim)) { \ @@ -393,7 +425,7 @@ } else { \ MOHQ_STR_APPEND((str1), (s2), (s2_len)); \ (str1_lim) -= (s2_len); \ -@@ -84,7 +83,7 @@ +@@ -83,7 +83,7 @@ #define MOHQ_STR_APPEND_CSTR_L( str1, str1_lim, cstr1 ) \ if ((str1)->len + strlen(cstr1) >= (str1_lim)) { \ @@ -402,22 +434,25 @@ } else { \ MOHQ_STR_APPEND_CSTR((str1), (cstr1)); \ } +@@ -100,4 +100,4 @@ + #define MOHQ_HEADER_EMPTY( hdr1 ) \ + ((hdr1) == NULL || MOHQ_STR_EMPTY( &(hdr1)->body )) + +-#endif /* MOHQ_COMMON_H */ ++#endif /* MOHQ_COMMON_H */ +\ No newline at end of file +diff --git a/modules/mohqueue/mohq_db.c b/modules/mohqueue/mohq_db.c +index 64ac90e..56e420f 100644 --- a/modules/mohqueue/mohq_db.c +++ b/modules/mohqueue/mohq_db.c -@@ -1,10 +1,8 @@ +@@ -1,5 +1,5 @@ /* -- * $Id$ +- * Copyright (C) 2013 Robert Boisvert + * Copyright (C) 2013-15 Robert Boisvert * -- * Copyright (C) 2013 Robert Boisvert -+ * This file is part of the mohqueue module for Kamailio, a free SIP server. + * This file is part of the mohqueue module for Kamailio, a free SIP server. * -- * This file is part of the mohqueue module for sip-router, a free SIP server. -- * - * The mohqueue module is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or -@@ -216,7 +214,7 @@ +@@ -214,7 +214,7 @@ pcall->call_time = time (0); fill_call_vals (prvals, pcall, CALL_COLCNT); if (pdb->insert (pconn, prkeys, prvals, CALL_COLCNT) < 0) { @@ -426,7 +461,7 @@ pmod_data->pcfg->db_ctable.s); } mohq_dbdisconnect (pconn); -@@ -243,7 +241,7 @@ +@@ -241,7 +241,7 @@ db_func_t *pdb = pmod_data->pdb; pdb->use_table (pconn, &pmod_data->pcfg->db_ctable); if (pdb->delete (pconn, 0, 0, 0, 0) < 0) { @@ -435,7 +470,7 @@ pmod_data->pcfg->db_ctable.s); } return; -@@ -277,7 +275,7 @@ +@@ -275,7 +275,7 @@ db_val_t prvals [1]; set_call_val (prvals, 0, CALLCOL_CALL, pcall->call_id); if (pdb->delete (pconn, prkeys, 0, prvals, 1) < 0) { @@ -444,16 +479,16 @@ pmod_data->pcfg->db_ctable.s); } mohq_dbdisconnect (pconn); -@@ -297,7 +295,7 @@ +@@ -295,7 +295,7 @@ db1_con_t *mohq_dbconnect (void) str *pdb_url = &pmod_data->pcfg->db_url; db1_con_t *pconn = pmod_data->pdb->init (pdb_url); if (!pconn) -- { LM_ERR ("Unable to connect to DB %s", pdb_url->s); } +- { LM_ERR ("Unable to connect to DB %s\n", pdb_url->s); } + { LM_ERR ("Unable to connect to DB %s!\n", pdb_url->s); } return pconn; } -@@ -348,7 +346,7 @@ +@@ -346,7 +346,7 @@ db_val_t puvals [1]; fill_call_vals (puvals, pcall, CALLCOL_STATE); if (pdb->update (pconn, pqkeys, 0, pqvals, pukeys, puvals, 1, 1) < 0) { @@ -462,7 +497,7 @@ pmod_data->pcfg->db_ctable.s); } mohq_dbdisconnect (pconn); -@@ -390,7 +388,7 @@ +@@ -388,7 +388,7 @@ puvals->type = DB1_INT; puvals->nul = 0; if (pdb->update (pconn, pqkeys, 0, pqvals, pukeys, puvals, 1, 1) < 0) { @@ -471,52 +506,7 @@ pmod_data->pcfg->db_qtable.s); } mohq_dbdisconnect (pconn); -@@ -428,7 +426,7 @@ - db1_res_t *presult = NULL; - if (pdb->query (pconn, 0, 0, 0, prkeys, 0, MOHQ_COLCNT, 0, &presult)) - { -- LM_ERR ("%stable query (%s) failed!", pfncname, -+ LM_ERR ("%stable query (%s) failed!\n", pfncname, - pmod_data->pcfg->db_qtable.s); - return; - } -@@ -449,7 +447,7 @@ - struct sip_uri puri_parsed [1]; - if (parse_uri (puri, strlen (puri), puri_parsed)) - { -- LM_ERR ("Queue,Field (%s,%.*s): %s is not a valid URI!", pqname, -+ LM_ERR ("Queue,Field (%s,%.*s): %s is not a valid URI!\n", pqname, - STR_FMT (&MOHQCSTR_URI), puri); - continue; - } -@@ -477,7 +475,7 @@ - struct stat psb [1]; - if (lstat (pmohdir, psb)) - { -- LM_ERR ("Queue,Field (%s,%.*s): Unable to find %s!", pqname, -+ LM_ERR ("Queue,Field (%s,%.*s): Unable to find %s!\n", pqname, - STR_FMT (&MOHQCSTR_MDIR), pmohdir); - continue; - } -@@ -485,7 +483,7 @@ - { - if ((psb->st_mode & S_IFMT) != S_IFDIR) - { -- LM_ERR ("Queue,Field (%s,%.*s): %s is not a directory!", pqname, -+ LM_ERR ("Queue,Field (%s,%.*s): %s is not a directory!\n", pqname, - STR_FMT (&MOHQCSTR_MDIR), pmohdir); - continue; - } -@@ -501,7 +499,7 @@ - (char *)VAL_STRING (prowvals + MOHQCOL_MFILE)); - if (!pmohfiles [0]) - { -- LM_ERR ("Queue,Field (%s,%.*s): Unable to find MOH files (%s/%s.*)!", -+ LM_ERR ("Queue,Field (%s,%.*s): Unable to find MOH files (%s/%s.*)!\n", - pqname, STR_FMT (&MOHQCSTR_MDIR), pmohdir, - (char *)VAL_STRING (prowvals + MOHQCOL_MFILE)); - continue; -@@ -525,21 +523,21 @@ +@@ -523,21 +523,21 @@ for (nidx = 0; nidx < nrows; nidx++) if (strcmp (pqlst [nidx2].mohq_mohdir, pmohdir)) { strcpy (pqlst [nidx2].mohq_mohdir, pmohdir); @@ -541,7 +531,7 @@ STR_FMT (&MOHQCSTR_NAME)); } int bdebug = VAL_INT (prowvals + MOHQCOL_DEBUG) ? MOHQF_DBG : 0; -@@ -549,7 +547,7 @@ +@@ -547,7 +547,7 @@ for (nidx = 0; nidx < nrows; nidx++) { pqlst [nidx2].mohq_flags |= MOHQF_DBG; } else { pqlst [nidx2].mohq_flags &= ~MOHQF_DBG; } @@ -550,16 +540,7 @@ STR_FMT (&MOHQCSTR_DEBUG)); } bfnd = -1; -@@ -576,7 +574,7 @@ - pnewlst = (mohq_lst *) shm_malloc (sizeof (mohq_lst) * nsize); - if (!pnewlst) - { -- LM_ERR ("%sUnable to allocate shared memory!", pfncname); -+ LM_ERR ("%sUnable to allocate shared memory!\n", pfncname); - return; - } - pmod_data->mohq_cnt = nsize; -@@ -592,7 +590,7 @@ +@@ -590,7 +590,7 @@ for (nidx = 0; nidx < nrows; nidx++) (char *)VAL_STRING (prowvals + MOHQCOL_NAME)); if (VAL_INT (prowvals + MOHQCOL_DEBUG)) { pnewlst [nsize].mohq_flags |= MOHQF_DBG; } @@ -568,7 +549,7 @@ if (nsize) { shm_free (pmod_data->pmohq_lst); } pmod_data->pmohq_lst = pnewlst; -@@ -613,7 +611,7 @@ +@@ -611,7 +611,7 @@ for (nidx = 0; nidx < pmod_data->mohq_cnt; nidx++) if (pqlst [nidx].mohq_flags & MOHQF_CHK) { continue; } @@ -577,36 +558,43 @@ if (nidx != (pmod_data->mohq_cnt - 1)) { memcpy (&pqlst [nidx], &pqlst [pmod_data->mohq_cnt - 1], +@@ -621,4 +621,4 @@ for (nidx = 0; nidx < pmod_data->mohq_cnt; nidx++) + --nidx; + } + return; +-} ++} +\ No newline at end of file +diff --git a/modules/mohqueue/mohq_db.h b/modules/mohqueue/mohq_db.h +index 611d455..c343601 100644 --- a/modules/mohqueue/mohq_db.h +++ b/modules/mohqueue/mohq_db.h -@@ -1,9 +1,7 @@ +@@ -1,5 +1,5 @@ /* -- * $Id$ +- * Copyright (C) 2013 Robert Boisvert + * Copyright (C) 2013-15 Robert Boisvert * -- * Copyright (C) 2013 Robert Boisvert -- * -- * This file is part of the mohqueue module for sip-router, a free SIP server. -+ * This file is part of the mohqueue module for Kamailio, a free SIP server. + * This file is part of the mohqueue module for Kamailio, a free SIP server. * - * The mohqueue module is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by +@@ -61,4 +61,4 @@ void update_call_rec (call_lst *); + void update_debug (mohq_lst *, int); + void update_mohq_lst (db1_con_t *pconn); + +-#endif /* MOHQ_DB_H */ ++#endif /* MOHQ_DB_H */ +\ No newline at end of file +diff --git a/modules/mohqueue/mohq_funcs.c b/modules/mohqueue/mohq_funcs.c +index 1d023e6..210f14e 100644 --- a/modules/mohqueue/mohq_funcs.c +++ b/modules/mohqueue/mohq_funcs.c -@@ -1,10 +1,8 @@ +@@ -1,5 +1,5 @@ /* -- * $Id$ +- * Copyright (C) 2013 Robert Boisvert + * Copyright (C) 2013-15 Robert Boisvert * -- * Copyright (C) 2013 Robert Boisvert -+ * This file is part of the mohqueue module for Kamailio, a free SIP server. + * This file is part of the mohqueue module for Kamailio, a free SIP server. * -- * This file is part of the mohqueue module for sip-router, a free SIP server. -- * - * The mohqueue module is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or -@@ -34,7 +32,7 @@ +@@ -32,7 +32,7 @@ #define ALLOWHDR "Allow: INVITE, ACK, BYE, CANCEL, NOTIFY, PRACK" #define CLENHDR "Content-Length" #define SIPEOL "\r\n" @@ -615,7 +603,7 @@ /********** * local constants -@@ -48,6 +46,7 @@ +@@ -46,6 +46,7 @@ str pinvite [1] = {STR_STATIC_INIT ("INVITE")}; str pmi_nolock [1] = {STR_STATIC_INIT ("Unable to lock queue")}; str pmi_noqueue [1] = {STR_STATIC_INIT ("No matching queue name found")}; str prefer [1] = {STR_STATIC_INIT ("REFER")}; @@ -623,7 +611,7 @@ str presp_noaccept [1] = {STR_STATIC_INIT ("Not Acceptable Here")}; str presp_noallow [1] = {STR_STATIC_INIT ("Method Not Allowed")}; str presp_nocall [1] = {STR_STATIC_INIT ("Call/Transaction Does Not Exist")}; -@@ -57,6 +56,7 @@ +@@ -55,6 +56,7 @@ str presp_reqterm [1] = {STR_STATIC_INIT ("Request Terminated")}; str presp_ring [1] = {STR_STATIC_INIT ("Ringing")}; str psipfrag [1] = {STR_STATIC_INIT ("message/sipfrag")}; str presp_srverr [1] = {STR_STATIC_INIT ("Server Internal Error")}; @@ -631,7 +619,7 @@ str presp_unsupp [1] = {STR_STATIC_INIT ("Unsupported Media Type")}; rtpmap prtpmap [] = -@@ -88,9 +88,9 @@ +@@ -86,9 +88,9 @@ str pallowhdr [1] = { STR_STATIC_INIT (ALLOWHDR SIPEOL) }; char pbyemsg [] = { "%s" @@ -642,7 +630,7 @@ }; str pextrahdr [1] = -@@ -100,7 +100,6 @@ +@@ -98,7 +100,6 @@ str pextrahdr [1] = "Supported: 100rel" SIPEOL "Accept-Language: en" SIPEOL "Content-Type: application/sdp" SIPEOL @@ -650,7 +638,7 @@ ) }; -@@ -118,10 +117,11 @@ +@@ -116,10 +117,11 @@ char pinvitesdp [] = char prefermsg [] = { "%s" @@ -664,7 +652,7 @@ }; char preinvitemsg [] = -@@ -131,7 +131,6 @@ +@@ -129,7 +131,6 @@ char preinvitemsg [] = "Contact: <%s>" SIPEOL ALLOWHDR SIPEOL "Supported: 100rel" SIPEOL @@ -672,7 +660,7 @@ "Accept-Language: en" SIPEOL "Content-Type: application/sdp" SIPEOL }; -@@ -153,8 +152,7 @@ +@@ -151,8 +152,7 @@ char prtpsdp [] = **********/ void delete_call (call_lst *); @@ -682,7 +670,7 @@ dlg_t *form_dialog (call_lst *, struct to_body *); int form_rtp_SDP (str *, call_lst *, char *); static void invite_cb (struct cell *, int, struct tmcb_params *); -@@ -164,6 +162,7 @@ +@@ -162,6 +162,7 @@ int send_prov_rsp (sip_msg_t *, call_lst *); int send_rtp_answer (sip_msg_t *, call_lst *); int search_hdr_ext (struct hdr_field *, str *); int start_stream (sip_msg_t *, call_lst *, int); @@ -690,7 +678,7 @@ /********** * local functions -@@ -175,10 +174,10 @@ +@@ -173,10 +174,10 @@ int start_stream (sip_msg_t *, call_lst *, int); * INPUT: * Arg (1) = SIP message pointer * Arg (2) = call pointer @@ -703,16 +691,8 @@ { /********** -@@ -195,13 +194,13 @@ - **********/ - - if (pcall->call_state != CLSTA_INQUEUE) -- { LM_ERR ("%sUnexpected ACK (%s)!", pfncname, pcall->call_from); } -+ { LM_ERR ("%sUnexpected ACK (%s)!\n", pfncname, pcall->call_from); } - else - { -- mohq_debug (pcall->pmohq, "%sACK from refused re-INVITE (%s)!", -+ mohq_debug (pcall->pmohq, "%sACK from refused re-INVITE (%s)!\n", +@@ -199,7 +200,7 @@ if (pcall->call_state != CLSTA_INVITED) + mohq_debug (pcall->pmohq, "%sACK from refused re-INVITE (%s)!\n", pfncname, pcall->call_from); } - return 1; @@ -720,29 +700,25 @@ } /********** -@@ -212,17 +211,17 @@ - - if (ptm->t_lookup_ident (&ptrans, pcall->call_hash, pcall->call_label) < 0) +@@ -212,7 +213,7 @@ if (ptm->t_lookup_ident (&ptrans, pcall->call_hash, pcall->call_label) < 0) { -- LM_ERR ("%sINVITE transaction missing for call (%s)!", -+ LM_ERR ("%sINVITE transaction missing for call (%s)!\n", + LM_ERR ("%sINVITE transaction missing for call (%s)!\n", pfncname, pcall->call_from); - return 1; + return; } else { - if (ptm->t_release (pcall->call_pmsg) < 0) +@@ -220,7 +221,7 @@ else { -- LM_ERR ("%sRelease transaction failed for call (%s)!", -+ LM_ERR ("%sRelease transaction failed for call (%s)!\n", + LM_ERR ("%sRelease transaction failed for call (%s)!\n", pfncname, pcall->call_from); - return 1; + return; } } pcall->call_hash = pcall->call_label = 0; -@@ -235,6 +234,47 @@ +@@ -233,6 +234,47 @@ pcall->call_cseq = 1; mohq_debug (pcall->pmohq, "%sACK received for call (%s); placed in queue (%s)", pfncname, pcall->call_from, pcall->pmohq->mohq_name); @@ -790,25 +766,25 @@ return 1; } -@@ -261,7 +301,7 @@ +@@ -259,7 +301,7 @@ char *pfncname = "bye_cb: "; call_lst *pcall = (call_lst *)*pcbp->param; if (ntype == TMCB_ON_FAILURE) { -- LM_ERR ("%sCall (%s) did not respond to BYE", pfncname, +- LM_ERR ("%sCall (%s) did not respond to BYE\n", pfncname, + LM_ERR ("%sCall (%s) did not respond to BYE!\n", pfncname, pcall->call_from); } else -@@ -269,7 +309,7 @@ +@@ -267,7 +309,7 @@ else int nreply = pcbp->code; if ((nreply / 100) != 2) { -- LM_ERR ("%sCall (%s) BYE error (%d)", pfncname, +- LM_ERR ("%sCall (%s) BYE error (%d)\n", pfncname, + LM_ERR ("%sCall (%s) BYE error (%d)!\n", pfncname, pcall->call_from, nreply); } else -@@ -288,33 +328,43 @@ +@@ -286,33 +328,43 @@ return; * INPUT: * Arg (1) = SIP message pointer * Arg (2) = call pointer @@ -833,7 +809,7 @@ + { return; } +if (pcall->call_state >= CLSTA_INQUEUE) { -- LM_ERR ("%sUnable to create reply to call (%s)", pfncname, +- LM_ERR ("%sUnable to create reply to call (%s)\n", pfncname, - pcall->call_from); - return 1; + pcall->call_state = CLSTA_BYEOK; @@ -843,8 +819,7 @@ - { drop_call (pmsg, pcall); } else { -- LM_ERR ("%sEnding call (%s) before placed in queue!", -+ LM_ERR ("%sEnding call (%s) before placed in queue!\n", + LM_ERR ("%sEnding call (%s) before placed in queue!\n", pfncname, pcall->call_from); - delete_call (pcall); } @@ -865,7 +840,7 @@ } /********** -@@ -323,14 +373,15 @@ +@@ -321,14 +373,15 @@ return 1; * INPUT: * Arg (1) = SIP message pointer * Arg (2) = call pointer @@ -884,28 +859,16 @@ **********/ char *pfncname = "cancel_msg: "; -@@ -340,16 +391,16 @@ - mohq_debug (pcall->pmohq, "%sCANCELed call (%s)", - pfncname, pcall->call_from); - if (pmod_data->psl->freply (pmsg, 487, presp_reqterm) < 0) -- { LM_ERR ("%sUnable to create reply!", pfncname); } -+ { LM_ERR ("%sUnable to create reply!\n", pfncname); } - } - else - { -- LM_ERR ("%sUnable to CANCEL because accepted INVITE for call (%s)!", -+ LM_ERR ("%sUnable to CANCEL because accepted INVITE for call (%s)!\n", - pfncname, pcall->call_from); +@@ -347,7 +400,7 @@ else if (pmod_data->psl->freply (pmsg, 481, presp_nocall) < 0) -- { LM_ERR ("%sUnable to create reply!", pfncname); } -+ { LM_ERR ("%sUnable to create reply!\n", pfncname); } + { LM_ERR ("%sUnable to create reply!\n", pfncname); } } -return 1; +return; } /********** -@@ -365,23 +416,14 @@ +@@ -363,23 +416,14 @@ void close_call (sip_msg_t *pmsg, call_lst *pcall) { /********** @@ -923,7 +886,7 @@ - pfncname, pcall->call_from); - if (pmod_data->fn_rtp_destroy (pmsg, 0, 0) != 1) - { -- LM_ERR ("%srtpproxy_destroy refused for call (%s)!", +- LM_ERR ("%srtpproxy_destroy refused for call (%s)!\n", - pfncname, pcall->call_from); - } - } @@ -931,7 +894,7 @@ struct to_body ptob [2]; dlg_t *pdlg = form_dialog (pcall, ptob); if (!pdlg) -@@ -398,15 +440,17 @@ +@@ -396,6 +440,7 @@ tm_api_t *ptm = pmod_data->ptm; char *pquri = pcall->pmohq->mohq_uri; int npos1 = sizeof (pbyemsg) // BYE template + strlen (pcall->call_via) // Via @@ -939,10 +902,7 @@ + strlen (pquri); // Contact phdr = pkg_malloc (npos1); if (!phdr) - { -- LM_ERR ("%sNo more memory!", pfncname); -+ LM_ERR ("%sNo more memory!\n", pfncname); - goto bye_err; +@@ -405,6 +450,7 @@ if (!phdr) } sprintf (phdr, pbyemsg, pcall->call_via, // Via @@ -950,16 +910,16 @@ pquri); // Contact str phdrs [1]; phdrs->s = phdr; -@@ -422,7 +466,7 @@ - pcall->call_state = CLSTA_BYE; - if (ptm->t_request_within (puac) < 0) - { -- LM_ERR ("%sUnable to create BYE request for call (%s)!", -+ LM_ERR ("%sUnable to create BYE request for call (%s)!\n", +@@ -424,7 +470,7 @@ if (ptm->t_request_within (puac) < 0) pfncname, pcall->call_from); goto bye_err; } -@@ -449,138 +493,127 @@ +-mohq_debug (pcall->pmohq, "%sSent BYE request for call (%s)\n", ++mohq_debug (pcall->pmohq, "%sSent BYE request for call (%s)", + pfncname, pcall->call_from); + bsent = 1; + +@@ -447,138 +493,127 @@ return; * Create New Call Record * * INPUT: @@ -987,7 +947,7 @@ -char *pfncname = "create_call: "; -if (!mohq_lock_set (pmod_data->pcall_lock, 1, 2000)) - { -- LM_ERR ("%sUnable to lock calls!", pfncname); +- LM_ERR ("%sUnable to lock calls!\n", pfncname); - return -1; - } -call_lst *pcall; @@ -995,7 +955,7 @@ -if (pcall) - { - mohq_lock_release (pmod_data->pcall_lock); -- LM_ERR ("%sCall already in use (%s)!", pfncname, pcall->call_from); +- LM_ERR ("%sCall already in use (%s)!\n", pfncname, pcall->call_from); - return -1; - } -for (ncall_idx = 0; ncall_idx < pmod_data->call_cnt; ncall_idx++) @@ -1006,7 +966,7 @@ -if (ncall_idx == pmod_data->call_cnt) - { - mohq_lock_release (pmod_data->pcall_lock); -- LM_ERR ("%sNo call slots available!", pfncname); +- LM_ERR ("%sNo call slots available!\n", pfncname); - return -1; - } - @@ -1129,8 +1089,8 @@ -* o update DB -* o lock MOH queue +* extract Route headers - **********/ - ++**********/ ++ +pcall->call_route = pbuf; +struct hdr_field *proute; +for (proute = pmsg->record_route; proute; proute = next_sibling_hdr (proute)) @@ -1154,8 +1114,8 @@ + +/********** +* update DB -+**********/ -+ + **********/ + pcall->call_state = CLSTA_ENTER; -mohq_lock_release (pmod_data->pcall_lock); add_call_rec (ncall_idx); @@ -1167,11 +1127,11 @@ } /********** -@@ -605,15 +638,15 @@ +@@ -603,15 +638,15 @@ if (pcall->call_hash || pcall->call_label) { if (ptm->t_lookup_ident (&ptrans, pcall->call_hash, pcall->call_label) < 0) { -- LM_ERR ("%sLookup transaction failed for call (%s)!", pfncname, +- LM_ERR ("%sLookup transaction failed for call (%s)!\n", pfncname, - pcall->call_from); + LM_ERR ("%sLookup transaction failed for call (%s) from queue (%s)!\n", + pfncname, pcall->call_from, pcall->pmohq->mohq_name); @@ -1180,14 +1140,14 @@ { if (ptm->t_release (pcall->call_pmsg) < 0) { -- LM_ERR ("%sRelease transaction failed for call (%s)!", +- LM_ERR ("%sRelease transaction failed for call (%s)!\n", - pfncname, pcall->call_from); + LM_ERR ("%sRelease transaction failed for call (%s) from queue (%s)!\n", + pfncname, pcall->call_from, pcall->pmohq->mohq_name); } } pcall->call_hash = pcall->call_label = 0; -@@ -622,14 +655,21 @@ +@@ -620,14 +655,21 @@ if (pcall->call_hash || pcall->call_label) /********** * o update DB * o inactivate slot @@ -1215,33 +1175,16 @@ return; } -@@ -655,28 +695,28 @@ - tm_api_t *ptm = pmod_data->ptm; - if (ptm->t_newtran (pmsg) < 0) - { -- LM_ERR ("%sUnable to create new transaction!", pfncname); -+ LM_ERR ("%sUnable to create new transaction!\n", pfncname); - if (pmod_data->psl->freply (pmsg, 500, presp_srverr) < 0) - { -- LM_ERR ("%sUnable to create reply to %.*s!", pfncname, -+ LM_ERR ("%sUnable to create reply to %.*s!\n", pfncname, - STR_FMT (&REQ_LINE (pmsg).method)); - } - return; +@@ -663,7 +705,7 @@ if (ptm->t_newtran (pmsg) < 0) } if (!add_lump_rpl2 (pmsg, pallowhdr->s, pallowhdr->len, LUMP_RPL_HDR)) -- { LM_ERR ("%sUnable to add Allow header!", pfncname); } + { LM_ERR ("%sUnable to add Allow header!\n", pfncname); } -LM_ERR ("%sRefused %.*s for call (%s)!", pfncname, -+ { LM_ERR ("%sUnable to add Allow header!\n", pfncname); } +LM_ERR ("%sRefused %.*s for call (%s)!\n", pfncname, STR_FMT (&REQ_LINE (pmsg).method), pcall->call_from); if (ptm->t_reply (pmsg, 405, presp_noallow->s) < 0) { -- LM_ERR ("%sUnable to create reply to %.*s!", pfncname, -+ LM_ERR ("%sUnable to create reply to %.*s!\n", pfncname, - STR_FMT (&REQ_LINE (pmsg).method)); - } - return; +@@ -674,7 +716,7 @@ return; } /********** @@ -1250,7 +1193,7 @@ * * INPUT: * Arg (1) = SIP message pointer -@@ -684,26 +724,24 @@ +@@ -682,16 +724,15 @@ return; * OUTPUT: none **********/ @@ -1271,10 +1214,7 @@ { mohq_debug (pcall->pmohq, "%sDestroying RTP link for call (%s)", pfncname, pcall->call_from); - if (pmod_data->fn_rtp_destroy (pmsg, 0, 0) != 1) - { -- LM_ERR ("%srtpproxy_destroy refused for call (%s)!", -+ LM_ERR ("%srtpproxy_destroy refused for call (%s)!\n", +@@ -701,7 +742,6 @@ if (pmsg != FAKED_REPLY) pfncname, pcall->call_from); } } @@ -1282,7 +1222,7 @@ return; } -@@ -712,62 +750,37 @@ +@@ -710,62 +750,37 @@ return; * * INPUT: * Arg (1) = SIP message pointer @@ -1361,7 +1301,7 @@ for (nidx = 0; nidx < pmod_data->call_cnt; nidx++) { /********** -@@ -775,21 +788,25 @@ +@@ -773,21 +788,25 @@ for (nidx = 0; nidx < pmod_data->call_cnt; nidx++) * o call timed out on ACK? * o callID matches? * o to tag matches? @@ -1382,7 +1322,7 @@ { if ((pcall->call_time + 32) < time (0)) { -- LM_ERR ("find_call: No ACK response for call (%s)", pcall->call_from); +- LM_ERR ("find_call: No ACK response for call (%s)\n", pcall->call_from); + LM_ERR ("%sNo ACK response for call (%s)!\n", pfncname, pcall->call_from); delete_call (pcall); continue; @@ -1392,7 +1332,7 @@ str tmpstr [1]; tmpstr->s = pcall->call_id; tmpstr->len = strlen (tmpstr->s); -@@ -802,36 +819,101 @@ +@@ -800,31 +819,96 @@ for (nidx = 0; nidx < pmod_data->call_cnt; nidx++) if (!STR_EQ (*tmpstr, *ptotag)) { continue; } } @@ -1496,22 +1436,7 @@ int nidx; str tmpstr; if (!mohq_lock_set (pmod_data->pmohq_lock, 0, 500)) - { -- LM_ERR ("%sUnable to lock queues!", pfncname); -+ LM_ERR ("%sUnable to lock queues!\n", pfncname); - return -1; - } - for (nidx = 0; nidx < pmod_data->mohq_cnt; nidx++) -@@ -843,7 +925,7 @@ - } - if (nidx == pmod_data->mohq_cnt) - { -- LM_ERR ("%sUnable to find queue (%.*s)!", pfncname, STR_FMT (pqname)); -+ LM_ERR ("%sUnable to find queue (%.*s)!\n", pfncname, STR_FMT (pqname)); - nidx = -1; - } - mohq_lock_release (pmod_data->pmohq_lock); -@@ -871,7 +953,7 @@ +@@ -869,7 +953,7 @@ parse_to (pvalue->s, &pvalue->s [pvalue->len + 1], pref); if (pref->error != PARSE_OK) { // should never happen @@ -1520,7 +1445,7 @@ return -1; } if (pref->param_lst) -@@ -886,7 +968,7 @@ +@@ -884,7 +968,7 @@ str tmpstr; struct to_body pfrom [1]; for (nidx = 0; nidx < pmod_data->call_cnt; nidx++) { @@ -1529,7 +1454,7 @@ { continue; } tmpstr.s = pmod_data->pcall_lst [nidx].call_from; tmpstr.len = strlen (tmpstr.s); -@@ -894,7 +976,7 @@ +@@ -892,7 +976,7 @@ for (nidx = 0; nidx < pmod_data->call_cnt; nidx++) if (pfrom->error != PARSE_OK) { // should never happen @@ -1538,7 +1463,7 @@ continue; } if (pfrom->param_lst) -@@ -910,55 +992,65 @@ +@@ -908,55 +992,65 @@ return -1; * * INPUT: * Arg (1) = SIP message pointer @@ -1625,7 +1550,7 @@ } /********** -@@ -971,10 +1063,11 @@ +@@ -969,10 +1063,11 @@ if (pmod_data->fn_rtp_offer (pmsg, 0, 0) != 1) tm_api_t *ptm = pmod_data->ptm; if (ptm->t_newtran (pmsg) < 0) { @@ -1639,7 +1564,7 @@ } struct cell *ptrans = ptm->t_gett (); pcall->call_hash = ptrans->hash_index; -@@ -982,28 +1075,53 @@ +@@ -980,28 +1075,53 @@ pcall->call_label = ptrans->label; str ptotag [1]; if (ptm->t_get_reply_totag (pmsg, ptotag) != 1) { @@ -1653,9 +1578,7 @@ delete_call (pcall); - return 1; + return; - } --strncpy (pcall->call_tag, ptotag->s, ptotag->len); --pcall->call_tag [ptotag->len] = '\0'; ++ } +char *pbuf = &pcall->call_buffer [pcall->call_bufpos]; +pcall->call_tag = pbuf; +if (!addstrbfr (ptotag->s, ptotag->len, &pbuf, &pcall->call_bufpos, 1)) @@ -1667,7 +1590,9 @@ + end_RTP (pmsg, pcall); + delete_call (pcall); + return; -+ } + } +-strncpy (pcall->call_tag, ptotag->s, ptotag->len); +-pcall->call_tag [ptotag->len] = '\0'; pcall->call_cseq = 1; if (ptm->register_tmcb (pmsg, 0, TMCB_DESTROY | TMCB_ON_FAILURE, invite_cb, pcall, 0) < 0) @@ -1701,7 +1626,7 @@ * o add contact to reply * o supports/requires PRACK? (RFC 3262 section 3) * o exit if not ringing -@@ -1011,19 +1129,20 @@ +@@ -1009,19 +1129,20 @@ if (ptm->register_tmcb (pmsg, 0, TMCB_DESTROY | TMCB_ON_FAILURE, str pcontact [1]; char *pcontacthdr = "Contact: <%s>" SIPEOL; @@ -1728,7 +1653,7 @@ pfncname, pcontact->s, pcall->call_from); } pkg_free (pcontact->s); -@@ -1032,42 +1151,30 @@ +@@ -1030,42 +1151,30 @@ if (search_hdr_ext (pmsg->require, p100rel)) { if (!send_prov_rsp (pmsg, pcall)) { @@ -1745,16 +1670,16 @@ { - LM_ERR ("%sUnable to reply to INVITE!", pfncname); - return 1; -+ end_RTP (pmsg, pcall); -+ delete_call (pcall); -+ return; - } +- } - else - { - pcall->call_state = CLSTA_RINGING; - mohq_debug (pcall->pmohq, "%sSent RINGING for call (%s)", - pfncname, pcall->call_from); -- } ++ end_RTP (pmsg, pcall); ++ delete_call (pcall); ++ return; + } } /********** @@ -1781,7 +1706,7 @@ } /********** -@@ -1087,6 +1194,9 @@ +@@ -1085,6 +1194,9 @@ dlg_t *form_dialog (call_lst *pcall, struct to_body *pto_body) **********/ char *pfncname = "form_dialog: "; @@ -1791,7 +1716,7 @@ struct to_body *ptob = &pto_body [0]; struct to_body *pcontact = &pto_body [1]; parse_to (pcall->call_from, -@@ -1094,12 +1204,49 @@ +@@ -1092,12 +1204,49 @@ parse_to (pcall->call_from, if (ptob->error != PARSE_OK) { // should never happen @@ -1843,7 +1768,7 @@ if (!*pcall->call_contact) { ptarget->s = ptob->uri.s; -@@ -1112,7 +1259,7 @@ +@@ -1110,7 +1259,7 @@ else if (pcontact->error != PARSE_OK) { // should never happen @@ -1852,7 +1777,7 @@ pcall->call_contact, pcall->call_from); return 0; } -@@ -1129,7 +1276,7 @@ +@@ -1127,7 +1276,7 @@ else dlg_t *pdlg = (dlg_t *)pkg_malloc (sizeof (dlg_t)); if (!pdlg) { @@ -1861,7 +1786,7 @@ return 0; } memset (pdlg, 0, sizeof (dlg_t)); -@@ -1147,6 +1294,11 @@ +@@ -1145,6 +1294,11 @@ pdlg->loc_uri.s = pcall->pmohq->mohq_uri; pdlg->loc_uri.len = strlen (pdlg->loc_uri.s); pdlg->rem_uri.s = ptob->uri.s; pdlg->rem_uri.len = ptob->uri.len; @@ -1873,7 +1798,7 @@ return pdlg; } -@@ -1173,7 +1325,7 @@ +@@ -1171,7 +1325,7 @@ rtpmap **pmohfiles = find_MOH (pcall->pmohq->mohq_mohdir, pcall->pmohq->mohq_mohfile); if (!pmohfiles [0]) { @@ -1882,7 +1807,7 @@ pcall->pmohq->mohq_name); return 0; } -@@ -1193,7 +1345,7 @@ +@@ -1191,7 +1345,7 @@ for (nidx = 0; pmohfiles [nidx]; nidx++) pstr->s = pkg_malloc (nsize + 1); if (!pstr->s) { @@ -1891,7 +1816,7 @@ return 0; } strcpy (pstr->s, pSDP); -@@ -1240,7 +1392,7 @@ +@@ -1238,7 +1392,7 @@ static void call_lst *pcall = (call_lst *)*pcbp->param; if (ntype == TMCB_DESTROY) { pcall->call_hash = pcall->call_label = 0; } @@ -1900,7 +1825,7 @@ delete_call (pcall); return; } -@@ -1251,10 +1403,10 @@ +@@ -1249,10 +1403,10 @@ return; * INPUT: * Arg (1) = SIP message pointer * Arg (2) = call pointer @@ -1913,7 +1838,7 @@ { /********** -@@ -1264,11 +1416,11 @@ +@@ -1262,11 +1416,11 @@ int notify_msg (sip_msg_t *pmsg, call_lst *pcall) char *pfncname = "notify_msg: "; if (pcall->call_state != CLSTA_RFRWAIT) { @@ -1928,7 +1853,7 @@ } /********** -@@ -1279,28 +1431,28 @@ +@@ -1277,28 +1431,28 @@ if (pcall->call_state != CLSTA_RFRWAIT) if (!search_hdr_ext (pmsg->content_type, psipfrag)) { @@ -1965,7 +1890,7 @@ } strncpy (pbody->s, pfrag, pbody->len); if (pbody->s [pbody->len - 1] != '\n') -@@ -1313,10 +1465,10 @@ +@@ -1311,10 +1465,10 @@ parse_first_line (pbody->s, pbody->len + 1, pstart); pkg_free (pbody->s); if (pstart->type != SIP_REPLY) { @@ -1979,7 +1904,7 @@ } /********** -@@ -1324,32 +1476,34 @@ +@@ -1322,32 +1476,34 @@ if (pstart->type != SIP_REPLY) * o REFER done? **********/ @@ -2021,7 +1946,7 @@ } /********** -@@ -1360,7 +1514,7 @@ +@@ -1358,7 +1514,7 @@ switch (nreply / 100) update_call_rec (pcall); break; } @@ -2030,7 +1955,7 @@ } /********** -@@ -1369,10 +1523,10 @@ +@@ -1367,10 +1523,10 @@ return 1; * INPUT: * Arg (1) = SIP message pointer * Arg (2) = call pointer @@ -2043,7 +1968,7 @@ { /********** -@@ -1383,10 +1537,10 @@ +@@ -1381,10 +1537,10 @@ char *pfncname = "prack_msg: "; tm_api_t *ptm = pmod_data->ptm; if (pcall->call_state != CLSTA_PRACKSTRT) { @@ -2057,7 +1982,7 @@ } /********** -@@ -1396,20 +1550,20 @@ +@@ -1394,20 +1550,20 @@ if (pcall->call_state != CLSTA_PRACKSTRT) if (ptm->t_newtran (pmsg) < 0) { @@ -2084,7 +2009,7 @@ } /********** -@@ -1450,18 +1604,22 @@ +@@ -1448,18 +1604,22 @@ puri->s = pcall->call_referto; puri->len = strlen (puri->s); int npos1 = sizeof (prefermsg) // REFER template + strlen (pcall->call_via) // Via @@ -2110,7 +2035,7 @@ /********** * send REFER request -@@ -1474,13 +1632,14 @@ +@@ -1472,13 +1632,14 @@ phdrs->s = pbuf; phdrs->len = strlen (pbuf); set_uac_req (puac, prefer, phdrs, 0, pdlg, TMCB_LOCAL_COMPLETED | TMCB_ON_FAILURE, refer_cb, pcall); @@ -2126,7 +2051,7 @@ pfncname, pcall->call_from); update_call_rec (pcall); goto refererr; -@@ -1514,21 +1673,23 @@ +@@ -1512,21 +1673,23 @@ char *pfncname = "refer_cb: "; call_lst *pcall = (call_lst *)*pcbp->param; if ((ntype == TMCB_ON_FAILURE) || (pcbp->req == FAKED_REPLY)) { @@ -2153,7 +2078,7 @@ pcall->call_from, nreply); if (nreply == 481) { delete_call (pcall); } -@@ -1547,10 +1708,10 @@ +@@ -1545,10 +1708,10 @@ return; * INPUT: * Arg (1) = SIP message pointer * Arg (2) = call pointer @@ -2166,7 +2091,7 @@ { /********** -@@ -1565,17 +1726,17 @@ +@@ -1563,17 +1726,17 @@ if ((pcall->call_state / 100) < 2) mohq_debug (pcall->pmohq, "%sINVITE still pending for call (%s)", pfncname, pcall->call_from); if (pmod_data->psl->freply (pmsg, 491, presp_reqpend) < 0) @@ -2189,7 +2114,7 @@ } } -@@ -1645,12 +1806,12 @@ +@@ -1643,12 +1806,12 @@ if (!bhold) { if (!bmatch) { @@ -2205,7 +2130,7 @@ } } else -@@ -1659,26 +1820,26 @@ +@@ -1657,26 +1820,26 @@ if (!bhold) pfncname, pcall->call_from); if (pmod_data->psl->freply (pmsg, 200, presp_ok) < 0) { @@ -2239,7 +2164,7 @@ } /********** -@@ -1746,22 +1907,21 @@ +@@ -1744,22 +1907,21 @@ char *phdrtmplt = "Accept-Language: en" SIPEOL "Require: 100rel" SIPEOL "RSeq: %d" SIPEOL @@ -2265,7 +2190,7 @@ pfncname, pcall->call_from); return 0; } -@@ -1782,7 +1942,7 @@ +@@ -1780,7 +1942,7 @@ while (1) { break; } if (nstart < time (0)) { @@ -2274,7 +2199,7 @@ pfncname, pcall->call_from); break; } -@@ -1822,7 +1982,7 @@ +@@ -1820,7 +1982,7 @@ pbuf->s = build_res_buf_from_sip_req (200, presp_ok, ptotag, ptrans->uas.request (unsigned int *)&pbuf->len, pBM); if (!pbuf->s || !pbuf->len) { @@ -2283,7 +2208,7 @@ pfncname, pcall->call_from); return 0; } -@@ -1895,7 +2055,7 @@ +@@ -1893,7 +2055,7 @@ npos1 += pextrahdr->len + strlen (pbodylen) + pSDP->len + 1; char *pnewbuf = pkg_malloc (npos1); if (!pnewbuf) { @@ -2292,7 +2217,7 @@ goto answer_done; } for (npos1 = npos2 = 0; npos2 < nhdrcnt; npos2++) -@@ -1925,7 +2085,7 @@ +@@ -1923,7 +2085,7 @@ build_sip_msg_from_buf (pnmsg, pbuf->s, pbuf->len, 0); memcpy (&pnmsg->rcv, &pmsg->rcv, sizeof (struct receive_info)); /********** @@ -2301,7 +2226,7 @@ * o form stream file * o send stream **********/ -@@ -1934,7 +2094,7 @@ +@@ -1932,7 +2094,7 @@ mohq_debug (pcall->pmohq, "%sAnswering RTP link for call (%s)", pfncname, pcall->call_from); if (pmod_data->fn_rtp_answer (pnmsg, 0, 0) != 1) { @@ -2310,7 +2235,7 @@ pfncname, pcall->call_from); goto answer_done; } -@@ -1951,7 +2111,7 @@ +@@ -1949,7 +2111,7 @@ pkg_free (pnewbuf); free_sip_msg (pnmsg); if (!pbuf->s || !pbuf->len) { @@ -2319,7 +2244,7 @@ pfncname, pcall->call_from); goto answer_done; } -@@ -1975,26 +2135,26 @@ +@@ -1973,26 +2135,26 @@ char *pfnd = strstr (pnewSDP->s, "m=audio "); if (!pfnd) { // should not happen @@ -2350,19 +2275,19 @@ pfncname, pcall->call_from); goto answer_done; } -@@ -2043,7 +2203,7 @@ +@@ -2041,7 +2203,34 @@ mohq_debug (pcall->pmohq, "%sStarting RTP link for call (%s)", pfncname, pcall->call_from); if (fn_stream (pmsg, (char *)pmodel, (char *)-1) != 1) { - LM_ERR ("%srtpproxy_stream refused for call (%s)!", + LM_ERR ("%srtpproxy_stream refused for call (%s)!\n", - pfncname, pcall->call_from); - return 0; - } -@@ -2051,6 +2211,33 @@ - } - - /********** ++ pfncname, pcall->call_from); ++ return 0; ++ } ++return 1; ++} ++ ++/********** +* Stop Streaming +* +* INPUT: @@ -2383,17 +2308,10 @@ +if (fn_stop (pmsg, (char *)-1, (char *)-1) != 1) + { + LM_ERR ("%srtpproxy_stop refused for call (%s)!\n", -+ pfncname, pcall->call_from); -+ return 0; -+ } -+return 1; -+} -+ -+/********** - * Form Char Array from STR - * - * INPUT: -@@ -2064,7 +2251,7 @@ + pfncname, pcall->call_from); + return 0; + } +@@ -2062,7 +2251,7 @@ char *form_tmpstr (str *pstr) char *pcstr = malloc (pstr->len + 1); if (!pcstr) { @@ -2402,7 +2320,7 @@ return NULL; } memcpy (pcstr, pstr->s, pstr->len); -@@ -2164,7 +2351,7 @@ +@@ -2162,7 +2351,7 @@ struct mi_root *mi_debug (struct mi_root *pcmd_tree, void *parms) struct mi_node *pnode = pcmd_tree->node.kids; if (!pnode || !pnode->next || pnode->next->next) { return init_mi_tree (400, MI_MISSING_PARM_S, MI_MISSING_PARM_LEN); } @@ -2411,7 +2329,7 @@ if (nq_idx == -1) { return init_mi_tree (400, pmi_noqueue->s, pmi_noqueue->len); } char pint [20]; -@@ -2217,7 +2404,7 @@ +@@ -2215,7 +2404,7 @@ struct mi_root *mi_drop_call (struct mi_root *pcmd_tree, void *parms) struct mi_node *pnode = pcmd_tree->node.kids; if (!pnode || !pnode->next || pnode->next->next) { return init_mi_tree (400, MI_MISSING_PARM_S, MI_MISSING_PARM_LEN); } @@ -2420,7 +2338,7 @@ if (nq_idx == -1) { return init_mi_tree (400, pmi_noqueue->s, pmi_noqueue->len); } if (!mohq_lock_set (pmod_data->pcall_lock, 0, 5000)) -@@ -2240,7 +2427,7 @@ +@@ -2238,7 +2427,7 @@ for (nidx = 0; nidx < pmod_data->call_cnt; nidx++) **********/ call_lst *pcall = &pmod_data->pcall_lst [nidx]; @@ -2429,7 +2347,7 @@ { continue; } if (pqueue->mohq_id != pcall->pmohq->mohq_id) { continue; } -@@ -2279,12 +2466,12 @@ +@@ -2277,12 +2466,12 @@ char *pfncname = "mohq_count: "; str pqname [1]; if (!pqueue || !presult) { @@ -2444,7 +2362,7 @@ return -1; } -@@ -2294,12 +2481,12 @@ +@@ -2292,12 +2481,12 @@ if (fixup_get_svalue (pmsg, (gparam_p)pqueue, pqname)) * o count items in queue **********/ @@ -2459,7 +2377,7 @@ else { if (nq_idx != -1) -@@ -2307,7 +2494,7 @@ +@@ -2305,7 +2494,7 @@ else mohq_id = pmod_data->pmohq_lst [nq_idx].mohq_id; for (ncall_idx = 0; ncall_idx < pmod_data->call_cnt; ncall_idx++) { @@ -2468,7 +2386,7 @@ { continue; } if (pcalls [ncall_idx].pmohq->mohq_id == mohq_id && pcalls [ncall_idx].call_state == CLSTA_INQUEUE) -@@ -2328,7 +2515,7 @@ +@@ -2326,7 +2515,7 @@ pavp_val->ri = ncount; pavp_val->flags = PV_TYPE_INT | PV_VAL_INT; if (presult->setf (pmsg, &presult->pvp, (int)EQ_T, pavp_val) < 0) { @@ -2477,7 +2395,7 @@ return -1; } return 1; -@@ -2366,7 +2553,7 @@ +@@ -2364,7 +2553,7 @@ va_list ap; va_start (ap, pfmt); vsnprintf (ptext, sizeof (ptext), pfmt, ap); va_end (ap); @@ -2486,7 +2404,7 @@ if (nsys_log < nmohq_log) { reset_local_debug_level (); } return; -@@ -2377,39 +2564,28 @@ +@@ -2375,39 +2564,28 @@ return; * * INPUT: * Arg (1) = SIP message pointer @@ -2507,17 +2425,17 @@ char *pfncname = "mohq_process: "; -if (parse_headers (pmsg, HDR_EOH_F, 0) < 0) +- { +- LM_ERR ("%sUnable to parse header!", pfncname); +- return -1; +- } +-if (!mohq_lock_set (pmod_data->pmohq_lock, 0, 2000)) +if (!mohq_lock_set (pmod_data->pmohq_lock, 0, 500)) { -- LM_ERR ("%sUnable to parse header!", pfncname); +- LM_ERR ("%sUnable to lock calls!", pfncname); + LM_ERR ("%sUnable to read lock queue!\n", pfncname); return -1; } --if (!mohq_lock_set (pmod_data->pmohq_lock, 0, 2000)) -- { -- LM_ERR ("%sUnable to lock calls!", pfncname); -- return -1; -- } -call_lst *pcall; -int mohq_idx = find_call (pmsg, &pcall); db1_con_t *pconn = mohq_dbconnect (); @@ -2531,7 +2449,7 @@ **********/ if (pmod_data->mohq_update + 60 < time (0)) -@@ -2423,22 +2599,51 @@ +@@ -2421,22 +2599,51 @@ if (pconn) } mohq_dbdisconnect (pconn); } @@ -2585,7 +2503,7 @@ switch (pmsg->REQ_METHOD) { case METHOD_INVITE: -@@ -2446,33 +2651,35 @@ +@@ -2444,33 +2651,35 @@ switch (pmsg->REQ_METHOD) * initial INVITE? **********/ @@ -2631,7 +2549,7 @@ } /********** -@@ -2497,28 +2704,28 @@ +@@ -2495,28 +2704,28 @@ char *pfncname = "mohq_retrieve: "; str puri [1], pqname [1]; if (!pqueue || !pURI) { @@ -2665,7 +2583,7 @@ return -1; } -@@ -2528,12 +2735,12 @@ +@@ -2526,12 +2735,12 @@ if (parse_uri (puri->s, puri->len, puri_parsed)) * o find oldest call **********/ @@ -2680,7 +2598,7 @@ return -1; } call_lst *pcall = 0; -@@ -2546,15 +2753,27 @@ +@@ -2544,15 +2753,27 @@ for (ncall_idx = 0; ncall_idx < pmod_data->call_cnt; ncall_idx++) /********** * o active call? * o matching queue? @@ -2709,7 +2627,7 @@ if (pcall->call_state != CLSTA_INQUEUE) { continue; } if (!ntime) -@@ -2573,7 +2792,7 @@ +@@ -2571,7 +2792,7 @@ for (ncall_idx = 0; ncall_idx < pmod_data->call_cnt; ncall_idx++) } if (nfound == -1) { @@ -2718,7 +2636,7 @@ mohq_lock_release (pmod_data->pcall_lock); return -1; } -@@ -2588,7 +2807,7 @@ +@@ -2586,7 +2807,7 @@ strncpy (pcall->call_referto, puri->s, puri->len); pcall->call_referto [puri->len] = '\0'; if (refer_call (pcall, pmod_data->pcall_lock)) { return 1; } @@ -2727,7 +2645,7 @@ return -1; } -@@ -2612,24 +2831,24 @@ +@@ -2610,24 +2831,24 @@ int mohq_send (sip_msg_t *pmsg, char *pqueue) char *pfncname = "mohq_send: "; if (pmsg->REQ_METHOD != METHOD_INVITE) { @@ -2756,7 +2674,7 @@ return -1; } -@@ -2639,14 +2858,14 @@ +@@ -2637,14 +2858,14 @@ if (fixup_get_svalue (pmsg, (gparam_p)pqueue, pqname)) * o relay message **********/ @@ -2773,7 +2691,7 @@ return -1; } strcpy (pruri->s, pmod_data->pmohq_lst [nq_idx].mohq_uri); -@@ -2658,7 +2877,7 @@ +@@ -2656,8 +2877,8 @@ pmsg->parsed_uri_ok = 0; pmsg->parsed_orig_ruri_ok = 0; if (pmod_data->ptm->t_relay (pmsg, 0, 0) < 0) { @@ -2782,36 +2700,39 @@ return -1; } return 1; +-} ++} +\ No newline at end of file +diff --git a/modules/mohqueue/mohq_funcs.h b/modules/mohqueue/mohq_funcs.h +index dbe02c5..5d4dfd1 100644 --- a/modules/mohqueue/mohq_funcs.h +++ b/modules/mohqueue/mohq_funcs.h -@@ -1,9 +1,7 @@ +@@ -1,5 +1,5 @@ /* -- * $Id$ +- * Copyright (C) 2013 Robert Boisvert + * Copyright (C) 2013-15 Robert Boisvert * -- * Copyright (C) 2013 Robert Boisvert -- * -- * This file is part of the mohqueue module for sip-router, a free SIP server. -+ * This file is part of the mohqueue module for Kamailio, a free SIP server. + * This file is part of the mohqueue module for Kamailio, a free SIP server. * - * The mohqueue module is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by +@@ -35,4 +35,4 @@ int mohq_process (sip_msg_t *); + int mohq_retrieve (sip_msg_t *, char *, char *); + int mohq_send (sip_msg_t *, char *); + +-#endif /* MOHQ_FUNCS_H */ ++#endif /* MOHQ_FUNCS_H */ +\ No newline at end of file +diff --git a/modules/mohqueue/mohq_locks.c b/modules/mohqueue/mohq_locks.c +index 7adb04b..50ecb1c 100644 --- a/modules/mohqueue/mohq_locks.c +++ b/modules/mohqueue/mohq_locks.c -@@ -1,10 +1,8 @@ +@@ -1,5 +1,5 @@ /* -- * $Id$ +- * Copyright (C) 2013 Robert Boisvert + * Copyright (C) 2013-15 Robert Boisvert * -- * Copyright (C) 2013 Robert Boisvert -+ * This file is part of the mohqueue module for Kamailio, a free SIP server. + * This file is part of the mohqueue module for Kamailio, a free SIP server. * -- * This file is part of the mohqueue module for sip-router, a free SIP server. -- * - * The mohqueue module is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or -@@ -103,12 +101,12 @@ +@@ -101,12 +101,12 @@ char *pfncname = "mohq_lock_init: "; plock->plock = lock_alloc (); if (!plock->plock) { @@ -2826,7 +2747,7 @@ lock_dealloc (plock->plock); return 0; } -@@ -140,7 +138,7 @@ +@@ -138,7 +138,7 @@ switch (plock->lock_cnt) plock->lock_cnt = 0; break; case 0: @@ -2835,17 +2756,28 @@ break; default: plock->lock_cnt--; +@@ -194,4 +194,4 @@ do + } + while (!nret && --nms_cnt >= 0); + return nret; +-} ++} +\ No newline at end of file +diff --git a/modules/mohqueue/mohq_locks.h b/modules/mohqueue/mohq_locks.h +index 6f95c65..18c23fe 100644 --- a/modules/mohqueue/mohq_locks.h +++ b/modules/mohqueue/mohq_locks.h -@@ -1,9 +1,7 @@ +@@ -1,5 +1,5 @@ /* -- * $Id$ +- * Copyright (C) 2013 Robert Boisvert + * Copyright (C) 2013-15 Robert Boisvert * -- * Copyright (C) 2013 Robert Boisvert -- * -- * This file is part of the mohqueue module for sip-router, a free SIP server. -+ * This file is part of the mohqueue module for Kamailio, a free SIP server. + * This file is part of the mohqueue module for Kamailio, a free SIP server. * - * The mohqueue module is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by +@@ -44,4 +44,4 @@ int mohq_lock_init (mohq_lock *); + void mohq_lock_release (mohq_lock *); + int mohq_lock_set (mohq_lock *, int, int); + +-#endif /* MOHQ_LOCKS_H */ ++#endif /* MOHQ_LOCKS_H */ +\ No newline at end of file |