Imported Upstream version 4.2.1

changes/34/1834/2 upstream/4.2.1
Victor Seva 11 years ago
parent eb59d0198f
commit b6e6d38fe9

@ -37,7 +37,7 @@ understand implications of the GNU license, read it.
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.

15286
ChangeLog

File diff suppressed because it is too large Load Diff

@ -24,17 +24,17 @@ Table of Contents
=================
1. SIP Server Flavours
2. Supported Architectures and Requirements
3. Howto Build SIP Server From the Source Distribution
2. Supported Architectures And Requirements
3. How-To Build SIP Server From The Source Code Distribution
3.1 Kamailio Fast Track Installation
3.2 Details Installing from Source Code
3.2 Details Installing From Source Code
A) Set SIP Server Flavour
B) Build Commands
4. Quick-Start Installation Guide
A) Getting Help
B) Disclaimers
C) Quick Start
D) SIP Server with Persistent Data Storage
C) Quick Atart
D) SIP Server With Persistent Data Storage
5. Troubleshooting
@ -43,7 +43,7 @@ Table of Contents
----------------------
The two major SIP server flavours are:
- SIP Express Router (aka SER)
- SIP Express Router (aka SER, the initial project name, started in 2001)
- Kamailio (former OpenSER)
Starting with version 3.0.0, the two SIP server flavours are built from
@ -69,7 +69,7 @@ Several installation tutorials for Kamailio are available on the web wiki:
- http://www.kamailio.org/wiki/
2. Supported Architectures and Requirements
2. Supported Architectures And Requirements
-------------------------------------------
Supported operating systems:
@ -97,7 +97,7 @@ Requirements:
- gcc or icc : gcc >= 2.9x; 3.[12] recommended (it will work with older version
but it might require some options tweaking for best performance)
- bison or yacc (Berkley yacc)
- bison or yacc (Berkley Yacc)
- flex
- GNU make (on Linux this is the standard "make", on *BSD and Solaris it is
called "gmake") version >= 3.80 (recommended 3.81).
@ -105,10 +105,10 @@ Requirements:
- GNU tar ("gtar" on Solaris) and gzip if you want "make tar" to work
- GNU install, BSD install or Solaris install if you want "make
install", "make bin", "make sunpkg" to work
- libmysqlclient & libz (zlib) if you want Mysql support (the db_mysql module)
- libmysqlclient & libz (zlib) if you want MySQL support (the db_mysql module)
- libxml2 if you want to compile the cpl-c (CPL support) or pa (presence)
modules
- libradiusclient-ng (> 5.0) if you need radius support (the auth_radius,
- libradiusclient-ng (> 5.0) if you need RADIUS support (the auth_radius,
group_radius, uri_radius and avp_radius modules)
- libpq if you need PostgreSQL support (the db_postgres module)
- libexpat if you want the jabber gateway support (the jabber module) or the
@ -120,17 +120,19 @@ Requirements:
- unixodbc - libs and devel headers - if you want UNIXODBC support as
DB underlayer
- libxmlrpc-c3 - libs and devel headers - if you want to have XML-RPC support
for the Management interface (MI)
- libperl - libs and devel headers - if you want PERL connector to support
perl scripting from you config file (perl module)
for the management interface (MI)
- libperl - libs and devel headers - if you want the perl connector to support
perl scripting from your config file (perl module)
- libsnmp9 - libs and devel headers - if you want SNMP client functionality
(SNMP AgentX subagent) for Kamailio
- libldap libs and devel headers v2.1 or greater - if you want LDAP support
- libpcre libs and devel headers - if you want to compile the lcr and dialplan
modules
- libsctp devel headers - if you want to compile the SCTP transport in the core
- libssl devel headers (openssl project) - if you want to compule the TLS module
- linunistring - for the Websockets module
- libssl devel headers (openssl project) - if you want to compile the TLS module
- libunistring - for the WebSocket module
- python and devel headers for the Python module
- jdk and gcj for Java module
OS Notes:
@ -223,8 +225,8 @@ OS Notes:
make bin include_modules="mysql jabber cpl-c auth_radius group_radius uri_radius postgres pa"
3. Howto Build SIP Server From Source Distribution
--------------------------------------------------
3. Howto Build SIP Server From Source Code Distribution
-------------------------------------------------------
(NOTE: if make doesn't work try gmake instead)
@ -232,8 +234,8 @@ OS Notes:
....................................
If you are familiar with Unix/Linux build tools aready and you installed
required dependency, then you can just follow this section, otherwise
If you are familiar with Unix/Linux build tools aready and you installed
the required dependencies, then you can just follow this section, otherwise
skip over it.
To get the SIP server installed, in the folder with source code run:
@ -249,7 +251,7 @@ tls, run:
make all
make install
3.2 Details Installing from Source Code
3.2 Details Installing From Source Code
.......................................
@ -329,12 +331,12 @@ are grouped based on Debian packaging rules. For example:
There are also in addition some "convenience" groups:
mysql - Include all the db modules dependent and the mysql db driver
postgres - Include all the db modules and the postgres db driver
mysql - Include all the db modules dependent and the MySQL db driver
postgres - Include all the db modules and the PostgreSQL db driver
radius - Include all modules on radiusclient
presence - Include all the presence modules
Ex. to make a standard installation with Mysql, use:
Ex. to make a standard installation with MySQL, use:
make group_include="standard mysql" all
In addition to group_include (or instead), you can use
@ -406,8 +408,8 @@ are grouped based on Debian packaging rules. For example:
Make targets:
=============
Configure:
----------
Make Local Build Config:
------------------------
* make cfg or make config - force config and module list regeneration
@ -417,7 +419,7 @@ Configure:
All future make invocations will include the mysql module and will build in debug mode
Note: if config.mak doesn't exist (e.g. initial checkout or after a make
Note: If config.mak doesn't exist (e.g. initial checkout or after a make
proper) or if Makefile.defs was changed, the config will be re-generated
automatically by the first make command. For example:
make cfg include_modules=db_mysql; make all
@ -471,7 +473,7 @@ Compile:
* make modules
or make modules exclude_modules="CVS print" etc.
Other make targets:
Other Make Targets:
-------------------
Make tags:
make TAGS
@ -512,9 +514,9 @@ Install:
Note: If you use prefix parameter in make install then you also need
to use this parameter in previous make commands, i.e. make, make modules,
or make all. If you fail to do this then SIP Router will look for the default
or make all. If you fail to do this then SIP server will look for the default
configuration file in a wrong directory, because the directory of the
default configuration file is hard coded into SIP server during compile time.
default configuration file is hardcoded into SIP server during compile time.
When you use a different prefix parameter when installing then the
directory hard coded in SIP server and the directory in which the file will be
installed by make install will not match. (You can specify exact location
@ -530,7 +532,7 @@ Install:
/usr/local/etc/kamailio/kamailio.cfg (because there was no prefix parameter
make all and /usr/local is the default value of prefix).
Workaround is trivial, use the same parameters in all make commands:
The workaround is trivial, use the same parameters in all make commands:
make prefix=/ all
make prefix=/ install
or save the desired prefix in the make config (e.g.: make cfg prefix=/).
@ -621,7 +623,7 @@ C) Quick Start
You can start SIP server directly with /usr/local/sbin/ser or
/usr/local/sbin/kamailio.
4) optionally, watch server's health using the
4) Optionally, watch server's health using the
serctl or kamctl utility
- to do so, first set the environment variable SIP_DOMAIN to your domain
@ -653,7 +655,7 @@ C) Quick Start
Auth user: the ID used for authentication
Secret/Password: The configured authentication password
D) SIP Server with Persistent Data Storage
D) SIP Server With Persistent Data Storage
------------------------------------------
The default configuration is very simple and features many simplifications.
@ -751,15 +753,6 @@ D) SIP Server with Persistent Data Storage
4. Troubleshooting
------------------
Q: Windows Messenger authentication fails.
A: The most likely reason for this problem is a bug in Windows Messenger.
WM only authenticates if server name in request URI equals authentication
realm. After a challenge is sent by SIP server, WM does not resubmit the
challenged request at all and pops up authentication window again. If you
want to authenticate WM, you need to set up your realm value to equal server
name. If your server has no name, IP address can be used as realm too.
Q: SIP requests are replied by SIP server with "483 Too Many Hops" or
"513 Message Too Large"
@ -776,3 +769,11 @@ A: In both cases, the reason is probably an error in request routing script
introduce a config option to ser.cfg or kamailio.cfg: alias=domainname,
where domainname shall be replaced with name of domain, which you wish to
server and which appears in request-URIs.
Q: Where to report issues?
A: Use bug tracker at: http://sip-router.org/tracker
Q: Any F.A.Q. that could be helpful to check before reporting an issue?
A: See: http://www.kamailio.org/wiki/tutorials/faq/main

@ -755,7 +755,7 @@ $(man_prefix)/$(man_dir)/man5:
# note: sed with POSIX.1 regex doesn't support |, + or ? (darwin, solaris ...)
install-cfg: $(cfg_prefix)/$(cfg_dir)
@if [ -f etc/$(CFG_NAME).cfg ]; then \
@if [ -f etc/$(CFG_NAME).cfg ]; then \
sed $(foreach m,$(modules_dirs),\
-e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
-e "s#/usr/local/etc/$(CFG_NAME)/#$(cfg_target)#g" \
@ -768,7 +768,7 @@ install-cfg: $(cfg_prefix)/$(cfg_dir)
$(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg; \
fi; \
fi
@if [ -f etc/$(CFG_NAME)-basic.cfg ]; then \
@if [ -f etc/$(CFG_NAME)-basic.cfg ]; then \
sed $(foreach m,$(modules_dirs),\
-e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
-e "s#/usr/local/etc/$(CFG_NAME)/#$(cfg_target)#g" \
@ -781,7 +781,7 @@ install-cfg: $(cfg_prefix)/$(cfg_dir)
$(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-basic.cfg; \
fi; \
fi
@if [ -f etc/$(CFG_NAME)-oob.cfg ]; then \
@if [ -f etc/$(CFG_NAME)-oob.cfg ]; then \
sed $(foreach m,$(modules_dirs),\
-e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
-e "s#/usr/local/etc/$(CFG_NAME)/#$(cfg_target)#g" \
@ -795,8 +795,8 @@ install-cfg: $(cfg_prefix)/$(cfg_dir)
$(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg; \
fi; \
fi
@# other configs
@for r in $(C_INSTALL_CFGS) ""; do \
@# other configs
@for r in $(C_INSTALL_CFGS) ""; do \
if [ -n "$$r" ]; then \
if [ -f "$$r" ]; then \
n=`basename "$$r"` ; \
@ -818,14 +818,15 @@ install-cfg: $(cfg_prefix)/$(cfg_dir)
fi ; \
fi ; \
fi ; \
done; true
# radius dictionary
$(INSTALL_TOUCH) $(cfg_prefix)/$(cfg_dir)/dictionary.$(CFG_NAME)
$(INSTALL_CFG) etc/dictionary.$(CFG_NAME) $(cfg_prefix)/$(cfg_dir)
: ; done; true
@# radius dictionary
@$(INSTALL_TOUCH) $(cfg_prefix)/$(cfg_dir)/dictionary.$(CFG_NAME)
@$(INSTALL_CFG) etc/dictionary.$(CFG_NAME) $(cfg_prefix)/$(cfg_dir)
@echo "config files installed"
install-bin: $(bin_prefix)/$(bin_dir) $(NAME)
$(INSTALL_TOUCH) $(bin_prefix)/$(bin_dir)/$(NAME)
$(INSTALL_BIN) $(NAME) $(bin_prefix)/$(bin_dir)
$(INSTALL_TOUCH) $(bin_prefix)/$(bin_dir)/$(NAME)
$(INSTALL_BIN) $(NAME) $(bin_prefix)/$(bin_dir)
install-share: $(share_prefix)/$(share_dir)

@ -163,14 +163,13 @@ INSTALL_FLAVOUR=$(FLAVOUR)
# version number
VERSION = 4
PATCHLEVEL = 1
SUBLEVEL = 6
EXTRAVERSION =
PATCHLEVEL = 2
SUBLEVEL = 1
# memory manager switcher
# 0 - f_malloc (fast malloc)
# 1 - q_malloc (quick malloc)
MEMMNG ?= 1
MEMMNG ?= 0
# memory debugger switcher
# 0 - off (no-debug mode)
# 1 - on (debug mode)
@ -946,7 +945,7 @@ else # CC_NAME, gcc
ifeq ($(CC_NAME), clang)
$(call set_if_empty,CPU,athlon64)
C_DEFS+=-DCC_GCC_LIKE_ASM
CFLAGS+=-m32
CFLAGS+=-g -m32
$(CC_OPT) \
\
-mtune=$(CPU)
@ -1042,7 +1041,7 @@ else # CC_NAME, gcc
ifeq ($(CC_NAME), clang)
$(call set_if_empty,CPU,opteron)
C_DEFS+=-DCC_GCC_LIKE_ASM
CFLAGS+=-m64 \
CFLAGS+=-g -m64 \
$(CC_OPT)
LDFLAGS+=-m64
else # CC_NAME, clang

@ -13,12 +13,12 @@ mod_list_basic=async auth benchmark blst cfg_rpc cfgutils corex counters \
mediaproxy mi_datagram mi_fifo mi_rpc mqueue \
nat_traversal nathelper path pike pv ratelimit rr rtimer \
rtpproxy sanity sdpops siputils sl statistics textops \
textopsx tm tmx topoh xlog rtpproxy-ng stun sipt
textopsx tm tmx topoh xlog rtpengine stun sipt
# - extra used modules, with no extra dependency
mod_list_extra=avp auth_diameter call_control cnxcc dmq domainpolicy msrp pdb \
qos sca seas sms sst timer tmrec uac_redirect xhttp \
xhttp_rpc xprint
xhttp_rpc xprint jsonrpc-s nosip
# - common modules depending on database
mod_list_db=acc alias_db auth_db avpops cfg_db db_text db_flatstore \
@ -54,7 +54,7 @@ mod_list_postgres=db_postgres
mod_list_unixodbc=db_unixodbc
# - modules depending on mysql cassandra library
mod_list_cassandra=db_cassandra
mod_list_cassandra=db_cassandra ndb_cassandra
# - modules depending on xml2 library
mod_list_cpl=cpl-c
@ -157,6 +157,18 @@ mod_list_iptrtpproxy=iptrtpproxy
# - modules depending on gzip library
mod_list_gzcompress=gzcompress
# - modules depending on uuid library
mod_list_uuid=uuid
# - modules depending on ev library
mod_list_ev=evapi
# - modules depending on kazoo/rabitmq
mod_list_kazoo=kazoo
# - modules depending on mongodb
mod_list_mongodb=db_mongodb ndb_mongodb
# - all modules
mod_list_all=$(sort $(mod_list_basic) $(mod_list_extra) \
$(mod_list_db) $(mod_list_dbuid) \
@ -179,7 +191,9 @@ mod_list_all=$(sort $(mod_list_basic) $(mod_list_extra) \
$(mod_list_outbound) $(mod_list_osp) \
$(mod_list_java) $(mod_list_dnssec) \
$(mod_list_sctp) $(mod_list_autheph) \
$(mod_list_gzcompress))
$(mod_list_gzcompress) $(mod_list_uuid) \
$(mod_list_ev) $(mod_list_kazoo) \
$(mod_list_mongodb))
@ -340,6 +354,18 @@ module_group_kautheph=$(mod_list_autheph)
# pkg gzcompress module
module_group_kgzcompress=$(mod_list_gzcompress)
# pkg uuid module
module_group_kuuid=$(mod_list_uuid)
# pkg libev modules
module_group_kev=$(mod_list_ev)
# pkg kazoo module
module_group_kkazoo=$(mod_list_kazoo)
# pkg mongodb modules
module_group_kmongodb=$(mod_list_mongodb)
# list of static modules
#
static_modules:=

@ -1,6 +1,6 @@
Kamailio v4.1
Kamailio v4.2
=============
http://www.kamailio.org

@ -37,6 +37,7 @@ app_lua Lang :: Execute embedded LUA scripts
app_mono Lang :: Execute embedded MONO scripts (like C#, Java, javascript)
app_perl Lang :: Embedded perl script support
app_python Lang :: Execute embedded Python scripts
app_java Lang :: Execute embedded Java compiled code
async Asynchronus SIP request handling functions
auth MD5 digest authentication support
auth_db Authentication using a database module
@ -118,6 +119,7 @@ mqueue Message queue system for configuration file
nat_traversal NAT :: NAT traversal module
nathelper NAT :: NAT traversal module :: RTPproxy (SIPPY software)
ndb_redis Connector to REDIS NoSQL Database engine
ndb_cassandra Connector to Apache Cassandra
osp Open Settlement Protocol support
outbound SIP Outbound Implementation
p_usrloc Partitioned and distributed user location services

@ -23,7 +23,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* History:
* ---------
@ -114,6 +114,14 @@ struct onsend_info* p_onsend=0; /* onsend route send info */
/* current action executed from config file */
static cfg_action_t *_cfg_crt_action = 0;
/*!< maximum number of recursive calls for blocks of actions */
static unsigned int max_recursive_level = 256;
void set_max_recursive_level(unsigned int lev)
{
max_recursive_level = lev;
}
/* return current action executed from config file */
cfg_action_t *get_cfg_crt_action(void)
{
@ -418,8 +426,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
}
if (ret<0) {
LOG(L_ERR, "ERROR: do_action: forward: bad_uri "
" dropping packet\n");
LM_ERR("forward: bad_uri dropping packet\n");
goto error;
}
@ -431,8 +438,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
port=a->val[1].u.number;
break;
default:
LOG(L_CRIT, "BUG: do_action bad forward 2nd"
" param type (%d)\n", a->val[1].type);
LM_CRIT("bad forward 2nd param type (%d)\n", a->val[1].type);
ret=E_UNSPEC;
goto error_fwd_uri;
}
@ -458,16 +464,14 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
dst.proto=u->proto;
break;
default:
LOG(L_ERR,"ERROR: do action: forward: bad uri"
" transport %d\n", u->proto);
LM_ERR("forward: bad uri transport %d\n", u->proto);
ret=E_BAD_PROTO;
goto error_fwd_uri;
}
#ifdef USE_TLS
if (u->type==SIPS_URI_T){
if (u->proto==PROTO_UDP){
LOG(L_ERR, "ERROR: do_action: forward: secure uri"
" incompatible with transport %d\n",
LM_ERR("forward: secure uri incompatible with transport %d\n",
u->proto);
ret=E_BAD_PROTO;
goto error_fwd_uri;
@ -504,7 +508,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
proxy_mark((struct proxy_l*)a->val[0].u.data, ret);
}
}else{
LOG(L_CRIT, "BUG: do_action: bad forward() types %d, %d\n",
LM_CRIT("bad forward() types %d, %d\n",
a->val[0].type, a->val[1].type);
ret=E_BUG;
goto error;
@ -512,7 +516,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
break;
case LOG_T:
if ((a->val[0].type!=NUMBER_ST)|(a->val[1].type!=STRING_ST)){
LOG(L_CRIT, "BUG: do_action: bad log() types %d, %d\n",
LM_CRIT("bad log() types %d, %d\n",
a->val[0].type, a->val[1].type);
ret=E_BUG;
goto error;
@ -525,8 +529,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
/* jku -- introduce a new branch */
case APPEND_BRANCH_T:
if (unlikely(a->val[0].type!=STR_ST)) {
LOG(L_CRIT, "BUG: do_action: bad append_branch_t %d\n",
a->val[0].type );
LM_CRIT("bad append_branch_t %d\n", a->val[0].type );
ret=E_BUG;
goto error;
}
@ -560,8 +563,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
/* jku begin: is_length_greater_than */
case LEN_GT_T:
if (a->val[0].type!=NUMBER_ST) {
LOG(L_CRIT, "BUG: do_action: bad len_gt type %d\n",
a->val[0].type );
LM_CRIT("bad len_gt type %d\n", a->val[0].type );
ret=E_BUG;
goto error;
}
@ -575,8 +577,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
case SETFLAG_T:
if (a->val[0].type!=NUMBER_ST) {
LOG(L_CRIT, "BUG: do_action: bad setflag() type %d\n",
a->val[0].type );
LM_CRIT("bad setflag() type %d\n", a->val[0].type );
ret=E_BUG;
goto error;
}
@ -590,8 +591,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
case RESETFLAG_T:
if (a->val[0].type!=NUMBER_ST) {
LOG(L_CRIT, "BUG: do_action: bad resetflag() type %d\n",
a->val[0].type );
LM_CRIT("bad resetflag() type %d\n", a->val[0].type );
ret=E_BUG;
goto error;
}
@ -605,8 +605,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
case ISFLAGSET_T:
if (a->val[0].type!=NUMBER_ST) {
LOG(L_CRIT, "BUG: do_action: bad isflagset() type %d\n",
a->val[0].type );
LM_CRIT("bad isflagset() type %d\n", a->val[0].type );
ret=E_BUG;
goto error;
}
@ -662,12 +661,11 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
break;
case ERROR_T:
if ((a->val[0].type!=STRING_ST)|(a->val[1].type!=STRING_ST)){
LOG(L_CRIT, "BUG: do_action: bad error() types %d, %d\n",
a->val[0].type, a->val[1].type);
LM_CRIT("bad error() types %d, %d\n", a->val[0].type, a->val[1].type);
ret=E_BUG;
goto error;
}
LOG(L_NOTICE, "WARNING: do_action: error(\"%s\", \"%s\") "
LM_NOTICE("error(\"%s\", \"%s\") "
"not implemented yet\n", a->val[0].u.string, a->val[1].u.string);
ret=1;
break;
@ -699,13 +697,12 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
rval_cache_clean(&c1);
s.s = 0;
} else {
LOG(L_CRIT, "BUG: do_action: bad route() type %d\n",
a->val[0].type);
LM_CRIT("bad route() type %d\n", a->val[0].type);
ret=E_BUG;
goto error;
}
if (unlikely((i>=main_rt.idx)||(i<0))){
LOG(L_ERR, "ERROR: invalid routing table number in"
LM_ERR("invalid routing table number in"
"route(%lu) at %s:%d\n", a->val[0].u.number,
(a->cfile)?a->cfile:"line", a->cline);
ret=E_CFG;
@ -719,16 +716,15 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
break;
case EXEC_T:
if (a->val[0].type!=STRING_ST){
LOG(L_CRIT, "BUG: do_action: bad exec() type %d\n",
a->val[0].type);
LM_CRIT("bad exec() type %d\n", a->val[0].type);
ret=E_BUG;
goto error;
}
LOG(L_NOTICE, "WARNING: exec(\"%s\") not fully implemented,"
LM_NOTICE("exec(\"%s\") not fully implemented,"
" using dumb version...\n", a->val[0].u.string);
ret=system(a->val[0].u.string);
if (ret!=0){
LOG(L_NOTICE, "WARNING: exec() returned %d\n", ret);
LM_NOTICE("exec() returned %d\n", ret);
}
ret=1;
break;
@ -757,15 +753,13 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
user=0;
if (a->type==STRIP_T || a->type==STRIP_TAIL_T) {
if (a->val[0].type!=NUMBER_ST) {
LOG(L_CRIT, "BUG: do_action: bad set*() type %d\n",
a->val[0].type);
LM_CRIT("bad set*() type %d\n", a->val[0].type);
ret=E_BUG;
goto error;
}
} else if (a->type!=SET_USERPHONE_T) {
if (a->val[0].type!=STRING_ST) {
LOG(L_CRIT, "BUG: do_action: bad set*() type %d\n",
a->val[0].type);
LM_CRIT("bad set*() type %d\n", a->val[0].type);
ret=E_BUG;
goto error;
}
@ -779,8 +773,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
len=strlen(a->val[0].u.string);
msg->new_uri.s=pkg_malloc(len+1);
if (msg->new_uri.s==0){
LOG(L_ERR, "ERROR: do_action: memory allocation"
" failure\n");
LM_ERR("memory allocation failure\n");
ret=E_OUT_OF_MEM;
goto error;
}
@ -801,8 +794,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
len=msg->first_line.u.request.uri.len;
}
if (parse_uri(tmp, len, &uri)<0){
LOG(L_ERR, "ERROR: do_action: bad uri <%s>, dropping"
" packet\n", tmp);
LM_ERR("bad uri <%s>, dropping packet\n", tmp);
ret=E_UNSPEC;
goto error;
}
@ -824,15 +816,14 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
&& ((uri.type==TEL_URI_T) || (uri.type==TELS_URI_T))
&& ((uri.flags & URI_SIP_USER_PHONE)==0)
) {
LOG(L_ERR, "ERROR: do_action: port number of a tel: URI cannot be set\n");
LM_ERR("port number of a tel: URI cannot be set\n");
ret=E_UNSPEC;
goto error;
}
new_uri=pkg_malloc(MAX_URI_SIZE);
if (new_uri==0){
LOG(L_ERR, "ERROR: do_action: memory allocation "
" failure\n");
LM_ERR("memory allocation failure\n");
ret=E_OUT_OF_MEM;
goto error;
}
@ -881,8 +872,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
break;
default:
LOG(L_ERR, "ERROR: Unsupported URI scheme (%d), "
"reverted to sip:\n",
LM_ERR("Unsupported URI scheme (%d), reverted to sip:\n",
uri.type);
len=s_sip.len;
tmp=s_sip.s;
@ -908,8 +898,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
len=strlen(tmp);
} else if (a->type==STRIP_T) {
if (a->val[0].u.number>uri.user.len) {
LOG(L_WARN, "Error: too long strip asked; "
" deleting username: %lu of <%.*s>\n",
LM_WARN("too long strip asked; deleting username: %lu of <%.*s>\n",
a->val[0].u.number, uri.user.len, uri.user.s );
len=0;
} else if (a->val[0].u.number==uri.user.len) {
@ -920,7 +909,7 @@ int do_action(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
}
} else if (a->type==STRIP_TAIL_T) {
if (a->val[0].u.number>uri.user.len) {
LOG(L_WARN, "WARNING: too long strip_tail asked; "
LM_WARN("too long strip_tail asked; "
" deleting username: %lu of <%.*s>\n",
a->val[0].u.number, uri.user.len, uri.user.s );
len=0;
@ -1388,8 +1377,7 @@ match_cleanup:
i++;
if (unlikely(i > cfg_get(core, core_cfg, max_while_loops))){
LOG(L_ERR, "ERROR: runaway while (%d, %d): more then"
" %d loops\n",
LM_ERR("runaway while (%d, %d): more then %d loops\n",
rve->fpos.s_line, rve->fpos.s_col,
cfg_get(core, core_cfg, max_while_loops));
ret=-1;
@ -1417,8 +1405,7 @@ match_cleanup:
break;
case SET_ADV_ADDR_T:
if (a->val[0].type!=STR_ST){
LOG(L_CRIT, "BUG: do_action: bad set_advertised_address() "
"type %d\n", a->val[0].type);
LM_CRIT("bad set_advertised_address() type %d\n", a->val[0].type);
ret=E_BUG;
goto error;
}
@ -1427,8 +1414,7 @@ match_cleanup:
break;
case SET_ADV_PORT_T:
if (a->val[0].type!=STR_ST){
LOG(L_CRIT, "BUG: do_action: bad set_advertised_port() "
"type %d\n", a->val[0].type);
LM_CRIT("bad set_advertised_port() type %d\n", a->val[0].type);
ret=E_BUG;
goto error;
}
@ -1446,7 +1432,7 @@ match_cleanup:
if (a->val[0].type==NOSUBTYPE) port=msg->via1->port;
else if (a->val[0].type==NUMBER_ST) port=(int)a->val[0].u.number;
else{
LOG(L_CRIT, "BUG: do_action: bad force_tcp_alias"
LM_CRIT("bad force_tcp_alias"
" port type %d\n", a->val[0].type);
ret=E_BUG;
goto error;
@ -1454,7 +1440,7 @@ match_cleanup:
if (tcpconn_add_alias(msg->rcv.proto_reserved1, port,
msg->rcv.proto)!=0){
LOG(L_ERR, " ERROR: receive_msg: tcp alias failed\n");
LM_ERR("receive_msg: tcp alias failed\n");
ret=E_UNSPEC;
goto error;
}
@ -1464,7 +1450,7 @@ match_cleanup:
break;
case FORCE_SEND_SOCKET_T:
if (a->val[0].type!=SOCKETINFO_ST){
LOG(L_CRIT, "BUG: do_action: bad force_send_socket argument"
LM_CRIT("bad force_send_socket argument"
" type: %d\n", a->val[0].type);
ret=E_BUG;
goto error;
@ -1536,14 +1522,14 @@ match_cleanup:
break;
/*
default:
LOG(L_CRIT, "BUG: do_action: unknown type %d\n", a->type);
LM_CRIT("unknown type %d\n", a->type);
*/
}
skip:
return ret;
error_uri:
LOG(L_ERR, "ERROR: do_action: set*: uri too long\n");
LM_ERR("set*: uri too long\n");
if (new_uri) pkg_free(new_uri);
LM_ERR("run action error at: %s:%d\n", (a->cfile)?a->cfile:"", a->cline);
return E_UNSPEC;
@ -1567,9 +1553,8 @@ int run_actions(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
ret=E_UNSPEC;
h->rec_lev++;
if (unlikely(h->rec_lev>ROUTE_MAX_REC_LEV)){
LOG(L_ERR, "WARNING: too many recursive routing table lookups (%d)"
" giving up!\n", h->rec_lev);
if (unlikely(h->rec_lev>max_recursive_level)){
LM_ERR("too many recursive routing table lookups (%d) giving up!\n", h->rec_lev);
ret=E_UNSPEC;
goto error;
}
@ -1587,8 +1572,7 @@ int run_actions(struct run_act_ctx* h, struct action* a, struct sip_msg* msg)
}
if (unlikely(a==0)){
DBG("DEBUG: run_actions: null action list (rec_level=%d)\n",
h->rec_lev);
DBG("DEBUG: run_actions: null action list (rec_level=%d)\n", h->rec_lev);
ret=1;
}

@ -23,7 +23,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*!
@ -72,6 +72,8 @@ cfg_action_t *get_cfg_crt_action(void);
int get_cfg_crt_line(void);
char *get_cfg_crt_name(void);
void set_max_recursive_level(unsigned int lev);
#ifdef USE_LONGJMP
int run_actions_safe(struct run_act_ctx* c, struct action* a,
struct sip_msg* msg);
@ -79,4 +81,6 @@ int run_actions_safe(struct run_act_ctx* c, struct action* a,
#define run_actions_safe(c, a, m) run_actions(c, a, m)
#endif /* USE_LONGJMP */
void log_prefix_set(sip_msg_t *msg);
#endif

@ -0,0 +1,220 @@
/**
* Copyright (C) 2014 Daniel-Constantin Mierla (asipto.com)
*
* This file is part of Extensible SIP Router, a free SIP server.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/un.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <fcntl.h>
#include <errno.h>
#include "dprint.h"
#include "sr_module.h"
#include "ut.h"
#include "pt.h"
#include "cfg/cfg_struct.h"
#include "async_task.h"
static int _async_task_workers = 0;
static int _async_task_sockets[2];
int async_task_run(int idx);
/**
*
*/
int async_task_init_sockets(void)
{
if (socketpair(PF_UNIX, SOCK_DGRAM, 0, _async_task_sockets) < 0) {
LM_ERR("opening tasks dgram socket pair\n");
return -1;
}
LM_DBG("inter-process event notification sockets initialized\n");
return 0;
}
/**
*
*/
void async_task_close_sockets_child(void)
{
LM_DBG("closing the notification socket used by children\n");
close(_async_task_sockets[1]);
}
/**
*
*/
void async_task_close_sockets_parent(void)
{
LM_DBG("closing the notification socket used by parent\n");
close(_async_task_sockets[0]);
}
/**
*
*/
int async_task_init(void)
{
LM_DBG("start initializing asynk task framework\n");
if(_async_task_workers<=0)
return 0;
/* advertise new processes to core */
register_procs(_async_task_workers);
/* advertise new processes to cfg framework */
cfg_register_child(_async_task_workers);
return 0;
}
/**
*
*/
int async_task_initialized(void)
{
if(_async_task_workers<=0)
return 0;
return 1;
}
/**
*
*/
int async_task_child_init(int rank)
{
int pid;
int i;
if(_async_task_workers<=0)
return 0;
LM_DBG("child initializing asynk task framework\n");
if (rank==PROC_INIT) {
if(async_task_init_sockets()<0) {
LM_ERR("failed to initialize tasks sockets\n");
return -1;
}
return 0;
}
if(rank>0) {
async_task_close_sockets_parent();
return 0;
}
if (rank!=PROC_MAIN)
return 0;
for(i=0; i<_async_task_workers; i++) {
pid=fork_process(PROC_RPC, "Async Task Worker", 1);
if (pid<0)
return -1; /* error */
if(pid==0) {
/* child */
/* initialize the config framework */
if (cfg_child_init())
return -1;
/* main function for workers */
if(async_task_run(i+1)<0) {
LM_ERR("failed to initialize task worker process: %d\n", i);
return -1;
}
}
}
return 0;
}
/**
*
*/
int async_task_set_workers(int n)
{
if(_async_task_workers>0) {
LM_WARN("task workers already set\n");
return 0;
}
if(n<=0)
return 0;
_async_task_workers = n;
return 0;
}
/**
*
*/
int async_task_push(async_task_t *task)
{
int len;
if(_async_task_workers<=0)
return 0;
len = write(_async_task_sockets[1], &task, sizeof(async_task_t*));
if(len<=0) {
LM_ERR("failed to pass the task to asynk workers\n");
return -1;
}
LM_DBG("task sent [%p]\n", task);
return 0;
}
/**
*
*/
int async_task_run(int idx)
{
async_task_t *ptask;
int received;
LM_DBG("async task worker %d ready\n", idx);
for( ; ; ) {
if ((received = recvfrom(_async_task_sockets[0],
&ptask, sizeof(async_task_t*),
0, NULL, 0)) < 0) {
LM_ERR("failed to received task (%d: %s)\n", errno, strerror(errno));
continue;
}
if(received != sizeof(async_task_t*)) {
LM_ERR("invalid task size %d\n", received);
continue;
}
if(ptask->exec!=NULL) {
LM_DBG("task executed [%p] (%p/%p)\n", ptask,
ptask->exec, ptask->param);
ptask->exec(ptask->param);
}
shm_free(ptask);
}
return 0;
}

@ -0,0 +1,36 @@
/**
* Copyright (C) 2014 Daniel-Constantin Mierla (asipto.com)
*
* This file is part of Extensible SIP Router, a free SIP server.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#ifndef _ASYNC_TASK_H_
#define _ASYNC_TASK_H_
typedef void (*async_cbe_t)(void *p);
typedef struct _async_task {
async_cbe_t exec;
void *param;
} async_task_t;
int async_task_init(void);
int async_task_child_init(int rank);
int async_task_initialized(void);
int async_task_set_workers(int n);
int async_task_push(async_task_t *task);
#endif

@ -17,7 +17,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*!

@ -2,6 +2,6 @@
* DO NOT EDIT IT
*/
#define REPO_VER "010d57"
#define REPO_HASH "010d57"
#define REPO_VER "868a34"
#define REPO_HASH "868a34"
#define REPO_STATE ""

@ -24,7 +24,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* History:
* -------
@ -135,6 +135,9 @@
int startcolumn=1;
int startline=1;
char *finame = 0;
char *routename = 0;
char *default_routename = 0;
static int ign_lines=0;
static int ign_columns=0;
char* yy_number_str=0; /* str correspondent for the current NUMBER token */
@ -155,6 +158,7 @@
int startcolumn;
int startline;
char *finame;
char *routename;
} include_stack[MAX_INCLUDE_DEPTH];
static int include_stack_ptr = 0;
@ -342,6 +346,7 @@ LOGSTDERROR log_stderror
LOGFACILITY log_facility
LOGNAME log_name
LOGCOLOR log_color
LOGPREFIX log_prefix
LISTEN listen
ADVERTISE advertise|ADVERTISE
ALIAS alias
@ -392,6 +397,7 @@ MAXBUFFER maxbuffer
SQL_BUFFER_SIZE sql_buffer_size
CHILDREN children
SOCKET_WORKERS socket_workers
ASYNC_WORKERS async_workers
CHECK_VIA check_via
PHONE2TEL phone2tel
MEMLOG "memlog"|"mem_log"
@ -482,12 +488,14 @@ VERSION_TABLE_CFG "version_table"
SERVER_ID "server_id"
MAX_RECURSIVE_LEVEL "max_recursive_level"
LATENCY_LOG latency_log
LATENCY_LIMIT_DB latency_limit_db
LATENCY_LIMIT_ACTION latency_limit_action
MSG_TIME msg_time
ONSEND_RT_REPLY "onsend_route_reply"
CFG_DESCRIPTION "description"|"descr"|"desc"
LOADMODULE loadmodule
@ -593,16 +601,24 @@ IMPORTFILE "import_file"
<INITIAL>{ISAVPFLAGSET} { count(); yylval.strval=yytext; return ISAVPFLAGSET; }
<INITIAL>{AVPFLAGS_DECL} { count(); yylval.strval=yytext; return AVPFLAGS_DECL; }
<INITIAL>{MSGLEN} { count(); yylval.strval=yytext; return MSGLEN; }
<INITIAL>{ROUTE} { count(); yylval.strval=yytext; return ROUTE; }
<INITIAL>{ROUTE_REQUEST} { count(); yylval.strval=yytext; return ROUTE_REQUEST; }
<INITIAL>{ROUTE_ONREPLY} { count(); yylval.strval=yytext;
<INITIAL>{ROUTE} { count(); default_routename="DEFAULT_ROUTE";
yylval.strval=yytext; return ROUTE; }
<INITIAL>{ROUTE_REQUEST} { count(); default_routename="DEFAULT_ROUTE";
yylval.strval=yytext; return ROUTE_REQUEST; }
<INITIAL>{ROUTE_ONREPLY} { count(); default_routename="DEFAULT_ONREPLY";
yylval.strval=yytext;
return ROUTE_ONREPLY; }
<INITIAL>{ROUTE_REPLY} { count(); yylval.strval=yytext; return ROUTE_REPLY; }
<INITIAL>{ROUTE_FAILURE} { count(); yylval.strval=yytext;
<INITIAL>{ROUTE_REPLY} { count(); default_routename="DEFAULT_ONREPLY";
yylval.strval=yytext; return ROUTE_REPLY; }
<INITIAL>{ROUTE_FAILURE} { count(); default_routename="DEFAULT_FAILURE";
yylval.strval=yytext;
return ROUTE_FAILURE; }
<INITIAL>{ROUTE_BRANCH} { count(); yylval.strval=yytext; return ROUTE_BRANCH; }
<INITIAL>{ROUTE_SEND} { count(); yylval.strval=yytext; return ROUTE_SEND; }
<INITIAL>{ROUTE_EVENT} { count(); yylval.strval=yytext; return ROUTE_EVENT; }
<INITIAL>{ROUTE_BRANCH} { count(); default_routename="DEFAULT_BRANCH";
yylval.strval=yytext; return ROUTE_BRANCH; }
<INITIAL>{ROUTE_SEND} { count(); default_routename="DEFAULT_SEND";
yylval.strval=yytext; return ROUTE_SEND; }
<INITIAL>{ROUTE_EVENT} { count(); default_routename="DEFAULT_EVENT";
yylval.strval=yytext; return ROUTE_EVENT; }
<INITIAL>{EXEC} { count(); yylval.strval=yytext; return EXEC; }
<INITIAL>{SET_HOST} { count(); yylval.strval=yytext; return SET_HOST; }
<INITIAL>{SET_HOSTPORT} { count(); yylval.strval=yytext; return SET_HOSTPORT; }
@ -694,6 +710,7 @@ IMPORTFILE "import_file"
<INITIAL>{LOGFACILITY} { yylval.strval=yytext; return LOGFACILITY; }
<INITIAL>{LOGNAME} { yylval.strval=yytext; return LOGNAME; }
<INITIAL>{LOGCOLOR} { yylval.strval=yytext; return LOGCOLOR; }
<INITIAL>{LOGPREFIX} { yylval.strval=yytext; return LOGPREFIX; }
<INITIAL>{LISTEN} { count(); yylval.strval=yytext; return LISTEN; }
<INITIAL>{ADVERTISE} { count(); yylval.strval=yytext; return ADVERTISE; }
<INITIAL>{ALIAS} { count(); yylval.strval=yytext; return ALIAS; }
@ -773,6 +790,7 @@ IMPORTFILE "import_file"
<INITIAL>{SQL_BUFFER_SIZE} { count(); yylval.strval=yytext; return SQL_BUFFER_SIZE; }
<INITIAL>{CHILDREN} { count(); yylval.strval=yytext; return CHILDREN; }
<INITIAL>{SOCKET_WORKERS} { count(); yylval.strval=yytext; return SOCKET_WORKERS; }
<INITIAL>{ASYNC_WORKERS} { count(); yylval.strval=yytext; return ASYNC_WORKERS; }
<INITIAL>{CHECK_VIA} { count(); yylval.strval=yytext; return CHECK_VIA; }
<INITIAL>{PHONE2TEL} { count(); yylval.strval=yytext; return PHONE2TEL; }
<INITIAL>{MEMLOG} { count(); yylval.strval=yytext; return MEMLOG; }
@ -917,8 +935,10 @@ IMPORTFILE "import_file"
return HTTP_REPLY_PARSE; }
<INITIAL>{VERSION_TABLE_CFG} { count(); yylval.strval=yytext; return VERSION_TABLE_CFG;}
<INITIAL>{SERVER_ID} { count(); yylval.strval=yytext; return SERVER_ID;}
<INITIAL>{MAX_RECURSIVE_LEVEL} { count(); yylval.strval=yytext; return MAX_RECURSIVE_LEVEL;}
<INITIAL>{LATENCY_LOG} { count(); yylval.strval=yytext; return LATENCY_LOG;}
<INITIAL>{MSG_TIME} { count(); yylval.strval=yytext; return MSG_TIME;}
<INITIAL>{ONSEND_RT_REPLY} { count(); yylval.strval=yytext; return ONSEND_RT_REPLY; }
<INITIAL>{LATENCY_LIMIT_DB} { count(); yylval.strval=yytext; return LATENCY_LIMIT_DB;}
<INITIAL>{LATENCY_LIMIT_ACTION} { count(); yylval.strval=yytext; return LATENCY_LIMIT_ACTION;}
<INITIAL>{CFG_DESCRIPTION} { count(); yylval.strval=yytext; return CFG_DESCRIPTION; }
@ -1588,6 +1608,7 @@ static int sr_push_yy_state(char *fin, int mode)
include_stack[include_stack_ptr].startline = startline;
include_stack[include_stack_ptr].startcolumn = startcolumn;
include_stack[include_stack_ptr].finame = finame;
include_stack[include_stack_ptr].routename = routename;
include_stack_ptr++;
line=1;
@ -1825,6 +1846,7 @@ static int pp_ifdef_type(int type)
}
pp_ifdef_stack[pp_sptr] = type;
pp_ifdef_level_update(1);
return 0;
}
@ -1867,6 +1889,7 @@ static void pp_else()
static void pp_endif()
{
pp_sptr--;
pp_ifdef_level_update(-1);
pp_update_state();
}

45
cfg.y

@ -24,7 +24,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*
* History:
@ -141,6 +141,7 @@
#include "rvalue.h"
#include "sr_compat.h"
#include "msg_translator.h"
#include "async_task.h"
#include "ppcfg.h"
#include "pvapi.h"
@ -255,12 +256,15 @@ extern int column;
extern int startcolumn;
extern int startline;
extern char *finame;
extern char *routename;
extern char *default_routename;
#define set_cfg_pos(x) \
do{\
if(x) {\
(x)->cline = line;\
(x)->cfile = (finame!=0)?finame:((cfg_file!=0)?cfg_file:"default");\
(x)->rname = (routename!=0)?routename:((default_routename!=0)?default_routename:"DEFAULT");\
}\
}while(0)
@ -391,6 +395,7 @@ extern char *finame;
%token LOGFACILITY
%token LOGNAME
%token LOGCOLOR
%token LOGPREFIX
%token LISTEN
%token ADVERTISE
%token ALIAS
@ -439,6 +444,7 @@ extern char *finame;
%token STAT
%token CHILDREN
%token SOCKET_WORKERS
%token ASYNC_WORKERS
%token CHECK_VIA
%token PHONE2TEL
%token MEMLOG
@ -536,10 +542,12 @@ extern char *finame;
%token VERSION_TABLE_CFG
%token CFG_DESCRIPTION
%token SERVER_ID
%token MAX_RECURSIVE_LEVEL
%token LATENCY_LOG
%token LATENCY_LIMIT_DB
%token LATENCY_LIMIT_ACTION
%token MSG_TIME
%token ONSEND_RT_REPLY
%token FLAGS_DECL
%token AVPFLAGS_DECL
@ -837,6 +845,8 @@ assign_stm:
| LOGNAME EQUAL error { yyerror("string value expected"); }
| LOGCOLOR EQUAL NUMBER { log_color=$3; }
| LOGCOLOR EQUAL error { yyerror("boolean value expected"); }
| LOGPREFIX EQUAL STRING { log_prefix_fmt=$3; }
| LOGPREFIX EQUAL error { yyerror("string value expected"); }
| DNS EQUAL NUMBER { received_dns|= ($3)?DO_DNS:0; }
| DNS EQUAL error { yyerror("boolean value expected"); }
| REV_DNS EQUAL NUMBER { received_dns|= ($3)?DO_REV_DNS:0; }
@ -937,6 +947,8 @@ assign_stm:
| CHILDREN EQUAL error { yyerror("number expected"); }
| SOCKET_WORKERS EQUAL NUMBER { socket_workers=$3; }
| SOCKET_WORKERS EQUAL error { yyerror("number expected"); }
| ASYNC_WORKERS EQUAL NUMBER { async_task_set_workers($3); }
| ASYNC_WORKERS EQUAL error { yyerror("number expected"); }
| CHECK_VIA EQUAL NUMBER { check_via=$3; }
| CHECK_VIA EQUAL error { yyerror("boolean value expected"); }
| PHONE2TEL EQUAL NUMBER { phone2tel=$3; }
@ -1559,6 +1571,7 @@ assign_stm:
| HTTP_REPLY_PARSE EQUAL NUMBER { http_reply_parse=$3; }
| HTTP_REPLY_PARSE EQUAL error { yyerror("boolean value expected"); }
| SERVER_ID EQUAL NUMBER { server_id=$3; }
| MAX_RECURSIVE_LEVEL EQUAL NUMBER { set_max_recursive_level($3); }
| LATENCY_LOG EQUAL NUMBER { default_core_cfg.latency_log=$3; }
| LATENCY_LOG EQUAL error { yyerror("number expected"); }
| LATENCY_LIMIT_DB EQUAL NUMBER { default_core_cfg.latency_limit_db=$3; }
@ -1567,6 +1580,8 @@ assign_stm:
| LATENCY_LIMIT_ACTION EQUAL error { yyerror("number expected"); }
| MSG_TIME EQUAL NUMBER { sr_msg_time=$3; }
| MSG_TIME EQUAL error { yyerror("number expected"); }
| ONSEND_RT_REPLY EQUAL NUMBER { onsend_route_reply=$3; }
| ONSEND_RT_REPLY EQUAL error { yyerror("int value expected"); }
| UDP_MTU EQUAL NUMBER { default_core_cfg.udp_mtu=$3; }
| UDP_MTU EQUAL error { yyerror("number expected"); }
| FORCE_RPORT EQUAL NUMBER
@ -1639,15 +1654,25 @@ module_stm:
}
| LOADMODULE error { yyerror("string expected"); }
| LOADPATH STRING {
DBG("loading modules under %s\n", $2);
printf("loading modules under %s\n", $2);
mods_dir = $2;
if(mods_dir_cmd==0) {
DBG("loading modules under %s\n", $2);
printf("loading modules under config path: %s\n", $2);
mods_dir = $2;
} else {
DBG("ignoring mod path given in config: %s\n", $2);
printf("loading modules under command line path: %s\n", mods_dir);
}
}
| LOADPATH error { yyerror("string expected"); }
| LOADPATH EQUAL STRING {
DBG("loading modules under %s\n", $3);
printf("loading modules under %s\n", $3);
mods_dir = $3;
if(mods_dir_cmd==0) {
DBG("loading modules under %s\n", $3);
printf("loading modules under config path: %s\n", $3);
mods_dir = $3;
} else {
DBG("ignoring mod path given in config: %s\n", $3);
printf("loading modules under command line path: %s\n", mods_dir);
}
}
| LOADPATH EQUAL error { yyerror("string expected"); }
| MODPARAM LPAREN STRING COMMA STRING COMMA STRING RPAREN {
@ -1737,9 +1762,10 @@ route_name: NUMBER {
memcpy($$, tmp, i_tmp);
$$[i_tmp]=0;
}
routename = tmp;
}
| ID { $$=$1; }
| STRING { $$=$1; }
| ID { routename = $1; $$=$1; }
| STRING { routename = $1; $$=$1; }
;
@ -3366,6 +3392,7 @@ static void get_cpos(struct cfg_pos* pos)
if(finame==0)
finame = (cfg_file!=0)?cfg_file:"default";
pos->fname=finame;
pos->rname=(routename!=0)?routename:default_routename;
}

@ -17,7 +17,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* History
* -------

@ -17,7 +17,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* History
* -------

@ -17,7 +17,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* History
* -------

@ -17,7 +17,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* History
* -------

@ -17,7 +17,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* History
* -------

@ -17,7 +17,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* History
* -------

@ -17,7 +17,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* History
* -------

@ -17,7 +17,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* History
* -------

@ -17,7 +17,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* History
* -------

@ -17,7 +17,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* History
* -------

@ -17,7 +17,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* History
* -------
@ -64,7 +64,7 @@
struct cfg_group_core default_core_cfg = {
L_WARN, /*!< print only msg. < L_WARN */
LOG_DAEMON, /*!< log_facility -- see syslog(3) */
L_DBG, /*!< memdbg */
L_DBG+1, /*!< memdbg */
#ifdef USE_DST_BLACKLIST
/* blacklist */
0, /*!< dst blacklist is disabled by default */
@ -115,7 +115,7 @@ struct cfg_group_core default_core_cfg = {
1500, /**< udp4_raw_mtu (1500 by default) */
-1, /**< udp4_raw_ttl (auto detect by default) */
0, /*!< force_rport */
L_DBG, /*!< memlog */
L_DBG+1, /*!< memlog */
3, /*!< mem_summary -flags: 0 off, 1 pkg_status, 2 shm_status,
4 pkg_sums, 8 shm_sums, 16 short_status */
0, /*!< mem_safety - 0 disabled */

@ -22,7 +22,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* HOWTO:
* If you need a new configuration variable within the core, put it into

@ -19,7 +19,7 @@
*
* 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.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*!
* \file

@ -19,7 +19,7 @@
*
* 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.,
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*!

@ -57,8 +57,7 @@ inline static int char_msg_val( struct sip_msg *msg, char *cv )
str src[8];
if (unlikely(!check_transaction_quadruple(msg))) {
LOG(L_ERR, "ERROR: can't calculate char_value due "
"to a parsing error\n");
LM_ERR("can't calculate char_value due to a parsing error\n");
memset( cv, '0', MD5_LEN );
return 0;
}
@ -81,7 +80,7 @@ inline static int char_msg_val( struct sip_msg *msg, char *cv )
if (msg->from->parsed==0){
/* parse from body */
if (unlikely(parse_from_header(msg) == -1)){
LOG(L_ERR, "error while parsing From header\n");
LM_ERR("error while parsing From header\n");
return 0;
}
}

@ -19,7 +19,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*!

@ -17,7 +17,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*! \brief compatibility defs for emergency roll-back if things do not work ;

@ -17,7 +17,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* History:
* --------
@ -66,9 +66,6 @@
#define EVENT_RT_NO RT_NO /*!< event_route routing tables number */
#define DEFAULT_RT 0 /*!< default routing table */
#define MAX_REC_LEV 100 /*!< maximum number of recursive calls */
#define ROUTE_MAX_REC_LEV 100 /*!< maximum number of recursive calls for route()*/
#define MAX_URI_SIZE 1024 /*!< Max URI size used when rewriting URIs */
#define MAX_PATH_SIZE 256 /*!< Maximum length of path header buffer */
@ -147,11 +144,11 @@
#define SRV_MAX_PREFIX_LEN SRV_TLS_PREFIX_LEN
#ifndef PKG_MEM_SIZE
#define PKG_MEM_SIZE 4
#define PKG_MEM_SIZE 8
#endif
#define PKG_MEM_POOL_SIZE PKG_MEM_SIZE*1024*1024 /*!< used only if PKG_MALLOC is defined*/
#define SHM_MEM_SIZE 32 /*!< used if SH_MEM is defined*/
#define SHM_MEM_SIZE 64 /*!< used if SH_MEM is defined*/
/* dimensioning buckets in q_malloc */
@ -169,7 +166,7 @@
#define BUF_SIZE 65535
#define MAX_VIA_LINE_SIZE 240 /*!< forwarding -- Via buffer dimensioning */
#define MAX_RECEIVED_SIZE 57 /*!< forwarding -- Via buffer dimensioning - Received header */
#define MAX_RECEIVED_SIZE 59 /*!< forwarding -- Via buffer dimensioning - Received header */
#define MAX_RPORT_SIZE 13 /*!< forwarding -- Via buffer dimensioning - Rport */
#define MAX_BRANCHES 12 /*!< maximum number of branches per transaction */

@ -17,7 +17,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/** core rpcs.
@ -969,7 +969,7 @@ static rpc_export_t core_rpc_methods[] = {
0 },
{"core.uptime", core_uptime, core_uptime_doc, 0 },
{"core.ps", core_ps, core_ps_doc, RET_ARRAY},
{"core.psx", core_psx, core_psx_doc, 0},
{"core.psx", core_psx, core_psx_doc, RET_ARRAY},
{"core.pwd", core_pwd, core_pwd_doc, RET_ARRAY},
{"core.arg", core_arg, core_arg_doc, RET_ARRAY},
{"core.kill", core_kill, core_kill_doc, 0 },

@ -22,7 +22,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*!

@ -19,7 +19,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*!
* \file
@ -243,7 +243,7 @@ void crcitt_string_array( char *dst, str src[], int size )
ccitt = ~ccitt;
if (int2reverse_hex( &dst, &str_len, ccitt )==-1) {
/* bug ... printed ccitt value longer than CRC32_LEN */
LOG(L_CRIT, "ERROR: crcitt_string_array: string conversion incomplete\n");
LM_CRIT("string conversion incomplete\n");
}
/* padding */
while( str_len ) {

@ -224,11 +224,11 @@ int enable_dumpable(void)
} else {
LM_DBG("core dumping has just been enabled...\n");
if (getrlimit(RLIMIT_CORE, &lim)<0){
LOG(L_CRIT, "cannot get the maximum core size: %s\n",
LM_CRIT( "cannot get the maximum core size: %s\n",
strerror(errno));
return -1;
} else {
DBG("current core file limit: %lu (max: %lu)\n",
LM_DBG("current core file limit: %lu (max: %lu)\n",
(unsigned long)lim.rlim_cur, (unsigned long)lim.rlim_max);
}
}
@ -272,6 +272,14 @@ int daemonize(char* name, int status_wait)
pid_t pid;
int r, p;
char pipe_status;
uid_t pid_uid;
gid_t pid_gid;
if(uid) pid_uid = uid;
else pid_uid = -1;
if(gid) pid_gid = gid;
else pid_gid = -1;
p=-1;
/* flush std file descriptors to avoid flushes after fork
@ -281,12 +289,12 @@ int daemonize(char* name, int status_wait)
setbuf(stdout, 0);
setbuf(stderr, 0);
if (chroot_dir&&(chroot(chroot_dir)<0)){
LOG(L_CRIT, "Cannot chroot to %s: %s\n", chroot_dir, strerror(errno));
LM_CRIT("Cannot chroot to %s: %s\n", chroot_dir, strerror(errno));
goto error;
}
if (chdir(working_dir)<0){
LOG(L_CRIT,"cannot chdir to %s: %s\n", working_dir, strerror(errno));
LM_CRIT("cannot chdir to %s: %s\n", working_dir, strerror(errno));
goto error;
}
@ -297,14 +305,14 @@ int daemonize(char* name, int status_wait)
}
/* fork to become!= group leader*/
if ((pid=fork())<0){
LOG(L_CRIT, "Cannot fork:%s\n", strerror(errno));
LM_CRIT("Cannot fork:%s\n", strerror(errno));
goto error;
}else if (pid!=0){
if (status_wait) {
if (daemon_status_wait(&pipe_status) == 0)
exit((int)pipe_status);
else{
LOG(L_ERR, "Main process exited before writing to pipe\n");
LM_ERR("Main process exited before writing to pipe\n");
exit(-1);
}
}
@ -314,13 +322,13 @@ int daemonize(char* name, int status_wait)
daemon_status_no_wait(); /* clean unused read fd */
/* become session leader to drop the ctrl. terminal */
if (setsid()<0){
LOG(L_WARN, "setsid failed: %s\n",strerror(errno));
LM_WARN("setsid failed: %s\n",strerror(errno));
}else{
own_pgid=1;/* we have our own process group */
}
/* fork again to drop group leadership */
if ((pid=fork())<0){
LOG(L_CRIT, "Cannot fork:%s\n", strerror(errno));
LM_CRIT("Cannot fork:%s\n", strerror(errno));
goto error;
}else if (pid!=0){
/*parent process => exit */
@ -340,26 +348,30 @@ int daemonize(char* name, int status_wait)
}
fclose(pid_stream);
if (p==-1){
LOG(L_CRIT, "pid file %s exists, but doesn't contain a valid"
LM_CRIT("pid file %s exists, but doesn't contain a valid"
" pid number\n", pid_file);
goto error;
}
if (kill((pid_t)p, 0)==0 || errno==EPERM){
LOG(L_CRIT, "running process found in the pid file %s\n",
LM_CRIT("running process found in the pid file %s\n",
pid_file);
goto error;
}else{
LOG(L_WARN, "pid file contains old pid, replacing pid\n");
LM_WARN("pid file contains old pid, replacing pid\n");
}
}
pid=getpid();
if ((pid_stream=fopen(pid_file, "w"))==NULL){
LOG(L_WARN, "unable to create pid file %s: %s\n",
LM_WARN("unable to create pid file %s: %s\n",
pid_file, strerror(errno));
goto error;
}else{
fprintf(pid_stream, "%i\n", (int)pid);
fclose(pid_stream);
if(chown(pid_file, pid_uid, pid_gid)<0) {
LM_ERR("failed to chwon PID file: %s\n", strerror(errno));
goto error;
}
}
}
@ -370,7 +382,7 @@ int daemonize(char* name, int status_wait)
}
fclose(pid_stream);
if (p==-1){
LOG(L_CRIT, "pgid file %s exists, but doesn't contain a valid"
LM_CRIT("pgid file %s exists, but doesn't contain a valid"
" pgid number\n", pgid_file);
goto error;
}
@ -378,15 +390,19 @@ int daemonize(char* name, int status_wait)
if (own_pgid){
pid=getpgid(0);
if ((pid_stream=fopen(pgid_file, "w"))==NULL){
LOG(L_WARN, "unable to create pgid file %s: %s\n",
LM_WARN("unable to create pgid file %s: %s\n",
pgid_file, strerror(errno));
goto error;
}else{
fprintf(pid_stream, "%i\n", (int)pid);
fclose(pid_stream);
if(chown(pid_file, pid_uid, pid_gid)<0) {
LM_ERR("failed to chwon PGID file: %s\n", strerror(errno));
goto error;
}
}
}else{
LOG(L_WARN, "we don't have our own process so we won't save"
LM_WARN("we don't have our own process so we won't save"
" our pgid\n");
unlink(pgid_file); /* just to be sure nobody will miss-use the old
value*/
@ -395,18 +411,18 @@ int daemonize(char* name, int status_wait)
/* try to replace stdin, stdout & stderr with /dev/null */
if (freopen("/dev/null", "r", stdin)==0){
LOG(L_ERR, "unable to replace stdin with /dev/null: %s\n",
LM_ERR("unable to replace stdin with /dev/null: %s\n",
strerror(errno));
/* continue, leave it open */
};
if (freopen("/dev/null", "w", stdout)==0){
LOG(L_ERR, "unable to replace stdout with /dev/null: %s\n",
LM_ERR("unable to replace stdout with /dev/null: %s\n",
strerror(errno));
/* continue, leave it open */
};
/* close stderr only if log_stderr=0 */
if ((!log_stderr) &&(freopen("/dev/null", "w", stderr)==0)){
LOG(L_ERR, "unable to replace stderr with /dev/null: %s\n",
LM_ERR("unable to replace stderr with /dev/null: %s\n",
strerror(errno));
/* continue, leave it open */
};
@ -437,23 +453,23 @@ int do_suid()
if (gid){
if(setgid(gid)<0){
LOG(L_CRIT, "cannot change gid to %d: %s\n", gid, strerror(errno));
LM_CRIT("cannot change gid to %d: %s\n", gid, strerror(errno));
goto error;
}
}
if(uid){
if (!(pw = getpwuid(uid))){
LOG(L_CRIT, "user lookup failed: %s\n", strerror(errno));
LM_CRIT("user lookup failed: %s\n", strerror(errno));
goto error;
}
if(initgroups(pw->pw_name, pw->pw_gid)<0){
LOG(L_CRIT, "cannot set supplementary groups: %s\n",
LM_CRIT("cannot set supplementary groups: %s\n",
strerror(errno));
goto error;
}
if(setuid(uid)<0){
LOG(L_CRIT, "cannot change uid to %d: %s\n", uid, strerror(errno));
LM_CRIT("cannot change uid to %d: %s\n", uid, strerror(errno));
goto error;
}
}
@ -475,7 +491,7 @@ int increase_open_fds(int target)
struct rlimit orig;
if (getrlimit(RLIMIT_NOFILE, &lim)<0){
LOG(L_CRIT, "cannot get the maximum number of file descriptors: %s\n",
LM_CRIT("cannot get the maximum number of file descriptors: %s\n",
strerror(errno));
goto error;
}
@ -489,7 +505,7 @@ int increase_open_fds(int target)
lim.rlim_cur=target; /* increase soft limit to target */
}else{
/* more than the hard limit */
LOG(L_INFO, "trying to increase the open file limit"
LM_INFO("trying to increase the open file limit"
" past the hard limit (%ld -> %d)\n",
(unsigned long)lim.rlim_max, target);
lim.rlim_max=target;
@ -498,7 +514,7 @@ int increase_open_fds(int target)
DBG("increasing open file limits to: %lu/%lu\n",
(unsigned long)lim.rlim_cur, (unsigned long)lim.rlim_max);
if (setrlimit(RLIMIT_NOFILE, &lim)<0){
LOG(L_CRIT, "cannot increase the open file limit to"
LM_CRIT("cannot increase the open file limit to"
" %lu/%lu: %s\n",
(unsigned long)lim.rlim_cur, (unsigned long)lim.rlim_max,
strerror(errno));
@ -508,7 +524,7 @@ int increase_open_fds(int target)
lim.rlim_max=orig.rlim_max;
lim.rlim_cur=orig.rlim_max;
if (setrlimit(RLIMIT_NOFILE, &lim)==0){
LOG(L_CRIT, " maximum number of file descriptors increased to"
LM_CRIT(" maximum number of file descriptors increased to"
" %u\n",(unsigned)orig.rlim_max);
}
}
@ -530,7 +546,7 @@ int set_core_dump(int enable, long unsigned int size)
if (enable){
if (getrlimit(RLIMIT_CORE, &lim)<0){
LOG(L_CRIT, "cannot get the maximum core size: %s\n",
LM_CRIT("cannot get the maximum core size: %s\n",
strerror(errno));
goto error;
}
@ -549,10 +565,10 @@ int set_core_dump(int enable, long unsigned int size)
newlim.rlim_max=lim.rlim_max;
newlim.rlim_cur=newlim.rlim_max;
if (setrlimit(RLIMIT_CORE, &newlim)<0){
LOG(L_CRIT, "could increase core limits at all: %s\n",
LM_CRIT("could increase core limits at all: %s\n",
strerror (errno));
}else{
LOG(L_CRIT, "core limits increased only to %lu\n",
LM_CRIT("core limits increased only to %lu\n",
(unsigned long)lim.rlim_max);
}
goto error; /* it's an error we haven't got the size we wanted*/
@ -566,7 +582,7 @@ int set_core_dump(int enable, long unsigned int size)
newlim.rlim_cur=0;
newlim.rlim_max=0;
if (setrlimit(RLIMIT_CORE, &newlim)<0){
LOG(L_CRIT, "failed to disable core dumps: %s\n",
LM_CRIT("failed to disable core dumps: %s\n",
strerror(errno));
goto error;
}
@ -585,7 +601,7 @@ int mem_lock_pages()
{
#ifdef HAVE_MLOCKALL
if (mlockall(MCL_CURRENT|MCL_FUTURE) !=0){
LOG(L_WARN,"failed to lock the memory pages (disable swap): %s [%d]\n",
LM_WARN("failed to lock the memory pages (disable swap): %s [%d]\n",
strerror(errno), errno);
goto error;
}
@ -593,7 +609,7 @@ int mem_lock_pages()
error:
return -1;
#else /* if MLOCKALL not defined return error */
LOG(L_WARN,"failed to lock the memory pages: no mlockall support\n");
LM_WARN("failed to lock the memory pages: no mlockall support\n");
return -1;
#endif
}
@ -619,31 +635,30 @@ int set_rt_prio(int prio, int policy)
sched_policy=SCHED_FIFO;
break;
default:
LOG(L_WARN, "WARNING: invalid scheduling policy,using"
" SCHED_OTHER\n");
LM_WARN("invalid scheduling policy,using SCHED_OTHER\n");
sched_policy=SCHED_OTHER;
}
memset(&sch_p, 0, sizeof(sch_p));
max_prio=sched_get_priority_max(policy);
min_prio=sched_get_priority_min(policy);
if (prio<min_prio){
LOG(L_WARN, "scheduling priority %d too small, using minimum value"
LM_WARN("scheduling priority %d too small, using minimum value"
" (%d)\n", prio, min_prio);
prio=min_prio;
}else if (prio>max_prio){
LOG(L_WARN, "scheduling priority %d too big, using maximum value"
LM_WARN("scheduling priority %d too big, using maximum value"
" (%d)\n", prio, max_prio);
prio=max_prio;
}
sch_p.sched_priority=prio;
if (sched_setscheduler(0, sched_policy, &sch_p) != 0){
LOG(L_WARN, "could not switch to real time priority: %s [%d]\n",
LM_WARN("could not switch to real time priority: %s [%d]\n",
strerror(errno), errno);
return -1;
};
return 0;
#else
LOG(L_WARN, "real time support not available\n");
LM_WARN("real time support not available\n");
return -1;
#endif
}

@ -17,7 +17,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* History:
* --------
@ -68,7 +68,7 @@ struct lump* append_new_lump(struct lump** list, char* new_hdr,
tmp=pkg_malloc(sizeof(struct lump));
if (tmp==0){
LOG(L_ERR, "ERROR: append_new_lump: out of memory\n");
LM_ERR("out of memory\n");
return 0;
}
@ -94,7 +94,7 @@ struct lump* add_new_lump(struct lump** list, char* new_hdr,
tmp=pkg_malloc(sizeof(struct lump));
if (tmp==0){
LOG(L_ERR, "ERROR: add_new_lump: out of memory\n");
LM_ERR("out of memory\n");
return 0;
}
@ -119,7 +119,7 @@ struct lump* insert_new_lump(struct lump** list, char* new_hdr,
tmp=pkg_malloc(sizeof(struct lump));
if (tmp==0){
LOG(L_ERR, "ERROR: insert_new_lump: out of memory\n");
LM_ERR("out of memory\n");
return 0;
}
memset(tmp,0,sizeof(struct lump));
@ -144,7 +144,7 @@ struct lump* insert_new_lump_after( struct lump* after, char* new_hdr,
tmp=pkg_malloc(sizeof(struct lump));
if (tmp==0){
ser_error=E_OUT_OF_MEM;
LOG(L_ERR, "ERROR: insert_new_lump_after: out of memory\n");
LM_ERR("out of memory\n");
return 0;
}
memset(tmp,0,sizeof(struct lump));
@ -169,7 +169,7 @@ struct lump* insert_new_lump_before( struct lump* before, char* new_hdr,
tmp=pkg_malloc(sizeof(struct lump));
if (tmp==0){
ser_error=E_OUT_OF_MEM;
LOG(L_ERR,"ERROR: insert_new_lump_before: out of memory\n");
LM_ERR("out of memory\n");
return 0;
}
memset(tmp,0,sizeof(struct lump));
@ -194,7 +194,7 @@ struct lump* insert_subst_lump_after( struct lump* after, enum lump_subst subst,
tmp=pkg_malloc(sizeof(struct lump));
if (tmp==0){
ser_error=E_OUT_OF_MEM;
LOG(L_ERR, "ERROR: insert_new_lump_after: out of memory\n");
LM_ERR("out of memory\n");
return 0;
}
memset(tmp,0,sizeof(struct lump));
@ -220,7 +220,7 @@ struct lump* insert_subst_lump_before( struct lump* before,
tmp=pkg_malloc(sizeof(struct lump));
if (tmp==0){
ser_error=E_OUT_OF_MEM;
LOG(L_ERR,"ERROR: insert_new_lump_before: out of memory\n");
LM_ERR("out of memory\n");
return 0;
}
memset(tmp,0,sizeof(struct lump));
@ -245,7 +245,7 @@ struct lump* insert_cond_lump_after( struct lump* after, enum lump_conditions c,
tmp=pkg_malloc(sizeof(struct lump));
if (tmp==0){
ser_error=E_OUT_OF_MEM;
LOG(L_ERR, "ERROR: insert_new_lump_after: out of memory\n");
LM_ERR("out of memory\n");
return 0;
}
memset(tmp,0,sizeof(struct lump));
@ -271,7 +271,7 @@ struct lump* insert_cond_lump_before( struct lump* before,
tmp=pkg_malloc(sizeof(struct lump));
if (tmp==0){
ser_error=E_OUT_OF_MEM;
LOG(L_ERR,"ERROR: insert_new_lump_before: out of memory\n");
LM_ERR("out of memory\n");
return 0;
}
memset(tmp,0,sizeof(struct lump));
@ -299,23 +299,22 @@ struct lump* del_lump(struct sip_msg* msg, int offset, int len, enum _hdr_types_
/* extra checks */
if (offset>msg->len){
LOG(L_CRIT, "BUG: del_lump: offset exceeds message size (%d > %d)"
" aborting...\n", offset, msg->len);
LM_CRIT("offset exceeds message size (%d > %d) aborting...\n",
offset, msg->len);
abort();
}
if (offset+len>msg->len){
LOG(L_CRIT, " BUG: del_lump: offset + len exceeds message"
" size (%d + %d > %d)\n", offset, len, msg->len);
LM_CRIT("offset + len exceeds message size (%d + %d > %d)\n",
offset, len, msg->len);
abort();
}
if (len==0){
LOG(L_WARN, "WARNING: del_lump: called with 0 len (offset =%d)\n",
offset);
LM_WARN("0 len (offset=%d)\n", offset);
}
tmp=pkg_malloc(sizeof(struct lump));
if (tmp==0){
LOG(L_ERR, "ERROR: del_lump: out of memory\n");
LM_ERR("out of memory\n");
return 0;
}
memset(tmp,0,sizeof(struct lump));
@ -356,21 +355,21 @@ struct lump* anchor_lump(struct sip_msg* msg, int offset, int len, enum _hdr_typ
/* extra checks */
if (offset>msg->len){
LOG(L_CRIT, "BUG: anchor_lump: offset exceeds message size (%d > %d)"
" aborting...\n", offset, msg->len);
LM_CRIT("offset exceeds message size (%d > %d) aborting...\n",
offset, msg->len);
abort();
}
if (len){
LOG(L_WARN, "WARNING: anchor_lump: called with len !=0 (%d)\n", len);
LM_WARN("len !=0 (%d)\n", len);
if (offset+len>msg->len)
LOG(L_WARN, "WARNING: anchor_lump: offset + len exceeds message"
" size (%d + %d > %d)\n", offset, len, msg->len);
LM_WARN("offset + len exceeds message size (%d + %d > %d)\n",
offset, len, msg->len);
}
tmp=pkg_malloc(sizeof(struct lump));
if (tmp==0){
ser_error=E_OUT_OF_MEM;
LOG(L_ERR, "ERROR: anchor_lump: out of memory\n");
LM_ERR("out of memory\n");
return 0;
}
memset(tmp,0,sizeof(struct lump));
@ -416,15 +415,15 @@ struct lump* anchor_lump2(struct sip_msg* msg, int offset, int len, enum _hdr_ty
/* extra checks */
if (offset>msg->len){
LOG(L_CRIT, "BUG: anchor_lump2: offset exceeds message size (%d > %d)"
" aborting...\n", offset, msg->len);
LM_CRIT("offset exceeds message size (%d > %d) aborting...\n",
offset, msg->len);
abort();
}
if (len){
LOG(L_WARN, "WARNING: anchor_lump2: called with len !=0 (%d)\n", len);
LM_WARN("len !=0 (%d)\n", len);
if (offset+len>msg->len)
LOG(L_WARN, "WARNING: anchor_lump2: offset + len exceeds message"
" size (%d + %d > %d)\n", offset, len, msg->len);
LM_WARN("offset + len exceeds message size (%d + %d > %d)\n",
offset, len, msg->len);
}
prev=0;
@ -448,7 +447,7 @@ struct lump* anchor_lump2(struct sip_msg* msg, int offset, int len, enum _hdr_ty
tmp=pkg_malloc(sizeof(struct lump));
if (tmp==0){
ser_error=E_OUT_OF_MEM;
LOG(L_ERR, "ERROR: anchor_lump2: out of memory\n");
LM_ERR("out of memory\n");
return 0;
}
memset(tmp,0,sizeof(struct lump));
@ -472,8 +471,7 @@ void free_lump(struct lump* lmp)
if (lmp && (lmp->op==LUMP_ADD)){
if (lmp->u.value){
if (lmp->flags &(LUMPFLAG_DUPED|LUMPFLAG_SHMEM)){
LOG(L_CRIT, "BUG: free_lump: called on a not free-able lump:"
"%p flags=%x\n", lmp, lmp->flags);
LM_CRIT("non free-able lump: %p flags=%x\n", lmp, lmp->flags);
abort();
}else{
pkg_free(lmp->u.value);
@ -574,8 +572,7 @@ static struct lump *dup_lump_list_r( struct lump *l,
LD_AFTER, &deep_error);
break;
default:
LOG(L_CRIT, "BUG: dup_limp_list_r: unknown dir: "
"%d\n", dir );
LM_CRIT("unknown dir: %d\n", dir );
deep_error=1;
}
if (deep_error) goto deeperror;
@ -584,7 +581,7 @@ static struct lump *dup_lump_list_r( struct lump *l,
return new_lump;
deeperror:
LOG(L_ERR, "ERROR: dup_lump_list_r: out of mem\n");
LM_ERR("out of mem\n");
free_shallow_lump(new_lump);
*error=1;
return 0;

@ -19,7 +19,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* History:

@ -23,7 +23,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* History:
* 2002-02-14 : created by bogdan
@ -60,11 +60,11 @@ struct lump_rpl** add_lump_rpl2(struct sip_msg *msg, char *s,
/* some checking */
if ( (flags&(LUMP_RPL_HDR|LUMP_RPL_BODY))==(LUMP_RPL_HDR|LUMP_RPL_BODY)
|| (flags&(LUMP_RPL_HDR|LUMP_RPL_BODY))==0 || (flags&LUMP_RPL_SHMEM) ) {
LOG(L_ERR,"ERROR:add_lump_rpl: bad flags combination (%d)!\n",flags);
LM_ERR("bad flags combination (%d)!\n",flags);
goto error;
}
if (len<=0 || s==0) {
LOG(L_ERR,"ERROR:add_lump_rpl: I won't add an empty lump!\n");
LM_ERR("I won't add an empty lump!\n");
goto error;
}
@ -72,7 +72,7 @@ struct lump_rpl** add_lump_rpl2(struct sip_msg *msg, char *s,
lump = (struct lump_rpl*) pkg_malloc
( sizeof(struct lump_rpl) + ((flags&LUMP_RPL_NODUP)?0:len) );
if (!lump) {
LOG(L_ERR,"ERROR:add_lump_rpl : no free pkg memory !\n");
LM_ERR("no free pkg memory !\n");
goto error;
}
@ -96,8 +96,7 @@ struct lump_rpl** add_lump_rpl2(struct sip_msg *msg, char *s,
else
for(foo=msg->reply_lump; ;foo=foo->next) {
if (foo->flags&LUMP_RPL_BODY) {
LOG(L_ERR,"ERROR:add_lump_rpl: LUMP_RPL_BODY "
"already added!\n");
LM_ERR("LUMP_RPL_BODY already added!\n");
pkg_free(lump);
goto error;
}

@ -18,7 +18,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* History:
* 2002-02-14 : created by bogdan

@ -24,7 +24,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* History:
* --------
@ -297,13 +297,13 @@ void fix_dns_flags(str *gname, str *name)
#ifdef DNS_SRV_LB
dns_flags|=DNS_SRV_RR_LB;
#else
LOG(L_WARN, "WARNING: fix_dns_flags: SRV loadbalaning is set, but"
LM_WARN("SRV loadbalaning is set, but"
" support for it is not compiled -- ignoring\n");
#endif
}
if (cfg_get(core, core_cfg, dns_try_naptr)) {
#ifndef USE_NAPTR
LOG(L_WARN, "WARNING: fix_dns_flags: NAPTR support is enabled, but"
LM_WARN("NAPTR support is enabled, but"
" support for it is not compiled -- ignoring\n");
#endif
dns_flags|=DNS_TRY_NAPTR;
@ -316,8 +316,7 @@ void fix_dns_flags(str *gname, str *name)
int use_dns_failover_fixup(void *handle, str *gname, str *name, void **val)
{
if ((int)(long)(*val) && !cfg_get(core, handle, use_dns_cache)) {
LOG(L_ERR, "ERROR: use_dns_failover_fixup(): "
"DNS cache is turned off, failover cannot be enabled. "
LM_ERR("DNS cache is turned off, failover cannot be enabled. "
"(set use_dns_cache to 1)\n");
return -1;
}
@ -330,14 +329,12 @@ int use_dns_failover_fixup(void *handle, str *gname, str *name, void **val)
int use_dns_cache_fixup(void *handle, str *gname, str *name, void **val)
{
if ((int)(long)(*val) && !dns_cache_init) {
LOG(L_ERR, "ERROR: use_dns_cache_fixup(): "
"DNS cache is turned off by dns_cache_init=0, "
LM_ERR("DNS cache is turned off by dns_cache_init=0, "
"it cannot be enabled runtime.\n");
return -1;
}
if (((int)(long)(*val)==0) && cfg_get(core, handle, use_dns_failover)) {
LOG(L_ERR, "ERROR: use_dns_failover_fixup(): "
"DNS failover depends on use_dns_cache, set use_dns_failover "
LM_ERR("DNS failover depends on use_dns_cache, set use_dns_failover "
"to 0 before disabling the DNS cache\n");
return -1;
}
@ -369,7 +366,7 @@ int init_dns_cache()
ret=0;
/* sanity check */
if (E_DNS_CRITICAL>=sizeof(dns_str_errors)/sizeof(char*)){
LOG(L_CRIT, "BUG: dns_cache_init: bad dns error table\n");
LM_CRIT("bad dns error table\n");
ret=E_BUG;
goto error;
}
@ -430,7 +427,7 @@ int init_dns_cache()
if (dns_timer_interval){
timer_init(dns_timer_h, dns_timer, 0, 0); /* "slow" timer */
if (timer_add(dns_timer_h, S_TO_TICKS(dns_timer_interval))<0){
LOG(L_CRIT, "BUG: dns_cache_init: failed to add the timer\n");
LM_CRIT("failed to add the timer\n");
timer_free(dns_timer_h);
dns_timer_h=0;
goto error;
@ -481,7 +478,7 @@ int init_dns_cache_stats(int iproc_num)
((l)!=dns_last_used_lst))
#define dbg_lu_lst(txt, l) \
LOG(L_CRIT, "BUG: %s: crt(%p, %p, %p)," \
LM_CRIT("%s: crt(%p, %p, %p)," \
" prev(%p, %p, %p), next(%p, %p, %p)\n", txt, \
(l), (l)->next, (l)->prev, \
(l)->prev, (l)->prev->next, (l)->prev->prev, \
@ -617,8 +614,8 @@ again:
return the last cname */
/* this is a cname => retry using its value */
if (cname_chain> MAX_CNAME_CHAIN){
LOG(L_ERR, "ERROR: _dns_hash_find: cname chain too long "
"or recursive (\"%.*s\")\n", name->len, name->s);
LM_ERR("cname chain too long or recursive (\"%.*s\")\n",
name->len, name->s);
ret=0; /* error*/
*err=-1;
break;
@ -814,12 +811,12 @@ inline static int dns_cache_add(struct dns_hash_entry* e)
#ifdef USE_DNS_CACHE_STATS
dns_cache_stats[process_no].dc_lru_cnt++;
#endif
LOG(L_WARN, "WARNING: dns_cache_add: cache full, trying to free...\n");
LM_WARN("cache full, trying to free...\n");
/* free ~ 12% of the cache */
dns_cache_free_mem(*dns_cache_mem_used/16*14,
!cfg_get(core, core_cfg, dns_cache_del_nonexp));
if ((*dns_cache_mem_used+e->total_size)>=cfg_get(core, core_cfg, dns_cache_max_mem)){
LOG(L_ERR, "ERROR: dns_cache_add: max. cache mem size exceeded\n");
LM_ERR("max. cache mem size exceeded\n");
return -1;
}
}
@ -854,14 +851,14 @@ inline static int dns_cache_add_unsafe(struct dns_hash_entry* e)
#ifdef USE_DNS_CACHE_STATS
dns_cache_stats[process_no].dc_lru_cnt++;
#endif
LOG(L_WARN, "WARNING: dns_cache_add: cache full, trying to free...\n");
LM_WARN("cache full, trying to free...\n");
/* free ~ 12% of the cache */
UNLOCK_DNS_HASH();
dns_cache_free_mem(*dns_cache_mem_used/16*14,
!cfg_get(core, core_cfg, dns_cache_del_nonexp));
LOCK_DNS_HASH();
if ((*dns_cache_mem_used+e->total_size)>=cfg_get(core, core_cfg, dns_cache_max_mem)){
LOG(L_ERR, "ERROR: dns_cache_add: max. cache mem size exceeded\n");
LM_ERR("max. cache mem size exceeded\n");
return -1;
}
}
@ -899,7 +896,7 @@ inline static struct dns_hash_entry* dns_cache_mk_bad_entry(str* name,
size=sizeof(struct dns_hash_entry)+name->len-1+1;
e=shm_malloc(size);
if (e==0){
LOG(L_ERR, "ERROR: dns_cache_mk_bad_entry: out of memory\n");
LM_ERR("out of memory\n");
return 0;
}
memset(e, 0, size); /* init with 0*/
@ -940,7 +937,7 @@ inline static struct dns_hash_entry* dns_cache_mk_ip_entry(str* name,
sizeof(struct dns_rr)+ ip->len;
e=shm_malloc(size);
if (e==0){
LOG(L_ERR, "ERROR: dns_cache_mk_ip_entry: out of memory\n");
LM_ERR("out of memory\n");
return 0;
}
memset(e, 0, size); /* init with 0*/
@ -993,7 +990,7 @@ static struct dns_hash_entry* dns_cache_mk_srv_entry(str* name,
e=shm_malloc(size);
if (e==0){
LOG(L_ERR, "ERROR: dns_cache_srv_ip_entry: out of memory\n");
LM_ERR("out of memory\n");
return 0;
}
memset(e, 0, size); /* init with 0*/
@ -1232,8 +1229,7 @@ inline static struct dns_hash_entry* dns_cache_mk_rd_entry(str* name, int type,
}
break;
default:
LOG(L_CRIT, "BUG: dns_cache_mk_rd_entry: type %d not "
"supported\n", type);
LM_CRIT("type %d not supported\n", type);
/* we don't know what to do with it, so don't
* add it to the tmp_lst */
return 0; /* error */
@ -1250,7 +1246,7 @@ inline static struct dns_hash_entry* dns_cache_mk_rd_entry(str* name, int type,
size+=ROUND_POINTER(sizeof(struct dns_hash_entry)+name->len-1+1);
e=shm_malloc(size);
if (e==0){
LOG(L_ERR, "ERROR: dns_cache_mk_rd_entry: out of memory\n");
LM_ERR("out of memory\n");
return 0;
}
memset(e, 0, size); /* init with 0 */
@ -1421,8 +1417,7 @@ inline static struct dns_hash_entry* dns_cache_mk_rd_entry(str* name, int type,
break;
default:
/* do nothing */
LOG(L_CRIT, "BUG: dns_cache_mk_rd_entry: create: type %d not "
"supported\n", type);
LM_CRIT("type %d not supported\n", type);
;
}
*tail_rr=0; /* terminate the list */
@ -1498,8 +1493,7 @@ inline static struct dns_hash_entry* dns_cache_mk_rd_entry2(struct rdata* rd)
rec[r].rd->name_len-1+1);
no_records++;
}else{
LOG(L_ERR, "ERROR: dns_cache_mk_rd_entry2: too many records: %d\n",
no_records);
LM_ERR("too many records: %d\n", no_records);
/* skip */
continue;
}
@ -1550,8 +1544,7 @@ found:
PTR_RDATA_SIZE(*(struct ptr_rdata*)l->rdata));
break;
default:
LOG(L_CRIT, "BUG: dns_cache_mk_rd_entry: type %d not "
"supported\n", l->type);
LM_CRIT("type %d not supported\n", l->type);
}
}
@ -1560,7 +1553,7 @@ found:
for (r=0; r<no_records; r++){
rec[r].e=shm_malloc(rec[r].size);
if (rec[r].e==0){
LOG(L_ERR, "ERROR: dns_cache_mk_rd_entry: out of memory\n");
LM_ERR("out of memory\n");
goto error;
}
memset(rec[r].e, 0, rec[r].size); /* init with 0*/
@ -1915,8 +1908,7 @@ inline static struct dns_hash_entry* dns_cache_do_request(str* name, int type)
goto end; /* the servers are down, needless to perform the query */
#endif
if (name->len>=MAX_DNS_NAME){
LOG(L_ERR, "ERROR: dns_cache_do_request: name too long (%d chars)\n",
name->len);
LM_ERR("name too long (%d chars)\n", name->len);
goto end;
}
/* null terminate the string, needed by get_record */
@ -2133,8 +2125,8 @@ inline static struct dns_hash_entry* dns_get_entry(str* name, int type)
e=0;
if (rec_cnt>MAX_CNAME_CHAIN){
LOG(L_WARN, "WARNING: dns_get_entry: CNAME chain too long or"
" recursive CNAMEs (\"%.*s\")\n", name->len, name->s);
LM_WARN("CNAME chain too long or recursive CNAMEs (\"%.*s\")\n",
name->len, name->s);
goto error;
}
rec_cnt++;
@ -2414,7 +2406,7 @@ inline static struct hostent* dns_entry2he(struct dns_hash_entry* e)
len=16;
break;
default:
LOG(L_CRIT, "BUG: dns_entry2he: wrong entry type %d for %.*s\n",
LM_CRIT("wrong entry type %d for %.*s\n",
e->type, e->name_len, e->name);
return 0;
}
@ -2676,8 +2668,8 @@ struct hostent* dns_srv_sip_resolvehost(str* name, unsigned short* port,
*port=(srv_proto==PROTO_TLS)?SIPS_PORT:SIP_PORT; /* just in case we
don't find another */
if ((name->len+SRV_MAX_PREFIX_LEN+1)>MAX_DNS_NAME){
LOG(L_WARN, "WARNING: dns_sip_resolvehost: domain name too long"
" (%d), unable to perform SRV lookup\n", name->len);
LM_WARN("domain name too long (%d), unable to perform SRV lookup\n",
name->len);
}else{
/* check if it's an ip address */
if ( ((ip=str2ip(name))!=0)
@ -2700,8 +2692,7 @@ struct hostent* dns_srv_sip_resolvehost(str* name, unsigned short* port,
create_srv_name(srv_proto, name, tmp);
break;
default:
LOG(L_CRIT, "BUG: sip_resolvehost: unknown proto %d\n",
(int)srv_proto);
LM_CRIT("unknown proto %d\n", (int)srv_proto);
return 0;
}
@ -2713,7 +2704,7 @@ struct hostent* dns_srv_sip_resolvehost(str* name, unsigned short* port,
}
/*skip_srv:*/
if (name->len >= MAX_DNS_NAME) {
LOG(L_ERR, "dns_sip_resolvehost: domain name too long\n");
LM_ERR("domain name too long\n");
return 0;
}
he=dns_get_he(name, dns_flags);
@ -2758,7 +2749,7 @@ struct naptr_rdata* dns_naptr_sip_iterate(struct dns_rr* naptr_head,
for(l=naptr_head; l && (i<MAX_NAPTR_RRS); l=l->next){
naptr=(struct naptr_rdata*) l->rdata;
if (naptr==0){
LOG(L_CRIT, "naptr_iterate: BUG: null rdata\n");
LM_CRIT("null rdata\n");
goto end;
}
/* check if valid and get proto */
@ -2820,8 +2811,7 @@ struct hostent* dns_naptr_sip_resolvehost(str* name, unsigned short* port,
origproto=*proto;
he=0;
if (dns_hash==0){ /* not init => use normal, non-cached version */
LOG(L_WARN, "WARNING: dns_sip_resolvehost: called before dns cache"
" initialization\n");
LM_WARN("called before dns cache initialization\n");
return _sip_resolvehost(name, port, proto);
}
if (proto && port && (*proto==0) && (*port==0)){
@ -3032,7 +3022,7 @@ inline static int dns_ip_resolve( struct dns_hash_entry** e,
struct ip_addr* ip,
int flags)
{
int ret;
int ret, orig_ret;
str host;
struct dns_hash_entry* orig;
@ -3060,10 +3050,13 @@ inline static int dns_ip_resolve( struct dns_hash_entry** e,
if (ret>=0) return ret;
if (!(flags&(DNS_IPV6_ONLY|DNS_IPV6_FIRST|DNS_IPV4_ONLY))){
/* not found, try with AAAA */
orig_ret=ret;
orig=*e;
*e=0;
*rr_no=0;
ret=dns_aaaa_resolve(e, rr_no, &host, ip);
if (ret==-E_DNS_NO_IP && orig_ret==-E_DNS_EOR)
ret=orig_ret;
/* delay original record release until we're finished with host*/
dns_hash_put(orig);
}
@ -3077,16 +3070,18 @@ inline static int dns_ip_resolve( struct dns_hash_entry** e,
if (ret>=0) return ret;
if ((flags&DNS_IPV6_FIRST) && !(flags&DNS_IPV6_ONLY)){
/* not found, try with A */
orig_ret=ret;
orig=*e;
*e=0;
*rr_no=0;
ret=dns_a_resolve(e, rr_no, &host, ip);
if (ret==-E_DNS_NO_IP && orig_ret==-E_DNS_EOR)
ret=orig_ret;
/* delay original record release until we're finished with host*/
dns_hash_put(orig);
}
}else{
LOG(L_CRIT, "BUG: dns_ip_resolve: invalid record type %d\n",
(*e)->type);
LM_CRIT("invalid record type %d\n", (*e)->type);
}
return ret;
}
@ -3232,8 +3227,7 @@ inline static int dns_srv_sip_resolve(struct dns_srv_handle* h, str* name,
origproto = *proto;
if (dns_hash==0){ /* not init => use normal, non-cached version */
LOG(L_WARN, "WARNING: dns_srv_sip_resolve: called before dns cache"
" initialization\n");
LM_WARN("called before dns cache initialization\n");
h->srv=h->a=0;
he=_sip_resolvehost(name, port, proto);
if (he){
@ -3254,8 +3248,7 @@ inline static int dns_srv_sip_resolve(struct dns_srv_handle* h, str* name,
/* try SRV if initial call & no port specified
* (draft-ietf-sip-srv-06) */
if ((name->len+SRV_MAX_PREFIX_LEN+1)>MAX_DNS_NAME){
LOG(L_WARN, "WARNING: dns_srv_sip_resolve: domain name too"
" long (%d), unable to perform SRV lookup\n",
LM_WARN("domain name too long (%d), unable to perform SRV lookup\n",
name->len);
}else{
/* check if it's an ip address */
@ -3284,8 +3277,7 @@ inline static int dns_srv_sip_resolve(struct dns_srv_handle* h, str* name,
create_srv_name(srv_proto_list[i].proto, name, tmp);
break;
default:
LOG(L_CRIT, "BUG: dns_srv_sip_resolve: "
"unknown proto %d\n", (int)srv_proto_list[i].proto);
LM_CRIT("unknown proto %d\n", (int)srv_proto_list[i].proto);
return -E_DNS_CRITICAL;
}
srv_name.s=tmp;
@ -3318,7 +3310,7 @@ inline static int dns_srv_sip_resolve(struct dns_srv_handle* h, str* name,
return ret;
}
if (name->len >= MAX_DNS_NAME) {
LOG(L_ERR, "dns_srv_sip_resolve: domain name too long\n");
LM_ERR("domain name too long\n");
return -E_DNS_NAME_TOO_LONG;
}
ret=dns_ip_resolve(&h->a, &h->ip_no, name, ip, flags);
@ -3364,8 +3356,7 @@ inline static int dns_naptr_sip_resolve(struct dns_srv_handle* h, str* name,
ret=-E_DNS_NO_NAPTR;
origproto=*proto;
if (dns_hash==0){ /* not init => use normal, non-cached version */
LOG(L_WARN, "WARNING: dns_sip_resolve: called before dns cache"
" initialization\n");
LM_WARN("called before dns cache initialization\n");
h->srv=h->a=0;
he=_sip_resolvehost(name, port, proto);
if (he){
@ -3814,21 +3805,21 @@ void dns_cache_print_entry(rpc_t* rpc, void* ctx, struct dns_hash_entry* e)
now=get_ticks_raw();
expires = (s_ticks_t)(e->expire-now)<0?-1: TICKS_TO_S(e->expire-now);
rpc->printf(ctx, "%sname: %s", SPACE_FORMAT, e->name);
rpc->printf(ctx, "%stype: %s", SPACE_FORMAT, print_type(e->type));
rpc->printf(ctx, "%ssize (bytes): %d", SPACE_FORMAT,
rpc->rpl_printf(ctx, "%sname: %s", SPACE_FORMAT, e->name);
rpc->rpl_printf(ctx, "%stype: %s", SPACE_FORMAT, print_type(e->type));
rpc->rpl_printf(ctx, "%ssize (bytes): %d", SPACE_FORMAT,
e->total_size);
rpc->printf(ctx, "%sreference counter: %d", SPACE_FORMAT,
rpc->rpl_printf(ctx, "%sreference counter: %d", SPACE_FORMAT,
e->refcnt.val);
if (e->ent_flags & DNS_FLAG_PERMANENT) {
rpc->printf(ctx, "%spermanent: yes", SPACE_FORMAT);
rpc->rpl_printf(ctx, "%spermanent: yes", SPACE_FORMAT);
} else {
rpc->printf(ctx, "%spermanent: no", SPACE_FORMAT);
rpc->printf(ctx, "%sexpires in (s): %d", SPACE_FORMAT, expires);
rpc->rpl_printf(ctx, "%spermanent: no", SPACE_FORMAT);
rpc->rpl_printf(ctx, "%sexpires in (s): %d", SPACE_FORMAT, expires);
}
rpc->printf(ctx, "%slast used (s): %d", SPACE_FORMAT,
rpc->rpl_printf(ctx, "%slast used (s): %d", SPACE_FORMAT,
TICKS_TO_S(now-e->last_used));
rpc->printf(ctx, "%snegative entry: %s", SPACE_FORMAT,
rpc->rpl_printf(ctx, "%snegative entry: %s", SPACE_FORMAT,
(e->ent_flags & DNS_FLAG_BAD_NAME) ? "yes" : "no");
for (rr=e->rr_lst; rr; rr=rr->next) {
@ -3836,74 +3827,74 @@ void dns_cache_print_entry(rpc_t* rpc, void* ctx, struct dns_hash_entry* e)
case T_A:
case T_AAAA:
if (dns_rr2ip(e->type, rr, &ip)==0){
rpc->printf(ctx, "%srr ip: %s", SPACE_FORMAT,
rpc->rpl_printf(ctx, "%srr ip: %s", SPACE_FORMAT,
ip_addr2a(&ip) );
}else{
rpc->printf(ctx, "%srr ip: <error: bad rr>",
rpc->rpl_printf(ctx, "%srr ip: <error: bad rr>",
SPACE_FORMAT);
}
break;
case T_SRV:
rpc->printf(ctx, "%srr name: %s", SPACE_FORMAT,
rpc->rpl_printf(ctx, "%srr name: %s", SPACE_FORMAT,
((struct srv_rdata*)(rr->rdata))->name);
rpc->printf(ctx, "%srr port: %d", SPACE_FORMAT,
rpc->rpl_printf(ctx, "%srr port: %d", SPACE_FORMAT,
((struct srv_rdata*)(rr->rdata))->port);
rpc->printf(ctx, "%srr priority: %d", SPACE_FORMAT,
rpc->rpl_printf(ctx, "%srr priority: %d", SPACE_FORMAT,
((struct srv_rdata*)(rr->rdata))->priority);
rpc->printf(ctx, "%srr weight: %d", SPACE_FORMAT,
rpc->rpl_printf(ctx, "%srr weight: %d", SPACE_FORMAT,
((struct srv_rdata*)(rr->rdata))->weight);
break;
case T_NAPTR:
rpc->printf(ctx, "%srr order: %d", SPACE_FORMAT,
rpc->rpl_printf(ctx, "%srr order: %d", SPACE_FORMAT,
((struct naptr_rdata*)(rr->rdata))->order);
rpc->printf(ctx, "%srr preference: %d", SPACE_FORMAT,
rpc->rpl_printf(ctx, "%srr preference: %d", SPACE_FORMAT,
((struct naptr_rdata*)(rr->rdata))->pref);
s.s = ((struct naptr_rdata*)(rr->rdata))->flags;
s.len = ((struct naptr_rdata*)(rr->rdata))->flags_len;
rpc->printf(ctx, "%srr flags: %.*s", SPACE_FORMAT,
rpc->rpl_printf(ctx, "%srr flags: %.*s", SPACE_FORMAT,
s.len, s.s);
s.s=((struct naptr_rdata*)(rr->rdata))->services;
s.len=((struct naptr_rdata*)(rr->rdata))->services_len;
rpc->printf(ctx, "%srr service: %.*s", SPACE_FORMAT,
rpc->rpl_printf(ctx, "%srr service: %.*s", SPACE_FORMAT,
s.len, s.s);
s.s = ((struct naptr_rdata*)(rr->rdata))->regexp;
s.len = ((struct naptr_rdata*)(rr->rdata))->regexp_len;
rpc->printf(ctx, "%srr regexp: %.*s", SPACE_FORMAT,
rpc->rpl_printf(ctx, "%srr regexp: %.*s", SPACE_FORMAT,
s.len, s.s);
s.s = ((struct naptr_rdata*)(rr->rdata))->repl;
s.len = ((struct naptr_rdata*)(rr->rdata))->repl_len;
rpc->printf(ctx, "%srr replacement: %.*s",
rpc->rpl_printf(ctx, "%srr replacement: %.*s",
SPACE_FORMAT, s.len, s.s);
break;
case T_CNAME:
rpc->printf(ctx, "%srr name: %s", SPACE_FORMAT,
rpc->rpl_printf(ctx, "%srr name: %s", SPACE_FORMAT,
((struct cname_rdata*)(rr->rdata))->name);
break;
case T_TXT:
for (i=0; i<((struct txt_rdata*)(rr->rdata))->cstr_no;
i++){
rpc->printf(ctx, "%stxt[%d]: %s", SPACE_FORMAT, i,
rpc->rpl_printf(ctx, "%stxt[%d]: %s", SPACE_FORMAT, i,
((struct txt_rdata*)(rr->rdata))->txt[i].cstr);
}
break;
case T_EBL:
rpc->printf(ctx, "%srr position: %d", SPACE_FORMAT,
rpc->rpl_printf(ctx, "%srr position: %d", SPACE_FORMAT,
((struct ebl_rdata*)(rr->rdata))->position);
rpc->printf(ctx, "%srr separator: %s", SPACE_FORMAT,
rpc->rpl_printf(ctx, "%srr separator: %s", SPACE_FORMAT,
((struct ebl_rdata*)(rr->rdata))->separator);
rpc->printf(ctx, "%srr apex: %s", SPACE_FORMAT,
rpc->rpl_printf(ctx, "%srr apex: %s", SPACE_FORMAT,
((struct ebl_rdata*)(rr->rdata))->apex);
break;
case T_PTR:
rpc->printf(ctx, "%srr name: %s", SPACE_FORMAT,
rpc->rpl_printf(ctx, "%srr name: %s", SPACE_FORMAT,
((struct ptr_rdata*)(rr->rdata))->ptrdname);
break;
default:
rpc->printf(ctx, "%sresource record: unknown",
rpc->rpl_printf(ctx, "%sresource record: unknown",
SPACE_FORMAT);
}
if ((e->ent_flags & DNS_FLAG_PERMANENT) == 0)
rpc->printf(ctx, "%srr expires in (s): %d", SPACE_FORMAT,
rpc->rpl_printf(ctx, "%srr expires in (s): %d", SPACE_FORMAT,
(s_ticks_t)(rr->expire-now)<0?-1 :
TICKS_TO_S(rr->expire-now));
}
@ -3931,9 +3922,9 @@ void dns_cache_view(rpc_t* rpc, void* ctx)
) {
continue;
}
rpc->printf(ctx, "{\n");
rpc->rpl_printf(ctx, "{\n");
dns_cache_print_entry(rpc, ctx, e);
rpc->printf(ctx, "}");
rpc->rpl_printf(ctx, "}");
}
}
UNLOCK_DNS_HASH();
@ -3969,7 +3960,7 @@ void dns_cache_delete_all(rpc_t* rpc, void* ctx)
return;
}
dns_cache_flush(0);
rpc->printf(ctx, "OK");
rpc->rpl_printf(ctx, "OK");
}
/* deletes all the entries from the cache,
@ -3981,7 +3972,7 @@ void dns_cache_delete_all_force(rpc_t* rpc, void* ctx)
return;
}
dns_cache_flush(1);
rpc->printf(ctx, "OK");
rpc->rpl_printf(ctx, "OK");
}
/* clones an entry and extends its memory area to hold a new rr.
@ -4027,8 +4018,7 @@ static struct dns_hash_entry *dns_cache_clone_entry(struct dns_hash_entry *e,
rr_size = sizeof(struct dns_rr);
break;
default:
LOG(L_ERR, "ERROR: dns_cache_clone_entry: type %d not "
"supported\n", e->type);
LM_ERR("type %d not supported\n", e->type);
return NULL;
}
} else {
@ -4039,7 +4029,7 @@ static struct dns_hash_entry *dns_cache_clone_entry(struct dns_hash_entry *e,
new=shm_malloc(rounded_size+rr_size+rdata_size);
if (!new) {
LOG(L_ERR, "ERROR: dns_cache_clone_entry: out of memory\n");
LM_ERR("out of memory\n");
return NULL;
}
memset(new, 0, rounded_size+rr_size+rdata_size);
@ -4167,13 +4157,12 @@ int dns_cache_add_record(unsigned short type,
rr_name.len = 0;
if (!cfg_get(core, core_cfg, use_dns_cache)){
LOG(L_ERR, "ERROR: dns cache support disabled (see use_dns_cache)\n");
LM_ERR("dns cache support disabled (see use_dns_cache)\n");
return -1;
}
if ((type != T_A) && (type != T_AAAA) && (type != T_SRV)) {
LOG(L_ERR, "ERROR: rr type %d is not implemented\n",
type);
LM_ERR("rr type %d is not implemented\n", type);
return -1;
}
@ -4183,7 +4172,7 @@ int dns_cache_add_record(unsigned short type,
case T_A:
ip_addr = str2ip(value);
if (!ip_addr) {
LOG(L_ERR, "ERROR: Malformed ip address: %.*s\n",
LM_ERR("Malformed ip address: %.*s\n",
value->len, value->s);
return -1;
}
@ -4191,7 +4180,7 @@ int dns_cache_add_record(unsigned short type,
case T_AAAA:
ip_addr = str2ip6(value);
if (!ip_addr) {
LOG(L_ERR, "ERROR: Malformed ip address: %.*s\n",
LM_ERR("Malformed ip address: %.*s\n",
value->len, value->s);
return -1;
}
@ -4215,7 +4204,7 @@ int dns_cache_add_record(unsigned short type,
&& (old->ent_flags & DNS_FLAG_PERMANENT)
&& ((flags & DNS_FLAG_PERMANENT) == 0)
) {
LOG(L_ERR, "ERROR: A non-permanent record cannot overwrite "
LM_ERR("A non-permanent record cannot overwrite "
"a permanent entry\n");
goto error;
}
@ -4224,7 +4213,7 @@ int dns_cache_add_record(unsigned short type,
/* negative entry */
new = dns_cache_mk_bad_entry(name, type, ttl, flags);
if (!new) {
LOG(L_ERR, "ERROR: Failed to create a negative "
LM_ERR("Failed to create a negative "
"DNS cache entry\n");
goto error;
}
@ -4244,7 +4233,7 @@ int dns_cache_add_record(unsigned short type,
case T_AAAA:
new = dns_cache_mk_ip_entry(name, ip_addr);
if (!new) {
LOG(L_ERR, "ERROR: Failed to create an A/AAAA record\n");
LM_ERR("Failed to create an A/AAAA record\n");
goto error;
}
/* fix the expiration time, dns_cache_mk_ip_entry() sets it
@ -4257,7 +4246,7 @@ int dns_cache_add_record(unsigned short type,
new = dns_cache_mk_srv_entry(name, priority, weight, port,
&rr_name, ttl);
if (!new) {
LOG(L_ERR, "ERROR: Failed to create an SRV record\n");
LM_ERR("Failed to create an SRV record\n");
goto error;
}
}
@ -4284,7 +4273,7 @@ int dns_cache_add_record(unsigned short type,
/* the rr was found in the list */
new = dns_cache_clone_entry(old, 0, 0, 0);
if (!new) {
LOG(L_ERR, "ERROR: Failed to clone an existing "
LM_ERR("Failed to clone an existing "
"DNS cache entry\n");
goto error;
}
@ -4322,7 +4311,7 @@ int dns_cache_add_record(unsigned short type,
}
new = dns_cache_clone_entry(old, size, ttl, &rr);
if (!new) {
LOG(L_ERR, "ERROR: Failed to clone an existing "
LM_ERR("Failed to clone an existing "
"DNS cache entry\n");
goto error;
}
@ -4372,7 +4361,7 @@ int dns_cache_add_record(unsigned short type,
rr_p = &((*rr_p)->next)
);
if (!rr_p) {
LOG(L_ERR, "ERROR: Failed to correct the orderd list of SRV resource records\n");
LM_ERR("Failed to correct the orderd list of SRV resource records\n");
goto error;
}
@ -4389,7 +4378,7 @@ int dns_cache_add_record(unsigned short type,
LOCK_DNS_HASH();
if (dns_cache_add_unsafe(new)) {
LOG(L_ERR, "ERROR: Failed to add the entry to the cache\n");
LM_ERR("Failed to add the entry to the cache\n");
UNLOCK_DNS_HASH();
goto error;
} else {
@ -4470,13 +4459,12 @@ int dns_cache_delete_single_record(unsigned short type,
ip_addr = 0;
if (!cfg_get(core, core_cfg, use_dns_cache)){
LOG(L_ERR, "ERROR: dns cache support disabled (see use_dns_cache)\n");
LM_ERR("dns cache support disabled (see use_dns_cache)\n");
return -1;
}
if ((type != T_A) && (type != T_AAAA) && (type != T_SRV)) {
LOG(L_ERR, "ERROR: rr type %d is not implemented\n",
type);
LM_ERR("rr type %d is not implemented\n", type);
return -1;
}
@ -4486,7 +4474,7 @@ int dns_cache_delete_single_record(unsigned short type,
case T_A:
ip_addr = str2ip(value);
if (!ip_addr) {
LOG(L_ERR, "ERROR: Malformed ip address: %.*s\n",
LM_ERR("Malformed ip address: %.*s\n",
value->len, value->s);
return -1;
}
@ -4494,7 +4482,7 @@ int dns_cache_delete_single_record(unsigned short type,
case T_AAAA:
ip_addr = str2ip6(value);
if (!ip_addr) {
LOG(L_ERR, "ERROR: Malformed ip address: %.*s\n",
LM_ERR("Malformed ip address: %.*s\n",
value->len, value->s);
return -1;
}
@ -4546,8 +4534,7 @@ int dns_cache_delete_single_record(unsigned short type,
* automatically destroyed when its refcnt will be 0*/
new = dns_cache_clone_entry(old, 0, 0, 0);
if (!new) {
LOG(L_ERR, "ERROR: Failed to clone an existing "
"DNS cache entry\n");
LM_ERR("Failed to clone an existing DNS cache entry\n");
dns_hash_put(old);
return -1;
}
@ -4568,7 +4555,7 @@ delete:
if (new) {
/* delete the old entry only if the new one can be added */
if (dns_cache_add_unsafe(new)) {
LOG(L_ERR, "ERROR: Failed to add the entry to the cache\n");
LM_ERR("Failed to add the entry to the cache\n");
UNLOCK_DNS_HASH();
if (old)
dns_hash_put(old);
@ -4588,7 +4575,7 @@ delete:
return 0;
not_found:
LOG(L_ERR, "ERROR: No matching record found\n");
LM_ERR("No matching record found\n");
if (old)
dns_hash_put(old);
return -1;

@ -19,7 +19,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* History:

@ -24,7 +24,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* History:
* --------

@ -28,7 +28,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/

@ -17,7 +17,7 @@
1.2.4.1. fault
1.2.4.2. send
1.2.4.3. add
1.2.4.4. printf
1.2.4.4. rpl_printf
1.2.4.5. struct_add
1.2.5. Real World Example
@ -39,12 +39,19 @@
implementing RPC transports.
The RPC transports are implemented by writting a RPC transport module.
The most used transport modules are ctl and xmlrpc . The first one
implements a ser-proprietary fast and space efficient RPC encoding over
different protocols (unix sockets, UDP, TCP, fifo). The second one uses
the de-facto XML-RPC standard encoding (over HTTP TCP or TLS). For more
information about the existing transport modules, please refer to their
documentation.
The most used transport modules are ctl , xmlrpc and jsonrpc-s .
ctl implements a proprietary fast and space efficient RPC encoding over
different protocols (unix sockets, UDP, TCP, fifo).
xmlrpc uses the de-facto XML-RPC standard encoding (over HTTP TCP or
TLS).
jsonrpc-s uses the de-facto JSON-RPC standard encoding (over HTTP TCP
or TLS).
For more information about the existing transport modules, please refer
to their documentation.
When writing a RPC procedure or function, one needs only use the RPC
API and it will work automatically with all the transports and
@ -523,13 +530,14 @@ static void rpc_func(rpc_t* rpc, void *ctx)
You can set the attributes of the newly created structure using
struct_add function described in Section 1.2.4.5, "struct_add".
1.2.4.4. printf
1.2.4.4. rpl_printf
printf is a convenience function. The function adds data of type string
to the result set. The first parameter of the function is again a
formatting string, but this time it is printf-like formatting string:
if (rpc->printf(ctx, "Unable to delete %d entries from table %s", num_entries, t
able_name) < 0) return;
rpl_printf is a convenience function. The function adds data of type
string to the result set. The first parameter of the function is again
a formatting string, but this time it is standard printf-like
formatting string:
if (rpc->rpl_printf(ctx, "Unable to delete %d entries from table %s", num_entrie
s, table_name) < 0) return;
The return value of the function is the same as of add function.

@ -34,17 +34,30 @@
<para>
The RPC transports are implemented by writting a RPC
transport module. The most used transport modules are
<ulink url='http://sip-router.org/docbook/sip-router/branch/master/modules/ctl/ctl.html'>
<ulink url='http://www.kamailio.org/docs/modules/devel/modules/ctl/ctl.html'>
<emphasis>ctl</emphasis>
</ulink>,
<ulink url='http://www.kamailio.org/docs/modules/devel/modules/xmlrpc/xmlrpc.html'>
<emphasis>xmlrpc</emphasis>
</ulink>
and
<ulink url='http://sip-router.org/docbook/sip-router/branch/master/modules/xmlrpc/xmlrpc.html'>
<emphasis>xmlrpc</emphasis>
<ulink url='http://www.kamailio.org/docs/modules/devel/modules/jsonrpc-s/jsonrpc-s.html'>
<emphasis>jsonrpc-s</emphasis>
</ulink>.
The first one implements a ser-proprietary fast and space efficient
</para>
<para>
ctl implements a proprietary fast and space efficient
RPC encoding over different protocols (unix sockets, UDP, TCP, fifo).
The second one uses the de-facto XML-RPC standard encoding
</para>
<para>
xmlrpc uses the de-facto XML-RPC standard encoding
(over HTTP TCP or TLS).
</para>
<para>
jsonrpc-s uses the de-facto JSON-RPC standard encoding
(over HTTP TCP or TLS).
</para>
<para>
For more information about the existing transport modules, please
refer to their documentation.
</para>
@ -364,7 +377,7 @@ add("sd", string_param, int_param);
<row>
<entry>String</entry>
<entry>S</entry>
<entry>str</entry>
<entry>str*</entry>
</row>
<row>
<entry>Optional modifier</entry>
@ -738,15 +751,16 @@ static void rpc_func(rpc_t* rpc, void *ctx)
</para>
</section>
<section>
<title>printf</title>
<title>rpl_printf</title>
<para>
<varname>printf</varname> is a convenience function. The
<varname>rpl_printf</varname> is a convenience function. The
function adds data of type string to the result set. The
first parameter of the function is again a formatting
string, but this time it is <function>printf</function>-like formatting string:
string, but this time it is standard
<function>printf</function>-like formatting string:
<programlisting>
<![CDATA[
if (rpc->printf(ctx, "Unable to delete %d entries from table %s", num_entries, table_name) < 0) return;
if (rpc->rpl_printf(ctx, "Unable to delete %d entries from table %s", num_entries, table_name) < 0) return;
]]>
</programlisting>
The return value of the function is the same as of

@ -23,7 +23,9 @@ docbook_output_dir=docbook
files_list= \
$(COREPATH)/core_cmd.c:core \
$(COREPATH)/modules/app_lua/app_lua_mod.c:app_lua \
$(COREPATH)/modules/app_perl/app_perl_mod.c:app_perl \
$(COREPATH)/modules/carrierroute/carrierroute.c:carrierroute \
$(COREPATH)/modules/cdp/cdp_rpc.c:cdp \
$(COREPATH)/modules/cfg_rpc/cfg_rpc.c:cfg_rpc \
$(COREPATH)/modules/cnxcc/cnxcc_mod.c:cnxcc \
$(COREPATH)/modules/corex/corex_rpc.c:corex \
@ -37,11 +39,14 @@ files_list= \
$(COREPATH)/modules/dialog_ng/dialog.c:dialog_ng \
$(COREPATH)/modules/dialplan/dialplan.c:dialplan \
$(COREPATH)/modules/dispatcher/dispatcher.c:dispatcher \
$(COREPATH)/modules/dmq/dmq.c:dmq \
$(COREPATH)/modules/domain/domain_mod.c:domain \
$(COREPATH)/modules/drouting/drouting.c:drouting \
$(COREPATH)/modules/htable/htable.c:htable \
$(COREPATH)/modules/ims_usrloc_pcscf/ul_rpc.c:ims_usrloc_pcscf \
$(COREPATH)/modules/ims_usrloc_scscf/ul_rpc.c:ims_usrloc_scscf \
$(COREPATH)/modules/jsonrpc-s/jsonrpc-s_mod.c:jsonrpc-s \
$(COREPATH)/modules/kex/core_stats.c:kex \
$(COREPATH)/modules/kex/pkg_stats.c:kex \
$(COREPATH)/modules/lcr/lcr_rpc.c:lcr \
$(COREPATH)/modules/malloc_test/malloc_test.c:malloc_test \
@ -100,17 +105,19 @@ gcc=gcc
# defines used by gcc
# -D__CPU_i386 -DARCH="i386"
c_defsX= -D__CPU_x86_64 -D__OS_linux -DSER_VER=3003000 -DPKG_MALLOC -DSHM_MEM \
-DVERSION='\"3.3.0-dev2\"' -DARCH='\"x86_64\"' -DOS=linux_ -DOS_QUOTED='\"linux\"' \
-DVERSION='\"4.3.0\"' -DARCH='\"x86_64\"' -DOS=linux_ -DOS_QUOTED='\"linux\"' \
-DSHM_MMAP -DDNS_IP_HACK -DUSE_MCAST -DUSE_TCP \
-DUSE_DNS_CACHE -DUSE_DNS_FAILOVER -DUSE_DST_BLACKLIST -DUSE_NAPTR \
-DUSE_TLS -DTLS_HOOKS -DFAST_LOCK -DCC_GCC_LIKE_ASM \
-DHAVE_GETHOSTBYNAME2 -DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
-DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H \
-DHAVE_SCHED_SETSCHEDULER -DHAVE_EPOLL -DUSE_SCTP -DNAME='\"ser\"' \
-DCFG_DIR='\"/tmp/\"'
-DHAVE_SCHED_SETSCHEDULER -DHAVE_EPOLL -DUSE_SCTP -DNAME='\"kamailio\"' \
-DMOD_NAME='\"rpcmod\"' -DCFG_DIR='\"/tmp/\"'
c_defs=$(subst ^^,='\",$(subst ",\"',$(subst =",^^,$(shell make -s -C ../.. printcdefs))))
c_defs+= -DMOD_NAME='\"rpcgen\"'
# common makefile vars used in defs
LOCALBASE=/usr/local
SYSBASE=/usr

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- this file is autogenerated, do not edit! -->
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<chapter id="rpc_exports.app_perl">
<title>
RPC Exports for app_perl
</title>
<section id="app_perl.set_reset_cycles"><title>app_perl.set_reset_cycles</title>
<para>
Set the value for reset_cycles
</para>
<para>
</para>
</section>
<section id="app_perl.get_reset_cycles"><title>app_perl.get_reset_cycles</title>
<para>
Get the value for reset_cycles
</para>
<para>
</para>
</section>
</chapter>

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- this file is autogenerated, do not edit! -->
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<chapter id="rpc_exports.cdp">
<title>
RPC Exports for cdp
</title>
<section id="cdp.disable_peer"><title>cdp.disable_peer</title>
<para>
disable diameter peer
</para>
<para>
</para>
</section>
<section id="cdp.enable_peer"><title>cdp.enable_peer</title>
<para>
enable diameter peer
</para>
<para>
</para>
</section>
<section id="cdp.list_peers"><title>cdp.list_peers</title>
<para>
list diameter peers and their state
</para>
<para>
</para>
</section>
</chapter>

@ -107,6 +107,7 @@ RPC Exports for core
Returns the detailed description of running SER processes.
</para>
<para>
Returns an array.
</para>
</section>

@ -13,6 +13,7 @@ RPC Exports for corex
List listening sockets
</para>
<para>
Returns an array.
</para>
</section>
@ -20,6 +21,23 @@ RPC Exports for corex
<para>
List socket aliases
</para>
<para>
Returns an array.
</para>
</section>
<section id="corex.shm_status"><title>corex.shm_status</title>
<para>
Trigger shm status dump to syslog
</para>
<para>
</para>
</section>
<section id="corex.shm_summary"><title>corex.shm_summary</title>
<para>
Trigger shm summary dump to syslog
</para>
<para>
</para>
</section>

@ -13,6 +13,7 @@ RPC Exports for dialog
Print all dialogs
</para>
<para>
Returns an array.
</para>
</section>
@ -21,6 +22,7 @@ RPC Exports for dialog
Print all dialogs with associated context
</para>
<para>
Returns an array.
</para>
</section>
@ -62,6 +64,7 @@ RPC Exports for dialog
Lists all the dialogs belonging to a profile
</para>
<para>
Returns an array.
</para>
</section>

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- this file is autogenerated, do not edit! -->
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<chapter id="rpc_exports.dmq">
<title>
RPC Exports for dmq
</title>
<section id="dmq.list_nodes"><title>dmq.list_nodes</title>
<para>
Print all nodes
</para>
<para>
Returns an array.
</para>
</section>
</chapter>

@ -13,6 +13,7 @@ RPC Exports for htable
Dump the contents of hash table.
</para>
<para>
Returns an array.
</para>
</section>
@ -53,6 +54,7 @@ RPC Exports for htable
List all htables.
</para>
<para>
Returns an array.
</para>
</section>
@ -69,6 +71,7 @@ RPC Exports for htable
Statistics about htables.
</para>
<para>
Returns an array.
</para>
</section>

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- this file is autogenerated, do not edit! -->
<!DOCTYPE section PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
"http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
<chapter id="rpc_exports.jsonrpc-s">
<title>
RPC Exports for jsonrpc-s
</title>
<section id="jsonrpc.echo"><title>jsonrpc.echo</title>
<para>
Sample echo command
</para>
<para>
Returns an array.
</para>
</section>
</chapter>

@ -13,6 +13,7 @@ RPC Exports for kex
Private memory (pkg) statistics per process
</para>
<para>
Returns an array.
</para>
</section>

@ -8,8 +8,8 @@
<book id="rpc_list" xmlns:xi="http://www.w3.org/2001/XInclude">
<title>RPC Exports List</title>
<bookinfo><revhistory><revision>
<revnumber>sip-router git-99c4af</revnumber>
<date>Wed, 04 Dec 2013 14:45:52 +0100</date>
<revnumber>sip-router git-c21808</revnumber>
<date>Tue, 14 Oct 2014 14:24:16 +0200</date>
<revremark>
Automatically generated by:
make -C doc/rpc_list all
@ -17,7 +17,9 @@
</revision></revhistory></bookinfo>
<xi:include href="rpc_core.xml"/>
<xi:include href="rpc_app_lua.xml"/>
<xi:include href="rpc_app_perl.xml"/>
<xi:include href="rpc_carrierroute.xml"/>
<xi:include href="rpc_cdp.xml"/>
<xi:include href="rpc_cfg_rpc.xml"/>
<xi:include href="rpc_cnxcc.xml"/>
<xi:include href="rpc_corex.xml"/>
@ -31,11 +33,14 @@
<xi:include href="rpc_dialog_ng.xml"/>
<xi:include href="rpc_dialplan.xml"/>
<xi:include href="rpc_dispatcher.xml"/>
<xi:include href="rpc_dmq.xml"/>
<xi:include href="rpc_domain.xml"/>
<xi:include href="rpc_drouting.xml"/>
<xi:include href="rpc_htable.xml"/>
<xi:include href="rpc_ims_usrloc_pcscf.xml"/>
<xi:include href="rpc_ims_usrloc_scscf.xml"/>
<xi:include href="rpc_jsonrpc-s.xml"/>
<xi:include href="rpc_kex.xml"/>
<xi:include href="rpc_kex.xml"/>
<xi:include href="rpc_lcr.xml"/>
<xi:include href="rpc_malloc_test.xml"/>

@ -13,6 +13,7 @@ RPC Exports for mtree
Print summary of loaded mtree tables
</para>
<para>
Returns an array.
</para>
</section>
@ -24,4 +25,12 @@ RPC Exports for mtree
</para>
</section>
<section id="mtree.match"><title>mtree.match</title>
<para>
Match prefix value against mtree
</para>
<para>
</para>
</section>
</chapter>

@ -16,4 +16,44 @@ RPC Exports for uac
</para>
</section>
<section id="uac.reg_info"><title>uac.reg_info</title>
<para>
Return the details of registration for a particular record.
</para>
<para>
</para>
</section>
<section id="uac.reg_enable"><title>uac.reg_enable</title>
<para>
Enable registration for a particular record.
</para>
<para>
</para>
</section>
<section id="uac.reg_disable"><title>uac.reg_disable</title>
<para>
Disable registration for a particular record.
</para>
<para>
</para>
</section>
<section id="uac.reg_reload"><title>uac.reg_reload</title>
<para>
Reload records from database.
</para>
<para>
</para>
</section>
<section id="uac.reg_refresh"><title>uac.reg_refresh</title>
<para>
Refresh a record from database.
</para>
<para>
</para>
</section>
</chapter>

@ -0,0 +1,12 @@
RPC Exports for app_perl
========================
[ this file is autogenerated, do not edit ]
1. app_perl.set_reset_cycles
Set the value for reset_cycles
2. app_perl.get_reset_cycles
Get the value for reset_cycles

@ -0,0 +1,15 @@
RPC Exports for cdp
===================
[ this file is autogenerated, do not edit ]
1. cdp.disable_peer
disable diameter peer
2. cdp.enable_peer
enable diameter peer
3. cdp.list_peers
list diameter peers and their state

@ -45,6 +45,7 @@ RPC Exports for core
12. core.psx
Returns the detailed description of running SER processes.
Returns an array.
13. core.pwd
Returns the working directory of SER server.

@ -6,7 +6,15 @@ RPC Exports for corex
1. corex.list_sockets
List listening sockets
Returns an array.
2. corex.list_aliases
List socket aliases
Returns an array.
3. corex.shm_status
Trigger shm status dump to syslog
4. corex.shm_summary
Trigger shm summary dump to syslog

@ -6,9 +6,11 @@ RPC Exports for dialog
1. dlg.list
Print all dialogs
Returns an array.
2. dlg.list_ctx
Print all dialogs with associated context
Returns an array.
3. dlg.dlg_list
Print dialog based on callid and fromtag
@ -25,6 +27,7 @@ RPC Exports for dialog
7. dlg.profile_list
Lists all the dialogs belonging to a profile
Returns an array.
8. dlg.bridge_dlg
Bridge two SIP addresses in a call using INVITE(hold)-REFER-BYE

@ -0,0 +1,10 @@
RPC Exports for dmq
===================
[ this file is autogenerated, do not edit ]
1. dmq.list_nodes
Print all nodes
Returns an array.

@ -6,6 +6,7 @@ RPC Exports for htable
1. htable.dump
Dump the contents of hash table.
Returns an array.
2. htable.delete
Delete one key from a hash table.
@ -21,10 +22,12 @@ RPC Exports for htable
6. htable.listTables
List all htables.
Returns an array.
7. htable.reload
Reload hash table.
8. htable.stats
Statistics about htables.
Returns an array.

@ -0,0 +1,10 @@
RPC Exports for jsonrpc-s
=========================
[ this file is autogenerated, do not edit ]
1. jsonrpc.echo
Sample echo command
Returns an array.

@ -6,4 +6,5 @@ RPC Exports for kex
1. pkg.stats
Private memory (pkg) statistics per process
Returns an array.

@ -6,7 +6,11 @@ RPC Exports for mtree
1. mtree.summary
Print summary of loaded mtree tables
Returns an array.
2. mtree.reload
Reload mtrees from database to memory
3. mtree.match
Match prefix value against mtree

@ -7,3 +7,18 @@ RPC Exports for uac
1. uac.reg_dump
Dump the contents of user registrations table.
2. uac.reg_info
Return the details of registration for a particular record.
3. uac.reg_enable
Enable registration for a particular record.
4. uac.reg_disable
Disable registration for a particular record.
5. uac.reg_reload
Reload records from database.
6. uac.reg_refresh
Refresh a record from database.

@ -21,7 +21,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-->

@ -19,7 +19,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-->

@ -20,7 +20,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-->

@ -20,7 +20,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-->

@ -18,7 +18,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-->

@ -20,7 +20,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-->

@ -21,7 +21,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-->

@ -20,7 +20,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-->

@ -20,7 +20,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-->

@ -20,7 +20,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-->

@ -20,7 +20,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-->
@ -86,7 +86,7 @@
<xsl:value-of select="concat('extern db_func_t ', $prefix, '_dbf;&#x0A;&#x0A;')"/>
<!-- macro for module parameter -->
<xsl:value-of select="concat('#define ', $prefix, '_DB_URL { &quot;db_url&quot;, STR_PARAM, &amp;', $prefix, '_db_url.s },&#x0A;&#x0A;')"/>
<xsl:value-of select="concat('#define ', $prefix, '_DB_URL { &quot;db_url&quot;, PARAM_STR, &amp;', $prefix, '_db_url },&#x0A;&#x0A;')"/>
<xsl:apply-templates select="/database[1]"/>
@ -140,7 +140,7 @@
</xsl:variable>
<!-- macro for db table -->
<xsl:value-of select="concat('#define ', $table.name, '_DB_TABLE { &quot;', $table.name, '_table&quot;, STR_PARAM, &amp;', $prefix, '_table.s },&#x0A;&#x0A;')"/>
<xsl:value-of select="concat('#define ', $table.name, '_DB_TABLE { &quot;', $table.name, '_table&quot;, PARAM_STR, &amp;', $prefix, '_table },&#x0A;&#x0A;')"/>
<xsl:value-of select="concat('extern str ', $table.name, '_table;&#x0A;')"/>
<xsl:text>&#x0A;</xsl:text>
@ -153,7 +153,7 @@
<xsl:variable name="column.name">
<xsl:call-template name="get-name"/>
</xsl:variable>
<xsl:value-of select="concat('{ &quot;', $table.name, '_', $column.name, '_col&quot;, STR_PARAM, &amp;', $table.name, '_', $column.name, '_col.s }, \&#x0A;')"/>
<xsl:value-of select="concat('{ &quot;', $table.name, '_', $column.name, '_col&quot;, PARAM_STR, &amp;', $table.name, '_', $column.name, '_col }, \&#x0A;')"/>
</xsl:for-each>
<xsl:text>&#x0A;</xsl:text>

@ -20,7 +20,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-->

@ -20,7 +20,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-->

@ -16,7 +16,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
@ -52,9 +52,18 @@
<xsl:text>&#x9;&#x9;&#x9;&lt;cmd_type&gt;DB1_QUERY&lt;/cmd_type&gt;&#xa;</xsl:text>
<xsl:text>&#x9;&#x9;&#x9;&lt;query_cols&gt;&#xa;</xsl:text>
<xsl:for-each select="column">
<xsl:text>&#x9;&#x9;&#x9;&#x9;&lt;col&gt;&lt;field&gt;</xsl:text>
<xsl:call-template name="get-name"/>
<xsl:text>&lt;/field&gt;&lt;/col&gt;&#xa;</xsl:text>
<xsl:choose>
<xsl:when test="primary">
<xsl:text>&#x9;&#x9;&#x9;&#x9;&lt;col&gt;&lt;field&gt;</xsl:text>
<xsl:call-template name="get-name"/>
<xsl:text>&lt;/field&gt;&lt;link_cmd&gt;update&lt;/link_cmd&gt;&lt;/col&gt;&#xa;</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text>&#x9;&#x9;&#x9;&#x9;&lt;col&gt;&lt;field&gt;</xsl:text>
<xsl:call-template name="get-name"/>
<xsl:text>&lt;/field&gt;&lt;/col&gt;&#xa;</xsl:text>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
<xsl:text>&#x9;&#x9;&#x9;&lt;/query_cols&gt;&#xa;</xsl:text>
<xsl:text>&#x9;&#x9;&lt;/cmd&gt;&#xa;</xsl:text>

@ -16,7 +16,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

@ -20,7 +20,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-->

@ -20,7 +20,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
-->

@ -25,7 +25,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*!
* \file
@ -38,6 +38,7 @@
#include "globals.h"
#include "dprint.h"
#include "pvar.h"
#include <stdarg.h>
#include <stdio.h>
@ -97,8 +98,7 @@ int log_facility_fixup(void *handle, str *gname, str *name, void **val)
int i;
if ((i = str2facility((char *)*val)) == -1) {
LOG(L_ERR, "log_facility_fixup: invalid log facility: %s\n",
(char *)*val);
LM_ERR("invalid log facility: %s\n", (char *)*val);
return -1;
}
*val = (void *)(long)i;
@ -368,3 +368,43 @@ void dprint_color_update(int level, char f, char b)
if(f && f!='0') _log_level_colors[level - L_MIN].f = f;
if(b && b!='0') _log_level_colors[level - L_MIN].b = b;
}
/* log_prefix functionality */
str *log_prefix_val = NULL;
static pv_elem_t *log_prefix_pvs = NULL;
#define LOG_PREFIX_SIZE 128
static char log_prefix_buf[LOG_PREFIX_SIZE];
static str log_prefix_str;
void log_prefix_init(void)
{
str s;
if(log_prefix_fmt==NULL)
return;
s.s = log_prefix_fmt; s.len = strlen(s.s);
if(pv_parse_format(&s, &log_prefix_pvs)<0)
{
LM_ERR("wrong format[%s]\n", s.s);
return;
}
}
void log_prefix_set(sip_msg_t *msg)
{
if(log_prefix_pvs == NULL)
return;
if(msg==NULL) {
log_prefix_val = NULL;
return;
}
log_prefix_str.s = log_prefix_buf;
log_prefix_str.len = LOG_PREFIX_SIZE;
if(pv_printf(msg, log_prefix_pvs, log_prefix_str.s, &log_prefix_str.len)<0)
return;
if(log_prefix_str.len<=0)
return;
log_prefix_val = &log_prefix_str;
}

@ -15,7 +15,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
@ -86,6 +86,7 @@
/*
* Log levels
*/
#define L_NPRL -6 /* (L_MIN-1) to skip printing level prefix */
#define L_MIN -5
#define L_ALERT -5
#define L_BUG -4
@ -117,6 +118,8 @@ extern int my_pid(void);
extern int log_stderr;
extern int log_color;
extern char *log_prefix_fmt;
extern str *log_prefix_val;
/** @brief maps log levels to their string name and corresponding syslog level */
@ -150,6 +153,8 @@ void dprint_color_update(int level, char f, char b);
void dprint_init_colors(void);
void dprint_term_color(char f, char b, str *obuf);
void log_prefix_init(void);
/** @brief
* General logging macros
*
@ -162,13 +167,17 @@ void dprint_term_color(char f, char b, str *obuf);
#ifdef NO_LOG
# ifdef __SUNPRO_C
# define LOG__(facility, level, lname, prefix, fmt, ...)
# define LOG_(facility, level, prefix, fmt, ...)
# define LOG(level, fmt, ...)
# define LOG_FC(facility, level, fmt, ...)
# define LOG_LN(level, lname, fmt, ...)
# else
# define LOG__(facility, level, lname, prefix, fmt, args...)
# define LOG_(facility, level, prefix, fmt, args...)
# define LOG(level, fmt, args...)
# define LOG_FC(facility, level, fmt, args...)
# define LOG_LN(level, lname, fmt, args...)
# endif
#else
@ -184,7 +193,7 @@ void dprint_term_color(char f, char b, str *obuf);
# endif
# ifdef __SUNPRO_C
# define LOG_(facility, level, prefix, fmt, ...) \
# define LOG__(facility, level, lname, prefix, fmt, ...) \
do { \
if (unlikely(get_debug_level(LOG_MNAME, LOG_MNAME_LEN) >= (level) && \
DPRINT_NON_CRIT)) { \
@ -194,7 +203,7 @@ void dprint_term_color(char f, char b, str *obuf);
if (unlikely(log_color)) dprint_color(level); \
fprintf(stderr, "%2d(%d) %s: %s" fmt, \
process_no, my_pid(), \
LOG_LEVEL2NAME(level), (prefix), \
(lname)?(lname):LOG_LEVEL2NAME(level), (prefix), \
__VA_ARGS__); \
if (unlikely(log_color)) dprint_color_reset(); \
} else { \
@ -202,7 +211,8 @@ void dprint_term_color(char f, char b, str *obuf);
(((facility) != DEFAULT_FACILITY) ? \
(facility) : \
cfg_get(core, core_cfg, log_facility)), \
"%s: %s" fmt, LOG_LEVEL2NAME(level),\
"%s: %s" fmt, \
(lname)?(lname):LOG_LEVEL2NAME(level),\
(prefix), __VA_ARGS__); \
} \
} else { \
@ -230,7 +240,10 @@ void dprint_term_color(char f, char b, str *obuf);
DPRINT_CRIT_EXIT; \
} \
} while(0)
# define LOG_(facility, level, lname, prefix, fmt, ...) \
LOG__(facility, level, NULL, prefix, fmt, __VA_ARGS__)
# ifdef LOG_FUNC_NAME
# define LOG(level, fmt, ...) \
LOG_(DEFAULT_FACILITY, (level), LOC_INFO, "%s(): " fmt,\
@ -239,6 +252,11 @@ void dprint_term_color(char f, char b, str *obuf);
# define LOG_FC(facility, level, fmt, ...) \
LOG_((facility), (level), LOC_INFO, "%s(): " fmt,\
_FUNC_NAME_, __VA_ARGS__)
# define LOG_LN(level, lname, fmt, ...) \
LOG__(DEFAULT_FACILITY, (level), (lname), LOC_INFO, "%s(): " fmt,\
_FUNC_NAME_, __VA_ARGS__)
# else /* LOG_FUNC_NAME */
# define LOG(level, fmt, ...) \
@ -247,56 +265,61 @@ void dprint_term_color(char f, char b, str *obuf);
# define LOG_FC(facility, level, fmt, ...) \
LOG_((facility), (level), LOC_INFO, fmt, __VA_ARGS__)
# define LOG_LN(level, lname, fmt, ...) \
LOG_(DEFAULT_FACILITY, (level), (lname), LOC_INFO, fmt, __VA_ARGS__)
# endif /* LOG_FUNC_NAME */
# else /* ! __SUNPRO_C */
# define LOG_(facility, level, prefix, fmt, args...) \
# define LOG__(facility, level, lname, prefix, fmt, args...) \
do { \
if (get_debug_level(LOG_MNAME, LOG_MNAME_LEN) >= (level) && \
DPRINT_NON_CRIT) { \
int __llevel; \
__llevel = ((level)<L_ALERT)?L_ALERT:(((level)>L_DBG)?L_DBG:level); \
DPRINT_CRIT_ENTER; \
if (likely(((level) >= L_ALERT) && ((level) <= L_DBG))){ \
if (unlikely(log_stderr)) { \
if (unlikely(log_color)) dprint_color(level); \
fprintf(stderr, "%2d(%d) %s: %s" fmt, \
process_no, my_pid(), \
LOG_LEVEL2NAME(level), \
(prefix) , ## args);\
if (unlikely(log_color)) dprint_color_reset(); \
if (unlikely(log_stderr)) { \
if (unlikely(log_color)) dprint_color(__llevel); \
if(unlikely(log_prefix_val)) { \
fprintf(stderr, "%.*s%2d(%d) %s: %s" fmt, \
log_prefix_val->len, log_prefix_val->s, \
process_no, my_pid(), \
(lname)?(lname):LOG_LEVEL2NAME(__llevel), \
(prefix) , ## args);\
} else { \
syslog(LOG2SYSLOG_LEVEL(level) |\
(((facility) != DEFAULT_FACILITY) ? \
(facility) : \
cfg_get(core, core_cfg, log_facility)), \
"%s: %s" fmt, LOG_LEVEL2NAME(level),\
(prefix) , ## args); \
fprintf(stderr, "%2d(%d) %s: %s" fmt, \
process_no, my_pid(), \
(lname)?(lname):LOG_LEVEL2NAME(__llevel), \
(prefix) , ## args);\
} \
if (unlikely(log_color)) dprint_color_reset(); \
} else { \
if (log_stderr) { \
if (unlikely(log_color)) dprint_color(level); \
fprintf(stderr, "%2d(%d) %s" fmt, \
process_no, my_pid(), \
(prefix) , ## args); \
if (unlikely(log_color)) dprint_color_reset(); \
if(unlikely(log_prefix_val)) { \
syslog(LOG2SYSLOG_LEVEL(__llevel) |\
(((facility) != DEFAULT_FACILITY) ? \
(facility) : \
cfg_get(core, core_cfg, log_facility)), \
"%.*s%s: %s" fmt,\
log_prefix_val->len, log_prefix_val->s, \
(lname)?(lname):LOG_LEVEL2NAME(__llevel),\
(prefix) , ## args); \
} else { \
if ((level)<L_ALERT) \
syslog(LOG2SYSLOG_LEVEL(L_ALERT) | \
(((facility) != DEFAULT_FACILITY) ? \
(facility) : \
cfg_get(core, core_cfg, log_facility)),\
"%s" fmt, (prefix) , ## args); \
else \
syslog(LOG2SYSLOG_LEVEL(L_DBG) | \
(((facility) != DEFAULT_FACILITY) ? \
(facility) : \
cfg_get(core, core_cfg, log_facility)),\
"%s" fmt, (prefix) , ## args); \
syslog(LOG2SYSLOG_LEVEL(__llevel) |\
(((facility) != DEFAULT_FACILITY) ? \
(facility) : \
cfg_get(core, core_cfg, log_facility)), \
"%s: %s" fmt,\
(lname)?(lname):LOG_LEVEL2NAME(__llevel),\
(prefix) , ## args); \
} \
} \
DPRINT_CRIT_EXIT; \
} \
} while(0)
# define LOG_(facility, level, prefix, fmt, args...) \
LOG__(facility, level, NULL, prefix, fmt, ## args)
# ifdef LOG_FUNC_NAME
# define LOG(level, fmt, args...) \
LOG_(DEFAULT_FACILITY, (level), LOC_INFO, "%s(): " fmt ,\
@ -305,11 +328,17 @@ void dprint_term_color(char f, char b, str *obuf);
# define LOG_FC(facility, level, fmt, args...) \
LOG_((facility), (level), LOC_INFO, "%s(): " fmt , _FUNC_NAME_, ## args)
# define LOG_LN(level, lname, fmt, args...) \
LOG__(DEFAULT_FACILITY, (level), (lname), LOC_INFO, "%s(): " fmt ,\
_FUNC_NAME_, ## args)
# else /* LOG_FUNC_NAME */
# define LOG(level, fmt, args...) \
LOG_(DEFAULT_FACILITY, (level), LOC_INFO, fmt , ## args)
# define LOG_FC(facility, level, fmt, args...) \
LOG_((facility), (level), LOC_INFO, fmt , ## args)
# define LOG_LN(level, lname, fmt, args...) \
LOG__(DEFAULT_FACILITY, (level), (lname), LOC_INFO, fmt , ## args)
# endif /* LOG_FUNC_NAME */
# endif /* __SUNPRO_C */
@ -321,6 +350,7 @@ void dprint_term_color(char f, char b, str *obuf);
*/
/*@ { */
#ifdef __SUNPRO_C
# define NPRL(...) LOG(L_NPRL, __VA_ARGS__)
# define ALERT(...) LOG(L_ALERT, __VA_ARGS__)
# define BUG(...) LOG(L_BUG, __VA_ARGS__)
# define ERR(...) LOG(L_ERR, __VA_ARGS__)
@ -340,6 +370,7 @@ void dprint_term_color(char f, char b, str *obuf);
# define DEBUG(...) DBG(__VA_ARGS__)
#else /* ! __SUNPRO_C */
# define NPRL(fmt, args...) LOG(L_NPRL, fmt , ## args)
# define ALERT(fmt, args...) LOG(L_ALERT, fmt , ## args)
# define BUG(fmt, args...) LOG(L_BUG, fmt , ## args)
# define ERR(fmt, args...) LOG(L_ERR, fmt , ## args)
@ -364,6 +395,7 @@ void dprint_term_color(char f, char b, str *obuf);
#define LM_GEN1 LOG
#define LM_GEN2 LOG_FC
#define LM_NPRL NPRL
#define LM_ALERT ALERT
#define LM_CRIT CRIT
#define LM_ERR ERR

@ -24,7 +24,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/** destination set / branches support.
@ -334,7 +334,7 @@ int append_branch(struct sip_msg* msg, str* uri, str* dst_uri, str* path,
* of branches, don't try new ones
*/
if (unlikely(nr_branches == MAX_BRANCHES - 1)) {
LOG(L_ERR, "max nr of branches exceeded\n");
LM_ERR("max nr of branches exceeded\n");
ser_error = E_TOO_MANY_BRANCHES;
return -1;
}
@ -350,14 +350,14 @@ int append_branch(struct sip_msg* msg, str* uri, str* dst_uri, str* path,
}
if (unlikely(luri.len > MAX_URI_SIZE - 1)) {
LOG(L_ERR, "too long uri: %.*s\n", luri.len, luri.s);
LM_ERR("too long uri: %.*s\n", luri.len, luri.s);
return -1;
}
/* copy the dst_uri */
if (dst_uri && dst_uri->len && dst_uri->s) {
if (unlikely(dst_uri->len > MAX_URI_SIZE - 1)) {
LOG(L_ERR, "too long dst_uri: %.*s\n", dst_uri->len, dst_uri->s);
LM_ERR("too long dst_uri: %.*s\n", dst_uri->len, dst_uri->s);
return -1;
}
memcpy(branches[nr_branches].dst_uri, dst_uri->s, dst_uri->len);
@ -371,7 +371,7 @@ int append_branch(struct sip_msg* msg, str* uri, str* dst_uri, str* path,
/* copy the path string */
if (unlikely(path && path->len && path->s)) {
if (unlikely(path->len > MAX_PATH_SIZE - 1)) {
LOG(L_ERR, "too long path: %.*s\n", path->len, path->s);
LM_ERR("too long path: %.*s\n", path->len, path->s);
return -1;
}
memcpy(branches[nr_branches].path, path->s, path->len);
@ -394,7 +394,7 @@ int append_branch(struct sip_msg* msg, str* uri, str* dst_uri, str* path,
/* copy instance string */
if (unlikely(instance && instance->len && instance->s)) {
if (unlikely(instance->len > MAX_INSTANCE_SIZE - 1)) {
LOG(L_ERR, "too long instance: %.*s\n",
LM_ERR("too long instance: %.*s\n",
instance->len, instance->s);
return -1;
}
@ -413,7 +413,7 @@ int append_branch(struct sip_msg* msg, str* uri, str* dst_uri, str* path,
/* copy ruid string */
if (unlikely(ruid && ruid->len && ruid->s)) {
if (unlikely(ruid->len > MAX_RUID_SIZE - 1)) {
LOG(L_ERR, "too long ruid: %.*s\n",
LM_ERR("too long ruid: %.*s\n",
ruid->len, ruid->s);
return -1;
}
@ -428,7 +428,7 @@ int append_branch(struct sip_msg* msg, str* uri, str* dst_uri, str* path,
if (unlikely(location_ua && location_ua->len && location_ua->s)) {
if (unlikely(location_ua->len > MAX_UA_SIZE)) {
LOG(L_ERR, "too long location_ua: %.*s\n",
LM_ERR("too long location_ua: %.*s\n",
location_ua->len, location_ua->s);
return -1;
}
@ -492,7 +492,7 @@ char* print_dset(struct sip_msg* msg, int* len)
*len += CONTACT_LEN + CRLF_LEN + (cnt - 1) * CONTACT_DELIM_LEN;
if (*len + 1 > MAX_REDIRECTION_LEN) {
LOG(L_ERR, "ERROR: redirection buffer length exceed\n");
LM_ERR("redirection buffer length exceed\n");
goto error;
}

@ -17,7 +17,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/*!

@ -24,7 +24,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* History:
* --------
@ -222,7 +222,7 @@ static int init_blacklist_hooks()
goto error;
return 0;
error:
LOG(L_ERR, "blacklist_hooks: failure initializing internal lists\n");
LM_ERR("failure initializing internal lists\n");
destroy_blacklist_hooks();
return -1;
}
@ -240,7 +240,7 @@ int register_blacklist_hook(struct blacklist_hook *h, int type)
int new_max_hooks;
if (dst_blacklist_init==0) {
LOG(L_ERR, "register_blacklist_hook: blacklist is turned off, "
LM_ERR("blacklist is turned off, "
"the hook cannot be registered\n");
goto error;
}
@ -500,7 +500,7 @@ int init_dst_blacklist()
if (blst_timer_interval){
timer_init(blst_timer_h, blst_timer, 0 ,0); /* slow timer */
if (timer_add(blst_timer_h, S_TO_TICKS(blst_timer_interval))<0){
LOG(L_CRIT, "BUG: init_dst_blacklist: failed to add the timer\n");
LM_CRIT("failed to add the timer\n");
timer_free(blst_timer_h);
blst_timer_h=0;
goto error;
@ -1075,11 +1075,11 @@ void dst_blst_view(rpc_t* rpc, void* ctx)
continue;
}
dst_blst_entry2ip(&ip, e);
rpc->printf(ctx, "{\n protocol: %s", get_proto_name(e->proto));
rpc->printf(ctx, " ip: %s", ip_addr2a(&ip));
rpc->printf(ctx, " port: %d", e->port);
rpc->printf(ctx, " expires in (s): %d", expires);
rpc->printf(ctx, " flags: %d\n}", e->flags);
rpc->rpl_printf(ctx, "{\n protocol: %s", get_proto_name(e->proto));
rpc->rpl_printf(ctx, " ip: %s", ip_addr2a(&ip));
rpc->rpl_printf(ctx, " port: %d", e->port);
rpc->rpl_printf(ctx, " expires in (s): %d", expires);
rpc->rpl_printf(ctx, " flags: %d\n}", e->flags);
}
UNLOCK_BLST(h);
}
@ -1173,8 +1173,7 @@ void dst_blst_add(rpc_t* rpc, void* ctx)
int use_dst_blacklist_fixup(void *handle, str *gname, str *name, void **val)
{
if ((int)(long)(*val) && !dst_blacklist_init) {
LOG(L_ERR, "ERROR: use_dst_blacklist_fixup(): "
"dst blacklist is turned off by dst_blacklist_init=0, "
LM_ERR("dst blacklist is turned off by dst_blacklist_init=0, "
"it cannot be enabled runtime.\n");
return -1;
}

@ -15,7 +15,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/** SIP-router core :: Destination blacklists.

@ -23,7 +23,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* History:
* --------
@ -216,7 +216,7 @@ void get_reply_status( str *status, struct sip_msg *reply, int code )
status->s=0;
if (reply==0) {
LOG(L_CRIT, "BUG: get_reply_status called with 0 msg\n");
LM_CRIT("0 msg\n");
return;
}
@ -229,7 +229,7 @@ void get_reply_status( str *status, struct sip_msg *reply, int code )
status->len=phrase.len+3/*code*/+1/*space*/;
status->s=pkg_malloc(status->len+1/*ZT */);
if (!status->s) {
LOG(L_ERR, "ERROR: get_reply_status: no mem\n");
LM_ERR("no mem\n");
return;
}
status->s[3]=' ';

@ -17,7 +17,7 @@
*
* 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/

@ -1,6 +1,6 @@
#!KAMAILIO
#
# Kamailio (OpenSER) SIP Server v4.0 - default configuration script
# Kamailio (OpenSER) SIP Server v4.2 - default configuration script
# - web: http://www.kamailio.org
# - git: http://sip-router.org
#
@ -37,6 +37,7 @@
# - install RTPProxy: http://www.rtpproxy.org
# - start RTPProxy:
# rtpproxy -l _your_public_ip_ -s udp:localhost:7722
# - option for NAT SIP OPTIONS keepalives: WITH_NATSIPPING
#
# *** To enable TLS support execute:
# - adjust CFGDIR/tls.cfg as needed
@ -136,9 +137,9 @@ tcp_connection_lifetime=3605
# set paths to location of modules (to sources or installation folders)
#!ifdef WITH_SRCPATH
mpath="modules_k:modules"
mpath="modules"
#!else
mpath="/usr/local/lib/kamailio/modules_k/:/usr/local/lib/kamailio/modules/"
mpath="/usr/local/lib/kamailio/modules/"
#!endif
#!ifdef WITH_MYSQL
@ -327,6 +328,11 @@ request_route {
### only initial requests (no To tag)
# handle retransmissions
if(t_precheck_trans()) {
t_check_trans();
exit;
}
t_check_trans();
# authentication
@ -399,6 +405,10 @@ route[REQINIT] {
exit;
}
}
if($ua =~ "friendly-scanner") {
sl_send_reply("200", "OK");
exit;
}
#!endif
if (!mf_process_maxfwd_header("10")) {
@ -406,6 +416,11 @@ route[REQINIT] {
exit;
}
if(is_method("OPTIONS") && uri==myself && $rU==$null) {
sl_send_reply("200","Keepalive");
exit;
}
if(!sanity_check("1511", "7")) {
xlog("Malformed SIP message from $si:$sp\n");
exit;
@ -414,59 +429,60 @@ route[REQINIT] {
# Handle requests within SIP dialogs
route[WITHINDLG] {
if (has_totag()) {
# sequential request withing a dialog should
# take the path determined by record-routing
if (loose_route()) {
route(DLGURI);
if (is_method("BYE")) {
setflag(FLT_ACC); # do accounting ...
setflag(FLT_ACCFAILED); # ... even if the transaction fails
}
else if ( is_method("ACK") ) {
# ACK is forwarded statelessy
route(NATMANAGE);
}
else if ( is_method("NOTIFY") ) {
# Add Record-Route for in-dialog NOTIFY as per RFC 6665.
record_route();
}
if (!has_totag()) return;
# sequential request withing a dialog should
# take the path determined by record-routing
if (loose_route()) {
route(DLGURI);
if (is_method("BYE")) {
setflag(FLT_ACC); # do accounting ...
setflag(FLT_ACCFAILED); # ... even if the transaction fails
}
else if ( is_method("ACK") ) {
# ACK is forwarded statelessy
route(NATMANAGE);
}
else if ( is_method("NOTIFY") ) {
# Add Record-Route for in-dialog NOTIFY as per RFC 6665.
record_route();
}
route(RELAY);
exit;
}
if ( is_method("ACK") ) {
if ( t_check_trans() ) {
# no loose-route, but stateful ACK;
# must be an ACK after a 487
# or e.g. 404 from upstream server
route(RELAY);
exit;
} else {
if ( is_method("ACK") ) {
if ( t_check_trans() ) {
# no loose-route, but stateful ACK;
# must be an ACK after a 487
# or e.g. 404 from upstream server
route(RELAY);
exit;
} else {
# ACK without matching transaction ... ignore and discard
exit;
}
}
sl_send_reply("404","Not here");
# ACK without matching transaction ... ignore and discard
exit;
}
exit;
}
sl_send_reply("404", "Not here");
exit;
}
# Handle SIP registrations
route[REGISTRAR] {
if (is_method("REGISTER")) {
if(isflagset(FLT_NATS)) {
setbflag(FLB_NATB);
# uncomment next line to do SIP NAT pinging
## setbflag(FLB_NATSIPPING);
}
if (!save("location"))
sl_reply_error();
exit;
if (!is_method("REGISTER")) return;
if(isflagset(FLT_NATS)) {
setbflag(FLB_NATB);
#!ifdef WITH_NATSIPPING
# do SIP NAT pinging
setbflag(FLB_NATSIPPING);
#!endif
}
if (!save("location"))
sl_reply_error();
exit;
}
# USER location service
# User location service
route[LOCATION] {
if (!lookup("location")) {
$var(rc) = $rc;
@ -492,7 +508,7 @@ route[LOCATION] {
}
# Authentication route
# IP authorization and user uthentication
route[AUTH] {
#!ifdef WITH_AUTH
@ -524,7 +540,7 @@ route[AUTH] {
return;
}
# Caller NAT detection route
# Caller NAT detection
route[NATDETECT] {
#!ifdef WITH_NAT
force_rport();
@ -532,7 +548,8 @@ route[NATDETECT] {
if (is_method("REGISTER")) {
fix_nated_register();
} else {
add_contact_alias();
if(is_first_hop())
set_contact_alias();
}
setflag(FLT_NATS);
}
@ -564,7 +581,7 @@ route[NATMANAGE] {
}
if (is_reply()) {
if(isbflagset(FLB_NATB)) {
add_contact_alias();
set_contact_alias();
}
}
#!endif
@ -583,26 +600,27 @@ route[DLGURI] {
# Routing to foreign domains
route[SIPOUT] {
if (!uri==myself) {
append_hf("P-hint: outbound\r\n");
route(RELAY);
}
if (uri==myself) return;
append_hf("P-hint: outbound\r\n");
route(RELAY);
exit;
}
# manage outgoing branches
# Manage outgoing branches
branch_route[MANAGE_BRANCH] {
xdbg("new branch [$T_branch_idx] to $ru\n");
route(NATMANAGE);
}
# manage incoming replies
# Manage incoming replies
onreply_route[MANAGE_REPLY] {
xdbg("incoming reply\n");
if(status=~"[12][0-9][0-9]")
route(NATMANAGE);
}
# manage failure routing cases
# Manage failure routing cases
failure_route[MANAGE_FAILURE] {
route(NATMANAGE);

@ -1,6 +1,6 @@
#!KAMAILIO
#
# Kamailio (OpenSER) SIP Server v3.4 - default configuration script
# Kamailio (OpenSER) SIP Server v4.2 - default configuration script
# - web: http://www.kamailio.org
# - git: http://sip-router.org
#
@ -41,6 +41,7 @@
# - install RTPProxy: http://www.rtpproxy.org
# - start RTPProxy:
# rtpproxy -l _your_public_ip_ -s udp:localhost:7722
# - option for NAT SIP OPTIONS keepalives: WITH_NATSIPPING
#
# *** To enable PSTN gateway routing execute:
# - define WITH_PSTN
@ -497,8 +498,7 @@ request_route {
route(NATDETECT);
# CANCEL processing
if (is_method("CANCEL"))
{
if (is_method("CANCEL")) {
if (t_check_trans())
t_relay();
exit;
@ -509,6 +509,11 @@ request_route {
### only initial requests (no To tag)
# handle retransmissions
if(t_precheck_trans()) {
t_check_trans();
exit;
}
t_check_trans();
# authentication
@ -521,8 +526,7 @@ request_route {
record_route();
# account only INVITEs
if (is_method("INVITE"))
{
if (is_method("INVITE")) {
setflag(FLT_ACC); # do accounting
}
@ -537,10 +541,9 @@ request_route {
# handle registrations
route(REGISTRAR);
if ($rU==$null)
{
if ($rU==$null) {
# request with no Username in RURI
sl_send_reply("484","Address Incomplete");
sl_send_reply("484", "Address Incomplete");
exit;
}
@ -580,21 +583,22 @@ route[REQINIT] {
# flood dection from same IP and traffic ban for a while
# be sure you exclude checking trusted peers, such as pstn gateways
# - local host excluded (e.g., loop to self)
if(src_ip!=myself)
{
if($sht(ipban=>$si)!=$null)
{
if(src_ip!=myself) {
if($sht(ipban=>$si)!=$null) {
# ip is already blocked
xdbg("request from blocked IP - $rm from $fu (IP:$si:$sp)\n");
exit;
}
if (!pike_check_req())
{
if (!pike_check_req()) {
xlog("L_ALERT","ALERT: pike blocking $rm from $fu (IP:$si:$sp)\n");
$sht(ipban=>$si) = 1;
exit;
}
}
if($ua =~ "friendly-scanner") {
sl_send_reply("200", "OK");
exit;
}
#!endif
if (!mf_process_maxfwd_header("10")) {
@ -602,8 +606,12 @@ route[REQINIT] {
exit;
}
if(!sanity_check("1511", "7"))
{
if(is_method("OPTIONS") && uri==myself && $rU==$null) {
sl_send_reply("200","Keepalive");
exit;
}
if(!sanity_check("1511", "7")) {
xlog("Malformed SIP message from $si:$sp\n");
exit;
}
@ -611,66 +619,67 @@ route[REQINIT] {
# Handle requests within SIP dialogs
route[WITHINDLG] {
if (has_totag()) {
# sequential request withing a dialog should
# take the path determined by record-routing
if (loose_route()) {
route(DLGURI);
if (is_method("BYE")) {
setflag(FLT_ACC); # do accounting ...
setflag(FLT_ACCFAILED); # ... even if the transaction fails
}
else if ( is_method("ACK") ) {
# ACK is forwarded statelessy
route(NATMANAGE);
}
else if ( is_method("NOTIFY") ) {
# Add Record-Route for in-dialog NOTIFY as per RFC 6665.
record_route();
}
route(RELAY);
} else {
if (is_method("SUBSCRIBE") && uri == myself) {
# in-dialog subscribe requests
route(PRESENCE);
exit;
}
if ( is_method("ACK") ) {
if ( t_check_trans() ) {
# no loose-route, but stateful ACK;
# must be an ACK after a 487
# or e.g. 404 from upstream server
t_relay();
exit;
} else {
# ACK without matching transaction ... ignore and discard
exit;
}
}
sl_send_reply("404","Not here");
if (!has_totag()) return;
# sequential request withing a dialog should
# take the path determined by record-routing
if (loose_route()) {
route(DLGURI);
if (is_method("BYE")) {
setflag(FLT_ACC); # do accounting ...
setflag(FLT_ACCFAILED); # ... even if the transaction fails
}
else if ( is_method("ACK") ) {
# ACK is forwarded statelessy
route(NATMANAGE);
}
else if ( is_method("NOTIFY") ) {
# Add Record-Route for in-dialog NOTIFY as per RFC 6665.
record_route();
}
route(RELAY);
exit;
}
if (is_method("SUBSCRIBE") && uri == myself) {
# in-dialog subscribe requests
route(PRESENCE);
exit;
}
if ( is_method("ACK") ) {
if ( t_check_trans() ) {
# no loose-route, but stateful ACK;
# must be an ACK after a 487
# or e.g. 404 from upstream server
t_relay();
exit;
} else {
# ACK without matching transaction ... ignore and discard
exit;
}
}
sl_send_reply("404", "Not here");
exit;
}
# Handle SIP registrations
route[REGISTRAR] {
if (is_method("REGISTER"))
{
if(isflagset(FLT_NATS))
{
setbflag(FLB_NATB);
# uncomment next line to do SIP NAT pinging
## setbflag(FLB_NATSIPPING);
}
if (!save("location"))
sl_reply_error();
if (!is_method("REGISTER")) return;
exit;
if(isflagset(FLT_NATS)) {
setbflag(FLB_NATB);
#!ifdef WITH_NATSIPPING
# do SIP NAT pinging
setbflag(FLB_NATSIPPING);
#!endif
}
if (!save("location"))
sl_reply_error();
exit;
}
# USER location service
# User location service
route[LOCATION] {
#!ifdef WITH_SPEEDDIAL
@ -703,8 +712,7 @@ route[LOCATION] {
}
# when routing via usrloc, log the missed calls also
if (is_method("INVITE"))
{
if (is_method("INVITE")) {
setflag(FLT_ACCMISSED);
}
}
@ -715,20 +723,15 @@ route[PRESENCE] {
return;
#!ifdef WITH_PRESENCE
if (!t_newtran())
{
if (!t_newtran()) {
sl_reply_error();
exit;
};
}
if(is_method("PUBLISH"))
{
if(is_method("PUBLISH")) {
handle_publish();
t_release();
}
else
if( is_method("SUBSCRIBE"))
{
} else if( is_method("SUBSCRIBE")) {
handle_subscribe();
t_release();
}
@ -736,8 +739,7 @@ route[PRESENCE] {
#!endif
# if presence enabled, this part will not be executed
if (is_method("PUBLISH") || $rU==$null)
{
if (is_method("PUBLISH") || $rU==$null) {
sl_send_reply("404", "Not here");
exit;
}
@ -749,15 +751,13 @@ route[AUTH] {
#!ifdef WITH_AUTH
#!ifdef WITH_IPAUTH
if((!is_method("REGISTER")) && allow_source_address())
{
if((!is_method("REGISTER")) && allow_source_address()) {
# source IP allowed
return;
}
#!endif
if (is_method("REGISTER") || from_uri==myself)
{
if (is_method("REGISTER") || from_uri==myself) {
# authenticate requests
if (!auth_check("$fd", "subscriber", "1")) {
auth_challenge("$fd", "0");
@ -769,8 +769,7 @@ route[AUTH] {
}
# if caller is not local subscriber, then check if it calls
# a local destination, otherwise deny, not an open relay here
if (from_uri!=myself && uri!=myself)
{
if (from_uri!=myself && uri!=myself) {
sl_send_reply("403","Not relaying");
exit;
}
@ -787,7 +786,8 @@ route[NATDETECT] {
if (is_method("REGISTER")) {
fix_nated_register();
} else {
add_contact_alias();
if(is_first_hop())
set_contact_alias();
}
setflag(FLT_NATS);
}
@ -808,16 +808,19 @@ route[NATMANAGE] {
if (!(isflagset(FLT_NATS) || isbflagset(FLB_NATB)))
return;
rtpproxy_manage();
rtpproxy_manage("co");
if (is_request()) {
if (!has_totag()) {
add_rr_param(";nat=yes");
if(t_is_branch_route()) {
add_rr_param(";nat=yes");
}
}
}
if (is_reply()) {
if(isbflagset(FLB_NATB)) {
add_contact_alias();
if(is_first_hop())
set_contact_alias();
}
}
#!endif
@ -836,11 +839,11 @@ route[DLGURI] {
# Routing to foreign domains
route[SIPOUT] {
if (!uri==myself)
{
append_hf("P-hint: outbound\r\n");
route(RELAY);
}
if (uri==myself) return;
append_hf("P-hint: outbound\r\n");
route(RELAY);
exit;
}
# PSTN GW routing
@ -897,7 +900,7 @@ route[XMLRPC] {
}
#!endif
# route to voicemail server
# Routing to voicemail server
route[TOVOICEMAIL] {
#!ifdef WITH_VOICEMAIL
if(!is_method("INVITE"))
@ -920,20 +923,20 @@ route[TOVOICEMAIL] {
return;
}
# manage outgoing branches
# Manage outgoing branches
branch_route[MANAGE_BRANCH] {
xdbg("new branch [$T_branch_idx] to $ru\n");
route(NATMANAGE);
}
# manage incoming replies
# Manage incoming replies
onreply_route[MANAGE_REPLY] {
xdbg("incoming reply\n");
if(status=~"[12][0-9][0-9]")
route(NATMANAGE);
}
# manage failure routing cases
# Manage failure routing cases
failure_route[MANAGE_FAILURE] {
route(NATMANAGE);
@ -959,6 +962,7 @@ failure_route[MANAGE_FAILURE] {
#!endif
}
# Handling HTTP events
#!ifdef WITH_XHTTP
event_route[xhttp:request] {
#!ifdef WITH_XHTTP_RPC

@ -1,6 +1,6 @@
#!KAMAILIO
#
# Kamailio (OpenSER) SIP Server v4.1 - default configuration script
# Kamailio (OpenSER) SIP Server v4.2 - default configuration script
# - web: http://www.kamailio.org
# - git: http://sip-router.org
#
@ -41,6 +41,7 @@
# - install RTPProxy: http://www.rtpproxy.org
# - start RTPProxy:
# rtpproxy -l _your_public_ip_ -s udp:localhost:7722
# - option for NAT SIP OPTIONS keepalives: WITH_NATSIPPING
#
# *** To enable PSTN gateway routing execute:
# - define WITH_PSTN
@ -300,8 +301,8 @@ modparam("tm", "fr_inv_timer", 120000)
# ----- rr params -----
# add value to ;lr param to cope with most of the UAs
modparam("rr", "enable_full_lr", 1)
# set next param to 1 to add value to ;lr param (helps with some UAs)
modparam("rr", "enable_full_lr", 0)
# do not append from tag to the RR (no need for this script)
modparam("rr", "append_fromtag", 0)
@ -444,6 +445,7 @@ modparam("xmlrpc", "url_match", "^/RPC")
#!ifdef WITH_DEBUG
# ----- debugger params -----
modparam("debugger", "cfgtrace", 1)
modparam("debugger", "log_level_name", "exec")
#!endif
####### Routing Logic ########
@ -461,8 +463,7 @@ request_route {
route(NATDETECT);
# CANCEL processing
if (is_method("CANCEL"))
{
if (is_method("CANCEL")) {
if (t_check_trans()) {
route(RELAY);
}
@ -474,6 +475,11 @@ request_route {
### only initial requests (no To tag)
# handle retransmissions
if(t_precheck_trans()) {
t_check_trans();
exit;
}
t_check_trans();
# authentication
@ -486,8 +492,7 @@ request_route {
record_route();
# account only INVITEs
if (is_method("INVITE"))
{
if (is_method("INVITE")) {
setflag(FLT_ACC); # do accounting
}
@ -502,8 +507,7 @@ request_route {
# handle registrations
route(REGISTRAR);
if ($rU==$null)
{
if ($rU==$null) {
# request with no Username in RURI
sl_send_reply("484","Address Incomplete");
exit;
@ -516,7 +520,7 @@ request_route {
route(LOCATION);
}
# Wrapper for relaying requests
route[RELAY] {
# enable additional event routes for forwarded requests
@ -543,21 +547,22 @@ route[REQINIT] {
# flood dection from same IP and traffic ban for a while
# be sure you exclude checking trusted peers, such as pstn gateways
# - local host excluded (e.g., loop to self)
if(src_ip!=myself)
{
if($sht(ipban=>$si)!=$null)
{
if(src_ip!=myself) {
if($sht(ipban=>$si)!=$null) {
# ip is already blocked
xdbg("request from blocked IP - $rm from $fu (IP:$si:$sp)\n");
exit;
}
if (!pike_check_req())
{
if (!pike_check_req()) {
xlog("L_ALERT","ALERT: pike blocking $rm from $fu (IP:$si:$sp)\n");
$sht(ipban=>$si) = 1;
exit;
}
}
if($ua =~ "friendly-scanner") {
sl_send_reply("200", "OK");
exit;
}
#!endif
if (!mf_process_maxfwd_header("10")) {
@ -565,8 +570,12 @@ route[REQINIT] {
exit;
}
if(!sanity_check("1511", "7"))
{
if(is_method("OPTIONS") && uri==myself && $rU==$null) {
sl_send_reply("200","Keepalive");
exit;
}
if(!sanity_check("1511", "7")) {
xlog("Malformed SIP message from $si:$sp\n");
exit;
}
@ -574,66 +583,66 @@ route[REQINIT] {
# Handle requests within SIP dialogs
route[WITHINDLG] {
if (has_totag()) {
# sequential request withing a dialog should
# take the path determined by record-routing
if (loose_route()) {
route(DLGURI);
if (is_method("BYE")) {
setflag(FLT_ACC); # do accounting ...
setflag(FLT_ACCFAILED); # ... even if the transaction fails
}
else if ( is_method("ACK") ) {
# ACK is forwarded statelessy
route(NATMANAGE);
}
else if ( is_method("NOTIFY") ) {
# Add Record-Route for in-dialog NOTIFY as per RFC 6665.
record_route();
}
if (!has_totag()) return;
# sequential request withing a dialog should
# take the path determined by record-routing
if (loose_route()) {
route(DLGURI);
if (is_method("BYE")) {
setflag(FLT_ACC); # do accounting ...
setflag(FLT_ACCFAILED); # ... even if the transaction fails
}
else if ( is_method("ACK") ) {
# ACK is forwarded statelessy
route(NATMANAGE);
}
else if ( is_method("NOTIFY") ) {
# Add Record-Route for in-dialog NOTIFY as per RFC 6665.
record_route();
}
route(RELAY);
exit;
}
if (is_method("SUBSCRIBE") && uri == myself) {
# in-dialog subscribe requests
route(PRESENCE);
exit;
}
if ( is_method("ACK") ) {
if ( t_check_trans() ) {
# no loose-route, but stateful ACK;
# must be an ACK after a 487
# or e.g. 404 from upstream server
route(RELAY);
exit;
} else {
if (is_method("SUBSCRIBE") && uri == myself) {
# in-dialog subscribe requests
route(PRESENCE);
exit;
}
if ( is_method("ACK") ) {
if ( t_check_trans() ) {
# no loose-route, but stateful ACK;
# must be an ACK after a 487
# or e.g. 404 from upstream server
route(RELAY);
exit;
} else {
# ACK without matching transaction ... ignore and discard
exit;
}
}
sl_send_reply("404","Not here");
# ACK without matching transaction ... ignore and discard
exit;
}
exit;
}
sl_send_reply("404","Not here");
exit;
}
# Handle SIP registrations
route[REGISTRAR] {
if (is_method("REGISTER"))
{
if(isflagset(FLT_NATS))
{
setbflag(FLB_NATB);
# uncomment next line to do SIP NAT pinging
## setbflag(FLB_NATSIPPING);
}
if (!save("location"))
sl_reply_error();
if (!is_method("REGISTER")) return;
exit;
if(isflagset(FLT_NATS)) {
setbflag(FLB_NATB);
#!ifdef WITH_NATSIPPING
# do SIP NAT pinging
setbflag(FLB_NATSIPPING);
#!endif
}
if (!save("location"))
sl_reply_error();
exit;
}
# USER location service
# User location service
route[LOCATION] {
#!ifdef WITH_SPEEDDIAL
@ -666,8 +675,7 @@ route[LOCATION] {
}
# when routing via usrloc, log the missed calls also
if (is_method("INVITE"))
{
if (is_method("INVITE")) {
setflag(FLT_ACCMISSED);
}
@ -675,7 +683,7 @@ route[LOCATION] {
exit;
}
# Presence server route
# Presence server processing
route[PRESENCE] {
if(!is_method("PUBLISH|SUBSCRIBE"))
return;
@ -688,14 +696,12 @@ route[PRESENCE] {
}
#!ifdef WITH_PRESENCE
if (!t_newtran())
{
if (!t_newtran()) {
sl_reply_error();
exit;
}
if(is_method("PUBLISH"))
{
if(is_method("PUBLISH")) {
handle_publish();
t_release();
} else if(is_method("SUBSCRIBE")) {
@ -706,21 +712,19 @@ route[PRESENCE] {
#!endif
# if presence enabled, this part will not be executed
if (is_method("PUBLISH") || $rU==$null)
{
if (is_method("PUBLISH") || $rU==$null) {
sl_send_reply("404", "Not here");
exit;
}
return;
}
# Authentication route
# IP authorization and user uthentication
route[AUTH] {
#!ifdef WITH_AUTH
#!ifdef WITH_IPAUTH
if((!is_method("REGISTER")) && allow_source_address())
{
if((!is_method("REGISTER")) && allow_source_address()) {
# source IP allowed
return;
}
@ -739,8 +743,7 @@ route[AUTH] {
}
# if caller is not local subscriber, then check if it calls
# a local destination, otherwise deny, not an open relay here
if (from_uri!=myself && uri!=myself)
{
if (from_uri!=myself && uri!=myself) {
sl_send_reply("403","Not relaying");
exit;
}
@ -749,7 +752,7 @@ route[AUTH] {
return;
}
# Caller NAT detection route
# Caller NAT detection
route[NATDETECT] {
#!ifdef WITH_NAT
force_rport();
@ -766,7 +769,7 @@ route[NATDETECT] {
return;
}
# RTPProxy control
# RTPProxy control and singaling updates for NAT traversal
route[NATMANAGE] {
#!ifdef WITH_NAT
if (is_request()) {
@ -810,11 +813,11 @@ route[DLGURI] {
# Routing to foreign domains
route[SIPOUT] {
if (!uri==myself)
{
append_hf("P-hint: outbound\r\n");
route(RELAY);
}
if (uri==myself) return;
append_hf("P-hint: outbound\r\n");
route(RELAY);
exit;
}
# PSTN GW routing
@ -871,7 +874,7 @@ route[XMLRPC] {
}
#!endif
# route to voicemail server
# Routing to voicemail server
route[TOVOICEMAIL] {
#!ifdef WITH_VOICEMAIL
if(!is_method("INVITE|SUBSCRIBE"))
@ -900,20 +903,20 @@ route[TOVOICEMAIL] {
return;
}
# manage outgoing branches
# Manage outgoing branches
branch_route[MANAGE_BRANCH] {
xdbg("new branch [$T_branch_idx] to $ru\n");
route(NATMANAGE);
}
# manage incoming replies
# Manage incoming replies
onreply_route[MANAGE_REPLY] {
xdbg("incoming reply\n");
if(status=~"[12][0-9][0-9]")
route(NATMANAGE);
}
# manage failure routing cases
# Manage failure routing cases
failure_route[MANAGE_FAILURE] {
route(NATMANAGE);

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

Loading…
Cancel
Save