Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ####### Defined Values #########
- # - flags
- # FLT_ - per transaction (message) flags
- # FLB_ - per branch flags
- #!define FLT_ACC 1
- #!define FLT_ACCMISSED 2
- #!define FLT_ACCFAILED 3
- #!define FLT_NATS 5
- #!define FLB_NATB 6
- #!define FLB_NATSIPPING 7
- ####### Global Parameters #########
- debug=2
- log_stderror=no
- memdbg=5
- memlog=5
- log_facility=LOG_LOCAL0
- fork=yes
- children=4
- /* port to listen to
- * - can be specified more than once if needed to listen on many ports */
- port=5060
- # life time of TCP connection when there is no traffic
- # - a bit higher than registration expires to cope with UA behind NAT
- tcp_connection_lifetime=3605
- ####### Modules Section ########
- # set paths to location of modules (to sources or installation folders)
- mpath="/usr/local/lib64/kamailio/modules_k/:/usr/local/lib64/kamailio/modules/"
- loadmodule "mi_fifo.so"
- loadmodule "kex.so"
- loadmodule "tm.so"
- loadmodule "tmx.so"
- loadmodule "sl.so"
- loadmodule "rr.so"
- loadmodule "pv.so"
- loadmodule "maxfwd.so"
- loadmodule "usrloc.so"
- loadmodule "registrar.so"
- loadmodule "textops.so"
- loadmodule "siputils.so"
- loadmodule "xlog.so"
- loadmodule "sanity.so"
- loadmodule "ctl.so"
- loadmodule "cfg_rpc.so"
- loadmodule "mi_rpc.so"
- loadmodule "acc.so"
- loadmodule "nathelper.so"
- loadmodule "rtpproxy.so"
- loadmodule "dispatcher.so"
- # ----------------- setting module-specific parameters ---------------
- # ----- mi_fifo params -----
- modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")
- # ----- tm params -----
- # auto-discard branches from previous serial forking leg
- modparam("tm", "failure_reply_mode", 3)
- # default retransmission timeout: 30sec
- modparam("tm", "fr_timer", 30000)
- # default invite retransmission timeout after 1xx: 120sec
- modparam("tm", "fr_inv_timer", 120000)
- # ----- rtpproxy params -----
- # rtpproxy -u rtpproxy:rtpproxy -l _your_public_ip_ -s udp:localhost:7722
- modparam("rtpproxy", "rtpproxy_sock", "udp:127.0.0.1:7722")
- # ----- nathelper params -----
- modparam("nathelper", "natping_interval", 30)
- modparam("nathelper", "ping_nated_only", 1)
- modparam("nathelper", "sipping_bflag", FLB_NATSIPPING)
- modparam("nathelper", "sipping_from", "sip:pinger@kamailio.org")
- # params needed for NAT traversal in other modules
- modparam("nathelper|registrar", "received_avp", "$avp(RECEIVED)")
- modparam("usrloc", "nat_bflag", FLB_NATB)
- # -- dispatcher params -----
- modparam("dispatcher", "list_file", "/usr/local/etc/kamailio/dispatcher.list")
- modparam("dispatcher", "flags", 2)
- modparam("dispatcher", "dst_avp", "$avp(AVP_DST)")
- modparam("dispatcher", "grp_avp", "$avp(AVP_GRP)")
- modparam("dispatcher", "cnt_avp", "$avp(AVP_CNT)")
- ####### Routing Logic ########
- # Main SIP request routing logic
- # - processing of any incoming SIP request starts with this route
- # - note: this is the same as route { ... }
- request_route {
- # per request initial checks
- route(REQINIT);
- # NAT detection
- route(NATDETECT);
- # handle requests within SIP dialogs
- route(WITHINDLG);
- # select from first dst group by round-robin
- if (!ds_select_dst("1", "4"))
- {
- sl_send_reply("500", "No destination available");
- exit;
- }
- t_on_failure("RTF_DISPATCH");
- route(RELAY);
- }
- route[RELAY] {
- # enable additional event routes for forwarded requests
- # - serial forking, RTP relaying handling, a.s.o.
- if (is_method("INVITE|SUBSCRIBE")) {
- t_on_branch("MANAGE_BRANCH");
- t_on_reply("MANAGE_REPLY");
- }
- if (is_method("INVITE")) {
- t_on_failure("MANAGE_FAILURE");
- }
- if (!t_relay()) {
- sl_reply_error();
- }
- exit;
- }
- # Per SIP request initial checks
- route[REQINIT] {
- if (!mf_process_maxfwd_header("10")) {
- sl_send_reply("483","Too Many Hops");
- exit;
- }
- if(!sanity_check("1511", "7"))
- {
- xlog("Malformed SIP message from $si:$sp\n");
- exit;
- }
- }
- # 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()) {
- if (is_method("BYE")) {
- setflag(FLT_ACC); # do accounting ...
- setflag(FLT_ACCFAILED); # ... even if the transaction fails
- }
- if ( is_method("ACK") ) {
- # ACK is forwarded statelessy
- route(NATMANAGE);
- }
- route(RELAY);
- } 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
- t_relay();
- exit;
- } else {
- # ACK without matching transaction ... ignore and discard
- exit;
- }
- }
- sl_send_reply("404","Not here");
- }
- exit;
- }
- }
- # Caller NAT detection route
- route[NATDETECT] {
- force_rport();
- if (nat_uac_test("19")) {
- if (is_method("REGISTER")) {
- fix_nated_register();
- } else {
- fix_nated_contact();
- }
- setflag(FLT_NATS);
- }
- return;
- }
- # RTPProxy control
- route[NATMANAGE] {
- if (is_request()) {
- if(has_totag()) {
- if(check_route_param("nat=yes")) {
- setbflag(FLB_NATB);
- }
- }
- }
- if (!(isflagset(FLT_NATS) || isbflagset(FLB_NATB)))
- return;
- rtpproxy_manage();
- if (is_request()) {
- if (!has_totag()) {
- add_rr_param(";nat=yes");
- }
- }
- if (is_reply()) {
- if(isbflagset(FLB_NATB)) {
- fix_nated_contact();
- }
- }
- return;
- }
- # manage outgoing branches
- branch_route[MANAGE_BRANCH] {
- xdbg("new branch [$T_branch_idx] to $ru\n");
- route(NATMANAGE);
- }
- # manage incoming replies
- onreply_route[MANAGE_REPLY] {
- xdbg("incoming reply\n");
- if(status=~"[12][0-9][0-9]")
- route(NATMANAGE);
- }
- # manage failure routing cases
- failure_route[MANAGE_FAILURE] {
- route(NATMANAGE);
- if (t_is_canceled()) {
- exit;
- }
- }
- # dispatcher failure routing block
- failure_route[RTF_DISPATCH] {
- if (t_is_canceled()) {
- exit;
- }
- # select next destination only for local timeout
- if (t_branch_timeout() && !t_branch_replied())
- {
- if(ds_next_dst())
- {
- t_on_failure("RTF_DISPATCH");
- t_relay();
- exit;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement