<html>
  <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    Looks like 1800 both ways.<br>
    Here are the packets:<br>
    <br>
    SUBSCRIBE <a class="moz-txt-link-abbreviated" href="mailto:sip:1020129@xxx.xxx.net:5020">sip:1020129@xxx.xxx.net:5020</a> SIP/2.0<br>
    Via: SIP/2.0/UDP xxxxxxxx9:1025;rport;branch=z9hG4bK738754275<br>
    From: "Bill" <a class="moz-txt-link-rfc2396E" href="mailto:sip:1020101@xxx.xxx.net:5020"><sip:1020101@xxx.xxx.net:5020></a>;tag=3473584939<br>
    To: <a class="moz-txt-link-rfc2396E" href="mailto:sip:1020129@xxx.xxx.net:5020"><sip:1020129@xxx.xxx.net:5020></a><br>
    Call-ID: <a class="moz-txt-link-abbreviated" href="mailto:0_2729374544@192.168.10.247">0_2729374544@192.168.10.247</a><br>
    CSeq: 2 SUBSCRIBE<br>
    Contact: <sip:1020101@xxxxxxxxxx:1025><br>
    Proxy-Authorization: Digest username="1020101", realm="xxx.xxxnet",
    nonce="V6n1hlep9FpBpyh0aCfkrnrITRd1Q3Mi",
    uri=<a class="moz-txt-link-rfc2396E" href="mailto:sip:1020129@xxx.xxx.net:5020">"sip:1020129@xxx.xxx.net:5020"</a>,
    response="decbe671fd4295cfa8406867dd499e14", algorithm=MD5<br>
    Allow: INVITE, INFO, PRACK, ACK, BYE, CANCEL, OPTIONS, NOTIFY,
    REGISTER, SUBSCRIBE, REFER, PUBLISH, UPDATE, MESSAGE<br>
    Accept: application/dialog-info+xml<br>
    Max-Forwards: 70<br>
    User-Agent: Yealink SIP-T23G 44.80.0.80<br>
    Expires: 1800<br>
    Event: dialog<br>
    Content-Length: 0<br>
    <br>
    SIP/2.0 202 OK<br>
    Via: SIP/2.0/UDP
xxxxxxxxxxxxxxxx9:1025;rport=1025;branch=z9hG4bK738754275;received=xxxxxxxxxxxxxxxxxxx<br>
    From: "Bill" <a class="moz-txt-link-rfc2396E" href="mailto:sip:1020101@xxx.xxx.net:5020"><sip:1020101@xxx.xxx.net:5020></a>;tag=3473584939<br>
    To:
<a class="moz-txt-link-rfc2396E" href="mailto:sip:1020129@xxx.xxx.net:5020"><sip:1020129@xxx.xxx.net:5020></a>;tag=829414f9145fc899ae1e9b7eacc23dbe-1153<br>
    Call-ID: <a class="moz-txt-link-abbreviated" href="mailto:0_2729374544@192.168.10.247">0_2729374544@192.168.10.247</a><br>
    CSeq: 2 SUBSCRIBE<br>
    Expires: 1800<br>
    Contact: <sip:xxxxxxxxxxxxxxx:5020><br>
    Server: kamailio (4.4.2 (x86_64/linux))<br>
    Content-Length: 0<br>
    <br>
    <div class="moz-cite-prefix">On 08/09/2016 12:36 AM,
      Daniel-Constantin Mierla wrote:<br>
    </div>
    <blockquote
      cite="mid:f2f9c0c0-a7fd-cddc-81cb-5e24d297d867@gmail.com"
      type="cite">
      <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
      <p>Hello,</p>
      <p>what is the Expires value in the SUBSCRIBE and its response?
        You can also send the pcap file for such case so we can check.<br>
      </p>
      Cheers,<br>
      Daniel<br>
      <br>
      <div class="moz-cite-prefix">On 09/08/16 01:26, Bill wrote:<br>
      </div>
      <blockquote cite="mid:57A9150D.1080308@novatrope.us" type="cite">
        <meta content="text/html; charset=utf-8"
          http-equiv="Content-Type">
        Still having issues with presence. Now I notice that when the
        watcher phone signs on, it puts an entry in the active_watchers
        table. BUT this entry is deleted in about 15 seconds. Does
        anybody know if this is normal???? or what is causing it?<br>
        <br>
        Bill<br>
        <br>
        <br>
        <br>
        <div class="moz-cite-prefix">On 08/08/2016 12:12 PM, Bill wrote:<br>
        </div>
        <blockquote cite="mid:57A8D98C.3040700@novatrope.us" type="cite">
          <meta content="text/html; charset=utf-8"
            http-equiv="Content-Type">
          As a followup to my earlier message, I have also found that
          the pua table in my database is empty. Since I have pua
          activated and db_mode set to 2 (see config file below), I
          don't understand why I am not getting any entries in the pua
          table. And I wonder if this is related to the lack of notify's
          that I am seeing. Anybody?<br>
          <br>
          <div class="moz-cite-prefix">On 08/06/2016 10:35 AM, Bill
            wrote:<br>
          </div>
          <blockquote cite="mid:57A61FFD.2080201@novatrope.us"
            type="cite">
            <meta content="text/html; charset=utf-8"
              http-equiv="Content-Type">
            We have tried all of your suggestions, but still not getting
            any light changes on the watcher.<br>
            The basic problem seems to be that the watched phone sends
            PUBLISH packets to the server, but the server does not send
            NOTIFY packets to the watcher phone.<br>
            We are seeing the following error in the logs every time the
            watched phone changes status:<br>
            <br>
            <font color="#ff0000">DEBUG: presence [notify.c:1263]:
              publ_notify(): Could not find subs_dialog<br>
              <br>
              <font color="#000000">We are running Kam 4.4.2</font><br>
            </font><br>
            If anybody has any ideas what could be causing this, let me
            know.<br>
            <br>
            <br>
            Thanks in advance, Bill<br>
            <br>
            <br>
            <br>
            For completeness, here is our config file:<br>
            <br>
            #!define WITH_MYSQL<br>
            #!define WITH_AUTH<br>
            #!define WITH_USRLOCDB<br>
            #define WITH_ANTIFLOOD<br>
            #!define WITH_PRESENCE<br>
            #!define WITH_VOICEMAIL<br>
            #!define WITH_DEBUG<br>
            #!define WITH_NAT<br>
            #!KAMAILIO<br>
            #<br>
            # Kamailio (OpenSER) SIP Server v4.4 - default configuration
            script<br>
            #     - web: <a moz-do-not-send="true"
              class="moz-txt-link-freetext"
              href="http://www.kamailio.org">http://www.kamailio.org</a><br>
            #     - git: <a moz-do-not-send="true"
              class="moz-txt-link-freetext" href="http://sip-router.org">http://sip-router.org</a><br>
            #<br>
            # Direct your questions about this file to: <a
              moz-do-not-send="true" class="moz-txt-link-rfc2396E"
              href="mailto:sr-users@lists.sip-router.org"><a class="moz-txt-link-rfc2396E" href="mailto:sr-users@lists.sip-router.org"><sr-users@lists.sip-router.org></a></a><br>
            #<br>
            # Refer to the Core CookBook at <a moz-do-not-send="true"
              class="moz-txt-link-freetext"
              href="http://www.kamailio.org/wiki/">http://www.kamailio.org/wiki/</a><br>
            # for an explanation of possible statements, functions and
            parameters.<br>
            #<br>
            # Several features can be enabled using '#!define
            WITH_FEATURE' directives:<br>
            #<br>
            # *** To run in debug mode:<br>
            #     - define WITH_DEBUG<br>
            #<br>
            # *** To enable mysql:<br>
            #     - define WITH_MYSQL<br>
            #<br>
            # *** To enable authentication execute:<br>
            #     - enable mysql<br>
            #     - define WITH_AUTH<br>
            #     - add users using 'kamctl'<br>
            #<br>
            # *** To enable IP authentication execute:<br>
            #     - enable mysql<br>
            #     - enable authentication<br>
            #     - define WITH_IPAUTH<br>
            #     - add IP addresses with group id '1' to 'address'
            table<br>
            #<br>
            # *** To enable persistent user location execute:<br>
            #     - enable mysql<br>
            #     - define WITH_USRLOCDB<br>
            #<br>
            # *** To enable presence server execute:<br>
            #     - enable mysql<br>
            #     - define WITH_PRESENCE<br>
            #<br>
            # *** To enable nat traversal execute:<br>
            #     - define WITH_NAT<br>
            #     - install RTPProxy: <a moz-do-not-send="true"
              class="moz-txt-link-freetext"
              href="http://www.rtpproxy.org">http://www.rtpproxy.org</a><br>
            #     - start RTPProxy:<br>
            #        rtpproxy -l _your_public_ip_ -s udp:localhost:7722<br>
            #     - option for NAT SIP OPTIONS keepalives:
            WITH_NATSIPPING<br>
            #<br>
            # *** To enable PSTN gateway routing execute:<br>
            #     - define WITH_PSTN<br>
            #     - set the value of pstn.gw_ip<br>
            #     - check route[PSTN] for regexp routing condition<br>
            #<br>
            # *** To enable database aliases lookup execute:<br>
            #     - enable mysql<br>
            #     - define WITH_ALIASDB<br>
            #<br>
            # *** To enable speed dial lookup execute:<br>
            #     - enable mysql<br>
            #     - define WITH_SPEEDDIAL<br>
            #<br>
            # *** To enable multi-domain support execute:<br>
            #     - enable mysql<br>
            #     - define WITH_MULTIDOMAIN<br>
            #<br>
            # *** To enable TLS support execute:<br>
            #     - adjust CFGDIR/tls.cfg as needed<br>
            #     - define WITH_TLS<br>
            #<br>
            # *** To enable XMLRPC support execute:<br>
            #     - define WITH_XMLRPC<br>
            #     - adjust route[XMLRPC] for access policy<br>
            #<br>
            # *** To enable anti-flood detection execute:<br>
            #     - adjust pike and htable=>ipban settings as needed
            (default is<br>
            #       block if more than 16 requests in 2 seconds and ban
            for 300 seconds)<br>
            #     - define WITH_ANTIFLOOD<br>
            #<br>
            # *** To block 3XX redirect replies execute:<br>
            #     - define WITH_BLOCK3XX<br>
            #<br>
            # *** To enable VoiceMail routing execute:<br>
            #     - define WITH_VOICEMAIL<br>
            #     - set the value of voicemail.srv_ip<br>
            #     - adjust the value of voicemail.srv_port<br>
            #<br>
            # *** To enhance accounting execute:<br>
            #     - enable mysql<br>
            #     - define WITH_ACCDB<br>
            #     - add following columns to database<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 src_ip varchar(64) 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 DEFAULT '';<br>
              ALTER TABLE missed_calls ADD COLUMN src_domain
            VARCHAR(128) NOT NULL DEFAULT '';<br>
              ALTER TABLE missed_calls ADD COLUMN src_ip varchar(64) NOT
            NULL default '';<br>
              ALTER TABLE missed_calls ADD COLUMN dst_ouser VARCHAR(64)
            NOT NULL DEFAULT '';<br>
              ALTER TABLE missed_calls ADD COLUMN dst_user VARCHAR(64)
            NOT NULL DEFAULT '';<br>
              ALTER TABLE missed_calls ADD COLUMN dst_domain
            VARCHAR(128) NOT NULL DEFAULT '';<br>
            #!endif<br>
            <br>
            ####### Include Local Config If Exists #########<br>
            import_file "kamailio-local.cfg"<br>
            <br>
            ####### Defined Values #########<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>
            #!ifndef DBURL<br>
            #!define DBURL <a moz-do-not-send="true"
              class="moz-txt-link-rfc2396E"
              href="mailto:mysql://kamailio:kam@@userrw@sql9.telopar.net/kamailio">"mysql://kamailio:kam@@userrw@sql9.telopar.net/kamailio"</a><br>
            #!endif<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>
            #!define FLT_DLG 9<br>
            #!define FLT_DLGINFO 10<br>
            #!define FLB_NATB 6<br>
            #!define FLB_NATSIPPING 7<br>
            <br>
            ####### Global Parameters #########<br>
            <br>
            ### LOG Levels: 3=DBG, 2=INFO, 1=NOTICE, 0=WARN, -1=ERR<br>
            #!ifdef WITH_DEBUG<br>
            debug=6<br>
            log_stderror=no<br>
            #!else<br>
            debug=-1<br>
            log_stderror=no<br>
            #!endif<br>
            <br>
            memdbg=5<br>
            memlog=5<br>
            <br>
            log_facility=LOG_LOCAL0<br>
            <br>
            # number of SIP routing processes<br>
            children=8<br>
            <br>
            /* uncomment the next line to disable TCP (default on) */<br>
            disable_tcp=yes<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="sip.mydomain.com"<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>
            <br>
            listen=udp:<kamail;io server IP>:5020<br>
            <br>
            /* port to listen to */<br>
            #port=5060<br>
            #port=5020<br>
            <br>
            #!ifdef WITH_TLS<br>
            enable_tls=yes<br>
            #!endif<br>
            <br>
            # life time of TCP connection when there is no traffic<br>
            # - a bit higher than registration expires to cope with UA
            behind NAT<br>
            tcp_connection_lifetime=3605<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>
            pstn.gw_port = "" desc "PSTN GW Port"<br>
            #!endif<br>
            <br>
            #!ifdef WITH_VOICEMAIL<br>
            # VoiceMail Routing on offline, busy or no answer<br>
            #<br>
            # - by default Voicemail server IP is empty to avoid
            misrouting<br>
            voicemail.srv_ip = "<asterisk server IP>" desc
            "VoiceMail IP Address"<br>
            voicemail.srv_port = "5060" desc "VoiceMail Port"<br>
            #!endif<br>
            <br>
            ####### Modules Section ########<br>
            <br>
            # set paths to location of modules (to sources or
            installation folders)<br>
            #!ifdef WITH_SRCPATH<br>
            mpath="modules/"<br>
            #!else<br>
            mpath="/usr/local/lib64/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 "corex.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 "cfg_rpc.so"<br>
            loadmodule "mi_rpc.so"<br>
            loadmodule "acc.so"<br>
            loadmodule "exec.so"<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_SPEEDDIAL<br>
            loadmodule "speeddial.so"<br>
            #!endif<br>
            <br>
            #!ifdef WITH_MULTIDOMAIN<br>
            loadmodule "domain.so"<br>
            #!endif<br>
            <br>
            <br>
            <br>
            # ----- pua params -----<br>
            #modparam("pua", "db_url", DBURL)<br>
            #modparam("pua", "db_mode", 2)<br>
            #modparam("pua", "update_period", 60)<br>
            #modparam("pua", "dlginfo_increase_version", 0)<br>
            #modparam("pua", "reginfo_increase_version", 0)<br>
            #modparam("pua", "check_remote_contact", 1)<br>
            #modparam("pua", "fetch_rows", 1000)<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_DEBUG<br>
            loadmodule "debugger.so"<br>
            #!endif<br>
            loadmodule "dialog.so"<br>
            #!ifdef WITH_PRESENCE<br>
            <br>
            loadmodule "presence.so"<br>
            loadmodule "presence_xml.so"<br>
            loadmodule "presence_mwi.so"<br>
            loadmodule "presence_dialoginfo.so"<br>
            #loadmodule "presence_reginfo"<br>
            loadmodule "pua.so"<br>
            #loadmodule "pua_usrloc.so"<br>
            loadmodule "pua_dialoginfo.so"<br>
            <br>
            #!endif<br>
            # ----------------- setting module-specific parameters
            ---------------<br>
            <br>
            <br>
            # ----- mi_fifo params -----<br>
            #modparam("mi_fifo", "fifo_name",
            "/var/run/kamailio/kamailio_fifo")<br>
            <br>
            # ----- ctl params -----<br>
            #modparam("ctl", "binrpc",
            "unix:/var/run/kamailio/kamailio_ctl")<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>
            # set next param to 1 to add value to ;lr param (helps with
            some UAs)<br>
            modparam("rr", "enable_full_lr", 0)<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>
            # max value for expires of registrations<br>
            modparam("registrar", "max_expires", 3600)<br>
            # set it to 1 to enable GRUU<br>
            modparam("registrar", "gruu_enabled", 0)<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;src_ip=$si;"<br>
                "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;src_ip=$si;"<br>
                "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>
            # ----- speeddial params -----<br>
            #!ifdef WITH_SPEEDDIAL<br>
            modparam("speeddial", "db_url", DBURL)<br>
            modparam("speeddial", "use_domain", MULTIDOMAIN)<br>
            #!endif<br>
            <br>
            <br>
            # ----- domain params -----<br>
            #!ifdef WITH_MULTIDOMAIN<br>
            modparam("domain", "db_url", DBURL)<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>
            modparam("presence", "server_address", "sip:<kamaiio
            server ip>:5020" )<br>
            <br>
            #modparam("presence", "timeout_rm_subs", 0)<br>
            #modparam("presence", "send_fast_notify", 1)<br>
            modparam("presence", "db_update_period", 20)<br>
            modparam("presence", "clean_period", 60)<br>
            modparam("presence", "subs_db_mode", 2)<br>
            #modparam("presence", "fetch_rows", 1000)<br>
            modparam("presence", "max_expires", 14430) # PortaOne max
            call time (4 hours) plus a little<br>
            <br>
            # ----- presence_xml params -----<br>
            modparam("presence_xml", "db_url", DBURL)<br>
            modparam("presence_xml", "force_active", 1)<br>
            <br>
            <br>
            # ----- presence_dialoginfo params -----<br>
            modparam("presence_dialoginfo", "force_single_dialog", 1)<br>
            #modparam("presence_dialoginfo", "force_dummy_dialog", 1)<br>
            <br>
            # ----- pua params -----<br>
            modparam("pua", "db_url", DBURL)<br>
            modparam("pua", "db_mode", 2)<br>
            modparam("pua", "db_table", "pua")<br>
            modparam("pua", "update_period", 20)<br>
            modparam("pua", "outbound_proxy", "<Kamailio server
            ip>:5020")<br>
            modparam("pua", "dlginfo_increase_version", 0)<br>
            modparam("pua", "reginfo_increase_version", 0)<br>
            modparam("pua", "check_remote_contact", 1)<br>
            modparam("pua", "fetch_rows", 1000)<br>
            <br>
            <br>
            # ----- pua_dialoginfo params -----<br>
            modparam("pua_dialoginfo", "include_callid", 1)<br>
            modparam("pua_dialoginfo", "send_publish_flag", FLT_DLGINFO)<br>
            modparam("pua_dialoginfo", "caller_confirmed", 0)<br>
            modparam("pua_dialoginfo", "include_tags", 1)<br>
            #modparam("pua_dialoginfo", "override_lifetime", 11420)<br>
            modparam("pua_dialoginfo", "callee_trying", 1)<br>
            <br>
            #!endif<br>
            <br>
            # ----- dialog params -----<br>
            modparam("dialog", "db_url", DBURL)<br>
            modparam("dialog", "enable_stats", 1)<br>
            modparam("dialog", "db_mode", 1)<br>
            modparam("dialog", "dlg_flag", FLT_DLG)<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
              moz-do-not-send="true" class="moz-txt-link-rfc2396E"
              href="mailto:sip:pinger@kamailio.org"><a class="moz-txt-link-rfc2396E" href="mailto:sip:pinger@kamailio.org">"sip:pinger@kamailio.org"</a></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", 20)<br>
            modparam("pike", "remove_latency", 1)<br>
            <br>
            # ----- htable params -----<br>
            # ip ban htable with autoexpire after 5 minutes<br>
            modparam("htable", "htable",
            "ipban=>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_DEBUG<br>
            # ----- debugger params -----<br>
            modparam("debugger", "cfgtrace", 1)<br>
            modparam("debugger", "log_level_name", "exec")<br>
            #!endif<br>
            <br>
            <br>
            ####### Routing Logic ########<br>
            <br>
            <br>
            # Main SIP request routing logic<br>
            # - processing of any incoming SIP request starts with this
            route<br>
            # - note: this is the same as route { ... }<br>
            request_route {<br>
                xlog("ENTER REQUEST ROUTE $rm -- $rb
            [$fu/$tu/$ru/$ci]\r\n\r\n");<br>
                <br>
                # per request initial checks<br>
                route(REQINIT);<br>
            <br>
                # NAT detection<br>
                route(NATDETECT);<br>
            <br>
                # CANCEL processing<br>
                if (is_method("CANCEL")) {<br>
                    if (t_check_trans()) {<br>
                        route(RELAY);<br>
                    }<br>
                    exit;<br>
                }<br>
            <br>
                # handle requests within SIP dialogs<br>
                route(WITHINDLG);<br>
            <br>
                ### only initial requests (no To tag)<br>
            <br>
                # handle retransmissions<br>
                if(t_precheck_trans()) {<br>
                    t_check_trans();<br>
                    exit;<br>
                }<br>
                t_check_trans();<br>
            <br>
                # authentication<br>
                if (registered("location")) {<br>
                    xlog("AUTH IS REGISTER (IP:$si:$sp) $fu");<br>
                    <br>
                } else {<br>
                    xlog("AUTH NOT REGISTER (IP:$si:$sp) $fu");<br>
                };<br>
                    route(AUTH);<br>
                # account only INVITEs<br>
                if (is_method("INVITE")  ) {<br>
                    setflag(FLT_ACC); # do accounting<br>
                    xlog("ALL INVITES COME THROUGH HERE
            [$tU](IP:$si:$sp) $fu\r\n\r\n");<br>
                        <br>
                        if ($tU =~ 'NL'  ){<br>
                            xlog("FOUND NL IN INVITE [$tu](IP:$si:$sp)
            $fu\r\n\r\n");<br>
            <br>
                            $avp(newtU) = $(tU{s.substr,2,0}); <br>
                            xlog("THE NEW TU =  [$avp(newtU)]\r\n");<br>
                            $rU =$avp(newtU);<br>
            <br>
                        } <br>
                    <br>
                    <br>
                }<br>
            <br>
                #if (is_method("REGISTER")) {<br>
                #    xlog("AUTH UNREGISTER (IP:$si:$sp) $fu");<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>
                    xlog("SUBSCRIBE OR INVITE RECEIVED [$rm --
            $tu]\n\r");<br>
                    #if($rm == "SUBSCRIBE"){<br>
                        #xlog("CHECKING MB STATE FOR NEW USER $tU");<br>
                        #exec_avp("/home/xantek/mwi_initial.php $tU");<br>
                    #}<br>
                    record_route();<br>
                }<br>
            <br>
                <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>
                <br>
                route(REGISTRAR);<br>
            <br>
                if ($rU==$null) {<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>
            <br>
            # Wrapper for relaying requests<br>
            route[RELAY] {<br>
                xlog("ROUTE RELAY [$ru] $rm\r\n\r\n");<br>
                # enable additional event routes for forwarded requests<br>
                # - serial forking, RTP relaying handling, a.s.o.<br>
                if (is_method("INVITE|BYE|SUBSCRIBE|UPDATE")) {<br>
                    if(!t_is_set("branch_route"))
            t_on_branch("MANAGE_BRANCH");<br>
                }<br>
                if (is_method("INVITE|SUBSCRIBE|UPDATE")) {<br>
                    if(!t_is_set("onreply_route"))
            t_on_reply("MANAGE_REPLY");<br>
                }<br>
                if (is_method("INVITE")) {<br>
                    if(!t_is_set("failure_route"))
            t_on_failure("MANAGE_FAILURE");<br>
                }<br>
            <br>
                if(is_method("INVITE|BYE|UPDATE|CANCEL|ACK")) {<br>
                    xlog("DIALOG $rm");<br>
                    setflag(FLT_DLGINFO);<br>
                    dlg_manage();<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>
            <br>
            #!ifdef WITH_ANTIFLOOD<br>
                # flood detection 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>
                    if($sht(ipban=>$si)!=$null) {<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>
                        xlog("L_ALERT","ALERT: pike blocking $rm from
            $fu (IP:$si:$sp)\n");<br>
                        $sht(ipban=>$si) = 1;<br>
                        exit;<br>
                    }<br>
                }<br>
                if($ua =~ "friendly-scanner|sipcli") {<br>
                    # silent drop for scanners - uncomment next line if
            want to reply<br>
                    # sl_send_reply("200", "OK");<br>
                    exit;<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(is_method("OPTIONS") && uri==myself
            && $rU==$null) {<br>
                    sl_send_reply("200","Keepalive");<br>
                    exit;<br>
                }<br>
            <br>
                if(!sanity_check("1511", "7")) {<br>
                    xlog("Malformed SIP message from $si:$sp\n");<br>
                    exit;<br>
                }<br>
            }<br>
            <br>
            # Handle requests within SIP dialogs<br>
            route[WITHINDLG] {<br>
                xlog("WITHINDLG $rm");<br>
                if (!has_totag()) return;<br>
            <br>
                # sequential request withing a dialog should<br>
                # take the path determined by record-routing<br>
                if (loose_route()) {<br>
                    route(DLGURI);<br>
                    if (is_method("BYE")) {<br>
                        setflag(FLT_ACC); # do accounting ...<br>
                        setflag(FLT_ACCFAILED); # ... even if the
            transaction fails<br>
                    } else if ( is_method("ACK") ) {<br>
                        # ACK is forwarded statelessy<br>
                        route(NATMANAGE);<br>
                    } else if ( is_method("NOTIFY")  ) {<br>
                        xlog("FOUND NOTIFY [$tu](IP:$si:$sp)
            $fu\r\n\r\n");<br>
                        # Add Record-Route for in-dialog NOTIFY as per
            RFC 6665.<br>
                        record_route();<br>
                    }<br>
                    route(RELAY);<br>
                    exit;<br>
                }<br>
            <br>
                if (is_method("SUBSCRIBE") && 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>
                        route(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>
                exit;<br>
            }<br>
            <br>
            # Handle SIP registrations<br>
            route[REGISTRAR] {<br>
                if (!is_method("REGISTER")) return;<br>
                <br>
                xlog("REGISTER1 [$fu/$tu/$ru/$ci]");<br>
                if(isflagset(FLT_NATS)) {<br>
                    setbflag(FLB_NATB);<br>
            #!ifdef WITH_NATSIPPING<br>
                    # do SIP NAT pinging<br>
                    setbflag(FLB_NATSIPPING);<br>
            #!endif<br>
                }<br>
                <br>
                if (!save("location")) {<br>
                    sl_reply_error();<br>
                }<br>
                <br>
                exit;<br>
            }<br>
            <br>
            # User location service<br>
            route[LOCATION] {<br>
            xlog("CHECKING LOCATION $rm [$fu/$tu/$ru/$ci]");<br>
            #!ifdef WITH_SPEEDDIAL<br>
                # search for short dialing - 2-digit extension<br>
                if($rU=~"^[0-9][0-9]$") {<br>
                    if(sd_lookup("speed_dial")) {<br>
                        route(SIPOUT);<br>
                    }<br>
                }<br>
            #!endif<br>
            <br>
            #!ifdef WITH_ALIASDB<br>
                # search in DB-based aliases<br>
                if(alias_db_lookup("dbaliases")) {<br>
                    route(SIPOUT);<br>
                }<br>
            #!endif<br>
            <br>
                $avp(oexten) = $rU;<br>
                if (!lookup("location")) {<br>
                    <br>
                    $var(rc) = $rc;<br>
                    route(TOVOICEMAIL);<br>
                    t_newtran();<br>
                    switch ($var(rc)) {<br>
                        case -1:<br>
                        case -3:<br>
                            send_reply("404", "Not Found");<br>
                            exit;<br>
                        case -2:<br>
                            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>
                    setflag(FLT_ACCMISSED);<br>
                }<br>
            <br>
                route(RELAY);<br>
                exit;<br>
            }<br>
            <br>
            # Presence server processing<br>
            route[PRESENCE] {<br>
                xlog("SUBSCRIBE ENTERING PRESENCE $rm $hdr(Event)");<br>
                if(!is_method("PUBLISH|SUBSCRIBE")) return;<br>
            <br>
                if(is_method("SUBSCRIBE") &&
            $hdr(Event)=="message-summary") {<br>
                    route(TOVOICEMAIL);<br>
                    xlog("MESSAGE RESULT [$fu/$tu/$ru/$ci]\r\n\r\n");<br>
                    # returns here if no voicemail server is configured<br>
                    sl_send_reply("404", "No voicemail service");<br>
                    exit;<br>
                }<br>
            <br>
            #!ifdef WITH_PRESENCE<br>
                xlog("SUBSCRIBE IN PRESENCE $rm");<br>
                if (!t_newtran()) {<br>
                    sl_reply_error();<br>
                    exit;<br>
                }<br>
                xlog("SUBSCRIBE2 IN PRESENCE $rm");<br>
                if(is_method("PUBLISH")) {<br>
                    xlog("PUBLISH, NOT SUBSCRIBE [$fu/$tu/$ru/$ci]
            $hdr(Sender)\r\n\r\n");<br>
                    #exec_avp("/home/xantek/kamailio_test.php",
            "$avp(s:test)");<br>
                    #xlog("TEST RESULT
            [$avp(s:test)][$fu/$tu/$ru/$ci]\r\n\r\n");<br>
                    <br>
                    handle_publish();<br>
                    t_release(); <br>
                } else if(is_method("SUBSCRIBE")) {<br>
                    xlog("HANDLE SUBSCRIBE");<br>
            <br>
                    xlog("SUBSCRIBE RESULT
            [$avp(s:test)][$fu/$tu/$ru/$ci]\r\n\r\n");<br>
                    handle_subscribe();<br>
                    t_release();<br>
                }<br>
                exit;<br>
            #!endif<br>
            <br>
                # if presence enabled, this part will not be executed<br>
                if (is_method("PUBLISH") || $rU==$null) {<br>
                    sl_send_reply("404", "Not here");<br>
                    exit;<br>
                }<br>
                return;<br>
            }<br>
            <br>
            # IP authorization and user authentication<br>
            route[AUTH] {<br>
            #!ifdef WITH_AUTH<br>
            <br>
            #!ifdef WITH_IPAUTH<br>
                if((!is_method("REGISTER")) &&
            allow_source_address()) {<br>
                    # source IP allowed<br>
                    return;<br>
                }<br>
            #!endif<br>
            <br>
                if (is_method("REGISTER") || from_uri==myself) {<br>
                    # authenticate requests<br>
                    #$var(auth_code) = auth_check("$fd", "subscriber",
            "1");<br>
                    #if ($var(auth_code) == -2) {xlog("AUTH BAD PASSWORD
            (IP:$si:$sp) $fu\r\n\r\n");}<br>
                    #if ($var(auth_code) == -3) {xlog("AUTH NO SUCH USER
            (IP:$si:$sp) $fu\r\n\r\n");}<br>
                    #if ($var(auth_code) == -5) {<br>
                    #    xlog("VALID REGISTRATION (IP:$si:$sp)
            $tU\r\n\r\n");<br>
                #            <br>
                    #    exec_avp("/home/xantek/mwi_initial.php $tU");<br>
                    #}<br>
                #    xlog("AUTH $var(auth_code) $fu
            (IP:$si:$sp)\r\n\r\n");<br>
                    if (!auth_check("$fd", "subscriber", "1")) {<br>
                        auth_challenge("$fd", "0");<br>
                        xlog("REGISTERUSER $fu (IP:$si:$sp)\r\n\r\n");<br>
                        exit;<br>
                    } else {<br>
                        xlog("REGISTERUSER NO AUTH CHECK");<br>
                    }<br>
                    $var(auth_code) = auth_check("$fd", "subscriber",
            "1");<br>
                    xlog("REGISTERUSER AUTH CODE = $var(auth_code)");<br>
                    if ($var(auth_code) == -2) {xlog("AUTH BAD PASSWORD
            (IP:$si:$sp) $fu\r\n\r\n");}<br>
                    if ($var(auth_code) == -3) {xlog("AUTH NO SUCH USER
            (IP:$si:$sp) $fu\r\n\r\n");}<br>
                    <br>
                    # user authenticated - remove auth header<br>
                    <br>
                    if(!is_method("REGISTER|PUBLISH"))<br>
                        xlog("REGISTERUSER CONSUME $fu IP:$si\r\n\r\n");<br>
                        consume_credentials();<br>
                }<br>
                # if caller is not local subscriber, then check if it
            calls<br>
                # a local destination, otherwise deny, not an open relay
            here<br>
                if (from_uri!=myself && uri!=myself) {<br>
                    sl_send_reply("403","Not relaying");<br>
                    exit;<br>
                }<br>
            <br>
            #!endif<br>
                return;<br>
            }<br>
            <br>
            # Caller NAT detection<br>
            route[NATDETECT] {<br>
            #!ifdef WITH_NAT<br>
                force_rport();<br>
                if (nat_uac_test("19")) {<br>
                    if (is_method("REGISTER")) {<br>
                        fix_nated_register();<br>
                    } else {<br>
                        if(is_first_hop()) {<br>
                            set_contact_alias();<br>
                        }<br>
                    }<br>
                    setflag(FLT_NATS);<br>
                }<br>
            #!endif<br>
                return;<br>
            }<br>
            <br>
            # RTPProxy control and signaling updates for NAT traversal<br>
            route[NATMANAGE] {<br>
            #!ifdef WITH_NAT<br>
                if (is_request()) {<br>
                    if(has_totag()) {<br>
                        if(check_route_param("nat=yes")) {<br>
                            setbflag(FLB_NATB);<br>
                        }<br>
                    }<br>
                }<br>
                if (!(isflagset(FLT_NATS) || isbflagset(FLB_NATB)))
            return;<br>
            <br>
                if(nat_uac_test("8")) {<br>
                    rtpproxy_manage("co");<br>
                } else {<br>
                    rtpproxy_manage("cor");<br>
                }<br>
            <br>
                if (is_request()) {<br>
                    if (!has_totag()) {<br>
                        if(t_is_branch_route()) {<br>
                            add_rr_param(";nat=yes");<br>
                        }<br>
                    }<br>
                }<br>
                if (is_reply()) {<br>
                    if(isbflagset(FLB_NATB)) {<br>
                        if(is_first_hop())<br>
                            set_contact_alias();<br>
                    }<br>
                }<br>
            #!endif<br>
                return;<br>
            }<br>
            <br>
            # URI update for dialog requests<br>
            route[DLGURI] {<br>
            #!ifdef WITH_NAT<br>
                if(!isdsturiset()) {<br>
                    handle_ruri_alias();<br>
                }<br>
            #!endif<br>
                return;<br>
            }<br>
            <br>
            # Routing to foreign domains<br>
            route[SIPOUT] {<br>
                if (uri==myself) return;<br>
                xlog("SIPOUT $du\r\n\r\n");<br>
                append_hf("P-hint: outbound\r\n");<br>
                route(RELAY);<br>
                exit;<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 routing 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}$")) 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>
                if (strempty($sel(cfg_get.pstn.gw_port))) {<br>
                    $ru = "sip:" + $rU + "@" + $sel(cfg_get.pstn.gw_ip);<br>
                } else {<br>
                    $ru = "sip:" + $rU + "@" + $sel(cfg_get.pstn.gw_ip)
            + ":"<br>
                                + $sel(cfg_get.pstn.gw_port);<br>
                }<br>
            <br>
                route(RELAY);<br>
                exit;<br>
            #!endif<br>
            <br>
                return;<br>
            }<br>
            <br>
            # XMLRPC routing<br>
            #!ifdef WITH_XMLRPC<br>
            route[XMLRPC] {<br>
                # allow XMLRPC from localhost<br>
                if ((method=="POST" || method=="GET")<br>
                        && (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>
            # Routing to voicemail server<br>
            route[TOVOICEMAIL] {<br>
            #!ifdef WITH_VOICEMAIL<br>
                if(!is_method("INVITE|SUBSCRIBE")) return;<br>
            <br>
                # check if VoiceMail server IP is defined<br>
                if (strempty($sel(cfg_get.voicemail.srv_ip))) {<br>
                    xlog("SCRIPT: VoiceMail routing enabled but IP not
            defined\n");<br>
                    return;<br>
                }<br>
                if(is_method("INVITE")) {<br>
                    if($avp(oexten)==$null) return;<br>
            <br>
                    $ru = "sip:" + $avp(oexten) + "@" +
            $sel(cfg_get.voicemail.srv_ip)<br>
                            + ":" + $sel(cfg_get.voicemail.srv_port);<br>
                } else {<br>
                    if($rU==$null) return;<br>
                    xlog("READY TO ROUTE to $rU");<br>
                    $ru = "sip:" + $rU + "@" +
            $sel(cfg_get.voicemail.srv_ip)<br>
                            + ":" + $sel(cfg_get.voicemail.srv_port);<br>
                    xlog("READY TO ROUTE to $ru");<br>
                }<br>
            <br>
                route(RELAY);<br>
                exit;<br>
            #!endif<br>
            <br>
                return;<br>
            }<br>
            <br>
            # Manage outgoing branches<br>
            branch_route[MANAGE_BRANCH] {<br>
                xdbg("new branch [$T_branch_idx] to $ru\n");<br>
                route(NATMANAGE);<br>
            }<br>
            <br>
            # Manage incoming replies<br>
            onreply_route[MANAGE_REPLY] {<br>
                xdbg("incoming reply\n");<br>
                if(status=~"[12][0-9][0-9]") {<br>
                    route(NATMANAGE);<br>
                }<br>
            }<br>
            <br>
            # Manage failure routing cases<br>
            failure_route[MANAGE_FAILURE] {<br>
                route(NATMANAGE);<br>
            <br>
                if (t_is_canceled()) exit;<br>
            <br>
            #!ifdef WITH_BLOCK3XX<br>
                # block call 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>
            #!endif<br>
            <br>
            #!ifdef WITH_VOICEMAIL<br>
                # serial forking<br>
                # - route to voicemail on busy or no answer (timeout)<br>
                if (t_check_status("486|408")) {<br>
                    $du = $null;<br>
                    route(TOVOICEMAIL); <br>
                    exit;<br>
                }<br>
            #!endif<br>
            }<br>
            <br>
            <br>
            <br>
            <br>
            <div class="moz-cite-prefix">On 08/02/2016 02:59 AM, Phil
              Lavin wrote:<br>
            </div>
            <blockquote
cite="mid:VI1PR03MB184032DBD61F9A183AA5D02F89050@VI1PR03MB1840.eurprd03.prod.outlook.com"
              type="cite">
              <pre wrap="">This works fine. On the T41P I went to the DSSKey tab, configured Line Key4 as follows:

:: Type: BLF
:: Value: <a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:44123456789@kamailio.domain.com">44123456789@kamailio.domain.com</a>
:: Label: Name of the user
:: Line 1

The value has 2 parts:

:: The phone number of the user to whom we are subscribing
:: The domain name that this user registers to. This bit is important in Kamailio. If you want BLF, all UAs need to use the same domain name

The line should be the line that is registered to the server you are subscribing too.

It should be noted that we are running a forked/patched version of Kamailio 4.3.4. The relevant git commits are:

:: 2e99fe0
:: 56f3e25
:: b2843e5
:: a9ece27
:: d97f47c
:: fb2ede3
:: feef158
:: 19fce63
:: b5f9fb1

I think all but the last 4 are in 4.4. The last 4 are on Github as pull requests into master. Daniel is going to review when he has time... but we've been running in production for around a week now with no issues.

We're also running a fairly carefully crafted config to work around a number of other bugs with pua/presence which we didn't have the time to find a proper code solution for. Config is below:

phil@ua-proxy-dev:~$ grep 'pua\|presence' /etc/kamailio/kamailio.cfg
loadmodule "presence.so"
loadmodule "presence_xml.so"
loadmodule "presence_mwi.so"
loadmodule "presence_dialoginfo.so"
loadmodule "pua.so"
loadmodule "pua_dialoginfo.so"
# ----- presence params -----
modparam("presence", "db_url", DBURL)
modparam("presence", "db_update_period", 20)
modparam("presence", "clean_period", 60)
modparam("presence", "local_log_facility", "LOG_LOCAL3")
modparam("presence", "max_expires", 14430) # PortaOne max call time (4 hours) plus a little
# ----- presence_xml params -----
modparam("presence_xml", "db_url", DBURL)
modparam("presence_xml", "force_active", 1)
# ----- pua params -----
modparam("pua", "db_url", DBURL)
modparam("pua", "db_mode", 0) # Memory only. Required due to the "multiple states for a single dialog" bug
modparam("pua", "update_period", 20)
modparam("pua", "outbound_proxy", MY_SIP_URL)
# ----- pua_dialoginfo params -----
modparam("pua_dialoginfo", "send_publish_flag", FLT_DLGINFO)
modparam("pua_dialoginfo", "override_lifetime", 14420) # PortaOne max call time (4 hours) plus a little
modparam("pua_dialoginfo", "callee_trying", 1) # Implemented by Phil - submitted upstream to v4.4

pua db_mode can probably be changed to 2 following the recent fixes that are awaiting pull request review. We haven't tested this yet, though.


Cheers

Phil Lavin
Telecoms Systems Manager
CloudCall
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="http://www.cloudcall.com">www.cloudcall.com</a>

T: +44 (0) 330 335 0000 / +1 617 982 1600
D: +44 (0) 116 424 4790 / +1 716 242 6604
SM: LinkedIn 
READ OUR BLOG FOR SMARTER COMMUNICATIONS 

Confidentiality: This e-mail transmission, including any attachments, is intended only for the named recipient(s) and may contain information that is privileged, confidential and/or exempt from disclosure under applicable law. If you have received this transmission in error, or are not the named recipient(s), please notify the sender immediately by return e-mail and permanently delete this transmission, including any attachments.
Security: This e-mail and any attachments are believed to be free from any virus but it is the responsibility of the recipient to ensure this is so. E-mail is not a 100% secure communication.

-----Original Message-----
From: Phil Lavin 
Sent: 02 August 2016 10:29
To: Kamailio (SER) - Users Mailing List <a moz-do-not-send="true" class="moz-txt-link-rfc2396E" href="mailto:sr-users@lists.sip-router.org"><sr-users@lists.sip-router.org></a>
Subject: RE: [SR-Users] Kamailio presence

I've done quite a bit with Kamailio BLF recently. I have a Yealink T41P on my desk here - I'll give it a whirl.


-----Original Message-----
From: Phil Lavin 
Sent: 02 August 2016 10:26
To: Kamailio (SER) - Users Mailing List <a moz-do-not-send="true" class="moz-txt-link-rfc2396E" href="mailto:sr-users@lists.sip-router.org"><sr-users@lists.sip-router.org></a>
Subject: RE: [SR-Users] Kamailio presence

I've done quite a bit with Kamailio BLF recently. I have a Yealink T41P on my desk here - I'll give it a whirl.


-----Original Message-----
From: sr-users [<a moz-do-not-send="true" class="moz-txt-link-freetext" href="mailto:sr-users-bounces@lists.sip-router.org">mailto:sr-users-bounces@lists.sip-router.org</a>] On Behalf Of Bill
Sent: 02 August 2016 01:07
To: <a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a>
Subject: [SR-Users] Kamailio presence



I have asked this question before, but never really got an answer:

Has anybody been able to get BLF working with Yealink phones.


Bill



_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list <a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a> <a moz-do-not-send="true" 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>
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a>
<a moz-do-not-send="true" 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>
</pre>
            </blockquote>
            <br>
            <br>
            <fieldset class="mimeAttachmentHeader"></fieldset>
            <br>
            <pre wrap="">_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a>
<a moz-do-not-send="true" 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>
</pre>
          </blockquote>
          <br>
        </blockquote>
        <br>
        <br>
        <fieldset class="mimeAttachmentHeader"></fieldset>
        <br>
        <pre wrap="">_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a>
<a moz-do-not-send="true" 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>
</pre>
      </blockquote>
      <br>
      <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a> - <a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.kamailio.org">http://www.kamailio.org</a>
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://twitter.com/#%21/miconda">http://twitter.com/#!/miconda</a> - <a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.linkedin.com/in/miconda">http://www.linkedin.com/in/miconda</a></pre>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a>
<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>
</pre>
    </blockquote>
    <br>
  </body>
</html>