This patch adds -DOPENSER_MOD_INTERFACE to the modules Makefile, this is needed to make Kamailio modules compile with the sip router core. --- modules/carrierroute/Makefile | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/modules/carrierroute/Makefile b/modules/carrierroute/Makefile index 9407069..3a42485 100644 --- a/modules/carrierroute/Makefile +++ b/modules/carrierroute/Makefile @@ -24,4 +24,6 @@ endif DEFS+=$(CONFUSEDEFS) LIBS=$(CONFUSELIBS)
+DEFS+=-DOPENSER_MOD_INTERFACE + include ../../Makefile.modules
--- modules/carrierroute/Makefile | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/modules/carrierroute/Makefile b/modules/carrierroute/Makefile index 3a42485..44106b3 100644 --- a/modules/carrierroute/Makefile +++ b/modules/carrierroute/Makefile @@ -26,4 +26,7 @@ LIBS=$(CONFUSELIBS)
DEFS+=-DOPENSER_MOD_INTERFACE
+SERLIBPATH=../../lib +SER_LIBS+=$(SERLIBPATH)/trie/trie $(SERLIBPATH)/srdb1/srdb1 $(SERLIBPATH)/kmi/kmi + include ../../Makefile.modules
Both header files are now part of shared libraries under lib directory --- modules/carrierroute/cr_domain.h | 2 +- modules/carrierroute/cr_fifo.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/modules/carrierroute/cr_domain.h b/modules/carrierroute/cr_domain.h index 816a9cb..406af0e 100644 --- a/modules/carrierroute/cr_domain.h +++ b/modules/carrierroute/cr_domain.h @@ -32,7 +32,7 @@
#include "../../str.h" #include "../../flags.h" -#include "../../trie/dtrie.h" +#include "../../lib/trie/dtrie.h"
/** diff --git a/modules/carrierroute/cr_fifo.h b/modules/carrierroute/cr_fifo.h index 9c6d073..2976645 100644 --- a/modules/carrierroute/cr_fifo.h +++ b/modules/carrierroute/cr_fifo.h @@ -30,7 +30,7 @@ #ifndef CR_FIFO_H #define CR_FIFO_H
-#include "../../mi/mi.h" +#include "../../lib/kmi/mi.h"
extern int fifo_err;
List of changes: * Rename db_res_t to db1_res_t * Rename db_con_t to db1_con_t * Rename db field type names DB_* to DB1_* * Update header paths to files in ../../lib/srdb1 --- modules/carrierroute/cr_db.c | 12 ++++++------ modules/carrierroute/cr_db.h | 2 +- modules/carrierroute/db_carrierroute.c | 2 +- modules/carrierroute/db_carrierroute.h | 4 ++-- 4 files changed, 10 insertions(+), 10 deletions(-)
diff --git a/modules/carrierroute/cr_db.c b/modules/carrierroute/cr_db.c index bb4d646..3d967c2 100644 --- a/modules/carrierroute/cr_db.c +++ b/modules/carrierroute/cr_db.c @@ -78,7 +78,7 @@ str * failure_columns[FAILURE_COLUMN_NUM] = {
static int load_carrier_map(struct route_data_t *rd) { - db_res_t * res = NULL; + db1_res_t * res = NULL; int i, count; if(!rd){ LM_ERR("invalid parameter\n"); @@ -134,7 +134,7 @@ static int load_carrier_map(struct route_data_t *rd) {
static int load_domain_map(struct route_data_t *rd) { - db_res_t * res = NULL; + db1_res_t * res = NULL; int i, count; if(!rd){ LM_ERR("invalid parameter\n"); @@ -190,7 +190,7 @@ static int load_domain_map(struct route_data_t *rd) {
int load_user_carrier(str * user, str * domain) { - db_res_t * res; + db1_res_t * res; db_key_t cols[1]; db_key_t keys[2]; db_val_t vals[2]; @@ -205,13 +205,13 @@ int load_user_carrier(str * user, str * domain) {
keys[0] = subscriber_columns[SUBSCRIBER_USERNAME_COL]; op[0] = OP_EQ; - VAL_TYPE(vals) = DB_STR; + VAL_TYPE(vals) = DB1_STR; VAL_NULL(vals) = 0; VAL_STR(vals) = *user;
keys[1] = subscriber_columns[SUBSCRIBER_DOMAIN_COL]; op[1] = OP_EQ; - VAL_TYPE(vals+1) = DB_STR; + VAL_TYPE(vals+1) = DB1_STR; VAL_NULL(vals+1) = 0; VAL_STR(vals+1) = *domain;
@@ -254,7 +254,7 @@ int load_user_carrier(str * user, str * domain) { * */ int load_route_data_db(struct route_data_t * rd) { - db_res_t * res = NULL; + db1_res_t * res = NULL; db_row_t * row = NULL; int i, ret; struct carrier_data_t * tmp_carrier_data; diff --git a/modules/carrierroute/cr_db.h b/modules/carrierroute/cr_db.h index 709babc..097bed7 100644 --- a/modules/carrierroute/cr_db.h +++ b/modules/carrierroute/cr_db.h @@ -30,7 +30,7 @@ #ifndef CR_DB_H #define CR_DB_H
-#include "../../db/db.h" +#include "../../lib/srdb1/db.h" #include "db_carrierroute.h" #include "cr_data.h"
diff --git a/modules/carrierroute/db_carrierroute.c b/modules/carrierroute/db_carrierroute.c index 4d19f35..cfe206f 100644 --- a/modules/carrierroute/db_carrierroute.c +++ b/modules/carrierroute/db_carrierroute.c @@ -23,7 +23,7 @@ /* TODO assign read-write or read-only URI, introduce a parameter in XML */
//extern str carrierroute_db_url; -db_con_t * carrierroute_dbh = NULL; +db1_con_t * carrierroute_dbh = NULL; db_func_t carrierroute_dbf;
str carrierroute_table = str_init("carrierroute"); diff --git a/modules/carrierroute/db_carrierroute.h b/modules/carrierroute/db_carrierroute.h index 3be17de..cebc30e 100644 --- a/modules/carrierroute/db_carrierroute.h +++ b/modules/carrierroute/db_carrierroute.h @@ -22,7 +22,7 @@
/* necessary includes */ -#include "../../db/db.h" +#include "../../lib/srdb1/db.h" #include "../../str.h" #include "../../ut.h"
@@ -32,7 +32,7 @@ /* database variables */
extern str carrierroute_db_url; -extern db_con_t * carrierroute_dbh; +extern db1_con_t * carrierroute_dbh; extern db_func_t carrierroute_dbf;
#define carrierroute_DB_URL { "db_url", STR_PARAM, &carrierroute_db_url.s },
In the sip router core these two attributes have different names: * sval -> str * ival -> i --- modules/carrierroute/cr_fixup.c | 12 ++++++------ modules/carrierroute/cr_func.c | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/modules/carrierroute/cr_fixup.c b/modules/carrierroute/cr_fixup.c index eeda611..f832af4 100644 --- a/modules/carrierroute/cr_fixup.c +++ b/modules/carrierroute/cr_fixup.c @@ -129,12 +129,12 @@ static int carrier_fixup(void ** param) { /* This is a name string, convert to a int */ ((gparam_p)(*param))->type=GPARAM_TYPE_INT; /* get carrier id */ - if ((id = carrier_name_2_id(&((gparam_p)(*param))->v.sval)) < 0) { - LM_ERR("could not find carrier name '%.*s' in map\n", ((gparam_p)(*param))->v.sval.len, ((gparam_p)(*param))->v.sval.s); + if ((id = carrier_name_2_id(&((gparam_p)(*param))->v.str)) < 0) { + LM_ERR("could not find carrier name '%.*s' in map\n", ((gparam_p)(*param))->v.str.len, ((gparam_p)(*param))->v.str.s); pkg_free(*param); return -1; } - ((gparam_p)(*param))->v.ival = id; + ((gparam_p)(*param))->v.i = id; } return 0; } @@ -160,12 +160,12 @@ static int domain_fixup(void ** param) { /* This is a name string, convert to a int */ ((gparam_p)(*param))->type=GPARAM_TYPE_INT; /* get domain id */ - if ((id = domain_name_2_id(&(((gparam_p)(*param))->v.sval))) < 0) { - LM_ERR("could not find domain name '%.*s' in map\n", ((gparam_p)(*param))->v.sval.len, ((gparam_p)(*param))->v.sval.s); + if ((id = domain_name_2_id(&(((gparam_p)(*param))->v.str))) < 0) { + LM_ERR("could not find domain name '%.*s' in map\n", ((gparam_p)(*param))->v.str.len, ((gparam_p)(*param))->v.str.s); pkg_free(*param); return -1; } - ((gparam_p)(*param))->v.ival = id; + ((gparam_p)(*param))->v.i = id; } return 0; } diff --git a/modules/carrierroute/cr_func.c b/modules/carrierroute/cr_func.c index d6406c9..451e2cc 100644 --- a/modules/carrierroute/cr_func.c +++ b/modules/carrierroute/cr_func.c @@ -80,7 +80,7 @@ static inline int cr_gp2id(struct sip_msg *_msg, gparam_t *gp, struct name_map_t
switch (gp->type) { case GPARAM_TYPE_INT: - return gp->v.ival; + return gp->v.i; break; case GPARAM_TYPE_PVE: /* does this PV hold an AVP? */
Before calling do_action function from the sip router core, one has to first create and initialize a context variable of type run_act_ctx. Pointer to this variable is then passed as the first parameter to do_action.
Also, it is safer to zero the whole 'action' structure using a memset than setting all its attributes explicitly, you never know when somebody adds a new attribute to the structure and then it might be used unitialized.
Finally, attribute 'elem' in 'action' structure was renamed to 'val in ser. --- modules/carrierroute/cr_func.c | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/modules/carrierroute/cr_func.c b/modules/carrierroute/cr_func.c index 451e2cc..325c20b 100644 --- a/modules/carrierroute/cr_func.c +++ b/modules/carrierroute/cr_func.c @@ -496,6 +496,7 @@ int cr_do_route(struct sip_msg * _msg, gparam_t *_carrier, struct carrier_data_t * carrier_data; struct domain_data_t * domain_data; struct action act; + struct run_act_ctx ra_ctx;
if (fixup_get_svalue(_msg, _rewrite_user, &rewrite_user)<0) { LM_ERR("cannot print the rewrite_user\n"); @@ -565,12 +566,12 @@ int cr_do_route(struct sip_msg * _msg, gparam_t *_carrier,
LM_INFO("uri %.*s was rewritten to %.*s, carrier %d, domain %d\n", rewrite_user.len, rewrite_user.s, dest.len, dest.s, carrier_id, domain_id);
+ memset(&act, 0, sizeof(act)); act.type = SET_URI_T; - act.elem[0].type= STRING_ST; - act.elem[0].u.string = dest.s; - act.next = NULL; - - ret = do_action(&act, _msg); + act.val[0].type = STRING_ST; + act.val[0].u.string = dest.s; + init_run_actions_ctx(&ra_ctx); + ret = do_action(&ra_ctx, &act, _msg); if (ret < 0) { LM_ERR("Error in do_action()\n"); }
The carrierroute module needs crc32_uint function which is missing in the sip router core, the function is present in libkcore --- modules/carrierroute/Makefile | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/modules/carrierroute/Makefile b/modules/carrierroute/Makefile index 44106b3..64d364c 100644 --- a/modules/carrierroute/Makefile +++ b/modules/carrierroute/Makefile @@ -27,6 +27,6 @@ LIBS=$(CONFUSELIBS) DEFS+=-DOPENSER_MOD_INTERFACE
SERLIBPATH=../../lib -SER_LIBS+=$(SERLIBPATH)/trie/trie $(SERLIBPATH)/srdb1/srdb1 $(SERLIBPATH)/kmi/kmi +SER_LIBS+=$(SERLIBPATH)/trie/trie $(SERLIBPATH)/srdb1/srdb1 $(SERLIBPATH)/kmi/kmi $(SERLIBPATH)/kcore/kcore
include ../../Makefile.modules
--- modules/carrierroute/prime_hash.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/modules/carrierroute/prime_hash.c b/modules/carrierroute/prime_hash.c index 7a3400e..8bb9579 100644 --- a/modules/carrierroute/prime_hash.c +++ b/modules/carrierroute/prime_hash.c @@ -31,7 +31,7 @@ #include "../../parser/parse_uri.h" #include "../../parser/parse_to.h" #include "../../parser/parse_from.h" -#include "../../crc.h" +#include "../../lib/kcore/km_crc.h"
#include <ctype.h>
On Tuesday 03 March 2009, Jan Janak wrote:
This patch adds -DOPENSER_MOD_INTERFACE to the modules Makefile, this is needed to make Kamailio modules compile with the sip router core.
Hi Jan,
thank you for the patches, i've commited them to master. The only remaining error (after /lib/kcore/km_crc was merged) is some incompatiblity with the LM_GEN1 macro from dprint.h.
Cheers,
Henning
On 03-03 13:01, Henning Westerholt wrote:
On Tuesday 03 March 2009, Jan Janak wrote:
This patch adds -DOPENSER_MOD_INTERFACE to the modules Makefile, this is needed to make Kamailio modules compile with the sip router core.
Hi Jan,
thank you for the patches, i've commited them to master. The only remaining error (after /lib/kcore/km_crc was merged) is some incompatiblity with the LM_GEN1 macro from dprint.h.
Yes, we don't have logging macros with support for va_list style arguments. One possible solution is to print the whole string using vsnprintf before passing it to LOG or LM_LOG1. Another one is adding support for such parameters to the macros in dprint.h. I don't know yet which one is simpler.
Jan.
On Mar 03, 2009 at 13:01, Henning Westerholt henning.westerholt@1und1.de wrote:
On Tuesday 03 March 2009, Jan Janak wrote:
This patch adds -DOPENSER_MOD_INTERFACE to the modules Makefile, this is needed to make Kamailio modules compile with the sip router core.
Hi Jan,
thank you for the patches, i've commited them to master. The only remaining error (after /lib/kcore/km_crc was merged) is some incompatiblity with the LM_GEN1 macro from dprint.h.
Just for future reference:
Patch series like Jan sent, can be very easily applied with git am. So instead of applying them by hand you could save them into a separate mailbox (e.g. jan_patches_1) and then run git am on that mailbox, e.g.: git am -s ~/jan_patches_1 This would apply all the patches saved in the mailbox and will use the mail body as commit message.
-s is optional, it adds a Signed-off-by: commiter name to the commit message.
Also patches like Jan sent are created using git format-patch. You basically give it a commit range and it would generate mail-ready patches.
Andrei
On 03-03 13:51, Andrei Pelinescu-Onciul wrote:
On Mar 03, 2009 at 13:01, Henning Westerholt henning.westerholt@1und1.de wrote:
On Tuesday 03 March 2009, Jan Janak wrote:
This patch adds -DOPENSER_MOD_INTERFACE to the modules Makefile, this is needed to make Kamailio modules compile with the sip router core.
Hi Jan,
thank you for the patches, i've commited them to master. The only remaining error (after /lib/kcore/km_crc was merged) is some incompatiblity with the LM_GEN1 macro from dprint.h.
Just for future reference:
Patch series like Jan sent, can be very easily applied with git am. So instead of applying them by hand you could save them into a separate mailbox (e.g. jan_patches_1) and then run git am on that mailbox, e.g.: git am -s ~/jan_patches_1 This would apply all the patches saved in the mailbox and will use the mail body as commit message.
-s is optional, it adds a Signed-off-by: commiter name to the commit message.
Also patches like Jan sent are created using git format-patch. You basically give it a commit range and it would generate mail-ready patches.
Yes, also I keep those commits in a local repository which I intend to publish somehow somewhere soon. Then you could merge changes from the repository easily. The main reason why I was sending the patches was to get some review by people who know the code better than myself.
Jan.
On Tuesday 03 March 2009, Jan Janak wrote:
Patch series like Jan sent, can be very easily applied with git am. So instead of applying them by hand you could save them into a separate mailbox (e.g. jan_patches_1) and then run git am on that mailbox, e.g.: git am -s ~/jan_patches_1 This would apply all the patches saved in the mailbox and will use the mail body as commit message.
-s is optional, it adds a Signed-off-by: commiter name to the commit message.
Also patches like Jan sent are created using git format-patch. You basically give it a commit range and it would generate mail-ready patches.
Yes, also I keep those commits in a local repository which I intend to publish somehow somewhere soon. Then you could merge changes from the repository easily. The main reason why I was sending the patches was to get some review by people who know the code better than myself.
Hi Jan, hi Andrei,
i supposed that there is something like this. But i still need to learn a lot about git before i feel really comfortable in using it, so i choose the "manual" way. Next time i'll try the git-am command.
Thanks,
Henning
On 03-03 13:01, Henning Westerholt wrote:
On Tuesday 03 March 2009, Jan Janak wrote:
This patch adds -DOPENSER_MOD_INTERFACE to the modules Makefile, this is needed to make Kamailio modules compile with the sip router core.
Hi Jan,
thank you for the patches, i've commited them to master. The only remaining error (after /lib/kcore/km_crc was merged) is some incompatiblity with the LM_GEN1 macro from dprint.h.
Henning,
any preferences on how to fix this? Carrierroute module in the sip-router master branch currently does not compile.
Jan.
On Tuesday 17 March 2009, Jan Janak wrote:
thank you for the patches, i've commited them to master. The only remaining error (after /lib/kcore/km_crc was merged) is some incompatiblity with the LM_GEN1 macro from dprint.h.
Henning,
any preferences on how to fix this? Carrierroute module in the sip-router master branch currently does not compile.
Hi Jan,
cr seems to be the only module that use LM_GEN1 with variable argument list, so probably it make sense to fix it in the module. Patch attached, as my sr tree behaves strange at the moment. It shows dozens of files as new, which i don't modified.
Cheers,
Henning
On 17-03 12:29, Henning Westerholt wrote:
Henning,
any preferences on how to fix this? Carrierroute module in the sip-router master branch currently does not compile.
Hi Jan,
cr seems to be the only module that use LM_GEN1 with variable argument list, so probably it make sense to fix it in the module. Patch attached, as my sr tree behaves strange at the moment. It shows dozens of files as new, which i don't modified.
Cheers,
Henning
diff --git a/modules/carrierroute/cr_config.c b/modules/carrierroute/cr_config.c index 48975a5..f8e587e 100644 --- a/modules/carrierroute/cr_config.c +++ b/modules/carrierroute/cr_config.c @@ -50,8 +50,15 @@
- @param ap format arguments
*/ static void conf_error(cfg_t *cfg, const char * fmt, va_list ap) {
- // FIXME this don't seems to work reliable, produces strange error messages
- LM_GEN1(L_ERR, (char *) fmt, ap);
- char buf[1024];
- if (vsnprintf(buf, sizeof(buf), fmt, ap) < 0) {
See again: http://lists.kamailio.org/pipermail/devel/2009-March/018219.html
The same applies to vsnprintf.
Jan.
On 17-03 12:29, Henning Westerholt wrote:
On Tuesday 17 March 2009, Jan Janak wrote:
thank you for the patches, i've commited them to master. The only remaining error (after /lib/kcore/km_crc was merged) is some incompatiblity with the LM_GEN1 macro from dprint.h.
Henning,
any preferences on how to fix this? Carrierroute module in the sip-router master branch currently does not compile.
Hi Jan,
cr seems to be the only module that use LM_GEN1 with variable argument list, so probably it make sense to fix it in the module. Patch attached, as my sr tree behaves strange at the moment. It shows dozens of files as new, which i don't modified.
Cheers,
Henning
diff --git a/modules/carrierroute/cr_config.c b/modules/carrierroute/cr_config.c index 48975a5..f8e587e 100644 --- a/modules/carrierroute/cr_config.c +++ b/modules/carrierroute/cr_config.c @@ -50,8 +50,15 @@
- @param ap format arguments
*/ static void conf_error(cfg_t *cfg, const char * fmt, va_list ap) {
- // FIXME this don't seems to work reliable, produces strange error messages
- LM_GEN1(L_ERR, (char *) fmt, ap);
- char buf[1024];
- if (vsnprintf(buf, sizeof(buf), fmt, ap) < 0) {
LM_ERR("could not print error message\n");
- } else {
// FIXME this don't seems to work reliable in all cases, charset problems
LM_GEN1(L_ERR, "%s", buf);
- }
- va_end(ap);
The function which calls the error handler in libconfuse already calls va_end when the handler finishes, so either you should call va_start at the beginning of this function or you should remove va_end from this function. See confuse.c, search for cfg_error function.
Jan.
On Tuesday 17 March 2009, Jan Janak wrote:
[patch] The function which calls the error handler in libconfuse already calls va_end when the handler finishes, so either you should call va_start at the beginning of this function or you should remove va_end from this function. See confuse.c, search for cfg_error function.
Hi Jan,
thanks for the pointer, i saw you already fixed this in the sr tree.
Cheers,
Henning