[OpenSER-Users] All media traffic gets passed through Mediaproxy?

Ash Rah ash at droshta.net
Thu Apr 24 11:41:58 CEST 2008


Hello,

Sorry for a novice question and equally sorry if it is already answered 
elsewhere.

I have an OpenSER setup with Mediaproxy in same box. I am including the 
configuration at the bottom. My question is does ALL media traffic (even 
the media traffic between non NAT'ed clinets, and media traffic between 
NAT'ed clients where both-way media traffic works perfectly fine without 
a media proxy) passes through Mediaproxy dispatcher/server? Or only the 
media traffic between (troubled) NAT'ed clients are passed through 
MediaProxy server?

My goal is to have the OpenSER to provide registration where the actual 
calls will be routed through an external Asterisk server. I do not want 
media traffic passing through Mediaproxy unless I have a NAT related 
media problems with a certain client. But apparently current set up is 
forcing all media traffic to pass through the Mediaproxy server.

Any advise or suggestion will be greatly appreciated.


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)


route {
  # -----------------------------------------------------------------
  # Record Route Section
  # -----------------------------------------------------------------
  if (method=="INVITE" && client_nat_test("3")) { 
    # INSERT YOUR IP ADDRESS HERE
    record_route_preset("192.0.2.13:5060;nat=yes");
  } else if (method!="REGISTER") {  
    record_route();
  };

  # -----------------------------------------------------------------
  # Call Tear Down Section
  # -----------------------------------------------------------------
  if (method=="BYE" || method=="CANCEL") { 
    end_media_session();
  };

  # -----------------------------------------------------------------
  # Loose Route Section
  # -----------------------------------------------------------------
  if (loose_route()) {

    if ((method=="INVITE" || method=="REFER") && !has_totag()) {
      sl_send_reply("403", "Forbidden");
      break;
    };

    if (method=="INVITE") {

      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") || search("^Route:.*;nat=yes")) { 
        setflag(6)
        use_media_proxy();
      };
    };

    route(1);
    break;
  };

  # -----------------------------------------------------------------
  # Call Type Processing Section
  # -----------------------------------------------------------------
  if (uri!=myself) {
    route(4);
    route(1);
    break;
  };

  if (method=="ACK") {
    route(1);
    break;
  else 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] {

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

  t_on_reply("1");

  if (!t_relay()) {

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

    sl_reply_error();
  };
}

route[2] {

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

  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] {

  # -----------------------------------------------------------------
  # INVITE Message Handler
  # -----------------------------------------------------------------

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

  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(4);
    route(1);
    break;
  };

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

  route(4);
  route(1);
}

route[4] {

  # -----------------------------------------------------------------
  # NAT Traversal Section
  # -----------------------------------------------------------------

  if (isflagset(6) || isflagset(7)) {
    if (!isflagset(8)) {
      setflag(8);
      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