|
@@ -41,12 +41,12 @@
|
|
#include "parse.h"
|
|
#include "parse.h"
|
|
|
|
|
|
|
|
|
|
-#define DST_ID_DRD_COL "gwid"
|
|
|
|
-#define ADDRESS_DRD_COL "address"
|
|
|
|
-#define STRIP_DRD_COL "strip"
|
|
|
|
-#define PREFIX_DRD_COL "pri_prefix"
|
|
|
|
-#define TYPE_DRD_COL "type"
|
|
|
|
-#define ATTRS_DRD_COL "attrs"
|
|
|
|
|
|
+#define DST_ID_DRD_COL "gwid"
|
|
|
|
+#define ADDRESS_DRD_COL "address"
|
|
|
|
+#define STRIP_DRD_COL "strip"
|
|
|
|
+#define PREFIX_DRD_COL "pri_prefix"
|
|
|
|
+#define TYPE_DRD_COL "type"
|
|
|
|
+#define ATTRS_DRD_COL "attrs"
|
|
static str dst_id_drd_col = str_init(DST_ID_DRD_COL);
|
|
static str dst_id_drd_col = str_init(DST_ID_DRD_COL);
|
|
static str address_drd_col = str_init(ADDRESS_DRD_COL);
|
|
static str address_drd_col = str_init(ADDRESS_DRD_COL);
|
|
static str strip_drd_col = str_init(STRIP_DRD_COL);
|
|
static str strip_drd_col = str_init(STRIP_DRD_COL);
|
|
@@ -54,13 +54,13 @@ static str prefix_drd_col = str_init(PREFIX_DRD_COL);
|
|
static str type_drd_col = str_init(TYPE_DRD_COL);
|
|
static str type_drd_col = str_init(TYPE_DRD_COL);
|
|
static str attrs_drd_col = str_init(ATTRS_DRD_COL);
|
|
static str attrs_drd_col = str_init(ATTRS_DRD_COL);
|
|
|
|
|
|
-#define RULE_ID_DRR_COL "ruleid"
|
|
|
|
-#define GROUP_DRR_COL "groupid"
|
|
|
|
-#define PREFIX_DRR_COL "prefix"
|
|
|
|
-#define TIME_DRR_COL "timerec"
|
|
|
|
-#define PRIORITY_DRR_COL "priority"
|
|
|
|
-#define ROUTEID_DRR_COL "routeid"
|
|
|
|
-#define DSTLIST_DRR_COL "gwlist"
|
|
|
|
|
|
+#define RULE_ID_DRR_COL "ruleid"
|
|
|
|
+#define GROUP_DRR_COL "groupid"
|
|
|
|
+#define PREFIX_DRR_COL "prefix"
|
|
|
|
+#define TIME_DRR_COL "timerec"
|
|
|
|
+#define PRIORITY_DRR_COL "priority"
|
|
|
|
+#define ROUTEID_DRR_COL "routeid"
|
|
|
|
+#define DSTLIST_DRR_COL "gwlist"
|
|
static str rule_id_drr_col = str_init(RULE_ID_DRR_COL);
|
|
static str rule_id_drr_col = str_init(RULE_ID_DRR_COL);
|
|
static str group_drr_col = str_init(GROUP_DRR_COL);
|
|
static str group_drr_col = str_init(GROUP_DRR_COL);
|
|
static str prefix_drr_col = str_init(PREFIX_DRR_COL);
|
|
static str prefix_drr_col = str_init(PREFIX_DRR_COL);
|
|
@@ -69,59 +69,61 @@ static str priority_drr_col = str_init(PRIORITY_DRR_COL);
|
|
static str routeid_drr_col = str_init(ROUTEID_DRR_COL);
|
|
static str routeid_drr_col = str_init(ROUTEID_DRR_COL);
|
|
static str dstlist_drr_col = str_init(DSTLIST_DRR_COL);
|
|
static str dstlist_drr_col = str_init(DSTLIST_DRR_COL);
|
|
|
|
|
|
-#define ID_DRL_COL "id"
|
|
|
|
|
|
+#define ID_DRL_COL "id"
|
|
#define GWLIST_DRL_CAL "gwlist"
|
|
#define GWLIST_DRL_CAL "gwlist"
|
|
static str id_drl_col = str_init(ID_DRL_COL);
|
|
static str id_drl_col = str_init(ID_DRL_COL);
|
|
static str gwlist_drl_col = str_init(GWLIST_DRL_CAL);
|
|
static str gwlist_drl_col = str_init(GWLIST_DRL_CAL);
|
|
|
|
|
|
-struct dr_gwl_tmp {
|
|
|
|
|
|
+struct dr_gwl_tmp
|
|
|
|
+{
|
|
unsigned int id;
|
|
unsigned int id;
|
|
char *gwlist;
|
|
char *gwlist;
|
|
struct dr_gwl_tmp *next;
|
|
struct dr_gwl_tmp *next;
|
|
};
|
|
};
|
|
|
|
|
|
|
|
|
|
-static struct dr_gwl_tmp* dr_gw_lists = NULL;
|
|
|
|
-
|
|
|
|
-#define check_val( _val, _type, _not_null, _is_empty_str) \
|
|
|
|
- do{\
|
|
|
|
- if ((_val)->type!=_type) { \
|
|
|
|
- LM_ERR("bad colum type\n");\
|
|
|
|
- goto error;\
|
|
|
|
- } \
|
|
|
|
- if (_not_null && (_val)->nul) { \
|
|
|
|
- LM_ERR("nul column\n");\
|
|
|
|
- goto error;\
|
|
|
|
- } \
|
|
|
|
- if (_is_empty_str && VAL_STRING(_val)==0) { \
|
|
|
|
- LM_ERR("empty str column\n");\
|
|
|
|
- goto error;\
|
|
|
|
- } \
|
|
|
|
- }while(0)
|
|
|
|
|
|
+static struct dr_gwl_tmp *dr_gw_lists = NULL;
|
|
|
|
+
|
|
|
|
+#define check_val(_val, _type, _not_null, _is_empty_str) \
|
|
|
|
+ do { \
|
|
|
|
+ if((_val)->type != _type) { \
|
|
|
|
+ LM_ERR("bad colum type\n"); \
|
|
|
|
+ goto error; \
|
|
|
|
+ } \
|
|
|
|
+ if(_not_null && (_val)->nul) { \
|
|
|
|
+ LM_ERR("nul column\n"); \
|
|
|
|
+ goto error; \
|
|
|
|
+ } \
|
|
|
|
+ if(_is_empty_str && VAL_STRING(_val) == 0) { \
|
|
|
|
+ LM_ERR("empty str column\n"); \
|
|
|
|
+ goto error; \
|
|
|
|
+ } \
|
|
|
|
+ } while(0)
|
|
|
|
|
|
|
|
|
|
#define TR_SEPARATOR '|'
|
|
#define TR_SEPARATOR '|'
|
|
|
|
|
|
-#define load_TR_value( _p,_s, _tr, _func, _err, _done) \
|
|
|
|
- do{ \
|
|
|
|
- _s = strchr(_p, (int)TR_SEPARATOR); \
|
|
|
|
- if (_s) \
|
|
|
|
- *_s = 0; \
|
|
|
|
- /*DBG("----parsing tr param <%s>\n",_p);*/\
|
|
|
|
- if(_s != _p) {\
|
|
|
|
- if( _func( _tr, _p)) {\
|
|
|
|
- if (_s) *_s = TR_SEPARATOR; \
|
|
|
|
- goto _err; \
|
|
|
|
- } \
|
|
|
|
- } \
|
|
|
|
- if (_s) { \
|
|
|
|
- *_s = TR_SEPARATOR; \
|
|
|
|
- _p = _s+1;\
|
|
|
|
- if ( *(_p)==0 ) \
|
|
|
|
- goto _done; \
|
|
|
|
- } else {\
|
|
|
|
- goto _done; \
|
|
|
|
- }\
|
|
|
|
|
|
+#define load_TR_value(_p, _s, _tr, _func, _err, _done) \
|
|
|
|
+ do { \
|
|
|
|
+ _s = strchr(_p, (int)TR_SEPARATOR); \
|
|
|
|
+ if(_s) \
|
|
|
|
+ *_s = 0; \
|
|
|
|
+ /*DBG("----parsing tr param <%s>\n",_p);*/ \
|
|
|
|
+ if(_s != _p) { \
|
|
|
|
+ if(_func(_tr, _p)) { \
|
|
|
|
+ if(_s) \
|
|
|
|
+ *_s = TR_SEPARATOR; \
|
|
|
|
+ goto _err; \
|
|
|
|
+ } \
|
|
|
|
+ } \
|
|
|
|
+ if(_s) { \
|
|
|
|
+ *_s = TR_SEPARATOR; \
|
|
|
|
+ _p = _s + 1; \
|
|
|
|
+ if(*(_p) == 0) \
|
|
|
|
+ goto _done; \
|
|
|
|
+ } else { \
|
|
|
|
+ goto _done; \
|
|
|
|
+ } \
|
|
} while(0)
|
|
} while(0)
|
|
|
|
|
|
extern int dr_fetch_rows;
|
|
extern int dr_fetch_rows;
|
|
@@ -134,13 +136,13 @@ static int add_tmp_gw_list(unsigned int id, char *list)
|
|
unsigned int list_len;
|
|
unsigned int list_len;
|
|
|
|
|
|
list_len = strlen(list) + 1;
|
|
list_len = strlen(list) + 1;
|
|
- tmp = (struct dr_gwl_tmp*)pkg_malloc(sizeof(struct dr_gwl_tmp) + list_len);
|
|
|
|
- if (tmp==NULL) {
|
|
|
|
|
|
+ tmp = (struct dr_gwl_tmp *)pkg_malloc(sizeof(struct dr_gwl_tmp) + list_len);
|
|
|
|
+ if(tmp == NULL) {
|
|
LM_ERR("no more pkg mem\n");
|
|
LM_ERR("no more pkg mem\n");
|
|
return -1;
|
|
return -1;
|
|
}
|
|
}
|
|
tmp->id = id;
|
|
tmp->id = id;
|
|
- tmp->gwlist = (char*)(tmp+1);
|
|
|
|
|
|
+ tmp->gwlist = (char *)(tmp + 1);
|
|
memcpy(tmp->gwlist, list, list_len);
|
|
memcpy(tmp->gwlist, list, list_len);
|
|
|
|
|
|
tmp->next = dr_gw_lists;
|
|
tmp->next = dr_gw_lists;
|
|
@@ -148,12 +150,13 @@ static int add_tmp_gw_list(unsigned int id, char *list)
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
-static char* get_tmp_gw_list(unsigned int id)
|
|
|
|
|
|
+static char *get_tmp_gw_list(unsigned int id)
|
|
{
|
|
{
|
|
struct dr_gwl_tmp *tmp;
|
|
struct dr_gwl_tmp *tmp;
|
|
|
|
|
|
- for( tmp=dr_gw_lists ; tmp ; tmp=tmp->next )
|
|
|
|
- if (tmp->id == id) return tmp->gwlist;
|
|
|
|
|
|
+ for(tmp = dr_gw_lists; tmp; tmp = tmp->next)
|
|
|
|
+ if(tmp->id == id)
|
|
|
|
+ return tmp->gwlist;
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -161,7 +164,7 @@ static void free_tmp_gw_list(void)
|
|
{
|
|
{
|
|
struct dr_gwl_tmp *tmp, *tmp1;
|
|
struct dr_gwl_tmp *tmp, *tmp1;
|
|
|
|
|
|
- for( tmp=dr_gw_lists ; tmp ; ) {
|
|
|
|
|
|
+ for(tmp = dr_gw_lists; tmp;) {
|
|
tmp1 = tmp;
|
|
tmp1 = tmp;
|
|
tmp = tmp->next;
|
|
tmp = tmp->next;
|
|
pkg_free(tmp1);
|
|
pkg_free(tmp1);
|
|
@@ -170,88 +173,88 @@ static void free_tmp_gw_list(void)
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-static inline tmrec_t* parse_time_def(char *time_str)
|
|
|
|
|
|
+static inline tmrec_t *parse_time_def(char *time_str)
|
|
{
|
|
{
|
|
tmrec_t *time_rec;
|
|
tmrec_t *time_rec;
|
|
- char *p,*s;
|
|
|
|
|
|
+ char *p, *s;
|
|
|
|
|
|
p = time_str;
|
|
p = time_str;
|
|
time_rec = 0;
|
|
time_rec = 0;
|
|
|
|
|
|
- time_rec = (tmrec_t*)shm_malloc(sizeof(tmrec_t));
|
|
|
|
- if (time_rec==0) {
|
|
|
|
|
|
+ time_rec = (tmrec_t *)shm_malloc(sizeof(tmrec_t));
|
|
|
|
+ if(time_rec == 0) {
|
|
LM_ERR("no more pkg mem\n");
|
|
LM_ERR("no more pkg mem\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
- memset( time_rec, 0, sizeof(tmrec_t));
|
|
|
|
|
|
+ memset(time_rec, 0, sizeof(tmrec_t));
|
|
|
|
|
|
/* empty definition? */
|
|
/* empty definition? */
|
|
- if ( time_str==0 || *time_str==0 )
|
|
|
|
|
|
+ if(time_str == 0 || *time_str == 0)
|
|
goto done;
|
|
goto done;
|
|
|
|
|
|
- load_TR_value( p, s, time_rec, tr_parse_dtstart, parse_error, done);
|
|
|
|
- load_TR_value( p, s, time_rec, tr_parse_duration, parse_error, done);
|
|
|
|
- load_TR_value( p, s, time_rec, tr_parse_freq, parse_error, done);
|
|
|
|
- load_TR_value( p, s, time_rec, tr_parse_until, parse_error, done);
|
|
|
|
- load_TR_value( p, s, time_rec, tr_parse_interval, parse_error, done);
|
|
|
|
- load_TR_value( p, s, time_rec, tr_parse_byday, parse_error, done);
|
|
|
|
- load_TR_value( p, s, time_rec, tr_parse_bymday, parse_error, done);
|
|
|
|
- load_TR_value( p, s, time_rec, tr_parse_byyday, parse_error, done);
|
|
|
|
- load_TR_value( p, s, time_rec, tr_parse_byweekno, parse_error, done);
|
|
|
|
- load_TR_value( p, s, time_rec, tr_parse_bymonth, parse_error, done);
|
|
|
|
-
|
|
|
|
- /* success */
|
|
|
|
|
|
+ load_TR_value(p, s, time_rec, tr_parse_dtstart, parse_error, done);
|
|
|
|
+ load_TR_value(p, s, time_rec, tr_parse_duration, parse_error, done);
|
|
|
|
+ load_TR_value(p, s, time_rec, tr_parse_freq, parse_error, done);
|
|
|
|
+ load_TR_value(p, s, time_rec, tr_parse_until, parse_error, done);
|
|
|
|
+ load_TR_value(p, s, time_rec, tr_parse_interval, parse_error, done);
|
|
|
|
+ load_TR_value(p, s, time_rec, tr_parse_byday, parse_error, done);
|
|
|
|
+ load_TR_value(p, s, time_rec, tr_parse_bymday, parse_error, done);
|
|
|
|
+ load_TR_value(p, s, time_rec, tr_parse_byyday, parse_error, done);
|
|
|
|
+ load_TR_value(p, s, time_rec, tr_parse_byweekno, parse_error, done);
|
|
|
|
+ load_TR_value(p, s, time_rec, tr_parse_bymonth, parse_error, done);
|
|
|
|
+
|
|
|
|
+/* success */
|
|
done:
|
|
done:
|
|
return time_rec;
|
|
return time_rec;
|
|
parse_error:
|
|
parse_error:
|
|
- LM_ERR("parse error in <%s> around position %i\n",
|
|
|
|
- time_str, (int)(long)(p-time_str));
|
|
|
|
|
|
+ LM_ERR("parse error in <%s> around position %i\n", time_str,
|
|
|
|
+ (int)(long)(p - time_str));
|
|
error:
|
|
error:
|
|
- if (time_rec)
|
|
|
|
- tmrec_free( time_rec );
|
|
|
|
|
|
+ if(time_rec)
|
|
|
|
+ tmrec_free(time_rec);
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-static int add_rule(rt_data_t *rdata, char *grplst, str *prefix, rt_info_t *rule)
|
|
|
|
|
|
+static int add_rule(
|
|
|
|
+ rt_data_t *rdata, char *grplst, str *prefix, rt_info_t *rule)
|
|
{
|
|
{
|
|
long int t;
|
|
long int t;
|
|
char *tmp;
|
|
char *tmp;
|
|
char *ep;
|
|
char *ep;
|
|
int n;
|
|
int n;
|
|
|
|
|
|
- tmp=grplst;
|
|
|
|
- n=0;
|
|
|
|
|
|
+ tmp = grplst;
|
|
|
|
+ n = 0;
|
|
/* parse the grplst */
|
|
/* parse the grplst */
|
|
- while(tmp && (*tmp!=0)) {
|
|
|
|
|
|
+ while(tmp && (*tmp != 0)) {
|
|
errno = 0;
|
|
errno = 0;
|
|
t = strtol(tmp, &ep, 10);
|
|
t = strtol(tmp, &ep, 10);
|
|
- if (ep == tmp) {
|
|
|
|
- LM_ERR("bad grp id '%c' (%d)[%s]\n",
|
|
|
|
- *ep, (int)(ep-grplst), grplst);
|
|
|
|
|
|
+ if(ep == tmp) {
|
|
|
|
+ LM_ERR("bad grp id '%c' (%d)[%s]\n", *ep, (int)(ep - grplst),
|
|
|
|
+ grplst);
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
- if ((!IS_SPACE(*ep)) && (*ep != SEP) && (*ep != SEP1) && (*ep!=0)) {
|
|
|
|
- LM_ERR("bad char %c (%d) [%s]\n",
|
|
|
|
- *ep, (int)(ep-grplst), grplst);
|
|
|
|
|
|
+ if((!IS_SPACE(*ep)) && (*ep != SEP) && (*ep != SEP1) && (*ep != 0)) {
|
|
|
|
+ LM_ERR("bad char %c (%d) [%s]\n", *ep, (int)(ep - grplst), grplst);
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
- if (errno == ERANGE && (t== LONG_MAX || t== LONG_MIN)) {
|
|
|
|
|
|
+ if(errno == ERANGE && (t == LONG_MAX || t == LONG_MIN)) {
|
|
LM_ERR("out of bounds\n");
|
|
LM_ERR("out of bounds\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
n++;
|
|
n++;
|
|
/* add rule -> has prefix? */
|
|
/* add rule -> has prefix? */
|
|
- if (prefix->len) {
|
|
|
|
|
|
+ if(prefix->len) {
|
|
/* add the routing rule */
|
|
/* add the routing rule */
|
|
- if ( add_prefix(rdata->pt, prefix, rule, (unsigned int)t)!=0 ) {
|
|
|
|
|
|
+ if(add_prefix(rdata->pt, prefix, rule, (unsigned int)t) != 0) {
|
|
LM_ERR("failed to add prefix route\n");
|
|
LM_ERR("failed to add prefix route\n");
|
|
- goto error;
|
|
|
|
|
|
+ goto error;
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- if ( add_rt_info( &rdata->noprefix, rule, (unsigned int)t)!=0 ) {
|
|
|
|
|
|
+ if(add_rt_info(&rdata->noprefix, rule, (unsigned int)t) != 0) {
|
|
LM_ERR("failed to add prefixless route\n");
|
|
LM_ERR("failed to add prefixless route\n");
|
|
- goto error;
|
|
|
|
|
|
+ goto error;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/* keep parsing */
|
|
/* keep parsing */
|
|
@@ -262,9 +265,8 @@ static int add_rule(rt_data_t *rdata, char *grplst, str *prefix, rt_info_t *rule
|
|
tmp = ep;
|
|
tmp = ep;
|
|
}
|
|
}
|
|
|
|
|
|
- if(n==0) {
|
|
|
|
- LM_ERR("no id in grp list [%s]\n",
|
|
|
|
- grplst);
|
|
|
|
|
|
+ if(n == 0) {
|
|
|
|
+ LM_ERR("no id in grp list [%s]\n", grplst);
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -274,35 +276,35 @@ error:
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-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 )
|
|
|
|
|
|
+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[5];
|
|
|
|
|
|
+ int int_vals[4];
|
|
|
|
+ char *str_vals[5];
|
|
str tmp;
|
|
str tmp;
|
|
db_key_t columns[7];
|
|
db_key_t columns[7];
|
|
- db1_res_t* res;
|
|
|
|
- db_row_t* row;
|
|
|
|
|
|
+ db1_res_t *res;
|
|
|
|
+ db_row_t *row;
|
|
rt_info_t *ri;
|
|
rt_info_t *ri;
|
|
rt_data_t *rdata;
|
|
rt_data_t *rdata;
|
|
- tmrec_t *time_rec;
|
|
|
|
|
|
+ tmrec_t *time_rec;
|
|
unsigned int id;
|
|
unsigned int id;
|
|
str s_id;
|
|
str s_id;
|
|
- int i,n;
|
|
|
|
|
|
+ int i, n;
|
|
|
|
|
|
res = 0;
|
|
res = 0;
|
|
ri = 0;
|
|
ri = 0;
|
|
rdata = 0;
|
|
rdata = 0;
|
|
|
|
|
|
/* init new data structure */
|
|
/* init new data structure */
|
|
- if ( (rdata=build_rt_data())==0 ) {
|
|
|
|
|
|
+ if((rdata = build_rt_data()) == 0) {
|
|
LM_ERR("failed to build rdata\n");
|
|
LM_ERR("failed to build rdata\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
|
|
|
|
/* read the destinations */
|
|
/* read the destinations */
|
|
- if (dr_dbf->use_table( db_hdl, drd_table) < 0) {
|
|
|
|
- LM_ERR("cannot select table \"%.*s\"\n", drd_table->len,drd_table->s);
|
|
|
|
|
|
+ if(dr_dbf->use_table(db_hdl, drd_table) < 0) {
|
|
|
|
+ LM_ERR("cannot select table \"%.*s\"\n", drd_table->len, drd_table->s);
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -313,138 +315,139 @@ rt_data_t* dr_load_routing_info( db_func_t *dr_dbf, db1_con_t* db_hdl,
|
|
columns[4] = &type_drd_col;
|
|
columns[4] = &type_drd_col;
|
|
columns[5] = &attrs_drd_col;
|
|
columns[5] = &attrs_drd_col;
|
|
|
|
|
|
- if (DB_CAPABILITY(*dr_dbf, DB_CAP_FETCH)) {
|
|
|
|
- if ( dr_dbf->query( db_hdl, 0, 0, 0, columns, 0, 6, 0, 0 ) < 0) {
|
|
|
|
|
|
+ if(DB_CAPABILITY(*dr_dbf, DB_CAP_FETCH)) {
|
|
|
|
+ if(dr_dbf->query(db_hdl, 0, 0, 0, columns, 0, 6, 0, 0) < 0) {
|
|
LM_ERR("DB query failed\n");
|
|
LM_ERR("DB query failed\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
- if(dr_dbf->fetch_result(db_hdl, &res, dr_fetch_rows)<0) {
|
|
|
|
|
|
+ if(dr_dbf->fetch_result(db_hdl, &res, dr_fetch_rows) < 0) {
|
|
LM_ERR("Error fetching rows\n");
|
|
LM_ERR("Error fetching rows\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- if ( dr_dbf->query( db_hdl, 0, 0, 0, columns, 0, 6, 0, &res) < 0) {
|
|
|
|
|
|
+ if(dr_dbf->query(db_hdl, 0, 0, 0, columns, 0, 6, 0, &res) < 0) {
|
|
LM_ERR("DB query failed\n");
|
|
LM_ERR("DB query failed\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if (RES_ROW_N(res) == 0) {
|
|
|
|
- LM_WARN("table \"%.*s\" empty\n", drd_table->len,drd_table->s );
|
|
|
|
|
|
+ if(RES_ROW_N(res) == 0) {
|
|
|
|
+ LM_WARN("table \"%.*s\" empty\n", drd_table->len, drd_table->s);
|
|
}
|
|
}
|
|
- LM_DBG("%d records found in %.*s\n",
|
|
|
|
- RES_ROW_N(res), drd_table->len,drd_table->s);
|
|
|
|
|
|
+ LM_DBG("%d records found in %.*s\n", RES_ROW_N(res), drd_table->len,
|
|
|
|
+ drd_table->s);
|
|
n = 0;
|
|
n = 0;
|
|
do {
|
|
do {
|
|
- for(i=0; i < RES_ROW_N(res); i++) {
|
|
|
|
|
|
+ for(i = 0; i < RES_ROW_N(res); i++) {
|
|
row = RES_ROWS(res) + i;
|
|
row = RES_ROWS(res) + i;
|
|
/* DST_ID column */
|
|
/* DST_ID column */
|
|
- check_val( ROW_VALUES(row), DB1_INT, 1, 0);
|
|
|
|
- int_vals[0] = VAL_INT (ROW_VALUES(row));
|
|
|
|
|
|
+ check_val(ROW_VALUES(row), DB1_INT, 1, 0);
|
|
|
|
+ int_vals[0] = VAL_INT(ROW_VALUES(row));
|
|
/* ADDRESS column */
|
|
/* ADDRESS column */
|
|
- check_val( ROW_VALUES(row)+1, DB1_STRING, 1, 1);
|
|
|
|
- str_vals[0] = (char*)VAL_STRING(ROW_VALUES(row)+1);
|
|
|
|
|
|
+ check_val(ROW_VALUES(row) + 1, DB1_STRING, 1, 1);
|
|
|
|
+ str_vals[0] = (char *)VAL_STRING(ROW_VALUES(row) + 1);
|
|
/* STRIP column */
|
|
/* STRIP column */
|
|
- check_val( ROW_VALUES(row)+2, DB1_INT, 1, 0);
|
|
|
|
- int_vals[1] = VAL_INT (ROW_VALUES(row)+2);
|
|
|
|
|
|
+ check_val(ROW_VALUES(row) + 2, DB1_INT, 1, 0);
|
|
|
|
+ int_vals[1] = VAL_INT(ROW_VALUES(row) + 2);
|
|
/* PREFIX column */
|
|
/* PREFIX column */
|
|
- check_val( ROW_VALUES(row)+3, DB1_STRING, 0, 0);
|
|
|
|
- str_vals[1] = (char*)VAL_STRING(ROW_VALUES(row)+3);
|
|
|
|
|
|
+ check_val(ROW_VALUES(row) + 3, DB1_STRING, 0, 0);
|
|
|
|
+ str_vals[1] = (char *)VAL_STRING(ROW_VALUES(row) + 3);
|
|
/* TYPE column */
|
|
/* TYPE column */
|
|
- check_val( ROW_VALUES(row)+4, DB1_INT, 1, 0);
|
|
|
|
- int_vals[2] = VAL_INT(ROW_VALUES(row)+4);
|
|
|
|
|
|
+ check_val(ROW_VALUES(row) + 4, DB1_INT, 1, 0);
|
|
|
|
+ int_vals[2] = VAL_INT(ROW_VALUES(row) + 4);
|
|
/* ATTRS column */
|
|
/* ATTRS column */
|
|
- check_val( ROW_VALUES(row)+5, DB1_STRING, 0, 0);
|
|
|
|
- str_vals[2] = (char*)VAL_STRING(ROW_VALUES(row)+5);
|
|
|
|
|
|
+ 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 */
|
|
/* add the destinaton definition in */
|
|
- if ( add_dst( rdata, int_vals[0], str_vals[0], int_vals[1],
|
|
|
|
- str_vals[1], int_vals[2], str_vals[2])<0 ) {
|
|
|
|
|
|
+ if(add_dst(rdata, int_vals[0], str_vals[0], int_vals[1],
|
|
|
|
+ str_vals[1], int_vals[2], str_vals[2])
|
|
|
|
+ < 0) {
|
|
LM_ERR("failed to add destination id %d -> skipping\n",
|
|
LM_ERR("failed to add destination id %d -> skipping\n",
|
|
- int_vals[0]);
|
|
|
|
|
|
+ int_vals[0]);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
n++;
|
|
n++;
|
|
}
|
|
}
|
|
- if (DB_CAPABILITY(*dr_dbf, DB_CAP_FETCH)) {
|
|
|
|
- if(dr_dbf->fetch_result(db_hdl, &res, dr_fetch_rows)<0) {
|
|
|
|
- LM_ERR( "fetching rows (1)\n");
|
|
|
|
|
|
+ if(DB_CAPABILITY(*dr_dbf, DB_CAP_FETCH)) {
|
|
|
|
+ if(dr_dbf->fetch_result(db_hdl, &res, dr_fetch_rows) < 0) {
|
|
|
|
+ LM_ERR("fetching rows (1)\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- } while(RES_ROW_N(res)>0);
|
|
|
|
|
|
+ } while(RES_ROW_N(res) > 0);
|
|
|
|
|
|
dr_dbf->free_result(db_hdl, res);
|
|
dr_dbf->free_result(db_hdl, res);
|
|
res = 0;
|
|
res = 0;
|
|
|
|
|
|
- if (n==0) {
|
|
|
|
|
|
+ if(n == 0) {
|
|
LM_WARN("no valid "
|
|
LM_WARN("no valid "
|
|
- "destinations set -> ignoring the routing rules\n");
|
|
|
|
|
|
+ "destinations set -> ignoring the routing rules\n");
|
|
return rdata;
|
|
return rdata;
|
|
}
|
|
}
|
|
|
|
|
|
/* read the gw lists, if any */
|
|
/* read the gw lists, if any */
|
|
- if (dr_dbf->use_table( db_hdl, drl_table) < 0) {
|
|
|
|
- LM_ERR("cannot select table \"%.*s\"\n", drl_table->len,drl_table->s);
|
|
|
|
|
|
+ if(dr_dbf->use_table(db_hdl, drl_table) < 0) {
|
|
|
|
+ LM_ERR("cannot select table \"%.*s\"\n", drl_table->len, drl_table->s);
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
|
|
|
|
columns[0] = &id_drl_col;
|
|
columns[0] = &id_drl_col;
|
|
columns[1] = &gwlist_drl_col;
|
|
columns[1] = &gwlist_drl_col;
|
|
|
|
|
|
- if (DB_CAPABILITY(*dr_dbf, DB_CAP_FETCH)) {
|
|
|
|
- if ( dr_dbf->query( db_hdl, 0, 0, 0, columns, 0, 2, 0, 0 ) < 0) {
|
|
|
|
|
|
+ if(DB_CAPABILITY(*dr_dbf, DB_CAP_FETCH)) {
|
|
|
|
+ if(dr_dbf->query(db_hdl, 0, 0, 0, columns, 0, 2, 0, 0) < 0) {
|
|
LM_ERR("DB query failed\n");
|
|
LM_ERR("DB query failed\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
- if(dr_dbf->fetch_result(db_hdl, &res, dr_fetch_rows)<0) {
|
|
|
|
|
|
+ if(dr_dbf->fetch_result(db_hdl, &res, dr_fetch_rows) < 0) {
|
|
LM_ERR("Error fetching rows\n");
|
|
LM_ERR("Error fetching rows\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- if ( dr_dbf->query( db_hdl, 0, 0, 0, columns, 0, 2, 0, &res) < 0) {
|
|
|
|
|
|
+ if(dr_dbf->query(db_hdl, 0, 0, 0, columns, 0, 2, 0, &res) < 0) {
|
|
LM_ERR("DB query failed\n");
|
|
LM_ERR("DB query failed\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if (RES_ROW_N(res) == 0) {
|
|
|
|
- LM_DBG("table \"%.*s\" empty\n", drl_table->len,drl_table->s );
|
|
|
|
|
|
+ if(RES_ROW_N(res) == 0) {
|
|
|
|
+ LM_DBG("table \"%.*s\" empty\n", drl_table->len, drl_table->s);
|
|
} else {
|
|
} else {
|
|
- LM_DBG("%d records found in %.*s\n",
|
|
|
|
- RES_ROW_N(res), drl_table->len,drl_table->s);
|
|
|
|
|
|
+ LM_DBG("%d records found in %.*s\n", RES_ROW_N(res), drl_table->len,
|
|
|
|
+ drl_table->s);
|
|
do {
|
|
do {
|
|
- for(i=0; i < RES_ROW_N(res); i++) {
|
|
|
|
|
|
+ for(i = 0; i < RES_ROW_N(res); i++) {
|
|
row = RES_ROWS(res) + i;
|
|
row = RES_ROWS(res) + i;
|
|
/* ID column */
|
|
/* ID column */
|
|
- check_val( ROW_VALUES(row), DB1_INT, 1, 0);
|
|
|
|
- int_vals[0] = VAL_INT (ROW_VALUES(row));
|
|
|
|
|
|
+ check_val(ROW_VALUES(row), DB1_INT, 1, 0);
|
|
|
|
+ int_vals[0] = VAL_INT(ROW_VALUES(row));
|
|
/* GWLIST column */
|
|
/* GWLIST column */
|
|
- check_val( ROW_VALUES(row)+1, DB1_STRING, 1, 1);
|
|
|
|
- str_vals[0] = (char*)VAL_STRING(ROW_VALUES(row)+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) {
|
|
|
|
|
|
+ if(add_tmp_gw_list(int_vals[0], str_vals[0]) != 0) {
|
|
LM_ERR("failed to add temporary GW list\n");
|
|
LM_ERR("failed to add temporary GW list\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (DB_CAPABILITY(*dr_dbf, DB_CAP_FETCH)) {
|
|
|
|
- if(dr_dbf->fetch_result(db_hdl, &res, dr_fetch_rows)<0) {
|
|
|
|
- LM_ERR( "fetching rows (1)\n");
|
|
|
|
|
|
+ if(DB_CAPABILITY(*dr_dbf, DB_CAP_FETCH)) {
|
|
|
|
+ if(dr_dbf->fetch_result(db_hdl, &res, dr_fetch_rows) < 0) {
|
|
|
|
+ LM_ERR("fetching rows (1)\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- } while(RES_ROW_N(res)>0);
|
|
|
|
|
|
+ } while(RES_ROW_N(res) > 0);
|
|
}
|
|
}
|
|
dr_dbf->free_result(db_hdl, res);
|
|
dr_dbf->free_result(db_hdl, res);
|
|
res = 0;
|
|
res = 0;
|
|
|
|
|
|
/* read the routing rules */
|
|
/* read the routing rules */
|
|
- if (dr_dbf->use_table( db_hdl, drr_table) < 0) {
|
|
|
|
|
|
+ if(dr_dbf->use_table(db_hdl, drr_table) < 0) {
|
|
LM_ERR("cannot select table \"%.*s\"\n", drr_table->len, drr_table->s);
|
|
LM_ERR("cannot select table \"%.*s\"\n", drr_table->len, drr_table->s);
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
@@ -457,130 +460,133 @@ rt_data_t* dr_load_routing_info( db_func_t *dr_dbf, db1_con_t* db_hdl,
|
|
columns[5] = &routeid_drr_col;
|
|
columns[5] = &routeid_drr_col;
|
|
columns[6] = &dstlist_drr_col;
|
|
columns[6] = &dstlist_drr_col;
|
|
|
|
|
|
- if (DB_CAPABILITY(*dr_dbf, DB_CAP_FETCH)) {
|
|
|
|
- if ( dr_dbf->query( db_hdl, 0, 0, 0, columns, 0, 7, 0, 0) < 0) {
|
|
|
|
|
|
+ if(DB_CAPABILITY(*dr_dbf, DB_CAP_FETCH)) {
|
|
|
|
+ if(dr_dbf->query(db_hdl, 0, 0, 0, columns, 0, 7, 0, 0) < 0) {
|
|
LM_ERR("DB query failed\n");
|
|
LM_ERR("DB query failed\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
- if(dr_dbf->fetch_result(db_hdl, &res, dr_fetch_rows)<0) {
|
|
|
|
|
|
+ if(dr_dbf->fetch_result(db_hdl, &res, dr_fetch_rows) < 0) {
|
|
LM_ERR("Error fetching rows\n");
|
|
LM_ERR("Error fetching rows\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- if ( dr_dbf->query( db_hdl, 0, 0, 0, columns, 0, 7, 0, &res) < 0) {
|
|
|
|
|
|
+ if(dr_dbf->query(db_hdl, 0, 0, 0, columns, 0, 7, 0, &res) < 0) {
|
|
LM_ERR("DB query failed\n");
|
|
LM_ERR("DB query failed\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- if (RES_ROW_N(res) == 0) {
|
|
|
|
|
|
+ if(RES_ROW_N(res) == 0) {
|
|
LM_WARN("table \"%.*s\" is empty\n", drr_table->len, drr_table->s);
|
|
LM_WARN("table \"%.*s\" is empty\n", drr_table->len, drr_table->s);
|
|
}
|
|
}
|
|
|
|
|
|
- LM_DBG("%d records found in %.*s\n", RES_ROW_N(res),
|
|
|
|
- drr_table->len, drr_table->s);
|
|
|
|
|
|
+ LM_DBG("%d records found in %.*s\n", RES_ROW_N(res), drr_table->len,
|
|
|
|
+ drr_table->s);
|
|
|
|
|
|
n = 0;
|
|
n = 0;
|
|
do {
|
|
do {
|
|
- for(i=0; i < RES_ROW_N(res); i++) {
|
|
|
|
|
|
+ for(i = 0; i < RES_ROW_N(res); i++) {
|
|
row = RES_ROWS(res) + i;
|
|
row = RES_ROWS(res) + i;
|
|
/* RULE_ID column */
|
|
/* RULE_ID column */
|
|
- check_val( ROW_VALUES(row), DB1_INT, 1, 0);
|
|
|
|
- int_vals[0] = VAL_INT (ROW_VALUES(row));
|
|
|
|
|
|
+ check_val(ROW_VALUES(row), DB1_INT, 1, 0);
|
|
|
|
+ int_vals[0] = VAL_INT(ROW_VALUES(row));
|
|
/* GROUP column */
|
|
/* GROUP column */
|
|
- check_val( ROW_VALUES(row)+1, DB1_STRING, 1, 1);
|
|
|
|
- str_vals[0] = (char*)VAL_STRING(ROW_VALUES(row)+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 */
|
|
/* PREFIX column - it may be null or empty */
|
|
- check_val( ROW_VALUES(row)+2, DB1_STRING, 0, 0);
|
|
|
|
- if ((ROW_VALUES(row)+2)->nul || VAL_STRING(ROW_VALUES(row)+2)==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.s = NULL;
|
|
tmp.len = 0;
|
|
tmp.len = 0;
|
|
} else {
|
|
} else {
|
|
- str_vals[1] = (char*)VAL_STRING(ROW_VALUES(row)+2);
|
|
|
|
|
|
+ str_vals[1] = (char *)VAL_STRING(ROW_VALUES(row) + 2);
|
|
tmp.s = str_vals[1];
|
|
tmp.s = str_vals[1];
|
|
tmp.len = strlen(str_vals[1]);
|
|
tmp.len = strlen(str_vals[1]);
|
|
}
|
|
}
|
|
/* TIME column */
|
|
/* TIME column */
|
|
- check_val( ROW_VALUES(row)+3, DB1_STRING, 1, 1);
|
|
|
|
- str_vals[2] = (char*)VAL_STRING(ROW_VALUES(row)+3);
|
|
|
|
|
|
+ check_val(ROW_VALUES(row) + 3, DB1_STRING, 1, 1);
|
|
|
|
+ str_vals[2] = (char *)VAL_STRING(ROW_VALUES(row) + 3);
|
|
/* PRIORITY column */
|
|
/* PRIORITY column */
|
|
- check_val( ROW_VALUES(row)+4, DB1_INT, 1, 0);
|
|
|
|
- int_vals[2] = VAL_INT (ROW_VALUES(row)+4);
|
|
|
|
|
|
+ check_val(ROW_VALUES(row) + 4, DB1_INT, 1, 0);
|
|
|
|
+ int_vals[2] = VAL_INT(ROW_VALUES(row) + 4);
|
|
/* ROUTE_ID column */
|
|
/* ROUTE_ID column */
|
|
- check_val( ROW_VALUES(row)+5, DB1_STRING, 1, 0);
|
|
|
|
- str_vals[3] = (char*)VAL_STRING(ROW_VALUES(row)+5);
|
|
|
|
|
|
+ check_val(ROW_VALUES(row) + 5, DB1_STRING, 1, 0);
|
|
|
|
+ str_vals[3] = (char *)VAL_STRING(ROW_VALUES(row) + 5);
|
|
/* DSTLIST column */
|
|
/* DSTLIST column */
|
|
- check_val( ROW_VALUES(row)+6, DB1_STRING, 1, 1);
|
|
|
|
- str_vals[4] = (char*)VAL_STRING(ROW_VALUES(row)+6);
|
|
|
|
|
|
+ check_val(ROW_VALUES(row) + 6, DB1_STRING, 1, 1);
|
|
|
|
+ str_vals[4] = (char *)VAL_STRING(ROW_VALUES(row) + 6);
|
|
/* parse the time definition */
|
|
/* parse the time definition */
|
|
- if ((time_rec=parse_time_def(str_vals[2]))==0) {
|
|
|
|
|
|
+ if((time_rec = parse_time_def(str_vals[2])) == 0) {
|
|
LM_ERR("bad time definition <%s> for rule id %d -> skipping\n",
|
|
LM_ERR("bad time definition <%s> for rule id %d -> skipping\n",
|
|
- str_vals[2], int_vals[0]);
|
|
|
|
|
|
+ str_vals[2], int_vals[0]);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
/* lookup for the script route ID */
|
|
/* lookup for the script route ID */
|
|
- if (str_vals[3][0] && str_vals[3][0]!='0') {
|
|
|
|
- int_vals[3] = route_lookup(&main_rt, str_vals[3]);
|
|
|
|
- if (int_vals[3]==-1) {
|
|
|
|
- LM_WARN("route <%s> does not exist\n",str_vals[3]);
|
|
|
|
|
|
+ if(str_vals[3][0] && str_vals[3][0] != '0') {
|
|
|
|
+ int_vals[3] = route_lookup(&main_rt, str_vals[3]);
|
|
|
|
+ if(int_vals[3] == -1) {
|
|
|
|
+ LM_WARN("route <%s> does not exist\n", str_vals[3]);
|
|
int_vals[3] = 0;
|
|
int_vals[3] = 0;
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
int_vals[3] = 0;
|
|
int_vals[3] = 0;
|
|
}
|
|
}
|
|
/* is gw_list a list or a list id? */
|
|
/* is gw_list a list or a list id? */
|
|
- if (str_vals[4][0]=='#') {
|
|
|
|
- s_id.s = str_vals[4]+1;
|
|
|
|
|
|
+ if(str_vals[4][0] == '#') {
|
|
|
|
+ s_id.s = str_vals[4] + 1;
|
|
s_id.len = strlen(s_id.s);
|
|
s_id.len = strlen(s_id.s);
|
|
- if ( str2int( &s_id, &id)!=0 ||
|
|
|
|
- (str_vals[4]=get_tmp_gw_list(id))==NULL ) {
|
|
|
|
|
|
+ if(str2int(&s_id, &id) != 0
|
|
|
|
+ || (str_vals[4] = get_tmp_gw_list(id)) == NULL) {
|
|
LM_ERR("invalid reference to a GW list <%s> -> skipping\n",
|
|
LM_ERR("invalid reference to a GW list <%s> -> skipping\n",
|
|
- str_vals[4]);
|
|
|
|
|
|
+ str_vals[4]);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
/* build the routing rule */
|
|
/* build the routing rule */
|
|
- if ((ri = build_rt_info( int_vals[2], time_rec, int_vals[3],
|
|
|
|
- str_vals[4], rdata->pgw_l))== 0 ) {
|
|
|
|
|
|
+ if((ri = build_rt_info(int_vals[2], time_rec, int_vals[3],
|
|
|
|
+ str_vals[4], rdata->pgw_l))
|
|
|
|
+ == 0) {
|
|
LM_ERR("failed to add routing info for rule id %d -> "
|
|
LM_ERR("failed to add routing info for rule id %d -> "
|
|
- "skipping\n", int_vals[0]);
|
|
|
|
- tmrec_free( time_rec );
|
|
|
|
|
|
+ "skipping\n",
|
|
|
|
+ int_vals[0]);
|
|
|
|
+ tmrec_free(time_rec);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
/* add the rule */
|
|
/* add the rule */
|
|
- if (add_rule( rdata, str_vals[0], &tmp, ri)!=0) {
|
|
|
|
|
|
+ if(add_rule(rdata, str_vals[0], &tmp, ri) != 0) {
|
|
LM_ERR("failed to add rule id %d -> skipping\n", int_vals[0]);
|
|
LM_ERR("failed to add rule id %d -> skipping\n", int_vals[0]);
|
|
- free_rt_info( ri );
|
|
|
|
|
|
+ free_rt_info(ri);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
n++;
|
|
n++;
|
|
}
|
|
}
|
|
- if (DB_CAPABILITY(*dr_dbf, DB_CAP_FETCH)) {
|
|
|
|
- if(dr_dbf->fetch_result(db_hdl, &res, dr_fetch_rows)<0) {
|
|
|
|
- LM_ERR( "fetching rows (1)\n");
|
|
|
|
|
|
+ if(DB_CAPABILITY(*dr_dbf, DB_CAP_FETCH)) {
|
|
|
|
+ if(dr_dbf->fetch_result(db_hdl, &res, dr_fetch_rows) < 0) {
|
|
|
|
+ LM_ERR("fetching rows (1)\n");
|
|
goto error;
|
|
goto error;
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- } while(RES_ROW_N(res)>0);
|
|
|
|
|
|
+ } while(RES_ROW_N(res) > 0);
|
|
|
|
|
|
dr_dbf->free_result(db_hdl, res);
|
|
dr_dbf->free_result(db_hdl, res);
|
|
res = 0;
|
|
res = 0;
|
|
|
|
|
|
free_tmp_gw_list();
|
|
free_tmp_gw_list();
|
|
|
|
|
|
- if (n==0) {
|
|
|
|
|
|
+ if(n == 0) {
|
|
LM_WARN("no valid routing rules -> discarding all destinations\n");
|
|
LM_WARN("no valid routing rules -> discarding all destinations\n");
|
|
- free_rt_data( rdata, 0 );
|
|
|
|
|
|
+ free_rt_data(rdata, 0);
|
|
}
|
|
}
|
|
|
|
|
|
return rdata;
|
|
return rdata;
|
|
error:
|
|
error:
|
|
- if (res)
|
|
|
|
|
|
+ if(res)
|
|
dr_dbf->free_result(db_hdl, res);
|
|
dr_dbf->free_result(db_hdl, res);
|
|
- if (rdata)
|
|
|
|
- free_rt_data( rdata, 1 );
|
|
|
|
|
|
+ if(rdata)
|
|
|
|
+ free_rt_data(rdata, 1);
|
|
rdata = NULL;
|
|
rdata = NULL;
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|