I am trying to incorporate a cpl script for testing purposes with kamailio 3 but have been met with failure with each try.<br><div class="gmail_quote"><br>Test scenario<br><br>I have two sip phones registered to kamailio successfully (I can make phone calls between the two phones).<br>

<br>The CPL XML is as follows:<br><br>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;<br>&lt;cpl&gt;<br>  &lt;incoming &gt;<br>    &lt;location clear=&quot;yes&quot; url=&quot;<a href="mailto:sip%3A1000@192.168.254.144" target="_blank">sip:1000@192.168.254.144</a>&quot; &gt;<br>

      &lt;log comment=&quot;cpl-log - just location&quot; /&gt;<br>    &lt;/location&gt;<br>  &lt;/incoming&gt;<br>&lt;/cpl&gt;<br><br>This compiled successfully and is populating the cpl table in the openser database.<br>

<br>When I call this from kamailio.cfg I get the 483 (Too many hops) error.  If someone could spot an obvious error, I would appreciate it.<br><br>The current kamailio.cfg file is as follows:<br>------------------<br><br>
debug=8<br>log_stderror=yes<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>/* uncomment the next line to disable the auto discovery of local aliases<br>   based on revers DNS on IPs (default on) */<br>

auto_aliases=no<br><br>port=5060<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:<a href="http://192.168.254.144:5060" target="_blank">192.168.254.144:5060</a><br>

<br><br>####### Custom Parameters #########<br><br># These parameters can be modified runtime via RPC interface<br># - see the documentation of &#39;cfg_rpc&#39; module.<br>#<br># Format: <a href="http://group.id" target="_blank">group.id</a> = value &#39;desc&#39; description<br>

# Access: $sel(<a href="http://cfg_get.group.id" target="_blank">cfg_get.group.id</a>) or @<a href="http://cfg_get.group.id" target="_blank">cfg_get.group.id</a><br>#<br><br>pstn.gw_ip = &quot;&quot; desc &quot;PSTN GW Address&quot;<br>
<br>####### Modules Section ########<br>
<br>#set module path<br>mpath=&quot;/usr/lib/kamailio/modules_k/:/usr/lib/kamailio/modules/&quot;<br><br>/* uncomment next line for MySQL DB support */<br>loadmodule &quot;db_mysql.so&quot;<br>loadmodule &quot;mi_fifo.so&quot;<br>

loadmodule &quot;kex.so&quot;<br>loadmodule &quot;tm.so&quot;<br>loadmodule &quot;tmx.so&quot;<br>loadmodule &quot;sl.so&quot;<br>loadmodule &quot;rr.so&quot;<br>loadmodule &quot;pv.so&quot;<br>loadmodule &quot;maxfwd.so&quot;<br>

loadmodule &quot;usrloc.so&quot;<br>loadmodule &quot;registrar.so&quot;<br>loadmodule &quot;textops.so&quot;<br>loadmodule &quot;uri_db.so&quot;<br>loadmodule &quot;siputils.so&quot;<br>loadmodule &quot;xlog.so&quot;<br>
loadmodule &quot;sanity.so&quot;<br>
loadmodule &quot;ctl.so&quot;<br>loadmodule &quot;mi_rpc.so&quot;<br>loadmodule &quot;acc.so&quot;<br>#!ifdef WITH_AUTH<br>loadmodule &quot;auth.so&quot;<br>loadmodule &quot;auth_db.so&quot;<br>#!endif<br>/* uncomment next line for aliases support<br>

   NOTE: a DB (like db_mysql) module must be also loaded */<br>#loadmodule &quot;alias_db.so&quot;<br>/* uncomment next line for multi-domain support<br>   NOTE: a DB (like db_mysql) module must be also loaded<br>   NOTE: be sure and enable multi-domain support in all used modules<br>

         (see &quot;multi-module params&quot; section ) */<br>#loadmodule &quot;domain.so&quot;<br>#!ifdef WITH_PRESENCE<br>loadmodule &quot;presence.so&quot;<br>loadmodule &quot;presence_xml.so&quot;<br>#!endif<br><br>#!ifdef WITH_NAT<br>

loadmodule &quot;nathelper.so&quot;<br>#!endif<br># ----kh add------#<br>loadmodule &quot;cpl-c.so&quot;<br># ----kh end -----#<br><br># ----------------- setting module-specific parameters ---------------<br><br><br># ----- mi_fifo params -----<br>

modparam(&quot;mi_fifo&quot;, &quot;fifo_name&quot;, &quot;/tmp/kamailio_fifo&quot;)<br><br><br># ----- rr params -----<br># add value to ;lr param to cope with most of the UAs<br>modparam(&quot;rr&quot;, &quot;enable_full_lr&quot;, 1)<br>

# do not append from tag to the RR (no need for this script)<br>modparam(&quot;rr&quot;, &quot;append_fromtag&quot;, 0)<br><br><br># ----- rr params -----<br>modparam(&quot;registrar&quot;, &quot;method_filtering&quot;, 1)<br>

/* uncomment the next line to disable parallel forking via location */<br># modparam(&quot;registrar&quot;, &quot;append_branches&quot;, 0)<br>/* uncomment the next line not to allow more than 10 contacts per AOR */<br>#modparam(&quot;registrar&quot;, &quot;max_contacts&quot;, 10)<br>

<br><br># ----- uri_db params -----<br>/* by default we disable the DB support in the module as we do not need it<br>   in this configuration */<br>modparam(&quot;uri_db&quot;, &quot;use_uri_table&quot;, 0)<br>modparam(&quot;uri_db&quot;, &quot;db_url&quot;, &quot;&quot;)<br>

<br><br># ----- acc params -----<br>/* what sepcial events should be accounted ? */<br>modparam(&quot;acc&quot;, &quot;early_media&quot;, 1)<br>modparam(&quot;acc&quot;, &quot;report_ack&quot;, 1)<br>modparam(&quot;acc&quot;, &quot;report_cancels&quot;, 1)<br>

/* by default ww do not adjust the direct of the sequential requests.<br>   if you enable this parameter, be sure the enable &quot;append_fromtag&quot;<br>   in &quot;rr&quot; module */<br>modparam(&quot;acc&quot;, &quot;detect_direction&quot;, 0)<br>

/* account triggers (flags) */<br>modparam(&quot;acc&quot;, &quot;failed_transaction_flag&quot;, 3)<br>modparam(&quot;acc&quot;, &quot;log_flag&quot;, 1)<br>modparam(&quot;acc&quot;, &quot;log_missed_flag&quot;, 2)<br>modparam(&quot;acc&quot;, &quot;log_extra&quot;, <br>

    &quot;src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd&quot;)<br>/* enhanced DB accounting */<br>#!ifdef WITH_ACCDB<br>modparam(&quot;acc&quot;, &quot;db_flag&quot;, 1)<br>modparam(&quot;acc&quot;, &quot;db_missed_flag&quot;, 2)<br>

modparam(&quot;acc&quot;, &quot;db_url&quot;,<br>    &quot;mysql://openser:openserrw@localhost/openser&quot;)<br>modparam(&quot;acc&quot;, &quot;db_extra&quot;,<br>    &quot;src_user=$fU;src_domain=$fd;dst_ouser=$tU;dst_user=$rU;dst_domain=$rd&quot;)<br>

#!endif<br><br># ----- usrloc params -----<br>/* enable DB persistency for location entries */<br>#!ifdef WITH_USRLOCDB<br>modparam(&quot;usrloc&quot;, &quot;db_mode&quot;,   2)<br>modparam(&quot;usrloc&quot;, &quot;db_url&quot;,<br>

    &quot;mysql://openser:openserrw@localhost/openser&quot;)<br>#!endif<br><br># ----- auth_db params -----<br>/* enable the DB based authentication */<br>#!ifdef WITH_AUTH<br>modparam(&quot;auth_db&quot;, &quot;calculate_ha1&quot;, yes)<br>

modparam(&quot;auth_db&quot;, &quot;password_column&quot;, &quot;password&quot;)<br>modparam(&quot;auth_db&quot;, &quot;db_url&quot;,<br>    &quot;mysql://openser:openserrw@localhost/openser&quot;)<br>modparam(&quot;auth_db&quot;, &quot;load_credentials&quot;, &quot;&quot;)<br>

#!endif<br><br># ----- alias_db params -----<br>/* uncomment the following lines if you want to enable the DB based<br>   aliases */<br>#modparam(&quot;alias_db&quot;, &quot;db_url&quot;,<br>#    &quot;mysql://openser:openserrw@localhost/openser&quot;)<br>

<br><br># ----- domain params -----<br>/* uncomment the following lines to enable multi-domain detection<br>   support */<br>#modparam(&quot;domain&quot;, &quot;db_url&quot;,<br>#    &quot;mysql://openser:openserrw@localhost/openser&quot;)<br>

#modparam(&quot;domain&quot;, &quot;db_mode&quot;, 1)   # Use caching<br><br><br># ----- multi-module params -----<br>/* uncomment the following line if you want to enable multi-domain support<br>   in the modules (dafault off) */<br>

#modparam(&quot;alias_db|auth_db|usrloc|uri_db&quot;, &quot;use_domain&quot;, 1)<br><br><br># ----- presence params -----<br>/* enable presence server support */<br>#!ifdef WITH_PRESENCE<br>modparam(&quot;presence|presence_xml&quot;, &quot;db_url&quot;,<br>

    &quot;mysql://openser:openserrw@localhost/openser&quot;)<br>modparam(&quot;presence_xml&quot;, &quot;force_active&quot;, 1)<br>modparam(&quot;presence&quot;, &quot;server_address&quot;, &quot;sip:<a href="http://10.0.0.10:5060" target="_blank">10.0.0.10:5060</a>&quot;)<br>

#!endif<br><br># ----- nathelper -----<br>#!ifdef WITH_NAT<br>modparam(&quot;nathelper&quot;, &quot;rtpproxy_sock&quot;, &quot;udp:<a href="http://127.0.0.1:7722" target="_blank">127.0.0.1:7722</a>&quot;)<br>modparam(&quot;nathelper&quot;, &quot;natping_interval&quot;, 30)<br>

modparam(&quot;nathelper&quot;, &quot;ping_nated_only&quot;, 1)<br>modparam(&quot;nathelper&quot;, &quot;sipping_bflag&quot;, 7)<br>modparam(&quot;nathelper&quot;, &quot;sipping_from&quot;, &quot;<a href="mailto:sip%3Apinger@kamailio.org" target="_blank">sip:pinger@kamailio.org</a>&quot;)<br>

modparam(&quot;registrar|nathelper&quot;, &quot;received_avp&quot;, &quot;$avp(i:80)&quot;)<br>modparam(&quot;usrloc&quot;, &quot;nat_bflag&quot;, 6)<br>#!endif<br><br># ----- cpl --------<br>modparam(&quot;cpl-c&quot;,&quot;db_url&quot;,&quot;mysql://openser:openserrw@localhost/openser&quot;)<br>

modparam(&quot;cpl-c&quot;,&quot;cpl_dtd_file&quot;,&quot;/etc/kamailio/cpl-06.dtd&quot;)<br>modparam(&quot;cpl-c&quot;,&quot;log_dir&quot;,&quot;/var/log/kamailio/cpl&quot;)<br># ----- cpl --------<br><br>####### Routing Logic ########<br>

<br>route{<br><br>    if (!mf_process_maxfwd_header(&quot;10&quot;)) {<br>        sl_send_reply(&quot;483&quot;,&quot;Too Many Hops&quot;);<br>        exit;<br>    }<br><br>    if(!sanity_check(&quot;1511&quot;, &quot;7&quot;))<br>

    {<br>        xlog(&quot;Malformed SIP message from $si:$sp\n&quot;);<br>        exit;<br>    }<br><br>    # NAT detection<br>    route(NAT);<br><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(&quot;BYE&quot;)) {<br>                setflag(1); # do accounting ...<br>                setflag(3); # ... even if the transaction fails<br>

            }<br>            route(RELAY);<br>        } else {<br>            if (is_method(&quot;SUBSCRIBE&quot;) &amp;&amp; uri == myself) {<br>                # in-dialog subscribe requests<br>                route(PRESENCE);<br>

                exit;<br>            }<br>            if ( is_method(&quot;ACK&quot;) ) {<br>                if ( t_check_trans() ) {<br>                    # non loose-route, but stateful ACK; must be an ACK after a 487 or e.g. 404 from upstream server<br>

                    t_relay();<br>                    exit;<br>                } else {<br>                    # ACK without matching transaction ... ignore and discard.\n&quot;);<br>                    exit;<br>                }<br>

            }<br>            sl_send_reply(&quot;404&quot;,&quot;Not here&quot;);<br>        }<br>        exit;<br>    }<br><br>    #initial requests<br><br>    # CANCEL processing<br>    if (is_method(&quot;CANCEL&quot;))<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(&quot;Route&quot;);<br>    if (is_method(&quot;INVITE|SUBSCRIBE&quot;))<br>        record_route();<br><br>    # account only INVITEs<br>    if (is_method(&quot;INVITE&quot;)) {<br>

        setflag(1); # do accounting<br>    }<br>    if (!uri==myself)<br>    /* replace with following line if multi-domain support is used */<br>    ##if (!is_uri_host_local())<br>    {<br>        append_hf(&quot;P-hint: outbound\r\n&quot;); <br>

        route(RELAY);<br>    }<br><br>    # requests for my domain<br><br>    if( is_method(&quot;PUBLISH|SUBSCRIBE&quot;))<br>        route(PRESENCE);<br><br>    if (is_method(&quot;REGISTER&quot;))<br>    {<br>        if(isflagset(5))<br>

        {<br>            setbflag(&quot;6&quot;);<br>            # uncomment next line to do SIP NAT pinging <br>            ## setbflag(&quot;7&quot;);<br>        }<br>        if (!save(&quot;location&quot;))<br>            sl_reply_error();<br>

<br>        exit;<br>    }<br><br>    if ($rU==$null) {<br>        # request with no Username in RURI<br>        sl_send_reply(&quot;484&quot;,&quot;Address Incomplete&quot;);<br>        exit;<br>    }<br><br>    route(PSTN);<br>

<br>    # apply DB based aliases (uncomment to enable)<br>    ##alias_db_lookup(&quot;dbaliases&quot;);<br><br>    if (!lookup(&quot;location&quot;)) {<br>        switch ($rc) {<br>            case -1:<br>            case -3:<br>

                t_newtran();<br>                t_reply(&quot;404&quot;, &quot;Not Found&quot;);<br>                exit;<br>            case -2:<br>                sl_send_reply(&quot;405&quot;, &quot;Method Not Allowed&quot;);<br>

                exit;<br>        }<br>    }<br><br>    # when routing via usrloc, log the missed calls also<br>    setflag(2);<br>    <br>    route(RELAY);<br>}<br><br><br>route[RELAY] {<br>#!ifdef WITH_NAT<br>    if (check_route_param(&quot;nat=yes&quot;)) {<br>

        setbflag(&quot;6&quot;);<br>    }<br>    if (isflagset(5) || isbflagset(&quot;6&quot;)) {<br>        route(RTPPROXY);<br>    }<br>#!endif<br><br>    /* example how to enable some additional event routes */<br>    if (is_method(&quot;INVITE&quot;)) {<br>

        #t_on_branch(&quot;BRANCH_ONE&quot;);<br>        xlog(&quot;--kh-- before cpl call&quot;);<br>        cpl_run_script(&quot;incoming&quot;, &quot;force_stateful&quot;);<br>        xlog(&quot;--kh-- after cpl call&quot;);<br>

        t_on_reply(&quot;REPLY_ONE&quot;);<br>        t_on_failure(&quot;FAIL_ONE&quot;);<br>    }<br><br>    if (!t_relay()) {<br>        sl_reply_error();<br>    }<br>    exit;<br>}<br><br><br># Presence server route<br>

route[PRESENCE]<br>{<br>#!ifdef WITH_PRESENCE<br>    if (!t_newtran())<br>    {<br>        sl_reply_error();<br>        exit;<br>    };<br><br>    if(is_method(&quot;PUBLISH&quot;))<br>    {<br>        handle_publish();<br>

        t_release();<br>    }<br>    else<br>    if( is_method(&quot;SUBSCRIBE&quot;))<br>    {<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(&quot;PUBLISH&quot;) || $rU==$null)<br>    {<br>        sl_send_reply(&quot;404&quot;, &quot;Not here&quot;);<br>        exit;<br>    }<br>    return;<br>}<br><br># Authentication route<br>route[AUTH] {<br>

#!ifdef WITH_AUTH<br>    if (is_method(&quot;REGISTER&quot;))<br>    {<br>        # authenticate the REGISTER requests (uncomment to enable auth)<br>        if (!www_authorize(&quot;&quot;, &quot;subscriber&quot;))<br>        {<br>

            www_challenge(&quot;&quot;, &quot;0&quot;);<br>            exit;<br>        }<br><br>        if ($au!=$tU)<br>        {<br>            sl_send_reply(&quot;403&quot;,&quot;Forbidden auth ID&quot;);<br>            exit;<br>

        }<br>    } else {<br>        # authenticate if from local subscriber (uncomment to enable auth)<br>        if (from_uri==myself)<br>        {<br>            if (!proxy_authorize(&quot;&quot;, &quot;subscriber&quot;)) {<br>

                proxy_challenge(&quot;&quot;, &quot;0&quot;);<br>                exit;<br>            }<br>            if (is_method(&quot;PUBLISH&quot;))<br>            {<br>                if ($au!=$tU) {<br>                    sl_send_reply(&quot;403&quot;,&quot;Forbidden auth ID&quot;);<br>

                    exit;<br>                }<br>            } else {<br>                if ($au!=$fU) {<br>                    sl_send_reply(&quot;403&quot;,&quot;Forbidden auth ID&quot;);<br>                    exit;<br>

                }<br>            }<br><br>            consume_credentials();<br>            # caller authenticated<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(&quot;19&quot;)) {<br>        if (method==&quot;REGISTER&quot;) {<br>            fix_nated_register();<br>        } else {<br>            fix_nated_contact();<br>

        }<br>        setflag(5);<br>    }<br>#!endif<br>    return;<br>}<br><br># RTPProxy control<br>route[RTPPROXY] {<br>#!ifdef WITH_NAT<br>    if (is_method(&quot;BYE&quot;)) {<br>        unforce_rtp_proxy();<br>    } else if (is_method(&quot;INVITE&quot;)){<br>

        force_rtp_proxy();<br>    }<br>    if (!has_totag()) add_rr_param(&quot;;nat=yes&quot;);<br>#!endif<br>    return;<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(&quot;SCRIPT: PSTN rotuing enabled but pstn.gw_ip not defined\n&quot;);<br>        return;<br>    }<br><br>    # route to PSTN dialed numbers starting with &#39;+&#39; or &#39;00&#39;<br>

    #     (international format)<br>    # - update the condition to match your dialing rules for PSTN routing<br>    if(!($rU=~&quot;^(\+|00)[1-9][0-9]{3,20}$&quot;))<br>        return;<br><br>    # only local users allowed to call<br>

    if(from_uri!=myself) {<br>        sl_send_reply(&quot;403&quot;, &quot;Not Allowed&quot;);<br>        exit;<br>    }<br><br>    $ru = &quot;sip:&quot; + $rU + &quot;@&quot; + $sel(cfg_get.pstn.gw_ip);<br><br>    route(RELAY);<br>

    exit;<br>#!endif<br><br>    return;<br>}<br><br># Sample branch router<br>branch_route[BRANCH_ONE] {<br>    xdbg(&quot;new branch at $ru\n&quot;);<br>}<br><br># Sample onreply route<br>onreply_route[REPLY_ONE] {<br>    xdbg(&quot;incoming reply\n&quot;);<br>

#!ifdef WITH_NAT<br>    if ((isflagset(5) || isbflagset(&quot;6&quot;)) &amp;&amp; status=~&quot;(183)|(2[0-9][0-9])&quot;) {<br>        force_rtp_proxy();<br>    }<br>    if (isbflagset(&quot;6&quot;)) {<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(&quot;INVITE&quot;)<br>            &amp;&amp; (isbflagset(&quot;6&quot;) || isflagset(5))) {<br>        unforce_rtp_proxy();<br>

    }<br>#!endif<br><br>    if (t_is_canceled()) {<br>        exit;<br>    }<br><br><br>}<br>
<br>
</div><br><br clear="all"><br>-- <br>Karl Harris<br><br>