[Serusers] RTPproxy debug

Joao Pereira joao.pereira at fccn.pt
Tue Oct 4 19:48:20 CEST 2005


I dont know If the problem is realy of my ser.cfg, because the IP phones 
with public IPs work, but the phones with private IPs just ring... but I 
believe theres no RTP passing.
Theres my SER:

|--------------|
|                     |-------------- private IP
|      S E R      |
|                     |-------------- public IP
|--------------|

Theres my ser.cfg:


(...)
listen = 193.136.xxx.xxx
listen = 10.0.0.135

(...)

alias=fccn.pt
alias=193.136.xxx.xxx
alias=10.0.0.135


# memlog - Debugging level for final memory statistics report. Default
# is L_DBG -- memory statistics are dumped only if debug is set high.
memlog=1




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


loadmodule "/usr/local/lib/ser/modules/postgres.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/textops.so"

loadmodule "/usr/local/lib/ser/modules/acc.so"

# Uncomment this if you want digest authentication
loadmodule "/usr/local/lib/ser/modules/auth.so"
loadmodule "/usr/local/lib/ser/modules/auth_db.so"


loadmodule "/usr/local/lib/ser/modules/exec.so"
loadmodule "/usr/local/lib/ser/modules/group.so"
loadmodule "/usr/local/lib/ser/modules/print.so"
#loadmodule "/usr/local/lib/ser/modules/mediaproxy.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/xlog.so"
loadmodule "/usr/local/lib/ser/modules/speeddial.so"
loadmodule "/usr/local/lib/ser/modules/options.so"
loadmodule "/usr/local/lib/ser/modules/avpops.so"
loadmodule "/usr/local/lib/ser/modules/permissions.so"
#loadmodule "/usr/local/lib/ser/modules/xdz_tools.so"


loadmodule "/usr/local/lib/ser/modules/nathelper.so"

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

# -- nathelper params --

# proxy nat
modparam("nathelper", "natping_interval", 15)
modparam("nathelper", "ping_nated_only", 1)

(...)


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

# main 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 too big");
    break;
  };

  # --------------------------------------------------
  # NOTIFY Keep-Alive Section
  # --------------------------------------------------
  if ((method=="NOTIFY") && search("^Event: keep-alive")) {
    sl_send_reply("200", "OK");
    break;
  };

  if ((method=="NOTIFY") && (uri=~"^sip:700@")) {
    sl_send_reply("200", "OK");
    break;
  };


  # --------------------------------------------------
  # OPTIONS Section
  # --------------------------------------------------
  if (method=="OPTIONS") {
    options_reply();
    break;
  };

 


  if (method=="REGISTER" && nat_uac_test("3")) {

    fix_nated_contact();
    force_rport();
    setflag(2);
    };



  # --------------------------------------------------
  # Registration Section
  # --------------------------------------------------
  (...)


  # --------------------------------------------------
  # Accounting Section
  # NOTE: We test for flag 14 because we do not want to record Click2Dial
  #       entries
  # --------------------------------------------------

  if ((method=="INVITE" || method=="BYE" || 
method=="CANCEL"||method=="ACK" ||method=="REGISTER") && !isflagset(14)) {
    setflag(1);
  };

  # --------------------------------------------------
  # NAT Tear-Down Section
  # --------------------------------------------------

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



  # --------------------------------------------------
  # Record Route Section
  # --------------------------------------------------
  # 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
  if (!method=="REGISTER") {
    record_route();
  };   


  # --------------------------------------------------
  # Loose Route Section
  #
  # Grant route routing if route headers present
  # --------------------------------------------------
  if (loose_route()) {
    route(2);
    break;
  };

  #


  # --------------------------------------------------
  # NAT Test Section #1
  # --------------------------------------------------

  if (nat_uac_test("3") && !search("^Record-Route:")) {
    force_rport();

    fix_nated_contact();
  };


(...)

  # --------------------------------------------------
  # Alias Routing Section
  # --------------------------------------------------
   
     lookup("aliases");
    if (!uri==myself) {
      route(2);
      break;
    };

(...)


  # --------------------------------------------------
  # Anonymous Call Rejection Section
  # --------------------------------------------------
  if (isflagset(24) && (method=="INVITE") && 
search("^(f|F)rom:.*(a|A)nonymous")) {
    route(8);
    break;
  };

 



  # --------------------------------------------------
  # URI Compare Section
  # --------------------------------------------------
  # Here we compare the "from" and "to" to see if the caller is dialing
  # their own extension. If so then we route to voicemail if needed
  if (method=="INVITE") {
    avp_write("$from", "i:34");
    if (avp_check("i:34", "eq/$ruri/i")) {
      if (isflagset(31)) {
        route(5);
        break;
      } else {
        sl_send_reply("486", "Busy");
        break;
      };
    };
  };

(...)

  # --------------------------------------------------
  # Do Not Disturb Section
  # --------------------------------------------------
  if (avp_db_load("$ruri/username", "s:donotdisturb")) {
    if (avp_check("s:donotdisturb", "eq/y/i")) {
      route(5);
      break;
    };
  };



  # --------------------------------------------------
  # Call Routing Section
  # --------------------------------------------------

  if (!lookup("location")){

    # if flag 31 (ie voicemail) is set and we made it here this means
    # the user's phone is not registered anywhere. We'll forward to
    # voicemail after this block because we need to check the call
    # forward settings first
    if (isflagset(31)) {

      # flag 19 means the user has voicemail but is not online
      # so we need to remember to send to voicemail if call
      # forwarding is not enabled
      setflag(19);
    };

    if (method=="INVITE") {



     if( !uri=~"@fccn.pt" ) {
    if (!method=="REGISTER") record_route();
        t_relay();
        break;
      }


 if (does_uri_exist()) {
        # o utilizador foi encontrado mas esta offline
    sl_send_reply("480", "Temporarily Unavailable");
        break;
      };


      sl_send_reply("404", "Utilizador nao Encontrado");
      break;
      };
  };


  # --------------------------------------------------
  # Call Forwarding Section
  # --------------------------------------------------


  if (method=="INVITE") {

    # only load the forward no answer option if voice mail is not enabled
      if (!isflagset(31)) {
        if (avp_db_load("$ruri/username", "s:fwdnoanswer")) {
          route(1);

      if (!avp_check("$calltype", "eq/-/i")) {
            if (avp_check("$calltype", "eq/dom/i")) {
              avp_write("dom", "$fwd_no_answer_type");
            } else if (avp_check("$calltype", "eq/int/i")) {
              avp_write("int", "$fwd_no_answer_type");
            } else {
            avp_write("sip", "$fwd_no_answer_type");
            }

            setflag(27);
          };
        };
      };


    if (avp_db_load("$ruri/username", "s:fwdbusy")) {
      route(1);

      if (!avp_check("$calltype", "eq/-/i")) {

        if (avp_check("$calltype", "eq/dom/i")) {
          avp_write("dom", "$fwd_busy_type");
        } else if (avp_check("$calltype", "eq/int/i")) {
          avp_write("int", "$fwd_busy_type");
        } else {
          avp_write("sip", "$fwd_busy_type");
        }

        setflag(26);
      };
    };

    avp_pushto("$ruri", "i:99");
  };

  if (isflagset(19)) {
    # send to voicemail
    route(5);
  } else {
    route(2);
  };

}  #route




route[1] {

  avp_write("-", "$calltype");

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


  lookup("aliases");
 if (!lookup("location")) {
    if (uri=~"^sip:[0-9]{10}@") {

      # test for domestic PSTN number
      if (isflagset(28)) {
        avp_write("dom", "$calltype");
      };

    } else if (uri=~"^sip:011[0-9]*@") {

      # test for international PSTN number
      if (isflagset(29)) {
        avp_write("int", "$calltype");
      };
    };

    break;
  };

  avp_write("sip", "$calltype");

}


route[2] {

#  check for RFC1918 ip addresses
 #  -- NATHELPER --
  if (uri=~"[@:](192\.168\.|10\.|172\.(1[6-9]|2[0-9]|3[0-1])\.)" && 
!search("^Route:")){
    sl_send_reply("479", "We don't forward to private IP addresses");
    break;
  };

  #check if the  NAT Flag is set
  if (isflagset(6)) {
    log(1, "LOG: flag 6 set => One of the sides is NATed -> 
force_rtp_proxy()\n");
    if(!force_rtp_proxy()) {
      log(1, "LOG: force_rtp_prpoxy FAILED!\n");
   } else {
      log(1, "LOG: force_rtp_proxy() succeeded!\n");   
  };
  };


  if (isflagset(25)) {
    replace("^From:(.*)>" , "From: \"Anonymous\" <sip:someone at 
anonymous.invalid>");
  };





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


  t_on_failure("1");
  t_on_reply("1");

  if (!t_relay()) {


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

    sl_reply_error();
  };
}


# encaminhamento para o Gateway PSTN
route[3] {

     if (method=="INVITE") {

       if (!proxy_authorize("fccn.pt", "utilizador")) {
 
         proxy_challenge("fccn.pt", "0");
         break;
    }  
    } else if (!check_from()) {

      log(1, "Spoofed SIP call attempt");
      sl_send_reply("403", "Use From=ID");
      break;

   } else if (!(is_from_local() || is_uri_host_local())) {

      sl_send_reply("403", "Please register to use our service");
      break;
    };

    # enable caller id blocking for PSTN calls
    if (isflagset(25)) {
      append_rpid_hf();
    };
  };

  # SIP->PSTN calls get 45 seconds to timeout
  avp_write("i:45", "inv_timeout");


rewritehostport("10.0.0.135:1720");


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

  if (isflagset(31)) {
    t_on_failure("1");
  };

  t_on_reply("1");

  if (!t_relay()) {

 

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

  sl_reply_error();
  };
}

(...)

onreply_route[1] {

  # Not all 2xx messages have a content body so here we
  # make sure our Content-Length > 0 to avoid a parse error
  if (status=~"(180)|(183)|2[0-9][0-9]") {

    if (!search("^Content-Length:\ 0")) {
      force_rtp_proxy();
    };
   };


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

failure_route[1] {

  if (t_check_status("487")) {
    break;
  };

  if (isflagset(26) && t_check_status("486")) {

    # forward busy is flag 26
    if (avp_pushto("$ruri", "s:fwdbusy")) {
      avp_delete("s:fwdbusy");
      append_branch();
      resetflag(26);
      # test for domestic PSTN gateway
      if (avp_check("$fwd_busy_type", "eq/dom/i")) {
        # test for domestic PSTN gateway
        route(3);
#        sl_send_reply("503", "Gateway PSTN Indisponivel-3");
      #} else if (avp_check("$fwd_busy_type", "eq/int/i")) {
        # test for international PSTN gateway
      #  route(6);
#      } else {
        # default to sip call
        route(2);
      };

      break;
    };
  };

  # here we can have either voicemail __OR__ forward no answer
  if (isflagset(27) && t_check_status("408")) {

  # forward no answer is flag 27

    if (avp_pushto("$ruri", "s:fwdnoanswer")) {
      avp_delete("s:fwdnoanswer");
      append_branch();
      resetflag(27);

      if (avp_check("$fwd_no_answer_type", "eq/dom/i")) {
        # test for domestic PSTN gateway
        route(3);
        #sl_send_reply("503", "Gateway PSTN Indisponivel");
      #} else if (avp_check("$fwd_no_answer_type", "eq/int/i")) {
        # test for international PSTN gateway
      #  route(6);
      #} else {
        # default to sip call
        route(2);
      };

      break;
    };

  } else if (isflagset(31) && avp_pushto("$ruri", "$voicemail")) {

    avp_delete("$voicemail");
    route(4);
    break;
  };
}




onreply_route[2] {

  log(1, "LOG: entered onreply_route[2] now... \n");

  if(isflagset(6)) { # && status =~"(183)|2[0-9][0-9]") {
    log(1, "LOG: TRansaction was sent to a NATed client --> 
fix_nated_contact() and force_rtp_proxy().\n");
    if(!fix_nated_contact()) {
      log(1, "LOG: fix_nated_contact() FAILED!\n");
    } else {
      log(1, "LOG: fix_nated_contact() succeded.\n");
    };
 
  if(!force_rtp_proxy()) {
    log(1, "LOG: force_rtp_proxy() FAILED!\n");
  } else {
    log(1, "LOG: force_rtp_proxy() succeded.\n");
  };
     
    append_hf("P-hint: fixed NAT contact for response\r\n");

  } else if (nat_uac_test("1")) {
    log(1, "LOG: Uncaught NAT. => fix_nated_contact()\n");
    if(!fix_nated_contact()) {
      log(1, "LOG: fix_nated_contact() FAILED!\n");
    } else {
      log(1, "LOG: fix_nated_contact() succeded.\n");
    };
  };

}




Sorry the long post.
Joao Pereira
www.fccn.pt






Paul Hazlett wrote:

>Joao,
>
>The problem is probably and error in your ser.cfg file. I'd recommend
>you download a copy of the Getting Started document from www.onsip.org
>and look at the section on RTPproxy.
>
>Regards,
>Paul
>
>On 10/4/05, Joao Pereira <joao.pereira at fccn.pt> wrote:
>  
>
>>Hello to all,
>>Is there any way of making debug in RTP proxy?
>>My SER has one public IP and one private IP. The public phones can speak
>>each other, but the private IP phones can t speak each other (they just
>>ring, but theres no voice ) , and apears this error on SER:
>> ERROR: send_rtpp_command: can't read reply from a RTP proxy
>>
>>How can I debug RTPproxy?
>>Thanks
>>
>>Joao Pereira
>>www.fccn.pt
>>
>>
>>
>>_______________________________________________
>>Serusers mailing list
>>serusers at lists.iptel.org
>>http://lists.iptel.org/mailman/listinfo/serusers
>>
>>    
>>
>
>  
>




More information about the sr-users mailing list