<html><head><meta http-equiv="Content-Type" content="text/html charset=windows-1252"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><br><div><div>On 12 Nov 2014, at 12:55, Ovidiu Sas <<a href="mailto:osas@voipembedded.com">osas@voipembedded.com</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><p dir="ltr">There were discussions in the list about getting rid of the MI interface and sticking with the RPC one. We should stop adding new MI commands. I see that the RPC commands are already implemented.</p><div><br></div></blockquote><div><br></div>+1</div><div><br></div><div>Some of us worked hard to try to implement all MI commands in RPC in an earlier release. If anything is still</div><div>missing, please fix it or send an e-mail to the list. We should have more RPC than MI in the coming release.</div><div><br></div><div>/O<br><blockquote type="cite"><p dir="ltr">Regards,<br>
Ovidiu Sas</p>
<div class="gmail_quote">On Nov 12, 2014 5:59 AM, "Federico Cabiddu" <<a href="mailto:federico.cabiddu@gmail.com">federico.cabiddu@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Module: sip-router<br>
Branch: master<br>
Commit: a255911902788bf74a7f4279fce4758b2f2a4613<br>
URL:    <a href="http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a255911902788bf74a7f4279fce4758b2f2a4613" target="_blank">http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a255911902788bf74a7f4279fce4758b2f2a4613</a><br>
<br>
Author: Federico Cabiddu <<a href="mailto:federico.cabiddu@gmail.com">federico.cabiddu@gmail.com</a>><br>
Committer: Federico Cabiddu <<a href="mailto:federico.cabiddu@gmail.com">federico.cabiddu@gmail.com</a>><br>
Date:   Wed Nov 12 11:52:29 2014 +0100<br>
<br>
modules/tsilo: added MI commands<br>
<br>
---<br>
<br>
 modules/tsilo/Makefile            |    5 +++-<br>
 modules/tsilo/README              |   51 +++++++++++++++++++++++++++++--------<br>
 modules/tsilo/doc/tsilo_admin.xml |   44 ++++++++++++++++++++++++++------<br>
 modules/tsilo/ts_hash.c           |    2 +-<br>
 modules/tsilo/ts_hash.h           |   16 ++++++------<br>
 modules/tsilo/tsilo.c             |   30 ++++++++++++++++-----<br>
 6 files changed, 112 insertions(+), 36 deletions(-)<br>
<br>
diff --git a/modules/tsilo/Makefile b/modules/tsilo/Makefile<br>
index 40b04cb..c179aec 100644<br>
--- a/modules/tsilo/Makefile<br>
+++ b/modules/tsilo/Makefile<br>
@@ -9,10 +9,13 @@ include ../../Makefile.defs<br>
 auto_gen=<br>
 NAME=tsilo.so<br>
 LIBS=<br>
-DEFS+= -DSER_MOD_INTERFACE<br>
+DEFS+=-DKAMAILIO_MOD_INTERFACE<br>
<br>
 ifeq ($(INSTALL_FLAVOUR),kamailio)<br>
 DEFS+= -DWITH_EVENT_LOCAL_REQUEST<br>
 endif # INSTALL_FLAVOUR<br>
<br>
+SERLIBPATH=../../lib<br>
+SER_LIBS+=$(SERLIBPATH)/kmi/kmi<br>
+<br>
 include ../../Makefile.modules<br>
diff --git a/modules/tsilo/README b/modules/tsilo/README<br>
index 4790ad1..297c435 100644<br>
--- a/modules/tsilo/README<br>
+++ b/modules/tsilo/README<br>
@@ -10,7 +10,7 @@ Federico Cabiddu<br>
<br>
    <<a href="mailto:federico.cabiddu@gmail.com">federico.cabiddu@gmail.com</a>><br>
<br>
-   Copyright © 2014 Federico Cabiddu<br>
+   Copyright © 2014 Federico Cabiddu<br>
      __________________________________________________________________<br>
<br>
    Table of Contents<br>
@@ -33,7 +33,10 @@ Federico Cabiddu<br>
               4.2. ts_append(domain, ruri)<br>
               4.3. ts_append_to(tindex, tlabel, domain)<br>
<br>
-        5. Statistics<br>
+        5. MI Commands<br>
+<br>
+              5.1. ts_dump<br>
+              5.2. ts_lookup<br>
<br>
    List of Examples<br>
<br>
@@ -62,19 +65,26 @@ Chapter 1. Admin Guide<br>
         4.2. ts_append(domain, ruri)<br>
         4.3. ts_append_to(tindex, tlabel, domain)<br>
<br>
-   5. Statistics<br>
+   5. MI Commands<br>
+<br>
+        5.1. ts_dump<br>
+        5.2. ts_lookup<br>
<br>
 1. Overview<br>
<br>
    This modules provides transaction storage for the Kamailio SIP Server<br>
-   Platform. It stores in an internal table transactions for an user and<br>
-   add branches to them if new contacts are added.<br>
+   Platform. It stores in an internal table transactions for a Request-URI<br>
+   (R-URI) and add branches to them later if new contacts for the AOR are<br>
+   added.<br>
<br>
-   For each message, the modules stores "Request-URI" ("R-URI"), URI and<br>
-   the internal transaction index and label.<br>
+   When the ts_store function is called, the modules stores the current<br>
+   transaction R-URI URI, index and label. Two functions (ts_append and<br>
+   ts_append_to) provide the ability to add new branches either to a<br>
+   specific transaction or to all of the transactions stored for a given<br>
+   R-URI.<br>
<br>
-   When the transaction is destroyed (by the TM module, the transaction is<br>
-   removed from the module table.<br>
+   When a transaction is destroyed by the TM module, it is removed from<br>
+   the module's table too.<br>
<br>
 2. Dependencies<br>
<br>
@@ -105,7 +115,7 @@ Chapter 1. Admin Guide<br>
    must be a power of two, otherwise it will be rounded down to the<br>
    nearest power of two.<br>
<br>
-   Default value is "2048".<br>
+   Default value is “2048”.<br>
<br>
    Example 1.1. Set hash_size parameter<br>
 ...<br>
@@ -182,4 +192,23 @@ if (is_method("REGISTER")) {<br>
 }<br>
 ...<br>
<br>
-5. Statistics<br>
+5. MI Commands<br>
+<br>
+   5.1. ts_dump<br>
+   5.2. ts_lookup<br>
+<br>
+5.1.  ts_dump<br>
+<br>
+   Dumps the entire content of the TSILO table<br>
+<br>
+   Parameters:<br>
+     * brief - (optional, may not be present); if equals to string<br>
+       “brief”, a brief dump will be done (only RURI, without the<br>
+       transaction(s) details)<br>
+<br>
+5.2.  ts_lookup<br>
+<br>
+   Dumps the transactions stored for the given RURI<br>
+<br>
+   Parameters:<br>
+     * ruri - RURI for which we want to show the transactions.<br>
diff --git a/modules/tsilo/doc/tsilo_admin.xml b/modules/tsilo/doc/tsilo_admin.xml<br>
index 4c35e69..36180d1 100644<br>
--- a/modules/tsilo/doc/tsilo_admin.xml<br>
+++ b/modules/tsilo/doc/tsilo_admin.xml<br>
@@ -17,17 +17,15 @@<br>
        <title>Overview</title><br>
        <para><br>
                This modules provides transaction storage for the &kamailioname;. It<br>
-               stores in an internal table transactions for an user and add branches<br>
-               to them if new contacts are added.<br>
+               stores in an internal table transactions for a Request-URI (R-URI) and add branches<br>
+               to them later if new contacts for the AOR are added.<br>
        </para><br>
        <para><br>
-               For each message, the modules stores <quote>Request-URI</quote><br>
-               (<quote>R-URI</quote>), &uri; and the internal transaction index<br>
-               and label.<br>
+               When the <emphasis>ts_store</emphasis> function is called, the modules stores the current transaction R-URI &uri;, index and label. Two functions (<emphasis>ts_append</emphasis> and <emphasis>ts_append_to</emphasis>) provide the ability to add new branches either to a specific transaction or to all of the transactions stored for a given R-URI.<br>
        </para><br>
        <para><br>
-               When the transaction is destroyed (by the <emphasis>TM</emphasis> module,<br>
-               the transaction is removed from the module table.<br>
+               When a transaction is destroyed by the <emphasis>TM</emphasis> module,<br>
+               it is removed from the module's table too.<br>
        </para><br>
        </section><br>
        <section><br>
@@ -201,6 +199,36 @@ if (is_method("REGISTER")) {<br>
        </section><br>
<br>
        <section><br>
-       <title>Statistics</title><br>
+               <title>MI Commands</title><br>
+               <section id="tsilo.mi.ts_dump"><br>
+                       <title><br>
+                       <function moreinfo="none">ts_dump</function><br>
+                       </title><br>
+                       <para><br>
+                       Dumps the entire content of the TSILO table<br>
+                       </para><br>
+                       <para>Parameters: </para><br>
+                       <itemizedlist><br>
+                               <listitem><para><br>
+                                       <emphasis>brief</emphasis> - (optional, may not be present); if<br>
+                                       equals to string <quote>brief</quote>, a brief dump will be<br>
+                                       done (only RURI, without the transaction(s) details)<br>
+                               </para></listitem><br>
+                       </itemizedlist><br>
+               </section><br>
+               <section id="tsilo.mi.ts_lookup"><br>
+                       <title><br>
+                       <function moreinfo="none">ts_lookup</function><br>
+                       </title><br>
+                       <para><br>
+                       Dumps the transactions stored for the given RURI<br>
+                       </para><br>
+                       <para>Parameters: </para><br>
+                       <itemizedlist><br>
+                               <listitem><para><br>
+                                       <emphasis>ruri</emphasis> - RURI for which we want to show the transactions.<br>
+                               </para></listitem><br>
+                       </itemizedlist><br>
+               </section><br>
        </section><br>
 </chapter><br>
diff --git a/modules/tsilo/ts_hash.c b/modules/tsilo/ts_hash.c<br>
index 089f425..6225db6 100644<br>
--- a/modules/tsilo/ts_hash.c<br>
+++ b/modules/tsilo/ts_hash.c<br>
@@ -162,7 +162,7 @@ void unlock_entry(ts_entry_t *entry) {<br>
<br>
 void lock_entry_by_ruri(str* ruri)<br>
 {<br>
-        unsigned int sl;<br>
+       unsigned int sl;<br>
<br>
        sl = core_hash(ruri, 0, 0) & (t_table->size-1);<br>
        ts_lock(t_table, &t_table->entries[sl]);<br>
diff --git a/modules/tsilo/ts_hash.h b/modules/tsilo/ts_hash.h<br>
index b895c26..bc7adf1 100644<br>
--- a/modules/tsilo/ts_hash.h<br>
+++ b/modules/tsilo/ts_hash.h<br>
@@ -26,8 +26,8 @@<br>
  * Module: \ref tsilo<br>
  */<br>
<br>
-#ifndef _DIALOG_TS_HASH_H_<br>
-#define _DIALOG_TS_HASH_H_<br>
+#ifndef _TS_HASH_H_<br>
+#define _TS_HASH_H_<br>
<br>
 #include "../../locking.h"<br>
 #include "../../lib/kmi/mi.h"<br>
@@ -64,10 +64,10 @@ typedef struct ts_urecord<br>
 /*! entries in the main transaction table */<br>
 typedef struct ts_entry<br>
 {<br>
-       int n;                          /*!< Number of elements in the collision slot */<br>
+       int n;                              /*!< Number of elements in the collision slot */<br>
        struct ts_urecord    *first;    /*!< urecord list */<br>
-       struct ts_urecord    *last;     /*!< optimisation, end of the urecord list */<br>
-       unsigned int       next_id;     /*!< next id */<br>
+       struct ts_urecord    *last;         /*!< optimisation, end of the urecord list */<br>
+       unsigned int       next_id;         /*!< next id */<br>
        unsigned int       lock_idx;    /*!< lock index */<br>
 } ts_entry_t;<br>
<br>
@@ -75,13 +75,13 @@ typedef struct ts_entry<br>
 /*! main transaction table */<br>
 typedef struct ts_table<br>
 {<br>
-       unsigned int       size;        /*!< size of the dialog table */<br>
+       unsigned int       size;            /*!< size of the tsilo table */<br>
        struct ts_entry    *entries;    /*!< urecord hash table */<br>
        unsigned int       locks_no;    /*!< number of locks */<br>
-       gen_lock_set_t     *locks;      /*!< lock table */<br>
+       gen_lock_set_t     *locks;          /*!< lock table */<br>
 } ts_table_t;<br>
<br>
-/*! global dialog table */<br>
+/*! global transactions table */<br>
 extern ts_table_t *t_table;<br>
<br>
 /*!<br>
diff --git a/modules/tsilo/tsilo.c b/modules/tsilo/tsilo.c<br>
index 90eb292..9c404dd 100644<br>
--- a/modules/tsilo/tsilo.c<br>
+++ b/modules/tsilo/tsilo.c<br>
@@ -32,11 +32,13 @@<br>
 #include "../../modules/tm/tm_load.h"<br>
 #include "../../modules/registrar/api.h"<br>
 #include "../../dset.h"<br>
+#include "../../lib/kmi/mi.h"<br>
<br>
 #include "ts_hash.h"<br>
 #include "ts_handlers.h"<br>
 #include "ts_append.h"<br>
 #include "ts_store.h"<br>
+#include "ts_mi.h"<br>
<br>
 MODULE_VERSION<br>
<br>
@@ -57,20 +59,24 @@ static int w_ts_append_to(struct sip_msg* msg, char *idx, char *lbl, char *d);<br>
 static int fixup_ts_append_to(void** param, int param_no);<br>
 static int w_ts_append(struct sip_msg* _msg, char *_table, char *_ruri);<br>
 static int fixup_ts_append(void** param, int param_no);<br>
-<br>
 static int w_ts_store(struct sip_msg* msg);<br>
<br>
-<br>
 static cmd_export_t cmds[]={<br>
        {"ts_append_to", (cmd_function)w_ts_append_to,  3,<br>
-               fixup_ts_append_to, REQUEST_ROUTE | FAILURE_ROUTE },<br>
+               fixup_ts_append_to, 0, REQUEST_ROUTE | FAILURE_ROUTE },<br>
        {"ts_append", (cmd_function)w_ts_append,  2,<br>
-               fixup_ts_append, REQUEST_ROUTE | FAILURE_ROUTE },<br>
+               fixup_ts_append, 0, REQUEST_ROUTE | FAILURE_ROUTE },<br>
        {"ts_store", (cmd_function)w_ts_store,  0,<br>
-               0 , REQUEST_ROUTE | FAILURE_ROUTE },<br>
+               0 , 0, REQUEST_ROUTE | FAILURE_ROUTE },<br>
        {0,0,0,0,0}<br>
 };<br>
<br>
+static mi_export_t mi_cmds[] = {<br>
+       { "ts_dump",            mi_tsilo_dump,          0,      0,      0 },<br>
+       { "ts_lookup",          mi_tsilo_lookup,        0,      0,      0 },<br>
+    { 0, 0, 0, 0, 0}<br>
+};<br>
+<br>
 static param_export_t params[]={<br>
        {"hash_size",   INT_PARAM,      &hash_size},<br>
        {0,0,0}<br>
@@ -80,13 +86,16 @@ static param_export_t params[]={<br>
 /** module exports */<br>
 struct module_exports exports= {<br>
        "tsilo",<br>
+    DEFAULT_DLFLAGS,<br>
        cmds,<br>
-       0, /* RPC methods */<br>
        params,<br>
+       0, /* exported statistics */<br>
+    mi_cmds,    /* exported MI functions */<br>
+    0,<br>
+    0,<br>
        mod_init,   /* module initialization function */<br>
        0,<br>
        (destroy_function) destroy,  /* destroy function */<br>
-       0,<br>
        0<br>
 };<br>
<br>
@@ -97,6 +106,13 @@ static int mod_init(void)<br>
 {<br>
        unsigned int n;<br>
<br>
+       /* register the MI commands */<br>
+       if(register_mi_mod(<a href="http://exports.name/" target="_blank">exports.name</a>, mi_cmds)!=0)<br>
+    {<br>
+        LM_ERR("failed to register MI commands\n");<br>
+        return -1;<br>
+    }<br>
+<br>
        /* load the TM API */<br>
        if (load_tm_api(&_tmb)!=0) {<br>
                LM_ERR("can't load TM API\n");<br>
<br>
<br>
<br>_______________________________________________<br>
sr-dev mailing list<br>
<a href="mailto:sr-dev@lists.sip-router.org">sr-dev@lists.sip-router.org</a><br>
<a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev</a><br>
<br></blockquote></div>
_______________________________________________<br>sr-dev mailing list<br><a href="mailto:sr-dev@lists.sip-router.org">sr-dev@lists.sip-router.org</a><br>http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev<br></blockquote></div><br></body></html>