Browse code

to_tags now generated all the time from TM

Jiri Kuthan authored on 21/10/2002 21:24:43
Showing 5 changed files
... ...
@@ -94,4 +94,7 @@
94 94
 */
95 95
 #undef ACK_FORKING_HACK
96 96
 
97
+/* to-tag separator for stateful processing */
98
+#define TM_TAG_SEPARATOR '-'
99
+
97 100
 #endif
... ...
@@ -38,6 +38,7 @@
38 38
 #include "../../error.h"
39 39
 #include "../../action.h"
40 40
 #include "../../dset.h"
41
+#include "../../tags.h"
41 42
 
42 43
 #include "t_hooks.h"
43 44
 #include "t_funcs.h"
... ...
@@ -49,6 +50,10 @@
49 49
 #include "fix_lumps.h"
50 50
 #include "t_stats.h"
51 51
 
52
+/* private place where we create to-tags for replies */
53
+static char tm_tags[TOTAG_LEN];
54
+static char *tm_tag_suffix;
55
+
52 56
 /* where to go if there is no positive reply */
53 57
 static int goto_on_negative=0;
54 58
 
... ...
@@ -74,6 +79,13 @@ unsigned int get_on_negative()
74 74
 	return goto_on_negative;
75 75
 }
76 76
 
77
+void tm_init_tags()
78
+{
79
+	init_tags(tm_tags, &tm_tag_suffix, 
80
+		"SER-TM/tags", TM_TAG_SEPARATOR );
81
+}
82
+
83
+
77 84
 static char *build_ack(struct sip_msg* rpl,struct cell *trans,int branch,
78 85
 	unsigned int *ret_len)
79 86
 {
... ...
@@ -336,9 +348,19 @@ static int _reply( struct cell *trans, struct sip_msg* p_msg,
336 336
 		trans->uas.tag->len, trans->uas.request,&len);
337 337
 	*/
338 338
 	cancel_bitmap=0;
339
-	/* compute the buffer in private memory prior to entering lock */
340
-	buf = build_res_buf_from_sip_req(code,text, 0,0, /* no to-tag */
341
-		p_msg,&len);
339
+	/* compute the buffer in private memory prior to entering lock;
340
+	 * create to-tag if needed */
341
+	if (code>=180 && p_msg->to 
342
+			&& (get_to(p_msg)->tag_value.s==0 
343
+			    || get_to(p_msg)->tag_value.len==0)) {
344
+		calc_crc_suffix( p_msg, tm_tag_suffix );
345
+		buf = build_res_buf_from_sip_req(code,text, 
346
+				tm_tags, TOTAG_LEN, 
347
+				p_msg,&len);
348
+	} else {
349
+		buf = build_res_buf_from_sip_req(code,text, 0,0, /* no to-tag */
350
+			p_msg,&len);
351
+	}
342 352
 	DBG("DEBUG: t_reply: buffer computed\n");
343 353
 	if (!buf)
344 354
 	{
... ...
@@ -536,9 +558,22 @@ enum rps relay_reply( struct cell *t, struct sip_msg *p_msg, int branch,
536 536
 			tm_stats->replied_localy++;
537 537
 			relayed_code = branch==relay
538 538
 				? msg_status : t->uac[relay].last_received;
539
-			buf = build_res_buf_from_sip_req( relayed_code,
540
-				error_text(relayed_code), 0,0, /* no to-tag */
541
-				t->uas.request, &res_len );
539
+
540
+			if (relayed_code>=180 && t->uas.request->to 
541
+					&& (get_to(t->uas.request)->tag_value.s==0 
542
+			    		|| get_to(t->uas.request)->tag_value.len==0)) {
543
+				calc_crc_suffix( t->uas.request, tm_tag_suffix );
544
+				buf = build_res_buf_from_sip_req(
545
+						relayed_code,
546
+						error_text(relayed_code),
547
+						tm_tags, TOTAG_LEN, 
548
+						t->uas.request, &res_len );
549
+			} else {
550
+				buf = build_res_buf_from_sip_req( relayed_code,
551
+					error_text(relayed_code), 0,0, /* no to-tag */
552
+					t->uas.request, &res_len );
553
+			}
554
+
542 555
 		} else {
543 556
 			relayed_code=relayed_msg->REPLY_STATUS;
544 557
 			buf = build_res_buf_from_sip_res( relayed_msg, &res_len );
... ...
@@ -109,5 +109,7 @@ unsigned int get_on_negative();
109 109
 
110 110
 int t_retransmit_reply( struct cell *t );
111 111
 
112
+void tm_init_tags();
113
+
112 114
 #endif
113 115
 
... ...
@@ -338,6 +338,8 @@ static int mod_init(void)
338 338
 	register_script_cb( script_init, PRE_SCRIPT_CB , 
339 339
 			0 /* empty param */ );
340 340
 
341
+	tm_init_tags();
342
+
341 343
 	return 0;
342 344
 }
343 345
 
... ...
@@ -60,7 +60,7 @@ static inline void calc_crc_suffix( struct sip_msg *msg, char *tag_suffix)
60 60
         crcitt_string_array( tag_suffix, suffix_source, ss_nr );
61 61
 }
62 62
 
63
-static inline init_tags( char *tag, char **suffix, 
63
+static void inline init_tags( char *tag, char **suffix, 
64 64
 		char *signature, char separator )
65 65
 {
66 66
 	str src[3];