Module: sip-router Branch: master Commit: a255911902788bf74a7f4279fce4758b2f2a4613 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a2559119...
Author: Federico Cabiddu federico.cabiddu@gmail.com Committer: Federico Cabiddu federico.cabiddu@gmail.com Date: Wed Nov 12 11:52:29 2014 +0100
modules/tsilo: added MI commands
---
modules/tsilo/Makefile | 5 +++- modules/tsilo/README | 51 +++++++++++++++++++++++++++++-------- modules/tsilo/doc/tsilo_admin.xml | 44 ++++++++++++++++++++++++++------ modules/tsilo/ts_hash.c | 2 +- modules/tsilo/ts_hash.h | 16 ++++++------ modules/tsilo/tsilo.c | 30 ++++++++++++++++----- 6 files changed, 112 insertions(+), 36 deletions(-)
diff --git a/modules/tsilo/Makefile b/modules/tsilo/Makefile index 40b04cb..c179aec 100644 --- a/modules/tsilo/Makefile +++ b/modules/tsilo/Makefile @@ -9,10 +9,13 @@ include ../../Makefile.defs auto_gen= NAME=tsilo.so LIBS= -DEFS+= -DSER_MOD_INTERFACE +DEFS+=-DKAMAILIO_MOD_INTERFACE
ifeq ($(INSTALL_FLAVOUR),kamailio) DEFS+= -DWITH_EVENT_LOCAL_REQUEST endif # INSTALL_FLAVOUR
+SERLIBPATH=../../lib +SER_LIBS+=$(SERLIBPATH)/kmi/kmi + include ../../Makefile.modules diff --git a/modules/tsilo/README b/modules/tsilo/README index 4790ad1..297c435 100644 --- a/modules/tsilo/README +++ b/modules/tsilo/README @@ -10,7 +10,7 @@ Federico Cabiddu
- Copyright � 2014 Federico Cabiddu + Copyright © 2014 Federico Cabiddu __________________________________________________________________
Table of Contents @@ -33,7 +33,10 @@ Federico Cabiddu 4.2. ts_append(domain, ruri) 4.3. ts_append_to(tindex, tlabel, domain)
- 5. Statistics + 5. MI Commands + + 5.1. ts_dump + 5.2. ts_lookup
List of Examples
@@ -62,19 +65,26 @@ Chapter 1. Admin Guide 4.2. ts_append(domain, ruri) 4.3. ts_append_to(tindex, tlabel, domain)
- 5. Statistics + 5. MI Commands + + 5.1. ts_dump + 5.2. ts_lookup
1. Overview
This modules provides transaction storage for the Kamailio SIP Server - Platform. It stores in an internal table transactions for an user and - add branches to them if new contacts are added. + Platform. It stores in an internal table transactions for a Request-URI + (R-URI) and add branches to them later if new contacts for the AOR are + added.
- For each message, the modules stores "Request-URI" ("R-URI"), URI and - the internal transaction index and label. + When the ts_store function is called, the modules stores the current + transaction R-URI URI, index and label. Two functions (ts_append and + ts_append_to) provide the ability to add new branches either to a + specific transaction or to all of the transactions stored for a given + R-URI.
- When the transaction is destroyed (by the TM module, the transaction is - removed from the module table. + When a transaction is destroyed by the TM module, it is removed from + the module's table too.
2. Dependencies
@@ -105,7 +115,7 @@ Chapter 1. Admin Guide must be a power of two, otherwise it will be rounded down to the nearest power of two.
- Default value is "2048". + Default value is “2048”.
Example 1.1. Set hash_size parameter ... @@ -182,4 +192,23 @@ if (is_method("REGISTER")) { } ...
-5. Statistics +5. MI Commands + + 5.1. ts_dump + 5.2. ts_lookup + +5.1. ts_dump + + Dumps the entire content of the TSILO table + + Parameters: + * brief - (optional, may not be present); if equals to string + “brief”, a brief dump will be done (only RURI, without the + transaction(s) details) + +5.2. ts_lookup + + Dumps the transactions stored for the given RURI + + Parameters: + * ruri - RURI for which we want to show the transactions. diff --git a/modules/tsilo/doc/tsilo_admin.xml b/modules/tsilo/doc/tsilo_admin.xml index 4c35e69..36180d1 100644 --- a/modules/tsilo/doc/tsilo_admin.xml +++ b/modules/tsilo/doc/tsilo_admin.xml @@ -17,17 +17,15 @@ <title>Overview</title> <para> This modules provides transaction storage for the &kamailioname;. It - stores in an internal table transactions for an user and add branches - to them if new contacts are added. + stores in an internal table transactions for a Request-URI (R-URI) and add branches + to them later if new contacts for the AOR are added. </para> <para> - For each message, the modules stores <quote>Request-URI</quote> - (<quote>R-URI</quote>), &uri; and the internal transaction index - and label. + 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. </para> <para> - When the transaction is destroyed (by the <emphasis>TM</emphasis> module, - the transaction is removed from the module table. + When a transaction is destroyed by the <emphasis>TM</emphasis> module, + it is removed from the module's table too. </para> </section> <section> @@ -201,6 +199,36 @@ if (is_method("REGISTER")) { </section>
<section> - <title>Statistics</title> + <title>MI Commands</title> + <section id="tsilo.mi.ts_dump"> + <title> + <function moreinfo="none">ts_dump</function> + </title> + <para> + Dumps the entire content of the TSILO table + </para> + <para>Parameters: </para> + <itemizedlist> + <listitem><para> + <emphasis>brief</emphasis> - (optional, may not be present); if + equals to string <quote>brief</quote>, a brief dump will be + done (only RURI, without the transaction(s) details) + </para></listitem> + </itemizedlist> + </section> + <section id="tsilo.mi.ts_lookup"> + <title> + <function moreinfo="none">ts_lookup</function> + </title> + <para> + Dumps the transactions stored for the given RURI + </para> + <para>Parameters: </para> + <itemizedlist> + <listitem><para> + <emphasis>ruri</emphasis> - RURI for which we want to show the transactions. + </para></listitem> + </itemizedlist> + </section> </section> </chapter> diff --git a/modules/tsilo/ts_hash.c b/modules/tsilo/ts_hash.c index 089f425..6225db6 100644 --- a/modules/tsilo/ts_hash.c +++ b/modules/tsilo/ts_hash.c @@ -162,7 +162,7 @@ void unlock_entry(ts_entry_t *entry) {
void lock_entry_by_ruri(str* ruri) { - unsigned int sl; + unsigned int sl;
sl = core_hash(ruri, 0, 0) & (t_table->size-1); ts_lock(t_table, &t_table->entries[sl]); diff --git a/modules/tsilo/ts_hash.h b/modules/tsilo/ts_hash.h index b895c26..bc7adf1 100644 --- a/modules/tsilo/ts_hash.h +++ b/modules/tsilo/ts_hash.h @@ -26,8 +26,8 @@ * Module: \ref tsilo */
-#ifndef _DIALOG_TS_HASH_H_ -#define _DIALOG_TS_HASH_H_ +#ifndef _TS_HASH_H_ +#define _TS_HASH_H_
#include "../../locking.h" #include "../../lib/kmi/mi.h" @@ -64,10 +64,10 @@ typedef struct ts_urecord /*! entries in the main transaction table */ typedef struct ts_entry { - int n; /*!< Number of elements in the collision slot */ + int n; /*!< Number of elements in the collision slot */ struct ts_urecord *first; /*!< urecord list */ - struct ts_urecord *last; /*!< optimisation, end of the urecord list */ - unsigned int next_id; /*!< next id */ + struct ts_urecord *last; /*!< optimisation, end of the urecord list */ + unsigned int next_id; /*!< next id */ unsigned int lock_idx; /*!< lock index */ } ts_entry_t;
@@ -75,13 +75,13 @@ typedef struct ts_entry /*! main transaction table */ typedef struct ts_table { - unsigned int size; /*!< size of the dialog table */ + unsigned int size; /*!< size of the tsilo table */ struct ts_entry *entries; /*!< urecord hash table */ unsigned int locks_no; /*!< number of locks */ - gen_lock_set_t *locks; /*!< lock table */ + gen_lock_set_t *locks; /*!< lock table */ } ts_table_t;
-/*! global dialog table */ +/*! global transactions table */ extern ts_table_t *t_table;
/*! diff --git a/modules/tsilo/tsilo.c b/modules/tsilo/tsilo.c index 90eb292..9c404dd 100644 --- a/modules/tsilo/tsilo.c +++ b/modules/tsilo/tsilo.c @@ -32,11 +32,13 @@ #include "../../modules/tm/tm_load.h" #include "../../modules/registrar/api.h" #include "../../dset.h" +#include "../../lib/kmi/mi.h"
#include "ts_hash.h" #include "ts_handlers.h" #include "ts_append.h" #include "ts_store.h" +#include "ts_mi.h"
MODULE_VERSION
@@ -57,20 +59,24 @@ static int w_ts_append_to(struct sip_msg* msg, char *idx, char *lbl, char *d); static int fixup_ts_append_to(void** param, int param_no); static int w_ts_append(struct sip_msg* _msg, char *_table, char *_ruri); static int fixup_ts_append(void** param, int param_no); - static int w_ts_store(struct sip_msg* msg);
- static cmd_export_t cmds[]={ {"ts_append_to", (cmd_function)w_ts_append_to, 3, - fixup_ts_append_to, REQUEST_ROUTE | FAILURE_ROUTE }, + fixup_ts_append_to, 0, REQUEST_ROUTE | FAILURE_ROUTE }, {"ts_append", (cmd_function)w_ts_append, 2, - fixup_ts_append, REQUEST_ROUTE | FAILURE_ROUTE }, + fixup_ts_append, 0, REQUEST_ROUTE | FAILURE_ROUTE }, {"ts_store", (cmd_function)w_ts_store, 0, - 0 , REQUEST_ROUTE | FAILURE_ROUTE }, + 0 , 0, REQUEST_ROUTE | FAILURE_ROUTE }, {0,0,0,0,0} };
+static mi_export_t mi_cmds[] = { + { "ts_dump", mi_tsilo_dump, 0, 0, 0 }, + { "ts_lookup", mi_tsilo_lookup, 0, 0, 0 }, + { 0, 0, 0, 0, 0} +}; + static param_export_t params[]={ {"hash_size", INT_PARAM, &hash_size}, {0,0,0} @@ -80,13 +86,16 @@ static param_export_t params[]={ /** module exports */ struct module_exports exports= { "tsilo", + DEFAULT_DLFLAGS, cmds, - 0, /* RPC methods */ params, + 0, /* exported statistics */ + mi_cmds, /* exported MI functions */ + 0, + 0, mod_init, /* module initialization function */ 0, (destroy_function) destroy, /* destroy function */ - 0, 0 };
@@ -97,6 +106,13 @@ static int mod_init(void) { unsigned int n;
+ /* register the MI commands */ + if(register_mi_mod(exports.name, mi_cmds)!=0) + { + LM_ERR("failed to register MI commands\n"); + return -1; + } + /* load the TM API */ if (load_tm_api(&_tmb)!=0) { LM_ERR("can't load TM API\n");
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.
Regards, Ovidiu Sas On Nov 12, 2014 5:59 AM, "Federico Cabiddu" federico.cabiddu@gmail.com wrote:
Module: sip-router Branch: master Commit: a255911902788bf74a7f4279fce4758b2f2a4613 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a2559119...
Author: Federico Cabiddu federico.cabiddu@gmail.com Committer: Federico Cabiddu federico.cabiddu@gmail.com Date: Wed Nov 12 11:52:29 2014 +0100
modules/tsilo: added MI commands
modules/tsilo/Makefile | 5 +++- modules/tsilo/README | 51 +++++++++++++++++++++++++++++-------- modules/tsilo/doc/tsilo_admin.xml | 44 ++++++++++++++++++++++++++------ modules/tsilo/ts_hash.c | 2 +- modules/tsilo/ts_hash.h | 16 ++++++------ modules/tsilo/tsilo.c | 30 ++++++++++++++++----- 6 files changed, 112 insertions(+), 36 deletions(-)
diff --git a/modules/tsilo/Makefile b/modules/tsilo/Makefile index 40b04cb..c179aec 100644 --- a/modules/tsilo/Makefile +++ b/modules/tsilo/Makefile @@ -9,10 +9,13 @@ include ../../Makefile.defs auto_gen= NAME=tsilo.so LIBS= -DEFS+= -DSER_MOD_INTERFACE +DEFS+=-DKAMAILIO_MOD_INTERFACE
ifeq ($(INSTALL_FLAVOUR),kamailio) DEFS+= -DWITH_EVENT_LOCAL_REQUEST endif # INSTALL_FLAVOUR
+SERLIBPATH=../../lib +SER_LIBS+=$(SERLIBPATH)/kmi/kmi
include ../../Makefile.modules diff --git a/modules/tsilo/README b/modules/tsilo/README index 4790ad1..297c435 100644 --- a/modules/tsilo/README +++ b/modules/tsilo/README @@ -10,7 +10,7 @@ Federico Cabiddu
<federico.cabiddu@gmail.com>
- Copyright © 2014 Federico Cabiddu
Copyright © 2014 Federico Cabiddu __________________________________________________________________
Table of Contents
@@ -33,7 +33,10 @@ Federico Cabiddu 4.2. ts_append(domain, ruri) 4.3. ts_append_to(tindex, tlabel, domain)
5. Statistics
5. MI Commands
5.1. ts_dump
5.2. ts_lookup
List of Examples
@@ -62,19 +65,26 @@ Chapter 1. Admin Guide 4.2. ts_append(domain, ruri) 4.3. ts_append_to(tindex, tlabel, domain)
- Statistics
- MI Commands
5.1. ts_dump
5.2. ts_lookup
Overview
This modules provides transaction storage for the Kamailio SIP Server
- Platform. It stores in an internal table transactions for an user and
- add branches to them if new contacts are added.
- Platform. It stores in an internal table transactions for a Request-URI
- (R-URI) and add branches to them later if new contacts for the AOR are
- added.
- For each message, the modules stores "Request-URI" ("R-URI"), URI and
- the internal transaction index and label.
- When the ts_store function is called, the modules stores the current
- transaction R-URI URI, index and label. Two functions (ts_append and
- ts_append_to) provide the ability to add new branches either to a
- specific transaction or to all of the transactions stored for a given
- R-URI.
- When the transaction is destroyed (by the TM module, the transaction is
- removed from the module table.
- When a transaction is destroyed by the TM module, it is removed from
- the module's table too.
- Dependencies
@@ -105,7 +115,7 @@ Chapter 1. Admin Guide must be a power of two, otherwise it will be rounded down to the nearest power of two.
- Default value is "2048".
Default value is “2048”.
Example 1.1. Set hash_size parameter
... @@ -182,4 +192,23 @@ if (is_method("REGISTER")) { } ...
-5. Statistics +5. MI Commands
- 5.1. ts_dump
- 5.2. ts_lookup
+5.1. ts_dump
- Dumps the entire content of the TSILO table
- Parameters:
* brief - (optional, may not be present); if equals to string
“brief”, a brief dump will be done (only RURI, without the
transaction(s) details)
+5.2. ts_lookup
- Dumps the transactions stored for the given RURI
- Parameters:
* ruri - RURI for which we want to show the transactions.
diff --git a/modules/tsilo/doc/tsilo_admin.xml b/modules/tsilo/doc/tsilo_admin.xml index 4c35e69..36180d1 100644 --- a/modules/tsilo/doc/tsilo_admin.xml +++ b/modules/tsilo/doc/tsilo_admin.xml @@ -17,17 +17,15 @@ <title>Overview</title> <para> This modules provides transaction storage for the &kamailioname;. It
stores in an internal table transactions for an user and
add branches
to them if new contacts are added.
stores in an internal table transactions for a Request-URI
(R-URI) and add branches
to them later if new contacts for the AOR are added. </para> <para>
For each message, the modules stores
<quote>Request-URI</quote>
(<quote>R-URI</quote>), &uri; and the internal transaction
index
and label.
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. </para> <para>
When the transaction is destroyed (by the
<emphasis>TM</emphasis> module,
the transaction is removed from the module table.
When a transaction is destroyed by the
<emphasis>TM</emphasis> module,
it is removed from the module's table too. </para> </section> <section>
@@ -201,6 +199,36 @@ if (is_method("REGISTER")) { </section>
<section>
<title>Statistics</title>
<title>MI Commands</title>
<section id="tsilo.mi.ts_dump">
<title>
<function moreinfo="none">ts_dump</function>
</title>
<para>
Dumps the entire content of the TSILO table
</para>
<para>Parameters: </para>
<itemizedlist>
<listitem><para>
<emphasis>brief</emphasis> -
(optional, may not be present); if
equals to string
<quote>brief</quote>, a brief dump will be
done (only RURI, without the
transaction(s) details)
</para></listitem>
</itemizedlist>
</section>
<section id="tsilo.mi.ts_lookup">
<title>
<function moreinfo="none">ts_lookup</function>
</title>
<para>
Dumps the transactions stored for the given RURI
</para>
<para>Parameters: </para>
<itemizedlist>
<listitem><para>
<emphasis>ruri</emphasis> - RURI
for which we want to show the transactions.
</para></listitem>
</itemizedlist>
</section> </section>
</chapter> diff --git a/modules/tsilo/ts_hash.c b/modules/tsilo/ts_hash.c index 089f425..6225db6 100644 --- a/modules/tsilo/ts_hash.c +++ b/modules/tsilo/ts_hash.c @@ -162,7 +162,7 @@ void unlock_entry(ts_entry_t *entry) {
void lock_entry_by_ruri(str* ruri) {
unsigned int sl;
unsigned int sl; sl = core_hash(ruri, 0, 0) & (t_table->size-1); ts_lock(t_table, &t_table->entries[sl]);
diff --git a/modules/tsilo/ts_hash.h b/modules/tsilo/ts_hash.h index b895c26..bc7adf1 100644 --- a/modules/tsilo/ts_hash.h +++ b/modules/tsilo/ts_hash.h @@ -26,8 +26,8 @@
- Module: \ref tsilo
*/
-#ifndef _DIALOG_TS_HASH_H_ -#define _DIALOG_TS_HASH_H_ +#ifndef _TS_HASH_H_ +#define _TS_HASH_H_
#include "../../locking.h" #include "../../lib/kmi/mi.h" @@ -64,10 +64,10 @@ typedef struct ts_urecord /*! entries in the main transaction table */ typedef struct ts_entry {
int n; /*!< Number of elements in the
collision slot */
int n; /*!< Number of elements in the
collision slot */ struct ts_urecord *first; /*!< urecord list */
struct ts_urecord *last; /*!< optimisation, end of the
urecord list */
unsigned int next_id; /*!< next id */
struct ts_urecord *last; /*!< optimisation, end of the
urecord list */
unsigned int next_id; /*!< next id */ unsigned int lock_idx; /*!< lock index */
} ts_entry_t;
@@ -75,13 +75,13 @@ typedef struct ts_entry /*! main transaction table */ typedef struct ts_table {
unsigned int size; /*!< size of the dialog table */
unsigned int size; /*!< size of the tsilo table */ struct ts_entry *entries; /*!< urecord hash table */ unsigned int locks_no; /*!< number of locks */
gen_lock_set_t *locks; /*!< lock table */
gen_lock_set_t *locks; /*!< lock table */
} ts_table_t;
-/*! global dialog table */ +/*! global transactions table */ extern ts_table_t *t_table;
/*! diff --git a/modules/tsilo/tsilo.c b/modules/tsilo/tsilo.c index 90eb292..9c404dd 100644 --- a/modules/tsilo/tsilo.c +++ b/modules/tsilo/tsilo.c @@ -32,11 +32,13 @@ #include "../../modules/tm/tm_load.h" #include "../../modules/registrar/api.h" #include "../../dset.h" +#include "../../lib/kmi/mi.h"
#include "ts_hash.h" #include "ts_handlers.h" #include "ts_append.h" #include "ts_store.h" +#include "ts_mi.h"
MODULE_VERSION
@@ -57,20 +59,24 @@ static int w_ts_append_to(struct sip_msg* msg, char *idx, char *lbl, char *d); static int fixup_ts_append_to(void** param, int param_no); static int w_ts_append(struct sip_msg* _msg, char *_table, char *_ruri); static int fixup_ts_append(void** param, int param_no);
static int w_ts_store(struct sip_msg* msg);
static cmd_export_t cmds[]={ {"ts_append_to", (cmd_function)w_ts_append_to, 3,
fixup_ts_append_to, REQUEST_ROUTE | FAILURE_ROUTE },
fixup_ts_append_to, 0, REQUEST_ROUTE | FAILURE_ROUTE }, {"ts_append", (cmd_function)w_ts_append, 2,
fixup_ts_append, REQUEST_ROUTE | FAILURE_ROUTE },
fixup_ts_append, 0, REQUEST_ROUTE | FAILURE_ROUTE }, {"ts_store", (cmd_function)w_ts_store, 0,
0 , REQUEST_ROUTE | FAILURE_ROUTE },
0 , 0, REQUEST_ROUTE | FAILURE_ROUTE }, {0,0,0,0,0}
};
+static mi_export_t mi_cmds[] = {
{ "ts_dump", mi_tsilo_dump, 0, 0, 0
},
{ "ts_lookup", mi_tsilo_lookup, 0, 0, 0
},
- { 0, 0, 0, 0, 0}
+};
static param_export_t params[]={ {"hash_size", INT_PARAM, &hash_size}, {0,0,0} @@ -80,13 +86,16 @@ static param_export_t params[]={ /** module exports */ struct module_exports exports= { "tsilo",
- DEFAULT_DLFLAGS, cmds,
0, /* RPC methods */ params,
0, /* exported statistics */
- mi_cmds, /* exported MI functions */
- 0,
- 0, mod_init, /* module initialization function */ 0, (destroy_function) destroy, /* destroy function */
0, 0
};
@@ -97,6 +106,13 @@ static int mod_init(void) { unsigned int n;
/* register the MI commands */
if(register_mi_mod(exports.name, mi_cmds)!=0)
- {
LM_ERR("failed to register MI commands\n");
return -1;
- }
/* load the TM API */ if (load_tm_api(&_tmb)!=0) { LM_ERR("can't load TM API\n");
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
Basically I added those commands for "completness" since I was adding the corresponding RPC commands. In the future if I will need to add more I'll add only the RPC ones. Thanks for the feedback.
Regards,
Federico
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.
Regards, Ovidiu Sas On Nov 12, 2014 5:59 AM, "Federico Cabiddu" federico.cabiddu@gmail.com wrote:
Module: sip-router Branch: master Commit: a255911902788bf74a7f4279fce4758b2f2a4613 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a2559119...
Author: Federico Cabiddu federico.cabiddu@gmail.com Committer: Federico Cabiddu federico.cabiddu@gmail.com Date: Wed Nov 12 11:52:29 2014 +0100
modules/tsilo: added MI commands
modules/tsilo/Makefile | 5 +++- modules/tsilo/README | 51 +++++++++++++++++++++++++++++-------- modules/tsilo/doc/tsilo_admin.xml | 44 ++++++++++++++++++++++++++------ modules/tsilo/ts_hash.c | 2 +- modules/tsilo/ts_hash.h | 16 ++++++------ modules/tsilo/tsilo.c | 30 ++++++++++++++++----- 6 files changed, 112 insertions(+), 36 deletions(-)
diff --git a/modules/tsilo/Makefile b/modules/tsilo/Makefile index 40b04cb..c179aec 100644 --- a/modules/tsilo/Makefile +++ b/modules/tsilo/Makefile @@ -9,10 +9,13 @@ include ../../Makefile.defs auto_gen= NAME=tsilo.so LIBS= -DEFS+= -DSER_MOD_INTERFACE +DEFS+=-DKAMAILIO_MOD_INTERFACE
ifeq ($(INSTALL_FLAVOUR),kamailio) DEFS+= -DWITH_EVENT_LOCAL_REQUEST endif # INSTALL_FLAVOUR
+SERLIBPATH=../../lib +SER_LIBS+=$(SERLIBPATH)/kmi/kmi
include ../../Makefile.modules diff --git a/modules/tsilo/README b/modules/tsilo/README index 4790ad1..297c435 100644 --- a/modules/tsilo/README +++ b/modules/tsilo/README @@ -10,7 +10,7 @@ Federico Cabiddu
<federico.cabiddu@gmail.com>
- Copyright © 2014 Federico Cabiddu
Copyright © 2014 Federico Cabiddu __________________________________________________________________
Table of Contents
@@ -33,7 +33,10 @@ Federico Cabiddu 4.2. ts_append(domain, ruri) 4.3. ts_append_to(tindex, tlabel, domain)
5. Statistics
5. MI Commands
5.1. ts_dump
5.2. ts_lookup
List of Examples
@@ -62,19 +65,26 @@ Chapter 1. Admin Guide 4.2. ts_append(domain, ruri) 4.3. ts_append_to(tindex, tlabel, domain)
- Statistics
- MI Commands
5.1. ts_dump
5.2. ts_lookup
Overview
This modules provides transaction storage for the Kamailio SIP Server
- Platform. It stores in an internal table transactions for an user and
- add branches to them if new contacts are added.
- Platform. It stores in an internal table transactions for a Request-URI
- (R-URI) and add branches to them later if new contacts for the AOR are
- added.
- For each message, the modules stores "Request-URI" ("R-URI"), URI and
- the internal transaction index and label.
- When the ts_store function is called, the modules stores the current
- transaction R-URI URI, index and label. Two functions (ts_append and
- ts_append_to) provide the ability to add new branches either to a
- specific transaction or to all of the transactions stored for a given
- R-URI.
- When the transaction is destroyed (by the TM module, the transaction is
- removed from the module table.
- When a transaction is destroyed by the TM module, it is removed from
- the module's table too.
- Dependencies
@@ -105,7 +115,7 @@ Chapter 1. Admin Guide must be a power of two, otherwise it will be rounded down to the nearest power of two.
- Default value is "2048".
Default value is “2048”.
Example 1.1. Set hash_size parameter
... @@ -182,4 +192,23 @@ if (is_method("REGISTER")) { } ...
-5. Statistics +5. MI Commands
- 5.1. ts_dump
- 5.2. ts_lookup
+5.1. ts_dump
- Dumps the entire content of the TSILO table
- Parameters:
* brief - (optional, may not be present); if equals to string
“brief”, a brief dump will be done (only RURI, without the
transaction(s) details)
+5.2. ts_lookup
- Dumps the transactions stored for the given RURI
- Parameters:
* ruri - RURI for which we want to show the transactions.
diff --git a/modules/tsilo/doc/tsilo_admin.xml b/modules/tsilo/doc/tsilo_admin.xml index 4c35e69..36180d1 100644 --- a/modules/tsilo/doc/tsilo_admin.xml +++ b/modules/tsilo/doc/tsilo_admin.xml @@ -17,17 +17,15 @@ <title>Overview</title> <para> This modules provides transaction storage for the &kamailioname;. It
stores in an internal table transactions for an user and
add branches
to them if new contacts are added.
stores in an internal table transactions for a Request-URI
(R-URI) and add branches
to them later if new contacts for the AOR are added. </para> <para>
For each message, the modules stores
<quote>Request-URI</quote>
(<quote>R-URI</quote>), &uri; and the internal transaction
index
and label.
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. </para> <para>
When the transaction is destroyed (by the
<emphasis>TM</emphasis> module,
the transaction is removed from the module table.
When a transaction is destroyed by the
<emphasis>TM</emphasis> module,
it is removed from the module's table too. </para> </section> <section>
@@ -201,6 +199,36 @@ if (is_method("REGISTER")) { </section>
<section>
<title>Statistics</title>
<title>MI Commands</title>
<section id="tsilo.mi.ts_dump">
<title>
<function moreinfo="none">ts_dump</function>
</title>
<para>
Dumps the entire content of the TSILO table
</para>
<para>Parameters: </para>
<itemizedlist>
<listitem><para>
<emphasis>brief</emphasis> -
(optional, may not be present); if
equals to string
<quote>brief</quote>, a brief dump will be
done (only RURI, without the
transaction(s) details)
</para></listitem>
</itemizedlist>
</section>
<section id="tsilo.mi.ts_lookup">
<title>
<function moreinfo="none">ts_lookup</function>
</title>
<para>
Dumps the transactions stored for the given RURI
</para>
<para>Parameters: </para>
<itemizedlist>
<listitem><para>
<emphasis>ruri</emphasis> - RURI
for which we want to show the transactions.
</para></listitem>
</itemizedlist>
</section> </section>
</chapter> diff --git a/modules/tsilo/ts_hash.c b/modules/tsilo/ts_hash.c index 089f425..6225db6 100644 --- a/modules/tsilo/ts_hash.c +++ b/modules/tsilo/ts_hash.c @@ -162,7 +162,7 @@ void unlock_entry(ts_entry_t *entry) {
void lock_entry_by_ruri(str* ruri) {
unsigned int sl;
unsigned int sl; sl = core_hash(ruri, 0, 0) & (t_table->size-1); ts_lock(t_table, &t_table->entries[sl]);
diff --git a/modules/tsilo/ts_hash.h b/modules/tsilo/ts_hash.h index b895c26..bc7adf1 100644 --- a/modules/tsilo/ts_hash.h +++ b/modules/tsilo/ts_hash.h @@ -26,8 +26,8 @@
- Module: \ref tsilo
*/
-#ifndef _DIALOG_TS_HASH_H_ -#define _DIALOG_TS_HASH_H_ +#ifndef _TS_HASH_H_ +#define _TS_HASH_H_
#include "../../locking.h" #include "../../lib/kmi/mi.h" @@ -64,10 +64,10 @@ typedef struct ts_urecord /*! entries in the main transaction table */ typedef struct ts_entry {
int n; /*!< Number of elements in the
collision slot */
int n; /*!< Number of elements in the
collision slot */ struct ts_urecord *first; /*!< urecord list */
struct ts_urecord *last; /*!< optimisation, end of the
urecord list */
unsigned int next_id; /*!< next id */
struct ts_urecord *last; /*!< optimisation, end of the
urecord list */
unsigned int next_id; /*!< next id */ unsigned int lock_idx; /*!< lock index */
} ts_entry_t;
@@ -75,13 +75,13 @@ typedef struct ts_entry /*! main transaction table */ typedef struct ts_table {
unsigned int size; /*!< size of the dialog table */
unsigned int size; /*!< size of the tsilo table */ struct ts_entry *entries; /*!< urecord hash table */ unsigned int locks_no; /*!< number of locks */
gen_lock_set_t *locks; /*!< lock table */
gen_lock_set_t *locks; /*!< lock table */
} ts_table_t;
-/*! global dialog table */ +/*! global transactions table */ extern ts_table_t *t_table;
/*! diff --git a/modules/tsilo/tsilo.c b/modules/tsilo/tsilo.c index 90eb292..9c404dd 100644 --- a/modules/tsilo/tsilo.c +++ b/modules/tsilo/tsilo.c @@ -32,11 +32,13 @@ #include "../../modules/tm/tm_load.h" #include "../../modules/registrar/api.h" #include "../../dset.h" +#include "../../lib/kmi/mi.h"
#include "ts_hash.h" #include "ts_handlers.h" #include "ts_append.h" #include "ts_store.h" +#include "ts_mi.h"
MODULE_VERSION
@@ -57,20 +59,24 @@ static int w_ts_append_to(struct sip_msg* msg, char *idx, char *lbl, char *d); static int fixup_ts_append_to(void** param, int param_no); static int w_ts_append(struct sip_msg* _msg, char *_table, char *_ruri); static int fixup_ts_append(void** param, int param_no);
static int w_ts_store(struct sip_msg* msg);
static cmd_export_t cmds[]={ {"ts_append_to", (cmd_function)w_ts_append_to, 3,
fixup_ts_append_to, REQUEST_ROUTE | FAILURE_ROUTE },
fixup_ts_append_to, 0, REQUEST_ROUTE | FAILURE_ROUTE }, {"ts_append", (cmd_function)w_ts_append, 2,
fixup_ts_append, REQUEST_ROUTE | FAILURE_ROUTE },
fixup_ts_append, 0, REQUEST_ROUTE | FAILURE_ROUTE }, {"ts_store", (cmd_function)w_ts_store, 0,
0 , REQUEST_ROUTE | FAILURE_ROUTE },
0 , 0, REQUEST_ROUTE | FAILURE_ROUTE }, {0,0,0,0,0}
};
+static mi_export_t mi_cmds[] = {
{ "ts_dump", mi_tsilo_dump, 0, 0, 0
},
{ "ts_lookup", mi_tsilo_lookup, 0, 0, 0
},
- { 0, 0, 0, 0, 0}
+};
static param_export_t params[]={ {"hash_size", INT_PARAM, &hash_size}, {0,0,0} @@ -80,13 +86,16 @@ static param_export_t params[]={ /** module exports */ struct module_exports exports= { "tsilo",
- DEFAULT_DLFLAGS, cmds,
0, /* RPC methods */ params,
0, /* exported statistics */
- mi_cmds, /* exported MI functions */
- 0,
- 0, mod_init, /* module initialization function */ 0, (destroy_function) destroy, /* destroy function */
0, 0
};
@@ -97,6 +106,13 @@ static int mod_init(void) { unsigned int n;
/* register the MI commands */
if(register_mi_mod(exports.name, mi_cmds)!=0)
- {
LM_ERR("failed to register MI commands\n");
return -1;
- }
/* load the TM API */ if (load_tm_api(&_tmb)!=0) { LM_ERR("can't load TM API\n");
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
_______________________________________________ sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
The plan is to remove all MI commands. The issue right now is that many ppl are using the MI and don't really want to migrate to RPC. If we add new MI commands, we are just adding more overhead. My suggestion would be to remove them, along with the mi lib dependency.
Regards, Ovidiu Sas On Nov 12, 2014 11:49 AM, "Federico Cabiddu" federico.cabiddu@gmail.com wrote:
Basically I added those commands for "completness" since I was adding the corresponding RPC commands. In the future if I will need to add more I'll add only the RPC ones. Thanks for the feedback.
Regards,
Federico
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.
Regards, Ovidiu Sas On Nov 12, 2014 5:59 AM, "Federico Cabiddu" federico.cabiddu@gmail.com wrote:
Module: sip-router Branch: master Commit: a255911902788bf74a7f4279fce4758b2f2a4613 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a2559119...
Author: Federico Cabiddu federico.cabiddu@gmail.com Committer: Federico Cabiddu federico.cabiddu@gmail.com Date: Wed Nov 12 11:52:29 2014 +0100
modules/tsilo: added MI commands
modules/tsilo/Makefile | 5 +++- modules/tsilo/README | 51 +++++++++++++++++++++++++++++-------- modules/tsilo/doc/tsilo_admin.xml | 44 ++++++++++++++++++++++++++------ modules/tsilo/ts_hash.c | 2 +- modules/tsilo/ts_hash.h | 16 ++++++------ modules/tsilo/tsilo.c | 30 ++++++++++++++++----- 6 files changed, 112 insertions(+), 36 deletions(-)
diff --git a/modules/tsilo/Makefile b/modules/tsilo/Makefile index 40b04cb..c179aec 100644 --- a/modules/tsilo/Makefile +++ b/modules/tsilo/Makefile @@ -9,10 +9,13 @@ include ../../Makefile.defs auto_gen= NAME=tsilo.so LIBS= -DEFS+= -DSER_MOD_INTERFACE +DEFS+=-DKAMAILIO_MOD_INTERFACE
ifeq ($(INSTALL_FLAVOUR),kamailio) DEFS+= -DWITH_EVENT_LOCAL_REQUEST endif # INSTALL_FLAVOUR
+SERLIBPATH=../../lib +SER_LIBS+=$(SERLIBPATH)/kmi/kmi
include ../../Makefile.modules diff --git a/modules/tsilo/README b/modules/tsilo/README index 4790ad1..297c435 100644 --- a/modules/tsilo/README +++ b/modules/tsilo/README @@ -10,7 +10,7 @@ Federico Cabiddu
<federico.cabiddu@gmail.com>
- Copyright © 2014 Federico Cabiddu
Copyright © 2014 Federico Cabiddu __________________________________________________________________
Table of Contents
@@ -33,7 +33,10 @@ Federico Cabiddu 4.2. ts_append(domain, ruri) 4.3. ts_append_to(tindex, tlabel, domain)
5. Statistics
5. MI Commands
5.1. ts_dump
5.2. ts_lookup
List of Examples
@@ -62,19 +65,26 @@ Chapter 1. Admin Guide 4.2. ts_append(domain, ruri) 4.3. ts_append_to(tindex, tlabel, domain)
- Statistics
- MI Commands
5.1. ts_dump
5.2. ts_lookup
Overview
This modules provides transaction storage for the Kamailio SIP Server
- Platform. It stores in an internal table transactions for an user and
- add branches to them if new contacts are added.
- Platform. It stores in an internal table transactions for a
Request-URI
- (R-URI) and add branches to them later if new contacts for the AOR are
- added.
- For each message, the modules stores "Request-URI" ("R-URI"), URI and
- the internal transaction index and label.
- When the ts_store function is called, the modules stores the current
- transaction R-URI URI, index and label. Two functions (ts_append and
- ts_append_to) provide the ability to add new branches either to a
- specific transaction or to all of the transactions stored for a given
- R-URI.
- When the transaction is destroyed (by the TM module, the transaction
is
- removed from the module table.
- When a transaction is destroyed by the TM module, it is removed from
- the module's table too.
- Dependencies
@@ -105,7 +115,7 @@ Chapter 1. Admin Guide must be a power of two, otherwise it will be rounded down to the nearest power of two.
- Default value is "2048".
Default value is “2048”.
Example 1.1. Set hash_size parameter
... @@ -182,4 +192,23 @@ if (is_method("REGISTER")) { } ...
-5. Statistics +5. MI Commands
- 5.1. ts_dump
- 5.2. ts_lookup
+5.1. ts_dump
- Dumps the entire content of the TSILO table
- Parameters:
* brief - (optional, may not be present); if equals to string
“brief”, a brief dump will be done (only RURI, without the
transaction(s) details)
+5.2. ts_lookup
- Dumps the transactions stored for the given RURI
- Parameters:
* ruri - RURI for which we want to show the transactions.
diff --git a/modules/tsilo/doc/tsilo_admin.xml b/modules/tsilo/doc/tsilo_admin.xml index 4c35e69..36180d1 100644 --- a/modules/tsilo/doc/tsilo_admin.xml +++ b/modules/tsilo/doc/tsilo_admin.xml @@ -17,17 +17,15 @@ <title>Overview</title> <para> This modules provides transaction storage for the &kamailioname;. It
stores in an internal table transactions for an user and
add branches
to them if new contacts are added.
stores in an internal table transactions for a
Request-URI (R-URI) and add branches
to them later if new contacts for the AOR are added. </para> <para>
For each message, the modules stores
<quote>Request-URI</quote>
(<quote>R-URI</quote>), &uri; and the internal
transaction index
and label.
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. </para> <para>
When the transaction is destroyed (by the
<emphasis>TM</emphasis> module,
the transaction is removed from the module table.
When a transaction is destroyed by the
<emphasis>TM</emphasis> module,
it is removed from the module's table too. </para> </section> <section>
@@ -201,6 +199,36 @@ if (is_method("REGISTER")) { </section>
<section>
<title>Statistics</title>
<title>MI Commands</title>
<section id="tsilo.mi.ts_dump">
<title>
<function moreinfo="none">ts_dump</function>
</title>
<para>
Dumps the entire content of the TSILO table
</para>
<para>Parameters: </para>
<itemizedlist>
<listitem><para>
<emphasis>brief</emphasis> -
(optional, may not be present); if
equals to string
<quote>brief</quote>, a brief dump will be
done (only RURI, without the
transaction(s) details)
</para></listitem>
</itemizedlist>
</section>
<section id="tsilo.mi.ts_lookup">
<title>
<function moreinfo="none">ts_lookup</function>
</title>
<para>
Dumps the transactions stored for the given RURI
</para>
<para>Parameters: </para>
<itemizedlist>
<listitem><para>
<emphasis>ruri</emphasis> - RURI
for which we want to show the transactions.
</para></listitem>
</itemizedlist>
</section> </section>
</chapter> diff --git a/modules/tsilo/ts_hash.c b/modules/tsilo/ts_hash.c index 089f425..6225db6 100644 --- a/modules/tsilo/ts_hash.c +++ b/modules/tsilo/ts_hash.c @@ -162,7 +162,7 @@ void unlock_entry(ts_entry_t *entry) {
void lock_entry_by_ruri(str* ruri) {
unsigned int sl;
unsigned int sl; sl = core_hash(ruri, 0, 0) & (t_table->size-1); ts_lock(t_table, &t_table->entries[sl]);
diff --git a/modules/tsilo/ts_hash.h b/modules/tsilo/ts_hash.h index b895c26..bc7adf1 100644 --- a/modules/tsilo/ts_hash.h +++ b/modules/tsilo/ts_hash.h @@ -26,8 +26,8 @@
- Module: \ref tsilo
*/
-#ifndef _DIALOG_TS_HASH_H_ -#define _DIALOG_TS_HASH_H_ +#ifndef _TS_HASH_H_ +#define _TS_HASH_H_
#include "../../locking.h" #include "../../lib/kmi/mi.h" @@ -64,10 +64,10 @@ typedef struct ts_urecord /*! entries in the main transaction table */ typedef struct ts_entry {
int n; /*!< Number of elements in the
collision slot */
int n; /*!< Number of elements in
the collision slot */ struct ts_urecord *first; /*!< urecord list */
struct ts_urecord *last; /*!< optimisation, end of the
urecord list */
unsigned int next_id; /*!< next id */
struct ts_urecord *last; /*!< optimisation, end of the
urecord list */
unsigned int next_id; /*!< next id */ unsigned int lock_idx; /*!< lock index */
} ts_entry_t;
@@ -75,13 +75,13 @@ typedef struct ts_entry /*! main transaction table */ typedef struct ts_table {
unsigned int size; /*!< size of the dialog table */
unsigned int size; /*!< size of the tsilo table
*/ struct ts_entry *entries; /*!< urecord hash table */ unsigned int locks_no; /*!< number of locks */
gen_lock_set_t *locks; /*!< lock table */
gen_lock_set_t *locks; /*!< lock table */
} ts_table_t;
-/*! global dialog table */ +/*! global transactions table */ extern ts_table_t *t_table;
/*! diff --git a/modules/tsilo/tsilo.c b/modules/tsilo/tsilo.c index 90eb292..9c404dd 100644 --- a/modules/tsilo/tsilo.c +++ b/modules/tsilo/tsilo.c @@ -32,11 +32,13 @@ #include "../../modules/tm/tm_load.h" #include "../../modules/registrar/api.h" #include "../../dset.h" +#include "../../lib/kmi/mi.h"
#include "ts_hash.h" #include "ts_handlers.h" #include "ts_append.h" #include "ts_store.h" +#include "ts_mi.h"
MODULE_VERSION
@@ -57,20 +59,24 @@ static int w_ts_append_to(struct sip_msg* msg, char *idx, char *lbl, char *d); static int fixup_ts_append_to(void** param, int param_no); static int w_ts_append(struct sip_msg* _msg, char *_table, char *_ruri); static int fixup_ts_append(void** param, int param_no);
static int w_ts_store(struct sip_msg* msg);
static cmd_export_t cmds[]={ {"ts_append_to", (cmd_function)w_ts_append_to, 3,
fixup_ts_append_to, REQUEST_ROUTE | FAILURE_ROUTE },
fixup_ts_append_to, 0, REQUEST_ROUTE | FAILURE_ROUTE }, {"ts_append", (cmd_function)w_ts_append, 2,
fixup_ts_append, REQUEST_ROUTE | FAILURE_ROUTE },
fixup_ts_append, 0, REQUEST_ROUTE | FAILURE_ROUTE }, {"ts_store", (cmd_function)w_ts_store, 0,
0 , REQUEST_ROUTE | FAILURE_ROUTE },
0 , 0, REQUEST_ROUTE | FAILURE_ROUTE }, {0,0,0,0,0}
};
+static mi_export_t mi_cmds[] = {
{ "ts_dump", mi_tsilo_dump, 0, 0, 0
},
{ "ts_lookup", mi_tsilo_lookup, 0, 0, 0
},
- { 0, 0, 0, 0, 0}
+};
static param_export_t params[]={ {"hash_size", INT_PARAM, &hash_size}, {0,0,0} @@ -80,13 +86,16 @@ static param_export_t params[]={ /** module exports */ struct module_exports exports= { "tsilo",
- DEFAULT_DLFLAGS, cmds,
0, /* RPC methods */ params,
0, /* exported statistics */
- mi_cmds, /* exported MI functions */
- 0,
- 0, mod_init, /* module initialization function */ 0, (destroy_function) destroy, /* destroy function */
0, 0
};
@@ -97,6 +106,13 @@ static int mod_init(void) { unsigned int n;
/* register the MI commands */
if(register_mi_mod(exports.name, mi_cmds)!=0)
- {
LM_ERR("failed to register MI commands\n");
return -1;
- }
/* load the TM API */ if (load_tm_api(&_tmb)!=0) { LM_ERR("can't load TM API\n");
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
Ok I understand your point. I can remove the commands, no problem.
Regards,
Federico
On Wed, Nov 12, 2014 at 6:09 PM, Ovidiu Sas osas@voipembedded.com wrote:
The plan is to remove all MI commands. The issue right now is that many ppl are using the MI and don't really want to migrate to RPC. If we add new MI commands, we are just adding more overhead. My suggestion would be to remove them, along with the mi lib dependency.
Regards, Ovidiu Sas On Nov 12, 2014 11:49 AM, "Federico Cabiddu" federico.cabiddu@gmail.com wrote:
Basically I added those commands for "completness" since I was adding the corresponding RPC commands. In the future if I will need to add more I'll add only the RPC ones. Thanks for the feedback.
Regards,
Federico
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.
Regards, Ovidiu Sas On Nov 12, 2014 5:59 AM, "Federico Cabiddu" federico.cabiddu@gmail.com wrote:
Module: sip-router Branch: master Commit: a255911902788bf74a7f4279fce4758b2f2a4613 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a2559119...
Author: Federico Cabiddu federico.cabiddu@gmail.com Committer: Federico Cabiddu federico.cabiddu@gmail.com Date: Wed Nov 12 11:52:29 2014 +0100
modules/tsilo: added MI commands
modules/tsilo/Makefile | 5 +++- modules/tsilo/README | 51 +++++++++++++++++++++++++++++-------- modules/tsilo/doc/tsilo_admin.xml | 44 ++++++++++++++++++++++++++------ modules/tsilo/ts_hash.c | 2 +- modules/tsilo/ts_hash.h | 16 ++++++------ modules/tsilo/tsilo.c | 30 ++++++++++++++++----- 6 files changed, 112 insertions(+), 36 deletions(-)
diff --git a/modules/tsilo/Makefile b/modules/tsilo/Makefile index 40b04cb..c179aec 100644 --- a/modules/tsilo/Makefile +++ b/modules/tsilo/Makefile @@ -9,10 +9,13 @@ include ../../Makefile.defs auto_gen= NAME=tsilo.so LIBS= -DEFS+= -DSER_MOD_INTERFACE +DEFS+=-DKAMAILIO_MOD_INTERFACE
ifeq ($(INSTALL_FLAVOUR),kamailio) DEFS+= -DWITH_EVENT_LOCAL_REQUEST endif # INSTALL_FLAVOUR
+SERLIBPATH=../../lib +SER_LIBS+=$(SERLIBPATH)/kmi/kmi
include ../../Makefile.modules diff --git a/modules/tsilo/README b/modules/tsilo/README index 4790ad1..297c435 100644 --- a/modules/tsilo/README +++ b/modules/tsilo/README @@ -10,7 +10,7 @@ Federico Cabiddu
<federico.cabiddu@gmail.com>
- Copyright © 2014 Federico Cabiddu
Copyright © 2014 Federico Cabiddu __________________________________________________________________
Table of Contents
@@ -33,7 +33,10 @@ Federico Cabiddu 4.2. ts_append(domain, ruri) 4.3. ts_append_to(tindex, tlabel, domain)
5. Statistics
5. MI Commands
5.1. ts_dump
5.2. ts_lookup
List of Examples
@@ -62,19 +65,26 @@ Chapter 1. Admin Guide 4.2. ts_append(domain, ruri) 4.3. ts_append_to(tindex, tlabel, domain)
- Statistics
- MI Commands
5.1. ts_dump
5.2. ts_lookup
Overview
This modules provides transaction storage for the Kamailio SIP Server
- Platform. It stores in an internal table transactions for an user and
- add branches to them if new contacts are added.
- Platform. It stores in an internal table transactions for a
Request-URI
- (R-URI) and add branches to them later if new contacts for the AOR
are
- added.
- For each message, the modules stores "Request-URI" ("R-URI"), URI and
- the internal transaction index and label.
- When the ts_store function is called, the modules stores the current
- transaction R-URI URI, index and label. Two functions (ts_append and
- ts_append_to) provide the ability to add new branches either to a
- specific transaction or to all of the transactions stored for a given
- R-URI.
- When the transaction is destroyed (by the TM module, the transaction
is
- removed from the module table.
- When a transaction is destroyed by the TM module, it is removed from
- the module's table too.
- Dependencies
@@ -105,7 +115,7 @@ Chapter 1. Admin Guide must be a power of two, otherwise it will be rounded down to the nearest power of two.
- Default value is "2048".
Default value is “2048”.
Example 1.1. Set hash_size parameter
... @@ -182,4 +192,23 @@ if (is_method("REGISTER")) { } ...
-5. Statistics +5. MI Commands
- 5.1. ts_dump
- 5.2. ts_lookup
+5.1. ts_dump
- Dumps the entire content of the TSILO table
- Parameters:
* brief - (optional, may not be present); if equals to string
“brief”, a brief dump will be done (only RURI, without the
transaction(s) details)
+5.2. ts_lookup
- Dumps the transactions stored for the given RURI
- Parameters:
* ruri - RURI for which we want to show the transactions.
diff --git a/modules/tsilo/doc/tsilo_admin.xml b/modules/tsilo/doc/tsilo_admin.xml index 4c35e69..36180d1 100644 --- a/modules/tsilo/doc/tsilo_admin.xml +++ b/modules/tsilo/doc/tsilo_admin.xml @@ -17,17 +17,15 @@ <title>Overview</title> <para> This modules provides transaction storage for the &kamailioname;. It
stores in an internal table transactions for an user and
add branches
to them if new contacts are added.
stores in an internal table transactions for a
Request-URI (R-URI) and add branches
to them later if new contacts for the AOR are added. </para> <para>
For each message, the modules stores
<quote>Request-URI</quote>
(<quote>R-URI</quote>), &uri; and the internal
transaction index
and label.
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. </para> <para>
When the transaction is destroyed (by the
<emphasis>TM</emphasis> module,
the transaction is removed from the module table.
When a transaction is destroyed by the
<emphasis>TM</emphasis> module,
it is removed from the module's table too. </para> </section> <section>
@@ -201,6 +199,36 @@ if (is_method("REGISTER")) { </section>
<section>
<title>Statistics</title>
<title>MI Commands</title>
<section id="tsilo.mi.ts_dump">
<title>
<function moreinfo="none">ts_dump</function>
</title>
<para>
Dumps the entire content of the TSILO table
</para>
<para>Parameters: </para>
<itemizedlist>
<listitem><para>
<emphasis>brief</emphasis> -
(optional, may not be present); if
equals to string
<quote>brief</quote>, a brief dump will be
done (only RURI, without the
transaction(s) details)
</para></listitem>
</itemizedlist>
</section>
<section id="tsilo.mi.ts_lookup">
<title>
<function moreinfo="none">ts_lookup</function>
</title>
<para>
Dumps the transactions stored for the given RURI
</para>
<para>Parameters: </para>
<itemizedlist>
<listitem><para>
<emphasis>ruri</emphasis> - RURI
for which we want to show the transactions.
</para></listitem>
</itemizedlist>
</section> </section>
</chapter> diff --git a/modules/tsilo/ts_hash.c b/modules/tsilo/ts_hash.c index 089f425..6225db6 100644 --- a/modules/tsilo/ts_hash.c +++ b/modules/tsilo/ts_hash.c @@ -162,7 +162,7 @@ void unlock_entry(ts_entry_t *entry) {
void lock_entry_by_ruri(str* ruri) {
unsigned int sl;
unsigned int sl; sl = core_hash(ruri, 0, 0) & (t_table->size-1); ts_lock(t_table, &t_table->entries[sl]);
diff --git a/modules/tsilo/ts_hash.h b/modules/tsilo/ts_hash.h index b895c26..bc7adf1 100644 --- a/modules/tsilo/ts_hash.h +++ b/modules/tsilo/ts_hash.h @@ -26,8 +26,8 @@
- Module: \ref tsilo
*/
-#ifndef _DIALOG_TS_HASH_H_ -#define _DIALOG_TS_HASH_H_ +#ifndef _TS_HASH_H_ +#define _TS_HASH_H_
#include "../../locking.h" #include "../../lib/kmi/mi.h" @@ -64,10 +64,10 @@ typedef struct ts_urecord /*! entries in the main transaction table */ typedef struct ts_entry {
int n; /*!< Number of elements in the
collision slot */
int n; /*!< Number of elements in
the collision slot */ struct ts_urecord *first; /*!< urecord list */
struct ts_urecord *last; /*!< optimisation, end of the
urecord list */
unsigned int next_id; /*!< next id */
struct ts_urecord *last; /*!< optimisation, end of
the urecord list */
unsigned int next_id; /*!< next id */ unsigned int lock_idx; /*!< lock index */
} ts_entry_t;
@@ -75,13 +75,13 @@ typedef struct ts_entry /*! main transaction table */ typedef struct ts_table {
unsigned int size; /*!< size of the dialog table */
unsigned int size; /*!< size of the tsilo table
*/ struct ts_entry *entries; /*!< urecord hash table */ unsigned int locks_no; /*!< number of locks */
gen_lock_set_t *locks; /*!< lock table */
gen_lock_set_t *locks; /*!< lock table */
} ts_table_t;
-/*! global dialog table */ +/*! global transactions table */ extern ts_table_t *t_table;
/*! diff --git a/modules/tsilo/tsilo.c b/modules/tsilo/tsilo.c index 90eb292..9c404dd 100644 --- a/modules/tsilo/tsilo.c +++ b/modules/tsilo/tsilo.c @@ -32,11 +32,13 @@ #include "../../modules/tm/tm_load.h" #include "../../modules/registrar/api.h" #include "../../dset.h" +#include "../../lib/kmi/mi.h"
#include "ts_hash.h" #include "ts_handlers.h" #include "ts_append.h" #include "ts_store.h" +#include "ts_mi.h"
MODULE_VERSION
@@ -57,20 +59,24 @@ static int w_ts_append_to(struct sip_msg* msg, char *idx, char *lbl, char *d); static int fixup_ts_append_to(void** param, int param_no); static int w_ts_append(struct sip_msg* _msg, char *_table, char *_ruri); static int fixup_ts_append(void** param, int param_no);
static int w_ts_store(struct sip_msg* msg);
static cmd_export_t cmds[]={ {"ts_append_to", (cmd_function)w_ts_append_to, 3,
fixup_ts_append_to, REQUEST_ROUTE | FAILURE_ROUTE },
fixup_ts_append_to, 0, REQUEST_ROUTE | FAILURE_ROUTE }, {"ts_append", (cmd_function)w_ts_append, 2,
fixup_ts_append, REQUEST_ROUTE | FAILURE_ROUTE },
fixup_ts_append, 0, REQUEST_ROUTE | FAILURE_ROUTE }, {"ts_store", (cmd_function)w_ts_store, 0,
0 , REQUEST_ROUTE | FAILURE_ROUTE },
0 , 0, REQUEST_ROUTE | FAILURE_ROUTE }, {0,0,0,0,0}
};
+static mi_export_t mi_cmds[] = {
{ "ts_dump", mi_tsilo_dump, 0, 0,
0 },
{ "ts_lookup", mi_tsilo_lookup, 0, 0,
0 },
- { 0, 0, 0, 0, 0}
+};
static param_export_t params[]={ {"hash_size", INT_PARAM, &hash_size}, {0,0,0} @@ -80,13 +86,16 @@ static param_export_t params[]={ /** module exports */ struct module_exports exports= { "tsilo",
- DEFAULT_DLFLAGS, cmds,
0, /* RPC methods */ params,
0, /* exported statistics */
- mi_cmds, /* exported MI functions */
- 0,
- 0, mod_init, /* module initialization function */ 0, (destroy_function) destroy, /* destroy function */
0, 0
};
@@ -97,6 +106,13 @@ static int mod_init(void) { unsigned int n;
/* register the MI commands */
if(register_mi_mod(exports.name, mi_cmds)!=0)
- {
LM_ERR("failed to register MI commands\n");
return -1;
- }
/* load the TM API */ if (load_tm_api(&_tmb)!=0) { LM_ERR("can't load TM API\n");
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
On 12 Nov 2014, at 12:55, Ovidiu Sas osas@voipembedded.com wrote:
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.
+1
Some of us worked hard to try to implement all MI commands in RPC in an earlier release. If anything is still missing, please fix it or send an e-mail to the list. We should have more RPC than MI in the coming release.
/O
Regards, Ovidiu Sas
On Nov 12, 2014 5:59 AM, "Federico Cabiddu" federico.cabiddu@gmail.com wrote: Module: sip-router Branch: master Commit: a255911902788bf74a7f4279fce4758b2f2a4613 URL: http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=a2559119...
Author: Federico Cabiddu federico.cabiddu@gmail.com Committer: Federico Cabiddu federico.cabiddu@gmail.com Date: Wed Nov 12 11:52:29 2014 +0100
modules/tsilo: added MI commands
modules/tsilo/Makefile | 5 +++- modules/tsilo/README | 51 +++++++++++++++++++++++++++++-------- modules/tsilo/doc/tsilo_admin.xml | 44 ++++++++++++++++++++++++++------ modules/tsilo/ts_hash.c | 2 +- modules/tsilo/ts_hash.h | 16 ++++++------ modules/tsilo/tsilo.c | 30 ++++++++++++++++----- 6 files changed, 112 insertions(+), 36 deletions(-)
diff --git a/modules/tsilo/Makefile b/modules/tsilo/Makefile index 40b04cb..c179aec 100644 --- a/modules/tsilo/Makefile +++ b/modules/tsilo/Makefile @@ -9,10 +9,13 @@ include ../../Makefile.defs auto_gen= NAME=tsilo.so LIBS= -DEFS+= -DSER_MOD_INTERFACE +DEFS+=-DKAMAILIO_MOD_INTERFACE
ifeq ($(INSTALL_FLAVOUR),kamailio) DEFS+= -DWITH_EVENT_LOCAL_REQUEST endif # INSTALL_FLAVOUR
+SERLIBPATH=../../lib +SER_LIBS+=$(SERLIBPATH)/kmi/kmi
include ../../Makefile.modules diff --git a/modules/tsilo/README b/modules/tsilo/README index 4790ad1..297c435 100644 --- a/modules/tsilo/README +++ b/modules/tsilo/README @@ -10,7 +10,7 @@ Federico Cabiddu
<federico.cabiddu@gmail.com>
- Copyright © 2014 Federico Cabiddu
Copyright © 2014 Federico Cabiddu __________________________________________________________________
Table of Contents
@@ -33,7 +33,10 @@ Federico Cabiddu 4.2. ts_append(domain, ruri) 4.3. ts_append_to(tindex, tlabel, domain)
5. Statistics
5. MI Commands
5.1. ts_dump
5.2. ts_lookup
List of Examples
@@ -62,19 +65,26 @@ Chapter 1. Admin Guide 4.2. ts_append(domain, ruri) 4.3. ts_append_to(tindex, tlabel, domain)
- Statistics
- MI Commands
5.1. ts_dump
5.2. ts_lookup
Overview
This modules provides transaction storage for the Kamailio SIP Server
- Platform. It stores in an internal table transactions for an user and
- add branches to them if new contacts are added.
- Platform. It stores in an internal table transactions for a Request-URI
- (R-URI) and add branches to them later if new contacts for the AOR are
- added.
- For each message, the modules stores "Request-URI" ("R-URI"), URI and
- the internal transaction index and label.
- When the ts_store function is called, the modules stores the current
- transaction R-URI URI, index and label. Two functions (ts_append and
- ts_append_to) provide the ability to add new branches either to a
- specific transaction or to all of the transactions stored for a given
- R-URI.
- When the transaction is destroyed (by the TM module, the transaction is
- removed from the module table.
- When a transaction is destroyed by the TM module, it is removed from
- the module's table too.
- Dependencies
@@ -105,7 +115,7 @@ Chapter 1. Admin Guide must be a power of two, otherwise it will be rounded down to the nearest power of two.
- Default value is "2048".
Default value is “2048”.
Example 1.1. Set hash_size parameter
... @@ -182,4 +192,23 @@ if (is_method("REGISTER")) { } ...
-5. Statistics +5. MI Commands
- 5.1. ts_dump
- 5.2. ts_lookup
+5.1. ts_dump
- Dumps the entire content of the TSILO table
- Parameters:
* brief - (optional, may not be present); if equals to string
“brief”, a brief dump will be done (only RURI, without the
transaction(s) details)
+5.2. ts_lookup
- Dumps the transactions stored for the given RURI
- Parameters:
* ruri - RURI for which we want to show the transactions.
diff --git a/modules/tsilo/doc/tsilo_admin.xml b/modules/tsilo/doc/tsilo_admin.xml index 4c35e69..36180d1 100644 --- a/modules/tsilo/doc/tsilo_admin.xml +++ b/modules/tsilo/doc/tsilo_admin.xml @@ -17,17 +17,15 @@ <title>Overview</title> <para> This modules provides transaction storage for the &kamailioname;. It
stores in an internal table transactions for an user and add branches
to them if new contacts are added.
stores in an internal table transactions for a Request-URI (R-URI) and add branches
to them later if new contacts for the AOR are added. </para> <para>
For each message, the modules stores <quote>Request-URI</quote>
(<quote>R-URI</quote>), &uri; and the internal transaction index
and label.
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. </para> <para>
When the transaction is destroyed (by the <emphasis>TM</emphasis> module,
the transaction is removed from the module table.
When a transaction is destroyed by the <emphasis>TM</emphasis> module,
it is removed from the module's table too. </para> </section> <section>
@@ -201,6 +199,36 @@ if (is_method("REGISTER")) { </section>
<section>
<title>Statistics</title>
<title>MI Commands</title>
<section id="tsilo.mi.ts_dump">
<title>
<function moreinfo="none">ts_dump</function>
</title>
<para>
Dumps the entire content of the TSILO table
</para>
<para>Parameters: </para>
<itemizedlist>
<listitem><para>
<emphasis>brief</emphasis> - (optional, may not be present); if
equals to string <quote>brief</quote>, a brief dump will be
done (only RURI, without the transaction(s) details)
</para></listitem>
</itemizedlist>
</section>
<section id="tsilo.mi.ts_lookup">
<title>
<function moreinfo="none">ts_lookup</function>
</title>
<para>
Dumps the transactions stored for the given RURI
</para>
<para>Parameters: </para>
<itemizedlist>
<listitem><para>
<emphasis>ruri</emphasis> - RURI for which we want to show the transactions.
</para></listitem>
</itemizedlist>
</section> </section>
</chapter> diff --git a/modules/tsilo/ts_hash.c b/modules/tsilo/ts_hash.c index 089f425..6225db6 100644 --- a/modules/tsilo/ts_hash.c +++ b/modules/tsilo/ts_hash.c @@ -162,7 +162,7 @@ void unlock_entry(ts_entry_t *entry) {
void lock_entry_by_ruri(str* ruri) {
unsigned int sl;
unsigned int sl; sl = core_hash(ruri, 0, 0) & (t_table->size-1); ts_lock(t_table, &t_table->entries[sl]);
diff --git a/modules/tsilo/ts_hash.h b/modules/tsilo/ts_hash.h index b895c26..bc7adf1 100644 --- a/modules/tsilo/ts_hash.h +++ b/modules/tsilo/ts_hash.h @@ -26,8 +26,8 @@
- Module: \ref tsilo
*/
-#ifndef _DIALOG_TS_HASH_H_ -#define _DIALOG_TS_HASH_H_ +#ifndef _TS_HASH_H_ +#define _TS_HASH_H_
#include "../../locking.h" #include "../../lib/kmi/mi.h" @@ -64,10 +64,10 @@ typedef struct ts_urecord /*! entries in the main transaction table */ typedef struct ts_entry {
int n; /*!< Number of elements in the collision slot */
int n; /*!< Number of elements in the collision slot */ struct ts_urecord *first; /*!< urecord list */
struct ts_urecord *last; /*!< optimisation, end of the urecord list */
unsigned int next_id; /*!< next id */
struct ts_urecord *last; /*!< optimisation, end of the urecord list */
unsigned int next_id; /*!< next id */ unsigned int lock_idx; /*!< lock index */
} ts_entry_t;
@@ -75,13 +75,13 @@ typedef struct ts_entry /*! main transaction table */ typedef struct ts_table {
unsigned int size; /*!< size of the dialog table */
unsigned int size; /*!< size of the tsilo table */ struct ts_entry *entries; /*!< urecord hash table */ unsigned int locks_no; /*!< number of locks */
gen_lock_set_t *locks; /*!< lock table */
gen_lock_set_t *locks; /*!< lock table */
} ts_table_t;
-/*! global dialog table */ +/*! global transactions table */ extern ts_table_t *t_table;
/*! diff --git a/modules/tsilo/tsilo.c b/modules/tsilo/tsilo.c index 90eb292..9c404dd 100644 --- a/modules/tsilo/tsilo.c +++ b/modules/tsilo/tsilo.c @@ -32,11 +32,13 @@ #include "../../modules/tm/tm_load.h" #include "../../modules/registrar/api.h" #include "../../dset.h" +#include "../../lib/kmi/mi.h"
#include "ts_hash.h" #include "ts_handlers.h" #include "ts_append.h" #include "ts_store.h" +#include "ts_mi.h"
MODULE_VERSION
@@ -57,20 +59,24 @@ static int w_ts_append_to(struct sip_msg* msg, char *idx, char *lbl, char *d); static int fixup_ts_append_to(void** param, int param_no); static int w_ts_append(struct sip_msg* _msg, char *_table, char *_ruri); static int fixup_ts_append(void** param, int param_no);
static int w_ts_store(struct sip_msg* msg);
static cmd_export_t cmds[]={ {"ts_append_to", (cmd_function)w_ts_append_to, 3,
fixup_ts_append_to, REQUEST_ROUTE | FAILURE_ROUTE },
fixup_ts_append_to, 0, REQUEST_ROUTE | FAILURE_ROUTE }, {"ts_append", (cmd_function)w_ts_append, 2,
fixup_ts_append, REQUEST_ROUTE | FAILURE_ROUTE },
fixup_ts_append, 0, REQUEST_ROUTE | FAILURE_ROUTE }, {"ts_store", (cmd_function)w_ts_store, 0,
0 , REQUEST_ROUTE | FAILURE_ROUTE },
0 , 0, REQUEST_ROUTE | FAILURE_ROUTE }, {0,0,0,0,0}
};
+static mi_export_t mi_cmds[] = {
{ "ts_dump", mi_tsilo_dump, 0, 0, 0 },
{ "ts_lookup", mi_tsilo_lookup, 0, 0, 0 },
- { 0, 0, 0, 0, 0}
+};
static param_export_t params[]={ {"hash_size", INT_PARAM, &hash_size}, {0,0,0} @@ -80,13 +86,16 @@ static param_export_t params[]={ /** module exports */ struct module_exports exports= { "tsilo",
- DEFAULT_DLFLAGS, cmds,
0, /* RPC methods */ params,
0, /* exported statistics */
- mi_cmds, /* exported MI functions */
- 0,
- 0, mod_init, /* module initialization function */ 0, (destroy_function) destroy, /* destroy function */
0, 0
};
@@ -97,6 +106,13 @@ static int mod_init(void) { unsigned int n;
/* register the MI commands */
if(register_mi_mod(exports.name, mi_cmds)!=0)
- {
LM_ERR("failed to register MI commands\n");
return -1;
- }
/* load the TM API */ if (load_tm_api(&_tmb)!=0) { LM_ERR("can't load TM API\n");
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
sr-dev mailing list sr-dev@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev
Olle E. Johansson writes:
Some of us worked hard to try to implement all MI commands in RPC in an earlier release. If anything is still missing, please fix it or send an e-mail to the list. We should have more RPC than MI in the coming release.
Olle,
I recently made backwards incompatible modification to pua_publish mi command. Before doing that I tried to implement corresponding rpc command. However, pua_publish is an asynchronous MI command and I did not find any documentation nor a corresponding example on how to write asynchronous rpc command. So in my case, it was lack of api documentation that prevented me implementing the rpc command.
-- Juha
On 13/11/14 02:44, Juha Heinanen wrote:
Olle E. Johansson writes:
Some of us worked hard to try to implement all MI commands in RPC in an earlier release. If anything is still missing, please fix it or send an e-mail to the list. We should have more RPC than MI in the coming release.
Olle,
I recently made backwards incompatible modification to pua_publish mi command. Before doing that I tried to implement corresponding rpc command. However, pua_publish is an asynchronous MI command and I did not find any documentation nor a corresponding example on how to write asynchronous rpc command. So in my case, it was lack of api documentation that prevented me implementing the rpc command.
Check rpc_t_uac_wait() implementation in tm/rpc_uac.c -- it seems to be what you are looking for as an example. Cheers, Daniel
Daniel-Constantin Mierla writes:
Check rpc_t_uac_wait() implementation in tm/rpc_uac.c -- it seems to be what you are looking for as an example.
beats me. far too complex stuff without any documentation.
-- juha
void rpc_publish(rpc_t* rpc, void* c) { str pres_uri, expires, event, content_type, id, etag, outbound_proxy, extra_headers, body; rpc_delayed_ctx_t* dctx; int exp, sign, ret, err_ret;
body.s = 0; body.len = 0; dctx = 0;
LM_DBG("rpc_publish ...\n");
if ((rpc->capabilities == 0) || !(rpc->capabilities(c) & RPC_DELAYED_REPLY)) { rpc->fault(c, 600, "Reply wait/async mode not supported" " by this rpc transport"); return; }
ret = rpc->scan(c, "SSSSSSSS*S", &pres_uri, &expires, &event, &content_type, &id, &etag, outbound_proxy, &extra_headers, &body); if (ret < 8 && !(-ret == 8)){ rpc->fault(c, 400, "too few parameters (%d/5)", ret?ret:-ret); return; }
if (parse_uri(pres_uri.s, pres_uri.len, &uri) <0) { LM_ERR("bad resentity uri\n"); rpc->fault(c, 400, "Invalid presentity uri '%s'", pres_ruri.s); return; } LM_DBG("presentity uri '%.*s'\n", pres_uri.len, pres_uri.s);
if (expires.s[0]== '-') { sign= -1; expires.s++; expires.len--; } else { sign = 1; } if (str2int(&expires, (unsigned int*)&exp) < 0) { LM_ERR("invalid expires parameter\n" ); rpc->fault(c, 400, "Invalid expires '%s'", expires.s); return; } exp= exp * sign; LM_DBG("expires '%d'\n", exp);
LM_DBG("event '%.*s'\n", event.len, event.s);
LM_DBG("content type '%.*s'\n", content_type.len, content_type.s);
LM_DBG("id '%.*s'\n", id.len, id.s);
LM_DBG("ETag '%.*s'\n", etag.len, etag.s);
LM_DBG("outbound_proxy '%.*s'\n", outbound_proxy.len, outbound_proxy.s);
LM_DBG("extra headers '%.*s'\n", extra_headers.len, extra_headers.s);
if (body.len > 0) LM_DBG("body '%.*s'\n", body.len, body.s);
if ((body.s == 0) && (content_type.len != 1 || content_type.s[0] != '.')) { LM_ERR("body is missing, but content type is not .\n"); rpc->fault(c, 400, "Body is missing"); return; }
memset(&publ, 0, sizeof(publ_info_t)); publ.pres_uri= &pres_uri;
publ.expires= exp;
publ.event= get_event_flag(&event); if (publ.event < 0) { LM_ERR("unknown event '%.*s'\n", event.len, event.s); rpc->fault(c, 400, "Unknown event"); return; }
if (content_type.len != 1) { publ.content_type= content_type; }
if (!((id.len == 1) && (id.s[0]== '.'))) { publ.id= id; }
if (!((etag.len== 1) && (etag.s[0]== '.'))) { publ.etag= &etag; }
if (!((outbound_proxy.len == 1) && (outbound_proxy.s[0] == '.'))) { publ.outbound_proxy = &outbound_proxy; }
if (!((extra_headers.len == 1) && (extra_headers.s[0] == '.'))) { publ.extra_headers = &extra_headers; }
if (body.s != 0) { publ.body= &body; }
LM_DBG("send publish\n");
/* do some magic to call pua_send_publish(&publ) asynchronously */
}
Daniel-Constantin Mierla writes:
Check rpc_t_uac_wait() implementation in tm/rpc_uac.c -- it seems to be what you are looking for as an example.
it appears that this example does not support async mode:
* Note: this version will wait for the transaction final reply * only if reply_wait is set to 1. Otherwise the rpc reply will be sent * immediately and it will be success if the paremters were ok and t_uac did * not report any error. * Note: reply waiting (reply_wait==1) is not yet supported.
and
if (reply_wait && (rpc->capabilities == 0 || !(rpc->capabilities(c) & RPC_DELAYED_REPLY))) { rpc->fault(c, 600, "Reply wait/async mode not supported" " by this rpc transport"
-- juha