You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kamailio/misc/examples/pkg/sip-router-basic.cfg

191 lines
4.7 KiB

#
# $Id$
#
# This a very basic config file w/ aliases and a named route but
# w/o authentication, accounting, database, multi-domain support etc.
# Please refer to sip-router.cfg for a more complete example
#
# Direct your questions about this file to: <sr-users@lists.kamailio.org>.
#
# For more information about the various parameters, functions and statements
# try http://sip-router.org/wiki/ .
#
#------------ Features -----------------------------------------------
# Several extra features can be enabled by adding #!define WITH_<FEATURE>
# statements to the config file, or by starting sr/ser with -A WITH_<FEATURE>.
# E.g.: ser -f /etc/ser/sip-router-basic.cfg -A WITH_TLS
# run in debug mode:
##!define WITH_DEBUG
# enable tls support:
##!define WITH_TLS
# started from compile directory (not installed)
##!define LOCAL_TEST_RUN
# ----------- global configuration parameters ------------------------
#!ifdef WITH_DEBUG
debug=5
log_stderror=yes
fork=no
#!else
debug=2 # debug level (cmd line: -dddddddddd)
#!endif
#memdbg=10 # memory debug message level
#memlog=10 # memory statistics log level
#log_facility=LOG_LOCAL0 # sets the facility used for logging (see syslog(3))
check_via=no # (cmd. line: -v)
dns=no # (cmd. line: -r)
rev_dns=no # (cmd. line: -R)
#port=5060
#children=4
#user=sip-router
#group=sip-router
#disable_core=yes #disables core dumping
#open_fd_limit=1024 # sets the open file descriptors limit
#mhomed=yes # useful for multihomed hosts, small performance penalty
#disable_tcp=yes
#tcp_accept_aliases=yes # accepts the tcp alias via option (see NEWS)
sip_warning=yes
#!ifdef WITH_TLS
enable_tls=yes
#!endif
#
# ------------------ module loading ----------------------------------
#!ifdef LOCAL_TEST_RUN
loadpath "modules:modules_s"
#!else
loadpath "/usr/lib/sip-router/modules:/usr/lib/sip-router/modules_s"
#!endif
loadmodule "tm"
loadmodule "sl"
loadmodule "rr"
loadmodule "textops"
loadmodule "maxfwd"
loadmodule "usrloc"
loadmodule "registrar"
loadmodule "ctl"
loadmodule "cfg_rpc"
#!ifdef WITH_TLS
loadmodule "tls"
#!endif
# ----------------- setting module-specific parameters ---------------
# -- usrloc params --
modparam("usrloc", "db_mode", 0)
# -- rr params --
# add value to ;lr param to make some broken UAs happy
modparam("rr", "enable_full_lr", 1)
# ctl params
# by default ctl listens on unixs:/tmp/sip-router_ctl if no other address is
# specified in modparams; this is also the default for sercmd
modparam("ctl", "binrpc", "unixs:/tmp/ser_ctl")
# listen on the "standard" fifo for backward compatibility
modparam("ctl", "fifo", "fifo:/tmp/ser_fifo")
# listen on tcp, localhost
modparam("ctl", "binrpc", "tcp:127.0.0.1:2046")
#!ifdef WITH_TLS
modparam("tls", "verify_certificate", 0)
#!ifdef LOCAL_TEST_RUN
modparam("tls", "certificate", "./modules/tls/sip-router-selfsigned.pem")
modparam("tls", "private_key", "./modules/tls/sip-router-selfsigned.key")
#separate TLS config file
#modparam("tls", "config", "./modules/tls/tls.cfg")
#!else
modparam("tls", "certificate", "ser-selfsigned.pem")
modparam("tls", "private_key", "ser-selfsigned.key")
#separate TLS config file
#modparam("tls", "config", "tls.cfg")
#!endif
#!endif
#!endif
# ------------------------- request routing logic -------------------
# main routing logic
route{
# initial sanity checks -- messages with
# max_forwards==0, or excessively long requests
if (!mf_process_maxfwd_header("10")) {
sl_reply("483", "Too Many Hops");
break;
}
if (msg:len >= 4096 ) {
sl_reply("513", "Message too big");
break;
}
# we record-route all messages -- to make sure that
# subsequent messages will go through our proxy; that's
# particularly good if upstream and downstream entities
# use different transport protocol
if (!method=="REGISTER") record_route();
# subsequent messages within a dialog should take the
# path determined by record-routing
if (loose_route()) {
# mark routing logic in request
append_hf("P-hint: rr-enforced\r\n");
route(FORWARD);
break;
}
if (!uri==myself) {
# mark routing logic in request
append_hf("P-hint: outbound\r\n");
route(FORWARD);
break;
}
# if the request is for other domain use UsrLoc
# (in case, it does not work, use the following command
# with proper names and addresses in it)
if (uri==myself) {
if (method=="REGISTER") {
save_contacts("location");
break;
}
# native SIP destinations are handled using our USRLOC DB
if (!lookup_contacts("location")) {
sl_reply("404", "Not Found");
break;
}
append_hf("P-hint: usrloc applied\r\n");
}
route(FORWARD);
}
route[FORWARD]
{
# send it out now; use stateful forwarding as it works reliably
# even for UDP2TCP
if (!t_relay()) {
sl_reply_error();
}
}