瀏覽代碼

topos: persistent branch data storage

Daniel-Constantin Mierla 9 年之前
父節點
當前提交
9eaef8ad5b
共有 2 個文件被更改,包括 65 次插入0 次删除
  1. 62 0
      modules/topos/tps_storage.c
  2. 3 0
      modules/topos/tps_storage.h

+ 62 - 0
modules/topos/tps_storage.c

@@ -389,3 +389,65 @@ int tps_db_insert_dialog(tps_data_t *td)
 error:
 	return -1;
 }
+
+
+/**
+ *
+ */
+int tps_db_insert_branch(tps_data_t *td)
+{
+	db_key_t db_keys[TPS_NR_KEYS];
+	db_val_t db_vals[TPS_NR_KEYS];
+	int nr_keys;
+
+	memset(db_keys, 0, TPS_NR_KEYS*sizeof(db_key_t));
+	memset(db_vals, 0, TPS_NR_KEYS*sizeof(db_val_t));
+	nr_keys = 0;
+
+	db_keys[nr_keys] = &tt_col_rectime;
+	db_vals[nr_keys].type = DB1_INT;
+	db_vals[nr_keys].val.int_val = (int)time(NULL);
+	nr_keys++;
+
+	db_keys[nr_keys] = &tt_col_a_callid;
+	db_vals[nr_keys].type = DB1_STR;
+	db_vals[nr_keys].val.str_val = td->a_callid;
+	nr_keys++;
+
+	db_keys[nr_keys] = &tt_col_a_uuid;
+	db_vals[nr_keys].type = DB1_STR;
+	db_vals[nr_keys].val.str_val = td->a_uuid;
+	nr_keys++;
+
+	db_keys[nr_keys] = &tt_col_b_uuid;
+	db_vals[nr_keys].type = DB1_STR;
+	db_vals[nr_keys].val.str_val = td->b_uuid;
+	nr_keys++;
+
+	db_keys[nr_keys] = &tt_col_direction;
+	db_vals[nr_keys].type = DB1_INT;
+	db_vals[nr_keys].val.int_val = td->direction;
+	nr_keys++;
+
+	db_keys[nr_keys] = &tt_col_x_via;
+	db_vals[nr_keys].type = DB1_STR;
+	db_vals[nr_keys].val.str_val = td->x_via;
+	nr_keys++;
+
+	db_keys[nr_keys] = &tt_col_x_tag;
+	db_vals[nr_keys].type = DB1_STR;
+	db_vals[nr_keys].val.str_val = td->x_tag;
+	nr_keys++;
+
+	if(_tpsdbf.insert(_tps_db_handle, db_keys, db_vals, nr_keys) < 0)
+	{
+		LM_ERR("failed to store message\n");
+		goto error;
+	}
+
+	return 0;
+
+error:
+	return -1;
+
+}

+ 3 - 0
modules/topos/tps_storage.h

@@ -57,7 +57,10 @@ typedef struct tps_data {
 	str x_via1;
 	str x_via2;
 	str x_vbranch1;
+	str x_via;
+	str x_tag;
 	int32_t iflags;
+	int32_t direction;
 } tps_data_t;
 
 int tps_storage_dialog_find(sip_msg_t *msg, tps_data_t *td);