[Serusers] Mediaproxy -- pls help!

yy lim yanyu_lim at yahoo.com.sg
Mon Aug 1 10:38:12 CEST 2005


Hi guys,

I'm trying to get my mediaproxy working without much
success.

Both mediaproxy and ser are installed on the same
machine, i.e. 201.23.13.145 for example. SER is
listening on port 5060, and mediaproxy is set up as
below. 

Please kindly advise.

Rgrds,
Zan

-----
Mediaproxy.ini
------

[MediaProxy]
start = yes
socket = /var/run/mediaproxy.sock
group = ser
listen = 201.23.13.145:5062
allow = any
proxyIP = 201.23.13.145
portRange = 5062:5064
TOS = 0xb8
idleTimeout = 60
holdTimeout = 3600
forceClose = 0
accounting = off

-------
ser.cfg
-------

debug=3
fork=yes
listen=201.23.13.145
log_stderror=yes
check_via=no    # (cmd. line: -v)
dns=no           # (cmd. line: -r)
rev_dns=no      # (cmd. line: -R)
fifo="/tmp/ser_fifo"
fifo_db_url="mysql://ser:XXXXX@localhost/ser"
# ------------------ module loading
----------------------------------

# Uncomment this if you want to use SQL database
loadmodule "/usr/local/lib/ser/modules/mysql.so"
loadmodule "/usr/local/lib/ser/modules/sl.so"
loadmodule "/usr/local/lib/ser/modules/tm.so"
loadmodule "/usr/local/lib/ser/modules/rr.so"
loadmodule "/usr/local/lib/ser/modules/maxfwd.so"
loadmodule "/usr/local/lib/ser/modules/usrloc.so"
loadmodule "/usr/local/lib/ser/modules/registrar.so"
loadmodule "/usr/local/lib/ser/modules/auth.so"
loadmodule "/usr/local/lib/ser/modules/auth_db.so"
loadmodule "/usr/local/lib/ser/modules/uri.so"
loadmodule "/usr/local/lib/ser/modules/uri_db.so"
loadmodule "/usr/local/lib/ser/modules/exec.so"
loadmodule "/usr/local/lib/ser/modules/domain.so"
loadmodule "/usr/local/lib/ser/modules/permissions.so"
loadmodule "/usr/local/lib/ser/modules/acc.so"

# -- mediaproxy NAT modules ---
loadmodule "/usr/local/lib/ser/modules/mediaproxy.so"
loadmodule "/usr/local/lib/ser/modules/nathelper.so"
loadmodule "/usr/local/lib/ser/modules/textops.so"
loadmodule "/usr/local/lib/ser/modules/avpops.so"

# ----------------- setting module-specific parameters
---------------

# -- auth_radius params --
modparam("auth_db|uri_db|usrloc", "db_url",
"mysql://ser:XXXXXX@localhost/ser")
modparam("acc", "db_url",
"mysql://ser:XXXXXX@localhost/ser")

# -- usrloc params --
# store user location in memory, not using database
modparam("usrloc", "db_mode", 0)

# -- auth params --
# Uncomment if you are using auth module
#
modparam("auth_db", "calculate_ha1", 1)
#
# If you set "calculate_ha1" parameter to yes (which
true in this config),
# uncomment also the following parameter)
#
modparam("auth_db", "password_column", "password")

# mysql accounting
# -- acc params --
modparam("acc", "db_flag", 1)
modparam("acc", "db_missed_flag", 1)
modparam("acc", "failed_transactions", 1)
# -- tm params --
# set time for which ser will be waiting for a final
response;
# fr_inv_timer sets value for INVITE transactions,
# fr_timer for all others
modparam("tm","fr_inv_timer",15)
modparam("tm","fr_timer",10)
modparam("tm","fr_inv_timer_avp", "inv_timeout")
#modparam("permissions", "db_mode", 1)
#modparam("permissions", "trusted_table", "trusted")

# -- Mediaproxy params --
modparam("nathelper", "rtpproxy_disable", 1)
modparam("nathelper", "natping_interval", 0)

modparam("mediaproxy","natping_interval", 30)
modparam("mediaproxy","mediaproxy_socket",
"/var/run/mediaproxy.sock")
modparam("mediaproxy","sip_asymmetrics","/usr/local/etc/ser/sip-clients")
modparam("mediaproxy","rtp_asymmetrics","/usr/local/etc/ser/rtp-clients")

modparam("registrar", "nat_flag", 6)

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

route{
        # -----------------------------
        #       Sanity check
        # -----------------------------

        # initial sanity checks -- messages with
        # max_forwards==0, or excessively long
requests
        if (!mf_process_maxfwd_header("10"))
        {
                sl_send_reply("483","Too Many Hops");
                break;
        };

        if ( msg:len > max_len )
        {
                sl_send_reply("513", "Message too
big");
                break;
        };

        # -----------------------------
        #       Record Route Section
        # -----------------------------

        # perform NAT check
        if (method=="INVITE" && client_nat_test("3"))
        {
               
record_route_preset("201.23.13.145:5060;nat=yes");
                log(1,"Invite + NAT test- Record
Route\n");
        }

        # we record-route all messages -- to make sure
that
        # subsequent messages will go through our
proxy; that's
        # particularly good if upstream and downstream
entities
        # use different transport protocol

        else if(method!="REGISTER")
        {
                record_route();
        };

        # -------------------------------
        #       Call Tear Down Section
        # -------------------------------


 if (method=="BYE" || method=="CANCEL")
        {
                end_media_session();
                log(1,"Tear Down Section\n");
        };

        # -------------------------
        # loose-route processing
        # -------------------------

        if (loose_route())
        {
                if (has_totag() && (method=="INVITE"
|| method=="ACK"))
                {
                        if (client_nat_test("3") ||
search("^Route:.*;nat=yes"))
                        {
                                setflag(6);
                                use_media_proxy();
                        };
                        log(1,"Loose route
processing\n");
                };

                route(1);
                break;
        };

        setflag(1);

 # -----------------------------
        # Call Type Processing Section
        # -----------------------------

        if(uri != myself)
        {
                route(5);
                route(1);
                break;
        };

        if (uri==myself)
        {
   if(method == "ACK")
                {
                        route(6);
                        break;
                }

                else if (method =="CANCEL")
                {
                        route(3);
                        break;
                }

                else if(method=="INVITE")
                {
                    route(3);
                    t_on_failure("1");
                    break;
                }

                else if(method=="REGISTER")
                {
                    route(2);
                    break;
                };

                lookup("aliases");
                if (uri!=myself)
                {
                        route(5);
                        route(1);
                        break;
                };

                # native SIP destinations are handled
using our USRLOC DB
                if (!lookup("location")) {
                        sl_send_reply("404", "Not
Found");
                        break;
                };
        };
        route(1);
}

 # -------------------------------
        #       Route Processing Section
        # -------------------------------

        # ------------------------------
        #       Default Message Handler
        # ------------------------------

        route[1]
        {
                  t_on_reply("1");

                  if(!t_relay())
                  {
                        if(method=="INVITE" ||
method=="ACK")
                        {
                                end_media_session();
                                log(1,"Route 1 default
message handler\n");
                        };

                        sl_reply_error();
                  };
        }

  # REGISTER Message Handler
        #
----------------------------------------------------------------

        route[2]
        {

                sl_send_reply("100", "Trying");

                if (!search("^Contact:\ +\*") &&
client_nat_test("7"))
                {
                        setflag(6);
                        fix_nated_register();
                        force_rport();
              log(1,"Nated register\n");
                 };

                if (!www_authorize("","subscriber"))
                {
                        www_challenge("","0");
                        break;
                };

                if (!check_to())
                {
                        sl_send_reply("401",
"Unauthorized");
                        break;
                };

                consume_credentials();

                if (!save("location"))
                {
                         sl_reply_error();
                };
        }
 #
-----------------------------------------------------------------
        # CANCEL & INVITE Message Handler
        #
-----------------------------------------------------------------

        route[3]
        {
                if (client_nat_test("3"))
                {
                        setflag(7);
                        force_rport();
                        fix_nated_contact();
                };

                if(method=="INVITE" &&
!(src_ip==10.10.10.4))
                {
                        if
(!proxy_authorize("","subscriber"))
                        {
                               
proxy_challenge("","0");
                                 break;
                        }

                        else if (!check_from())
                        {
                                sl_send_reply("403",
"Use From=ID");
                                break;
                        };

                        consume_credentials();
                };

                lookup("aliases");

                if (uri!=myself)
                {
                        route(5);
                        route(1);
                        break;
                };

                if (!lookup("location"))
                {
                        # attempt handoff to PSTN
                        if (uri=~"^sip:8[0-9]*@")
                        {
                                log(1, "Forwarding to
PSTN\n");
                                route(4);
                   break;
                        };

                        # retrieve voicemail
                        if (uri=~"^sip:2[0-9]*@")
                        {
                                log(1, "Retrieving
voicemail\n");
                                route(7);
                                break;
                        };
                sl_send_reply("404", "User Not
Found!");
                        break;
                };

                if(method=="CANCEL")
                {
                        route(1);
                        break;
                };
                route(5);
                route(1);
        }

        # -----------------------------
        #       PSTN Handler
        # -----------------------------

        route[4]
        {
                rewritehostport("10.10.10.4:5060");
                avp_write("i:45", "inv_timeout");

           # -------------------------------
        #       RTP Proxy Enabler
        # -------------------------------

        route[5]
        {
                if(isflagset(6)||isflagset(7))
                {
                        use_media_proxy();
                        log(1,"Using rtp proxy\n");
                };
        }

        # -------------------------------
        #       ACK
        # -------------------------------

        route[6]
        {
                if (client_nat_test("3"))
                {
                        setflag(7);
                        force_rport();
                        fix_nated_contact();
                };

                lookup("aliases");

                if (uri!=myself)
                {
                        route(5);
                        route(1);
                        break;
                };

                if (!lookup("location"))
                {
                        sl_send_reply("404", "User Not
Found!");
                        break;
                };

                route(5);
                route(1);
        }
      route(5);
                route(1);
        }

      # ------------------------------
        #       Asterisk voicemail
        # ------------------------------

        route[7]
        {
                #redirect now!
                rewritehostport("201.23.13.145:5061");
                append_branch();
               
t_relay_to_udp("201.23.13.145","5061");
        }

        failure_route[1]
        {
                if(!(method=="BYE") &&
!(method=="CANCEL"))
                {
                        log(1,"Activating
voicemail!!\n");
                };

                #revert_uri();

                #redirect now!
                rewritehostport("201.23.13.145:5061");
                append_branch();
               
t_relay_to_udp("201.23.13.145","5061");
        }

        onreply_route[1]
        {
                log(1,"On reply route/n");

                if ((isflagset(6) || isflagset(7)) &&
(status=~"(180)|(183)|2[0-9][0-9]"))
                {
                        if (!search("^Content-Length:\
+0"))
                        {
                                use_media_proxy();
                        };
                };

                if (client_nat_test("1"))
                {
                        fix_nated_contact();
                };
        }






__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 




More information about the sr-users mailing list