<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>Hello,<br>
    </p>
    <br>
    <div class="moz-cite-prefix">On 22.11.17 16:45, Karsten Horsmann
      wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAFArqsZayC4=DsVdc_4PseA43CLEJT9pgeLBgHjE3_Bj0_d5CQ@mail.gmail.com">
      <div dir="ltr">Hello Daniel,
        <div><br>
        </div>
        <div>yes after playing around under kamailio-5.0.x, i understand
          that kemi exports are not complete.</div>
        <div><br>
        </div>
        <div>For example the KSR.hdr.append_hf dont work in
          kamailio-5.0.x</div>
        <div>attempt to call field 'append_hf' (a nil value)<br>
        </div>
        <div>
          <div>KSR.hdr.append_hf("P-Hint: outbound\r\n");</div>
        </div>
        <div>But i found KSR.hdr.append("P-Hint: outbound\r\n");
          (without _hf) - that did the same and works.<br>
        </div>
      </div>
    </blockquote>
    <br>
    append_hf() function is part of textops module. KSR.hdr subpackage
    is from core, somehow inspired from old app_lua sr.hdr subpackage.
    That was the reason to have different name, not to have a confusion
    on dependencies.<br>
    <br>
    <blockquote type="cite"
cite="mid:CAFArqsZayC4=DsVdc_4PseA43CLEJT9pgeLBgHjE3_Bj0_d5CQ@mail.gmail.com">
      <div dir="ltr">
        <div><br>
        </div>
        <div>The hardest part with kemi seems to be "find the new kemi
          (function)name in your config-language" and also the module
          dependencies.</div>
      </div>
    </blockquote>
    <br>
    The functions available in KSR module and submodules are listed by:<br>
    <br>
    kamctl rpc app_lua.api_list<br>
    <br>
    <blockquote type="cite"
cite="mid:CAFArqsZayC4=DsVdc_4PseA43CLEJT9pgeLBgHjE3_Bj0_d5CQ@mail.gmail.com">
      <div dir="ltr">
        <div><br>
        </div>
        <div>A few questions to kemi and kemi-docu:</div>
        <div><br>
        </div>
        <div>* Are all config-language on the same level with the
          kemi-exports or are some "more ahead" - for example python or
          javascript?</div>
      </div>
    </blockquote>
    <br>
    In terms of functions, they should be pretty much in pair, in the
    way that any kemi function exported by core or a module is available
    immediately in all kemi languages. The only difference can be in the
    kemi functions implemented by the kemi-interpreter modules,
    respectively KSR.x subpackage.<br>
    <br>
    KSR.pv is also implemented by each kemi-interpreter module, but that
    is because of KSR.pv.get() which needs special code for each
    interpreter, otherwise the functions in KSR.pv must be the same in
    all kemi languages, with the same behaviour in the script.<br>
    <br>
    KSR.x is supposed to collect per kemi-interpreter specific functions
    or have code that is specific per interpeter. For example
    KSR.x.exit() has an implementation that reuses various tricks of the
    interpreter to stop execution of the kemi script.<br>
     <br>
    <blockquote type="cite"
cite="mid:CAFArqsZayC4=DsVdc_4PseA43CLEJT9pgeLBgHjE3_Bj0_d5CQ@mail.gmail.com">
      <div dir="ltr">
        <div><br>
        </div>
        <div>* the behavior of "config-language exit - then exit
          kamailio" in lua makes me fear. <br>
        </div>
      </div>
    </blockquote>
    <br>
    Indeed, the native-lua 'exit' is stopping the lua interpreter
    completely, which in this case is kamailio, so it stops kamailio.<br>
    <br>
    You have to use KSR.x.exit() instead.<br>
    <br>
    <blockquote type="cite"
cite="mid:CAFArqsZayC4=DsVdc_4PseA43CLEJT9pgeLBgHjE3_Bj0_d5CQ@mail.gmail.com">
      <div dir="ltr">
        <div>With the old-school kamailio-cfg you cannot break kamailio
          itself.</div>
      </div>
    </blockquote>
    <br>
    Again, here is about the functions of the interpreter. I think that
    also in Python there is an system exit function that stops
    compeltely the interpreter (kamailio in this case).<br>
    <br>
    So, the importat thing here is that the scripting language
    interpreter is kamailio itself, so the native functions for that
    scripting language behave as being run by the standalone
    interpreter.<br>
    <br>
    <blockquote type="cite"
cite="mid:CAFArqsZayC4=DsVdc_4PseA43CLEJT9pgeLBgHjE3_Bj0_d5CQ@mail.gmail.com">
      <div dir="ltr">
        <div> Pointing to nil values in app_lua / cfgengine lua or
          request nathelper module</div>
        <div>in kemi-lua without load nathelper - breaks your kamailio.
          huuuu. so many kamailio-cores today in my testlab.</div>
        <div>
          <div>Are there changes in the future for this?</div>
        </div>
      </div>
    </blockquote>
    <br>
    I do not really get the above? If you do not load natherlper module,
    kamailio crashes of used with kemi lua engine? If yes, can you
    provide the backtrace with gdb from the core file? It needs to be
    fixed.<br>
    <br>
    <blockquote type="cite"
cite="mid:CAFArqsZayC4=DsVdc_4PseA43CLEJT9pgeLBgHjE3_Bj0_d5CQ@mail.gmail.com">
      <div dir="ltr">
        <div>
          <div><br>
          </div>
          <div>* Is it better to say "if you want kemi, then go to 5.1.x
            or master branch"?<br>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    Not necessarily. Kemi framework code from core is more or less the
    same in 5.0 and 5.1, but the 5.1 has lot more kamailio functions
    exported to kemi. Based on your needs, using 5.0 with kemi can be
    sufficient.<br>
    <br>
    Cheers,<br>
    Daniel<br>
    <blockquote type="cite"
cite="mid:CAFArqsZayC4=DsVdc_4PseA43CLEJT9pgeLBgHjE3_Bj0_d5CQ@mail.gmail.com">
      <div dir="ltr">
        <div><br>
        </div>
        <div>Thanks!</div>
        <div><br>
        </div>
        <div class="gmail_extra"><br>
          <div class="gmail_quote">2017-11-22 14:40 GMT+01:00
            Daniel-Constantin Mierla <span dir="ltr"><<a
                href="mailto:miconda@gmail.com" target="_blank"
                moz-do-not-send="true">miconda@gmail.com</a>></span>:<br>
            <blockquote class="gmail_quote" style="margin:0 0 0
              .8ex;border-left:1px #ccc solid;padding-left:1ex">
              <div text="#000000" bgcolor="#FFFFFF">
                <p>Hello,<br>
                </p>
                <span class=""> <br>
                  <div class="m_3428622838471601703moz-cite-prefix">On
                    22.11.17 12:42, Karsten Horsmann wrote:<br>
                  </div>
                  <blockquote type="cite">
                    <div dir="ltr">
                      <div class="gmail_extra">Hello List,</div>
                      <div class="gmail_extra"><br>
                      </div>
                      <div class="gmail_extra">i dunno why this happen
                        :) after i write an email to the list - but now
                        i found it.</div>
                      <div class="gmail_extra"><br>
                      </div>
                      <div class="gmail_extra">the app_lua/kemi function
                        name is sr.dispatcher.select for ds_select_dst</div>
                    </div>
                  </blockquote>
                  <br>
                </span> as wrote on my previous response to your initial
                email in this discussion, this is not via KEMI, the "sr"
                module in Lua is old style implementation, when for each
                function exported to Lua, new C code had to be written
                inside app_lua. But you can still use it, as in v5.0
                many modules didn't export their functions to kemi.<br>
                <br>
                Cheers,<br>
                Daniel<br>
                <br>
                <blockquote type="cite">
                  <div>
                    <div class="h5">
                      <div dir="ltr">
                        <div class="gmail_extra">The source-code
                          documentation guides me to this point after
                          greping around in app_lua.</div>
                        <div class="gmail_extra"><br>
                        </div>
                        <div class="gmail_extra"><br>
                        </div>
                        <div class="gmail_extra">
                          <div class="gmail_extra">    # dst_select(
                            "GROUP", "HASH METHOD")</div>
                          <div class="gmail_extra">   
                            if(!ds_select_dst($avp(<wbr>routing_target),
                            "4")) {</div>
                          <div class="gmail_extra">       
                            send_reply("404", "No destination");</div>
                          <div class="gmail_extra">        exit;</div>
                          <div class="gmail_extra">    }</div>
                          <div><br>
                          </div>
                          <div>In lua part it looks like this (the nil
                            part maybe broken per default, lua dont like
                            vars with nil)</div>
                          <div><br>
                          </div>
                        </div>
                        <div class="gmail_extra">
                          <div class="gmail_extra">--- dispatcher route</div>
                          <div class="gmail_extra">function
                            ksr_route_dispatch(direction,
                            routing_target)</div>
                          <div class="gmail_extra"><br>
                          </div>
                          <div class="gmail_extra">   
                            KSR.xlog.xinfo("new $fU -> $rU in
                            routing_target ksr_route_dispatch");</div>
                          <div class="gmail_extra">   
                            KSR.info(routing_target);</div>
                          <div class="gmail_extra">    if
                            (routing_target == nil) then</div>
                          <div class="gmail_extra">       
                            KSR.xlog.xinfo("routing_target nil");</div>
                          <div class="gmail_extra">       
                            KSR.sl.sl_send_reply(604, "Does Not Exist
                            Anywhere");</div>
                          <div class="gmail_extra">        KSR.x.exit();</div>
                          <div class="gmail_extra">    end</div>
                          <div class="gmail_extra"><br>
                          </div>
                          <div class="gmail_extra">    -- return code
                            dispatcher.select NOT true - then 404</div>
                          <div class="gmail_extra">    if
                            (sr.dispatcher.select(routing_<wbr>target,
                            4) ~= 1) then</div>
                          <div class="gmail_extra">       
                            KSR.sl.sl_send_reply(404, "No destination");</div>
                          <div class="gmail_extra">        KSR.x.exit();</div>
                          <div class="gmail_extra">    end</div>
                          <div class="gmail_extra">   
                            ksr_route_myheader(pathinfo);</div>
                          <div class="gmail_extra">   
                            ksr_route_relay();</div>
                          <div class="gmail_extra">    KSR.x.exit();</div>
                          <div class="gmail_extra">end</div>
                          <div><br>
                          </div>
                        </div>
                        <div class="gmail_extra"><br>
                        </div>
                        <div class="gmail_extra"><br>
                        </div>
                        <div class="gmail_extra">-- <br>
                          <div
                            class="m_3428622838471601703gmail_signature">Kind
                            Regards<br>
                            *Karsten Horsmann*<br>
                          </div>
                        </div>
                      </div>
                      <br>
                      <fieldset
                        class="m_3428622838471601703mimeAttachmentHeader"></fieldset>
                      <br>
                    </div>
                  </div>
                  <span class="">
                    <pre>______________________________<wbr>_________________
Kamailio (SER) - Users Mailing List
<a class="m_3428622838471601703moz-txt-link-abbreviated" href="mailto:sr-users@lists.kamailio.org" target="_blank" moz-do-not-send="true">sr-users@lists.kamailio.org</a>
<a class="m_3428622838471601703moz-txt-link-freetext" href="https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users" target="_blank" moz-do-not-send="true">https://lists.kamailio.org/<wbr>cgi-bin/mailman/listinfo/sr-<wbr>users</a>
</pre>
                  </span></blockquote>
                <span class=""> <br>
                  <pre class="m_3428622838471601703moz-signature" cols="72">-- 
Daniel-Constantin Mierla
<a class="m_3428622838471601703moz-txt-link-abbreviated" href="http://www.twitter.com/miconda" target="_blank" moz-do-not-send="true">www.twitter.com/miconda</a> -- <a class="m_3428622838471601703moz-txt-link-abbreviated" href="http://www.linkedin.com/in/miconda" target="_blank" moz-do-not-send="true">www.linkedin.com/in/miconda</a>
Kamailio Advanced Training - <a class="m_3428622838471601703moz-txt-link-abbreviated" href="http://www.asipto.com" target="_blank" moz-do-not-send="true">www.asipto.com</a>
Kamailio World Conference - May 14-16, 2018 - <a class="m_3428622838471601703moz-txt-link-abbreviated" href="http://www.kamailioworld.com" target="_blank" moz-do-not-send="true">www.kamailioworld.com</a></pre>
                </span></div>
            </blockquote>
          </div>
          <br>
          <br clear="all">
          <div><br>
          </div>
          -- <br>
          <div class="gmail_signature" data-smartmail="gmail_signature">Kind
            Regards<br>
            *Karsten Horsmann*<br>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla
<a class="moz-txt-link-abbreviated" href="http://www.twitter.com/miconda">www.twitter.com/miconda</a> -- <a class="moz-txt-link-abbreviated" href="http://www.linkedin.com/in/miconda">www.linkedin.com/in/miconda</a>
Kamailio Advanced Training - <a class="moz-txt-link-abbreviated" href="http://www.asipto.com">www.asipto.com</a>
Kamailio World Conference - May 14-16, 2018 - <a class="moz-txt-link-abbreviated" href="http://www.kamailioworld.com">www.kamailioworld.com</a></pre>
  </body>
</html>