فهرست منبع

tm: new inter-module API function t_find(...)

- combines get_t() with t_check_msg(...) to get the transaction,
  returning also if it was referenced or not
Daniel-Constantin Mierla 3 سال پیش
والد
کامیت
a9cf4577c2
4فایلهای تغییر یافته به همراه27 افزوده شده و 0 حذف شده
  1. 22 0
      src/modules/tm/t_lookup.c
  2. 3 0
      src/modules/tm/t_lookup.h
  3. 1 0
      src/modules/tm/tm_load.c
  4. 1 0
      src/modules/tm/tm_load.h

+ 22 - 0
src/modules/tm/t_lookup.c

@@ -145,6 +145,28 @@ int get_t_branch()
 	return T_branch;
 	return T_branch;
 }
 }
 
 
+/**
+ * return the transaction by combining get() and t_check_msg()
+ * - if T is not set, checks the transactions table for msg, and if found,
+ *   sets T and *branch as well as *vref=1 to signal that T was ref'ed
+ */
+struct cell* t_find(struct sip_msg *msg, int *branch, int *vref)
+{
+	if(vref) {
+		*vref = 0;
+	}
+	if(T != NULL && T != T_UNDEFINED) {
+		return T;
+	}
+	t_check_msg(msg, branch);
+	if(T != NULL && T != T_UNDEFINED) {
+		if(vref) {
+			*vref = 1;
+		}
+	}
+	return T;
+}
+
 static inline int parse_dlg( struct sip_msg *msg )
 static inline int parse_dlg( struct sip_msg *msg )
 {
 {
 	if (parse_headers(msg, HDR_FROM_F | HDR_CSEQ_F | HDR_TO_F, 0)==-1) {
 	if (parse_headers(msg, HDR_FROM_F | HDR_CSEQ_F | HDR_TO_F, 0)==-1) {

+ 3 - 0
src/modules/tm/t_lookup.h

@@ -68,6 +68,9 @@ int t_check_msg(struct sip_msg* , int *branch );
 typedef struct cell * (*tgett_f)(void);
 typedef struct cell * (*tgett_f)(void);
 struct cell *get_t(void);
 struct cell *get_t(void);
 
 
+typedef struct cell* (*tfind_f)(struct sip_msg*, int*, int*);
+struct cell* t_find(struct sip_msg *msg, int *branch, int *vref);
+
 typedef int (*tgett_branch_f)(void);
 typedef int (*tgett_branch_f)(void);
 int get_t_branch(void);
 int get_t_branch(void);
 
 

+ 1 - 0
src/modules/tm/tm_load.c

@@ -92,6 +92,7 @@ int load_tm( struct tm_binds *tmb)
 	tmb->free_dlg = free_dlg;
 	tmb->free_dlg = free_dlg;
 	tmb->print_dlg = print_dlg;
 	tmb->print_dlg = print_dlg;
 	tmb->t_gett = get_t;
 	tmb->t_gett = get_t;
+	tmb->t_find = t_find;
 	tmb->t_gett_branch = get_t_branch;
 	tmb->t_gett_branch = get_t_branch;
 	tmb->t_sett = set_t;
 	tmb->t_sett = set_t;
 	tmb->calculate_hooks = w_calculate_hooks;
 	tmb->calculate_hooks = w_calculate_hooks;

+ 1 - 0
src/modules/tm/tm_load.h

@@ -71,6 +71,7 @@ struct tm_binds {
 	free_dlg_f         free_dlg;
 	free_dlg_f         free_dlg;
 	print_dlg_f        print_dlg;
 	print_dlg_f        print_dlg;
 	tgett_f            t_gett;
 	tgett_f            t_gett;
+	tfind_f            t_find;
 	tgett_branch_f     t_gett_branch;
 	tgett_branch_f     t_gett_branch;
 	tsett_f            t_sett;
 	tsett_f            t_sett;
 	calculate_hooks_f  calculate_hooks;
 	calculate_hooks_f  calculate_hooks;