|
@@ -39,6 +39,7 @@
|
|
|
#include <string.h>
|
|
|
|
|
|
#include "../../dprint.h"
|
|
|
+#include "../../sr_module.h"
|
|
|
#include "../../parser/parse_from.h"
|
|
|
#include "../../parser/parse_content.h"
|
|
|
#include "../../modules/tm/tm_load.h"
|
|
@@ -103,8 +104,6 @@ struct acc_enviroment acc_env;
|
|
|
#define is_acc_prepare_on(_rq) \
|
|
|
(is_acc_flag_set(_rq,acc_prepare_flag))
|
|
|
|
|
|
-
|
|
|
-
|
|
|
static void tmcb_func( struct cell* t, int type, struct tmcb_params *ps );
|
|
|
|
|
|
|
|
@@ -182,6 +181,35 @@ int w_acc_log_request(struct sip_msg *rq, char *comment, char *foo)
|
|
|
|
|
|
|
|
|
#ifdef SQL_ACC
|
|
|
+int acc_db_set_table_name(struct sip_msg *msg, void *param, str *table)
|
|
|
+{
|
|
|
+#define DB_TABLE_NAME_SIZE 64
|
|
|
+ static char db_table_name_buf[DB_TABLE_NAME_SIZE];
|
|
|
+ str dbtable;
|
|
|
+
|
|
|
+ if(param!=NULL) {
|
|
|
+ if(get_str_fparam(&dbtable, msg, (fparam_t*)param)<0) {
|
|
|
+ LM_ERR("cannot get acc db table name\n");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ if(dbtable.len>=DB_TABLE_NAME_SIZE) {
|
|
|
+ LM_ERR("acc db table name too big [%.*s] max %d\n",
|
|
|
+ dbtable.len, dbtable.s, DB_TABLE_NAME_SIZE);
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ strncpy(db_table_name_buf, dbtable.s, dbtable.len);
|
|
|
+ env_set_text(db_table_name_buf, dbtable.len);
|
|
|
+ } else {
|
|
|
+ if(table==NULL) {
|
|
|
+ LM_ERR("no acc table name\n");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
+ env_set_text(table->s, table->len);
|
|
|
+ }
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
int w_acc_db_request(struct sip_msg *rq, char *comment, char *table)
|
|
|
{
|
|
|
if (!table) {
|
|
@@ -190,9 +218,12 @@ int w_acc_db_request(struct sip_msg *rq, char *comment, char *table)
|
|
|
}
|
|
|
if (acc_preparse_req(rq)<0)
|
|
|
return -1;
|
|
|
+ if(acc_db_set_table_name(rq, (void*)table, NULL)<0) {
|
|
|
+ LM_ERR("cannot set table name\n");
|
|
|
+ return -1;
|
|
|
+ }
|
|
|
env_set_to( rq->to );
|
|
|
env_set_comment((struct acc_param*)comment);
|
|
|
- env_set_text(table, strlen(table));
|
|
|
return acc_db_request(rq);
|
|
|
}
|
|
|
#endif
|
|
@@ -340,7 +371,10 @@ static inline void on_missed(struct cell *t, struct sip_msg *req,
|
|
|
}
|
|
|
#ifdef SQL_ACC
|
|
|
if (is_db_mc_on(req)) {
|
|
|
- env_set_text(db_table_mc.s, db_table_mc.len);
|
|
|
+ if(acc_db_set_table_name(req, db_table_mc_data, &db_table_mc)<0) {
|
|
|
+ LM_ERR("cannot set missed call db table name\n");
|
|
|
+ return;
|
|
|
+ }
|
|
|
acc_db_request( req );
|
|
|
flags_to_reset |= db_missed_flag;
|
|
|
}
|
|
@@ -411,7 +445,10 @@ static inline void acc_onreply( struct cell* t, struct sip_msg *req,
|
|
|
}
|
|
|
#ifdef SQL_ACC
|
|
|
if (is_db_acc_on(req)) {
|
|
|
- env_set_text( db_table_acc.s, db_table_acc.len);
|
|
|
+ if(acc_db_set_table_name(req, db_table_acc_data, &db_table_acc)<0) {
|
|
|
+ LM_ERR("cannot set acc db table name\n");
|
|
|
+ return;
|
|
|
+ }
|
|
|
acc_db_request(req);
|
|
|
}
|
|
|
#endif
|
|
@@ -452,7 +489,10 @@ static inline void acc_onack( struct cell* t, struct sip_msg *req,
|
|
|
}
|
|
|
#ifdef SQL_ACC
|
|
|
if (is_db_acc_on(req)) {
|
|
|
- env_set_text( db_table_acc.s, db_table_acc.len);
|
|
|
+ if(acc_db_set_table_name(ack, db_table_acc_data, &db_table_acc)<0) {
|
|
|
+ LM_ERR("cannot set acc db table name\n");
|
|
|
+ return;
|
|
|
+ }
|
|
|
acc_db_request( ack );
|
|
|
}
|
|
|
#endif
|