Browse code

modules/siptrace: added totag field to sip_trace table - added sip_trace table version check

Juha Heinanen authored on 13/02/2015 00:08:00
Showing 2 changed files
... ...
@@ -9,7 +9,7 @@
9 9
 
10 10
 <table id="sip_trace" xmlns:db="http://docbook.org/ns/docbook">
11 11
     <name>sip_trace</name>
12
-    <version>3</version>
12
+    <version>4</version>
13 13
     <type db="mysql">&MYSQL_TABLE_TYPE;</type>
14 14
     <description>
15 15
         <db:para>This table is used to store incoming/outgoing SIP messages in database. More informations can be found in the siptrace module documentation at: &KAMAILIO_MOD_DOC;siptrace.html.
... ...
@@ -105,6 +105,14 @@
105 105
     </column>
106 106
 
107 107
     <column>
108
+        <name>totag</name>
109
+        <type>string</type>
110
+        <size>&id_len;</size>
111
+        <default/>
112
+        <description>To tag</description>
113
+    </column>
114
+
115
+    <column>
108 116
         <name>direction</name>
109 117
         <type>string</type>
110 118
         <size>4</size>
... ...
@@ -72,6 +72,7 @@ struct _siptrace_data {
72 72
 	char *dir;
73 73
 	str fromtag;
74 74
 	str fromip;
75
+	str totag;
75 76
 	str toip;
76 77
 	char toip_buff[IP_ADDR_MAX_STR_SIZE+12];
77 78
 	char fromip_buff[IP_ADDR_MAX_STR_SIZE+12];
... ...
@@ -123,8 +124,10 @@ static str toip_column        = str_init("toip");        /* 07 */
123 123
 static str fromtag_column     = str_init("fromtag");     /* 08 */
124 124
 static str direction_column   = str_init("direction");   /* 09 */
125 125
 static str time_us_column     = str_init("time_us");     /* 10 */
126
+static str totag_column       = str_init("totag");       /* 11 */
126 127
 
127
-#define NR_KEYS 11
128
+#define NR_KEYS 12
129
+#define SIP_TRACE_TABLE_VERSION 4
128 130
 
129 131
 #define XHEADERS_BUFSIZE 512
130 132
 
... ...
@@ -193,6 +196,7 @@ static param_export_t params[] = {
193 193
 	{"fromip_column",      PARAM_STR, &fromip_column      },
194 194
 	{"toip_column",        PARAM_STR, &toip_column        },
195 195
 	{"fromtag_column",     PARAM_STR, &fromtag_column     },
196
+	{"totag_column",       PARAM_STR, &totag_column       },
196 197
 	{"direction_column",   PARAM_STR, &direction_column   },
197 198
 	{"trace_flag",         INT_PARAM, &trace_flag           },
198 199
 	{"trace_on",           INT_PARAM, &trace_on             },
... ...
@@ -463,6 +467,12 @@ static int child_init(int rank)
463 463
 			LM_ERR("unable to connect to database. Please check configuration.\n");
464 464
 			return -1;
465 465
 		}
466
+		if (db_check_table_version(&db_funcs, db_con, &siptrace_table,
467
+					   SIP_TRACE_TABLE_VERSION) < 0) {
468
+			LM_ERR("error during table version check\n");
469
+			db_funcs.close(db_con);		
470
+			return -1;
471
+		}
466 472
 	}
467 473
 
468 474
 	return 0;
... ...
@@ -809,6 +819,11 @@ static int sip_trace_store_db(struct _siptrace_data *sto)
809 809
 	db_vals[10].nul = 0;
810 810
 	db_vals[10].val.int_val = sto->tv.tv_usec;
811 811
 
812
+	db_keys[11] = &totag_column;
813
+	db_vals[11].type = DB1_STR;
814
+	db_vals[11].nul = 0;
815
+	db_vals[11].val.str_val = sto->totag;
816
+
812 817
 	db_funcs.use_table(db_con, siptrace_get_table());
813 818
 
814 819
 	if(trace_on_flag!=NULL && *trace_on_flag!=0) {
... ...
@@ -1025,6 +1040,7 @@ static int sip_trace(struct sip_msg *msg, struct dest_info * dst, char *dir)
1025 1025
 	}
1026 1026
 
1027 1027
 	sto.fromtag = get_from(msg)->tag_value;
1028
+	sto.totag = get_to(msg)->tag_value;
1028 1029
 
1029 1030
 #ifdef STATISTICS
1030 1031
 	if(msg->first_line.type==SIP_REPLY) {
... ...
@@ -1210,6 +1226,7 @@ static void trace_onreq_out(struct cell* t, int type, struct tmcb_params *ps)
1210 1210
 	sto.dir = "out";
1211 1211
 
1212 1212
 	sto.fromtag = get_from(msg)->tag_value;
1213
+	sto.totag = get_to(msg)->tag_value;
1213 1214
 
1214 1215
 #ifdef STATISTICS
1215 1216
 	sto.stat = siptrace_req;
... ...
@@ -1282,6 +1299,7 @@ static void trace_onreply_in(struct cell* t, int type, struct tmcb_params *ps)
1282 1282
 	sto.dir = "in";
1283 1283
 
1284 1284
 	sto.fromtag = get_from(msg)->tag_value;
1285
+	sto.totag = get_to(msg)->tag_value;
1285 1286
 #ifdef STATISTICS
1286 1287
 	sto.stat = siptrace_rpl;
1287 1288
 #endif
... ...
@@ -1390,6 +1408,7 @@ static void trace_onreply_out(struct cell* t, int type, struct tmcb_params *ps)
1390 1390
 
1391 1391
 	sto.dir = "out";
1392 1392
 	sto.fromtag = get_from(msg)->tag_value;
1393
+	sto.totag = get_to(msg)->tag_value;
1393 1394
 
1394 1395
 #ifdef STATISTICS
1395 1396
 	sto.stat = siptrace_rpl;
... ...
@@ -1476,6 +1495,7 @@ static void trace_sl_onreply_out(sl_cbp_t *slcbp)
1476 1476
 
1477 1477
 	sto.dir = "out";
1478 1478
 	sto.fromtag = get_from(msg)->tag_value;
1479
+	sto.totag = get_to(msg)->tag_value;
1479 1480
 
1480 1481
 #ifdef STATISTICS
1481 1482
 	sto.stat = siptrace_rpl;