[Serusers] When to use MediaProxy

Christophe Irles christophe.irles at rightvision.com
Fri Oct 28 11:54:12 CEST 2005


Hi Tchan,

I have the same problem. So i used this "ser.cfg" (see below) to be sure
that if UA1 can call UA2 without any problem (and the opposite).
Like i don't know how to avoid the use of media proxy for private use only.
Is there a way to use media proxy ONLY when one of the two UA comes from
Internet ? How NatHelper / MediaProxy modules know which ip range concerns
private network and public network ? With this config file, all RTP sessions
used the media proxy module...

Thanks in advance,
Chris.


' ------------------------- SER.CFG -------------------------

alias="test.ser"
listen=172.20.255.192

check_via=no	# (cmd. line: -v)
dns=no           # (cmd. line: -r)
rev_dns=no      # (cmd. line: -R)
fifo="/tmp/ser_fifo"

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

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/textops.so"

loadmodule "/usr/local/lib/ser/modules/mysql.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/domain.so"
loadmodule "/usr/local/lib/ser/modules/mediaproxy.so"
loadmodule "/usr/local/lib/ser/modules/nathelper.so"

# ----------------- setting module-specific parameters ---------------
modparam("usrloc", "db_mode", 2)

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

modparam("rr", "enable_full_lr", 1)

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

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/asymmetrics/sip-clients")
modparam("mediaproxy", "rtp_asymmetrics",
"/usr/local/etc/ser/asymmetrics/rtp-clients")

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

route {
  if (!mf_process_maxfwd_header("10")) {
    sl_send_reply("483", "Too Many Hops");
    break;
  };

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

  if (method=="INVITE" && client_nat_test("3") ) {
    record_route_preset("172.20.255.192:5060;nat=yes");
  } else if (method!="REGISTER") {
    record_route();
  };

  if (method=="BYE" || method=="CANCEL") {
    end_media_session();
  };

  if (loose_route()) {
    if (has_totag() && (method=="INVITE" || method=="ACK"))  {
      if (client_nat_test("3") || search("^Route:.*;nat=yes")) {
        setflag(6);
        use_media_proxy();²
      };
  };

  route(1);
  break;
  };

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

  if (method=="CANCEL") {
   route(1);
   break;
  } else if (method=="INVITE") {
   route(3);
   break;
  } else if (method=="REGISTER") {
   route(2);
   break;
  };

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

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

  route(1);
}

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

 if (!t_relay()) {
  if (method=="INVITE" || method=="ACK") {
    end_media_session();
  };

  sl_reply_error();
 };
}

route[2] {
 sl_send_reply("100", "Trying");

 if (!search("^Contact:[ ]*\*") && client_nat_test("7")) {
   setflag(6);
   fix_nated_register();
   force_rport();
 };

 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();
   };
}

route[3] {
 if (!proxy_authorize("","subscriber")) {
  proxy_challenge("","0");
  break;
 } else if (!check_from()) {
  sl_send_reply("403", "Use From=ID");
  break;
 };

 consume_credentials();

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

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

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

 route(4);
 route(1);
}

route[4] {
 if (isflagset(6) || isflagset(7)) {
   use_media_proxy();
 };
}


onreply_route[1] {
 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();
   };
}




More information about the sr-users mailing list