Browse code

topos: cseq number and method linked to db

Daniel-Constantin Mierla authored on 18/03/2016 14:19:18
Showing 2 changed files
... ...
@@ -292,6 +292,12 @@ int tps_storage_link_msg(sip_msg_t *msg, tps_data_t *td, int dir)
292 292
 		td->b_contact = ((contact_body_t*)msg->contact->parsed)->contacts->uri;
293 293
 	}
294 294
 	td->x_via = td->x_via2;
295
+	if(parse_headers(msg, HDR_CSEQ_F, 0)!=0 || msg->cseq==NULL) {
296
+		LM_ERR("cannot parse cseq header\n");
297
+		return -1; /* should it be 0 ?!?! */
298
+	}
299
+	td->s_method = get_cseq(msg)->method;
300
+	td->s_cseq = get_cseq(msg)->number;
295 301
 	return 0;
296 302
 
297 303
 error:
... ...
@@ -477,8 +483,8 @@ int tps_db_insert_dialog(tps_data_t *td)
477 483
 	nr_keys++;
478 484
 
479 485
 	db_keys[nr_keys] = &td_col_s_cseq;
480
-	db_vals[nr_keys].type = DB1_INT;
481
-	db_vals[nr_keys].val.int_val = (int)td->s_cseq;
486
+	db_vals[nr_keys].type = DB1_STR;
487
+	db_vals[nr_keys].val.str_val = TPS_STRZ(td->s_cseq);
482 488
 	nr_keys++;
483 489
 
484 490
 	if (_tpsdbf.use_table(_tps_db_handle, &td_table_name) < 0) {
... ...
@@ -597,8 +603,8 @@ int tps_db_insert_branch(tps_data_t *td)
597 603
 	nr_keys++;
598 604
 
599 605
 	db_keys[nr_keys] = &tt_col_s_cseq;
600
-	db_vals[nr_keys].type = DB1_INT;
601
-	db_vals[nr_keys].val.int_val = (int)td->s_cseq;
606
+	db_vals[nr_keys].type = DB1_STR;
607
+	db_vals[nr_keys].val.str_val = TPS_STRZ(td->s_cseq);
602 608
 	nr_keys++;
603 609
 
604 610
 	if (_tpsdbf.use_table(_tps_db_handle, &tt_table_name) < 0) {
... ...
@@ -731,6 +737,8 @@ int tps_storage_load_branch(sip_msg_t *msg, tps_data_t *md, tps_data_t *sd)
731 737
 	db_cols[nr_cols++] = &tt_col_x_rr;
732 738
 	db_cols[nr_cols++] = &tt_col_x_uri;
733 739
 	db_cols[nr_cols++] = &tt_col_x_tag;
740
+	db_cols[nr_cols++] = &tt_col_s_method;
741
+	db_cols[nr_cols++] = &tt_col_s_cseq;
734 742
 
735 743
 	if (_tpsdbf.use_table(_tps_db_handle, &tt_table_name) < 0) {
736 744
 		LM_ERR("failed to perform use table\n");
... ...
@@ -762,6 +770,8 @@ int tps_storage_load_branch(sip_msg_t *msg, tps_data_t *md, tps_data_t *sd)
762 770
 	TPS_DATA_APPEND_DB(sd, db_res, n, &sd->x_rr); n++;
763 771
 	TPS_DATA_APPEND_DB(sd, db_res, n, &sd->x_uri); n++;
764 772
 	TPS_DATA_APPEND_DB(sd, db_res, n, &sd->x_tag); n++;
773
+	TPS_DATA_APPEND_DB(sd, db_res, n, &sd->s_method); n++;
774
+	TPS_DATA_APPEND_DB(sd, db_res, n, &sd->s_cseq); n++;
765 775
 
766 776
 	if ((db_res!=NULL) && _tpsdbf.free_result(_tps_db_handle, db_res)<0)
767 777
 		LM_ERR("failed to free result of query\n");
... ...
@@ -820,6 +830,8 @@ int tps_storage_load_dialog(sip_msg_t *msg, tps_data_t *md, tps_data_t *sd)
820 830
 	db_cols[nr_cols++] = &td_col_r_uri;
821 831
 	db_cols[nr_cols++] = &td_col_a_srcip;
822 832
 	db_cols[nr_cols++] = &td_col_b_srcip;
833
+	db_cols[nr_cols++] = &td_col_s_method;
834
+	db_cols[nr_cols++] = &td_col_s_cseq;
823 835
 
824 836
 
825 837
 	if (_tpsdbf.use_table(_tps_db_handle, &td_table_name) < 0) {
... ...
@@ -860,6 +872,8 @@ int tps_storage_load_dialog(sip_msg_t *msg, tps_data_t *md, tps_data_t *sd)
860 872
 	TPS_DATA_APPEND_DB(sd, db_res, n, &sd->r_uri); n++;
861 873
 	TPS_DATA_APPEND_DB(sd, db_res, n, &sd->a_srcip); n++;
862 874
 	TPS_DATA_APPEND_DB(sd, db_res, n, &sd->b_srcip); n++;
875
+	TPS_DATA_APPEND_DB(sd, db_res, n, &sd->s_method); n++;
876
+	TPS_DATA_APPEND_DB(sd, db_res, n, &sd->s_cseq); n++;
863 877
 
864 878
 	if ((db_res!=NULL) && _tpsdbf.free_result(_tps_db_handle, db_res)<0)
865 879
 		LM_ERR("failed to free result of query\n");
... ...
@@ -62,9 +62,9 @@ typedef struct tps_data {
62 62
 	str x_rr;
63 63
 	str x_uri;
64 64
 	str s_method;
65
+	str s_cseq;
65 66
 	int32_t iflags;
66 67
 	int32_t direction;
67
-	int32_t s_cseq;
68 68
 } tps_data_t;
69 69
 
70 70
 int tps_storage_dialog_find(sip_msg_t *msg, tps_data_t *td);