Module: kamailio Branch: master Commit: a9cf4577c25d7933531b8969a1941bac4faf8d68 URL: https://github.com/kamailio/kamailio/commit/a9cf4577c25d7933531b8969a1941bac...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2022-08-25T14:51:23+02:00
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
---
Modified: src/modules/tm/t_lookup.c Modified: src/modules/tm/t_lookup.h Modified: src/modules/tm/tm_load.c Modified: src/modules/tm/tm_load.h
---
Diff: https://github.com/kamailio/kamailio/commit/a9cf4577c25d7933531b8969a1941bac... Patch: https://github.com/kamailio/kamailio/commit/a9cf4577c25d7933531b8969a1941bac...
---
diff --git a/src/modules/tm/t_lookup.c b/src/modules/tm/t_lookup.c index f041116bb8..ad41f0de93 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 1f6596a90d..de65be8365 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 8635b90eae..c9f39b576e 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 4695a8f7e1..1f97061d1e 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;