From a9cf4577c25d7933531b8969a1941bac4faf8d68 Mon Sep 17 00:00:00 2001 From: Daniel-Constantin Mierla Date: Thu, 25 Aug 2022 14:51:23 +0200 Subject: [PATCH] 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 --- src/modules/tm/t_lookup.c | 22 ++++++++++++++++++++++ src/modules/tm/t_lookup.h | 3 +++ src/modules/tm/tm_load.c | 1 + src/modules/tm/tm_load.h | 1 + 4 files changed, 27 insertions(+) diff --git a/src/modules/tm/t_lookup.c b/src/modules/tm/t_lookup.c index f041116bb88..ad41f0de930 100644 --- a/src/modules/tm/t_lookup.c +++ b/src/modules/tm/t_lookup.c @@ -145,6 +145,28 @@ int get_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 ) { if (parse_headers(msg, HDR_FROM_F | HDR_CSEQ_F | HDR_TO_F, 0)==-1) { diff --git a/src/modules/tm/t_lookup.h b/src/modules/tm/t_lookup.h index 1f6596a90d6..de65be83651 100644 --- a/src/modules/tm/t_lookup.h +++ b/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); 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); int get_t_branch(void); diff --git a/src/modules/tm/tm_load.c b/src/modules/tm/tm_load.c index 8635b90eae7..c9f39b576e6 100644 --- a/src/modules/tm/tm_load.c +++ b/src/modules/tm/tm_load.c @@ -92,6 +92,7 @@ int load_tm( struct tm_binds *tmb) tmb->free_dlg = free_dlg; tmb->print_dlg = print_dlg; tmb->t_gett = get_t; + tmb->t_find = t_find; tmb->t_gett_branch = get_t_branch; tmb->t_sett = set_t; tmb->calculate_hooks = w_calculate_hooks; diff --git a/src/modules/tm/tm_load.h b/src/modules/tm/tm_load.h index 4695a8f7e16..1f97061d1e0 100644 --- a/src/modules/tm/tm_load.h +++ b/src/modules/tm/tm_load.h @@ -71,6 +71,7 @@ struct tm_binds { free_dlg_f free_dlg; print_dlg_f print_dlg; tgett_f t_gett; + tfind_f t_find; tgett_branch_f t_gett_branch; tsett_f t_sett; calculate_hooks_f calculate_hooks;