<html>
<head>
<style>
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
FONT-SIZE: 10pt;
FONT-FAMILY:Tahoma
}
</style>
</head>
<body class='hmmessage'>&nbsp;<BR>Hi All,<BR>&nbsp;<BR>I am trying to setup an OpenSER server with support for registration, messaging &amp; presence however I am having a problem with the presence server.<BR>&nbsp;<BR>I have had presence working correctly before, however for some reason it is no longer working. I have spent about two days trying everything!<BR>&nbsp;<BR>I would really appreciate some advice with this. I have included my config below.<BR>&nbsp;<BR>Thank you in advance,<BR>&nbsp;<BR>Ross<BR>&nbsp;<BR>------------------------------------------------------------------------------<BR>listen = udp:my.ip.address:5060<BR>mpath = "/usr/local/lib64/openser/modules"<BR>children = 8<BR>debug = 3<BR>fork = yes<BR>disable_tcp = no<BR>#log_facility = LOG_DAEMON<BR>log_facility = LOG_LOCAL0<BR>log_stderror = yes<BR>tcp_children = 4<BR>mhomed = no<BR>server_signature = yes<BR>#sock_group = "openser"<BR>#sock_mode = 0600<BR>#sock_user = "openser"<BR>#unix_sock = "/tmp/openser.sock"<BR>#unix_sock_children = 1<BR>#reply_to_via = no<BR>#sip_warning = no<BR>#check_via = no<BR>#dns = no<BR>#rev_dns = no<BR>#disable_core_dump = no<BR>#dns_try_ipv6 = yes<BR>#dns_use_search_list = yes<BR>loadmodule "usrloc.so"<BR>modparam("usrloc", "user_column", "username")<BR>modparam("usrloc", "domain_column", "domain")<BR>modparam("usrloc", "contact_column", "contact")<BR>modparam("usrloc", "expires_column", "expires")<BR>modparam("usrloc", "q_column", "q")<BR>modparam("usrloc", "callid_column", "callid")<BR>modparam("usrloc", "cseq_column", "cseq")<BR>modparam("usrloc", "methods_column", "methods")<BR>modparam("usrloc", "flags_column", "flags")<BR>modparam("usrloc", "user_agent_column", "user_agent")<BR>modparam("usrloc", "received_column", "received")<BR>modparam("usrloc", "socket_column", "socket")<BR>modparam("usrloc", "use_domain", 0)<BR>modparam("usrloc", "desc_time_order", 0)<BR>modparam("usrloc", "timer_interval", 60)<BR>modparam("usrloc", "db_url", "mysql://username:password@localhost/openser")<BR>modparam("usrloc", "db_mode", 1)<BR>modparam("usrloc", "matching_mode", 0)<BR>modparam("usrloc", "cseq_delay", 20)<BR>modparam("usrloc", "nat_bflag", 6)<BR>loadmodule "registrar.so"<BR>modparam("registrar", "default_expires", 3600)<BR>modparam("registrar", "min_expires", 60)<BR>modparam("registrar", "max_expires", 0)<BR>modparam("registrar", "default_q", 0)<BR>modparam("registrar", "append_branches", 1)<BR>modparam("registrar", "case_sensitive", 0)<BR>modparam("registrar", "received_param", "received")<BR>modparam("registrar", "max_contacts", 0)<BR>modparam("registrar", "retry_after", 0)<BR>modparam("registrar", "method_filtering", 0)<BR>modparam("registrar", "path_mode", 2)<BR>modparam("registrar", "path_use_received", 0)<BR>modparam("registrar", "received_avp", "$avp(i:801)")<BR>loadmodule "rr.so"<BR>modparam("rr", "enable_full_lr", 1)<BR>modparam("rr", "append_fromtag", 1)<BR>modparam("rr", "enable_double_rr", 1)<BR>modparam("rr", "add_username", 0)<BR>loadmodule "tm.so"<BR>modparam("tm", "fr_timer", 30)<BR>modparam("tm", "fr_inv_timer", 120)<BR>modparam("tm", "wt_timer", 5)<BR>modparam("tm", "delete_timer", 2)<BR>modparam("tm", "noisy_ctimer", 0)<BR>modparam("tm", "ruri_matching", 1)<BR>modparam("tm", "via1_matching", 1)<BR>modparam("tm", "unix_tx_timeout", 2)<BR>modparam("tm", "restart_fr_on_each_reply", 1)<BR>modparam("tm", "pass_provisional_replies", 0)<BR>&nbsp;<BR>&nbsp;<BR>loadmodule "xlog.so"<BR>modparam("xlog", "buf_size", 4096)<BR>modparam("xlog", "force_color", 1)<BR>loadmodule "mi_fifo.so"<BR>modparam("mi_fifo", "fifo_name", "/tmp/openser_fifo")<BR>#modparam("mi_fif0", "fifo_name", "FIFO")<BR>modparam("mi_fifo", "fifo_mode", 0660)<BR>#modparam("mi_fifo", "fifo_group", "openser")<BR>#modparam("mi_fifo", "fifo_user", "openser")<BR>modparam("mi_fifo", "reply_dir", "/tmp/")<BR>modparam("mi_fifo", "reply_indent", "\t")<BR>loadmodule "domain.so"<BR>modparam("domain", "db_url", "mysql://username:password@localhost/openser")<BR>modparam("domain", "db_mode", 1)<BR>modparam("domain", "domain_table", "domain")<BR>modparam("domain", "domain_col", "domain")<BR>loadmodule "nathelper.so"<BR>modparam("nathelper", "natping_interval", 0)<BR>modparam("nathelper", "ping_nated_only", 1)<BR>modparam("nathelper", "rtpproxy_sock", "")<BR>modparam("nathelper", "rtpproxy_disable_tout", 60)<BR>modparam("nathelper", "rtpproxy_tout", 1)<BR>modparam("nathelper", "rtpproxy_retr", 5)<BR>modparam("nathelper", "sipping_method", "OPTIONS")<BR>modparam("nathelper", "received_avp", "$avp(i:801)")<BR>loadmodule "textops.so"<BR>loadmodule "mediaproxy.so"<BR>#modparam("mediaproxy", "mediaproxy_socket", "/var/run/proxydispatcher.sock")<BR>modparam("mediaproxy", "mediaproxy_socket", "/var/run/mediaproxy.sock")<BR>modparam("mediaproxy", "sip_asymmetrics", "/etc/openser/sip-asymmetric-clients")<BR>modparam("mediaproxy", "rtp_asymmetrics", "/etc/openser/rtp-asymmetric-clients")<BR>modparam("mediaproxy", "natping_interval", 60)<BR>loadmodule "uri.so"<BR>loadmodule "sl.so"<BR>modparam("sl", "enable_stats", 1)<BR>loadmodule "maxfwd.so"<BR>modparam("maxfwd", "max_limit", 256)<BR>loadmodule "mysql.so"<BR>modparam("mysql", "ping_interval", 300)<BR>modparam("mysql", "auto_reconnect", 1)<BR>loadmodule "auth.so"<BR>modparam("auth", "nonce_expire", 300)<BR>modparam("auth", "rpid_suffix", ";party=calling;id-type=subscriber;screen=yes")<BR>modparam("auth", "rpid_avp", "$avp(s:rpid)")<BR>loadmodule "auth_db.so"<BR>modparam("auth_db", "db_url", "mysql://username:password@localhost/openser")<BR>modparam("auth_db", "user_column", "username")<BR>modparam("auth_db", "domain_column", "domain")<BR>modparam("auth_db", "password_column", "password")<BR>#modparam("auth_db", "password_column_2", "ha1b")<BR>modparam("auth_db", "calculate_ha1", 1)<BR>modparam("auth_db", "use_domain", 0)<BR>modparam("auth_db", "load_credentials", "$avp(s:caller_uuid)=id")<BR>loadmodule "uri_db.so"<BR>modparam("uri_db", "db_url", "mysql://username:password@localhost/openser")<BR>modparam("uri_db", "uri_table", "uri")<BR>modparam("uri_db", "uri_user_column", "username")<BR>modparam("uri_db", "uri_domain_column", "domain")<BR>modparam("uri_db", "uri_uriuser_column", "uri_user")<BR>modparam("uri_db", "subscriber_table", "subscriber")<BR>modparam("uri_db", "subscriber_user_column", "username")<BR>modparam("uri_db", "subscriber_domain_column", "domain")<BR>modparam("uri_db", "use_uri_table", 0)<BR>modparam("uri_db", "use_domain", 0)<BR>loadmodule "avpops.so"<BR>modparam("avpops", "db_url", "mysql://username:password@localhost/openser")<BR>modparam("avpops", "avp_table", "usr_preferences")<BR>modparam("avpops", "use_domain", 0)<BR>modparam("avpops", "uuid_column", "id")<BR>modparam("avpops", "username_column", "username")<BR>modparam("avpops", "domain_column", "domain")<BR>modparam("avpops", "attribute_column", "attribute")<BR>modparam("avpops", "value_column", "value")<BR>modparam("avpops", "type_column", "type")<BR>loadmodule "enum.so"<BR>modparam("enum", "domain_suffix", "e164.org.")<BR>loadmodule "permissions.so"<BR>#modparam("permissions", "default_allow_file", "permissions.allow")<BR>#modparam("permissions", "default_deny_file", "permissions.deny")<BR>#modparam("permissions", "check_all_branches", 1)<BR>#modparam("permissions", "allow_suffix", ".allow")<BR>#modparam("permissions", "deny_suffix", ".deny")<BR>modparam("permissions", "db_url", "mysql://username:password@localhost/openser")<BR>modparam("permissions", "db_mode", 1)<BR>modparam("permissions", "trusted_table", "trusted")<BR>modparam("permissions", "source_col", "src_ip")<BR>modparam("permissions", "proto_col", "proto")<BR>modparam("permissions", "from_col", "from_pattern")<BR>modparam("permissions", "tag_col", "tag")<BR>modparam("permissions", "peer_tag_avp", "$avp(i:707)")<BR>loadmodule "lcr.so"<BR>modparam("lcr", "db_url", "mysql://username:password@localhost/openser")<BR>modparam("lcr", "gw_table", "gw")<BR>modparam("lcr", "gw_name_column", "gw_name")<BR>modparam("lcr", "ip_addr_column", "ip_addr")<BR>modparam("lcr", "port_column", "port")<BR>modparam("lcr", "uri_scheme_column", "uri_scheme")<BR>modparam("lcr", "transport_column", "transport")<BR>modparam("lcr", "grp_id_column", "grp_id")<BR>modparam("lcr", "lcr_table", "lcr")<BR>modparam("lcr", "strip_column", "strip")<BR>modparam("lcr", "prefix_column", "prefix")<BR>modparam("lcr", "from_uri_column", "from_uri")<BR>modparam("lcr", "priority_column", "priority")<BR>modparam("lcr", "gw_uri_avp", "$avp(i:709)")<BR>modparam("lcr", "ruri_user_avp", "$avp(i:500)")<BR>modparam("lcr", "contact_avp", "$avp(i:711)")<BR>modparam("lcr|tm", "fr_inv_timer_avp", "$avp(i:704)")<BR>modparam("lcr", "fr_inv_timer", 90)<BR>modparam("lcr", "fr_inv_timer_next", 30)<BR>modparam("lcr", "rpid_avp", "$avp(i:302)")<BR>modparam("lcr", "dm_flag", 25)<BR>&nbsp;<BR>&nbsp;<BR>loadmodule "alias_db.so"<BR>modparam("alias_db", "db_url", "mysql://username:password@localhost/openser")<BR>modparam("alias_db", "user_column", "username")<BR>modparam("alias_db", "domain_column", "domain")<BR>modparam("alias_db", "alias_user_column", "alias_username")<BR>modparam("alias_db", "alias_domain_column", "alias_domain")<BR>modparam("alias_db", "use_domain", 0)<BR>&nbsp;<BR><STRONG># ----- presence params -----</STRONG><BR><STRONG>loadmodule "presence.so"</STRONG><BR><STRONG>loadmodule "presence_xml.so"</STRONG><BR><STRONG>loadmodule "presence_mwi.so"</STRONG><BR><STRONG>loadmodule "pua.so"</STRONG><BR><STRONG>loadmodule "pua_mi.so"</STRONG><BR><STRONG>loadmodule "pua_usrloc.so"</STRONG><BR><STRONG>modparam("presence|presence_xml", "db_url","mysql://username:password@localhost/openser")</STRONG><BR><STRONG>modparam("presence_xml", "force_active", 1)</STRONG><BR><STRONG>modparam("presence", "server_address", "sip:my.ip.address:5060")</STRONG><BR><STRONG>modparam("presence", "presentity_table", "presentity")</STRONG><BR><STRONG>modparam("presence", "active_watchers_table", "active_watchers")</STRONG><BR><STRONG>modparam("presence", "watchers_table", "watchers")</STRONG><BR><STRONG>modparam("presence", "clean_period", 100)</STRONG><BR><STRONG>modparam("presence", "max_expires", 3600)</STRONG><BR><STRONG>modparam("presence", "fallback2db", 1)</STRONG><BR><STRONG>modparam("presence_xml", "xcap_table", "xcap")</STRONG><BR><STRONG>modparam("presence_xml", "pidf_manipulation", 1)</STRONG><BR><STRONG>modparam("presence_xml", "integrated_xcap_server", 1)</STRONG><BR><STRONG>modparam("pua_usrloc", "default_domain", "my.domain.com")</STRONG><BR><STRONG>modparam("presence", "to_tag_pref", 'pres')</STRONG><BR>&nbsp;<BR>&nbsp;<BR>########################################################################<BR># Request route 'main'<BR>########################################################################<BR>route[0]<BR>{<BR>xlog("L_INFO", "New request - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR>force_rport();<BR>if(msg:len &gt; max_len)<BR>{<BR><BR>xlog("L_INFO", "Message too big - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR>sl_send_reply("513", "Message Too Big");<BR>exit;<BR>}<BR>if (!mf_process_maxfwd_header("10"))<BR>{<BR><BR>xlog("L_INFO", "Too many hops - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR>sl_send_reply("483", "Too Many Hops");<BR>exit;<BR>}<BR>if(!is_method("REGISTER|MESSAGE"))<BR>{<BR>if(nat_uac_test("19"))<BR>{<BR>record_route(";nat=yes");<BR>}<BR>else<BR>{<BR>record_route();<BR>}<BR>}<BR><BR>if(is_method("CANCEL") || is_method("BYE"))<BR>{<BR>end_media_session();<BR>}<BR>if(loose_route())<BR>{<BR>if(!has_totag())<BR>{<BR><BR>xlog("L_INFO", "Initial loose-routing rejected - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR>sl_send_reply("403", "Initial Loose-Routing Rejected");<BR>exit;<BR>}<BR>if(nat_uac_test("19") || search("^Route:.*;nat=yes"))<BR>{<BR>fix_nated_contact();<BR>setbflag(6);<BR>}<BR>route(7);<BR>}<BR>if(is_method("REGISTER"))<BR>{<BR>route(6);<BR>}<BR>if(is_method("INVITE"))<BR>{<BR>route(8);<BR>}<BR><STRONG>if(is_method("PUBLISH|SUBSCRIBE"))</STRONG><BR><STRONG>{</STRONG><BR><STRONG>route(17);</STRONG><BR><STRONG>}</STRONG><BR>if(is_method("CANCEL") || is_method("ACK"))<BR>{<BR>route(14);<BR>}<BR><BR>############################<BR># MESSAGES #<BR>############################<BR>if(is_method("MESSAGE"))<BR>{<BR>route(18);<BR>}<BR>route(15);<BR>}<BR>########################################################################<BR># Request route 'clear-usr-preferences-caller'<BR>########################################################################<BR>route[1]<BR>{<BR>xlog("L_INFO", "Clear caller preferences - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR>}<BR>########################################################################<BR># Request route 'clear-usr-preferences-callee'<BR>########################################################################<BR>route[2]<BR>{<BR>xlog("L_INFO", "Clear callee preferences - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR>}<BR>########################################################################<BR># Request route 'usr-preferences-caller'<BR>########################################################################<BR>route[3]<BR>{<BR>route(1);<BR>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");<BR># load caller avps<BR>avp_db_load("$avp(s:caller_uuid)", "*");<BR><BR>}<BR>########################################################################<BR># Request route 'usr-preferences-callee'<BR>########################################################################<BR>route[4]<BR>{<BR>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");<BR># load callee avps<BR>avp_db_load("$avp(s:callee_uuid)", "*");<BR><BR>}<BR>########################################################################<BR># Request route 'stop-media-proxy'<BR>########################################################################<BR>route[5]<BR>{<BR>if(isflagset(22))<BR>{<BR>end_media_session();<BR>}<BR><BR>}<BR>########################################################################<BR># Request route 'base-route-register'<BR>########################################################################<BR>route[6]<BR>{<BR>sl_send_reply("100", "Trying");<BR>if(!www_authorize("", "subscriber")) <BR>{<BR><BR>xlog("L_INFO", "Register authentication failed - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR>www_challenge("", "0");<BR>exit;<BR>}<BR>if(!check_to()) <BR>{<BR><BR>xlog("L_INFO", "Spoofed To-URI detected - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR>sl_send_reply("403", "Spoofed To-URI Detected");<BR>exit;<BR>}<BR>consume_credentials();<BR>if(!search("^Contact:[ ]*\*") &amp;&amp; nat_uac_test("19")) <BR>{<BR>fix_nated_register();<BR>setbflag(6);<BR>}<BR>if(!save("location")) <BR>{<BR><BR>xlog("L_ERR", "Saving contact failed - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR>sl_reply_error();<BR>exit;<BR>}<BR><BR>xlog("L_INFO", "Registration successful - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR>exit;<BR><BR>}<BR>########################################################################<BR># Request route 'base-outbound'<BR>########################################################################<BR>route[7]<BR>{<BR>xlog("L_INFO", "ROUTE 7 RUN - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR>if(isbflagset(6))<BR>{<BR>if(!isflagset(22) &amp;&amp; !search("^Content-Length:[ ]*0"))<BR>{<BR>setflag(22);<BR>use_media_proxy();<BR>}<BR><BR>t_on_reply("2");<BR>}<BR>else<BR>{<BR><BR>t_on_reply("1");<BR>}<BR>if(!isflagset(21))<BR>{<BR><BR>t_on_failure("2");<BR>}<BR>if(isflagset(29))<BR>{<BR>append_branch();<BR>}<BR>if(is_present_hf("Proxy-Authorization"))<BR>{<BR>consume_credentials();<BR>}<BR><BR>xlog("L_INFO", "Request leaving server, D-URI='$du' - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR># no 100 (we already sent it) and no DNS blacklisting<BR>if(!t_relay("0x05"))<BR>{<BR>sl_reply_error();<BR>if(is_method("INVITE") &amp;&amp; isbflagset(6))<BR>{<BR>end_media_session();<BR>}<BR>}<BR>exit;<BR><BR>}<BR>########################################################################<BR># Request route 'base-route-invite'<BR>########################################################################<BR>route[8]<BR>{<BR>sl_send_reply("100", "Trying");<BR>if(from_gw())<BR>{<BR>$avp(s:caller_uuid) = "0";<BR><BR>xlog("L_INFO", "Call from PSTN' - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR>setflag(23);<BR>}<BR>else<BR>{<BR>if(allow_trusted())<BR>{<BR>if(is_avp_set("$avp(s:peer_uuid)/s"))<BR>{<BR># use tag-column from trusted-table as uuid for this caller<BR>avp_copy("$avp(s:peer_uuid)", "$avp(s:caller_uuid)/d");<BR>}<BR>else<BR>{<BR># if no uuid is set, use "0" as default uuid<BR>$avp(s:caller_uuid) = "0";<BR>}<BR><BR>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");<BR>if(!is_domain_local("$rd"))<BR>{<BR><BR>xlog("L_INFO", "Rejecting peering attempt with non-local request domain - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR>sl_send_reply("403", "Relaying Denied");<BR>exit;<BR>}<BR>setflag(23);<BR>}<BR>else<BR>{<BR># if(!proxy_authorize("", "subscriber")) <BR># {<BR># <BR># xlog("L_INFO", "Proxy authentication failed - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR># proxy_challenge("", "0");<BR># exit;<BR># }<BR># if(!check_from()) <BR># {<BR># <BR># xlog("L_INFO", "Spoofed From-URI detected - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR># sl_send_reply("403", "Spoofed From-URI Detected");<BR># exit;<BR># }<BR>}<BR>}<BR><BR>if(nat_uac_test("19")) <BR>{<BR>fix_nated_contact();<BR>setbflag(6);<BR>}<BR><BR>route(9);<BR>}<BR>########################################################################<BR># Request route 'invite-find-callee'<BR>########################################################################<BR>route[9]<BR>{<BR>if(alias_db_lookup("dbaliases"))<BR>{<BR><BR>xlog("L_INFO", "Callee was aliased - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR>}<BR><BR>route(2);<BR>if(!is_domain_local("$rd"))<BR>{<BR>setflag(20);<BR>$avp(s:callee_uuid) = "0";<BR><BR>route(11);<BR>}<BR>avp_delete("$avp(s:callee_uuid)");<BR>avp_db_query("select id from subscriber where username = '$rU'", "$avp(s:callee_uuid)");<BR>if(is_avp_set("$avp(s:callee_uuid)"))<BR>{<BR><BR>xlog("L_INFO", "Callee is local, uuid='$avp(s:callee_uuid)' - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR>route(10);<BR>}<BR>else<BR>{<BR>$avp(s:callee_uuid) = "0";<BR><BR>xlog("L_INFO", "Callee is not local - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR>route(11);<BR>}<BR>exit;<BR><BR>}<BR>########################################################################<BR># Request route 'invite-to-internal'<BR>########################################################################<BR>route[10]<BR>{<BR>route(4);<BR>if(!lookup("location")) <BR>{<BR><BR>xlog("L_INFO", "Local user offline - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR>sl_send_reply("404", "User Offline");<BR>}<BR>else<BR>{<BR><BR>xlog("L_INFO", "Local user online - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR>route(7);<BR>}<BR>exit;<BR><BR>}<BR>########################################################################<BR># Request route 'invite-to-external'<BR>########################################################################<BR>route[11]<BR>{<BR>if(isflagset(20))<BR>{<BR><BR>xlog("L_INFO", "Call to foreign domain - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR>route(7);<BR>exit;<BR>}<BR><BR>route(13);<BR>if(!isflagset(23))<BR>{<BR># don't allow calls relaying from PSTN to PSTN, if not explicitely forwarded<BR>if(uri =~ "^sip:[0-9]+@")<BR>{<BR># only route numeric users to PSTN<BR>if(!load_gws())<BR>{<BR><BR>xlog("L_ERR", "Error loading PSTN gateways - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR>sl_send_reply("503", "PSTN Termination Currently Unavailable");<BR>exit;<BR>}<BR>if(!next_gw())<BR>{<BR><BR>xlog("L_ERR", "No PSTN gateways available - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR>sl_send_reply("503", "PSTN Termination Currently Unavailable");<BR>exit;<BR>}<BR>setflag(21);<BR><BR>t_on_failure("1");<BR>route(7);<BR>}<BR>}<BR><BR>xlog("L_INFO", "Call to unknown user - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR>sl_send_reply("404", "User Not Found");<BR>exit;<BR><BR>}<BR>########################################################################<BR># Request route 'normalize-e164'<BR>########################################################################<BR>route[12]<BR>{<BR># European numbering plans look like this:<BR># CC = country code (i.e. 43 for Austria)<BR># NDC = national destination code (i.e. 1 for Vienna)<BR># SN = subscriber number (i.e. 4001234)<BR># <BR># CC + NDC + SN, i.e. 4314001234<BR>#<BR># Within the same CC+NDC, it can be omitted, so if<BR># +4314001234 wants to call +4315002345, one can dial<BR># just 5002345.<BR>#<BR># Within the same CC, CC can be ommitted and a "0" is prefixed<BR># to NDC, so if +4314001234 wants to call +4326003456, <BR># one can dial 026003456.<BR>#<BR># For international calls, either "00" or + is prefixed, like<BR># +49123456780 or 0049123456789.<BR>#<BR>avp_delete("$avp(s:orig_callee_user)/g");<BR>$avp(s:orig_callee_user) = $rU;<BR>if(uri =~ "^sip:(\+[1-9])?[0-9]+@")<BR>{<BR># looks like a PSTN number<BR>if(uri =~ "^sip:0[1-9][0-9]+@")<BR>{<BR># we have format 0+NDC+SN<BR>strip(1);<BR>prefix("+44");<BR>}<BR>else if(uri =~ "^sip:00[1-9]+@")<BR>{<BR># we have format 00 + CC + NDC + SN<BR>strip(2);<BR>prefix("+");<BR>}<BR>else if(!uri =~ "^sip:\+[1-9][0-9]+@")<BR>{<BR># unknown format, maybe NDC wasn't added before?<BR><BR>xlog("L_INFO", "Not normalized callee '$avp(s:orig_callee_user)' to E.164 format - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR>return(-1);<BR>}<BR># else we have "+" + CC + NDC + SN<BR><BR>xlog("L_INFO", "Normalized callee '$avp(s:orig_callee_user)' to E.164 format '$rU' - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR>return(1);<BR>}<BR>else<BR>{<BR><BR>xlog("L_INFO", "Not normalized callee '$avp(s:orig_callee_user)' to E.164 format - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR>return(-1);<BR>}<BR><BR>}<BR>########################################################################<BR># Request route 'lookup-enum'<BR>########################################################################<BR>route[13]<BR>{<BR>route(12);<BR>if($rc == 1)<BR>{<BR>if(enum_query("e164.org."))<BR>{<BR># TODO: do GW fallback (load gws, set failure-route)?<BR><BR>xlog("L_INFO", "ENUM query succeeded - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR>route(7);<BR>exit;<BR>}<BR>else<BR>{<BR><BR>xlog("L_INFO", "ENUM query failed - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR># ENUM query failed, revert $rU<BR>avp_pushto("$ru/username", "$avp(s:orig_callee_user)");<BR>}<BR>}<BR><BR>}<BR>########################################################################<BR># Request route 'base-route-local'<BR>########################################################################<BR>route[14]<BR>{<BR>t_on_reply("1");<BR>if(t_check_trans())<BR>{<BR><BR>xlog("L_INFO", "Request leaving server - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR>if(!t_relay())<BR>{<BR>sl_reply_error();<BR>}<BR>}<BR>else<BR>{<BR><BR>xlog("L_INFO", "Dropping mis-routed request - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR>}<BR>exit;<BR><BR>}<BR>########################################################################<BR># Request route 'base-route-generic'<BR>########################################################################<BR>route[15]<BR>{<BR>xlog("L_INFO", "Method not supported - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR>sl_send_reply("501", "Method Not Supported Here");<BR>exit;<BR><BR>}<BR>########################################################################<BR># Request route 'base-filter-failover'<BR>########################################################################<BR>route[16]<BR>{<BR>if(!t_check_status("408|500|503"))<BR>{<BR><BR>xlog("L_INFO", "No failover routing needed for this response code - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR>route(5);<BR>exit;<BR>}<BR><BR>}<BR><STRONG>#########################################################################</STRONG><BR><STRONG># Presence</STRONG><BR><STRONG>#########################################################################</STRONG><BR><STRONG>route[17]</STRONG><BR><STRONG>{</STRONG><BR><STRONG># if(nat_uac_test("19") || search("^Route:.*;nat=yes"))</STRONG><BR><STRONG># {</STRONG><BR><STRONG># fix_nated_contact();</STRONG><BR><STRONG># setbflag(6);</STRONG><BR><STRONG># }</STRONG><BR><STRONG>&nbsp;</STRONG><BR><STRONG>if (!t_newtran())</STRONG><BR><STRONG>{</STRONG><BR><STRONG>sl_reply_error();</STRONG><BR><STRONG>exit;</STRONG><BR><STRONG>};</STRONG><BR><STRONG>#if(is_method("PUBLISH"))</STRONG><BR><STRONG>#{</STRONG><BR><STRONG># xlog("L_INFO", "PUBLISH - Process Publish Request - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");</STRONG><BR><STRONG># handle_publish();</STRONG><BR><STRONG># t_release();</STRONG><BR><STRONG>#}</STRONG><BR><STRONG>if(is_method("PUBLISH"))</STRONG><BR><STRONG>{</STRONG><BR><STRONG>if($hdr(Sender)!= NULL)</STRONG><BR><STRONG>handle_publish("$hdr(Sender)");</STRONG><BR><STRONG>else</STRONG><BR><STRONG>handle_publish();</STRONG><BR><STRONG>t_release();</STRONG><BR><STRONG>}</STRONG><BR><STRONG>if(is_method("SUBSCRIBE"))</STRONG><BR><STRONG>{</STRONG><BR><STRONG>handle_subscribe();</STRONG><BR><STRONG>xlog("L_INFO", "SUBSCRIBE - Process Subscribe Request - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");</STRONG><BR><STRONG>t_release();</STRONG><BR><STRONG>}</STRONG><BR><STRONG>exit;</STRONG><BR><STRONG>}</STRONG><BR>########################################################################<BR># SEND MESSAGES<BR>########################################################################<BR>route[18]<BR>{<BR>if (!lookup("location")) <BR>{<BR>switch ($retcode) <BR>{<BR>case -1:<BR>case -3:<BR>t_newtran();<BR>t_reply("404", "Not Found");<BR>exit;<BR>case -2:<BR>sl_send_reply("405", "Method Not Allowed");<BR>exit;<BR>}<BR>}<BR>if (!t_relay()) {<BR>sl_reply_error();<BR>};<BR>exit;<BR>}<BR>########################################################################<BR># Reply route 'base-standard-reply'<BR>########################################################################<BR>onreply_route[1]<BR>{<BR>xlog("L_INFO", "Reply - S=$rs D=$rr F=$fu T=$tu IP=$si ID=$ci\n");<BR>exit;<BR><BR>}<BR>########################################################################<BR># Reply route 'base-nat-reply'<BR>########################################################################<BR>onreply_route[2]<BR>{<BR>xlog("L_INFO", "NAT-Reply - S=$rs D=$rr F=$fu T=$tu IP=$si ID=$ci\n");<BR>if(nat_uac_test("1"))<BR>{<BR>fix_nated_contact();<BR>}<BR>if(isbflagset(6) &amp;&amp; status=~"(180)|(183)|2[0-9][0-9]") <BR>{<BR>if(!search("^Content-Length:[ ]*0"))<BR>{<BR>use_media_proxy();<BR>}<BR>}<BR>exit;<BR><BR>}<BR>########################################################################<BR># Failure route 'pstn-failover'<BR>########################################################################<BR>failure_route[1]<BR>{<BR>xlog("L_INFO", "Failure route for PSTN entered - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR>route(16);<BR>if(!next_gw())<BR>{<BR><BR>xlog("L_ERR", "Failed to select next PSTN gateway - M=$rm RURI=$ru F=$fu T=$tu IP=$si ID=$ci\n");<BR>route(5);<BR>exit;<BR>}<BR><BR>t_on_failure("1");<BR>route(7);<BR>}<BR>########################################################################<BR># Failure route 'base-standard-failure'<BR>########################################################################<BR>failure_route[2]<BR>{<BR>route(16);<BR>route(5);<BR>}<BR><br /><hr />Think you know your TV, music and film? <a href='https://www.searchcharades.com' target='_new'>Try Search Charades!</a></body>
</html>