[Users] Rtpproxy and re-invites

Joshua Laroff jlaroff at gmail.com
Wed Jan 17 02:35:48 CET 2007


Hello,
I am new to openser and rtpproxy. I have tried to configure openser so that
reinvites are also handled by rtpproxy. It seems however that they are not.
I have included my config below:

debug=9
fork=yes
log_stderror=no

check_via=no
dns=no
rev_dns=no
port=5060
children=4
fifo="/tmp/openser_fifo"

# ------------------ Module Loading Section -------------------------
mpath="/usr/lib/openser/modules/"

loadmodule "mysql.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 "domain.so"
loadmodule "nathelper.so"
loadmodule "textops.so"
loadmodule "avpops.so"
loadmodule "permissions.so"
loadmodule "options.so"
#------------------- Module Parameters -----------------------------
modparam("auth_db|permissions|uri_db|usrloc", "db_url",
"mysql://openser:openserrw@localhost/openser")
modparam("auth_db", "calculate_ha1", 1)
modparam("auth_db", "password_column", "password")

#--- nathelper params ---
modparam("nathelper", "rtpproxy_sock", "udp:127.0.0.1:8899")
modparam("nathelper", "natping_interval", 30)
modparam("nathelper", "ping_nated_only", 1)
modparam("nathelper", "sipping_from", "sip:pinger at openser.org")

#--- usrloc params ---
modparam("usrloc", "db_mode", 2)

#--- registrar params ---
modparam("registrar", "nat_flag", 6)

#--- rr params ---
modparam("rr", "enable_full_lr", 1)

#--- tm params ---
modparam("tm", "fr_inv_timer", 27)
modparam("tm", "fr_inv_timer_avp", "i:45")

#--- permissions params ---
modparam("permissions", "db_mode", 1)
modparam("permissions", "trusted_table", "trusted")
#------------------------ Main Routing Block ------------------------------
route {
  
  # -----------------------------------------
  # Sanity check Section
  # -----------------------------------------
  if (!mf_process_maxfwd_header("10")) {
    sl_send_reply("483", "Too Many Hops");
    exit;
  };

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

  # -------------------------------------------
  # Record Route Section
  # -------------------------------------------
  if (method!="REGISTER") {
    record_route();
  };

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

  # -------------------------------------------
  # - Loose Route Section
  # -------------------------------------------
  if (loose_route()) {
    if ((method=="INVITE" || method=="REFER") && !has_totag()) {
      sl_send_reply("403", "Forbidden");
      exit;
  };

  if (method=="INVITE") {
    if (!allow_trusted()) {
      if (!proxy_authorize("", "subscriber")) {
        proxy_challenge("", "0");
        exit;
      } else if (!check_from()) {
        sl_send_reply("403", "Use From=ID");
        exit;
      }; 

      consume_credentials();
    };            
    
    if (nat_uac_test("19")) {
      setflag(6);
     }; 
    };
    route(4); 
    route(1);
    exit;
  };  

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

    if (!is_uri_host_local()) {
      if (is_from_local() || allow_trusted()) {
        route(4);
        route(1);
      } else {
        sl_send_reply("403", "Forbidden");
      };
      exit;
    };

    if (method=="ACK") {
      route(1);
      exit;
    } if (method=="CANCEL") {
      route(1);
      exit;
    } else if (method=="INVITE") {
      route(3);
      exit;
    } else if (method=="REGISTER") {
      route(2);
      exit;
    } else if (uri==myself) {
        if (method==OPTIONS) {
          options_reply();
           }
    }

    lookup("aliases");
    if (!is_uri_host_local()) {
      route(4);
      route(1);
      exit;
    };

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

    route(1); 
}

route[1] {
  
  # --------------------------------------------
  # - Default Message Handler
  # --------------------------------------------

  t_on_reply("1");
  if (!t_relay()) {
    if (method=="INVITE" || method=="ACK") {
      unforce_rtp_proxy();
    };

    sl_reply_error();
    };
}

route[2] {
  
  # --------------------------------------------
  # - REGISTER Message Handler
  # --------------------------------------------

  sl_send_reply("100", "Trying");

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

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

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

  if (!save("location")) {
    sl_reply_error();
  };
}
route[3] {

  # ------------------------------------------------
  # - INVITE Message Handler
  # ------------------------------------------------
 
  if (!allow_trusted()) {
    if (!proxy_authorize("", "subscriber")) {
      proxy_challenge("", "0");
      exit;
    } else if (!check_from()) {
      sl_send_reply("403", "Use From=ID");
      exit;
    };
    consume_credentials();
  };
  if (nat_uac_test("19")) {
    setflag(6);
  };

  if (uri=~"^sip:1[0-9]{10}@") {
    strip(1);
  };

  lookup("aliases");
  if (!is_uri_host_local()) {
    route(4);
    route(5);
    exit;
  };

  if (uri=~"^sip:011[0-9]*@") {         # International PSTN
    route(4);
    route(5);
    exit;
  };
  
  if (!lookup("location")) {
    if (uri=~"^sip:[0-9]{10}@") {       # Domestic PSTN
      route(4);
      route(5);
      exit;
    };
  
    sl_send_reply("404", "User Not Found");
    exit;
   };
  
   route(4);
   route(5);
}

route[4] {

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

  if (isflagset(6)) {
    force_rport();
    fix_nated_contact();
    force_rtp_proxy();
  };
}

route[5] {

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

  rewritehost("204.x.x.x");
#  avp_write("i:45", "inv_timeout");
  route(1);
}

onreply_route[1] {

  # ---------------------------------------
  # - REPLY ROUTE
  # ---------------------------------------

  if (isflagset(6) && status=~"(180)|(183)|2[0-9][0-9]") {
    if (!search("^Content-Length:[ ]*0")) {
      force_rtp_proxy();
    }
  }
  if (nat_uac_test("1")) {
    fix_nated_contact();
  };
}






More information about the Users mailing list