Jelajahi Sumber

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)

(cherry picked from commit 73c8316bf89703156f241886554919339ac270d0)
Daniel-Constantin Mierla 3 bulan lalu
induk
melakukan
082a07138b
4 mengubah file dengan 14 tambahan dan 8 penghapusan
  1. 3 3
      src/modules/tm/dlg.c
  2. 4 0
      src/modules/tm/dlg.h
  3. 2 2
      src/modules/tm/rpc_uac.c
  4. 5 3
      src/modules/tm/uac.c

+ 3 - 3
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

+ 4 - 0
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
  */

+ 2 - 2
src/modules/tm/rpc_uac.c

@@ -757,7 +757,7 @@ static void rpc_t_uac(rpc_t *rpc, void *c, int reply_wait)
 		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;
@@ -1052,7 +1052,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;

+ 5 - 3
src/modules/tm/uac.c

@@ -497,11 +497,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
@@ -723,7 +723,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);