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 #########
- ### LOG Levels: 3=DBG, 2=INFO, 1=NOTICE, 0=WARN, -1=ERR
- debug=3
- log_stderror=no
- memdbg=5
- memlog=5
- log_facility=LOG_LOCAL0
- fork=yes
- children=8
- /* uncomment the next line to disable TCP (default on) */
- disable_tcp=yes
- /* uncomment the next line to disable the auto discovery of local aliases
- based on reverse DNS on IPs (default on) */
- auto_aliases=no
- /* add local domain aliases */
- #alias=50.0.0.1
- /* uncomment and configure the following line if you want Kamailio to
- bind on a specific interface/port/proto (default bind on all available) */
- #listen=udp:50.0.0.1:5060 advertise 194.190.8.171:5060
- #listen=udp:194.190.8.171:5060 advertise 50.0.0.1:5060
- listen=udp:194.190.8.171
- listen=udp:50.0.0.1
- dns=no
- rev_dns=no
- check_via=yes
- /* port to listen to
- * - can be specified more than once if needed to listen on many ports */
- port=5060
- mhomed=1
- # 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=300
- ####### Custom Parameters #########
- asterisk.bindip = "50.0.0.10" desc "Asterisk IP Address"
- asterisk.bindport = "5060" desc "Asterisk Port"
- kamailio.bindip = "50.0.0.1" desc "Kamailio IP Address"
- kamailio.bindport = "5060" desc "Kamailio Port"
- ####### Modules Section ########
- # set paths to location of modules (to sources or installation folders)
- mpath="/usr/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 "dialog.so"
- modparam("dialog", "enable_stats", 1)
- modparam("dialog", "dlg_flag", 4)
- #loadmodule "path.so"
- # -- path params --
- #modparam("path", "use_received", 1)
- #loadmodule "topoh.so"
- #modparam("topoh", "mask_key", "balalayka")
- #modparam("topoh", "mask_ip", "50.0.0.1")
- # ----------------- 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)
- modparam("tm", "reparse_on_dns_failover", 0)
- # ----- rr params -----
- # add value to ;lr param to cope with most of the UAs
- modparam("rr", "enable_full_lr", 1)
- # do not append from tag to the RR (no need for this script)
- modparam("rr", "append_fromtag", 1)
- # ----- acc params -----
- /* what special events should be accounted ? */
- modparam("acc", "early_media", 0)
- modparam("acc", "report_ack", 0)
- modparam("acc", "report_cancels", 0)
- /* by default ww do not adjust the direct of the sequential requests.
- if you enable this parameter, be sure the enable "append_fromtag"
- in "rr" module */
- modparam("acc", "detect_direction", 0)
- /* account triggers (flags) */
- modparam("acc", "log_flag", FLT_ACC)
- modparam("acc", "log_missed_flag", FLT_ACCMISSED)
- modparam("acc", "log_extra",
- "src_user=$fU;src_domain=$fd;src_ip=$si;"
- "dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")
- modparam("acc", "failed_transaction_flag", FLT_ACCFAILED)
- # ----- rtpproxy params -----
- 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@194.190.8.171")
- # params needed for NAT traversal in other modules
- modparam("nathelper|registrar", "received_avp", "$avp(RECEIVED)")
- modparam("usrloc", "nat_bflag", FLB_NATB)
- ####################################################################################################
- #################### in the end of the route u meet UCHIBUCHI. just ignore him. ####################
- ####################################################################################################
- # Main SIP request routing logic
- # - processing of any incoming SIP request starts with this route
- # - note: this is the same as route { ... }
- route {
- # per request initial checks
- route(REQINIT);
- # NAT detection
- route(NATDETECT);
- # CANCEL processing
- if (is_method("CANCEL"))
- {
- if (t_check_trans()) {
- route(RELAY);
- }
- exit;
- }
- # handle requests within SIP dialogs
- route(WITHINDLG);
- ### only initial requests (no To tag)
- t_check_trans();
- # record routing for dialog forming requests (in case they are routed)
- # - remove preloaded route headers
- remove_hf("Route");
- if (is_method("INVITE|SUBSCRIBE"))
- record_route();
- # account only INVITEs
- if (is_method("INVITE"))
- {
- setflag(FLT_ACC); # do accounting
- }
- # dispatch requests to foreign domains
- route(SIPOUT);
- ### requests for my local domains
- # handle presence related requests
- route(PRESENCE);
- # handle registrations
- route(REGISTRAR);
- if ($rU==$null)
- {
- # request with no Username in RURI
- sl_send_reply("484","Address Incomplete");
- exit;
- }
- # dispatch destinations to PSTN
- route(PSTN);
- # user location service
- route(LOCATION);
- }
- ####################################################################################################
- #################### in the end of the route u meet UCHIBUCHI. just ignore him. ####################
- ####################################################################################################
- # Per SIP request initial checks
- route[REQINIT] {
- if (!mf_process_maxfwd_header("10")) {
- sl_send_reply("483","Too Many Hops");
- xlog("483 Too Many Hops to $du\n");
- exit;
- }
- if(!sanity_check("1511", "7"))
- {
- xlog("Malformed SIP message from $si:$sp\n");
- exit;
- }
- }
- ####################################################################################################
- #################### in the end of the route u meet UCHIBUCHI. just ignore him. ####################
- ####################################################################################################
- # Caller NAT detection route
- route[NATDETECT] {
- force_rport();
- xlog("L_NOTICE","--------------------- FORCE RPORT --------------------------------------\n");
- if (nat_uac_test("19")) {
- if (is_method("REGISTER")) {
- # forward("50.0.0.10");
- # xlog("L_NOTICE","--------------------- NATDETECT REGISTER FWD --------------------------------------\n");
- xlog("L_NOTICE","--------------------- BEFORE fix_nated_register TO_URI: $dlg(to_uri) FROM_URI: $dlg(from_uri) --------------------------------------\n");
- fix_nated_register();
- xlog("L_NOTICE","--------------------- fix_nated_register TO_URI: $dlg(to_uri) FROM_URI: $dlg(from_uri) --------------------------------------\n");
- } else {
- if(is_first_hop())
- xlog("L_NOTICE","--------------------- BEFORE set_contact_alias $dlg(to_contact) --------------------------------------\n");
- set_contact_alias();
- xlog("L_NOTICE","--------------------- set_contact_alias $dlg(to_contact) --------------------------------------\n");
- }
- xlog("L_NOTICE","--------------------- BEFORE setflag(FLT_NATS) flags: $mf --------------------------------------\n");
- setflag(FLT_NATS);
- xlog("L_NOTICE","--------------------- setflag(FLT_NATS) flags: $mf --------------------------------------\n");
- }
- return;
- }
- ####################################################################################################
- #################### in the end of the route u meet UCHIBUCHI. just ignore him. ####################
- ####################################################################################################
- # Handle requests within SIP dialogs
- route[WITHINDLG] {
- if (has_totag()) {
- xlog("L_NOTICE","--------------------- chech to tag: $tt $dlg(to_tag) --------------------------------------\n");
- # 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 ...
- xlog("L_NOTICE","--------------------- FLT_ACC setflag check: $tt --------------------------------------\n");
- setflag(FLT_ACCFAILED); # ... even if the transaction fails
- xlog("L_NOTICE","--------------------- FLT_ACCFAILED setflag check: $tt --------------------------------------\n");
- }
- 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.
- xlog("L_NOTICE","--------------------- BEFORE rr TO_RS: $dlg(to_rs) FROM_RS: $dlg(from_rs) --------------------------------------\n");
- record_route();
- xlog("L_NOTICE","--------------------- rr TO_RS: $dlg(to_rs) FROM_RS: $dlg(from_rs) --------------------------------------\n");
- }
- 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
- route(RELAY);
- exit;
- } else {
- # ACK without matching transaction ... ignore and discard
- exit;
- }
- }
- sl_send_reply("404","Not here");
- }
- exit;
- }
- }
- ####################################################################################################
- #################### in the end of the route u meet UCHIBUCHI. just ignore him. ####################
- ####################################################################################################
- # Routing to foreign domains
- route[SIPOUT] {
- if (!uri==myself)
- {
- append_hf("P-hint: outbound\r\n");
- route(RELAY);
- }
- }
- ####################################################################################################
- #################### in the end of the route u meet UCHIBUCHI. just ignore him. ####################
- ####################################################################################################
- # Presence server route
- route[PRESENCE] {
- if(!is_method("PUBLISH|SUBSCRIBE"))
- return;
- if(is_method("SUBSCRIBE") && $hdr(Event)=="message-summary") {
- forward("50.0.0.10");
- xlog("L_NOTICE","--------------------- PRESENSE FWD --------------------------------------\n");
- # route(TOVOICEMAIL);
- # returns here if no voicemail server is configured
- # sl_send_reply("404", "No voicemail service");
- exit;
- }
- # if presence enabled, this part will not be executed
- if (is_method("PUBLISH") || $rU==$null)
- {
- sl_send_reply("404", "Not here");
- exit;
- }
- return;
- }
- ####################################################################################################
- #################### in the end of the route u meet UCHIBUCHI. just ignore him. ####################
- ####################################################################################################
- # Handle SIP registrations
- route[REGISTRAR] {
- if (is_method("REGISTER"))
- {
- forward("50.0.0.10");
- xlog("L_NOTICE","--------------------- REGISTER FWD --------------------------------------\n");
- if(isflagset(FLT_NATS))
- {
- # setbflag(FLB_NATB);
- # # uncomment next line to do SIP NAT pinging
- # xlog("L_NOTICE","--------------------- BEFORE NATSIPPING setflag check: $tt --------------------------------------\n");
- setbflag(FLB_NATSIPPING);
- xlog("L_NOTICE","--------------------- NATSIPPING setflag check: $tt --------------------------------------\n");
- }
- if (!save("location"))
- sl_reply_error();
- exit;
- }
- }
- #route[REGISTRAR] {
- # if (is_method("REGISTER"))
- # {
- # forward("50.0.0.10");
- # save("sip:50.0.0.10","0x02");
- # t_relay_to_udp("50.0.0.10", "5060");
- # exit;
- # }
- #}
- ####################################################################################################
- #################### in the end of the route u meet UCHIBUCHI. just ignore him. ####################
- ####################################################################################################
- # PSTN GW routing
- route[PSTN] {
- return;
- }
- ####################################################################################################
- #################### in the end of the route u meet UCHIBUCHI. just ignore him. ####################
- ####################################################################################################
- # USER location service
- route[LOCATION] {
- $avp(oexten) = $rU;
- if (!lookup("location")) {
- $var(rc) = $rc;
- route(TOVOICEMAIL);
- t_newtran();
- switch ($var(rc)) {
- case -1:
- case -3:
- send_reply("404", "Not Found");
- exit;
- case -2:
- send_reply("405", "Method Not Allowed");
- exit;
- }
- }
- # when routing via usrloc, log the missed calls also
- if (is_method("INVITE"))
- {
- xlog("L_NOTICE","--------------------- NEED TO REMOVE setflag check: $tt -------------------------------------\n");
- setflag(FLT_ACCMISSED);
- xlog("L_NOTICE","--------------------- NEED TO REMOVE setflag check: $tt --------------------------------------\n");
- forward("50.0.0.10");
- xlog("L_NOTICE","--------------------- INVITE FWD --------------------------------------\n");
- }
- route(RELAY);
- exit;
- }
- ####################################################################################################
- #################### in the end of the route u meet UCHIBUCHI. just ignore him. ####################
- ####################################################################################################
- route[RELAY] {
- # enable additional event routes for forwarded requests
- # - serial forking, RTP relaying handling, a.s.o.
- if (is_method("INVITE|BYE|SUBSCRIBE|UPDATE")) {
- if(!t_is_set("branch_route")) t_on_branch("MANAGE_BRANCH");
- }
- if (is_method("INVITE|SUBSCRIBE|UPDATE")) {
- if(!t_is_set("onreply_route")) t_on_reply("MANAGE_REPLY");
- }
- if (is_method("INVITE")) {
- if(!t_is_set("failure_route")) t_on_failure("MANAGE_FAILURE");
- }
- if (!t_relay()) {
- sl_reply_error();
- }
- exit;
- }
- # manage outgoing branches
- branch_route[MANAGE_BRANCH] {
- xdbg("new branch [$T_branch_idx] to $ru\n");
- xlog("L_NOTICE","new branch [$T_branch_idx] to $ru\n");
- route(NATMANAGE);
- }
- # manage incoming replies
- onreply_route[MANAGE_REPLY] {
- xdbg("incoming reply\n");
- xlog("L_NOTICE","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;
- }
- }
- ####################################################################################################
- #################### in the end of the route u meet UCHIBUCHI. just ignore him. ####################
- ####################################################################################################
- # route to voicemail server
- route[TOVOICEMAIL] {
- return;
- }
- ####################################################################################################
- #################### in the end of the route u meet UCHIBUCHI. just ignore him. ####################
- ####################################################################################################
- # URI update for dialog requests
- route[DLGURI] {
- if(!isdsturiset()) {
- xlog("L_NOTICE","--------------------- BEFORE HANDLE RURI ALIAS TO_URI: $dlg(to_uri) FROM_URI: $dlg(from_uri) --------------------------------------\n");
- handle_ruri_alias();
- xlog("L_NOTICE","--------------------- HANDLE RURI ALIAS TO_URI: $dlg(to_uri) FROM_URI: $dlg(from_uri) --------------------------------------\n");
- }
- return;
- }
- ####################################################################################################
- #################### in the end of the route u meet UCHIBUCHI. just ignore him. ####################
- ####################################################################################################
- # 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()) {
- if(t_is_branch_route()) {
- add_rr_param(";nat=yes");
- }
- }
- }
- if (is_reply()) {
- if(isbflagset(FLB_NATB)) {
- if(is_first_hop())
- set_contact_alias();
- }
- }
- return;
- }
- ####################################################################################################
- #################### in the end of the route u meet UCHIBUCHI. just ignore him. ####################
- ####################################################################################################
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement