Module: sip-router
Branch: rbetancor/drouting
Commit: 4f3dbdd89505497b78ce7ce005f2e3a41923955e
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=4f3dbdd…
Author: Raul Alexis Betancor Santana <rabs(a)dimension-virtual.com>
Committer: Raul Alexis Betancor Santana <rabs(a)dimension-virtual.com>
Date: Thu Jul 2 15:53:08 2009 +0100
drouting:
- changed db support to db1_k calls
---
modules_k/drouting/dr_load.c | 36 ++++++++++++++++++------------------
modules_k/drouting/dr_load.h | 4 ++--
modules_k/drouting/drouting.c | 32 ++++++++++++++++++++++++++------
3 files changed, 46 insertions(+), 26 deletions(-)
diff --git a/modules_k/drouting/dr_load.c b/modules_k/drouting/dr_load.c
index 80f7f43..3d833d9 100644
--- a/modules_k/drouting/dr_load.c
+++ b/modules_k/drouting/dr_load.c
@@ -34,7 +34,7 @@
#include "../../dprint.h"
-#include "../../db/db.h"
+//#include "../../db/db.h"
#include "../../mem/shm_mem.h"
#include "dr_load.h"
@@ -276,14 +276,14 @@ error:
}
-rt_data_t* dr_load_routing_info( db_func_t *dr_dbf, db_con_t* db_hdl,
+rt_data_t* dr_load_routing_info( db_func_t *dr_dbf, db1_con_t* db_hdl,
str *drd_table, str *drl_table, str* drr_table )
{
int int_vals[4];
char * str_vals[4];
str tmp;
db_key_t columns[7];
- db_res_t* res;
+ db1_res_t* res;
db_row_t* row;
rt_info_t *ri;
rt_data_t *rdata;
@@ -341,22 +341,22 @@ rt_data_t* dr_load_routing_info( db_func_t *dr_dbf, db_con_t*
db_hdl,
for(i=0; i < RES_ROW_N(res); i++) {
row = RES_ROWS(res) + i;
/* DST_ID column */
- check_val( ROW_VALUES(row), DB_INT, 1, 0);
+ check_val( ROW_VALUES(row), DB1_INT, 1, 0);
int_vals[0] = VAL_INT (ROW_VALUES(row));
/* ADDRESS column */
- check_val( ROW_VALUES(row)+1, DB_STRING, 1, 1);
+ check_val( ROW_VALUES(row)+1, DB1_STRING, 1, 1);
str_vals[0] = (char*)VAL_STRING(ROW_VALUES(row)+1);
/* STRIP column */
- check_val( ROW_VALUES(row)+2, DB_INT, 1, 0);
+ check_val( ROW_VALUES(row)+2, DB1_INT, 1, 0);
int_vals[1] = VAL_INT (ROW_VALUES(row)+2);
/* PREFIX column */
- check_val( ROW_VALUES(row)+3, DB_STRING, 0, 0);
+ check_val( ROW_VALUES(row)+3, DB1_STRING, 0, 0);
str_vals[1] = (char*)VAL_STRING(ROW_VALUES(row)+3);
/* TYPE column */
- check_val( ROW_VALUES(row)+4, DB_INT, 1, 0);
+ check_val( ROW_VALUES(row)+4, DB1_INT, 1, 0);
int_vals[2] = VAL_INT(ROW_VALUES(row)+4);
/* ATTRS column */
- check_val( ROW_VALUES(row)+5, DB_STRING, 0, 0);
+ check_val( ROW_VALUES(row)+5, DB1_STRING, 0, 0);
str_vals[2] = (char*)VAL_STRING(ROW_VALUES(row)+5);
/* add the destinaton definition in */
@@ -421,10 +421,10 @@ rt_data_t* dr_load_routing_info( db_func_t *dr_dbf, db_con_t*
db_hdl,
for(i=0; i < RES_ROW_N(res); i++) {
row = RES_ROWS(res) + i;
/* ID column */
- check_val( ROW_VALUES(row), DB_INT, 1, 0);
+ check_val( ROW_VALUES(row), DB1_INT, 1, 0);
int_vals[0] = VAL_INT (ROW_VALUES(row));
/* GWLIST column */
- check_val( ROW_VALUES(row)+1, DB_STRING, 1, 1);
+ check_val( ROW_VALUES(row)+1, DB1_STRING, 1, 1);
str_vals[0] = (char*)VAL_STRING(ROW_VALUES(row)+1);
if (add_tmp_gw_list(int_vals[0], str_vals[0])!=0) {
@@ -487,13 +487,13 @@ rt_data_t* dr_load_routing_info( db_func_t *dr_dbf, db_con_t*
db_hdl,
for(i=0; i < RES_ROW_N(res); i++) {
row = RES_ROWS(res) + i;
/* RULE_ID column */
- check_val( ROW_VALUES(row), DB_INT, 1, 0);
+ check_val( ROW_VALUES(row), DB1_INT, 1, 0);
int_vals[0] = VAL_INT (ROW_VALUES(row));
/* GROUP column */
- check_val( ROW_VALUES(row)+1, DB_STRING, 1, 1);
+ check_val( ROW_VALUES(row)+1, DB1_STRING, 1, 1);
str_vals[0] = (char*)VAL_STRING(ROW_VALUES(row)+1);
/* PREFIX column - it may be null or empty */
- check_val( ROW_VALUES(row)+2, DB_STRING, 0, 0);
+ check_val( ROW_VALUES(row)+2, DB1_STRING, 0, 0);
if ((ROW_VALUES(row)+2)->nul || VAL_STRING(ROW_VALUES(row)+2)==0){
tmp.s = NULL;
tmp.len = 0;
@@ -503,16 +503,16 @@ rt_data_t* dr_load_routing_info( db_func_t *dr_dbf, db_con_t*
db_hdl,
tmp.len = strlen(str_vals[1]);
}
/* TIME column */
- check_val( ROW_VALUES(row)+3, DB_STRING, 1, 1);
+ check_val( ROW_VALUES(row)+3, DB1_STRING, 1, 1);
str_vals[2] = (char*)VAL_STRING(ROW_VALUES(row)+3);
/* PRIORITY column */
- check_val( ROW_VALUES(row)+4, DB_INT, 1, 0);
+ check_val( ROW_VALUES(row)+4, DB1_INT, 1, 0);
int_vals[2] = VAL_INT (ROW_VALUES(row)+4);
/* ROUTE_ID column */
- check_val( ROW_VALUES(row)+5, DB_INT, 1, 0);
+ check_val( ROW_VALUES(row)+5, DB1_INT, 1, 0);
int_vals[3] = VAL_INT (ROW_VALUES(row)+5);
/* DSTLIST column */
- check_val( ROW_VALUES(row)+6, DB_STRING, 1, 1);
+ check_val( ROW_VALUES(row)+6, DB1_STRING, 1, 1);
str_vals[3] = (char*)VAL_STRING(ROW_VALUES(row)+6);
/* parse the time definition */
if ((time_rec=parse_time_def(str_vals[2]))==0) {
diff --git a/modules_k/drouting/dr_load.h b/modules_k/drouting/dr_load.h
index 5345d47..b0357f8 100644
--- a/modules_k/drouting/dr_load.h
+++ b/modules_k/drouting/dr_load.h
@@ -30,10 +30,10 @@
#define _DR_LOAD_
#include "../../str.h"
-#include "../../db/db.h"
+#include "../../lib/srdb1/db.h"
#include "routing.h"
-rt_data_t* dr_load_routing_info( db_func_t *dr_dbf, db_con_t* db_hdl,
+rt_data_t* dr_load_routing_info( db_func_t *dr_dbf, db1_con_t* db_hdl,
str *drd_table, str *drl_table, str* str_table);
#endif
diff --git a/modules_k/drouting/drouting.c b/modules_k/drouting/drouting.c
index 3e69836..6c76f21 100644
--- a/modules_k/drouting/drouting.c
+++ b/modules_k/drouting/drouting.c
@@ -76,7 +76,7 @@ static str drg_user_col = str_init("username");
static str drg_domain_col = str_init("domain");
static str drg_grpid_col = str_init("groupid");
/* variables */
-static db_con_t *db_hdl=0; /* DB handler */
+static db1_con_t *db_hdl=0; /* DB handler */
static db_func_t dr_dbf; /* DB functions */
/* current dr data - pointer to a pointer in shm */
@@ -205,6 +205,26 @@ struct module_exports exports = {
};
+/**
+ * Rewrite Request-URI
+ */
+static inline int rewrite_ruri(struct sip_msg* _m, char* _s)
+{
+ struct action act;
+ struct run_act_ctx ra_ctx;
+
+ memset(&act, '\0', sizeof(act));
+ act.type = SET_URI_T;
+ act.val[0].type = STRING_ST;
+ act.val[0].u.string = _s;
+ init_run_actions_ctx(&ra_ctx);
+ if (do_action(&ra_ctx, &act, _m) < 0)
+ {
+ LM_ERR("do_action failed\n");
+ return -1;
+ }
+ return 0;
+}
static inline int dr_reload_data( void )
{
@@ -478,20 +498,20 @@ static inline int get_group_id(struct sip_uri *uri)
db_key_t keys_ret[1];
db_key_t keys_cmp[2];
db_val_t vals_cmp[2];
- db_res_t* res;
+ db1_res_t* res;
int n;
/* user */
keys_cmp[0] = &drg_user_col;
- vals_cmp[0].type = DB_STR;
+ vals_cmp[0].type = DB1_STR;
vals_cmp[0].nul = 0;
vals_cmp[0].val.str_val = uri->user;
n = 1;
if (use_domain) {
keys_cmp[1] = &drg_domain_col;
- vals_cmp[1].type = DB_STR;
+ vals_cmp[1].type = DB1_STR;
vals_cmp[1].nul = 0;
vals_cmp[1].val.str_val = uri->host;
n++;
@@ -511,7 +531,7 @@ static inline int get_group_id(struct sip_uri *uri)
uri->host.len, uri->host.s);
goto error;
}
- if (res->rows[0].values[0].nul || res->rows[0].values[0].type!=DB_INT) {
+ if (res->rows[0].values[0].nul || res->rows[0].values[0].type!=DB1_INT) {
LM_ERR("null or non-integer group_id\n");
goto error;
}
@@ -612,7 +632,7 @@ static int use_next_gw(struct sip_msg* msg)
if (!avp) return -1;
- if (set_ruri( msg, &val.s)==-1) {
+ if (rewrite_ruri(msg, &val.s.s)==-1) {
LM_ERR("failed to rewite RURI\n");
return -1;
}