Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ####### Global Parameters #########
- debug=2
- log_stderror=no
- memdbg=5
- memlog=5
- log_facility=LOG_LOCAL0
- fork=yes
- children=4
- port=5060
- # - 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
- ####### Modules Section ########
- # set paths to location of modules
- 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 "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 -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
- route {
- if ( !mf_process_maxfwd_header("10") )
- {
- sl_send_reply("483","To Many Hops");
- exit;
- }
- # NAT detection
- route(NAT);
- # 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");
- if(!t_relay())
- {
- sl_reply_error();
- 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
- }
- 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");
- }
- exit;
- }
- }
- route[RELAY] {
- if (check_route_param("nat=yes")) {
- setbflag(FLB_NATB);
- }
- if (isflagset(FLT_NATS) || isbflagset(FLB_NATB)) {
- route(RTPPROXY);
- }
- if (!t_relay()) {
- sl_reply_error();
- }
- exit;
- }
- # RTPProxy control
- route[RTPPROXY] {
- if (is_method("BYE")) {
- unforce_rtp_proxy();
- } else if (is_method("INVITE")){
- force_rtp_proxy();
- }
- if (!has_totag()) add_rr_param(";nat=yes");
- return;
- }
- # Caller NAT detection route
- route[NAT] {
- force_rport();
- if (nat_uac_test("19")) {
- if (method=="REGISTER") {
- fix_nated_register();
- } else {
- fix_nated_contact();
- }
- setflag(FLT_NATS);
- }
- return;
- }
- # 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