Module: sip-router
Branch: master
Commit: d1930021c4c72ab8876c734ed634fe97d858abf4
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=d193002…
Author: Henning Westerholt <henning.westerholt(a)1und1.de>
Committer: Henning Westerholt <henning.westerholt(a)1und1.de>
Date: Tue Mar 3 12:56:29 2009 +0100
integrate sip-router compatiblity patches from Jan Janak
- define OPENSER_MOD_INTERFACE in Makefile
- link with shared libraries libtrie, libsrdb1, and libkmi
- fix paths to dtrie.h and mi.h header files
- various fixes to make the module compatible with libsrdb1
- rename sval and ival attributes in gparam structure
- use sip-router style of calling do_action
- link with libkcore
- include lib/kcore/km_crc.h which contains crc32_uint
---
modules/carrierroute/Makefile | 5 +++++
modules/carrierroute/cr_db.c | 12 ++++++------
modules/carrierroute/cr_db.h | 2 +-
modules/carrierroute/cr_domain.h | 2 +-
modules/carrierroute/cr_fifo.h | 2 +-
modules/carrierroute/cr_fixup.c | 12 ++++++------
modules/carrierroute/cr_func.c | 13 +++++++------
modules/carrierroute/db_carrierroute.c | 2 +-
modules/carrierroute/db_carrierroute.h | 4 ++--
modules/carrierroute/prime_hash.c | 2 +-
10 files changed, 31 insertions(+), 25 deletions(-)
diff --git a/modules/carrierroute/Makefile b/modules/carrierroute/Makefile
index 9407069..64d364c 100644
--- a/modules/carrierroute/Makefile
+++ b/modules/carrierroute/Makefile
@@ -24,4 +24,9 @@ endif
DEFS+=$(CONFUSEDEFS)
LIBS=$(CONFUSELIBS)
+DEFS+=-DOPENSER_MOD_INTERFACE
+
+SERLIBPATH=../../lib
+SER_LIBS+=$(SERLIBPATH)/trie/trie $(SERLIBPATH)/srdb1/srdb1 $(SERLIBPATH)/kmi/kmi
$(SERLIBPATH)/kcore/kcore
+
include ../../Makefile.modules
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/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;
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..325c20b 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? */
@@ -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");
}
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
},
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>