<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
    <title></title>
  </head>
  <body text="#000000" bgcolor="#ffffff">
    <br>
    Hello,<br>
    <br>
    Thanks for your responses and happy new year!<br>
    <br>
    Could anyone tell me how to make the RLS module work properly?<br>
    <br>
    I've tried several different solutions, but I still don't know
    what's the expected behaviour of the RLS.<br>
    <br>
    I'm using the Kamailio integrated presence server + RLS. Then, the
    RLS is supposed to send a SUBSCRIBE to each of the presentities in
    the subscribed presence list?<br>
    <br>
    In that case, and if the domain of the presentity is the same as the
    used by the watcher, the SUBSCRIBE will go back to the Kamailio?<br>
    <br>
    This is the reason why I don't receive the notify. There are no
    dialogs for the subscription:<br>
    <br>
    <font face="Courier New, Courier, monospace">&nbsp;5(13925) DEBUG:
      presence [notify.c:1302]: found 0 dialogs( 0 in database and 0 in
      hash_table)<br>
      &nbsp;5(13925) DEBUG: presence [notify.c:1387]: Could not get
      subscription dialog<br>
      &nbsp;5(13925) DEBUG: presence [notify.c:1461]: dialog info:<br>
      &nbsp;5(13925) DEBUG: presence [notify.c:122]: <br>
      &nbsp;&nbsp;&nbsp; [pres_uri]= <a class="moz-txt-link-freetext" href="sip:restricted_areas_presentities@open-ims.test">sip:restricted_areas_presentities@open-ims.test</a><br>
      &nbsp;&nbsp;&nbsp; [to_user]= restricted_areas_presentities&nbsp;&nbsp;&nbsp; [to_domain]=
      open-ims.test<br>
      &nbsp;&nbsp;&nbsp; [w_user]= restricted_areas&nbsp;&nbsp;&nbsp; [w_domain]= open-ims.test<br>
      &nbsp;&nbsp;&nbsp; [event]= presence<br>
      &nbsp;&nbsp;&nbsp; [status]= active<br>
      &nbsp;&nbsp;&nbsp; [expires]= 0<br>
      &nbsp;&nbsp;&nbsp; [callid]= nYhLl92BHRHtSTy3f8iNZ1v6irOhhfd2fNnFtSXTOlk.&nbsp;&nbsp;&nbsp;
      [local_cseq]=1<br>
      &nbsp;&nbsp;&nbsp; [to_tag]= a6a1c5f60faecf035a1ae5b6e96e979a-5cc7&nbsp;&nbsp;&nbsp; [from_tag]=
      f733f739<br>
      &nbsp;&nbsp;&nbsp; [contact]= <a class="moz-txt-link-freetext" href="sip:restricted_areas@155.54.190.245:8060">sip:restricted_areas@155.54.190.245:8060</a>&nbsp;&nbsp;&nbsp;
      [record_route]=
<a class="moz-txt-link-rfc2396E" href="sip:mo@scscf.open-ims.test:6060;lr">&lt;sip:mo@scscf.open-ims.test:6060;lr&gt;</a>,<a class="moz-txt-link-rfc2396E" href="sip:mo@pcscf.open-ims.test:4060;lr">&lt;sip:mo@pcscf.open-ims.test:4060;lr&gt;</a><br>
      &nbsp;5(13925) DEBUG: presence [hash.c:471]: pres_uri=
      <a class="moz-txt-link-freetext" href="sip:restricted_areas_presentities@open-ims.test">sip:restricted_areas_presentities@open-ims.test</a><br>
      &nbsp;5(13925) DEBUG: presence [notify.c:643]: No record exists in
      hash_table<br>
      &nbsp;5(13925) DEBUG: presence [notify.c:1515]: Could not get the
      notify_body<br>
      &nbsp;5(13925) DEBUG: presence [notify.c:225]: state = terminated<br>
      &nbsp;5(13925) DEBUG: presence [notify.c:1555]: headers:<br>
      Max-Forwards: 70
<br>
      Event: presence
<br>
      Contact: <a class="moz-txt-link-rfc2396E" href="sip:155.54.190.245:5060;transport=udp">&lt;sip:155.54.190.245:5060;transport=udp&gt;</a>
<br>
      Subscription-State: terminated;reason=timeout
</font><br>
    <br>
    Any hints?<br>
    <br>
    Cheers,<br>
    &nbsp; Andr&eacute;s.<br>
    <br>
    <br>
    El 24/12/10 11:03, Daniel-Constantin Mierla escribi&oacute;:
    <blockquote cite="mid:4D146FE1.3020806@gmail.com" type="cite">Hello,
      <br>
      <br>
      On 12/22/10 4:55 PM, Klaus Darilion wrote: <br>
      <blockquote type="cite">1. Kamailio will send the request to the
        address of the list member (normal DNS lookups). <br>
        <br>
        2. If there is a problem with OpenIMS then you should ask the
        OpenIMS guys, we are not familiar with OpenIMS. <br>
      </blockquote>
      <br>
      for sake of completion, openimscore is running now on the same
      core as version 3.x, it has just some extra modules. So in regard
      to routing and common modules, it the same thing. <br>
      <br>
      Cheers, <br>
      Daniel <br>
      <br>
      <blockquote type="cite"> <br>
        regards <br>
        klaus <br>
        <br>
        Am 22.12.2010 12:57, schrieb "Andr&eacute;s S. Garc&iacute;a Ruiz": <br>
        <blockquote type="cite"> <br>
          Thanks a lot for your response! <br>
          <br>
          I've been thinking about it and there's something abnormal.
          Firs, the <br>
          RLS is suppose to send the initial SUBSCRIBE to the S-CSCF
          instead of <br>
          sending it to the I-CSCF. Then, I don't know why the S-CSCF
          translates <br>
          the SUBSCRIBE URI (<a class="moz-txt-link-freetext"
            href="sip:testuser02@open-ims.test">sip:testuser02@open-ims.test</a>)
          to <br>
          <a class="moz-txt-link-rfc2396E"
            href="sip:testuser01@155.54.190.245:8060;rinstance=9b7761b4bcaa4bd0">"sip:testuser01@155.54.190.245:8060;rinstance=9b7761b4bcaa4bd0"</a>.
          All the <br>
          routing is the default configuration of both cscfs and rls. <br>
          <br>
          How can I change the routing of the RLS in order it to send
          the <br>
          SUBSCRIBE messages to the S-CSCF? <br>
          <br>
          Here's the configuration file: <br>
          / <br>
          #!KAMAILIO <br>
          <br>
          #!ifdef ACCDB_COMMENT <br>
          ALTER TABLE acc ADD COLUMN src_user VARCHAR(64) NOT NULL
          DEFAULT ''; <br>
          ALTER TABLE acc ADD COLUMN src_domain VARCHAR(128) NOT NULL
          DEFAULT ''; <br>
          ALTER TABLE acc ADD COLUMN dst_ouser VARCHAR(64) NOT NULL
          DEFAULT ''; <br>
          ALTER TABLE acc ADD COLUMN dst_user VARCHAR(64) NOT NULL
          DEFAULT ''; <br>
          ALTER TABLE acc ADD COLUMN dst_domain VARCHAR(128) NOT NULL
          DEFAULT ''; <br>
          ALTER TABLE missed_calls ADD COLUMN src_user VARCHAR(64) NOT
          NULL <br>
          DEFAULT ''; <br>
          ALTER TABLE missed_calls ADD COLUMN src_domain VARCHAR(128)
          NOT NULL <br>
          DEFAULT ''; <br>
          ALTER TABLE missed_calls ADD COLUMN dst_ouser VARCHAR(64) NOT
          NULL <br>
          DEFAULT ''; <br>
          ALTER TABLE missed_calls ADD COLUMN dst_user VARCHAR(64) NOT
          NULL <br>
          DEFAULT ''; <br>
          ALTER TABLE missed_calls ADD COLUMN dst_domain VARCHAR(128)
          NOT NULL <br>
          DEFAULT ''; <br>
          #!endif <br>
          <br>
          ####### Defined Values ######### <br>
          <br>
          #!define WITH_DEBUG <br>
          #!define WITH_AUTH <br>
          #!define WITH_MYSQL <br>
          #!define WITH_USRLOCDB <br>
          #!define WITH_PRESENCE <br>
          #!define WITH_XCAPSRV <br>
          <br>
          <br>
          # *** Value defines - IDs used later in config <br>
          #!ifdef WITH_MYSQL <br>
          # - database URL - used to connect to database server by
          modules such <br>
          # as: auth_db, acc, usrloc, a.s.o. <br>
          #!define DBURL "mysql://openser:openserrw@localhost/openser" <br>
          #!endif <br>
          #!ifdef WITH_MULTIDOMAIN <br>
          # - the value for 'use_domain' parameters <br>
          #!define MULTIDOMAIN 1 <br>
          #!else <br>
          #!define MULTIDOMAIN 0 <br>
          #!endif <br>
          <br>
          # - flags <br>
          # FLT_ - per transaction (message) flags <br>
          # FLB_ - per branch flags <br>
          #!define FLT_ACC 1 <br>
          #!define FLT_ACCMISSED 2 <br>
          #!define FLT_ACCFAILED 3 <br>
          #!define FLT_NATS 5 <br>
          <br>
          #!define FLB_NATB 6 <br>
          #!define FLB_NATSIPPING 7 <br>
          <br>
          ####### Global Parameters ######### <br>
          <br>
          #!ifdef WITH_DEBUG <br>
          debug=4 <br>
          log_stderror=yes <br>
          #!else <br>
          debug=2 <br>
          log_stderror=no <br>
          #!endif <br>
          <br>
          memdbg=5 <br>
          memlog=5 <br>
          <br>
          log_facility=LOG_LOCAL0 <br>
          <br>
          fork=yes <br>
          children=4 <br>
          <br>
          /* uncomment the next line to disable TCP (default on) */ <br>
          #disable_tcp=yes <br>
          <br>
          <br>
          /* uncomment the next line to disable the auto discovery of
          local aliases <br>
          based on reverse DNS on IPs (default on) */ <br>
          #auto_aliases=no <br>
          <br>
          /* add local domain aliases */ <br>
          alias="open-ims.test" <br>
          <br>
          /* uncomment and configure the following line if you want
          Kamailio to <br>
          bind on a specific interface/port/proto (default bind on all
          available) */ <br>
          #listen=udp:10.0.0.10:5060 <br>
          <br>
          /* port to listen to <br>
          * - can be specified more than once if needed to listen on
          many ports */ <br>
          port=5060 <br>
          <br>
          #!ifdef WITH_TLS <br>
          enable_tls=yes <br>
          #!endif <br>
          <br>
          #!ifdef WITH_XCAPSRV <br>
          tcp_accept_no_cl=yes <br>
          #!endif <br>
          <br>
          ####### Custom Parameters ######### <br>
          <br>
          # These parameters can be modified runtime via RPC interface <br>
          # - see the documentation of 'cfg_rpc' module. <br>
          # <br>
          # Format: group.id = value 'desc' description <br>
          # Access: $sel(cfg_get.group.id) or @cfg_get.group.id <br>
          # <br>
          <br>
          #!ifdef WITH_PSTN <br>
          # PSTN GW Routing <br>
          # <br>
          # - pstn.gw_ip: valid IP or hostname as string value, example:
          <br>
          # pstn.gw_ip = "10.0.0.101" desc "My PSTN GW Address" <br>
          # <br>
          # - by default is empty to avoid misrouting <br>
          pstn.gw_ip = "" desc "PSTN GW Address" <br>
          #!endif <br>
          <br>
          <br>
          ####### Modules Section ######## <br>
          <br>
          # set paths to location of modules <br>
          #!ifdef LOCAL_TEST_RUN <br>
          mpath="modules_k:modules" <br>
          #!else <br>
          mpath="/usr/local/kamailio-3.1-xcap-rls/lib/kamailio/modules_k/:/usr/local/kamailio-3.1-xcap-rls/lib/kamailio/modules/"

          <br>
          #!endif <br>
          <br>
          #!ifdef WITH_MYSQL <br>
          loadmodule "db_mysql.so" <br>
          #!endif <br>
          <br>
          loadmodule "mi_fifo.so" <br>
          loadmodule "kex.so" <br>
          loadmodule "tm.so" <br>
          loadmodule "tmx.so" <br>
          loadmodule "sl.so" <br>
          loadmodule "rr.so" <br>
          loadmodule "pv.so" <br>
          loadmodule "maxfwd.so" <br>
          loadmodule "usrloc.so" <br>
          loadmodule "registrar.so" <br>
          loadmodule "textops.so" <br>
          loadmodule "siputils.so" <br>
          loadmodule "xlog.so" <br>
          loadmodule "sanity.so" <br>
          loadmodule "ctl.so" <br>
          loadmodule "mi_rpc.so" <br>
          loadmodule "acc.so" <br>
          # loadmodule "pua_mi.so" <br>
          # loadmodule "pua_usrloc.so" <br>
          <br>
          <br>
          #!ifdef WITH_AUTH <br>
          loadmodule "auth.so" <br>
          loadmodule "auth_db.so" <br>
          #!ifdef WITH_IPAUTH <br>
          loadmodule "permissions.so" <br>
          #!endif <br>
          #!endif <br>
          <br>
          #!ifdef WITH_ALIASDB <br>
          loadmodule "alias_db.so" <br>
          #!endif <br>
          <br>
          #!ifdef WITH_MULTIDOMAIN <br>
          loadmodule "domain.so" <br>
          #!endif <br>
          <br>
          #!ifdef WITH_PRESENCE <br>
          loadmodule "presence.so" <br>
          loadmodule "presence_xml.so" <br>
          loadmodule "pua.so" <br>
          loadmodule "rls.so" <br>
          #!endif <br>
          <br>
          #!ifdef WITH_NAT <br>
          loadmodule "nathelper.so" <br>
          loadmodule "rtpproxy.so" <br>
          #!endif <br>
          <br>
          #!ifdef WITH_TLS <br>
          loadmodule "tls.so" <br>
          #!endif <br>
          <br>
          #!ifdef WITH_ANTIFLOOD <br>
          loadmodule "htable.so" <br>
          loadmodule "pike.so" <br>
          #!endif <br>
          <br>
          #!ifdef WITH_XMLRPC <br>
          loadmodule "xmlrpc.so" <br>
          #!endif <br>
          <br>
          #!ifdef WITH_XCAPSRV <br>
          loadmodule "xhttp.so" <br>
          loadmodule "xcap_server.so" <br>
          #!endif <br>
          <br>
          # ----------------- setting module-specific parameters
          --------------- <br>
          <br>
          <br>
          # ----- mi_fifo params ----- <br>
          modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo") <br>
          <br>
          <br>
          # ----- tm params ----- <br>
          # auto-discard branches from previous serial forking leg <br>
          modparam("tm", "failure_reply_mode", 3) <br>
          # default retransmission timeout: 30sec <br>
          modparam("tm", "fr_timer", 30000) <br>
          # default invite retransmission timeout after 1xx: 120sec <br>
          modparam("tm", "fr_inv_timer", 120000) <br>
          <br>
          <br>
          # ----- rr params ----- <br>
          # add value to ;lr param to cope with most of the UAs <br>
          modparam("rr", "enable_full_lr", 1) <br>
          # do not append from tag to the RR (no need for this script) <br>
          modparam("rr", "append_fromtag", 0) <br>
          <br>
          <br>
          # ----- registrar params ----- <br>
          modparam("registrar", "method_filtering", 1) <br>
          /* uncomment the next line to disable parallel forking via
          location */ <br>
          # modparam("registrar", "append_branches", 0) <br>
          /* uncomment the next line not to allow more than 10 contacts
          per AOR */ <br>
          #modparam("registrar", "max_contacts", 10) <br>
          <br>
          <br>
          # ----- acc params ----- <br>
          /* what special events should be accounted ? */ <br>
          modparam("acc", "early_media", 0) <br>
          modparam("acc", "report_ack", 0) <br>
          modparam("acc", "report_cancels", 0) <br>
          /* by default ww do not adjust the direct of the sequential
          requests. <br>
          if you enable this parameter, be sure the enable
          "append_fromtag" <br>
          in "rr" module */ <br>
          modparam("acc", "detect_direction", 0) <br>
          /* account triggers (flags) */ <br>
          modparam("acc", "log_flag", FLT_ACC) <br>
          modparam("acc", "log_missed_flag", FLT_ACCMISSED) <br>
          modparam("acc", "log_extra", <br>
          "src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")

          <br>
          modparam("acc", "failed_transaction_flag", FLT_ACCFAILED) <br>
          /* enhanced DB accounting */ <br>
          #!ifdef WITH_ACCDB <br>
          modparam("acc", "db_flag", FLT_ACC) <br>
          modparam("acc", "db_missed_flag", FLT_ACCMISSED) <br>
          modparam("acc", "db_url", DBURL) <br>
          modparam("acc", "db_extra", <br>
          "src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")

          <br>
          #!endif <br>
          <br>
          <br>
          # ----- usrloc params ----- <br>
          /* enable DB persistency for location entries */ <br>
          #!ifdef WITH_USRLOCDB <br>
          modparam("usrloc", "db_url", DBURL) <br>
          modparam("usrloc", "db_mode", 2) <br>
          modparam("usrloc", "use_domain", MULTIDOMAIN) <br>
          #!endif <br>
          <br>
          <br>
          # ----- auth_db params ----- <br>
          #!ifdef WITH_AUTH <br>
          modparam("auth_db", "db_url", DBURL) <br>
          modparam("auth_db", "calculate_ha1", yes) <br>
          modparam("auth_db", "password_column", "password") <br>
          modparam("auth_db", "load_credentials", "") <br>
          modparam("auth_db", "use_domain", MULTIDOMAIN) <br>
          <br>
          # ----- permissions params ----- <br>
          #!ifdef WITH_IPAUTH <br>
          modparam("permissions", "db_url", DBURL) <br>
          modparam("permissions", "db_mode", 1) <br>
          #!endif <br>
          <br>
          #!endif <br>
          <br>
          <br>
          # ----- alias_db params ----- <br>
          #!ifdef WITH_ALIASDB <br>
          modparam("alias_db", "db_url", DBURL) <br>
          modparam("alias_db", "use_domain", MULTIDOMAIN) <br>
          #!endif <br>
          <br>
          <br>
          # ----- domain params ----- <br>
          #!ifdef WITH_MULTIDOMAIN <br>
          modparam("domain", "db_url", DBURL) <br>
          # use caching <br>
          modparam("domain", "db_mode", 1) <br>
          # register callback to match myself condition with domains
          list <br>
          modparam("domain", "register_myself", 1) <br>
          #!endif <br>
          <br>
          <br>
          #!ifdef WITH_PRESENCE <br>
          # ----- presence params ----- <br>
          modparam("presence", "db_url", DBURL) <br>
          <br>
          # ----- presence_xml params ----- <br>
          modparam("presence_xml", "db_url", DBURL) <br>
          modparam("presence_xml", "force_active", 1) <br>
          modparam("presence_xml", "integrated_xcap_server", 1) <br>
          modparam("rls", "db_url", DBURL) <br>
          modparam("rls", "xcap_table", "xcap") <br>
          modparam("rls", "rlsubs_table", "rls_watchers") <br>
          modparam("rls", "rlpres_table", "rls_presentity") <br>
          modparam("rls", "clean_period", 100) <br>
          modparam("rls", "waitn_time", 50) <br>
          modparam("rls", "max_expires", 10800) <br>
          modparam("rls", "hash_size", 9) <br>
          modparam("rls", "xcap_root", <a class="moz-txt-link-rfc2396E"
            href="http://ciervo.inf.um.es/xcap-root:5060">"http://ciervo.inf.um.es/xcap-root:5060"</a>)
          <br>
          modparam("rls", "integrated_xcap_server", 1) <br>
          modparam("rls", "to_presence_code", 10) <br>
          modparam("rls", "rls_event", "presence") <br>
          #!endif <br>
          <br>
          <br>
          #!ifdef WITH_NAT <br>
          # ----- rtpproxy params ----- <br>
          modparam("rtpproxy", "rtpproxy_sock", "udp:127.0.0.1:7722") <br>
          <br>
          # ----- nathelper params ----- <br>
          modparam("nathelper", "natping_interval", 30) <br>
          modparam("nathelper", "ping_nated_only", 1) <br>
          modparam("nathelper", "sipping_bflag", FLB_NATSIPPING) <br>
          modparam("nathelper", "sipping_from", <a
            class="moz-txt-link-rfc2396E" href="sip:pinger@kamailio.org">"sip:pinger@kamailio.org"</a>)
          <br>
          <br>
          # params needed for NAT traversal in other modules <br>
          modparam("nathelper|registrar", "received_avp",
          "$avp(RECEIVED)") <br>
          modparam("usrloc", "nat_bflag", FLB_NATB) <br>
          #!endif <br>
          <br>
          <br>
          #!ifdef WITH_TLS <br>
          # ----- tls params ----- <br>
          modparam("tls", "config", "/usr/local/etc/kamailio/tls.cfg") <br>
          #!endif <br>
          <br>
          #!ifdef WITH_ANTIFLOOD <br>
          # ----- pike params ----- <br>
          modparam("pike", "sampling_time_unit", 2) <br>
          modparam("pike", "reqs_density_per_unit", 16) <br>
          modparam("pike", "remove_latency", 4) <br>
          <br>
          # ----- htable params ----- <br>
          # ip ban htable with autoexpire after 5 minutes <br>
          modparam("htable", "htable",
          "ipban=&gt;size=8;autoexpire=300;") <br>
          #!endif <br>
          <br>
          #!ifdef WITH_XMLRPC <br>
          # ----- xmlrpc params ----- <br>
          modparam("xmlrpc", "route", "XMLRPC"); <br>
          modparam("xmlrpc", "url_match", "^/RPC") <br>
          #!endif <br>
          <br>
          #!ifdef WITH_XCAPSRV <br>
          # ----- xcap_server params ----- <br>
          modparam("xcap_server", "db_url", DBURL) <br>
          # modparam("rls", "integrated_xcap_server", 1) <br>
          #!endif <br>
          <br>
          ####### Routing Logic ######## <br>
          <br>
          <br>
          # Main SIP request routing logic <br>
          # - processing of any incoming SIP request starts with this
          route <br>
          route { <br>
          <br>
          # per request initial checks <br>
          route(REQINIT); <br>
          <br>
          # NAT detection <br>
          route(NAT); <br>
          <br>
          # handle requests within SIP dialogs <br>
          route(WITHINDLG); <br>
          <br>
          ### only initial requests (no To tag) <br>
          <br>
          # CANCEL processing <br>
          if (is_method("CANCEL")) <br>
          { <br>
          if (t_check_trans()) <br>
          t_relay(); <br>
          exit; <br>
          } <br>
          <br>
          t_check_trans(); <br>
          <br>
          # authentication <br>
          route(AUTH); <br>
          <br>
          # record routing for dialog forming requests (in case they are
          routed) <br>
          # - remove preloaded route headers <br>
          remove_hf("Route"); <br>
          if (is_method("INVITE|SUBSCRIBE")) <br>
          record_route(); <br>
          <br>
          # account only INVITEs <br>
          if (is_method("INVITE")) <br>
          { <br>
          setflag(FLT_ACC); # do accounting <br>
          } <br>
          <br>
          # dispatch requests to foreign domains <br>
          route(SIPOUT); <br>
          <br>
          ### requests for my local domains <br>
          <br>
          # handle presence related requests <br>
          route(PRESENCE); <br>
          <br>
          # handle registrations <br>
          route(REGISTRAR); <br>
          <br>
          if ($rU==$null) <br>
          { <br>
          # request with no Username in RURI <br>
          sl_send_reply("484","Address Incomplete"); <br>
          exit; <br>
          } <br>
          <br>
          # dispatch destinations to PSTN <br>
          route(PSTN); <br>
          <br>
          # user location service <br>
          route(LOCATION); <br>
          <br>
          route(RELAY); <br>
          } <br>
          <br>
          <br>
          route[RELAY] { <br>
          #!ifdef WITH_NAT <br>
          if (check_route_param("nat=yes")) { <br>
          setbflag(FLB_NATB); <br>
          } <br>
          if (isflagset(FLT_NATS) || isbflagset(FLB_NATB)) { <br>
          route(RTPPROXY); <br>
          } <br>
          #!endif <br>
          <br>
          /* example how to enable some additional event routes */ <br>
          if (is_method("INVITE")) { <br>
          #t_on_branch("BRANCH_ONE"); <br>
          t_on_reply("REPLY_ONE"); <br>
          t_on_failure("FAIL_ONE"); <br>
          } <br>
          <br>
          if (!t_relay()) { <br>
          sl_reply_error(); <br>
          } <br>
          exit; <br>
          } <br>
          <br>
          # Per SIP request initial checks <br>
          route[REQINIT] { <br>
          #!ifdef WITH_ANTIFLOOD <br>
          # flood dection from same IP and traffic ban for a while <br>
          # be sure you exclude checking trusted peers, such as pstn
          gateways <br>
          # - local host excluded (e.g., loop to self) <br>
          if(src_ip!=myself) <br>
          { <br>
          if($sht(ipban=&gt;$si)!=$null) <br>
          { <br>
          # ip is already blocked <br>
          xdbg("request from blocked IP - $rm from $fu (IP:$si:$sp)\n");
          <br>
          exit; <br>
          } <br>
          if (!pike_check_req()) <br>
          { <br>
          xlog("L_ALERT","ALERT: pike blocking $rm from $fu
          (IP:$si:$sp)\n"); <br>
          $sht(ipban=&gt;$si) = 1; <br>
          exit; <br>
          } <br>
          } <br>
          #!endif <br>
          <br>
          if (!mf_process_maxfwd_header("10")) { <br>
          sl_send_reply("483","Too Many Hops"); <br>
          exit; <br>
          } <br>
          <br>
          if(!sanity_check("1511", "7")) <br>
          { <br>
          xlog("Malformed SIP message from $si:$sp\n"); <br>
          exit; <br>
          } <br>
          } <br>
          <br>
          # Handle requests within SIP dialogs <br>
          route[WITHINDLG] { <br>
          if (has_totag()) { <br>
          # sequential request withing a dialog should <br>
          # take the path determined by record-routing <br>
          if (loose_route()) { <br>
          if (is_method("BYE")) { <br>
          setflag(FLT_ACC); # do accounting ... <br>
          setflag(FLT_ACCFAILED); # ... even if the transaction fails <br>
          } <br>
          route(RELAY); <br>
          } else { <br>
          if (is_method("SUBSCRIBE") &amp;&amp; uri == myself) { <br>
          # in-dialog subscribe requests <br>
          route(PRESENCE); <br>
          exit; <br>
          } <br>
          if ( is_method("ACK") ) { <br>
          if ( t_check_trans() ) { <br>
          # no loose-route, but stateful ACK; <br>
          # must be an ACK after a 487 <br>
          # or e.g. 404 from upstream server <br>
          t_relay(); <br>
          exit; <br>
          } else { <br>
          # ACK without matching transaction ... ignore and discard <br>
          exit; <br>
          } <br>
          } <br>
          sl_send_reply("404","Not here"); <br>
          } <br>
          exit; <br>
          } <br>
          } <br>
          <br>
          # Handle SIP registrations <br>
          route[REGISTRAR] { <br>
          if (is_method("REGISTER")) <br>
          { <br>
          if(isflagset(FLT_NATS)) <br>
          { <br>
          setbflag(FLB_NATB); <br>
          # uncomment next line to do SIP NAT pinging <br>
          ## setbflag(FLB_NATSIPPING); <br>
          } <br>
          if (!save("location")) <br>
          sl_reply_error(); <br>
          <br>
          exit; <br>
          } <br>
          } <br>
          <br>
          # USER location service <br>
          route[LOCATION] { <br>
          <br>
          #!ifdef WITH_ALIASDB <br>
          # search in DB-based aliases <br>
          alias_db_lookup("dbaliases"); <br>
          #!endif <br>
          <br>
          if (!lookup("location")) { <br>
          switch ($rc) { <br>
          case -1: <br>
          case -3: <br>
          t_newtran(); <br>
          t_reply("404", "Not Found"); <br>
          exit; <br>
          case -2: <br>
          sl_send_reply("405", "Method Not Allowed"); <br>
          exit; <br>
          } <br>
          } <br>
          <br>
          # when routing via usrloc, log the missed calls also <br>
          if (is_method("INVITE")) <br>
          { <br>
          setflag(FLT_ACCMISSED); <br>
          } <br>
          } <br>
          <br>
          # Presence server route <br>
          route[PRESENCE] { <br>
          <br>
          if(!is_method("PUBLISH|SUBSCRIBE")) <br>
          return; <br>
          <br>
          #!ifdef WITH_PRESENCE <br>
          <br>
          if (!t_newtran()) <br>
          { <br>
          sl_reply_error(); <br>
          exit; <br>
          }; <br>
          <br>
          if(is_method("PUBLISH")) <br>
          { <br>
          handle_publish(); <br>
          t_release(); <br>
          } <br>
          else if( is_method("SUBSCRIBE")) <br>
          { <br>
          $var(ret_code)= rls_handle_subscribe(); <br>
          <br>
          if($var(ret_code)== 10) { <br>
          handle_subscribe(); <br>
          } <br>
          t_release(); <br>
          <br>
          }else if(method=="NOTIFY") <br>
          { <br>
          rls_handle_notify(); <br>
          } <br>
          <br>
          exit; <br>
          #!endif <br>
          # if presence enabled, this part will not be executed <br>
          if (is_method("PUBLISH") || $rU==$null) <br>
          { <br>
          sl_send_reply("404", "Not here"); <br>
          exit; <br>
          } <br>
          return; <br>
          } <br>
          <br>
          # Authentication route <br>
          route[AUTH] { <br>
          return; <br>
          #!ifdef WITH_AUTH <br>
          if (is_method("REGISTER")) <br>
          { <br>
          # authenticate the REGISTER requests (uncomment to enable
          auth) <br>
          if (!www_authorize("$td", "subscriber")) <br>
          { <br>
          www_challenge("$td", "0"); <br>
          exit; <br>
          } <br>
          <br>
          if ($au!=$tU) <br>
          { <br>
          sl_send_reply("403","Forbidden auth ID"); <br>
          exit; <br>
          } <br>
          } else { <br>
          <br>
          #!ifdef WITH_IPAUTH <br>
          if(allow_source_address()) <br>
          { <br>
          # source IP allowed <br>
          return; <br>
          } <br>
          #!endif <br>
          # authenticate if from local subscriber <br>
          if (from_uri==myself) <br>
          { <br>
          if (!proxy_authorize("$fd", "subscriber")) { <br>
          proxy_challenge("$fd", "0"); <br>
          exit; <br>
          } <br>
          if (is_method("PUBLISH")) <br>
          { <br>
          if ($au!=$tU) { <br>
          sl_send_reply("403","Forbidden auth ID"); <br>
          exit; <br>
          } <br>
          } else { <br>
          if ($au!=$fU) { <br>
          sl_send_reply("403","Forbidden auth ID"); <br>
          exit; <br>
          } <br>
          } <br>
          <br>
          consume_credentials(); <br>
          # caller authenticated <br>
          } else { <br>
          # caller is not local subscriber, then check if it calls <br>
          # a local destination, otherwise deny, not an open relay here
          <br>
          if (!uri==myself) <br>
          { <br>
          sl_send_reply("403","Not relaying"); <br>
          exit; <br>
          } <br>
          } <br>
          } <br>
          #!endif <br>
          return; <br>
          } <br>
          <br>
          # Caller NAT detection route <br>
          route[NAT] { <br>
          #!ifdef WITH_NAT <br>
          force_rport(); <br>
          if (nat_uac_test("19")) { <br>
          if (method=="REGISTER") { <br>
          fix_nated_register(); <br>
          } else { <br>
          fix_nated_contact(); <br>
          } <br>
          setflag(FLT_NATS); <br>
          } <br>
          #!endif <br>
          return; <br>
          } <br>
          <br>
          # RTPProxy control <br>
          route[RTPPROXY] { <br>
          #!ifdef WITH_NAT <br>
          if (is_method("BYE")) { <br>
          unforce_rtp_proxy(); <br>
          } else if (is_method("INVITE")){ <br>
          force_rtp_proxy(); <br>
          } <br>
          if (!has_totag()) add_rr_param(";nat=yes"); <br>
          #!endif <br>
          return; <br>
          } <br>
          <br>
          # Routing to foreign domains <br>
          route[SIPOUT] { <br>
          if (!uri==myself) <br>
          { <br>
          append_hf("P-hint: outbound\r\n"); <br>
          route(RELAY); <br>
          } <br>
          } <br>
          <br>
          # PSTN GW routing <br>
          route[PSTN] { <br>
          #!ifdef WITH_PSTN <br>
          # check if PSTN GW IP is defined <br>
          if (strempty($sel(cfg_get.pstn.gw_ip))) { <br>
          xlog("SCRIPT: PSTN rotuing enabled but pstn.gw_ip not
          defined\n"); <br>
          return; <br>
          } <br>
          <br>
          # route to PSTN dialed numbers starting with '+' or '00' <br>
          # (international format) <br>
          # - update the condition to match your dialing rules for PSTN
          routing <br>
          if(!($rU=~"^(\+|00)[1-9][0-9]{3,20}$")) <br>
          return; <br>
          <br>
          # only local users allowed to call <br>
          if(from_uri!=myself) { <br>
          sl_send_reply("403", "Not Allowed"); <br>
          exit; <br>
          } <br>
          <br>
          $ru = "sip:" + $rU + "@" + $sel(cfg_get.pstn.gw_ip); <br>
          <br>
          route(RELAY); <br>
          exit; <br>
          #!endif <br>
          <br>
          return; <br>
          } <br>
          <br>
          # XMLRPC routing <br>
          #!ifdef WITH_XMLRPC <br>
          route[XMLRPC] <br>
          { <br>
          # allow XMLRPC from localhost <br>
          if ((method=="POST" || method=="GET") <br>
          &amp;&amp; (src_ip==127.0.0.1)) { <br>
          # close connection only for xmlrpclib user agents (there is a
          bug in <br>
          # xmlrpclib: it waits for EOF before interpreting the
          response). <br>
          if ($hdr(User-Agent) =~ "xmlrpclib") <br>
          set_reply_close(); <br>
          set_reply_no_connect(); <br>
          dispatch_rpc(); <br>
          exit; <br>
          } <br>
          send_reply("403", "Forbidden"); <br>
          exit; <br>
          } <br>
          #!endif <br>
          <br>
          # Sample branch router <br>
          branch_route[BRANCH_ONE] { <br>
          xdbg("new branch at $ru\n"); <br>
          } <br>
          <br>
          # Sample onreply route <br>
          onreply_route[REPLY_ONE] { <br>
          xdbg("incoming reply\n"); <br>
          #!ifdef WITH_NAT <br>
          if ((isflagset(FLT_NATS) || isbflagset(FLB_NATB)) <br>
          &amp;&amp; status=~"(183)|(2[0-9][0-9])") { <br>
          force_rtp_proxy(); <br>
          } <br>
          if (isbflagset("6")) { <br>
          fix_nated_contact(); <br>
          } <br>
          #!endif <br>
          } <br>
          <br>
          # Sample failure route <br>
          failure_route[FAIL_ONE] { <br>
          #!ifdef WITH_NAT <br>
          if (is_method("INVITE") <br>
          &amp;&amp; (isbflagset(FLB_NATB) || isflagset(FLT_NATS))) { <br>
          unforce_rtp_proxy(); <br>
          } <br>
          #!endif <br>
          <br>
          if (t_is_canceled()) { <br>
          exit; <br>
          } <br>
          <br>
          # uncomment the following lines if you want to block client <br>
          # redirect based on 3xx replies. <br>
          ##if (t_check_status("3[0-9][0-9]")) { <br>
          ##t_reply("404","Not found"); <br>
          ## exit; <br>
          ##} <br>
          <br>
          # uncomment the following lines if you want to redirect the
          failed <br>
          # calls to a different new destination <br>
          ##if (t_check_status("486|408")) { <br>
          ## sethostport("192.168.2.100:5060"); <br>
          ## append_branch(); <br>
          ## # do not set the missed call flag again <br>
          ## t_relay(); <br>
          ##} <br>
          } <br>
          <br>
          #!ifdef WITH_XCAPSRV <br>
          # #!define WITH_XHTTPAUTH <br>
          event_route[xhttp:request] { <br>
          xdbg("===== xhttp: request [$rv] $rm =&gt; $hu\n"); <br>
          <br>
          #!ifdef WITH_XHTTPAUTH <br>
          if (!www_authorize("xcap", "subscriber")) <br>
          { <br>
          www_challenge("xcap", "0"); <br>
          exit; <br>
          } <br>
          #!endif <br>
          xdbg("===== xhttp: Antes del if de $hu\n"); <br>
          if($hu=~"^/xcap-root/") <br>
          { <br>
          xdbg("===== xhttp: Dentro del if de $hu\n"); <br>
          set_reply_close(); <br>
          set_reply_no_connect(); <br>
          # xcap ops <br>
          $xcapuri(u=&gt;data) = $hu; <br>
          if($xcapuri(u=&gt;xuid)=~"^<a class="moz-txt-link-freetext"
            href="sip:.+@.+">sip:.+@.+</a>") <br>
          $var(uri) = $xcapuri(u=&gt;xuid); <br>
          else if($xcapuri(u=&gt;xuid)=~<a class="moz-txt-link-rfc2396E"
            href="mailto:.+@.+">".+@.+"</a>) <br>
          $var(uri) = "sip:" + $xcapuri(u=&gt;xuid); <br>
          else <br>
          $var(uri) = "sip:"+ $xcapuri(u=&gt;xuid) + "@" + $Ri; <br>
          xlog("===== xhttp: $xcapuri(u=&gt;auid) :
          $xcapuri(u=&gt;xuid)\n"); <br>
          if($xcapuri(u=&gt;auid)=="xcap-caps") <br>
          { <br>
          $var(xbody) = <br>
          "&lt;?xml version='1.0' encoding='UTF-8'?&gt; <br>
          &lt;xcap-caps xmlns='urn:ietf:params:xml:ns:xcap-caps'&gt; <br>
          &lt;auids&gt; <br>
          &lt;auid&gt;rls-services&lt;/auid&gt; <br>
          &lt;auid&gt;pidf-manipulation&lt;/auid&gt; <br>
          &lt;auid&gt;xcap-caps&lt;/auid&gt; <br>
          &lt;auid&gt;resource-lists&lt;/auid&gt; <br>
          &lt;auid&gt;pres-rules&lt;/auid&gt; <br>
          &lt;auid&gt;org.openmobilealliance.pres-rules&lt;/auid&gt; <br>
          &lt;/auids&gt; <br>
          &lt;extensions&gt; <br>
          &lt;/extensions&gt; <br>
          &lt;namespaces&gt; <br>
          &lt;namespace&gt;urn:ietf:params:xml:ns:rls-services&lt;/namespace&gt;

          <br>
          &lt;namespace&gt;urn:ietf:params:xml:ns:pidf&lt;/namespace&gt;
          <br>
          &lt;namespace&gt;urn:ietf:params:xml:ns:xcap-caps&lt;/namespace&gt;

          <br>
          &lt;namespace&gt;urn:ietf:params:xml:ns:resource-lists&lt;/namespace&gt;

          <br>
          &lt;namespace&gt;urn:ietf:params:xml:ns:pres-rules&lt;/namespace&gt;

          <br>
          &lt;/namespaces&gt; <br>
          &lt;/xcap-caps&gt;"; <br>
          xhttp_reply("200", "ok", "application/xcap-caps+xml", <br>
          "$var(xbody)"); <br>
          exit; <br>
          } <br>
          <br>
          #!ifdef WITH_XHTTPAUTH <br>
          # be sure auth user access only its documents <br>
          if ($au!=$(var(uri){uri.user})) { <br>
          xhttp_reply("403", "Forbidden", "text/html", <br>
          "&lt;html&gt;&lt;body&gt;$si:$sp&lt;/body&gt;&lt;/html&gt;");
          <br>
          exit; <br>
          } <br>
          <br>
          #!endif <br>
          xdbg("===== xhttp: Antes del switch $rm =&gt; $hu\n"); <br>
          switch($rm) { <br>
          case "PUT": <br>
          xcaps_put("$var(uri)", "$hu", "$rb"); <br>
          if($xcapuri(u=&gt;auid)=~"pres-rules") <br>
          { <br>
          xlog("===== xhttp put: refreshing watchers for $var(uri)\n");
          <br>
          pres_update_watchers("$var(uri)", "presence"); <br>
          pres_refresh_watchers("$var(uri)", "presence", 1); <br>
          } <br>
          exit; <br>
          break; <br>
          case "GET": <br>
          xlog("===== xhttp: get $var(uri) =&gt; $hu\n"); <br>
          xcaps_get("$var(uri)", "$hu"); <br>
          exit; <br>
          break; <br>
          case "DELETE": <br>
          xcaps_del("$var(uri)", "$hu"); <br>
          if($xcapuri(u=&gt;auid)=~"pres-rules") <br>
          { <br>
          xlog("===== xhttp del: refreshing watchers for $var(uri)\n");
          <br>
          pres_update_watchers("$var(uri)", "presence"); <br>
          pres_refresh_watchers("$var(uri)", "presence", 1); <br>
          } <br>
          exit; <br>
          break; <br>
          } <br>
          } <br>
          <br>
          # http ops <br>
          xhttp_reply("200", "ok", "text/html", <br>
          "&lt;html&gt;&lt;body&gt;OK:
          $si:$sp&lt;/body&gt;&lt;/html&gt;"); <br>
          exit; <br>
          } <br>
          #!endif/ <br>
          <br>
          <br>
          Regards, <br>
          Andr&eacute;s. <br>
          <br>
          El 21/12/10 10:22, Klaus Darilion escribi&oacute;: <br>
          <blockquote type="cite">Am 16.12.2010 13:36, schrieb "Andr&eacute;s
            S. Garc&iacute;a Ruiz": <br>
            <blockquote type="cite"> <br>
              B.5) P-CSCF ---- SUBSCRIBE ----&gt; Presentity??? <br>
              <br>
              SUBSCRIBE <a class="moz-txt-link-freetext"
                href="sip:testuser01@155.54.190.245:8060;rinstance=9b7761b4bcaa4bd0">sip:testuser01@155.54.190.245:8060;rinstance=9b7761b4bcaa4bd0</a>
              <br>
              SIP/2.0 <br>
              Record-Route: <a class="moz-txt-link-rfc2396E"
                href="sip:mt@pcscf.open-ims.test:4060;lr">&lt;sip:mt@pcscf.open-ims.test:4060;lr&gt;</a>
              <br>
              Record-Route: <a class="moz-txt-link-rfc2396E"
                href="sip:mt@scscf.open-ims.test:6060;lr">&lt;sip:mt@scscf.open-ims.test:6060;lr&gt;</a>
              <br>
              Via: SIP/2.0/TCP
              155.54.210.134:4060;branch=z9hG4bK07df.baa7cf24.0 <br>
              Via: SIP/2.0/UDP <br>
              155.54.210.135:6060;received=155.54.210.135;rport=6060;branch=z9hG4bK07df.8a35e4f3.0

              <br>
              <br>
              <br>
              Via: SIP/2.0/UDP
              155.54.210.136;branch=z9hG4bK07df.3688b985.0 <br>
              Via: SIP/2.0/UDP
              155.54.190.245;branch=z9hG4bK07df.964e0ba7.0 <br>
              To: <a class="moz-txt-link-freetext"
                href="sip:testuser01@open-ims.test">sip:testuser01@open-ims.test</a>
              <br>
              From: <br>
              <a class="moz-txt-link-freetext"
href="sip:restricted_areas@open-ims.test;tag=533cb9e91f4b999cf76861cbb9ed54ed-32d5">sip:restricted_areas@open-ims.test;tag=533cb9e91f4b999cf76861cbb9ed54ed-32d5</a>
              <br>
              <br>
              <br>
              CSeq: 10 SUBSCRIBE <br>
              Call-ID: <a class="moz-txt-link-abbreviated"
                href="mailto:7fd8dfdd-21694@127.0.0.1">7fd8dfdd-21694@127.0.0.1</a>
              <br>
              Content-Length: 0 <br>
              User-Agent: kamailio (3.2.0-dev1 (i386/linux)) <br>
              Max-Forwards: 14 <br>
              Event: presence <br>
              Contact: <a class="moz-txt-link-rfc2396E"
                href="sip:155.54.190.245:5060;transport=udp">&lt;sip:155.54.190.245:5060;transport=udp&gt;</a>
              <br>
              Expires: 10810 <br>
              Max-Forwards: 70 <br>
              Support: eventlist <br>
              P-Called-Party-ID: <a class="moz-txt-link-rfc2396E"
                href="sip:testuser01@open-ims.test">&lt;sip:testuser01@open-ims.test&gt;</a>
              <br>
              <br>
              <br>
              The step B.5 is sent directly to the presentity
              testuser01. Instead of <br>
              that, I thought that message was suppose to be sent to the
              presence <br>
              server in the URI that is shown in Contact header. <br>
            </blockquote>
            <br>
            <br>
            If the P-CSCF is not forwarding the request as supposed, I
            guess you <br>
            have to fix the routing on the P-CSCF. <br>
            <br>
            klaus <br>
          </blockquote>
          <br>
        </blockquote>
        <br>
        _______________________________________________ <br>
        SIP Express Router (SER) and Kamailio (OpenSER) - sr-users
        mailing list <br>
        <a class="moz-txt-link-abbreviated"
          href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a>
        <br>
        <a class="moz-txt-link-freetext"
          href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a>
        <br>
      </blockquote>
      <br>
    </blockquote>
    <br>
    <br>
  </body>
</html>