<div class="gmail_quote"> Hi all! <br><br> I'm trying to make Opensips 1.4.4 work as proxy and presence server. Proxy, with NAT support, seems to work - calls are redirected, voice is transmitted in both directions.<br>
<br> Now I try to configure presence - it would be nice, if X-Lite shows user's availability and status. So, I've got 2 questions:<br> 1) What options regarding to presence should be configured in X-Lite (Peer-to-peer, Presence agent)?<br>
2) What's wrong and/or missing in my OpenSips configuration file? As I see from logs, SUBSCRIBE, PUBLISH and NOTIFY messages are received by OpenSips, but X-Lite does not show user's availability/status.<br><br>
My OpenSips configuration file is below. Note, that authorization is done via db_oracle, and in presence module I try to use db_berkeley. It's done dueto some reasons. <br><br> Thanks in advance!<br><br> ===============================================================================<br>
<br># Run rtpproxy like this:<br># /usr/local/bin/rtpproxy -l xx.xxx.xxx.xx -s udp:*:7877 -F<br><br># For details, visit:<br># - <a href="http://voip.rus.net">http://voip.rus.net</a><br># - <a href="http://voip.rus.net/tiki-index.php?page=Sip+Express+Router">http://voip.rus.net/tiki-index.php?page=Sip+Express+Router</a><br>
<br># ------------------ module loading ---------------------------------<br><br># Set module path.<br># ----------------<br>mpath="/usr/local/lib/opensips/modules/"<br><br>debug = 2<br>fork = yes<br>
log_stderror = no<br>log_facility = LOG_DAEMON<br>log_name = "opensips"<br><br>listen = udp:xx.xxx.xxx.xx:5060<br><br>dns = no # (cmd. line: -r)<br>rev_dns = no # (cmd. line: -R)<br>
<br><br># ------------------- Load modules ----------------------------------<br><br>loadmodule "db_oracle.so"<br>loadmodule "db_berkeley.so"<br>loadmodule "sl.so"<br>loadmodule "tm.so"<br>
loadmodule "rr.so"<br>loadmodule "maxfwd.so"<br>loadmodule "usrloc.so"<br>loadmodule "registrar.so"<br>loadmodule "auth.so"<br>loadmodule "auth_db.so"<br>loadmodule "uri.so"<br>
loadmodule "uri_db.so"<br>loadmodule "nathelper.so"<br>loadmodule "nat_traversal.so"<br>loadmodule "textops.so"<br>loadmodule "dialog.so"<br>loadmodule "xlog.so"<br>
loadmodule "uac.so"<br>loadmodule "avpops.so"<br>loadmodule "presence.so"<br>loadmodule "presence_mwi.so"<br>loadmodule "presence_xml.so"<br>loadmodule "xcap_client.so"<br>
<br><br># ------------------- Set module-specific parameters -----------------<br><br># usrloc params<br># -------------<br>modparam("usrloc", "db_mode", 0)<br>modparam("usrloc", "nat_bflag", 6)<br>
<br># nathelper params<br># ----------------<br>modparam("nathelper", "natping_interval", 20)<br>modparam("nathelper", "ping_nated_only", 1)<br>modparam("nathelper", "rtpproxy_sock", "udp:xx.xxx.xxx.xx:7877")<br>
modparam("nathelper", "received_avp", "$avp(i:42)")<br><br># nat_traversal params<br># --------------------<br>modparam("nat_traversal", "keepalive_interval", 30)<br>
modparam("nat_traversal", "keepalive_method", "NOTIFY")<br>modparam("nat_traversal", "keepalive_state_file", "/var/run/opensips/keepalive_state")<br><br># dialog params<br>
# -------------<br>modparam("dialog", "dlg_flag", 4)<br><br># rr params<br># ---------<br># add value to ;lr param to make some broken UAs happy<br>modparam("rr", "enable_full_lr", 1)<br>
<br># auth db params<br># --------------<br>modparam("auth_db", "db_url", "oracle://user:password@localhost/work")<br>modparam("auth_db", "calculate_ha1", yes)<br>modparam("auth_db", "use_domain", 0)<br>
<br># auth params<br># -----------<br>modparam("auth", "rpid_suffix", ";party=calling;id-type=subscriber;screen=yes")<br><br># uri db params<br># -------------<br>modparam("uri_db", "use_uri_table", 0)<br>
modparam("uri_db", "db_url", "")<br><br># registrar params<br># ----------------<br>modparam("registrar", "default_expires", 60)<br>modparam("registrar", "min_expires", 30)<br>
modparam("registrar", "received_avp", "$avp(s:rcv)")<br><br># presense params<br># ---------------<br>modparam("presence", "db_url", "berkeley:///usr/local/etc/opensips/db_berkeley/")<br>
modparam("presence_xml", "force_active", 1)<br>modparam("presence", "server_address", "sip:xx.xxx.xxx.xx:5060")<br>modparam("presence", "fallback2db", 0)<br>
modparam("presence", "presentity_table", "presentity")<br>modparam("presence", "active_watchers_table", "active_watchers")<br>modparam("presence", "watchers_table", "watchers")<br>
modparam("presence", "clean_period", 100)<br>modparam("presence", "to_tag_pref", 'pres')<br>modparam("presence", "expires_offset", 10)<br><br># xcap params<br>
# -----------<br>modparam("xcap_client", "db_url", "berkeley:///usr/local/etc/opensips/db_berkeley/")<br>modparam("xcap_client", "xcap_table","xcap")<br><br># presense_xml params<br>
# -------------------<br>modparam("presence_xml", "db_url", "berkeley:///usr/local/etc/opensips/db_berkeley/")<br>modparam("presence_xml", "force_active", 0)<br>modparam("presence_xml", "xcap_table", "xcap")<br>
modparam("presence_xml", "pidf_manipulation", 1)<br>modparam("presence_xml", "integrated_xcap_server", 1)<br><br># ------------------------- request routing logic -------------------<br>
<br># main routing logic<br><br>route<br>{<br> xlog("L_DBG", "Main route\n");<br><br> # Prevent buffer overflow.<br> # ------------------------<br> if (msg:len > max_len)<br> {<br> sl_send_reply("513", "Message Overflow");<br>
return(0);<br> };<br><br> # Attempt to prevent eternal loop when failures occur.<br> # ----------------------------------------------------<br> if (!mf_process_maxfwd_header("10"))<br> {<br>
sl_send_reply("483", "Too Many Hops");<br> return(0);<br> };<br><br> # Record route and NAT preset.<br> # ----------------------------<br> if (method == "INVITE" && client_nat_test("3"))<br>
{<br> xlog("L_INFO", "DBG [$Tf] Got INVITE from NATed client\n");<br> <br> # Put the string into Record-Route section (Switch's IP and SIP-port).<br> # -----------------------------------------------------------------------<br>
record_route_preset("xx.xxx.xxx.xx:5060;nat=yes");<br> }<br> else if (method != "REGISTER" && method != "MESSAGE")<br> {<br> # Insert OpenSips address as a via header entry in the SIP message.<br>
# -----------------------------------------------------------------<br> record_route();<br> }<br><br> # Call tear down.<br> # ---------------<br> if ((method == "BYE" || method == "CANCEL"))<br>
{<br> xlog("L_INFO", "DBG [$Tf] Unforcing RTP proxy - call tear down\n");<br> <br> # Stop RTP proxy session for current call.<br> # ----------------------------------------<br>
unforce_rtp_proxy();<br> }<br><br> # Loose Route.<br> # loose_route() returns true if route headers are present.<br> # It also removes any route header entries that match OpenSips own address(es).<br> # -----------------------------------------------------------------------------<br>
if (loose_route())<br> {<br> if (has_totag() && (method == "INVITE" || method == "ACK"))<br> {<br> if (client_nat_test("3") || search("^Route:.*;nat=yes"))<br>
{<br> setflag(6);<br> force_rtp_proxy();<br> };<br> };<br><br> route(1);<br> return(0);<br> };<br><br> # Call type processing.<br> # ---------------------<br>
if (uri != myself)<br> {<br> route(1);<br> return(0);<br> };<br><br> # Incoming messages handling.<br> # ---------------------------<br> if (uri == myself)<br> {<br> if (method == "BYE")<br>
{<br> route(4);<br> return(0);<br> }<br> else if (method == "CANCEL")<br> {<br> route(4);<br> return(0);<br> }<br> else if (method == "INVITE")<br>
{<br> route(3);<br> return(0);<br> }<br> else if (method == "REGISTER")<br> {<br> route(2);<br> return(0);<br> }<br> else if (method == "OPTIONS")<br>
{<br> sl_send_reply("200", "Got it");<br> return(0);<br> }<br> else if (method == "SUBSCRIBE" || method == "PUBLISH" || method == "NOTIFY")<br>
{<br> route(5);<br> return(0);<br> }<br> else if (method == "MESSAGE")<br> {<br> xdbg("script: message not for room, from [$fu] r-uri [$ru] msg [$rb]\n");<br> if (!lookup("location"))<br>
{<br> sl_send_reply("404", "not found");<br> return(0);<br> }<br> <br> t_relay();<br> <br> return(0);<br> }<br> };<br> <br> route(1);<br>
}<br><br><br># Default Message Handling<br># -----------------------<br>route[1]<br>{<br> xlog("L_DBG", "Route 1\n");<br><br> t_on_reply("1");<br> <br> if (!t_relay())<br> {<br>
if ((method == "INVITE" || method == "ACK") && isflagset(6))<br> {<br> xlog("L_INFO", "DBG [$Tf] Unforcing RTP proxy - NAT flag is set\n");<br> unforce_rtp_proxy();<br>
}<br><br> sl_reply_error();<br> };<br>}<br><br><br># REGISTER Message Handling<br># -------------------------<br>route[2]<br>{<br> xlog("L_DBG", "Route 4\n");<br><br> if (!search("^Contact:\ +\*") && client_nat_test("7"))<br>
{<br> xlog("L_INFO", "DBG [$Tf] Client registers behind NAT - fix URI and force rport\n");<br> setflag(6);<br> <br> # Create URI consisting of the source IP, port, and protocol and store<br>
# the URI in an Attribute-Value-Pair. The URI will be appended as "received"<br> # parameter to Contact in 200 OK and registrar will store it in the user location database.<br> # -----------------------------------------------------------------------------------------<br>
fix_nated_register();<br> <br> # Add public port to the top-most Via header.<br> # -------------------------------------------<br> force_rport();<br> <br> # Ping NAT endpoints to keep them alive.<br>
# --------------------------------------<br> nat_keepalive();<br> };<br><br> sl_send_reply("100", "Trying");<br><br> # Perform authorization.<br> # ----------------------<br>
if (!www_authorize("", "subscriber"))<br> {<br> www_challenge("","0");<br> return(0);<br> };<br> <br> if (!check_to())<br> {<br> sl_send_reply("401", "Unauthorized");<br>
return(0);<br> };<br> <br> consume_credentials();<br> <br> if (!save("location"))<br> sl_reply_error();<br>}<br><br># INVITE Message Handling<br># -----------------------<br>route[3]<br>
{<br> xlog("L_DBG", "Route 3\n");<br><br> # Test for NAT, perhaps fix headers<br> if (client_nat_test("3"))<br> {<br> xlog("L_DBG", "DBG [$Tf] NAT detected for caller\n");<br>
<br> setflag(7);<br><br> force_rport();<br><br> force_rtp_proxy();<br> <br> # Rewrite Contact header to contain request's source address:port.<br> # ----------------------------------------------------------------<br>
fix_nated_contact();<br> }<br> <br> xlog("L_INFO", "Vars: fd = $fd, fu = $fu, od = $od, pd = $pd, rd = $rd, si = $si\n");<br><br> # Calls from every IP (except of TelcoBridges's one) go to TelcoBridges.<br>
# ----------------------------------------------------------------------<br> if ((uri =~ "sip:*@*") && ($si != "xx.xxx.xxx.xxy"))<br> {<br> xlog("L_DBG", "DBG [$Tf] Trying to authorize caller\n");<br>
<br> # Perform authorization.<br> # ---------------------- <br> if (!proxy_authorize("", "subscriber"))<br> {<br> proxy_challenge("", "0");<br> return(0);<br>
}<br> else if (!check_from())<br> {<br> sl_send_reply("403", "Use From ID");<br> return(0);<br> };<br><br> consume_credentials();<br> <br> xlog("L_DBG", "DBG [$Tf] Redirecting call to TelcoBridges\n");<br>
rewritehostport("xx.xxx.xxx.xxy:5061");<br> route(1);<br> return(0);<br> }<br><br> # Rewrite SDP body to ensure that media is passed through an RTP proxy.<br> # ---------------------------------------------------------------------<br>
force_rtp_proxy();<br><br> xlog("L_DBG", "DBG [$Tf] Try to find user in usrloc\n");<br> <br> if (!lookup("location"))<br> {<br> sl_send_reply("404", "User not found, sorry");<br>
return(0);<br> }<br><br> # If NAT is previously detected, proxy<br> if (isflagset(6) || isflagset(7))<br> {<br> xlog("L_DBG", "DBG [$Tf] NAT flag was previously set, force the use of RTP proxy\n");<br>
force_rtp_proxy();<br> }<br><br> route(1);<br>}<br><br><br># CANCEL and BYE Message Handling<br># ----------------------------------<br>route[4]<br>{<br> xlog("L_DBG", "Route 4\n");<br>
<br> if (client_nat_test("3"))<br> {<br> xlog("L_DBG", "DBG [$Tf] Handling CANCEL or BYE for NATed client, unforcing RTP proxy\n");<br> setflag(7);<br> force_rport();<br>
fix_nated_contact();<br> unforce_rtp_proxy();<br> };<br> <br> route(1);<br><br>}<br><br># SUBSCRIBE and PUBLISH Message Handling<br># --------------------------------------<br>route[5]<br>{<br> xlog("L_DBG", "Route 5\n");<br>
<br> if (!t_newtran())<br> {<br> xlog("L_DBG", "Failed to create transaction\n");<br> sl_reply_error();<br> exit;<br> }<br> <br> if (is_method("PUBLISH"))<br> {<br>
xlog("L_DBG", "Route 5 - PUBLISH \n");<br> handle_publish();<br> t_release();<br> } <br> else if (is_method("SUBSCRIBE"))<br> {<br> xlog("L_DBG", "Route 5 - SUBSCRIBE\n");<br>
handle_subscribe();<br> t_release();<br> }<br> else if (is_method("NOTIFY"))<br> {<br> xlog("L_DBG", "Route 5 - NOTIFY\n");<br> t_reply("200", "OK");<br>
exit; <br> }<br> <br> <br> exit; <br>}<br><br>onreply_route[1]<br>{<br> xlog("L_DBG", "OnReply route\n");<br><br> if ((isflagset(6) || isflagset(7)) && (status =~ "(180)|(183)|2[0-9][0-9]"))<br>
{<br> xlog("L_DBG", "DBG [$Tf] OnReply: NAT flags are set\n");<br> <br> if (!search("^Content-Length:[ ]*0"))<br> {<br> xlog("L_DBG", "DBG [$Tf] Callee answered behind NAT, forcing RTP proxy\n");<br>
<br> force_rtp_proxy();<br> }<br> };<br> <br> if (nat_uac_test("19") && search("Content-Type: application/sdp"))<br> {<br> xlog("L_DBG", "DBG [$Tf] OnReply: callee is behind NAT, forcing RTP proxy on reply\n");<br>
force_rtp_proxy();<br> }<br> <br> xlog("L_DBG", "DBG [$Tf] Callee has answered\n");<br> <br> if (isflagset(6) || isflagset(7))<br> {<br> xlog("L_DBG", "DBG [$Tf] OnReply: callee answered behind NAT, fix it\n");<br>
fix_nated_contact();<br> };<br>}<br><br></div><br>