Browse code

acc: removed define for SQL_ACC

- it was enabled for more than 10 years and the module links to
lib/srdb1 anyhow

Daniel-Constantin Mierla authored on 09/08/2017 11:37:20
Showing 8 changed files
... ...
@@ -8,9 +8,6 @@ auto_gen=
8 8
 NAME=acc.so
9 9
 LIBS=
10 10
 
11
-# comment the next line if you wish to disable SQL accounting
12
-DEFS+=-DSQL_ACC
13
-
14 11
 # set ENABLE_DIAMETER_ACC to true if you wish to enable DIAMETER accounting
15 12
 #   (uncomment next line or 'ENABLE_DIAMETER_ACC=true make all')
16 13
 #ENABLE_DIAMETER_ACC=true
... ...
@@ -64,11 +64,9 @@ extern int diameter_client_port;
64 64
 extern struct acc_extra *dia_extra;
65 65
 #endif
66 66
 
67
-#ifdef SQL_ACC
68 67
 static db_func_t acc_dbf;
69 68
 static db1_con_t* db_handle=0;
70 69
 extern struct acc_extra *db_extra;
71
-#endif
72 70
 
73 71
 /* arrays used to collect the values before being
74 72
  * pushed to the storage backend (whatever used)
... ...
@@ -306,16 +304,12 @@ int acc_log_request( struct sip_msg *rq)
306 304
 
307 305
 int acc_is_db_ready(void)
308 306
 {
309
-#ifdef SQL_ACC
310 307
 	if(db_handle!=0)
311 308
 		return 1;
312
-#endif
313 309
 
314 310
 	return 0;
315 311
 }
316 312
 
317
-#ifdef SQL_ACC
318
-
319 313
 /* caution: keys need to be aligned to core format
320 314
  * (3 = datetime + max 2 from time_mode) */
321 315
 static db_key_t db_keys[ACC_CORE_LEN+3+MAX_ACC_EXTRA+MAX_ACC_LEG];
... ...
@@ -528,8 +522,6 @@ error:
528 522
 	return -1;
529 523
 }
530 524
 
531
-#endif
532
-
533 525
 
534 526
 /************ RADIUS & DIAMETER helper functions **************/
535 527
 #if defined (DIAM_ACC)
... ...
@@ -79,13 +79,11 @@ int core2strar(struct sip_msg *req, str *c_vals, int *i_vals, char *t_vals);
79 79
 
80 80
 int acc_is_db_ready(void);
81 81
 
82
-#ifdef SQL_ACC
83 82
 int  acc_db_init(const str* db_url);
84 83
 int  acc_db_init_child(const str* db_url);
85 84
 void acc_db_close(void);
86 85
 int  acc_db_request( struct sip_msg *req);
87 86
 int acc_get_db_handlers(void **vf, void **vh);
88
-#endif
89 87
 
90 88
 #ifdef DIAM_ACC
91 89
 int  acc_diam_init(void);
... ...
@@ -45,9 +45,7 @@
45 45
 #include "acc_extra.h"
46 46
 #include "acc.h"
47 47
 
48
-#ifdef SQL_ACC
49 48
 #include "../../lib/srdb1/db.h"
50
-#endif
51 49
 
52 50
 #include <sys/time.h>
53 51
 
... ...
@@ -124,7 +122,6 @@ static int cdr_core2strar( struct dlg_cell* dlg,
124 122
     return MAX_CDR_CORE;
125 123
 }
126 124
 
127
-#ifdef SQL_ACC
128 125
 /* caution: keys need to be aligned to core format */
129 126
 static db_key_t db_cdr_keys[ MAX_CDR_CORE + MAX_CDR_EXTRA];
130 127
 static db_val_t db_cdr_vals[ MAX_CDR_CORE + MAX_CDR_EXTRA];
... ...
@@ -263,7 +260,6 @@ error:
263 260
 	free_strar_mem( &(cdr_type_array[m-n]), &(cdr_value_array[m-n]), n, m);
264 261
     return -1;
265 262
 }
266
-#endif
267 263
 
268 264
 /* collect all crd data and write it to a syslog */
269 265
 static int log_write_cdr( struct dlg_cell* dialog,
... ...
@@ -375,9 +371,7 @@ static int write_cdr( struct dlg_cell* dialog,
375 371
 	}
376 372
 
377 373
 	ret = log_write_cdr(dialog, message);
378
-#ifdef SQL_ACC
379 374
 	ret |= db_write_cdr(dialog, message);
380
-#endif
381 375
 	return ret;
382 376
 }
383 377
 
... ...
@@ -62,14 +62,8 @@ struct acc_enviroment acc_env;
62 62
 #define is_log_acc_on(_rq)     is_acc_flag_set(_rq,log_flag)
63 63
 #define is_log_mc_on(_rq)      is_acc_flag_set(_rq,log_missed_flag)
64 64
 
65
-#ifdef SQL_ACC
66
-	#define is_db_acc_on(_rq)     is_acc_flag_set(_rq,db_flag)
67
-	#define is_db_mc_on(_rq)      is_acc_flag_set(_rq,db_missed_flag)
68
-#else
69
-	#define is_db_acc_on(_rq)     (0)
70
-	#define is_db_mc_on(_rq)      (0)
71
-#endif
72
-
65
+#define is_db_acc_on(_rq)     is_acc_flag_set(_rq,db_flag)
66
+#define is_db_mc_on(_rq)      is_acc_flag_set(_rq,db_missed_flag)
73 67
 
74 68
 #ifdef DIAM_ACC
75 69
 	#define is_diam_acc_on(_rq)     is_acc_flag_set(_rq,diameter_flag)
... ...
@@ -262,7 +256,6 @@ int ki_acc_log_request(sip_msg_t *rq, str *comment)
262 256
 }
263 257
 
264 258
 
265
-#ifdef SQL_ACC
266 259
 int acc_db_set_table_name(struct sip_msg *msg, void *param, str *table)
267 260
 {
268 261
 #define DB_TABLE_NAME_SIZE	64
... ...
@@ -331,7 +324,6 @@ int ki_acc_db_request(sip_msg_t *rq, str *comment, str *dbtable)
331 324
 	env_set_comment(&accp);
332 325
 	return acc_db_request(rq);
333 326
 }
334
-#endif
335 327
 
336 328
 int ki_acc_request(sip_msg_t *rq, str *comment, str *dbtable)
337 329
 {
... ...
@@ -345,12 +337,10 @@ int ki_acc_request(sip_msg_t *rq, str *comment, str *dbtable)
345 337
 	if (acc_preparse_req(rq)<0)
346 338
 		return -1;
347 339
 
348
-#ifdef SQL_ACC
349 340
 	if(acc_db_set_table_name(rq, NULL, dbtable)<0) {
350 341
 		LM_ERR("cannot set table name\n");
351 342
 		return -1;
352 343
 	}
353
-#endif
354 344
 
355 345
 	env_set_to(rq->to);
356 346
 	env_set_comment(&accp);
... ...
@@ -359,14 +349,12 @@ int ki_acc_request(sip_msg_t *rq, str *comment, str *dbtable)
359 349
 	if(ret<0) {
360 350
 		LM_ERR("acc log request failed\n");
361 351
 	}
362
-#ifdef SQL_ACC
363 352
 	if(acc_is_db_ready()) {
364 353
 		ret = acc_db_request(rq);
365 354
 		if(ret<0) {
366 355
 			LM_ERR("acc db request failed\n");
367 356
 		}
368 357
 	}
369
-#endif
370 358
 
371 359
 	return ret;
372 360
 }
... ...
@@ -531,7 +519,6 @@ static inline void on_missed(struct cell *t, struct sip_msg *req,
531 519
 		acc_log_request( req );
532 520
 		flags_to_reset |= log_missed_flag;
533 521
 	}
534
-#ifdef SQL_ACC
535 522
 	if (is_db_mc_on(req)) {
536 523
 		if(acc_db_set_table_name(req, db_table_mc_data, &db_table_mc)<0) {
537 524
 			LM_ERR("cannot set missed call db table name\n");
... ...
@@ -540,7 +527,6 @@ static inline void on_missed(struct cell *t, struct sip_msg *req,
540 527
 		acc_db_request( req );
541 528
 		flags_to_reset |= db_missed_flag;
542 529
 	}
543
-#endif
544 530
 
545 531
 /* DIAMETER */
546 532
 #ifdef DIAM_ACC
... ...
@@ -634,7 +620,6 @@ static void acc_onreply(tm_cell_t *t, sip_msg_t *req, sip_msg_t *reply, int code
634 620
 		env_set_text( ACC_ANSWERED, ACC_ANSWERED_LEN);
635 621
 		acc_log_request(preq);
636 622
 	}
637
-#ifdef SQL_ACC
638 623
 	if (is_db_acc_on(preq)) {
639 624
 		if(acc_db_set_table_name(preq, db_table_acc_data, &db_table_acc)<0) {
640 625
 			LM_ERR("cannot set acc db table name\n");
... ...
@@ -642,7 +627,6 @@ static void acc_onreply(tm_cell_t *t, sip_msg_t *req, sip_msg_t *reply, int code
642 627
 			acc_db_request(preq);
643 628
 		}
644 629
 	}
645
-#endif
646 630
 
647 631
 /* DIAMETER */
648 632
 #ifdef DIAM_ACC
... ...
@@ -690,7 +674,6 @@ static inline void acc_onack( struct cell* t, struct sip_msg *req,
690 674
 		env_set_text( ACC_ACKED, ACC_ACKED_LEN);
691 675
 		acc_log_request( ack );
692 676
 	}
693
-#ifdef SQL_ACC
694 677
 	if (is_db_acc_on(req)) {
695 678
 		if(acc_db_set_table_name(ack, db_table_acc_data, &db_table_acc)<0) {
696 679
 			LM_ERR("cannot set acc db table name\n");
... ...
@@ -698,7 +681,6 @@ static inline void acc_onack( struct cell* t, struct sip_msg *req,
698 681
 		}
699 682
 		acc_db_request( ack );
700 683
 	}
701
-#endif
702 684
 
703 685
 /* DIAMETER */
704 686
 #ifdef DIAM_ACC
... ...
@@ -42,10 +42,8 @@ void acc_onreq( struct cell* t, int type, struct tmcb_params *ps );
42 42
 int w_acc_log_request(struct sip_msg *rq, char *comment, char *foo);
43 43
 int ki_acc_log_request(sip_msg_t *rq, str *comment);
44 44
 
45
-#ifdef SQL_ACC
46 45
 int w_acc_db_request(struct sip_msg *rq, char *comment, char *table);
47 46
 int ki_acc_db_request(sip_msg_t *rq, str *comment, str *dbtable);
48
-#endif
49 47
 
50 48
 int w_acc_request(sip_msg_t *rq, char *comment, char *table);
51 49
 int ki_acc_request(sip_msg_t *rq, str *comment, str *dbtable);
... ...
@@ -154,7 +154,6 @@ int diameter_client_port=3000;
154 154
 /*! \name AccSQLVariables  Radius Variables */
155 155
 /*@{*/
156 156
 
157
-#ifdef SQL_ACC
158 157
 int db_flag = -1;
159 158
 int db_missed_flag = -1;
160 159
 static char *db_extra_str = 0;		/*!< db extra variables */
... ...
@@ -173,7 +172,6 @@ str acc_sipcode_col    = str_init("sip_code");
173 172
 str acc_sipreason_col  = str_init("sip_reason");
174 173
 str acc_time_col       = str_init("time");
175 174
 int acc_db_insert_mode = 0;
176
-#endif
177 175
 
178 176
 /*@}*/
179 177
 
... ...
@@ -192,11 +190,9 @@ static cmd_export_t cmds[] = {
192 190
 	{"acc_log_request", (cmd_function)w_acc_log_request, 1,
193 191
 		acc_fixup, free_acc_fixup,
194 192
 		ANY_ROUTE},
195
-#ifdef SQL_ACC
196 193
 	{"acc_db_request",  (cmd_function)w_acc_db_request,  2,
197 194
 		acc_fixup, free_acc_fixup,
198 195
 		ANY_ROUTE},
199
-#endif
200 196
 	{"acc_request",  (cmd_function)w_acc_request,  2,
201 197
 		fixup_spve_spve, fixup_free_spve_spve,
202 198
 		ANY_ROUTE},
... ...
@@ -247,7 +243,6 @@ static param_export_t params[] = {
247 243
 	{"diameter_extra",       PARAM_STRING, &dia_extra_str     },
248 244
 #endif
249 245
 	/* db-specific */
250
-#ifdef SQL_ACC
251 246
 	{"db_flag",              INT_PARAM, &db_flag            },
252 247
 	{"db_missed_flag",       INT_PARAM, &db_missed_flag     },
253 248
 	{"db_extra",             PARAM_STRING, &db_extra_str    },
... ...
@@ -262,7 +257,6 @@ static param_export_t params[] = {
262 257
 	{"acc_sip_reason_column",PARAM_STR, &acc_sipreason_col  },
263 258
 	{"acc_time_column",      PARAM_STR, &acc_time_col       },
264 259
 	{"db_insert_mode",       INT_PARAM, &acc_db_insert_mode },
265
-#endif
266 260
 	/* time-mode-specific */
267 261
 	{"time_mode",            INT_PARAM, &acc_time_mode        },
268 262
 	{"time_attr",            PARAM_STR, &acc_time_attr        },
... ...
@@ -332,7 +326,6 @@ static int acc_fixup(void** param, int param_no)
332 326
 			}
333 327
 		}
334 328
 		*param = (void*)accp;
335
-#ifdef SQL_ACC
336 329
 	} else if (param_no == 2) {
337 330
 		/* only for db acc - the table name */
338 331
 		if (db_url.s==0) {
... ...
@@ -341,7 +334,6 @@ static int acc_fixup(void** param, int param_no)
341 334
 		} else {
342 335
 			return fixup_var_pve_str_12(param, 2);
343 336
 		}
344
-#endif
345 337
 	}
346 338
 	return 0;
347 339
 }
... ...
@@ -402,7 +394,6 @@ static int parse_failed_filter(char *s, unsigned short *failed_filter)
402 394
 
403 395
 static int mod_init( void )
404 396
 {
405
-#ifdef SQL_ACC
406 397
 	if (db_url.s) {
407 398
 		if(db_url.len<=0) {
408 399
 			db_url.s = NULL;
... ...
@@ -429,7 +420,6 @@ static int mod_init( void )
429 420
 			return -1;
430 421
 		}
431 422
 	}
432
-#endif
433 423
 
434 424
 	if (log_facility_str) {
435 425
 		int tmp = str2facility(log_facility_str);
... ...
@@ -560,7 +550,6 @@ static int mod_init( void )
560 550
 
561 551
 	/* ------------ SQL INIT SECTION ----------- */
562 552
 
563
-#ifdef SQL_ACC
564 553
 	if (db_url.s && db_url.len > 0) {
565 554
 		/* parse the extra string, if any */
566 555
 		if (db_extra_str && (db_extra=parse_acc_extra(db_extra_str))==0 ) {
... ...
@@ -588,8 +577,6 @@ static int mod_init( void )
588 577
 		db_flag = -1;
589 578
 		db_missed_flag = -1;
590 579
 	}
591
-#endif
592
-
593 580
 
594 581
 	/* ------------ DIAMETER INIT SECTION ----------- */
595 582
 
... ...
@@ -628,14 +615,11 @@ static int child_init(int rank)
628 615
 	if (rank==PROC_INIT || rank==PROC_MAIN || rank==PROC_TCP_MAIN)
629 616
 		return 0; /* do nothing for the main process */
630 617
 
631
-#ifdef SQL_ACC
632 618
 	if(db_url.s && acc_db_init_child(&db_url)<0) {
633 619
 		LM_ERR("could not open database connection");
634 620
 		return -1;
635 621
 	}
636 622
 
637
-#endif
638
-
639 623
 	/* DIAMETER */
640 624
 #ifdef DIAM_ACC
641 625
 	/* open TCP connection */
... ...
@@ -668,11 +652,9 @@ static void destroy(void)
668 652
 {
669 653
 	if (log_extra)
670 654
 		destroy_extras( log_extra);
671
-#ifdef SQL_ACC
672 655
 	acc_db_close();
673 656
 	if (db_extra)
674 657
 		destroy_extras( db_extra);
675
-#endif
676 658
 #ifdef DIAM_ACC
677 659
 	close_tcp_connection(sockfd);
678 660
 	if (dia_extra)
... ...
@@ -796,13 +778,11 @@ static sr_kemi_t sr_kemi_acc_exports[] = {
796 778
 		{ SR_KEMIP_STR, SR_KEMIP_NONE, SR_KEMIP_NONE,
797 779
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
798 780
 	},
799
-#ifdef SQL_ACC
800 781
 	{ str_init("acc"), str_init("acc_db_request"),
801 782
 		SR_KEMIP_INT, ki_acc_db_request,
802 783
 		{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE,
803 784
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
804 785
 	},
805
-#endif
806 786
 	{ str_init("acc"), str_init("acc_request"),
807 787
 		SR_KEMIP_INT, ki_acc_request,
808 788
 		{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE,
... ...
@@ -60,7 +60,6 @@ extern int diameter_flag;
60 60
 extern int diameter_missed_flag;
61 61
 #endif
62 62
 
63
-#ifdef SQL_ACC
64 63
 extern int db_flag;
65 64
 extern int db_missed_flag;
66 65
 
... ...
@@ -81,7 +80,6 @@ extern str acc_sipreason_col;
81 80
 extern str acc_time_col;
82 81
 
83 82
 extern int acc_db_insert_mode;
84
-#endif /* SQL_ACC */
85 83
 
86 84
 /* time mode */
87 85
 extern int acc_time_mode;