[OpenSER-Users] problem with sipwise config

Alexander J. Perovich alexanderjp at thinksimplicity.net
Sun Aug 5 17:28:18 CEST 2007


Hello,

 

I am having issues with the openser.cfg  from sipwise.

 

The CFC does not forward the calls when set in the database.  Also, I am
using the full uri as the UUID for example UUID can be
4163334444 at proxy.domain.net.

 

I have modified the config for radius authentication as well.

 

Here is what I am trying to do:

 

1.       Radius Authentication on register and PSTN calling

2.       CFC based on user preferences in database

3.       If user offline forward the asterisk vmail server

4.       If user cancels call it will forward to vmail server

 

Here is the config I currently have:

 

########################################################################

# This configuration is autogenerated by sip:wizard

# (http://www.sipwise.com/wizard) on Tue Jun 26 22:47:33 +0200 2007

# for OpenSER 1.2

#

# Copyright (C) 2007 Sipwise (support at sipwise.com)

########################################################################

 

########################################################################

# By obtaining, using, and/or copying this configuration and/or its

# associated documentation, you agree that you have read, understood,

# and will comply with the Terms of Usage provided at

# http://www.sipwise.com/news/?page_id=6 as well as the following

# additions:

#

# Permission to use, copy, modify, and distribute this configuration and

# its associated documentation for any purpose and without fee is hereby

# granted, provided that the above copyright notice appears in all

# copies, and that both that copyright notice and this permission notice

# appear in supporting documentation, and that the name of Sipwise or

# the author will not be used in advertising or publicity pertaining to

# distribution of the configuration without specific, written prior

# permission.

########################################################################

 

########################################################################

# Before using this configuration, read the following prerequisites in

# order to gain the designated functionallity:

#

# base:

#    You have to insert all locally served domains (i.e. 

#    "openserctl domain add your.domain.com").

#    

# nat-mediaproxy:

#    You have to install mediaproxy 

#    (http://mediaproxy.ag-projects.com/) for relaying RTP traffic.

#    

# usr-preferences:

#    This feature relies on UUID-based provisioning. Thus, you have 

#    to add the uuid-column to the subscriber table ("alter table 

#    subscriber add column uuid varchar(64);") and populate it with a 

#    UUID (unique user identifier) per user, for example an 

#    auto-incremented id.

#    

# offnet-incoming-sip:

#    You have to populate the "trusted"-table with rules for 

#    allowed peering hosts (i.e. src_ip="1.2.3.4", proto="udp", 

#    from_pattern="^sip:.*@domain.of.peering.host$", tag="1234"). If the


#    feature "usr-preferences" is selected, the tag-value is used as 

#    caller-uuid for such calls.

#    

# offnet-pstn:

#    You have to add a routing entry for lcr (i.e. "openserctl  lcr 

#    addroute '' '' 1 1"). Additionally, you have to add your gateways 

#    (i.e. "openserctl lcr addgw my-test-gw 1.2.3.4 5060 sip udp 1").

#    

# cfu:

#    You have to provision the call-forward-unconditional as full 

#    SIP URI (AVP cfu as type 0) for each user in the usr_preferences 

#    table (i.e. uuid='1234', username='', domain='', attribute='cfu', 

#    type=0, value='sip:foo at otherdomain.com').  Forwards to another user


#    in the same domain or to other domains are possible.

#    

# cfc:

#    You have to provision the call-forward-conditional as full SIP 

#    URI (AVP cfc as type 0) for each user in the usr_preferences table 

#    (i.e. uuid='1234', username='', domain='', attribute='cfc', type=0,


#    value='sip:foo at otherdomain.com').  Forwards to another user in the 

#    same domain or to other domains are possible.

#    

# user-aliases:

#    You have to add aliases for your users (i.e. "openserctl alias 

#    add 01234567 sip:bob at yourdomain.com" for usrloc-based aliases or 

#    make entries into "dbaliases" table for db-based aliases)

#    

# cli:

#    You have to provision the CLI as full SIP URI (AVP cli as type 

#    0) for each user in the usr_preferences table (i.e. uuid='1234', 

#    username='', domain='', attribute='cli', type=0, 

#    value='sip:01234567 at yourdomain.com').

#    

# clir:

#    You have to provision '1' to enable CLIR and '0' to disable it 

#    (AVP clir as type 1) for each user in the usr_preferences table 

#    (i.e. uuid='1234', username='', domain='', attribute='clir', 

#    type=1, value='1').

#    

# acc-db:

#    You have to add the columns "src_leg" and "dst_leg" to your 

#    acc-table ("alter table acc add column src_leg varchar(128); alter 

#    table acc add column dst_leg varchar(128);").

#    

########################################################################

 

########################################################################

# Configuration 'sip:wizard - Tue Jun 26 22:47:33 +0200 2007'

########################################################################

 

listen = udp::x.x.x.x:5060

 

mpath = "/usr/local/lib/openser/modules"

children = 8

debug = 3

fork = yes

group = "openser"

user = "openser"

disable_tcp = no

log_facility = LOG_DAEMON

log_stderror = yes

tcp_children = 4

mhomed = no

server_signature = yes

sock_group = "openser"

sock_mode = 0600

sock_user = "openser"

unix_sock = "/tmp/openser.sock"

unix_sock_children = 1

reply_to_via = no

sip_warning = no

check_via = no

dns = no

rev_dns = no

disable_core_dump = no

dns_try_ipv6 = yes

dns_use_search_list = yes

 

loadmodule "usrloc.so"

modparam("usrloc", "user_column", "username")

modparam("usrloc", "domain_column", "domain")

modparam("usrloc", "contact_column", "contact")

modparam("usrloc", "expires_column", "expires")

modparam("usrloc", "q_column", "q")

modparam("usrloc", "callid_column", "callid")

modparam("usrloc", "cseq_column", "cseq")

modparam("usrloc", "methods_column", "methods")

modparam("usrloc", "flags_column", "flags")

modparam("usrloc", "user_agent_column", "user_agent")

modparam("usrloc", "received_column", "received")

modparam("usrloc", "socket_column", "socket")

modparam("usrloc", "use_domain", 0)

modparam("usrloc", "desc_time_order", 0)

modparam("usrloc", "timer_interval", 60)

modparam("usrloc", "db_url", "mysql://openser:xxxx@x.x.x.x/openser")

modparam("usrloc", "db_mode", 1)

modparam("usrloc", "matching_mode", 0)

modparam("usrloc", "cseq_delay", 20)

modparam("usrloc", "nat_bflag", 6)

 

loadmodule "registrar.so"

modparam("registrar", "default_expires", 3600)

modparam("registrar", "min_expires", 60)

modparam("registrar", "max_expires", 0)

modparam("registrar", "default_q", 0)

modparam("registrar", "append_branches", 1)

modparam("registrar", "case_sensitive", 0)

modparam("registrar", "received_param", "received")

modparam("registrar", "max_contacts", 0)

modparam("registrar", "retry_after", 0)

modparam("registrar", "method_filtering", 0)

modparam("registrar", "path_mode", 2)

modparam("registrar", "path_use_received", 0)

modparam("registrar", "received_avp", "$avp(i:801)")

 

loadmodule "rr.so"

modparam("rr", "enable_full_lr", 0)

modparam("rr", "append_fromtag", 1)

modparam("rr", "enable_double_rr", 1)

modparam("rr", "add_username", 0)

 

loadmodule "tm.so"

modparam("tm", "fr_timer", 30)

modparam("tm", "fr_inv_timer", 120)

modparam("tm", "wt_timer", 5)

modparam("tm", "delete_timer", 2)

modparam("tm", "noisy_ctimer", 0)

modparam("tm", "ruri_matching", 1)

modparam("tm", "via1_matching", 1)

modparam("tm", "unix_tx_timeout", 2)

modparam("tm", "restart_fr_on_each_reply", 1)

modparam("tm", "pass_provisional_replies", 0)

 

loadmodule "xlog.so"

modparam("xlog", "buf_size", 4096)

modparam("xlog", "force_color", 0)

 

loadmodule "mi_fifo.so"

modparam("mi_fifo", "fifo_name", "/tmp/openser_fifo")

modparam("mi_fifo", "fifo_mode", 0660)

modparam("mi_fifo", "fifo_group", "openser")

modparam("mi_fifo", "fifo_user", "openser")

modparam("mi_fifo", "reply_dir", "/tmp/")

modparam("mi_fifo", "reply_indent", "\t")

 

loadmodule "domain.so"

modparam("domain", "db_url", "mysql://openser:xxxx@x.x.x.x/openser")

modparam("domain", "db_mode", 1)

modparam("domain", "domain_table", "domain")

modparam("domain", "domain_col", "domain")

 

loadmodule "nathelper.so"

modparam("nathelper", "natping_interval", 0)

modparam("nathelper", "ping_nated_only", 1)

modparam("nathelper", "rtpproxy_sock", "unix:/var/run/rtpproxy.sock")

modparam("nathelper", "rtpproxy_disable", 1)

modparam("nathelper", "rtpproxy_disable_tout", 60)

modparam("nathelper", "rtpproxy_tout", 1)

modparam("nathelper", "rtpproxy_retr", 5)

modparam("nathelper", "sipping_method", "OPTIONS")

modparam("nathelper", "received_avp", "$avp(i:801)")

 

loadmodule "textops.so"

 

loadmodule "mediaproxy.so"

modparam("mediaproxy", "mediaproxy_socket",
"/var/run/proxydispatcher.sock")

modparam("mediaproxy", "sip_asymmetrics",
"/etc/openser/sip-asymmetric-clients")

modparam("mediaproxy", "rtp_asymmetrics",
"/etc/openser/rtp-asymmetric-clients")

modparam("mediaproxy", "natping_interval", 60)

 

loadmodule "uri.so"

 

loadmodule "sl.so"

modparam("sl", "enable_stats", 1)

 

loadmodule "maxfwd.so"

modparam("maxfwd", "max_limit", 256)

 

loadmodule "mysql.so"

modparam("mysql", "ping_interval", 300)

modparam("mysql", "auto_reconnect", 1)

 

loadmodule "auth.so"

modparam("auth", "nonce_expire", 300)

modparam("auth", "rpid_suffix",
";party=calling;id-type=subscriber;screen=yes")

modparam("auth", "rpid_avp", "$avp(s:rpid)")

 

loadmodule "auth_db.so"

modparam("auth_db", "db_url", "mysql://openser:xxxx@x.x.x.x/openser")

modparam("auth_db", "user_column", "username")

modparam("auth_db", "domain_column", "domain")

modparam("auth_db", "password_column", "password")

modparam("auth_db", "password_column_2", "ha1b")

modparam("auth_db", "calculate_ha1", 1)

modparam("auth_db", "use_domain", 0)

modparam("auth_db", "load_credentials", "$avp(s:caller_uuid)=uuid")

 

loadmodule "uri_db.so"

modparam("uri_db", "db_url", "mysql://openser:xxxx@x.x.x.x/openser")

modparam("uri_db", "uri_table", "uri")

modparam("uri_db", "uri_user_column", "username")

modparam("uri_db", "uri_domain_column", "domain")

modparam("uri_db", "uri_uriuser_column", "uri_user")

modparam("uri_db", "subscriber_table", "subscriber")

modparam("uri_db", "subscriber_user_column", "username")

modparam("uri_db", "subscriber_domain_column", "domain")

modparam("uri_db", "use_uri_table", 0)

modparam("uri_db", "use_domain", 0)

 

loadmodule "avpops.so"

modparam("avpops", "db_url", "mysql://openser:xxxx@x.x.x.x/openser")

modparam("avpops", "avp_table", "usr_preferences")

modparam("avpops", "use_domain", 0)

modparam("avpops", "uuid_column", "uuid")

modparam("avpops", "username_column", "username")

modparam("avpops", "domain_column", "domain")

modparam("avpops", "attribute_column", "attribute")

modparam("avpops", "value_column", "value")

modparam("avpops", "type_column", "type")

 

 

 

loadmodule "permissions.so"

modparam("permissions", "default_allow_file", "permissions.allow")

modparam("permissions", "default_deny_file", "permissions.deny")

modparam("permissions", "check_all_branches", 1)

modparam("permissions", "allow_suffix", ".allow")

modparam("permissions", "deny_suffix", ".deny")

modparam("permissions", "db_url",
"mysql://openser:xxxx@x.x.x.x/openser")

modparam("permissions", "db_mode", 1)

modparam("permissions", "trusted_table", "trusted")

modparam("permissions", "source_col", "src_ip")

modparam("permissions", "proto_col", "proto")

modparam("permissions", "from_col", "from_pattern")

modparam("permissions", "tag_col", "tag")

modparam("permissions", "peer_tag_avp", "s:peer_uuid")

 

loadmodule "lcr.so"

modparam("lcr", "db_url", "mysql://openser:xxxx@x.x.x.x/openser")

modparam("lcr", "gw_table", "gw")

modparam("lcr", "gw_name_column", "gw_name")

modparam("lcr", "ip_addr_column", "ip_addr")

modparam("lcr", "port_column", "port")

modparam("lcr", "uri_scheme_column", "uri_scheme")

modparam("lcr", "transport_column", "transport")

modparam("lcr", "grp_id_column", "grp_id")

modparam("lcr", "lcr_table", "lcr")

modparam("lcr", "strip_column", "strip")

modparam("lcr", "prefix_column", "prefix")

modparam("lcr", "from_uri_column", "from_uri")

modparam("lcr", "priority_column", "priority")

modparam("lcr", "gw_uri_avp", "1400")

modparam("lcr", "ruri_user_avp", "1402")

modparam("lcr", "contact_avp", "1401")

modparam("lcr", "fr_inv_timer_avp", "s:fr_inv_timer_avp")

modparam("lcr", "fr_inv_timer", 90)

modparam("lcr", "fr_inv_timer_next", 30)

modparam("lcr", "rpid_avp", "s:rpid")

 

loadmodule "alias_db.so"

modparam("alias_db", "db_url", "mysql://openser:xxxx@x.x.x.x/openser")

modparam("alias_db", "user_column", "username")

modparam("alias_db", "domain_column", "domain")

modparam("alias_db", "alias_user_column", "alias_username")

modparam("alias_db", "alias_domain_column", "alias_domain")

modparam("alias_db", "use_domain", 0)

 

loadmodule "uac.so"

modparam("uac", "rr_store_param", "vsf")

modparam("uac", "from_restore_mode", "auto")

modparam("uac", "from_passwd", "s1p:Wiz4rd!")

 

#loadmodule "acc.so"

#modparam("acc", "early_media", 0)

#modparam("acc", "failed_transaction_flag", 24)

#modparam("acc", "report_ack", 0)

#modparam("acc", "report_cancels", 0)

#modparam("acc", "log_flag", 0)

#modparam("acc", "log_missed_flag", 0)

#modparam("acc", "log_level", 2)

 

 

loadmodule "auth_radius.so"

loadmodule "group_radius.so"

loadmodule "avp_radius.so"

modparam("auth_radius|group_radius|avp_radius",
"radius_config","/etc/radiusclient-ng/radiusclient.conf")

 

 

loadmodule "acc.so"

 

modparam("acc", "failed_transaction_flag", 1)

modparam("acc", "report_cancels",     0)

modparam("acc", "report_ack",         0)

modparam("acc", "early_media",        0)

 

modparam("acc", "log_level",          1)

modparam("acc", "log_flag",           1)

modparam("acc", "log_missed_flag",    1)

 

modparam("acc", "db_flag", 25)

modparam("acc", "db_missed_flag", 0)

modparam("acc", "db_table_acc", "acc")

modparam("acc", "db_table_missed_calls", "missed_calls")

modparam("acc", "db_url", "mysql://openser:xxxx@x.x.x.x/openser")

modparam("acc", "acc_method_column", "method")

modparam("acc", "acc_callid_column", "callid")

modparam("acc", "acc_time_column", "time")

modparam("acc", "acc_totag_column", "to_tag")

modparam("acc", "acc_from_tag_column", "from_tag")

modparam("acc", "detect_direction", 1)

modparam("acc", "acc_sip_code_column", "sip_code")

modparam("acc", "acc_sip_reason_column", "sip_reason")

 

 

#modparam("acc", "multi_leg_info",
"leg_src=$avp(i:901);leg_dst=$avp(i:902)")

 

 

modparam("acc", "radius_config",
"/etc/radiusclient-ng/radiusclient.conf")

modparam("acc", "radius_flag",        1)

modparam("acc", "radius_missed_flag", 1)

#modparam("acc", "multi_leg_info",
"RAD_LEG_SRC=$avp(i:901);RAD_LEG_SRC=$avp(i:902)")

modparam("acc", "radius_extra",       "Sip-RPid=$avp(s:rpid); \

                                       Source-IP=$si; \

                                       Source-Port=$sp; \

                                   Canonical-URI=$ru; \

 
Billing-Party=$avp(s:billingparty); \

 
Divert-Reason=$avp(s:divert_reason); \

 
X-RTP-Stat=$avp(s:rtp_statistics); \

                                       From-Header=$hdr(from); \

                                       User-Agent=$hdr(user-agent); \

                                       Contact=$hdr(contact); \

                                    Calling-Station-Id=$fu; \

                                    Called-Station-Id=$rU; \

                                       Event=$hdr(event); \

                                   SIP-Proxy-IP=$avp(s:sip_proxy_ip)")

# Billing-Party=$avp(s:caller_uuid); \

 

 

loadmodule "siptrace.so"

modparam("siptrace", "trace_flag", 0) 

modparam("siptrace", "db_url", "mysql://openser:xxxx@x.x.x.x/openser") 

modparam("siptrace", "trace_on", 1) 

modparam("siptrace", "table", "sip_trace") 

modparam("siptrace", "duplicate_uri", "sip:x.x.x.x:5888") 

 

 

########################################################################

# Request route 'main'

########################################################################

route[0]

{

      sip_trace(); #ajp sip trace to database

      xlog("L_INFO", "New request - M=$rm RURI=$ru F=$fu T=$tu IP=$si
ID=$ci\n");

      force_rport();

      if(msg:len > max_len)

      {

            

            xlog("L_INFO", "Message too big - M=$rm RURI=$ru F=$fu T=$tu
IP=$si ID=$ci\n");

            sl_send_reply("513", "Message Too Big");

            exit;

      }

      if (!mf_process_maxfwd_header("10"))

      {

            

            xlog("L_INFO", "Too many hops - M=$rm RURI=$ru F=$fu T=$tu
IP=$si ID=$ci\n");

            sl_send_reply("483", "Too Many Hops");

            exit;

      }

      if(!is_method("REGISTER"))

      {

            if(nat_uac_test("19"))

            {

                  record_route(";nat=yes");

            }

            else

            {

                  record_route();

            }

      }

      if(is_method("CANCEL") || is_method("BYE"))

      {

            setflag(1);

            end_media_session();

      }

      if(loose_route())

      {

            if(!has_totag())

            {

                  

                  xlog("L_INFO", "Initial loose-routing rejected - M=$rm
RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");

                  sl_send_reply("403", "Initial Loose-Routing
Rejected");

                  exit;

            }

            if(nat_uac_test("19") || search("^Route:.*;nat=yes"))

            {

                  fix_nated_contact();

                  setbflag(6);

            }

            if(is_method("BYE"))

            {

                  setflag(24); # account failed transactions

                  setflag(25); # account successful transactions

            }

            # mark as loose-routed for acc

            setflag(26);

            

            route(12);

      }

      if(is_method("REGISTER"))

      {

            route(11);

      }

      setflag(24); # account failed transactions

      setflag(25); # account successful transactions

      

      if(is_method("INVITE"))

      {

            

            route(13);

      }

      if(is_method("CANCEL") || is_method("ACK"))

      {

            route(17);

      }

      

      route(18);

}

 

########################################################################

# Request route 'clear-usr-preferences-caller'

########################################################################

route[1]

{

      xlog("L_INFO", "Clear caller preferences - M=$rm RURI=$ru F=$fu
T=$tu IP=$si ID=$ci\n");

      avp_delete("$avp(s:caller_cli)/g");

      avp_delete("$avp(s:clir)/g");

      

}

 

########################################################################

# Request route 'clear-usr-preferences-callee'

########################################################################

route[2]

{

      xlog("L_INFO", "Clear callee preferences - M=$rm RURI=$ru F=$fu
T=$tu IP=$si ID=$ci\n");

      avp_delete("$avp(s:cfu)/g");

      avp_delete("$avp(s:cfc)/g");

      

}

 

########################################################################

# Request route 'usr-preferences-caller'

########################################################################

route[3]

{

      route(1);

      xlog("L_INFO", "Load caller preferences for uuid
'$avp(s:caller_uuid)' - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");

      # load caller avps

      avp_db_load("$avp(s:caller_uuid)", "*");

      avp_copy("$avp(s:cli)", "$avp(s:caller_cli)/d");

      if(is_avp_set("$avp(s:clir)/n") && avp_check("$avp(s:clir)",
"eq/i:1"))

      {

            # mark for anonymization

            setflag(28);

      }

      

}

 

########################################################################

# Request route 'usr-preferences-callee'

########################################################################

route[4]

{

      xlog("L_INFO", "Load callee preferences for uuid
'$avp(s:callee_uuid)' - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");

      # load callee avps

      avp_db_load("$avp(s:callee_uuid)", "*");

      if(is_avp_set("$avp(s:cfu)/s"))

      {

            

            xlog("L_INFO", "Call-forward-unconditional to '$avp(s:cfu)'
found - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");

            route(8);

            avp_delete("$avp(s:caller_uuid)/g");

            avp_copy("$avp(s:callee_uuid)", "$avp(s:caller_uuid)/d");

            avp_pushto("$ru", "$avp(s:cfu)");

            

            route(3);

            route(14);

            exit;

      }

      

}

 

########################################################################

# Request route 'acc-caller'

########################################################################

route[5]

{

      xlog("L_INFO", "Setting acc source-leg for uuid
'$avp(s:caller_uuid)' - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");

      avp_printf("$avp(i:901)",
"$avp(s:caller_uuid)|$avp(s:acc_caller_user)|$avp(s:acc_caller_domain)|$
avp(s:acc_state)");

      

}

 

########################################################################

# Request route 'acc-callee'

########################################################################

route[6]

{

      xlog("L_INFO", "Setting acc destination-leg for uuid
'$avp(s:callee_uuid)' - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");

      avp_printf("$avp(i:902)",
"$avp(s:callee_uuid)|$avp(s:acc_callee_user)|$avp(s:acc_callee_domain)")
;

      

}

 

########################################################################

# Request route 'acc-failure'

########################################################################

route[7]

{

      xlog("L_INFO", "Accounting failed request for uuid
'$avp(s:caller_uuid)' - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");

      route(5);

      route(6);

      resetflag(24);

      acc_db_request("404", "acc");

      

}

 

########################################################################

# Request route 'cfu-acc'

########################################################################

route[8]

{

      $avp(s:acc_callee_user) = $rU;

      $avp(s:acc_callee_domain) = $rd;

      

      route(5);

      route(6);

      avp_delete("$avp(s:acc_caller_user)");

      avp_delete("$avp(s:acc_caller_domain)");

      avp_copy("$avp(s:acc_callee_user)", "$avp(s:acc_caller_user)");

      avp_copy("$avp(s:acc_callee_domain)",
"$avp(s:acc_caller_domain)");

      avp_delete("$avp(s:acc_state)/g");

      $avp(s:acc_state) = "cfu";

      

}

 

########################################################################

# Request route 'clir'

########################################################################

route[9]

{

      if(isflagset(28) && !isflagset(27))

      {

            setflag(27);

            

            xlog("L_INFO", "Anonymize caller - M=$rm RURI=$ru F=$fu
T=$tu IP=$si ID=$ci\n");

 
uac_replace_from("Anonymous","sip:anonymous at anonymous.invalid");

            if(is_present_hf("Privacy"))

            {

                  remove_hf("Privacy");

            }

            append_hf("Privacy: id\r\n");

      }

      

}

 

########################################################################

# Request route 'stop-media-proxy'

########################################################################

route[10]

{

      if(isflagset(22))

      {

            end_media_session();

      }

      

}

 

########################################################################

# Request route 'base-route-register'

########################################################################

route[11]

{

      sl_send_reply("100", "Trying");

      if(!www_authorize("", "subscriber") && !radius_www_authorize("")) 

      #if(!radius_www_authorize("proxy-ca.thinksimplicity.net")) 

      {

            

            xlog("L_INFO", "Register authentication failed - M=$rm
RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");

            www_challenge("", "0");

            exit;

      }

      if(!check_to()) 

      {

            

            xlog("L_INFO", "Spoofed To-URI detected - M=$rm RURI=$ru
F=$fu T=$tu IP=$si ID=$ci\n");

            sl_send_reply("403", "Spoofed To-URI Detected");

            exit;

      }

      consume_credentials();

 

      if(!search("^Contact:[ ]*\*") && nat_uac_test("19")) 

      {

            fix_nated_register();

            setbflag(6);

      }

      if(!save("location")) 

      {

            

            xlog("L_ERR", "Saving contact failed - M=$rm RURI=$ru F=$fu
T=$tu IP=$si ID=$ci\n");

            sl_reply_error();

            exit;

      }

      

      xlog("L_INFO", "Registration successful - M=$rm RURI=$ru F=$fu
T=$tu IP=$si ID=$ci\n");

      exit;

      

}

 

########################################################################

# Request route 'base-outbound'

########################################################################

route[12]

{

      if(is_present_hf("P-Asserted-Identity"))

      {

            remove_hf("P-Asserted-Identity");

      }

      if(is_present_hf("Remote-Party-ID"))

      {

            remove_hf("Remote-Party-ID");

      }

      if(is_avp_set("$avp(s:caller_cli)/s"))

      {

            if(!isflagset(28))

            {

                  

                  xlog("L_INFO", "Set caller CLI '$avp(s:caller_cli)' -
M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");

                  append_hf("P-Asserted-Identity:
<$avp(s:caller_cli)>\r\n");

                  append_hf("Remote-Party-ID:
<$avp(s:caller_cli)>;party=caller;privacy=none;screen=yes\r\n");

            }

      }

      

      route(9);

      if(isbflagset(6))

      {

            if(!isflagset(22) && !search("^Content-Length:[ ]*0"))

            {

                  setflag(22);

                  use_media_proxy();

            }

            

            t_on_reply("2");

      }

      else

      {

            

            t_on_reply("1");

      }

      if(!isflagset(21))

      {

            

            t_on_failure("2");

            if(!isflagset(26))

            {

                  $avp(s:acc_callee_user) = $rU;

                  $avp(s:acc_callee_domain) = $rd;

                  

                  route(5);

                  route(6);

            }

      }

      if(isflagset(29))

      {

            append_branch();

      }

      if(is_present_hf("Proxy-Authorization"))

      {

            consume_credentials();

      }

      

      xlog("L_INFO", "Request leaving server, D-URI='$du' - M=$rm
RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");

      # no 100 (we already sent it) and no DNS blacklisting

      if(!t_relay("0x05"))

      {

            sl_reply_error();

            if(is_method("INVITE") && isbflagset(6))

            {

                  end_media_session();

            }

      }

      exit;

      

}

 

########################################################################

# Request route 'base-route-invite'

########################################################################

route[13]

{

      sl_send_reply("100", "Trying");

 

 

      

      if(from_gw())

      {

            $avp(s:caller_uuid) = "0";

            

            xlog("L_INFO", "Call from PSTN' - M=$rm RURI=$ru F=$fu T=$tu
IP=$si ID=$ci\n");

            #setflag(1);

            setflag(23);

      }

      else

      {

            if(allow_trusted())

            {

                  if(is_avp_set("$avp(s:peer_uuid)/s"))

                  {

                        # use tag-column from trusted-table as uuid for
this caller

                        avp_copy("$avp(s:peer_uuid)",
"$avp(s:caller_uuid)/d");

                  }

                  else

                  {

                        # if no uuid is set, use "0" as default uuid

                        $avp(s:caller_uuid) = "0";

                  }

                  

                  xlog("L_INFO", "Call from trusted peer with uuid
'$avp(s:caller_uuid)' - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");

                  if(!is_domain_local("$rd"))

                  {

                        

                        xlog("L_INFO", "Rejecting peering attempt with
non-local request domain - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");

                        sl_send_reply("403", "Relaying Denied");

                        exit;

                  }

                  setflag(23);

            }

      

      }

      #else

      #{

########AJP - Radius Authorization  

      #if (!radius_proxy_authorize("")) 

      #{    

      #     xlog("L_INFO", "Route authentication failed - M=$rm RURI=$ru
F=$fu T=$tu IP=$si ID=$ci\n");

      #     proxy_challenge("", "0");

      

      #}

      

      #if(!check_from()) 

      #{

            

      #     xlog("L_INFO", "Spoofed To-URI detected - M=$rm RURI=$ru
F=$fu T=$tu IP=$si ID=$ci\n");

      #     sl_send_reply("403", "Spoofed To-URI Detected");

            

      #}

      

      #consume_credentials();

 

#########

 

      #}

      $avp(s:acc_caller_user) = $fU;

      $avp(s:acc_caller_domain) = $fd;

      $avp(s:acc_state) = "call";

      

      #setflag(1);

       #$avp(s:sip-proxy) = "x.x.x.x";

       #$avp($ru) = "can_uri";

      

      route(3);

      if(nat_uac_test("19")) 

      {

            fix_nated_contact();

            setbflag(6);

      }

      

      route(14);

}

 

########################################################################

# Request route 'invite-find-callee'

########################################################################

route[14]

{

      if(lookup("aliases"))

      {

            

            xlog("L_INFO", "Callee was aliased - M=$rm RURI=$ru F=$fu
T=$tu IP=$si ID=$ci\n");

      }

      

      route(2);

      if(!is_domain_local("$rd"))

      {

            setflag(20);

            $avp(s:callee_uuid) = "0";

            

            route(16);

      }

      

#######ajp - Strip 1 for possible local numbers

      

      if (uri=~"^sip:1[0-9]{10}@") 

      {

            strip(1);

      }

 

      

 

 

      avp_delete("$avp(s:callee_uuid)");

      avp_db_query("select uuid from subscriber where username = '$rU'",
"$avp(s:callee_uuid)");

      if(is_avp_set("$avp(s:callee_uuid)/s"))

      {

            

            xlog("L_INFO", "Callee is local, uuid='$avp(s:callee_uuid)'
- M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");

            

            route(15);

      }

      else

      {

            $avp(s:callee_uuid) = "0";

            

            xlog("L_INFO", "Callee is not local - M=$rm RURI=$ru F=$fu
T=$tu IP=$si ID=$ci\n");

            route(16);

      }

      exit;

      

}

 

########################################################################

# Request route 'invite-to-internal'

########################################################################

route[15]

{

      route(4);

      

      if(!lookup("location")) 

      {

            

            xlog("L_INFO", "Local user offline - M=$rm RURI=$ru F=$fu
T=$tu IP=$si ID=$ci\n");

            $avp(s:acc_callee_user) = $rU;

            $avp(s:acc_callee_domain) = $rd;

            

            route(7);

            sl_send_reply("404", "User Offline");

      }

      else

      {

            

            xlog("L_INFO", "Local user online - M=$rm RURI=$ru F=$fu
T=$tu IP=$si ID=$ci\n");

            

            avp_delete("$avp(s:caller_uuid)/g"); #ajp - This call is
billed to receiving party.

            avp_copy("$avp(s:callee_uuid)", "$avp(s:caller_uuid)/d");

            $avp(s:billingparty) = "inbound";

            

            #avp_delete("$avp(s:caller_uuid)"); #ajp  - billed to
internal user

            #avp_db_query("select uuid from subscriber where username =
'$tU'", "$avp(s:caller_uuid)"); #ajp

            #$avp(s:billingparty) = $avp(s:caller_uuid);

 

            $avp(s:sip_proxy_ip) = "x.x.x.x";

            setflag(1);  #accounting

            

            route(12);

      }

      exit;

      

}

 

########################################################################

# Request route 'invite-to-external'

########################################################################

route[16]

{

      if(isflagset(20))

      {

            

            xlog("L_INFO", "Call to foreign domain - M=$rm RURI=$ru
F=$fu T=$tu IP=$si ID=$ci\n");

            route(12);

            exit;

      }

      if(!isflagset(23))

      {

            # don't allow calls relaying from PSTN to PSTN, if not
explicitely forwarded

            if(uri =~ "^sip:[0-9]+@")

            {

                  # only route numeric users to PSTN

      

 

#ajp-normalize the call

            

            if(uri =~ "^sip:[0-9]{10}+@") #ajp- North Americal local
numbers prefix with 1

            {

                  prefix("1");

            }

            if(uri =~ "^sip:001[0-9]*@") #ajp- Europe dial to North
America

            {

                  strip(2);

            }

            if(uri =~ "^sip:00[0-9]*@") #ajp- International Calling from
Europe

            {

                  strip(2);

            }

            if(uri =~ "^sip:011[0-9]*@") #ajp- International Calling
from North America

            {

                  strip(3);

            }

#ajp-accounting

                  #$avp(s:acc_caller_uuid) = $rU; #ajp

                  avp_delete("$avp(s:callee_uuid)"); #ajp

                  avp_db_query("select uuid from subscriber where
username = '$fU'", "$avp(s:callee_uuid)"); #ajp

                  $avp(s:billingparty) = $avp(s:callee_uuid);

                  $avp(s:sip_proxy_ip) = "x.x.x.x"; #ajp accounting

                  

 

                  

 

                  if(!load_gws())

                  {

                        

                        xlog("L_ERR", "Error loading PSTN gateways -
M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");

                        sl_send_reply("503", "PSTN Termination Currently
Unavailable");

                        exit;

                  }

                  if(!next_gw())

                  {

                        

                        xlog("L_ERR", "No PSTN gateways available -
M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");

                        sl_send_reply("503", "PSTN Termination Currently
Unavailable");

                        exit;

                  }

                  setflag(21);

                  setflag(1);  

                  

                  t_on_failure("1");

                  route(12);

            }

      }

      

      xlog("L_INFO", "Call to unknown user - M=$rm RURI=$ru F=$fu T=$tu
IP=$si ID=$ci\n");

      route(7);

      sl_send_reply("404", "User Not Found");

      exit;

      

}

 

########################################################################

# Request route 'base-route-local'

########################################################################

route[17]

{

      t_on_reply("1");

      if(t_check_trans())

      {

            

            xlog("L_INFO", "Request leaving server - M=$rm RURI=$ru
F=$fu T=$tu IP=$si ID=$ci\n");

            if(!t_relay())

            {

                  sl_reply_error();

            }

      }

      else

      {

            

            xlog("L_INFO", "Dropping mis-routed request - M=$rm RURI=$ru
F=$fu T=$tu IP=$si ID=$ci\n");

      }

      exit;

      

}

 

########################################################################

# Request route 'base-route-generic'

########################################################################

route[18]

{

      xlog("L_INFO", "Method not supported - M=$rm RURI=$ru F=$fu T=$tu
IP=$si ID=$ci\n");

      sl_send_reply("501", "Method Not Supported Here");

      exit;

      

}

 

########################################################################

# Request route 'base-filter-failover'

########################################################################

route[19]

{

      if(!t_check_status("408|500|503"))

      {

            

            xlog("L_INFO", "No failover routing needed for this response
code - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");

            route(10);

            exit;

      }

      

}

 

########################################################################

# Reply route 'base-standard-reply'

########################################################################

onreply_route[1]

{

      xlog("L_INFO", "Reply - S=$rs D=$rr F=$fu T=$tu IP=$si ID=$ci\n");

      exit;

      

}

 

########################################################################

# Reply route 'base-nat-reply'

########################################################################

onreply_route[2]

{

      xlog("L_INFO", "NAT-Reply - S=$rs D=$rr F=$fu T=$tu IP=$si
ID=$ci\n");

      if(nat_uac_test("1"))

      {

            fix_nated_contact();

      }

      if(isbflagset(6) && status=~"(180)|(183)|2[0-9][0-9]") 

      {

            if(!search("^Content-Length:[ ]*0"))

            {

                  use_media_proxy();

            }

      }

      exit;

      

}

 

########################################################################

# Failure route 'pstn-failover'

########################################################################

failure_route[1]

{

      xlog("L_INFO", "Failure route for PSTN entered - M=$rm RURI=$ru
F=$fu T=$tu IP=$si ID=$ci\n");

      route(19);

      if(!next_gw())

      {

            

            xlog("L_ERR", "Failed to select next PSTN gateway - M=$rm
RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");

            route(10);

            exit;

      }

      

      t_on_failure("1");

      route(12);

}

 

########################################################################

# Failure route 'base-standard-failure'

########################################################################

failure_route[2]

{

      if(t_check_status("422|481|487"))

      {

            

            xlog("L_INFO", "Final reply - M=$rm RURI=$ru F=$fu T=$tu
IP=$si ID=$ci\n");

            route(10);

            exit;

      }

      

      t_on_branch("1");

      xlog("L_INFO", "Redirect from UAC intercepted - M=$rm RURI=$ru
F=$fu T=$tu IP=$si ID=$ci\n");

      route(14);

      if($avp(s:cfc) != NULL)

      {

            avp_delete("$avp(s:acc_caller_user)/g");

            avp_delete("$avp(s:acc_caller_domain)/g");

            avp_delete("$avp(s:acc_state)/g");

            avp_copy("$avp(s:acc_callee_user)",
"$avp(s:acc_caller_user)");

            avp_copy("$avp(s:acc_callee_domain)",
"$avp(s:acc_caller_domain)");

            $avp(s:acc_state) = "cfc";

            avp_pushto("$ru", "$avp(s:cfc)");

            setflag(29);

            append_branch();

            

            t_on_branch("1");

            xlog("L_INFO", "CFC detected - M=$rm RURI=$ru F=$fu T=$tu
IP=$si ID=$ci\n");

            route(14);

      }

      

      route(19);

      route(10);

}

 

########################################################################

# Branch route 'cfc-drop-local'

########################################################################

branch_route[1]

{

      if(is_domain_local("$rd"))

      {

            

            xlog("L_INFO", "Dropping local branch - M=$rm RURI=$ru F=$fu
T=$tu IP=$si ID=$ci\n");

            drop();

      }

      

}

 

 





 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20070805/74016158/attachment.htm>


More information about the sr-users mailing list