Module: kamailio Branch: master Commit: 73c8316bf89703156f241886554919339ac270d0 URL: https://github.com/kamailio/kamailio/commit/73c8316bf89703156f24188655491933...
Author: Daniel-Constantin Mierla miconda@gmail.com Committer: Daniel-Constantin Mierla miconda@gmail.com Date: 2025-06-06T10:08:12+02:00
tm: add defines for dlg cseq is_self field
- DLG_SEQ_VALINIT (should be initialized), DLG_SEQ_VALSET (is set, but can be updated for requests within dialog), DLG_SEQ_VALNEW (is set, and ready to be used as new cseq number in generated request)
---
Modified: src/modules/tm/dlg.c Modified: src/modules/tm/dlg.h Modified: src/modules/tm/rpc_uac.c Modified: src/modules/tm/uac.c
---
Diff: https://github.com/kamailio/kamailio/commit/73c8316bf89703156f24188655491933... Patch: https://github.com/kamailio/kamailio/commit/73c8316bf89703156f24188655491933...
---
diff --git a/src/modules/tm/dlg.c b/src/modules/tm/dlg.c index b99065a94c2..6c97db622af 100644 --- a/src/modules/tm/dlg.c +++ b/src/modules/tm/dlg.c @@ -357,7 +357,7 @@ int new_dlg_uac(str *_cid, str *_ltag, unsigned int _lseq, str *_luri, /* Make a copy of local sequence (usually CSeq) */ res->loc_seq.value = _lseq; /* And mark it as set */ - res->loc_seq.is_set = 1; + res->loc_seq.is_set = DLG_SEQ_VALSET;
*_d = res;
@@ -979,7 +979,7 @@ static inline int request2dlg(struct sip_msg *_m, dlg_t *_d)
if(get_cseq_value(_m, &_d->rem_seq.value) < 0) goto err3; - _d->rem_seq.is_set = 1; + _d->rem_seq.is_set = DLG_SEQ_VALSET;
if(get_dlg_uri(_m->from, &_d->rem_uri) < 0) goto err3; @@ -1149,7 +1149,7 @@ int dlg_request_uas(
/* Neither out of order nor retransmission -> update */ _d->rem_seq.value = cseq; - _d->rem_seq.is_set = 1; + _d->rem_seq.is_set = DLG_SEQ_VALSET;
/* We will als update remote target URI if the message * is target refresher diff --git a/src/modules/tm/dlg.h b/src/modules/tm/dlg.h index 732ba970bc0..ff37bc4bd9a 100644 --- a/src/modules/tm/dlg.h +++ b/src/modules/tm/dlg.h @@ -52,6 +52,10 @@ #endif /* DIALOG_CALLBACKS */
+#define DLG_SEQ_VALINIT 0 +#define DLG_SEQ_VALSET 1 +#define DLG_SEQ_VALNEW 2 + /* * Dialog sequence */ diff --git a/src/modules/tm/rpc_uac.c b/src/modules/tm/rpc_uac.c index 285f3c7e9eb..3cd99a4d9c6 100644 --- a/src/modules/tm/rpc_uac.c +++ b/src/modules/tm/rpc_uac.c @@ -757,7 +757,7 @@ static void rpc_t_uac(rpc_t *rpc, void *c, int reply_wait, int cbflags) dlg.loc_seq.value = cseq; else dlg.loc_seq.value = DEFAULT_CSEQ; - dlg.loc_seq.is_set = 1; + dlg.loc_seq.is_set = DLG_SEQ_VALSET;
dlg.loc_uri = get_from(&faked_msg)->uri; dlg.rem_uri = get_to(&faked_msg)->uri; @@ -1077,7 +1077,7 @@ int t_uac_send(str *method, str *ruri, str *nexthop, str *send_socket, dlg.loc_seq.value = cseq; else dlg.loc_seq.value = DEFAULT_CSEQ; - dlg.loc_seq.is_set = 1; + dlg.loc_seq.is_set = DLG_SEQ_VALSET;
dlg.loc_uri = get_from(&faked_msg)->uri; dlg.rem_uri = get_to(&faked_msg)->uri; diff --git a/src/modules/tm/uac.c b/src/modules/tm/uac.c index a9a327745ec..26748f4570c 100644 --- a/src/modules/tm/uac.c +++ b/src/modules/tm/uac.c @@ -451,11 +451,11 @@ static inline int t_uac_prepare( /* if err's returned, the message is incorrect */ goto error3;
- if(!uac_r->dialog->loc_seq.is_set) { + if(uac_r->dialog->loc_seq.is_set == DLG_SEQ_VALINIT) { /* this is the first request in the dialog, set cseq to default value now - Miklos */ uac_r->dialog->loc_seq.value = DEFAULT_CSEQ; - uac_r->dialog->loc_seq.is_set = 1; + uac_r->dialog->loc_seq.is_set = DLG_SEQ_VALSET; }
/* build cell sets X/AVP lists to new transaction structure @@ -677,7 +677,9 @@ int prepare_req_within(uac_req_t *uac_r, struct retr_buf **dst_req) goto send; if((uac_r->method->len == 6) && (!memcmp("CANCEL", uac_r->method->s, 6))) goto send; - uac_r->dialog->loc_seq.value++; /* Increment CSeq */ + if(uac_r->dialog->loc_seq.is_set != DLG_SEQ_VALNEW) { + uac_r->dialog->loc_seq.value++; /* Increment CSeq */ + } send: ret = t_uac_prepare(uac_r, dst_req, 0);