Proxy, presence and x-lite

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Proxy, presence and x-lite

Alexander-4
  Hi all!

  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.
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:
  1) What options regarding to presence should be configured in X-Lite (Peer-to-peer, Presence agent)?
  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.

  My OpenSips configuration file is attached to this messages. Note, that authorization is done via db_oracle, and in presence module I try to use db_berkeley. It's done due
to some reasons.

  Thanks in advance!


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users

opensips.cfg (17K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Proxy, presence and x-lite

Alexander-4
  Hi all! 

  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.

  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:
  1) What options regarding to presence should be configured in X-Lite (Peer-to-peer, Presence agent)?
  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.

  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. 

  Thanks in advance!

  ===============================================================================

# Run rtpproxy like this:
# /usr/local/bin/rtpproxy -l xx.xxx.xxx.xx -s udp:*:7877 -F

# For details, visit:
# - http://voip.rus.net
# - http://voip.rus.net/tiki-index.php?page=Sip+Express+Router

# ------------------ module loading ---------------------------------

# Set module path.
# ----------------
mpath="/usr/local/lib/opensips/modules/"

debug        = 2
fork         = yes
log_stderror = no
log_facility = LOG_DAEMON
log_name     = "opensips"

listen       = udp:xx.xxx.xxx.xx:5060

dns          = no    # (cmd. line: -r)
rev_dns      = no    # (cmd. line: -R)


# ------------------- Load modules  ----------------------------------

loadmodule "db_oracle.so"
loadmodule "db_berkeley.so"
loadmodule "sl.so"
loadmodule "tm.so"
loadmodule "rr.so"
loadmodule "maxfwd.so"
loadmodule "usrloc.so"
loadmodule "registrar.so"
loadmodule "auth.so"
loadmodule "auth_db.so"
loadmodule "uri.so"
loadmodule "uri_db.so"
loadmodule "nathelper.so"
loadmodule "nat_traversal.so"
loadmodule "textops.so"
loadmodule "dialog.so"
loadmodule "xlog.so"
loadmodule "uac.so"
loadmodule "avpops.so"
loadmodule "presence.so"
loadmodule "presence_mwi.so"
loadmodule "presence_xml.so"
loadmodule "xcap_client.so"


# ------------------- Set module-specific parameters -----------------

# usrloc params
# -------------
modparam("usrloc",    "db_mode",   0)
modparam("usrloc",    "nat_bflag", 6)

# nathelper params
# ----------------
modparam("nathelper", "natping_interval", 20)
modparam("nathelper", "ping_nated_only",  1)
modparam("nathelper", "rtpproxy_sock",    "udp:xx.xxx.xxx.xx:7877")
modparam("nathelper", "received_avp",     "$avp(i:42)")

# nat_traversal params
# --------------------
modparam("nat_traversal", "keepalive_interval",   30)
modparam("nat_traversal", "keepalive_method",     "NOTIFY")
modparam("nat_traversal", "keepalive_state_file", "/var/run/opensips/keepalive_state")

# dialog params
# -------------
modparam("dialog", "dlg_flag", 4)

# rr params
# ---------
# add value to ;lr param to make some broken UAs happy
modparam("rr", "enable_full_lr", 1)

# auth db params
# --------------
modparam("auth_db", "db_url",        "oracle://user:password@localhost/work")
modparam("auth_db", "calculate_ha1", yes)
modparam("auth_db", "use_domain",    0)

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

# uri db params
# -------------
modparam("uri_db", "use_uri_table", 0)
modparam("uri_db", "db_url",        "")

# registrar params
# ----------------
modparam("registrar", "default_expires", 60)
modparam("registrar", "min_expires",     30)
modparam("registrar", "received_avp",    "$avp(s:rcv)")

# presense params
# ---------------
modparam("presence",     "db_url", "berkeley:///usr/local/etc/opensips/db_berkeley/")
modparam("presence_xml", "force_active", 1)
modparam("presence", "server_address", "sip:xx.xxx.xxx.xx:5060")
modparam("presence", "fallback2db", 0)
modparam("presence", "presentity_table", "presentity")
modparam("presence", "active_watchers_table", "active_watchers")
modparam("presence", "watchers_table", "watchers")
modparam("presence", "clean_period", 100)
modparam("presence", "to_tag_pref", 'pres')
modparam("presence", "expires_offset", 10)

# xcap params
# -----------
modparam("xcap_client", "db_url", "berkeley:///usr/local/etc/opensips/db_berkeley/")
modparam("xcap_client", "xcap_table","xcap")

# presense_xml params
# -------------------
modparam("presence_xml", "db_url", "berkeley:///usr/local/etc/opensips/db_berkeley/")
modparam("presence_xml", "force_active", 0)
modparam("presence_xml", "xcap_table", "xcap")
modparam("presence_xml", "pidf_manipulation", 1)
modparam("presence_xml", "integrated_xcap_server", 1)

# -------------------------  request routing logic -------------------

# main routing logic

route
{
    xlog("L_DBG", "Main route\n");

    # Prevent buffer overflow.
    # ------------------------
    if (msg:len > max_len)
    {
        sl_send_reply("513", "Message Overflow");
        return(0);
    };

    # Attempt to prevent eternal loop when failures occur.
    # ----------------------------------------------------
    if (!mf_process_maxfwd_header("10"))
    {
        sl_send_reply("483", "Too Many Hops");
        return(0);
    };

    # Record route and NAT preset.
    # ----------------------------
    if (method == "INVITE" && client_nat_test("3"))
    {
    xlog("L_INFO", "DBG [$Tf] Got INVITE from NATed client\n");
       
        # Put the string into Record-Route section (Switch's IP and SIP-port).
        # -----------------------------------------------------------------------
    record_route_preset("xx.xxx.xxx.xx:5060;nat=yes");
    }
    else if (method != "REGISTER" && method != "MESSAGE")
    {
        # Insert OpenSips address as a via header entry in the SIP message.
        # -----------------------------------------------------------------
        record_route();
    }

    # Call tear down.
    # ---------------
    if ((method == "BYE" || method == "CANCEL"))
    {
    xlog("L_INFO", "DBG [$Tf] Unforcing RTP proxy - call tear down\n");
       
        # Stop RTP proxy session for current call.
        # ----------------------------------------
        unforce_rtp_proxy();
    }

    # Loose Route.
    # loose_route() returns true if route headers are present.
    # It also removes any route header entries that match OpenSips own address(es).
    # -----------------------------------------------------------------------------
    if (loose_route())
    {
        if (has_totag() && (method == "INVITE" || method == "ACK"))
    {
            if (client_nat_test("3") || search("^Route:.*;nat=yes"))
        {
                setflag(6);
        force_rtp_proxy();
            };
        };

        route(1);
        return(0);
    };

    # Call type processing.
    # ---------------------
    if (uri != myself)
    {
        route(1);
        return(0);
    };

    # Incoming messages handling.
    # ---------------------------
    if (uri == myself)
    {
        if (method == "BYE")
    {
            route(4);
            return(0);
        }
    else if (method == "CANCEL")
    {
            route(4);
            return(0);
        }
    else if (method == "INVITE")
    {
            route(3);
            return(0);
        }
    else  if (method == "REGISTER")
    {
            route(2);
            return(0);
        }
    else if (method == "OPTIONS")
    {
            sl_send_reply("200", "Got it");
            return(0);
        }
    else if (method == "SUBSCRIBE" || method == "PUBLISH" || method == "NOTIFY")
    {
        route(5);
            return(0);
    }
    else if (method == "MESSAGE")
    {
        xdbg("script: message not for room, from [$fu] r-uri [$ru] msg [$rb]\n");
        if (!lookup("location"))
        {
            sl_send_reply("404", "not found");
            return(0);
        }
       
        t_relay();
   
        return(0);
    }
    };
   
    route(1);
}


# Default Message Handling
# -----------------------
route[1]
{
    xlog("L_DBG", "Route 1\n");

    t_on_reply("1");
   
    if (!t_relay())
    {
        if ((method == "INVITE" || method == "ACK") && isflagset(6))
    {
        xlog("L_INFO", "DBG [$Tf] Unforcing RTP proxy - NAT flag is set\n");
            unforce_rtp_proxy();
    }

        sl_reply_error();
    };
}


# REGISTER Message Handling
# -------------------------
route[2]
{
    xlog("L_DBG", "Route 4\n");

    if (!search("^Contact:\ +\*") && client_nat_test("7"))
    {
    xlog("L_INFO", "DBG [$Tf] Client registers behind NAT - fix URI and force rport\n");
        setflag(6);
       
        # Create URI consisting of the source IP, port, and protocol and store
        # the URI in an Attribute-Value-Pair. The URI will be appended as "received"
        # parameter to Contact in 200 OK and registrar will store it in the user location database.
        # -----------------------------------------------------------------------------------------
        fix_nated_register();
       
        # Add public port to the top-most Via header.
        # -------------------------------------------
        force_rport();
   
        # Ping NAT endpoints to keep them alive.
        # --------------------------------------
        nat_keepalive();
    };

    sl_send_reply("100", "Trying");

    # Perform authorization.
    # ----------------------
    if (!www_authorize("", "subscriber"))
    {
        www_challenge("","0");
        return(0);
    };
   
    if (!check_to())
    {
        sl_send_reply("401", "Unauthorized");
        return(0);
    };
   
    consume_credentials();
   
    if (!save("location"))
        sl_reply_error();
}

# INVITE Message Handling
# -----------------------
route[3]
{
    xlog("L_DBG", "Route 3\n");

    # Test for NAT, perhaps fix headers
    if (client_nat_test("3"))
    {
    xlog("L_DBG", "DBG [$Tf] NAT detected for caller\n");

        setflag(7);

        force_rport();

    force_rtp_proxy();
       
        # Rewrite Contact header to contain request's source address:port.
        # ----------------------------------------------------------------
        fix_nated_contact();
    }
   
    xlog("L_INFO", "Vars: fd = $fd, fu = $fu, od = $od, pd = $pd, rd = $rd, si = $si\n");

    # Calls from every IP (except of TelcoBridges's one) go to TelcoBridges.
    # ----------------------------------------------------------------------
    if ((uri =~ "sip:*@*") && ($si != "xx.xxx.xxx.xxy"))
    {
    xlog("L_DBG", "DBG [$Tf] Trying to authorize caller\n");

        # Perform authorization.
        # ----------------------   
        if (!proxy_authorize("", "subscriber"))
    {
        proxy_challenge("", "0");
            return(0);
        }
    else if (!check_from())
    {
        sl_send_reply("403", "Use From ID");
            return(0);
        };

        consume_credentials();
   
    xlog("L_DBG", "DBG [$Tf] Redirecting call to TelcoBridges\n");
    rewritehostport("xx.xxx.xxx.xxy:5061");
    route(1);
    return(0);
    }

    # Rewrite SDP body to ensure that media is passed through an RTP proxy.
    # ---------------------------------------------------------------------
    force_rtp_proxy();

    xlog("L_DBG", "DBG [$Tf] Try to find user in usrloc\n");
   
    if (!lookup("location"))
    {
        sl_send_reply("404", "User not found, sorry");
        return(0);
    }

    # If NAT is previously detected, proxy
    if (isflagset(6) || isflagset(7))
    {
    xlog("L_DBG", "DBG [$Tf] NAT flag was previously set, force the use of RTP proxy\n");
        force_rtp_proxy();
    }

    route(1);
}


# CANCEL and BYE Message Handling
# ----------------------------------
route[4]
{
    xlog("L_DBG", "Route 4\n");

    if (client_nat_test("3"))
    {
    xlog("L_DBG", "DBG [$Tf] Handling CANCEL or BYE for NATed client, unforcing RTP proxy\n");
        setflag(7);
        force_rport();
        fix_nated_contact();
    unforce_rtp_proxy();
    };
   
    route(1);

}

# SUBSCRIBE and PUBLISH Message Handling
# --------------------------------------
route[5]
{
    xlog("L_DBG", "Route 5\n");
   
    if (!t_newtran())
    {
    xlog("L_DBG", "Failed to create transaction\n");
    sl_reply_error();
    exit;
    }
   
    if (is_method("PUBLISH"))
    {
        xlog("L_DBG", "Route 5 - PUBLISH \n");
        handle_publish();
        t_release();
    } 
    else if (is_method("SUBSCRIBE"))
    {
        xlog("L_DBG", "Route 5 - SUBSCRIBE\n");
        handle_subscribe();
        t_release();
    }
    else if (is_method("NOTIFY"))
    {
    xlog("L_DBG", "Route 5 - NOTIFY\n");
    t_reply("200", "OK");
    exit;       
    }
   
   
    exit;
}

onreply_route[1]
{
    xlog("L_DBG", "OnReply route\n");

    if ((isflagset(6) || isflagset(7)) && (status =~ "(180)|(183)|2[0-9][0-9]"))
    {
    xlog("L_DBG", "DBG [$Tf] OnReply: NAT flags are set\n");
   
        if (!search("^Content-Length:[ ]*0"))
    {
        xlog("L_DBG", "DBG [$Tf] Callee answered behind NAT, forcing RTP proxy\n");
   
        force_rtp_proxy();
    }
    };
   
    if (nat_uac_test("19") && search("Content-Type: application/sdp"))
    {
        xlog("L_DBG", "DBG [$Tf] OnReply: callee is behind NAT, forcing RTP proxy on reply\n");
        force_rtp_proxy();
    }
   
    xlog("L_DBG", "DBG [$Tf] Callee has answered\n");
   
    if (isflagset(6) || isflagset(7))
    {
    xlog("L_DBG", "DBG [$Tf] OnReply: callee answered behind NAT, fix it\n");
    fix_nated_contact();
    };
}



_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Proxy, presence and x-lite

Anca Vamanu-2
In reply to this post by Alexander-4
Hi Alexander,

I have looked through your configuration file and there is a big mess in
there in the presence part :).
Please read the presence tutorial from opensips site:
http://www.opensips.org/index.php?n=Resources.PresenceServer. Since you
say that you use xlite it means that you don't need support for privacy
rules, so no xcap server. The configuration that matches your need is
the one described at point 1 in the Configuration section. The presence
part from your configuration file should resemble the one from this
example: http://www.opensips.org/index.php?n=Resources.SimplePresConfig.
<http://www.opensips.org/index.php?n=Resources.SimplePresConfig>
To give you also some indications of what is wrong now:
- you should set the force_active parameter in presence_xml module to 1
( now you set it twice, once to 1 and later to 0)
- you don't need xcap_client module
- it's useless to set integrated_xcap_server and xcap_table parameters
in presence_xml module ( you shouldn't have nothing related to xcap in
your configuration file)

I noticed that you have set all the parameters for the modules, some to
their default value. There is probably something that you don't know: in
the modules documentation if a default value is mentioned for a
parameter it means that the parameter already has that value, and that
you should set it only if you what to change it.

As for xlite, you have to configure it to use Presence Agent operation mode.

regards,
Anca



Alexander wrote:

>   Hi all!
>
>   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.
> 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:
>   1) What options regarding to presence should be configured in X-Lite
> (Peer-to-peer, Presence agent)?
>   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.
>
>   My OpenSips configuration file is attached to this messages. Note,
> that authorization is done via db_oracle, and in presence module I try
> to use db_berkeley. It's done due
> to some reasons.
>
>   Thanks in advance!
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> [hidden email]
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>  


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Proxy, presence and x-lite

Alexander-4
  Thank you very much, it works now :)

  Also I've switched to mysql from berkeley - it seems there're some bugs in berkeley db engine.

2009/4/13 Anca Vamanu <[hidden email]>
Hi Alexander,

I have looked through your configuration file and there is a big mess in there in the presence part :).
Please read the presence tutorial from opensips site: http://www.opensips.org/index.php?n=Resources.PresenceServer. Since you say that you use xlite it means that you don't need support for privacy rules, so no xcap server. The configuration that matches your need is the one described at point 1 in the Configuration section. The presence part from your configuration file should resemble the one from this example: http://www.opensips.org/index.php?n=Resources.SimplePresConfig. <http://www.opensips.org/index.php?n=Resources.SimplePresConfig>
To give you also some indications of what is wrong now:
- you should set the force_active parameter in presence_xml module to 1 ( now you set it twice, once to 1 and later to 0)
- you don't need xcap_client module
- it's useless to set integrated_xcap_server and xcap_table parameters in presence_xml module ( you shouldn't have nothing related to xcap in your configuration file)

I noticed that you have set all the parameters for the modules, some to their default value. There is probably something that you don't know: in the modules documentation if a default value is mentioned for a parameter it means that the parameter already has that value, and that you should set it only if you what to change it.

As for xlite, you have to configure it to use Presence Agent operation mode.

regards,
Anca



Alexander wrote:
 Hi all!

 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.
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:
 1) What options regarding to presence should be configured in X-Lite (Peer-to-peer, Presence agent)?
 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.

 My OpenSips configuration file is attached to this messages. Note, that authorization is done via db_oracle, and in presence module I try to use db_berkeley. It's done due
to some reasons.

 Thanks in advance!

------------------------------------------------------------------------

_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
 



_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Proxy, presence and x-lite

Bogdan-Andrei Iancu
Hi Alexander,

that may be true as the Berkeley engine is not so used. But if you can
across any but, feel free to report it anytime.

Regards,
Bogdan

Alexander wrote:

>   Thank you very much, it works now :)
>
>   Also I've switched to mysql from berkeley - it seems there're some
> bugs in berkeley db engine.
>
> 2009/4/13 Anca Vamanu <[hidden email] <mailto:[hidden email]>>
>
>     Hi Alexander,
>
>     I have looked through your configuration file and there is a big
>     mess in there in the presence part :).
>     Please read the presence tutorial from opensips site:
>     http://www.opensips.org/index.php?n=Resources.PresenceServer.
>     Since you say that you use xlite it means that you don't need
>     support for privacy rules, so no xcap server. The configuration
>     that matches your need is the one described at point 1 in the
>     Configuration section. The presence part from your configuration
>     file should resemble the one from this example:
>     http://www.opensips.org/index.php?n=Resources.SimplePresConfig.
>     <http://www.opensips.org/index.php?n=Resources.SimplePresConfig>
>     To give you also some indications of what is wrong now:
>     - you should set the force_active parameter in presence_xml module
>     to 1 ( now you set it twice, once to 1 and later to 0)
>     - you don't need xcap_client module
>     - it's useless to set integrated_xcap_server and xcap_table
>     parameters in presence_xml module ( you shouldn't have nothing
>     related to xcap in your configuration file)
>
>     I noticed that you have set all the parameters for the modules,
>     some to their default value. There is probably something that you
>     don't know: in the modules documentation if a default value is
>     mentioned for a parameter it means that the parameter already has
>     that value, and that you should set it only if you what to change it.
>
>     As for xlite, you have to configure it to use Presence Agent
>     operation mode.
>
>     regards,
>     Anca
>
>
>
>     Alexander wrote:
>
>          Hi all!
>
>          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.
>         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:
>          1) What options regarding to presence should be configured in
>         X-Lite (Peer-to-peer, Presence agent)?
>          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.
>
>          My OpenSips configuration file is attached to this messages.
>         Note, that authorization is done via db_oracle, and in
>         presence module I try to use db_berkeley. It's done due
>         to some reasons.
>
>          Thanks in advance!
>
>         ------------------------------------------------------------------------
>
>         _______________________________________________
>         Users mailing list
>         [hidden email] <mailto:[hidden email]>
>         http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>          
>
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Users mailing list
> [hidden email]
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>  


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users