Skip to content

Commit

Permalink
tm: clang-format for coherent indentation and coding style
Browse files Browse the repository at this point in the history
  • Loading branch information
linuxmaniac committed May 18, 2023
1 parent 5a347dd commit 7769324
Show file tree
Hide file tree
Showing 43 changed files with 7,112 additions and 6,817 deletions.
2 changes: 1 addition & 1 deletion src/modules/tm/callid.c
Expand Up @@ -52,7 +52,7 @@
+ 42 /* embedded v4inv6 address can be looong '128.' */ \
+ 2 /* parenthesis [] */ + 1 /* ZT 0 */ \
+ 16 /* one never knows ;-) */ \
)
)


static unsigned long callid_nr;
Expand Down
311 changes: 159 additions & 152 deletions src/modules/tm/config.c

Large diffs are not rendered by default.

99 changes: 50 additions & 49 deletions src/modules/tm/config.h
Expand Up @@ -40,32 +40,32 @@
#include "../../core/str.h"

/* maximum length of localy generated acknowledgment */
#define MAX_ACK_LEN 1024
#define MAX_ACK_LEN 1024

/* FINAL_RESPONSE_TIMER ... tells how long should the transaction engine
wait if no final response comes back*/
#define FR_TIME_OUT 30000 /* ms */
#define INV_FR_TIME_OUT 120000 /* ms */
#define FR_TIME_OUT 30000 /* ms */
#define INV_FR_TIME_OUT 120000 /* ms */

/*! \brief final response timers to be used for serial forwarding */
#define INV_FR_TIME_OUT_NEXT 30000 /* ms */
#define INV_FR_TIME_OUT_NEXT 30000 /* ms */

/* WAIT timer ... tells how long state should persist in memory after
a transaction was finalized*/
#define WT_TIME_OUT 5000 /* ms */
#define WT_TIME_OUT 5000 /* ms */

/* retransmission timers */
#define RETR_T1 500 /* ms */
#define RETR_T2 4000 /* ms */
#define RETR_T1 500 /* ms */
#define RETR_T2 4000 /* ms */

/* maximum total lifetime for an INVITE or non-INVITE transaction
* Note: after this time the transaction will not be deleted
* immediately, but forced to go in the wait state or in wait for ack state
* and then wait state, so it will still be alive for either WT_TIME_OUT in
* the non-inv or "silent" inv. case and for FR_TIME_OUT + WT_TIME_OUT for an
* invite transaction (for which we must wait for the neg. reply ack)*/
#define MAX_INV_LIFETIME 180000 /* ms, rfc min. C-timer value */
#define MAX_NONINV_LIFETIME 32000 /* ms, rfc timer F value */
#define MAX_INV_LIFETIME 180000 /* ms, rfc min. C-timer value */
#define MAX_NONINV_LIFETIME 32000 /* ms, rfc timer F value */

/* when first reply is sent, this additional space is allocated so that
one does not have to reallocate share memory when the message is
Expand All @@ -75,10 +75,10 @@
#define TAG_OVERBUFFER_LEN 32

/* dimensions of FIFO server */
#define MAX_METHOD 64
#define MAX_HEADER 1024
#define MAX_BODY 1024
#define MAX_DST 512
#define MAX_METHOD 64
#define MAX_HEADER 1024
#define MAX_BODY 1024
#define MAX_DST 512
#define MAX_FROM 512

/* messages generated by server */
Expand All @@ -92,39 +92,40 @@
/* FIFO substitution character */
#define SUBST_CHAR '!'

struct cfg_group_tm {
char *tm_auto_inv_100_r;
char *default_reason;
str ac_extra_hdrs;
int ruri_matching;
int via1_matching;
int callid_matching;
int callid_cseq_matching;
unsigned int fr_timeout;
unsigned int fr_inv_timeout;
unsigned int fr_inv_timeout_next;
unsigned int wait_timeout;
unsigned int rt_t1_timeout_ms;
unsigned int rt_t2_timeout_ms;
unsigned int tm_max_inv_lifetime;
unsigned int tm_max_noninv_lifetime;
int noisy_ctimer;
int tm_auto_inv_100;
int tm_unix_tx_timeout;
int restart_fr_on_each_reply;
int pass_provisional_replies;
int tm_aggregate_auth;
int unmatched_cancel;
int default_code;
int reparse_invite;
int tm_blst_503;
int tm_blst_503_default;
int tm_blst_503_min;
int tm_blst_503_max;
unsigned int tm_blst_methods_add;
unsigned int tm_blst_methods_lookup;
unsigned int cancel_b_flags;
int reparse_on_dns_failover;
struct cfg_group_tm
{
char *tm_auto_inv_100_r;
char *default_reason;
str ac_extra_hdrs;
int ruri_matching;
int via1_matching;
int callid_matching;
int callid_cseq_matching;
unsigned int fr_timeout;
unsigned int fr_inv_timeout;
unsigned int fr_inv_timeout_next;
unsigned int wait_timeout;
unsigned int rt_t1_timeout_ms;
unsigned int rt_t2_timeout_ms;
unsigned int tm_max_inv_lifetime;
unsigned int tm_max_noninv_lifetime;
int noisy_ctimer;
int tm_auto_inv_100;
int tm_unix_tx_timeout;
int restart_fr_on_each_reply;
int pass_provisional_replies;
int tm_aggregate_auth;
int unmatched_cancel;
int default_code;
int reparse_invite;
int tm_blst_503;
int tm_blst_503_default;
int tm_blst_503_min;
int tm_blst_503_max;
unsigned int tm_blst_methods_add;
unsigned int tm_blst_methods_lookup;
unsigned int cancel_b_flags;
int reparse_on_dns_failover;
int disable_6xx;
int local_ack_mode;
int local_cancel_reason;
Expand All @@ -133,8 +134,8 @@ struct cfg_group_tm {
int enable_uac_fr;
};

extern struct cfg_group_tm default_tm_cfg;
extern void *tm_cfg;
extern cfg_def_t tm_cfg_def[];
extern struct cfg_group_tm default_tm_cfg;
extern void *tm_cfg;
extern cfg_def_t tm_cfg_def[];

#endif
2 changes: 1 addition & 1 deletion src/modules/tm/dlg.c
Expand Up @@ -44,7 +44,7 @@
#include "callid.h"
#include "uac.h"

#define NORMAL_ORDER 0 /* Create route set in normal order - UAS */
#define NORMAL_ORDER 0 /* Create route set in normal order - UAS */
#define REVERSE_ORDER 1 /* Create route set in reverse order - UAC */


Expand Down
20 changes: 11 additions & 9 deletions src/modules/tm/dlg.h
Expand Up @@ -55,17 +55,18 @@
*/
typedef struct dlg_seq
{
unsigned int value; /* Sequence value */
unsigned int value; /* Sequence value */
unsigned char is_set; /* is_set flag */
} dlg_seq_t;


/*
* Dialog state
*/
typedef enum dlg_state {
typedef enum dlg_state
{
DLG_NEW = 0, /* New dialog, no reply received yet */
DLG_EARLY, /* Early dialog, provisional response received */
DLG_EARLY, /* Early dialog, provisional response received */
DLG_CONFIRMED, /* Confirmed dialog, 2xx received */
DLG_DESTROYED /* Destroyed dialog */
} dlg_state_t;
Expand Down Expand Up @@ -95,7 +96,7 @@ typedef struct dlg_hooks
str ru;
str nh;
str *request_uri; /* This should be put into Request-URI */
str *next_hop; /* Where the message should be really sent */
str *next_hop; /* Where the message should be really sent */
rr_t *first_route; /* First route to be printed into the message */
str *last_route; /* If not zero add this as the last route */
} dlg_hooks_t;
Expand All @@ -107,18 +108,18 @@ typedef struct dlg_hooks
typedef struct dlg
{
dlg_id_t id; /* Dialog identifier */
dlg_seq_t loc_seq; /* Local sequence number */
dlg_seq_t rem_seq; /* Remote sequence number */
dlg_seq_t loc_seq; /* Local sequence number */
dlg_seq_t rem_seq; /* Remote sequence number */
str loc_uri; /* Local URI */
str rem_uri; /* Remote URI */
str rem_target; /* Remote target URI */
str dst_uri; /* Destination URI */
str loc_dname; /* Local Display Name */
str rem_dname; /* Remote Display Name */
unsigned char secure; /* Secure flag -- currently not used */
dlg_state_t state; /* State of the dialog */
dlg_state_t state; /* State of the dialog */
rr_t *route_set; /* Route set */
dlg_hooks_t hooks; /* Various hooks used to store information that
dlg_hooks_t hooks; /* Various hooks used to store information that
* can be reused when building a message (to
* prevent repeated analyzing of the dialog data
*/
Expand All @@ -128,7 +129,8 @@ typedef struct dlg
#endif
} dlg_t;

typedef enum {
typedef enum
{
IS_TARGET_REFRESH,
IS_NOT_TARGET_REFRESH,
TARGET_REFRESH_UNKNOWN
Expand Down
37 changes: 18 additions & 19 deletions src/modules/tm/h_table.c
Expand Up @@ -47,8 +47,9 @@
#include "uac.h" /* free_local_ack */


#define T_UAC_PTR(T) ((tm_ua_client_t*)((char*)T + sizeof(tm_cell_t) \
+ MD5_LEN - sizeof(((tm_cell_t*)0)->md5)))
#define T_UAC_PTR(T) \
((tm_ua_client_t *)((char *)T + sizeof(tm_cell_t) + MD5_LEN \
- sizeof(((tm_cell_t *)0)->md5)))


static enum kill_reason kr;
Expand Down Expand Up @@ -131,7 +132,7 @@ void free_cell_helper(

LM_DBG("freeing transaction %p from %s:%u\n", dead_cell, fname, fline);

if(dead_cell==NULL) {
if(dead_cell == NULL) {
return;
}

Expand All @@ -153,10 +154,10 @@ void free_cell_helper(
release_cell_lock(dead_cell); /* does nothing */

dead_cell->fcount++;
if(dead_cell->fcount!=1) {
if(dead_cell->fcount != 1) {
LM_WARN("unexpected fcount value: %d\n", dead_cell->fcount);
}
if(dead_cell->uac==NULL || dead_cell->uac!=T_UAC_PTR(dead_cell)) {
if(dead_cell->uac == NULL || dead_cell->uac != T_UAC_PTR(dead_cell)) {
LM_WARN("unexpected tm cell content: %p\n", dead_cell);
return;
}
Expand Down Expand Up @@ -204,8 +205,9 @@ void free_cell_helper(
#ifdef USE_DNS_FAILOVER
if(dead_cell->uac[i].dns_h.a) {
LM_DBG("branch %d -> dns_h.srv (%.*s) ref=%d,"
" dns_h.a (%.*s) ref=%d\n",
i, dead_cell->uac[i].dns_h.srv
" dns_h.a (%.*s) ref=%d\n",
i,
dead_cell->uac[i].dns_h.srv
? dead_cell->uac[i].dns_h.srv->name_len
: 0,
dead_cell->uac[i].dns_h.srv
Expand Down Expand Up @@ -599,21 +601,18 @@ void tm_xdata_replace(tm_xdata_t *newxd, tm_xlinks_t *bakxd)
void tm_log_transaction(tm_cell_t *tcell, int llev, char *ltext)
{
LOG(llev, "%s [start] transaction %p\n", ltext, tcell);
LOG(llev, "%s - tindex=%u tlabel=%u method='%.*s' from_hdr='%.*s'"
LOG(llev,
"%s - tindex=%u tlabel=%u method='%.*s' from_hdr='%.*s'"
" to_hdr='%.*s' callid_hdr='%.*s' cseq_hdr='%.*s' uas_request=%s"
" tflags=%u outgoings=%u ref_count=%u lifetime=%u\n",
ltext, (unsigned)tcell->hash_index, (unsigned)tcell->label,
tcell->method.len, tcell->method.s,
tcell->from_hdr.len, tcell->from_hdr.s,
tcell->to_hdr.len, tcell->to_hdr.s,
tcell->callid_hdr.len, tcell->callid_hdr.s,
tcell->cseq_hdr_n.len, tcell->cseq_hdr_n.s,
(tcell->uas.request)?"yes":"no",
(unsigned)tcell->flags,
(unsigned)tcell->nr_of_outgoings,
tcell->method.len, tcell->method.s, tcell->from_hdr.len,
tcell->from_hdr.s, tcell->to_hdr.len, tcell->to_hdr.s,
tcell->callid_hdr.len, tcell->callid_hdr.s, tcell->cseq_hdr_n.len,
tcell->cseq_hdr_n.s, (tcell->uas.request) ? "yes" : "no",
(unsigned)tcell->flags, (unsigned)tcell->nr_of_outgoings,
(unsigned)atomic_get(&tcell->ref_count),
(unsigned)TICKS_TO_S(tcell->end_of_life)
);
(unsigned)TICKS_TO_S(tcell->end_of_life));

LOG(llev, "%s [end] transaction %p\n", ltext, tcell);
}
Expand All @@ -628,7 +627,7 @@ void tm_clean_lifetime(void)

texp = get_ticks_raw() - S_TO_TICKS(TM_LIFETIME_LIMIT);

for (r=0; r<TABLE_ENTRIES; r++) {
for(r = 0; r < TABLE_ENTRIES; r++) {
/* faster first try without lock */
if(clist_empty(&_tm_table->entries[r], next_c)) {
continue;
Expand Down
28 changes: 15 additions & 13 deletions src/modules/tm/h_table.h
Expand Up @@ -143,9 +143,9 @@ typedef struct retr_buf
* 0 (TYPE_REQUEST) if request, -1 if local CANCEL (TYPE_LOCAL_CANCEL),
* -2 if local ACK (TYPE_LOCAL_ACK) */
short rbtype;
volatile unsigned short flags; /* DISABLED, T2 */
volatile unsigned short flags; /* DISABLED, T2 */
volatile unsigned short t_active; /* timer active */
unsigned short branch; /* no more than 64k branches */
unsigned short branch; /* no more than 64k branches */
int buffer_len;
char *buffer;
/*the cell that contains this retrans_buff*/
Expand Down Expand Up @@ -177,10 +177,10 @@ typedef struct ua_server
/* User Agent Client content */

/* UAC internal flags */
#define TM_UAC_FLAG_RR (1) /* Record-Route applied */
#define TM_UAC_FLAG_R2 (1 << 1) /* 2nd Record-Route applied */
#define TM_UAC_FLAG_FB (1 << 2) /* Mark first entry in new branch set */
#define TM_UAC_FLAG_BLIND (1 << 3) /* A blind uac */
#define TM_UAC_FLAG_RR (1) /* Record-Route applied */
#define TM_UAC_FLAG_R2 (1 << 1) /* 2nd Record-Route applied */
#define TM_UAC_FLAG_FB (1 << 2) /* Mark first entry in new branch set */
#define TM_UAC_FLAG_BLIND (1 << 3) /* A blind uac */

typedef struct ua_client
{
Expand Down Expand Up @@ -268,14 +268,15 @@ typedef struct async_state
/* 6xx received => stop forking */
#define T_6xx (1 << 4)

#define T_IN_AGONY (1 << 5) /* set if waiting to die (delete timer)
#define T_IN_AGONY \
(1 << 5) /* set if waiting to die (delete timer)
* TODO: replace it with del on unref */
#define T_AUTO_INV_100 (1 << 6) /* send an 100 reply automatically to inv. */
/* don't generate automatically an ACK for local transaction */
#define T_NO_AUTO_ACK (1 << 7)

#define T_DISABLE_6xx (1 << 8) /* treat 6xx as a normal reply */
#define T_DISABLE_FAILOVER (1 << 9) /* don't perform dns failover */
#define T_DISABLE_6xx (1 << 8) /* treat 6xx as a normal reply */
#define T_DISABLE_FAILOVER (1 << 9) /* don't perform dns failover */
#define T_NO_E2E_CANCEL_REASON (1 << 10) /* don't propagate CANCEL Reason */
#define T_DONT_FORK (T_CANCELED | T_6xx)

Expand Down Expand Up @@ -387,7 +388,7 @@ typedef struct cell

/* bindings to wait and delete timer */
struct timer_ln wait_timer; /* used also for delete */
ticks_t wait_start; /* ticks when put on wait first time */
ticks_t wait_start; /* ticks when put on wait first time */

/* UA Server */
struct ua_server uas;
Expand Down Expand Up @@ -424,7 +425,7 @@ typedef struct cell
ticks_t fr_inv_timeout; /* final inv. response interval for retr_bufs */
retr_timeout_t rt_t1_timeout_ms; /* start retr. interval for retr_bufs */
retr_timeout_t rt_t2_timeout_ms; /* maximum retr. interval for retr_bufs */
ticks_t end_of_life; /* maximum lifetime */
ticks_t end_of_life; /* maximum lifetime */

/* nr of replied branch; 0..sr_dst_max_branches=branch value,
* -1 no reply, -2 local reply */
Expand All @@ -449,7 +450,8 @@ typedef struct cell

#if 0
/* warning: padding too much => big size increase */
#define ENTRY_PAD_TO 128 /* should be a multiple of cacheline size for
#define ENTRY_PAD_TO \
128 /* should be a multiple of cacheline size for
* best performance*/
#define ENTRY_PAD_BYTES \
(ENTRY_PAD_TO - 2 * sizeof(struct cell *) + sizeof(ser_lock_t) \
Expand All @@ -468,7 +470,7 @@ typedef struct entry
/* sync mutex */
ser_lock_t mutex;
atomic_t locker_pid; /* pid of the process that holds the lock */
int rec_lock_level; /* recursive lock count */
int rec_lock_level; /* recursive lock count */
/* currently highest sequence number in a synonym list */
unsigned int next_label;
#ifdef TM_HASH_STATS
Expand Down

0 comments on commit 7769324

Please sign in to comment.