Update upstream source from tag 'upstream/5.4.4'

Update to upstream version '5.4.4'
with Debian dir 3ff732019b
mr9.4
Victor Seva 5 years ago
commit e3fe283bdc

@ -1,3 +0,0 @@
<vseva@sipwise.com> <linuxmaniac@torreviejawireless.org>
Sipwise Jenkins Builder <jenkins@sipwise.com>
Victor Seva <vseva@sipwise.com>

File diff suppressed because it is too large Load Diff

@ -19,7 +19,7 @@ Kamailio development was started back in 2001 by [Fraunhofer Fokus](https://www.
Fraunhofer Fokus is no longer actively involved in the evolution of the project. Kamailio is now developed and managed by its world wide community. Fokus still uses Kamailio in its research projects (such as OpenIMSCore) and it is hosting events related to the project, such as developer meetings or the Kamailio World Conference.
For more information about Kamailio, see the the [website of the project](https://www.kamailio.org), where you can find pointers to documentation, the project wiki and much more.
For more information about Kamailio, see the [website of the project](https://www.kamailio.org), where you can find pointers to documentation, the project wiki and much more.
## Contributions

@ -1,5 +1,5 @@
.\"
.TH kamailio 8 06.12.2016 kamailio "Kamailio SIP Server"
.TH kamailio 8 03.02.2021 kamailio "Kamailio SIP Server"
.\" Process with
.\" groff -man -Tascii kamailio.8
.\"
@ -8,39 +8,39 @@ kamailio \- a very fast and configurable SIP server
.SH SYNOPSIS
.B kamailio
[
.B \-hcrRvdDEVTI
.B \-hfcmMdVIhEeblLnvKrRDTNWwtugPGSQOaAxXY
] [
.BI \-f " config\-file"
.BI \-a " auto\-aliases\-mode"
] [
.BI \-l " address"
.BI \-A " pre\-processor\-define"
] [
.BI \-n " processes\-no"
.BI \-b " max_rcv_buf_size"
] [
.BI \-N " tcp processes\-no"
.BI \-f " config\-file"
] [
.BI \-b " max_rcv_buf_size"
.BI \-g " gid"
] [
.BI \-m " shared_mem_size"
.BI \-G " pgid\-file"
] [
.BI \-M " private_mem_size"
.BI \-l " address"
] [
.BI \-w " working\-dir"
.BI \-L " modules\-dir"
] [
.BI \-t " chroot\-dir"
.BI \-M " private_mem_size"
] [
.BI \-u " uid"
.BI \-m " shared_mem_size"
] [
.BI \-g " gid"
.BI \-n " processes\-no"
] [
.BI \-P " pid\-file"
.BI \-N " tcp processes\-no"
] [
.BI \-G " pgid\-file"
.BI \-P " pid\-file"
] [
.BI \-L " modules\-dir"
.BI \-t " chroot\-dir"
] [
.BI \-a " auto\-aliases\-mode"
.BI \-u " uid"
] [
.BI \-A " pre\-processor\-define"
.BI \-w " working\-dir"
]
.SH DESCRIPTION
@ -49,28 +49,41 @@ is a very fast and configurable SIP (RFC3261) server.
.SH OPTIONS
.TP 12
.B \-h
Displays a short usage description, including all available options.
.B
.TP
.BI \-c
Checks the config file and displays the aliases and listen interface list.
.BI \-a " auto\-aliases\-mode"
Enable auto-aliases with 'yes' or 'on', disable with 'no' or 'off
.TP
.BI \-r
Uses dns to check if it is necessary to add a "received=" field to a via.
.BI \-\-alias\fR=\fIval
Add an alias, the value has to be '[proto:]hostname[:port]'
(like for 'alias' global parameter)
.TP
.BI \-R
Same as
.B \-r
but uses reverse dns.
.BI \-\-atexit\fR=\fIval
Control atexit callbacks execution from external libraries
which may access destroyed shm memory causing crash on shutdown.
Can be y[es] or 1 to enable atexit callbacks, n[o] or 0 to disable,
default is yes.
.TP
.BI \-K
Turns on via host checking when forwarding replies.
.BI \-A " pre\-processor\-define"
Add config pre-processor define (e.g., -A WITH_AUTH, -A N=1, -A X='"Y"')
.TP
.BI \-b " max_rcv_buf_size"
Maximum receive buffer size which will not be exceeded by the auto-probing procedure even if the OS allows.
.TP
.BI \-c
Checks the config file and displays the aliases and listen interface list.
.TP
.BI \-\-cfg\-print
Print configuration file evaluating includes and ifdefs
.TP
.BI \-d
Turns on debugging, multiple
.B \-d
increase the debug level.
.TP
.BI \-\-debug\fR=\fIval
Debugging level value
.TP
.BI \-D
Control how daemonize is done:
.br
@ -83,18 +96,12 @@ Control how daemonize is done:
.B \-DDD
- daemonize (default)
.TP
.BI \-e
Log messages printed in terminal colors (requires -E)
.TP
.BI \-E
Sends all the log messages to stderr.
.TP
.BI \-T
Disables TCP support.
.TP
.BI \-V
Displays the version number.
.TP
.BI \-I
Displays details of internal constants and attributes.
.TP
.BI \-f " config\-file"
Reads the configuration from
.B " config\-file"
@ -102,6 +109,25 @@ Reads the configuration from
.I /etc/kamailio/kamailio.cfg
).
.TP
.BI \-g " gid"
Changes the group id under which
.B kamailio
runs.
.TP
.BI \-G " pgid\-file"
Creates a file containing the pgid of the main
.B kamailio
process.
.TP
.B \-h \-\-help
Displays a short usage description, including all available options.
.TP
.BI \-I
Displays details of internal constants and attributes.
.TP
.BI \-K
Turns on via host checking when forwarding replies.
.TP
.BI \-l " address"
Listens on the specified address/interface. Multiple
.B \-l
@ -111,6 +137,27 @@ address = host|ip_address|interface_name. Example: -l localhost,
-l udp:127.0.0.1:5080, -l eth0:5062.
The default behaviour is to listen on all the ipv4 interfaces.
.TP
.BI \-\-loadmodule\fR=\fIname
load the module specified by name
.TP
.BI \-\-log\-engine\fR=\fIname
log engine name and data
.TP
.BI \-L " modules\-dir"
Specifies the directory where to look for
.B kamailio
modules (default: /usr/lib/kamailio/modules or /usr/lib64/kamailio/modules)
.TP
.BI \-m " shared_mem_size"
Size of the shared memory which will be allocated (in Megabytes).
.TP
.BI \-\-modparam\fR=\fImodname:paramname:type:value
set the module parameter type has to be 's' for string value and 'i' for int value,
example: --modparam=corex:alias_subdomains:s:" NAME ".org
.TP
.BI \-M " private_mem_size"
Size of the private memory which will be allocated per process (in Megabytes).
.TP
.BI \-n " processes\-no"
Specifies the number of children processes forked per interface (default 8).
.TP
@ -119,56 +166,83 @@ Specifies the number of children processes forked to handle tcp incoming connect
.BI \-n
).
.TP
.BI \-b " max_rcv_buf_size"
Maximum receive buffer size which will not be exceeded by the auto-probing procedure even if the OS allows.
.TP
.BI \-m " shared_mem_size"
Size of the shared memory which will be allocated (in Megabytes).
.BI \-P " pid\-file"
Creates a file containing the pid of the main
.B kamailio
process.
.TP
.BI \-M " private_mem_size"
Size of the private memory which will be allocated per process (in Megabytes).
.BI \-O " optimization\-level"
Script optimization level (debugging option).
.TP
.BI \-w " working\-dir"
Specifies the working directory. In the very improbable event that
.BI \-P " pid\-file"
Creates a file containing the pid of the main
.B kamailio
will crash, the core file will be generated here.
process.
.TP
.BI \-Q
Number of sctp child processes (default: equal to
.BI \-n
).
.TP
.BI \-r
Uses dns to check if it is necessary to add a "received=" field to a via.
.TP
.BI \-R
Same as
.B \-r
but uses reverse dns (to use both:
.BI \-rR
).
.TP
.BI \-\-server\-id\fR=\fInum
Set the value for server_id
.TP
.BI \-\-subst\fR=\fIexp
Set a subst preprocessor directive
.TP
.BI \-\-substdef\fR=\fIexp
Set a substdef preprocessor directive
.TP
.BI \-\-substdefs\fR=\fIexp
Set a substdefs preprocessor directive.
.TP
.BI \-S
Disables SCTP support.
.TP
.BI \-t " chroot\-dir"
Forces
.B kamailio
to chroot after reading the config file.
.TP
.BI \-T
Disables TCP support.
.TP
.BI \-u " uid"
Changes the user id under which
.B kamailio
runs.
.TP
.BI \-g " gid"
Changes the group id under which
.B kamailio
runs.
.BI "\-v \-V \-\-version"
Displays the version number.
.TP
.BI \-P " pid\-file"
Creates a file containing the pid of the main
.B kamailio
process.
.BI \-x " name"
Specify internal manager for shared memory (shm) can be: fm, qm or tlsf
.TP
.BI \-G " pgid\-file"
Creates a file containing the pgid of the main
.B kamailio
process.
.BI \-X " name"
Specify internal manager for private memory (pkg) if omitted, the one for shm is used
.TP
.BI \-L " modules\-dir"
Specifies the directory where to look for
.BI \-Y " dir"
Runtime dir path
.TP
.BI \-w " working\-dir"
Specifies the working directory. In the very improbable event that
.B kamailio
modules (default: /usr/lib/kamailio/modules or /usr/lib64/kamailio/modules)
will crash, the core file will be generated here.
.TP
.BI \-a " auto\-aliases\-mode"
Enable auto-aliases with 'yes' or 'on', disable with 'no' or 'off
.BI \-W " type"
poll method (depending on support in OS, it can be: poll,
epoll_lt, epoll_et, sigio_rt, select, kqueue, /dev/poll).
.TP
.BI \-A " pre\-processor\-define"
Add config pre-processor define (e.g., -A WITH_AUTH, -A N=1, -A X='"Y"')
.SH FILES
.PD 0
.B /usr/sbin/kamailio

@ -53,6 +53,7 @@
<!-- version data template -->
<xsl:template match="version">
<xsl:text>0:</xsl:text>
<xsl:call-template name="get-name">
<xsl:with-param name="select" select="parent::table"/>
</xsl:call-template>

@ -615,7 +615,7 @@ route[REQINIT] {
}
}
#!endif
if($ua =~ "friendly-scanner|sipcli|sipvicious|VaxSIPUserAgent") {
if($ua =~ "friendly|scanner|sipcli|sipvicious|VaxSIPUserAgent") {
# silent drop for scanners - uncomment next line if want to reply
# sl_send_reply("200", "OK");
exit;

@ -116,24 +116,26 @@ function ksr_route_relay()
function ksr_route_reqinit()
{
if (!KSR.is_myself_srcip()) {
if (!KSR.pv.is_null("$sht(ipban=>$si)")) {
var srcip = KSR.kx.get_srcip();
if (KSR.htable.sht_match_name("ipban", "eq", srcip) > 0) {
// ip is already blocked
KSR.dbg("request from blocked IP - " + KSR.pv.get("$rm")
+ " from " + KSR.pv.get("$fu") + " (IP:"
+ KSR.pv.get("$si") + ":" + KSR.pv.get("$sp") + ")\n");
KSR.dbg("request from blocked IP - " + KSR.kx.get_method()
+ " from " + KSR.kx.get_furi() + " (IP:"
+ srcip + ":" + KSR.kx.get_srcport() + ")\n");
KSR.x.exit();
}
if (KSR.pike.pike_check_req()<0) {
KSR.err("ALERT: pike blocking " + KSR.pv.get("$rm")
+ " from " + KSR.pv.get("$fu") + " (IP:"
+ KSR.pv.get("$si") + ":" + KSR.pv.get("$sp") + ")\n");
KSR.pv.seti("$sht(ipban=>$si)", 1);
KSR.err("ALERT: pike blocking " + KSR.kx.get_method()
+ " from " + KSR.kx.get_furi() + " (IP:"
+ srcip + ":" + KSR.kx.get_srcport() + ")\n");
KSR.htable.sht_seti("ipban", srcip, 1);
KSR.x.exit();
}
}
if (KSR.corex.has_user_agent()>0) {
var UA = KSR.pv.gete("$ua");
if (UA.indexOf("friendly-scanner")>=0 || UA.indexOf("sipcli")>=0) {
var UA = KSR.kx.gete_ua();
if (UA.indexOf("friendly")>=0 || UA.indexOf("scanner")>=0
|| UA.indexOf("sipcli")>=0 || UA.indexOf("sipvicious")>=0) {
KSR.sl.sl_send_reply(200, "OK");
KSR.x.exit();
}
@ -153,7 +155,7 @@ function ksr_route_reqinit()
if (KSR.sanity.sanity_check(1511, 7)<0) {
KSR.err("Malformed SIP message from "
+ KSR.pv.get("$si") + ":" + KSR.pv.get("$sp") + "\n");
+ KSR.kx.get_srcip() + ":" + KSR.kx.get_srcport() + "\n");
KSR.x.exit();
}
}
@ -237,7 +239,7 @@ function ksr_route_location()
}
// IP authorization and user uthentication
// IP authorization and user authentication
function ksr_route_auth()
{
if (!KSR.is_REGISTER()) {
@ -249,8 +251,8 @@ function ksr_route_auth()
if (KSR.is_REGISTER() || KSR.is_myself_furi()) {
// authenticate requests
if (KSR.auth_db.auth_check(KSR.pv.get("$fd"), "subscriber", 1)<0) {
KSR.auth.auth_challenge(KSR.pv.get("$fd"), 0);
if (KSR.auth_db.auth_check(KSR.kx.gete_fhost(), "subscriber", 1)<0) {
KSR.auth.auth_challenge(KSR.kx.gete_fhost(), 0);
KSR.x.exit();
}
// user authenticated - remove auth header
@ -339,8 +341,8 @@ function ksr_route_sipout()
// equivalent of branch_route[...]{}
function ksr_branch_manage()
{
KSR.dbg("new branch [" + KSR.pv.get("$T_branch_idx")
+ "] to " + KSR.pv.get("$ru") + "\n");
KSR.dbg("new branch [" + KSR.tm.t_get_branch_index()
+ "] to " + KSR.kx.get_ruri() + "\n");
ksr_route_natmanage();
return;
}
@ -350,7 +352,7 @@ function ksr_branch_manage()
function ksr_onreply_manage()
{
KSR.dbg("incoming reply\n");
var scode = KSR.pv.get("$rs");
var scode = KSR.kx.gets_status();
if (scode>100 && scode<=299) {
ksr_route_natmanage();
}

@ -1,7 +1,7 @@
-- Kamailio - equivalent of routing blocks in Lua
--
-- KSR - the new dynamic object exporting Kamailio functions (kemi)
-- sr - the old static object exporting Kamailio functions
-- KSR - the object exporting Kamailio KEMI functions (app_lua module)
-- sr - the old object exporting Kamailio functions (app_lua_sr module)
--
-- Relevant remarks:
@ -11,6 +11,9 @@
-- * KSR.drop() is only marking the SIP message for drop, but doesn't stop
-- the execution of the script. Use KSR.x.exit() after it or KSR.x.drop()
--
-- Hints:
-- * Lua syntax check: luac -p /path/to/script.lua
--
-- debug callback function to print details of execution trace
--[[
@ -160,21 +163,21 @@ function ksr_route_reqinit()
if KSR.htable.sht_match_name("ipban", "eq", srcip) > 0 then
-- ip is already blocked
KSR.dbg("request from blocked IP - " .. KSR.kx.get_method()
.. " from " .. KSR.kx.gete_furi() .. " (IP:"
.. " from " .. KSR.kx.get_furi() .. " (IP:"
.. srcip .. ":" .. KSR.kx.get_srcport() .. ")\n");
KSR.x.exit();
end
if KSR.pike.pike_check_req() < 0 then
KSR.err("ALERT: pike blocking " .. KSR.kx.get_method()
.. " from " .. KSR.kx.gete_furi() .. " (IP:"
.. " from " .. KSR.kx.get_furi() .. " (IP:"
.. srcip .. ":" .. KSR.kx.get_srcport() .. ")\n");
KSR.htable.sht_seti("ipban", srcip, 1);
KSR.x.exit();
end
end
local ua = KSR.kx.gete_ua();
if string.find(ua, "friendly-scanner")
or string.find(ua, "sipcli") then
if string.find(ua, "friendly") or string.find(ua, "scanner")
or string.find(ua, "sipcli") or string.find(ua, "sipvicious") then
KSR.sl.sl_send_reply(200, "OK");
KSR.x.exit();
end

@ -157,8 +157,8 @@ class kamailio:
if KSR.corex.has_user_agent() > 0 :
ua = KSR.pv.gete("$ua")
if (ua.find("friendly-scanner")!=-1
or ua.find("sipcli")!=-1) :
if (ua.find("friendly")!=-1 or ua.find("scanner")!=-1
or ua.find("sipcli")!=-1 or ua.find("sipvicious")!=-1) :
KSR.sl.sl_send_reply(200, "Processed")
return -255

@ -41,7 +41,7 @@ def ksr_request_route()
# Auth
ksr_route_auth()
# Record routing for dialog forming requests (in case they are routed)
KSR::HDR.remove("Route")
if KSR.is_method_in("IS") then
@ -65,7 +65,8 @@ end
def ksr_route_reqinit()
if KSR::COREX.has_user_agent() > 0 then
ua = KSR::PV.gete("$ua");
if ua.include? 'friendly-scanner' or ua.include? 'sipcli' then
if ua.include? 'friendly' or ua.include? 'scanner'
or ua.include? 'sipcli' or ua.include? 'sipvicious' then
KSR::SL.sl_send_reply(200, "OK");
exit
end

@ -137,7 +137,8 @@ function ksr_route_reqinit()
if (KSR.corex.has_user_agent()>0) {
local UA = KSR.pv.get("$ua");
// if (sipscanregex.match(UA)) {
if (UA.find("friendly-scanner")!=null || UA.find("sipcli")!=null) {
if (UA.find("friendly")!=null || UA.find("scanner")!=null
|| UA.find("sipcli")!=null || UA.find("sipvicious")!=null) {
KSR.sl.sl_send_reply(200, "OK");
KSR.x.exit();
}

@ -4,7 +4,7 @@
# Maintainer: Nathan Angelacos <nangel@alpinelinux.org>
pkgname=kamailio
pkgver=5.4.1
pkgver=5.4.4
pkgrel=0
# If building from a git snapshot, specify the gitcommit
@ -157,7 +157,7 @@ _mod_list_presence="presence presence_conference presence_dialoginfo \
rls xcap_client xcap_server"
# - modules depending on lua library
_mod_list_lua="app_lua"
_mod_list_lua="app_lua app_lua_sr"
# - modules depending on perl library
_mod_list_perl="app_perl db_perlvdb"

@ -1,3 +1,21 @@
kamailio (5.4.4) unstable; urgency=medium
* version set 5.4.4
-- Victor Seva <vseva@debian.org> Mon, 15 Feb 2021 09:31:26 +0100
kamailio (5.4.3) unstable; urgency=medium
* version set 5.4.3
-- Victor Seva <vseva@debian.org> Mon, 14 Dec 2020 09:44:12 +0100
kamailio (5.4.2) unstable; urgency=medium
* version set 5.4.2
-- Victor Seva <vseva@debian.org> Tue, 27 Oct 2020 11:44:52 +0100
kamailio (5.4.1) unstable; urgency=medium
* version set 5.4.1

@ -20,6 +20,8 @@ Restart=on-failure
# /run/kamailio in tmpfs
RuntimeDirectory=kamailio
RuntimeDirectoryMode=0770
# necessary for chown of control files e.g. for jsonrpcs and ctl modules
AmbientCapabilities=CAP_CHOWN
[Install]
WantedBy=multi-user.target

@ -1,3 +1,21 @@
kamailio (5.4.4) unstable; urgency=medium
* version set 5.4.4
-- Victor Seva <vseva@debian.org> Mon, 15 Feb 2021 09:31:26 +0100
kamailio (5.4.3) unstable; urgency=medium
* version set 5.4.3
-- Victor Seva <vseva@debian.org> Mon, 14 Dec 2020 09:44:12 +0100
kamailio (5.4.2) unstable; urgency=medium
* version set 5.4.2
-- Victor Seva <vseva@debian.org> Tue, 27 Oct 2020 11:44:52 +0100
kamailio (5.4.1) unstable; urgency=medium
* version set 5.4.1

@ -20,6 +20,8 @@ Restart=on-failure
# /run/kamailio in tmpfs
RuntimeDirectory=kamailio
RuntimeDirectoryMode=0770
# necessary for chown of control files e.g. for jsonrpcs and ctl modules
AmbientCapabilities=CAP_CHOWN
[Install]
WantedBy=multi-user.target

@ -90,7 +90,12 @@ sed -i -e '/^EXTRA_EXCLUDED_MODULES=/s/$/ ruby/' ${DIST}/rules
# no python3 for app_python3
sed -i -e '/python3-dev/d' -e '/^Package: kamailio-python3-modules/,/^$/d' \
-e '/python3/d' ${DIST}/control
${DIST}/control
# this removes python3 from Package: kamalio
sed -i -e '/python3/d' ${DIST}/control
# add that again
sed -i '/lsb-base,/a \ python3,' ${DIST}/control
sed -i -e 's/ python3[ ,$]*/ /' ${DIST}/rules
sed -i -e '/^EXTRA_EXCLUDED_MODULES=/s/$/ python3/' ${DIST}/rules

@ -90,7 +90,12 @@ sed -i -e '/^EXTRA_EXCLUDED_MODULES=/s/$/ ruby/' ${DIST}/rules
# no python3 for app_python3
sed -i -e '/python3-dev/d' -e '/^Package: kamailio-python3-modules/,/^$/d' \
-e '/python3/d' ${DIST}/control
${DIST}/control
# this removes python3 from Package: kamalio
sed -i -e '/python3/d' ${DIST}/control
# add that again
sed -i '/lsb-base,/a \ python3,' ${DIST}/control
sed -i -e 's/ python3[ ,$]*/ /' ${DIST}/rules
sed -i -e '/^EXTRA_EXCLUDED_MODULES=/s/$/ python3/' ${DIST}/rules

@ -1,3 +1,21 @@
kamailio (5.4.4) unstable; urgency=medium
* version set 5.4.4
-- Victor Seva <vseva@debian.org> Mon, 15 Feb 2021 09:31:26 +0100
kamailio (5.4.3) unstable; urgency=medium
* version set 5.4.3
-- Victor Seva <vseva@debian.org> Mon, 14 Dec 2020 09:44:12 +0100
kamailio (5.4.2) unstable; urgency=medium
* version set 5.4.2
-- Victor Seva <vseva@debian.org> Tue, 27 Oct 2020 11:44:52 +0100
kamailio (5.4.1) unstable; urgency=medium
* version set 5.4.1

@ -20,6 +20,8 @@ Restart=on-failure
# /run/kamailio in tmpfs
RuntimeDirectory=kamailio
RuntimeDirectoryMode=0770
# necessary for chown of control files e.g. for jsonrpcs and ctl modules
AmbientCapabilities=CAP_CHOWN
[Install]
WantedBy=multi-user.target

@ -1,3 +1,21 @@
kamailio (5.4.4) unstable; urgency=medium
* version set 5.4.4
-- Victor Seva <vseva@debian.org> Mon, 15 Feb 2021 09:31:26 +0100
kamailio (5.4.3) unstable; urgency=medium
* version set 5.4.3
-- Victor Seva <vseva@debian.org> Mon, 14 Dec 2020 09:44:12 +0100
kamailio (5.4.2) unstable; urgency=medium
* version set 5.4.2
-- Victor Seva <vseva@debian.org> Tue, 27 Oct 2020 11:44:52 +0100
kamailio (5.4.1) unstable; urgency=medium
* version set 5.4.1

@ -20,6 +20,8 @@ Restart=on-failure
# /run/kamailio in tmpfs
RuntimeDirectory=kamailio
RuntimeDirectoryMode=0770
# necessary for chown of control files e.g. for jsonrpcs and ctl modules
AmbientCapabilities=CAP_CHOWN
[Install]
WantedBy=multi-user.target

@ -1,3 +1,21 @@
kamailio (5.4.4) unstable; urgency=medium
* version set 5.4.4
-- Victor Seva <vseva@debian.org> Mon, 15 Feb 2021 09:31:26 +0100
kamailio (5.4.3) unstable; urgency=medium
* version set 5.4.3
-- Victor Seva <vseva@debian.org> Mon, 14 Dec 2020 09:44:12 +0100
kamailio (5.4.2) unstable; urgency=medium
* version set 5.4.2
-- Victor Seva <vseva@debian.org> Tue, 27 Oct 2020 11:44:52 +0100
kamailio (5.4.1) unstable; urgency=medium
* version set 5.4.1

@ -20,6 +20,8 @@ Restart=on-failure
# /run/kamailio in tmpfs
RuntimeDirectory=kamailio
RuntimeDirectoryMode=0770
# necessary for chown of control files e.g. for jsonrpcs and ctl modules
AmbientCapabilities=CAP_CHOWN
[Install]
WantedBy=multi-user.target

@ -1,3 +1,21 @@
kamailio (5.4.4) unstable; urgency=medium
* version set 5.4.4
-- Victor Seva <vseva@debian.org> Mon, 15 Feb 2021 09:31:26 +0100
kamailio (5.4.3) unstable; urgency=medium
* version set 5.4.3
-- Victor Seva <vseva@debian.org> Mon, 14 Dec 2020 09:44:12 +0100
kamailio (5.4.2) unstable; urgency=medium
* version set 5.4.2
-- Victor Seva <vseva@debian.org> Tue, 27 Oct 2020 11:44:52 +0100
kamailio (5.4.1) unstable; urgency=medium
* version set 5.4.1

@ -62,6 +62,7 @@ Depends:
adduser,
lsb-base,
python,
python3,
${misc:Depends},
${shlibs:Depends},
Replaces:

@ -1,3 +1,21 @@
kamailio (5.4.4) unstable; urgency=medium
* version set 5.4.4
-- Victor Seva <vseva@debian.org> Mon, 15 Feb 2021 09:31:26 +0100
kamailio (5.4.3) unstable; urgency=medium
* version set 5.4.3
-- Victor Seva <vseva@debian.org> Mon, 14 Dec 2020 09:44:12 +0100
kamailio (5.4.2) unstable; urgency=medium
* version set 5.4.2
-- Victor Seva <vseva@debian.org> Tue, 27 Oct 2020 11:44:52 +0100
kamailio (5.4.1) unstable; urgency=medium
* version set 5.4.1

@ -20,6 +20,8 @@ Restart=on-failure
# /run/kamailio in tmpfs
RuntimeDirectory=kamailio
RuntimeDirectoryMode=0770
# necessary for chown of control files e.g. for jsonrpcs and ctl modules
AmbientCapabilities=CAP_CHOWN
[Install]
WantedBy=multi-user.target

@ -1,3 +1,21 @@
kamailio (5.4.4) unstable; urgency=medium
* version set 5.4.4
-- Victor Seva <vseva@debian.org> Mon, 15 Feb 2021 09:31:26 +0100
kamailio (5.4.3) unstable; urgency=medium
* version set 5.4.3
-- Victor Seva <vseva@debian.org> Mon, 14 Dec 2020 09:44:12 +0100
kamailio (5.4.2) unstable; urgency=medium
* version set 5.4.2
-- Victor Seva <vseva@debian.org> Tue, 27 Oct 2020 11:44:52 +0100
kamailio (5.4.1) unstable; urgency=medium
* version set 5.4.1

@ -20,6 +20,8 @@ Restart=on-failure
# /run/kamailio in tmpfs
RuntimeDirectory=kamailio
RuntimeDirectoryMode=0770
# necessary for chown of control files e.g. for jsonrpcs and ctl modules
AmbientCapabilities=CAP_CHOWN
[Install]
WantedBy=multi-user.target

@ -1,3 +1,21 @@
kamailio (5.4.4) unstable; urgency=medium
* version set 5.4.4
-- Victor Seva <vseva@debian.org> Mon, 15 Feb 2021 09:31:26 +0100
kamailio (5.4.3) unstable; urgency=medium
* version set 5.4.3
-- Victor Seva <vseva@debian.org> Mon, 14 Dec 2020 09:44:12 +0100
kamailio (5.4.2) unstable; urgency=medium
* version set 5.4.2
-- Victor Seva <vseva@debian.org> Tue, 27 Oct 2020 11:44:52 +0100
kamailio (5.4.1) unstable; urgency=medium
* version set 5.4.1

@ -1,3 +1,21 @@
kamailio (5.4.4) unstable; urgency=medium
* version set 5.4.4
-- Victor Seva <vseva@debian.org> Mon, 15 Feb 2021 09:31:26 +0100
kamailio (5.4.3) unstable; urgency=medium
* version set 5.4.3
-- Victor Seva <vseva@debian.org> Mon, 14 Dec 2020 09:44:12 +0100
kamailio (5.4.2) unstable; urgency=medium
* version set 5.4.2
-- Victor Seva <vseva@debian.org> Tue, 27 Oct 2020 11:44:52 +0100
kamailio (5.4.1) unstable; urgency=medium
* version set 5.4.1

@ -62,6 +62,7 @@ Depends:
adduser,
lsb-base,
python,
python3,
${misc:Depends},
${shlibs:Depends},
Replaces:

@ -1,3 +1,21 @@
kamailio (5.4.4) unstable; urgency=medium
* version set 5.4.4
-- Victor Seva <vseva@debian.org> Mon, 15 Feb 2021 09:31:26 +0100
kamailio (5.4.3) unstable; urgency=medium
* version set 5.4.3
-- Victor Seva <vseva@debian.org> Mon, 14 Dec 2020 09:44:12 +0100
kamailio (5.4.2) unstable; urgency=medium
* version set 5.4.2
-- Victor Seva <vseva@debian.org> Tue, 27 Oct 2020 11:44:52 +0100
kamailio (5.4.1) unstable; urgency=medium
* version set 5.4.1

@ -20,6 +20,8 @@ Restart=on-failure
# /run/kamailio in tmpfs
RuntimeDirectory=kamailio
RuntimeDirectoryMode=0770
# necessary for chown of control files e.g. for jsonrpcs and ctl modules
AmbientCapabilities=CAP_CHOWN
[Install]
WantedBy=multi-user.target

@ -13,6 +13,8 @@ Environment='PKG_MEMORY=4'
EnvironmentFile=-/etc/sysconfig/kamailio
ExecStart=/usr/sbin/kamailio -DD -P /run/kamailio/kamailio.pid -f $CFGFILE -m $SHM_MEMORY -M $PKG_MEMORY
Restart=on-failure
# necessary for chown of control files e.g. for jsonrpcs and ctl modules
AmbientCapabilities=CAP_CHOWN
[Install]
WantedBy=multi-user.target

@ -1,5 +1,5 @@
%define name kamailio
%define ver 5.4.1
%define ver 5.4.4
%define rel dev1.0%{dist}
%if 0%{?fedora}
@ -1119,6 +1119,12 @@ UUID module for Kamailio.
sed -i -e 's/python3/python2/' utils/kamctl/dbtextdb/dbtextdb.py
%endif
# on latest dist need to add --atexit=no for Kamailio options. More details GH #2616
%if 0%{?fedora} || 0%{?suse_version} || 0%{?rhel} == 8
sed -i -e 's|/usr/sbin/kamailio|/usr/sbin/kamailio --atexit=no|' pkg/kamailio/obs/kamailio.service
%endif
%build
ln -s ../obs pkg/kamailio/%{dist_name}/%{dist_version}
%if 0%{?fedora} || 0%{?suse_version} || 0%{?rhel} == 8

@ -1 +1,6 @@
D /run/kamailio 0700 kamailio kamailio -
x /run/kamailio/kamailio_ctl
x /run/kamailio/kamailio.pid
x /run/kamailio/kamailio_rpc.fifo
x /run/kamailio/kamailio_rpc.sock
d /run/kamailio 0700 kamailio kamailio 7d

@ -106,7 +106,7 @@ INSTALL_FLAVOUR=$(FLAVOUR)
# version number
VERSION = 5
PATCHLEVEL = 4
SUBLEVEL = 1
SUBLEVEL = 4
EXTRAVERSION =
# memory manager switcher

@ -2,6 +2,6 @@
* DO NOT EDIT IT
*/
#define REPO_VER "09fd6a"
#define REPO_HASH "09fd6a"
#define REPO_VER "e16352"
#define REPO_HASH "e16352"
#define REPO_STATE ""

@ -39,8 +39,12 @@
#include "select.h"
#include "cfg.tab.h"
#include "sr_compat.h"
#include "daemonize.h"
#include "ppcfg.h"
static void ksr_yy_fatal_error(const char* msg);
#define YY_FATAL_ERROR(msg) ksr_yy_fatal_error(msg);
/* states */
#define INITIAL_S 0
#define COMMENT_S 1
@ -1271,7 +1275,7 @@ IMPORTFILE "import_file"
LM_CRIT(
"error at %s line %d: '-' not allowed\n",
(finame)?finame:"cfg", line);
exit(-1);
ksr_exit(-1);
}
<DEFINE_ID>{ID} { count();
if (pp_define(yyleng, yytext)) return 1;
@ -1304,7 +1308,7 @@ IMPORTFILE "import_file"
LM_CRIT(
"error at %s line %d: '-' not allowed\n",
(finame)?finame:"cfg", line);
exit(-1);
ksr_exit(-1);
}
<IFDEF_ID>{ID} { count();
pp_ifdef_var(yyleng, yytext);
@ -1351,7 +1355,7 @@ IMPORTFILE "import_file"
if(sr_push_yy_state(s_buf.s, 0)<0)
{
LOG(L_CRIT, "error at %s line %d\n", (finame)?finame:"cfg", line);
exit(-1);
ksr_exit(-1);
}
memset(&s_buf, 0, sizeof(s_buf));
BEGIN(INITIAL);
@ -1365,7 +1369,7 @@ IMPORTFILE "import_file"
if(sr_push_yy_state(s_buf.s, 1)<0)
{
LM_CRIT("error at %s line %d\n", (finame)?finame:"cfg", line);
exit(-1);
ksr_exit(-1);
}
memset(&s_buf, 0, sizeof(s_buf));
BEGIN(INITIAL);
@ -1459,7 +1463,7 @@ static char* addstr(struct str_buf* dst_b, char* src, int len)
return dst_b->s;
error:
PKG_MEM_CRITICAL;
exit(-1);
ksr_exit(-1);
}
@ -1970,3 +1974,12 @@ static void pp_endif()
pp_update_state();
}
static void ksr_yy_fatal_error(const char* msg)
{
if(ksr_atexit_mode==1) {
yy_fatal_error(msg);
}
fprintf( stderr, "%s\n", msg );
_exit( YY_EXIT_FAILURE );
}

@ -69,6 +69,7 @@
#include "ppcfg.h"
#include "pvapi.h"
#include "config.h"
#include "daemonize.h"
#include "cfg_core.h"
#include "cfg/cfg.h"
#ifdef CORE_TLS
@ -3436,7 +3437,7 @@ cmd:
if (mod_func_action != NULL) {
LM_ERR("function used inside params of another function: %s\n", $1);
yyerror("use of function execution inside params not allowed\n");
exit(-1);
ksr_exit(-1);
}
mod_func_action = mk_action(MODULE0_T, 2, MODEXP_ST, NULL, NUMBER_ST, 0);
} LPAREN func_params RPAREN {
@ -3456,7 +3457,7 @@ cmd:
}else{
if (mod_func_action && mod_f_params_pre_fixup(mod_func_action)<0) {
/* error messages are printed inside the function */
free_mod_func_action(mod_func_action);
/* free_mod_func_action(mod_func_action); */
mod_func_action = 0;
YYERROR;
}

@ -111,7 +111,10 @@
#define COMP_PARAM ";comp="
#define COMP_PARAM_LEN (sizeof(COMP_PARAM)-1)
#define SOCKNAME_PARAM ";sn="
#define SOCKNAME_ATTR "sn"
#define SOCKNAME_ATTR_LEN (sizeof(SOCKNAME_ATTR)-1)
#define SOCKNAME_PARAM ";" SOCKNAME_ATTR "="
#define SOCKNAME_PARAM_LEN (sizeof(SOCKNAME_PARAM)-1)
#define SIGCOMP_NAME "sigcomp"

@ -297,14 +297,14 @@ int daemonize(char* name, int status_wait)
goto error;
}else if (pid!=0){
if (status_wait) {
if (daemon_status_wait(&pipe_status) == 0)
exit((int)pipe_status);
else{
if (daemon_status_wait(&pipe_status) == 0) {
ksr_exit((int)pipe_status);
} else {
LM_ERR("Main process exited before writing to pipe\n");
exit(-1);
ksr_exit(-1);
}
}
exit(0);
ksr_exit(0);
}
if (status_wait)
daemon_status_no_wait(); /* clean unused read fd */
@ -320,7 +320,7 @@ int daemonize(char* name, int status_wait)
goto error;
}else if (pid!=0){
/*parent process => exit */
exit(0);
ksr_exit(0);
}
}

@ -41,6 +41,16 @@ int daemon_status_send(char status);
void daemon_status_no_wait(void);
void daemon_status_on_fork_cleanup(void);
extern int ksr_atexit_mode;
#define ksr_exit(excode) do { \
if(ksr_atexit_mode==1) { \
exit(excode); \
} else { \
_exit(excode); \
} \
} while(0)
#endif /*_daemonize_h */
/* vi: set ts=4 sw=4 tw=79:ai:cindent: */

@ -456,14 +456,17 @@ struct lump* anchor_lump2(struct sip_msg* msg, int offset, int len,
}
/**
* free lump content
*/
void free_lump(struct lump* lmp)
{
if (lmp && (lmp->op==LUMP_ADD)){
if (lmp->u.value){
if (lmp->flags &(LUMPFLAG_DUPED|LUMPFLAG_SHMEM)){
if (lmp && (lmp->op==LUMP_ADD)) {
if (lmp->u.value) {
if (lmp->flags & LUMPFLAG_SHMEM) {
LM_CRIT("non free-able lump: %p flags=%x\n", lmp, lmp->flags);
abort();
}else{
} else if(!(lmp->flags & LUMPFLAG_DUPED)) {
pkg_free(lmp->u.value);
lmp->u.value=0;
lmp->len=0;

@ -2488,37 +2488,6 @@ struct hostent* dns_resolvehost(char* name)
}
#if 0
/* resolves a host name trying NAPTR, SRV, A & AAAA lookups, for details
* see dns_sip_resolve()
* FIXME: this version will return only the first ip
* returns: hostent struct & *port filled with the port from the SRV record;
* 0 on error
*/
struct hostent* dns_sip_resolvehost(str* name, unsigned short* port,
char* proto)
{
struct dns_srv_handle h;
struct ip_addr ip;
int ret;
if ((cfg_get(core, core_cfg, use_dns_cache==0)) || (dns_hash==0)){
/* not init or off => use normal, non-cached version */
return _sip_resolvehost(name, port, proto);
}
dns_srv_handle_init(&h);
ret=dns_sip_resolve(&h, name, &ip, port, proto, dns_flags);
dns_srv_handle_put(&h);
if (ret>=0)
return ip_addr2he(name, &ip);
return 0;
}
#endif
/* resolves a host name trying SRV lookup if *port==0 or normal A/AAAA lookup
* if *port!=0.
* when performing SRV lookup (*port==0) it will use proto to look for
@ -3292,6 +3261,7 @@ inline static int dns_naptr_sip_resolve(struct dns_srv_handle* h, str* name,
ret=-E_DNS_NO_NAPTR;
if(proto) origproto=*proto;
else origproto = PROTO_NONE;
if (dns_hash==0){ /* not init => use normal, non-cached version */
LM_WARN("called before dns cache initialization\n");
h->srv=h->a=0;
@ -3323,6 +3293,9 @@ inline static int dns_naptr_sip_resolve(struct dns_srv_handle* h, str* name,
}
try_lookup_naptr = 1;
}
/* check if it's an ip address, dns_srv_sip_resolve will return the right failure */
if (str2ip(name) || str2ip6(name))
goto naptr_not_found;
/* do naptr lookup */
if ((e=dns_get_entry(name, T_NAPTR))==0)
goto naptr_not_found;

@ -334,6 +334,7 @@ int sr_event_exec(int type, sr_event_param_t *evp)
&& _sr_events_list.sip_reply_out[i]; i++) {
ret |= _sr_events_list.sip_reply_out[i](evp);
}
return ret;
} else return 1;
default:
return -1;

@ -851,6 +851,12 @@ static int sr_kemi_core_is_method_in(sip_msg_t *msg, str *vmethod)
return SR_KEMI_TRUE;
}
break;
case 'E':
case 'e':
if(imethod==METHOD_PRACK) {
return SR_KEMI_TRUE;
}
break;
case 'P':
case 'p':
if(imethod==METHOD_PUBLISH) {

@ -16,8 +16,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*!
@ -35,20 +35,21 @@
enum lump_op { LUMP_NOP=0, LUMP_DEL, LUMP_ADD, LUMP_ADD_SUBST, LUMP_ADD_OPT };
enum lump_subst{ SUBST_NOP=0, /* do nothing */
SUBST_RCV_IP, SUBST_SND_IP, /* add ip address */
SUBST_RCV_PORT, SUBST_SND_PORT, /* add port no */
SUBST_RCV_PROTO, SUBST_SND_PROTO, /* add protocol(udp,tcp,tls)*/
SUBST_RCV_ALL, SUBST_SND_ALL, /* ip:port;transport=proto */
SUBST_RCV_ALL_EX, SUBST_SND_ALL_EX /* ip:port;transport=proto;sn=xyz */
};
enum lump_subst{ SUBST_NOP=0, /* do nothing */
SUBST_RCV_IP, SUBST_SND_IP, /* add ip address */
SUBST_RCV_PORT, SUBST_SND_PORT, /* add port no */
SUBST_RCV_PROTO, SUBST_SND_PROTO, /* add protocol(udp,tcp,tls)*/
SUBST_RCV_ALL, SUBST_SND_ALL, /* ip:port;transport=proto */
SUBST_RCV_ALL_EX, SUBST_SND_ALL_EX /* ip:port;transport=proto;sn=xyz */
};
/* Where:
SND = sending, e.g the src ip of the outgoing message
RCV = received e.g the dst ip of the original incoming msg,
or the ip of the ser socket on which the msg was received
For SUBST_{RCV,SND}_ALL, :port is added only if port!=5060
and transport=proto only if proto!=udp
*/
* SND = sending, e.g the src ip of the outgoing message
* RCV = received e.g the dst ip of the original incoming msg,
* or the ip of the ser socket on which the msg was received
* For SUBST_{RCV,SND}_ALL, :port is added only if port!=5060
* and transport=proto only if proto!=udp
*/
enum lump_conditions { COND_FALSE, /* always false */
COND_TRUE, /* always true */
@ -59,14 +60,20 @@ enum lump_conditions { COND_FALSE, /* always false */
COND_IF_DIFF_IP, /* true if RCV ip != SND ip */
COND_IF_RAND /* 50-50 random prob.of being true*/
};
/* Where:
REALM= ip_addr:port:proto
af = address family (ipv4 or ipv6)
proto = protocol (tcp, udp, tls)
/* Where:
* REALM= ip_addr:port:proto
* af = address family (ipv4 or ipv6)
* proto = protocol (tcp, udp, tls)
*/
enum lump_flag { LUMPFLAG_NONE=0, LUMPFLAG_DUPED=1, LUMPFLAG_SHMEM=2,
LUMPFLAG_BRANCH=4, LUMPFLAG_COND_TRUE=8 };
enum lump_flag { LUMPFLAG_NONE=0, /* */
LUMPFLAG_DUPED=1, /* lump struct duplicated in pkg, with value
* pointing to initial lump structure
* - e.g., used for branch_route execution */
LUMPFLAG_SHMEM=2, /* lump stored in shared memory (e.g., tm) */
LUMPFLAG_BRANCH=4, /* not in use ?!? */
LUMPFLAG_COND_TRUE=8 /* conditional lump processing */
};
#define LUMP_SET_COND_TRUE(_lump) (_lump)->flags |= LUMPFLAG_COND_TRUE
#define LUMP_IS_COND_TRUE(_lump) ((_lump)->flags & LUMPFLAG_COND_TRUE)
@ -74,7 +81,7 @@ enum lump_flag { LUMPFLAG_NONE=0, LUMPFLAG_DUPED=1, LUMPFLAG_SHMEM=2,
typedef struct lump{
enum _hdr_types_t type; /* HDR_VIA_T, HDR_OTHER_T (0), ... */
enum lump_op op; /* DEL, ADD, NOP, UNSPEC(=0) */
union{
int offset; /* used for DEL, MODIFY */
enum lump_subst subst; /*what to subst: ip addr, port, proto*/
@ -82,13 +89,13 @@ typedef struct lump{
char * value; /* used for ADD */
}u;
int len; /* length of this header field */
struct lump* before; /* list of headers to be inserted in front of the
current one */
struct lump* after; /* list of headers to be inserted immediately after
the current one */
struct lump* after; /* list of headers to be inserted immediately after
* the current one */
struct lump* next;
enum lump_flag flags; /* additional hints for use from TM's shmem */
@ -98,7 +105,7 @@ typedef struct lump{
/*
* hdrs must be kept sorted after their offset (DEL, NOP, UNSPEC)
* and/or their position (ADD). E.g.:
* - to delete header Z insert it in to the list according to its offset
* - to delete header Z insert it in to the list according to its offset
* and with op=DELETE
* - if you want to add a new header X after a header Y, insert Y in the list
* with op NOP and after it X (op ADD).
@ -107,11 +114,11 @@ typedef struct lump{
* -if you want to replace Y with X, insert Y with op=DELETE and then X with
* op=ADD.
* before and after must contain only ADD ops!
*
*
* Difference between "after" & "next" when Adding:
* "after" forces the new header immediately after the current one while
* "next" means another header can be inserted between them.
*
*
*/
/* frees the content of a lump struct */

@ -3251,7 +3251,12 @@ int sip_msg_update_buffer(sip_msg_t *msg, str *obuf)
LM_ERR("invalid buffer parameter\n");
return -1;
}
#ifdef USE_TCP
if(tcp_get_clone_rcvbuf()==0) {
LM_ERR("tcp clone received buffer not enabled\n");
return -1;
}
#endif
if(obuf->len >= BUF_SIZE) {
LM_ERR("new buffer is too large (%d)\n", obuf->len);
return -1;
@ -3276,6 +3281,7 @@ int sip_msg_update_buffer(sip_msg_t *msg, str *obuf)
/* restore msg fields */
msg->buf = tmp.buf;
msg->id = tmp.id;
msg->pid = tmp.pid;
msg->rcv = tmp.rcv;
msg->set_global_address = tmp.set_global_address;
msg->set_global_port = tmp.set_global_port;

@ -169,9 +169,9 @@ char* get_hdr_field(char* const buf, char* const end, struct hdr_field* const hd
hdr->body.len=tmp-hdr->body.s;
DBG("<%.*s> [%d]; uri=[%.*s]\n", hdr->name.len, ZSW(hdr->name.s),
hdr->body.len, to_b->uri.len, ZSW(to_b->uri.s));
DBG("to body [%.*s], to tag [%.*s]\n", to_b->body.len,
ZSW(to_b->body.s), to_b->tag_value.len,
ZSW(to_b->tag_value.s));
DBG("to body (%d)[%.*s], to tag (%d)[%.*s]\n", to_b->body.len,
to_b->body.len, ZSW(to_b->body.s), to_b->tag_value.len,
to_b->tag_value.len, ZSW(to_b->tag_value.s));
break;
case HDR_CONTENTLENGTH_T:
hdr->body.s=tmp;

@ -296,7 +296,8 @@ static inline int do_duplicate_rr(rr_t** _new, rr_t* _r, int _shm)
} else {
PKG_MEM_ERROR;
}
return -2;
ret = -2;
goto error;
}
memcpy(res, it, sizeof(rr_t));
@ -313,7 +314,8 @@ static inline int do_duplicate_rr(rr_t** _new, rr_t* _r, int _shm)
LM_ERR("Error while duplicating parameters\n");
if (_shm) shm_free(res);
else pkg_free(res);
return -3;
ret = -3;
goto error;
}
xlate_pointers(it, res);
@ -327,6 +329,18 @@ static inline int do_duplicate_rr(rr_t** _new, rr_t* _r, int _shm)
it = it->next;
}
return 0;
error:
if(*_new != NULL) {
if (_shm) {
shm_free_rr(_new);
} else {
free_rr(_new);
}
*_new = NULL;
}
return ret;
}

@ -80,7 +80,7 @@ int pp_subst_add(char *data)
}
pp_subst_rules_tail = pr;
LM_INFO("### added subst expression: %s\n", data);
LM_DBG("### added subst expression: [%s]\n", data);
return 0;
}

@ -1070,6 +1070,7 @@ error:
req.g.rtgen_family = family;\
} while(0);
#define NETLINK_BUFFER_SIZE 32768
static int get_flags(int family){
struct {
@ -1079,12 +1080,12 @@ static int get_flags(int family){
int rtn = 0;
struct nlmsghdr* nlp;
struct ifinfomsg *ifi;
char buf[8192];
char buf[NETLINK_BUFFER_SIZE];
char *p = buf;
int nll = 0;
int nl_sock = -1;
fill_nl_req(req, RTM_GETLINK, AF_INET);
fill_nl_req(req, RTM_GETLINK, family);
if((nl_sock = nl_bound_sock()) < 0) return -1;
@ -1095,6 +1096,10 @@ static int get_flags(int family){
}
while(1) {
if ((sizeof(buf) - nll) == 0) {
LM_ERR("netlink buffer overflow in get_flags");
goto error;
}
rtn = recv(nl_sock, p, sizeof(buf) - nll, 0);
nlp = (struct nlmsghdr *) p;
if(nlp->nlmsg_type == NLMSG_DONE){
@ -1148,7 +1153,7 @@ static int build_iface_list(void)
struct nlmsghdr* nlp;
struct ifaddrmsg *ifi;
int rtl;
char buf[8192];
char buf[NETLINK_BUFFER_SIZE];
char *p = buf;
int nll = 0;
struct rtattr * rtap;
@ -1184,6 +1189,10 @@ static int build_iface_list(void)
nll = 0;
p = buf;
while(1) {
if ((sizeof(buf) - nll) == 0) {
LM_ERR("netlink buffer overflow in build_iface_list");
goto error;
}
rtn = recv(nl_sock, p, sizeof(buf) - nll, 0);
LM_DBG("received %d byles \n", rtn);
nlp = (struct nlmsghdr *) p;
@ -2142,7 +2151,7 @@ void init_proto_order()
/**
* parse '[port:]host[:port]' string to a broken down structure
* parse '[proto:]host[:port]' string to a broken down structure
*/
int parse_protohostport(str* ins, sr_phostp_t *r)
{
@ -2230,7 +2239,7 @@ error_port:
}
/**
* lookup a local socket by '[port:]host[:port]' string
* lookup a local socket by '[proto:]host[:port]' string
*/
struct socket_info* lookup_local_socket(str *phostp)
{

@ -43,6 +43,8 @@
#include "sr_compat.h"
#include "ppcfg.h"
#include "async_task.h"
#include "shm_init.h"
#include "daemonize.h"
#include <sys/stat.h>
#include <regex.h>
@ -109,6 +111,24 @@ unsigned int set_modinit_delay(unsigned int v)
return r;
}
/* shut down phase for instance - kept in shared memory */
static int *_ksr_shutdown_phase = NULL;
int ksr_shutdown_phase_init(void)
{
if((_ksr_shutdown_phase == NULL) && (shm_initialized())) {
_ksr_shutdown_phase = (int*)shm_mallocxz(sizeof(int));
}
return 0;
}
/**
* return destroy modules phase state
*/
int ksr_shutdown_phase(void)
{
return (_ksr_shutdown_phase)?(*_ksr_shutdown_phase):0;
}
/* keep state if server is in destroy modules phase */
static int _sr_destroy_modules_phase = 0;
@ -521,7 +541,7 @@ reload:
}
/* version control */
if (!version_control(handle, path)) {
exit(-1);
ksr_exit(-1);
}
/* launch register */
mr = (mod_register_function)dlsym(handle, "mod_register");
@ -738,6 +758,12 @@ void destroy_modules()
struct sr_module* t, *foo;
_sr_destroy_modules_phase = 1;
if(_ksr_shutdown_phase!=NULL) {
*_ksr_shutdown_phase = 1;
}
LM_DBG("starting modules destroy phase\n");
/* call first destroy function from each module */
t=modules;
while(t) {

@ -544,5 +544,7 @@ int is_rpc_worker(int rank);
unsigned int set_modinit_delay(unsigned int v);
int destroy_modules_phase(void);
int ksr_shutdown_phase_init(void);
int ksr_shutdown_phase(void);
#endif /* sr_module_h */

@ -40,13 +40,16 @@
* need to make a zero-terminated copy of it.
*
* @section drawbacks Drawbacks
* Note well that the fact that string stored
* using this data structure are not zero terminated makes them a little
* incovenient to use with many standard libc string functions, because these
* usually expect the input to be zero-terminated. In this case you have to
* either make a zero-terminated copy or inject the terminating zero behind
* the actuall string (if possible). Note that injecting a zero terminating
* characters is considered to be dangerous.
* Note well that the fact that a string stored
* using this data structure are not guaranteed to be zero terminated (by
* default they're not) makes them a little incovenient to use with many
* standard libc string functions, because these usually expect the input
* to be zero-terminated.
* In this case you have to either make a zero-terminated copy or inject the
* terminating zero behind the actuall string (if possible). Note that
* injecting a zero terminating characters is considered to be dangerous.
* The functions shm_str_dup() and pkg_str_dup() will always create a
* zero-terminated copy.
*/
/** @file

@ -95,6 +95,7 @@
#include "tcp_info.h"
#include "tcp_options.h"
#include "ut.h"
#include "events.h"
#include "cfg/cfg_struct.h"
#include <fcntl.h> /* must be included after io_wait.h if SIGIO_RT is used */
@ -5135,4 +5136,88 @@ void tcp_get_info(struct tcp_gen_info *ti)
#endif /* TCP_ASYNC */
}
/* finds an ws/wss tcpconn & sends on it
* uses the dst members to, proto (ws/wss) and id and tries to send
* returns: number of bytes written (>=0) on success
* <0 on error */
int wss_send(dest_info_t* dst, const char* buf, unsigned len)
{
int port;
struct ip_addr ip;
union sockaddr_union* from = NULL;
union sockaddr_union local_addr;
struct tcp_connection *con = NULL;
struct ws_event_info wsev;
sr_event_param_t evp = {0};
int ret;
if (unlikely((dst->proto == PROTO_WS
#ifdef USE_TLS
|| dst->proto == PROTO_WSS
#endif
) && sr_event_enabled(SREV_TCP_WS_FRAME_OUT))) {
if (unlikely(dst->send_flags.f & SND_F_FORCE_SOCKET
&& dst->send_sock)) {
local_addr = dst->send_sock->su;
#ifdef SO_REUSEPORT
if (cfg_get(tcp, tcp_cfg, reuse_port)) {
LM_DBG("sending to: %s, force_socket=%d, send_sock=%p\n",
su2a(&dst->to,sizeof(struct sockaddr_in)),
(dst->send_flags.f & SND_F_FORCE_SOCKET),
dst->send_sock);
su_setport(&local_addr, dst->send_sock->port_no);
}
else
su_setport(&local_addr, 0); /* any local port will do */
#else
su_setport(&local_addr, 0); /* any local port will do */
#endif
from = &local_addr;
}
port = su_getport(&dst->to);
if (likely(port)) {
su2ip_addr(&ip, &dst->to);
if(tcp_connection_match==TCPCONN_MATCH_STRICT) {
con = tcpconn_lookup(dst->id, &ip, port, from,
(dst->send_sock)?dst->send_sock->port_no:0, 0);
} else {
con = tcpconn_get(dst->id, &ip, port, from, 0);
}
}
else if (likely(dst->id))
con = tcpconn_get(dst->id, 0, 0, 0, 0);
else {
LM_CRIT("null_id & to\n");
goto error;
}
if (con == NULL) {
LM_WARN("TCP/TLS connection for WebSocket could not be found\n");
goto error;
}
memset(&wsev, 0, sizeof(ws_event_info_t));
wsev.type = SREV_TCP_WS_FRAME_OUT;
wsev.buf = (char*)buf;
wsev.len = len;
wsev.id = con->id;
evp.data = (void *)&wsev;
ret = sr_event_exec(SREV_TCP_WS_FRAME_OUT, &evp);
tcpconn_put(con);
goto done;
} else {
LM_CRIT("used with invalid proto %d\n", dst->proto);
goto error;
}
done:
return ret;
error:
return -1;
}
#endif /* USE_TCP */

@ -157,6 +157,7 @@ void tcp_options_get(struct cfg_group_tcp* t);
#ifdef USE_TCP
int tcp_set_clone_rcvbuf(int v);
int tcp_get_clone_rcvbuf(void);
#endif /* USE_TCP */
#endif /* tcp_options_h */

@ -52,6 +52,7 @@
#include "ut.h"
#include "trim.h"
#include "pt.h"
#include "daemonize.h"
#include "cfg/cfg_struct.h"
#ifdef CORE_TLS
#include "tls/tls_server.h"
@ -109,6 +110,11 @@ int tcp_set_clone_rcvbuf(int v)
return r;
}
int tcp_get_clone_rcvbuf(void)
{
return tcp_clone_rcvbuf;
}
#ifdef READ_HTTP11
static inline char *strfindcasestrz(str *haystack, char *needlez)
{
@ -311,12 +317,14 @@ again:
}
}else if (unlikely((bytes_read==0) ||
(*flags & RD_CONN_FORCE_EOF))){
LM_DBG("EOF on connection %p (state: %u, flags: %x) - FD %d,"
" bytes %d, rd-flags %x ([%s]:%u -> [%s]:%u)",
c, c->state, c->flags, fd, bytes_read, *flags,
ip_addr2a(&c->rcv.src_ip), c->rcv.src_port,
ip_addr2a(&c->rcv.dst_ip), c->rcv.dst_port);
c->state=S_CONN_EOF;
*flags|=RD_CONN_EOF;
tcp_emit_closed_event(c, TCP_CLOSED_EOF);
LM_DBG("EOF on %p, FD %d ([%s]:%u ->", c, fd,
ip_addr2a(&c->rcv.src_ip), c->rcv.src_port);
LM_DBG("-> [%s]:%u)\n", ip_addr2a(&c->rcv.dst_ip), c->rcv.dst_port);
}else{
if (unlikely(c->state==S_CONN_CONNECT || c->state==S_CONN_ACCEPT)){
TCP_STATS_ESTABLISHED(c->state);
@ -2022,7 +2030,7 @@ void tcp_receive_loop(int unix_sock)
error:
destroy_io_wait(&io_w);
LM_CRIT("exiting...");
exit(-1);
ksr_exit(-1);
}

@ -13,8 +13,8 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
@ -33,7 +33,7 @@ int tcp_send(struct dest_info* dst, union sockaddr_union* from,
int tcpconn_add_alias(int id, int port, int proto);
int wss_send(dest_info_t* dst, const char* buf, unsigned len);
#endif

@ -745,9 +745,33 @@ static inline int strz2sint(char* _s, int* _r)
return 0;
}
/**
* duplicate str structure and content in a single shm block
*/
static inline str* shm_str_dup_block(const str* src)
{
str *dst;
if(src==NULL) {
return NULL;
}
dst = (str*)shm_malloc(sizeof(str) + src->len + 1);
if (dst == NULL) {
SHM_MEM_ERROR;
return NULL;
}
memset(dst, 0, sizeof(str) + src->len + 1);
dst->s = (char*)dst + sizeof(str);
dst->len = src->len;
memcpy(dst->s, src->s, src->len);
return dst;
}
/**
* \brief Make a copy of a str structure to a str using shm_malloc
* The copy will be zero-terminated
* \param dst destination
* \param src source
* \return 0 on success, -1 on failure
@ -775,7 +799,7 @@ static inline int shm_str_dup(str* dst, const str* src)
dst->len = src->len;
}
dst->s = (char*)shm_malloc(dst->len);
dst->s = (char*)shm_malloc(dst->len+1);
if (dst->s == NULL) {
SHM_MEM_ERROR;
return -1;
@ -788,6 +812,7 @@ static inline int shm_str_dup(str* dst, const str* src)
}
memcpy(dst->s, src->s, dst->len);
dst->s[dst->len] = 0;
return 0;
}
@ -848,6 +873,7 @@ static inline char* shm_str2char_dup(str *src)
/**
* \brief Make a copy of a str structure using pkg_malloc
* The copy will be zero-terminated
* \param dst destination
* \param src source
* \return 0 on success, -1 on failure
@ -875,7 +901,7 @@ static inline int pkg_str_dup(str* dst, const str* src)
dst->len = src->len;
}
dst->s = (char*)pkg_malloc(dst->len);
dst->s = (char*)pkg_malloc(dst->len+1);
if (dst->s == NULL) {
PKG_MEM_ERROR;
return -1;
@ -888,6 +914,7 @@ static inline int pkg_str_dup(str* dst, const str* src)
}
memcpy(dst->s, src->s, dst->len);
dst->s[dst->len] = 0;
return 0;
}

@ -454,6 +454,8 @@ static int xavp_rm_internal(str *name, sr_xavp_t **head, int idx)
if(idx>=0)
return 1;
count++;
} else {
prv = foo;
}
n++;
} else {
@ -1851,6 +1853,8 @@ static int xavi_rm_internal(str *name, sr_xavp_t **head, int idx)
if(idx>=0)
return 1;
count++;
} else {
prv = foo;
}
n++;
} else {

@ -477,8 +477,12 @@ int db_check_table_version(db_func_t* dbf, db1_con_t* dbh, const str* table,
*/
int db_use_table(db1_con_t* _h, const str* _t)
{
if (!_h || !_t || !_t->s) {
LM_ERR("invalid parameter value\n");
if (!_h) {
LM_ERR("invalid connection parameter\n");
return -1;
}
if (!_t || !_t->s) {
LM_ERR("invalid table parameter value\n");
return -1;
}

@ -59,7 +59,7 @@
<type>string</type>
<size>&user_len;</size>
<default/>
<description>Name of column contains the the scan prefixes. Scan prefixes define the matching
<description>Name of column contains the scan prefixes. Scan prefixes define the matching
portion of a phone number, e.g. we have the scan prefixes 49721 and 49, the called number is
49721913740, it matches 49721, because the longest match is taken. If no prefix matches,
the number is not failure routed. To prevent this, an empty prefix value of <quote></quote>

@ -164,6 +164,10 @@ Options:\n\
disable with no or off\n\
--alias=val Add an alias, the value has to be '[proto:]hostname[:port]'\n\
(like for 'alias' global parameter)\n\
--atexit=val Control atexit callbacks execution from external libraries\n\
which may access destroyed shm memory causing crash on shutdown.\n\
Can be y[es] or 1 to enable atexit callbacks, n[o] or 0 to disable,\n\
default is yes.\n\
-A define Add config pre-processor define (e.g., -A WITH_AUTH,\n\
-A 'FLT_ACC=1', -A 'DEFVAL=\"str-val\"')\n\
-b nr Maximum receive buffer size which will not be exceeded by\n\
@ -533,6 +537,8 @@ char *sr_memmng_shm = NULL;
static int *_sr_instance_started = NULL;
int ksr_atexit_mode = 1;
/**
* return 1 if all child processes were forked
* - note: they might still be in init phase (i.e., child init)
@ -735,7 +741,7 @@ void handle_sigs(void)
LM_NOTICE("Thank you for flying " NAME "!!!\n");
/* shutdown/kill all the children */
shutdown_children(SIGTERM, 1);
exit(0);
ksr_exit(0);
break;
case SIGUSR1:
@ -805,9 +811,9 @@ void handle_sigs(void)
/* exit */
shutdown_children(SIGTERM, 1);
if (WIFSIGNALED(chld_status)) {
exit(1);
ksr_exit(1);
} else {
exit(0);
ksr_exit(0);
}
break;
@ -1933,6 +1939,7 @@ int main(int argc, char** argv)
{"modparam", required_argument, 0, KARGOPTVAL + 6},
{"log-engine", required_argument, 0, KARGOPTVAL + 7},
{"debug", required_argument, 0, KARGOPTVAL + 8},
{"atexit", required_argument, 0, KARGOPTVAL + 10},
{0, 0, 0, 0 }
};
@ -2002,6 +2009,16 @@ int main(int argc, char** argv)
goto error;
}
break;
case KARGOPTVAL+10:
if(optarg[0]=='y' || optarg[0]=='1') {
ksr_atexit_mode = 1;
} else if(optarg[0]=='n' || optarg[0]=='0') {
ksr_atexit_mode = 0;
} else {
LM_ERR("bad atexit value: %s\n", optarg);
goto error;
}
break;
default:
if (c == 'h' || (optarg && strcmp(optarg, "-h") == 0)) {
@ -2164,6 +2181,7 @@ int main(int argc, char** argv)
case KARGOPTVAL+6:
case KARGOPTVAL+7:
case KARGOPTVAL+8:
case KARGOPTVAL+10:
break;
/* long options */
@ -2541,6 +2559,8 @@ try_again:
if (ksr_route_locks_set_init()<0)
goto error;
ksr_shutdown_phase_init();
/* init lookup for core event routes */
sr_core_ert_init();
@ -2864,7 +2884,7 @@ try_again:
strerror(errno), errno);
}
/* else terminate process */
return ret;
ksr_exit(ret);
error:
/*kill everything*/
@ -2874,7 +2894,7 @@ error:
fprintf(stderr, "error sending exit status: %s [%d]\n",
strerror(errno), errno);
}
return -1;
ksr_exit(-1);
}

@ -20,9 +20,6 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* History:
* --------
* 2004-09-01: first version (ramona)
*/
@ -43,6 +40,8 @@
MODULE_VERSION
/* clang-format off */
/* Module destroy function prototype */
static void destroy(void);
@ -122,23 +121,23 @@ struct module_exports exports = {
child_init, /* per-child·init·function */
destroy /* destroy function */
};
/* clang-format on */
static int alias_flags_fixup(void** param)
static int alias_flags_fixup(void **param)
{
char *c;
unsigned int flags;
c = (char*)*param;
c = (char *)*param;
flags = 0;
if(alias_db_use_domain) {
flags |= ALIAS_DOMAIN_FLAG;
}
while (*c) {
switch (*c)
{
while(*c) {
switch(*c) {
case 'd':
case 'D':
flags &= ~ALIAS_DOMAIN_FLAG;
@ -152,61 +151,58 @@ static int alias_flags_fixup(void** param)
flags |= ALIAS_DOMAIN_FLAG;
break;
default:
LM_ERR("unsupported flag '%c'\n",*c);
LM_ERR("unsupported flag '%c'\n", *c);
return -1;
}
c++;
}
pkg_free(*param);
*param = (void*)(unsigned long)flags;
*param = (void *)(unsigned long)flags;
return 0;
}
static int lookup_fixup(void** param, int param_no)
static int lookup_fixup(void **param, int param_no)
{
if (param_no==1)
{
if(param_no == 1) {
/* string or pseudo-var - table name */
return fixup_spve_null(param, 1);
} else if (param_no==2) {
} else if(param_no == 2) {
/* string - flags ? */
return alias_flags_fixup(param);
} else {
LM_CRIT(" invalid number of params %d \n",param_no);
LM_CRIT(" invalid number of params %d \n", param_no);
return -1;
}
}
static int find_fixup(void** param, int param_no)
static int find_fixup(void **param, int param_no)
{
pv_spec_t *sp;
if (param_no==1)
{
if(param_no == 1) {
/* string or pseudo-var - table name */
return fixup_spve_null(param, 1);
} else if(param_no==2) {
} else if(param_no == 2) {
/* pseudo-var - source URI */
return fixup_pvar_null(param, 1);
} else if(param_no==3) {
} else if(param_no == 3) {
/* pvar (AVP or VAR) - destination URI */
if (fixup_pvar_null(param, 1))
if(fixup_pvar_null(param, 1))
return E_CFG;
sp = (pv_spec_t*)*param;
if (sp->type!=PVT_AVP && sp->type!=PVT_SCRIPTVAR)
{
sp = (pv_spec_t *)*param;
if(sp->type != PVT_AVP && sp->type != PVT_SCRIPTVAR) {
LM_ERR("PV type %d (param 3) cannot be written\n", sp->type);
pv_spec_free(sp);
return E_CFG;
}
return 0;
} else if (param_no==4) {
} else if(param_no == 4) {
/* string - flags ? */
return alias_flags_fixup(param);
} else {
LM_CRIT(" invalid number of params %d \n",param_no);
LM_CRIT(" invalid number of params %d \n", param_no);
return -1;
}
}
@ -217,17 +213,15 @@ static int find_fixup(void** param, int param_no)
*/
static int child_init(int rank)
{
if (rank==PROC_INIT || rank==PROC_MAIN || rank==PROC_TCP_MAIN)
if(rank == PROC_INIT || rank == PROC_MAIN || rank == PROC_TCP_MAIN)
return 0; /* do nothing for the main process */
db_handle = adbf.init(&db_url);
if (!db_handle)
{
if(!db_handle) {
LM_ERR("unable to connect database\n");
return -1;
}
return 0;
}
@ -237,15 +231,13 @@ static int child_init(int rank)
static int mod_init(void)
{
/* Find a database module */
if (db_bind_mod(&db_url, &adbf))
{
if(db_bind_mod(&db_url, &adbf)) {
LM_ERR("unable to bind database module\n");
return -1;
}
if (!DB_CAPABILITY(adbf, DB_CAP_QUERY))
{
if(!DB_CAPABILITY(adbf, DB_CAP_QUERY)) {
LM_CRIT("database modules does not "
"provide all functions needed by alias_db module\n");
"provide all functions needed by alias_db module\n");
return -1;
}
@ -258,13 +250,13 @@ static int mod_init(void)
*/
static void destroy(void)
{
if (db_handle) {
if(db_handle) {
adbf.close(db_handle);
db_handle = 0;
}
}
static int w_alias_db_lookup1(struct sip_msg* _msg, char* _table, char* p2)
static int w_alias_db_lookup1(struct sip_msg *_msg, char *_table, char *p2)
{
str table_s;
unsigned long flags;
@ -274,7 +266,8 @@ static int w_alias_db_lookup1(struct sip_msg* _msg, char* _table, char* p2)
flags |= ALIAS_DOMAIN_FLAG;
}
if(_table==NULL || fixup_get_svalue(_msg, (gparam_p)_table, &table_s)!=0) {
if(_table == NULL
|| fixup_get_svalue(_msg, (gparam_p)_table, &table_s) != 0) {
LM_ERR("invalid table parameter\n");
return -1;
}
@ -282,20 +275,21 @@ static int w_alias_db_lookup1(struct sip_msg* _msg, char* _table, char* p2)
return alias_db_lookup_ex(_msg, table_s, flags);
}
static int w_alias_db_lookup2(struct sip_msg* _msg, char* _table, char* flags)
static int w_alias_db_lookup2(struct sip_msg *_msg, char *_table, char *flags)
{
str table_s;
if(_table==NULL || fixup_get_svalue(_msg, (gparam_p)_table, &table_s)!=0) {
if(_table == NULL
|| fixup_get_svalue(_msg, (gparam_p)_table, &table_s) != 0) {
LM_ERR("invalid table parameter\n");
return -1;
return -1;
}
return alias_db_lookup_ex(_msg, table_s, (unsigned long)flags);
}
static int w_alias_db_find3(struct sip_msg* _msg, char* _table, char* _in,
char* _out)
static int w_alias_db_find3(
struct sip_msg *_msg, char *_table, char *_in, char *_out)
{
str table_s;
unsigned long flags;
@ -305,20 +299,22 @@ static int w_alias_db_find3(struct sip_msg* _msg, char* _table, char* _in,
flags |= ALIAS_DOMAIN_FLAG;
}
if(_table==NULL || fixup_get_svalue(_msg, (gparam_p)_table, &table_s)!=0) {
if(_table == NULL
|| fixup_get_svalue(_msg, (gparam_p)_table, &table_s) != 0) {
LM_ERR("invalid table parameter\n");
return -1;
}
return alias_db_find(_msg, table_s, _in, _out, (char*)flags);
return alias_db_find(_msg, table_s, _in, _out, (char *)flags);
}
static int w_alias_db_find4(struct sip_msg* _msg, char* _table, char* _in,
char* _out, char* flags)
static int w_alias_db_find4(
struct sip_msg *_msg, char *_table, char *_in, char *_out, char *flags)
{
str table_s;
if(_table==NULL || fixup_get_svalue(_msg, (gparam_p)_table, &table_s)!=0) {
if(_table == NULL
|| fixup_get_svalue(_msg, (gparam_p)_table, &table_s) != 0) {
LM_ERR("invalid table parameter\n");
return -1;
}
@ -328,8 +324,9 @@ static int w_alias_db_find4(struct sip_msg* _msg, char* _table, char* _in,
int bind_alias_db(struct alias_db_binds *pxb)
{
if (pxb == NULL) {
LM_WARN("bind_alias_db: Cannot load alias_db API into a NULL pointer\n");
if(pxb == NULL) {
LM_WARN("bind_alias_db: Cannot load alias_db API into a NULL "
"pointer\n");
return -1;
}
@ -342,7 +339,7 @@ int bind_alias_db(struct alias_db_binds *pxb)
/**
*
*/
static int ki_alias_db_lookup(sip_msg_t* msg, str* stable)
static int ki_alias_db_lookup(sip_msg_t *msg, str *stable)
{
unsigned long flags;
@ -357,7 +354,7 @@ static int ki_alias_db_lookup(sip_msg_t* msg, str* stable)
/**
*
*/
static int ki_alias_db_lookup_ex(sip_msg_t* msg, str* stable, str* sflags)
static int ki_alias_db_lookup_ex(sip_msg_t *msg, str *stable, str *sflags)
{
unsigned long flags;
int i;
@ -366,9 +363,8 @@ static int ki_alias_db_lookup_ex(sip_msg_t* msg, str* stable, str* sflags)
if(alias_db_use_domain) {
flags |= ALIAS_DOMAIN_FLAG;
}
for(i=0; i<sflags->len; i++) {
switch (sflags->s[i])
{
for(i = 0; i < sflags->len; i++) {
switch(sflags->s[i]) {
case 'd':
case 'D':
flags &= ~ALIAS_DOMAIN_FLAG;

@ -1,6 +1,4 @@
/*
* $Id$
*
/*
* ALIAS_DB Module
*
* Copyright (C) 2004 Voice Sistem
@ -17,13 +15,10 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* History:
* --------
* 2004-09-01: first version (ramona)
*/
@ -36,13 +31,13 @@
/* Module parameters variables */
extern str user_column; /* 'username' column name */
extern str domain_column; /* 'domain' column name */
extern str alias_user_column; /* 'alias_username' column name */
extern str alias_domain_column; /* 'alias_domain' column name */
extern str user_column; /* 'username' column name */
extern str domain_column; /* 'domain' column name */
extern str alias_user_column; /* 'alias_username' column name */
extern str alias_domain_column; /* 'alias_domain' column name */
extern str domain_prefix;
extern int ald_append_branches; /* append branches after an alias lookup */
extern int ald_append_branches; /* append branches after an alias lookup */
extern db1_con_t* db_handle; /* Database connection handle */
extern db1_con_t *db_handle; /* Database connection handle */
#endif /* _ALIAS_DB_H_ */

@ -1,6 +1,4 @@
/*
* $Id$
*
/*
* ALIAS_DB Module
*
* Copyright (C) 2004 Voice Sistem SRL
@ -17,13 +15,10 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* History:
* --------
* 2004-09-01: first version (ramona)
*/
#include <string.h>
@ -41,32 +36,30 @@
#include "alias_db.h"
#include "alookup.h"
#define MAX_USERURI_SIZE 256
#define MAX_USERURI_SIZE 256
extern db_func_t adbf; /* DB functions */
extern db_func_t adbf; /* DB functions */
extern int alias_db_use_domain;
char useruri_buf[MAX_USERURI_SIZE];
typedef int (*set_alias_f)(struct sip_msg* _msg, str *alias, int no, void *p);
typedef int (*set_alias_f)(struct sip_msg *_msg, str *alias, int no, void *p);
/**
*
*/
static int alias_db_query(struct sip_msg* _msg, str table,
struct sip_uri *puri, unsigned long flags,
set_alias_f set_alias, void *param)
static int alias_db_query(struct sip_msg *_msg, str table, struct sip_uri *puri,
unsigned long flags, set_alias_f set_alias, void *param)
{
str user_s;
db_key_t db_keys[2];
db_val_t db_vals[2];
db_key_t db_cols[2];
db1_res_t* db_res = NULL;
db1_res_t *db_res = NULL;
int i;
if (flags&ALIAS_REVERSE_FLAG)
{
if(flags & ALIAS_REVERSE_FLAG) {
/* revert lookup: user->alias */
db_keys[0] = &user_column;
db_keys[1] = &domain_column;
@ -85,101 +78,96 @@ static int alias_db_query(struct sip_msg* _msg, str table,
db_vals[0].val.str_val.s = puri->user.s;
db_vals[0].val.str_val.len = puri->user.len;
if ( flags&ALIAS_DOMAIN_FLAG ) {
if(flags & ALIAS_DOMAIN_FLAG) {
db_vals[1].type = DB1_STR;
db_vals[1].nul = 0;
db_vals[1].val.str_val.s = puri->host.s;
db_vals[1].val.str_val.len = puri->host.len;
if (domain_prefix.s && domain_prefix.len>0
&& domain_prefix.len<puri->host.len
&& strncasecmp(puri->host.s,domain_prefix.s,
domain_prefix.len)==0)
{
db_vals[1].val.str_val.s += domain_prefix.len;
if(domain_prefix.s && domain_prefix.len > 0
&& domain_prefix.len < puri->host.len
&& strncasecmp(puri->host.s, domain_prefix.s, domain_prefix.len)
== 0) {
db_vals[1].val.str_val.s += domain_prefix.len;
db_vals[1].val.str_val.len -= domain_prefix.len;
}
}
adbf.use_table(db_handle, &table);
if(adbf.query( db_handle, db_keys, NULL, db_vals, db_cols,
(flags&ALIAS_DOMAIN_FLAG)?2:1 /*no keys*/, 2 /*no cols*/,
NULL, &db_res)!=0 || db_res==NULL)
{
if(adbf.query(db_handle, db_keys, NULL, db_vals, db_cols,
(flags & ALIAS_DOMAIN_FLAG) ? 2 : 1 /*no keys*/, 2 /*no cols*/,
NULL, &db_res)
!= 0
|| db_res == NULL) {
LM_ERR("failed to query database\n");
goto err_server;
}
if (RES_ROW_N(db_res)<=0 || RES_ROWS(db_res)[0].values[0].nul != 0)
{
if(RES_ROW_N(db_res) <= 0 || RES_ROWS(db_res)[0].values[0].nul != 0) {
LM_DBG("no alias found for R-URI\n");
goto err_server;
}
memcpy(useruri_buf, "sip:", 4);
for(i=0; i<RES_ROW_N(db_res); i++)
{
for(i = 0; i < RES_ROW_N(db_res); i++) {
user_s.len = 4;
user_s.s = useruri_buf+4;
switch(RES_ROWS(db_res)[i].values[0].type)
{
user_s.s = useruri_buf + 4;
switch(RES_ROWS(db_res)[i].values[0].type) {
case DB1_STRING:
strcpy(user_s.s,
(char*)RES_ROWS(db_res)[i].values[0].val.string_val);
strcpy(user_s.s,
(char *)RES_ROWS(db_res)[i].values[0].val.string_val);
user_s.len += strlen(user_s.s);
break;
break;
case DB1_STR:
strncpy(user_s.s,
(char*)RES_ROWS(db_res)[i].values[0].val.str_val.s,
RES_ROWS(db_res)[i].values[0].val.str_val.len);
strncpy(user_s.s,
(char *)RES_ROWS(db_res)[i].values[0].val.str_val.s,
RES_ROWS(db_res)[i].values[0].val.str_val.len);
user_s.len += RES_ROWS(db_res)[i].values[0].val.str_val.len;
break;
break;
case DB1_BLOB:
strncpy(user_s.s,
(char*)RES_ROWS(db_res)[i].values[0].val.blob_val.s,
RES_ROWS(db_res)[i].values[0].val.blob_val.len);
strncpy(user_s.s,
(char *)RES_ROWS(db_res)[i].values[0].val.blob_val.s,
RES_ROWS(db_res)[i].values[0].val.blob_val.len);
user_s.len += RES_ROWS(db_res)[i].values[0].val.blob_val.len;
break;
break;
default:
LM_ERR("unknown type of DB user column\n");
goto err_server;
}
/* add the @*/
useruri_buf[user_s.len] = '@';
user_s.len++;
/* add the domain */
user_s.s = useruri_buf+user_s.len;
switch(RES_ROWS(db_res)[i].values[1].type)
{
user_s.s = useruri_buf + user_s.len;
switch(RES_ROWS(db_res)[i].values[1].type) {
case DB1_STRING:
strcpy(user_s.s,
(char*)RES_ROWS(db_res)[i].values[1].val.string_val);
strcpy(user_s.s,
(char *)RES_ROWS(db_res)[i].values[1].val.string_val);
user_s.len += strlen(user_s.s);
break;
break;
case DB1_STR:
strncpy(user_s.s,
(char*)RES_ROWS(db_res)[i].values[1].val.str_val.s,
RES_ROWS(db_res)[i].values[1].val.str_val.len);
strncpy(user_s.s,
(char *)RES_ROWS(db_res)[i].values[1].val.str_val.s,
RES_ROWS(db_res)[i].values[1].val.str_val.len);
user_s.len += RES_ROWS(db_res)[i].values[1].val.str_val.len;
useruri_buf[user_s.len] = '\0';
break;
break;
case DB1_BLOB:
strncpy(user_s.s,
(char*)RES_ROWS(db_res)[i].values[1].val.blob_val.s,
RES_ROWS(db_res)[i].values[1].val.blob_val.len);
strncpy(user_s.s,
(char *)RES_ROWS(db_res)[i].values[1].val.blob_val.s,
RES_ROWS(db_res)[i].values[1].val.blob_val.len);
user_s.len += RES_ROWS(db_res)[i].values[1].val.blob_val.len;
useruri_buf[user_s.len] = '\0';
break;
break;
default:
LM_ERR("unknown type of DB user column\n");
goto err_server;
}
useruri_buf[user_s.len] = '\0';
user_s.s = useruri_buf;
/* set the URI */
LM_DBG("new URI [%d] is [%.*s]\n", i, user_s.len ,user_s.s );
if (set_alias(_msg, &user_s, i, param)!=0) {
LM_DBG("new URI [%d] is [%.*s]\n", i, user_s.len, user_s.s);
if(set_alias(_msg, &user_s, i, param) != 0) {
LM_ERR("error while setting alias\n");
goto err_server;
}
@ -188,14 +176,14 @@ static int alias_db_query(struct sip_msg* _msg, str table,
/**
* Free the DB result
*/
if (adbf.free_result(db_handle, db_res) < 0) {
if(adbf.free_result(db_handle, db_res) < 0) {
LM_DBG("failed to freeing result of query\n");
}
return 1;
err_server:
if (db_res!=NULL) {
if(db_res != NULL) {
if(adbf.free_result(db_handle, db_res) < 0) {
LM_DBG("failed to freeing result of query\n");
}
@ -203,19 +191,16 @@ err_server:
return -1;
}
int set_alias_to_ruri(struct sip_msg* _msg, str *alias, int no, void *p)
int set_alias_to_ruri(struct sip_msg *_msg, str *alias, int no, void *p)
{
/* set the RURI */
if(no==0)
{
if(rewrite_uri(_msg, alias)<0)
{
if(no == 0) {
if(rewrite_uri(_msg, alias) < 0) {
LM_ERR("cannot replace the R-URI\n");
return -1;
}
} else if (ald_append_branches) {
if (append_branch(_msg, alias, 0, 0, MIN_Q, 0, 0, 0, 0, 0, 0) == -1)
{
} else if(ald_append_branches) {
if(append_branch(_msg, alias, 0, 0, MIN_Q, 0, 0, 0, 0, 0, 0) == -1) {
LM_ERR("error while appending branches\n");
return -1;
}
@ -224,26 +209,27 @@ int set_alias_to_ruri(struct sip_msg* _msg, str *alias, int no, void *p)
}
int alias_db_lookup_ex(struct sip_msg* _msg, str table, unsigned long flags)
int alias_db_lookup_ex(struct sip_msg *_msg, str table, unsigned long flags)
{
if (parse_sip_msg_uri(_msg) < 0)
if(parse_sip_msg_uri(_msg) < 0)
return -1;
return alias_db_query(_msg, table, &_msg->parsed_uri, flags,
set_alias_to_ruri, NULL);
return alias_db_query(
_msg, table, &_msg->parsed_uri, flags, set_alias_to_ruri, NULL);
}
int alias_db_lookup(struct sip_msg* _msg, str table)
int alias_db_lookup(struct sip_msg *_msg, str table)
{
unsigned long flags = 0;
if(alias_db_use_domain) flags = ALIAS_DOMAIN_FLAG;
if(alias_db_use_domain)
flags = ALIAS_DOMAIN_FLAG;
return alias_db_lookup_ex(_msg, table, flags);
}
int set_alias_to_pvar(struct sip_msg* _msg, str *alias, int no, void *p)
int set_alias_to_pvar(struct sip_msg *_msg, str *alias, int no, void *p)
{
pv_value_t val;
pv_spec_t *pvs=(pv_spec_t*)p;
pv_spec_t *pvs = (pv_spec_t *)p;
if(no && !ald_append_branches)
return 0;
@ -253,8 +239,7 @@ int set_alias_to_pvar(struct sip_msg* _msg, str *alias, int no, void *p)
val.ri = 0;
val.rs = *alias;
if(pv_set_spec_value(_msg, pvs, (int)(no?EQ_T:ASSIGN_T), &val)<0)
{
if(pv_set_spec_value(_msg, pvs, (int)(no ? EQ_T : ASSIGN_T), &val) < 0) {
LM_ERR("setting PV AVP failed\n");
return -1;
}
@ -262,30 +247,26 @@ int set_alias_to_pvar(struct sip_msg* _msg, str *alias, int no, void *p)
}
int alias_db_find(struct sip_msg* _msg, str table, char* _in, char* _out,
char* flags)
int alias_db_find(
struct sip_msg *_msg, str table, char *_in, char *_out, char *flags)
{
pv_value_t val;
struct sip_uri puri;
/* get the input value */
if (pv_get_spec_value(_msg, (pv_spec_t*)_in, &val)!=0)
{
if(pv_get_spec_value(_msg, (pv_spec_t *)_in, &val) != 0) {
LM_ERR("failed to get PV value\n");
return -1;
}
if ( (val.flags&PV_VAL_STR)==0 )
{
if((val.flags & PV_VAL_STR) == 0) {
LM_ERR("PV vals is not string\n");
return -1;
}
if (parse_uri(val.rs.s, val.rs.len, &puri)<0)
{
LM_ERR("failed to parse uri %.*s\n",val.rs.len,val.rs.s);
if(parse_uri(val.rs.s, val.rs.len, &puri) < 0) {
LM_ERR("failed to parse uri %.*s\n", val.rs.len, val.rs.s);
return -1;
}
return alias_db_query(_msg, table, &puri, (unsigned long)flags,
set_alias_to_pvar, _out);
return alias_db_query(
_msg, table, &puri, (unsigned long)flags, set_alias_to_pvar, _out);
}

@ -1,6 +1,4 @@
/*
* $Id$
*
/*
* ALIAS_DB Module
*
* Copyright (C) 2004 Voice Sistem SRL
@ -17,13 +15,10 @@
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* History:
* --------
* 2004-09-01: first version (ramona)
*/
@ -32,12 +27,12 @@
#include "../../core/parser/msg_parser.h"
#define ALIAS_REVERSE_FLAG (1<<0)
#define ALIAS_DOMAIN_FLAG (1<<1)
#define ALIAS_REVERSE_FLAG (1 << 0)
#define ALIAS_DOMAIN_FLAG (1 << 1)
int alias_db_lookup(struct sip_msg* _msg, str _table);
int alias_db_lookup_ex(struct sip_msg* _msg, str _table, unsigned long flags);
int alias_db_find(struct sip_msg* _msg, str _table, char* _in, char* _out,
char* flags);
int alias_db_lookup(struct sip_msg *_msg, str _table);
int alias_db_lookup_ex(struct sip_msg *_msg, str _table, unsigned long flags);
int alias_db_find(
struct sip_msg *_msg, str _table, char *_in, char *_out, char *flags);
#endif /* _ALOOKUP_H_ */

@ -1,26 +1,54 @@
/*
* ALIAS_DB Module
*
* Copyright (C) 2011 Crocodile RCS
*
* This file is part of a module for Kamailio, a free SIP server.
*
* Kamailio 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
* (at your option) any later version
*
* Kamailio is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
#ifndef ALIASDB_API_H
#define ALIASDB_API_H
#include "../../core/str.h"
typedef int (*alias_db_lookup_t)(sip_msg_t*, str table);
typedef int (*alias_db_lookup_ex_t)(sip_msg_t*, str table, unsigned long flags);
typedef int (*alias_db_find_t)(sip_msg_t*, str table, char* _in, char* _out, char *flags);
typedef int (*alias_db_lookup_t)(sip_msg_t *, str table);
typedef int (*alias_db_lookup_ex_t)(
sip_msg_t *, str table, unsigned long flags);
typedef int (*alias_db_find_t)(
sip_msg_t *, str table, char *_in, char *_out, char *flags);
/* clang-format off */
typedef struct alias_db_binds {
alias_db_lookup_t alias_db_lookup;
alias_db_lookup_ex_t alias_db_lookup_ex;
alias_db_find_t alias_db_find;
} alias_db_api_t;
/* clang-format on */
typedef int (*bind_alias_db_f)(alias_db_api_t*);
typedef int (*bind_alias_db_f)(alias_db_api_t *);
int bind_alias_db(struct alias_db_binds*);
int bind_alias_db(struct alias_db_binds *);
inline static int alias_db_load_api(alias_db_api_t *pxb)
{
bind_alias_db_f bind_alias_db_exports;
if (!(bind_alias_db_exports = (bind_alias_db_f)find_export("bind_alias_db", 1, 0)))
{
if(!(bind_alias_db_exports =
(bind_alias_db_f)find_export("bind_alias_db", 1, 0))) {
LM_ERR("Failed to import bind_alias_db\n");
return -1;
}

@ -1,9 +1,9 @@
/*
* duk_config.h configuration header generated by genconfig.py.
*
* Git commit: 6001888049cb42656f8649db020e804bcdeca6a7
* Git describe: v2.5.0
* Git branch: master
* Git commit: fffa346eff06a8764b02c31d4336f63a773a95c3
* Git describe: v2.6.0
* Git branch: v2-maintenance
*
* Supported platforms:
* - Mac OSX, iPhone, Darwin
@ -964,9 +964,7 @@
#elif defined(DUK_F_PPC64)
/* --- PowerPC 64-bit --- */
#define DUK_USE_ARCH_STRING "ppc64"
#if !defined(DUK_USE_BYTEORDER)
#define DUK_USE_BYTEORDER 3
#endif
/* No forced byteorder (both little and big endian are possible). */
#undef DUK_USE_PACKED_TVAL
#define DUK_F_PACKED_TVAL_PROVIDED
#elif defined(DUK_F_SPARC32)
@ -2917,6 +2915,8 @@ typedef struct duk_hthread duk_context;
#define DUK_USE_CACHE_CATCHER
#define DUK_USE_CALLSTACK_LIMIT 10000
#define DUK_USE_CBOR_BUILTIN
#define DUK_USE_CBOR_DEC_RECLIMIT 1000
#define DUK_USE_CBOR_ENC_RECLIMIT 1000
#define DUK_USE_CBOR_SUPPORT
#define DUK_USE_COMPILER_RECLIMIT 2500
#define DUK_USE_COROUTINE_SUPPORT

File diff suppressed because it is too large Load Diff

@ -1,13 +1,13 @@
/*
* Duktape public API for Duktape 2.5.0.
* Duktape public API for Duktape 2.6.0.
*
* See the API reference for documentation on call semantics. The exposed,
* supported API is between the "BEGIN PUBLIC API" and "END PUBLIC API"
* comments. Other parts of the header are Duktape internal and related to
* e.g. platform/compiler/feature detection.
*
* Git commit 6001888049cb42656f8649db020e804bcdeca6a7 (v2.5.0).
* Git branch master.
* Git commit fffa346eff06a8764b02c31d4336f63a773a95c3 (v2.6.0).
* Git branch v2-maintenance.
*
* See Duktape AUTHORS.rst and LICENSE.txt for copyright and
* licensing information.
@ -176,16 +176,16 @@
* development snapshots have 99 for patch level (e.g. 0.10.99 would be a
* development version after 0.10.0 but before the next official release).
*/
#define DUK_VERSION 20500L
#define DUK_VERSION 20600L
/* Git commit, describe, and branch for Duktape build. Useful for
* non-official snapshot builds so that application code can easily log
* which Duktape snapshot was used. Not available in the ECMAScript
* environment.
*/
#define DUK_GIT_COMMIT "6001888049cb42656f8649db020e804bcdeca6a7"
#define DUK_GIT_DESCRIBE "v2.5.0"
#define DUK_GIT_BRANCH "master"
#define DUK_GIT_COMMIT "fffa346eff06a8764b02c31d4336f63a773a95c3"
#define DUK_GIT_DESCRIBE "v2.6.0"
#define DUK_GIT_BRANCH "v2-maintenance"
/* External duk_config.h provides platform/compiler/OS dependent
* typedefs and macros, and DUK_USE_xxx config options so that

@ -346,7 +346,9 @@ int apy_load_script(void)
}
Py_Initialize();
#if PY_VERSION_HEX < 0x03070000
PyEval_InitThreads();
#endif
myThreadState = PyThreadState_Get();
PY_GIL_ENSURE;

@ -185,7 +185,7 @@ AAAMessage* AAATranslateMessage( unsigned char* source, unsigned int sourceLen,
int attach_buf)
{
unsigned char *ptr;
AAAMessage *msg;
AAAMessage *msg = NULL;
unsigned char version;
unsigned int msg_len;
AAA_AVP *avp;
@ -310,7 +310,9 @@ AAAMessage* AAATranslateMessage( unsigned char* source, unsigned int sourceLen,
return msg;
error:
LM_ERR(" message conversion dropped!!\n");
AAAFreeMessage(&msg);
if (msg) {
AAAFreeMessage(&msg);
}
return 0;
}

@ -168,7 +168,7 @@
<para>
The <function>attr_equals()</function> function checks whether
the attribute identified by the argument <symbol>attribute</symbol>
exists and its value is identical the the value given by the
exists and its value is identical the value given by the
argument <symbol>value</symbol>. If so, it returns
<literal>true</literal> and <literal>false</literal> otherwise.
</para>

@ -1262,7 +1262,7 @@ modparam("carrierroute", "carrierfailureroute_domain_col", "domain")
19. carrierfailureroute_scan_prefix_col (string)
Name of column contains the the scan prefixes. Scan prefixes define the
Name of column contains the scan prefixes. Scan prefixes define the
matching portion of a phone number, e.g. we have the scan prefixes
49721 and 49, the called number is 49721913740, it matches 49721,
because the longest match is taken. If no prefix matches, the number is

@ -273,7 +273,7 @@ modparam("carrierroute", "carrierfailureroute_domain_col", "domain")
</section>
<section>
<title><varname>carrierfailureroute_scan_prefix_col</varname> (string)</title>
<para>Name of column contains the the scan prefixes. Scan prefixes define the matching
<para>Name of column contains the scan prefixes. Scan prefixes define the matching
portion of a phone number, e.g. we have the scan prefixes 49721 and 49, the called number is
49721913740, it matches 49721, because the longest match is taken. If no prefix matches,
the number is not failure routed. To prevent this, an empty prefix value of

@ -429,6 +429,8 @@ void cfgt_save_node(cfgt_node_p node)
}
fclose(fp);
node->jdoc.free_fn(dest.s);
LM_INFO("*** node uuid:[%.*s] id:[%d] saved ***\n",
STR_FMT(&node->uuid), node->msgid);
} else {
LM_ERR("Can't open file [%s] to write\n", dest.s);
pkg_free(dest.s);
@ -767,7 +769,7 @@ int cfgt_msgin(sr_event_param_t *evp)
int cfgt_pre(struct sip_msg *msg, unsigned int flags, void *bar)
{
str unknown = {"unknown", 7};
int get_hdr_result = 0;
int get_hdr_result = 0, res;
if(_cfgt_node) {
if(_cfgt_node->msgid == 0) {
@ -786,7 +788,10 @@ int cfgt_pre(struct sip_msg *msg, unsigned int flags, void *bar)
}
pkg_str_dup(&_cfgt_node->uuid, &unknown);
}
return _cfgt_get_uuid_id(_cfgt_node);
res = _cfgt_get_uuid_id(_cfgt_node);
LM_INFO("*** node uuid:[%.*s] id:[%d] created ***\n",
STR_FMT(&_cfgt_node->uuid), _cfgt_node->msgid);
return res;
} else {
LM_DBG("_cfgt_node->uuid:[%.*s]\n", _cfgt_node->uuid.len,
_cfgt_node->uuid.s);

@ -132,7 +132,7 @@ struct module_exports exports = {
/** parse the the script_counter modparam.
/** parse the script_counter modparam.
* Format: [grp.]name[( |:)desc]
* E.g.:
* "name" => new counter: *cnt_script_grp."name"
@ -554,4 +554,4 @@ int mod_register(char *path, int *dlflags, void *p1, void *p2)
return 0;
}
/* vi: set ts=4 sw=4 tw=79:ai:cindent: */
/* vi: set ts=4 sw=4 tw=79:ai:cindent: */

@ -228,8 +228,8 @@ modparam("cpl-c","domain_column","domain")
3.5. cpl_xml_column (string)
Indicates the name of the column used for storing the the XML version
of the cpl script.
Indicates the name of the column used for storing the XML version of
the cpl script.
Default value is “cpl_xml”.
@ -240,8 +240,8 @@ modparam("cpl-c","cpl_xml_column","cpl_xml")
3.6. cpl_bin_column (string)
Indicates the name of the column used for storing the the binary
version of the cpl script (compiled version).
Indicates the name of the column used for storing the binary version of
the cpl script (compiled version).
Default value is “cpl_bin”.

@ -175,7 +175,7 @@ modparam("cpl-c","domain_column","domain")
<title><varname>cpl_xml_column</varname> (string)</title>
<para>
Indicates the name of the column used for storing the
the XML version of the cpl script.
XML version of the cpl script.
</para>
<para>
<emphasis>
@ -195,7 +195,7 @@ modparam("cpl-c","cpl_xml_column","cpl_xml")
<title><varname>cpl_bin_column</varname> (string)</title>
<para>
Indicates the name of the column used for storing the
the binary version of the cpl script (compiled version).
binary version of the cpl script (compiled version).
</para>
<para>
<emphasis>

@ -76,7 +76,9 @@ int crypto_aes_init(unsigned char *key_data, int key_data_len,
{
int i, nrounds = 5;
int x;
unsigned char key[32], iv[32];
unsigned char key[32], iv[32]; /* IV is only 16 bytes, but makes it easier */
memset(key, 0, sizeof(key));
memset(iv, 0, sizeof(iv));
/*
* Gen key & IV for AES 256 CBC mode. A SHA1 digest is used to hash

@ -627,10 +627,17 @@ int process_rpc_req(unsigned char* buf, int size, int* bytes_needed,
rpc_export_t* rpc_e;
struct binrpc_ctx f_ctx;
struct binrpc_parse_ctx* ctx;
if(ksr_shutdown_phase()) {
/* during shutdown - no more RPC command handling */
LM_DBG("shutdown phase - skipping rpc command\n");
return -1;
}
if (size<BINRPC_MIN_PKT_SIZE){
*bytes_needed=BINRPC_MIN_PKT_SIZE-size;
return 0; /* more data , nothing processed */
LM_DBG("more data needed - at least: %d bytes\n", *bytes_needed);
return 0; /* more data, nothing processed */
}
err=init_binrpc_ctx(&f_ctx, buf, size, sh);
ctx=&f_ctx.in.ctx;

@ -495,6 +495,7 @@ again:
DBG("handle_stream read: eof on %s\n", s_c->parent->name);
goto close_connection;
}
LM_INFO("bytes read: %d\n", bytes_read);
r->end+=bytes_read;
if (bytes_read && (bytes_read<r->bytes_to_go)){
r->bytes_to_go-=bytes_read;
@ -514,6 +515,7 @@ again:
/* error while processing the packet => close the connection */
goto close_connection;
}
LM_INFO("bytes processed: %d\n", bytes_processed);
r->proc+=bytes_processed;
r->bytes_to_go=bytes_needed;
if (bytes_needed>0){

@ -100,7 +100,7 @@ Chapter 1. Admin Guide
5. Usage
Load the module and set the the DB URL for specific modules to:
Load the module and set the DB URL for specific modules to:
mongodb://username:password@host:port/database. Username, password and
port are optional.

@ -96,7 +96,7 @@
<section>
<title>Usage</title>
<para>
Load the module and set the the DB URL for specific modules to:
Load the module and set the DB URL for specific modules to:
mongodb://username:password@host:port/database. Username, password
and port are optional.
</para>

@ -2942,7 +2942,7 @@ static void rpc_dlg_list_match_ex(rpc_t *rpc, void *c, int with_context)
vkey = 1;
} else if(mkey.len==4 && strncmp(mkey.s, "turi", mkey.len)==0) {
vkey = 2;
} else if(mkey.len==5 && strncmp(mkey.s, "callid", mkey.len)==0) {
} else if(mkey.len==6 && strncmp(mkey.s, "callid", mkey.len)==0) {
vkey = 3;
} else {
LM_ERR("invalid key %.*s\n", mkey.len, mkey.s);

@ -381,7 +381,20 @@ int dlg_cseq_msg_sent(sr_event_param_t *evp)
goto done;
}
LM_DBG("traking cseq updates\n");
if(!IS_SIP(&msg)) {
/* nothing to do for non-sip requests */
goto done;
}
if(get_to(&msg)->tag_value.len<=0) {
/* intial request - handle only INVITEs, ACKs and CANCELs */
if(!(msg.first_line.u.request.method_value
& (METHOD_INVITE|METHOD_ACK|METHOD_CANCEL))) {
goto done;
}
}
LM_DBG("tracking cseq updates\n");
via = (struct via_body*)msg.h_via1->parsed;
if(via->branch==NULL || via->branch->value.len<=0) {

@ -534,11 +534,11 @@ int dlg_dmq_replicate_action(dlg_dmq_action_t action, dlg_cell_t* dlg,
if (dlg->vars != NULL) {
srjson_t *pj = NULL;
pj = srjson_CreateObject(&jdoc);
for(var=dlg->vars ; var ; var=var->next) {
for(var=dlg->vars ; var ; var=var->next) {
srjson_AddStrToObject(&jdoc, pj, var->key.s,
var->value.s, var->value.len);
}
srjson_AddItemToObject(&jdoc, jdoc.root, "vars", pj);
}
srjson_AddItemToObject(&jdoc, jdoc.root, "vars", pj);
}
if (dlg->profile_links) {
@ -646,22 +646,22 @@ error:
int dmq_send_all_dlgs(dmq_node_t* dmq_node) {
int index;
dlg_entry_t entry;
dlg_entry_t *entry;
dlg_cell_t *dlg;
LM_DBG("sending all dialogs \n");
for(index = 0; index< d_table->size; index++){
/* lock the whole entry */
entry = (d_table->entries)[index];
dlg_lock( d_table, &entry);
entry = &d_table->entries[index];
dlg_lock( d_table, entry);
for(dlg = entry.first; dlg != NULL; dlg = dlg->next){
dlg->dflags |= DLG_FLAG_CHANGED_PROF;
dlg_dmq_replicate_action(DLG_DMQ_UPDATE, dlg, 0, dmq_node);
for(dlg = entry->first; dlg != NULL; dlg = dlg->next){
dlg->dflags |= DLG_FLAG_CHANGED_PROF;
dlg_dmq_replicate_action(DLG_DMQ_UPDATE, dlg, 0, dmq_node);
}
dlg_unlock( d_table, &entry);
dlg_unlock( d_table, entry);
}
return 0;
@ -672,7 +672,7 @@ int dmq_send_all_dlgs(dmq_node_t* dmq_node) {
* @brief dmq response callback
*/
int dlg_dmq_resp_callback_f(struct sip_msg* msg, int code,
dmq_node_t* node, void* param)
dmq_node_t* node, void* param)
{
LM_DBG("dmq response callback triggered [%p %d %p]\n", msg, code, param);
return 0;

@ -749,15 +749,15 @@ static void dlg_on_send(struct cell* t, int type, struct tmcb_params *param)
LM_DBG("dialog_on_send CB\n");
iuid = (dlg_iuid_t*)(*param->param);
if (iuid==NULL)
return;
return;
dlg = dlg_get_by_iuid(iuid);
if(dlg==NULL)
return;
return;
/* sync over dmq */
if (dlg_enable_dmq) {
dlg_dmq_replicate_action(DLG_DMQ_UPDATE, dlg, 1, 0);
dlg_dmq_replicate_action(DLG_DMQ_UPDATE, dlg, 1, 0);
}
/* unref by 2: 1 set when adding in tm cb, 1 set by dlg_get_by_iuid() */

@ -857,7 +857,7 @@ dlg_cell_t* dlg_get_by_iuid(dlg_iuid_t *diuid)
* \param ftag from tag
* \param ttag to tag
* \param dir direction
* \param mode let hash table slot locked or not
* \param mode let hash table slot locked or not, even when dlg is not found
* \return dialog structure on success, NULL on failure
*/
static inline struct dlg_cell* internal_get_dlg(unsigned int h_entry,
@ -865,24 +865,50 @@ static inline struct dlg_cell* internal_get_dlg(unsigned int h_entry,
unsigned int *dir, int mode)
{
struct dlg_cell *dlg;
struct dlg_cell *dlg_no_totag=NULL;
struct dlg_entry *d_entry;
unsigned int dir_no_totag = DLG_DIR_NONE;
d_entry = &(d_table->entries[h_entry]);
dlg_lock( d_table, d_entry);
for( dlg = d_entry->first ; dlg ; dlg = dlg->next ) {
/* Check callid / fromtag / totag */
/* check callid / fromtag / totag */
if (match_dialog( dlg, callid, ftag, ttag, dir)==1) {
/* if to-tag is empty continue to search in case another dialog
* is found with a matching to-tag. */
if (dlg->tag[DLG_CALLEE_LEG].len == 0) {
dlg_no_totag = dlg;
dir_no_totag = *dir;
continue;
}
ref_dlg_unsafe(dlg, 1);
if(likely(mode==0)) dlg_unlock( d_table, d_entry);
LM_DBG("dialog callid='%.*s' found on entry %u, dir=%d\n",
callid->len, callid->s,h_entry,*dir);
if(likely(mode==0)) {
dlg_unlock( d_table, d_entry);
}
LM_DBG("dialog callid='%.*s' found on entry %u, dir=%d to-tag='%.*s'\n",
callid->len, callid->s, h_entry, *dir,
dlg->tag[DLG_CALLEE_LEG].len, dlg->tag[DLG_CALLEE_LEG].s);
return dlg;
}
}
if(likely(mode==0)) dlg_unlock( d_table, d_entry);
if (dlg_no_totag) {
ref_dlg_unsafe(dlg_no_totag, 1);
}
if(likely(mode==0)) {
dlg_unlock(d_table, d_entry);
}
if (dlg_no_totag) {
*dir = dir_no_totag;
LM_DBG("dialog callid='%.*s' found on entry %u, dir=%d no-to-tag\n",
callid->len, callid->s, h_entry, *dir);
return dlg_no_totag;
}
LM_DBG("no dialog callid='%.*s' found\n", callid->len, callid->s);
return 0;
}

@ -434,10 +434,11 @@ int pv_set_dlg_variable(struct sip_msg* msg, pv_param_t *param, int op, pv_value
/* unlock dialog */
if (dlg) {
dlg->dflags |= DLG_FLAG_CHANGED_VARS;
dlg_unlock(d_table, &(d_table->entries[dlg->h_entry]));
if ( dlg_db_mode==DB_MODE_REALTIME )
if ( dlg_db_mode==DB_MODE_REALTIME ) {
/* dlg_lock() / dlg_unlock() are reentrant */
update_dialog_dbinfo(dlg);
}
dlg_unlock(d_table, &(d_table->entries[dlg->h_entry]));
}
print_lists(dlg);

@ -1058,8 +1058,8 @@ modparam("dispatcher", "reload_delta", 1)
(serial forking ordered by priority).
+ “9” - use weight based load distribution. You have to set the
attribute 'weight' for each address (gateway) in destination
set. For more see the description of the 'weight' attribute in
the 'Special Attributes' section.
set. See also the description of the 'weight' attribute in the
'Special Attributes' section.
+ “10” - use call load distribution. You have to set the
attribute 'duid' (as an unique string id) per each address in
destination set. Also, you must set the parameter
@ -1081,10 +1081,14 @@ modparam("dispatcher", "reload_delta", 1)
active host rweights in destination group).
The major difference from the weight distribution is the
probability recalculation according to rweight value in case
of host enabling/disabling
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.
of destinations being active or inactive.
For example, 100 calls in 3-destinations group with rweight
params 1/2/1 will be distributed as 25/50/25. If the third
destination becomes inactive, the distribution is changed to
33/67/0. If the computation of percentage per destination is
not an exact integer number, the value is trucated and the
last destination is used to fill the remaining percentage till
100.
Using this algorithm, you can also enable congestion control
by setting the attibute 'cc=1', when 'cc' is enabled the
'rweight' attribute will also be used to control congestion
@ -1097,6 +1101,8 @@ modparam("dispatcher", "reload_delta", 1)
above their congestion threshold(weight), the load
distribution is instead done using the ratio of estimated
congestion ms.
See also the description of the 'rweight' attribute in the
'Special Attributes' section.
+ “12” - dispatch to all destination in setid at once (parallel
forking). Note that the XAVPs are no longer set with the
values of the destination records, no re-routing making sense
@ -1681,11 +1687,17 @@ kamctl rpc dispatcher.hash 4 bob server.com
If set to 0, then no active call limit is used.>
* 'weight' - used for weight based load distribution. It must be set
to a positive integer value beteen 0 and 100. The value represents
the percent of calls to be sent to that gateways.>
the percent of calls to be sent to that gateways. The sum must not
exceed 100, otherwise the destinations whose weight added to the
sum go over 100 are ignored. If the sum is less than 100, then the
last destination is used to fill the missing percentage. See also
the description of the corresponding algorithm parameter for
ds_select_dst().
* '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).
type). See also the description of the corresponding algorithm
parameter for ds_select_dst().
* 'socket' - used to set the sending socket for the gateway. It is
used for sending the SIP traffic as well as OPTIONS keepalives.
* 'sockname' - used to set by name the sending socket for the

@ -872,14 +872,14 @@ next_line:
goto error;
}
LM_DBG("found [%d] dest sets\n", _ds_list_nr);
fclose(f);
f = NULL;
/* Update list - should it be sync'ed? */
_ds_list_nr = setn;
*crt_idx = *next_idx;
LM_DBG("found [%d] dest sets\n", _ds_list_nr);
ds_log_sets();
return 0;
@ -1120,14 +1120,14 @@ int ds_load_db(void)
goto err2;
}
LM_DBG("found [%d] dest sets\n", _ds_list_nr);
ds_dbf.free_result(ds_db_handle, res);
/* update data - should it be sync'ed? */
_ds_list_nr = setn;
*crt_idx = *next_idx;
LM_DBG("found [%d] dest sets\n", _ds_list_nr);
ds_log_sets();
if(dest_errs > 0)

@ -1063,7 +1063,6 @@ static int ki_ds_list_exists(struct sip_msg *msg, int set)
static int fixup_ds_list_exist(void **param, int param_no)
{
return fixup_igp_null(param, param_no);
return 0;
}
static int ds_parse_reply_codes()

@ -1189,7 +1189,7 @@ modparam("dispatcher", "reload_delta", 1)
<para>
<quote>9</quote> - use weight based load distribution. You
have to set the attribute 'weight' for each address (gateway) in
destination set. For more see the description of the 'weight'
destination set. See also the description of the 'weight'
attribute in the 'Special Attributes' section.
</para>
</listitem>
@ -1228,12 +1228,15 @@ modparam("dispatcher", "reload_delta", 1)
<para>
The major difference from the weight distribution is the
probability recalculation according to rweight value in case of
host enabling/disabling
destinations being active or inactive.
</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
distribution will be changed to 33/67/0.
For example, 100 calls in 3-destinations group with rweight params 1/2/1
will be distributed as 25/50/25. If the third destination becomes
inactive, the distribution is changed to 33/67/0. If the computation
of percentage per destination is not an exact integer number, the value
is trucated and the last destination is used to fill the remaining
percentage till 100.
</para>
<para>
Using this algorithm, you can also enable congestion control by setting the
@ -1248,6 +1251,10 @@ modparam("dispatcher", "reload_delta", 1)
If all the gateways in a set are above their congestion threshold(weight), the
load distribution is instead done using the ratio of estimated congestion ms.
</para>
<para>
See also the description of the 'rweight' attribute in the
'Special Attributes' section.
</para>
</listitem>
<listitem>
<para>
@ -2100,13 +2107,19 @@ kamctl rpc dispatcher.hash 4 bob server.com
<listitem>
<para>'weight' - used for weight based load distribution. It must be set
to a positive integer value beteen 0 and 100. The value represents
the percent of calls to be sent to that gateways.></para>
the percent of calls to be sent to that gateways. The sum must not
exceed 100, otherwise the destinations whose weight added to the
sum go over 100 are ignored. If the sum is less than 100, then the
last destination is used to fill the missing percentage. See also
the description of the corresponding algorithm parameter for
ds_select_dst().</para>
</listitem>
<listitem>
<para>'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).</para>
type). See also the description of the corresponding algorithm
parameter for ds_select_dst().</para>
</listitem>
<listitem>
<para>'socket' - used to set the sending socket for the gateway. It is

@ -250,13 +250,16 @@ static int w_dlgs_update(sip_msg_t *msg, char *p1, char *p2)
*/
static int ki_dlgs_count(sip_msg_t *msg, str *vfield, str *vop, str *vdata)
{
int ret;
LM_DBG("counting by: [%.*s] [%.*s] [%.*s]\n", vfield->len, vfield->s,
vop->len, vop->s, vdata->len, vdata->s);
if(dlgs_count(msg, vfield, vop, vdata) < 0) {
return -1;
ret = dlgs_count(msg, vfield, vop, vdata);
if(ret <= 0) {
return (ret-1);
}
return 1;
return ret;
}
/**
@ -338,8 +341,11 @@ static int w_dlgs_tags_rm(sip_msg_t *msg, char *ptags, char *p2)
*/
static int ki_dlgs_tags_count(sip_msg_t *msg, str *vtags)
{
if(dlgs_tags_count(msg, vtags)<0) {
return -1;
int ret;
ret = dlgs_tags_count(msg, vtags);
if(ret<=0) {
return (ret-1);
}
return 1;
}

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

Loading…
Cancel
Save