Browse code

acc: add to-tag for locally generated replies

Julien Chavanton authored on 28/07/2020 23:22:42
Showing 3 changed files
... ...
@@ -123,6 +123,13 @@ int core2strar(struct sip_msg *req, str *c_vals, int *i_vals, char *t_vals)
123 123
 		t_vals[2] = TYPE_NULL;
124 124
 	}
125 125
 
126
+	LM_ERR("default - totag[%*.s]\n", c_vals[2].len, c_vals[2].s);
127
+	if (c_vals[2].len == 0 && acc_env.to_tag.s && acc_env.to_tag.len > 0) {
128
+		LM_ERR("extra [%p] totag[%.*s]\n", acc_env.to_tag.s, acc_env.to_tag.len, acc_env.to_tag.s);
129
+		c_vals[2].len = acc_env.to_tag.len;
130
+		c_vals[2].s = acc_env.to_tag.s;
131
+	}
132
+
126 133
 	/* Callid */
127 134
 	if (req->callid && req->callid->body.len) {
128 135
 		c_vals[3] = req->callid->body;
... ...
@@ -54,6 +54,7 @@ typedef struct acc_enviroment {
54 54
 	str code_s;
55 55
 	str reason;
56 56
 	struct hdr_field *to;
57
+	str to_tag; // sometimes needed if not present yet in a reply
57 58
 	str text;
58 59
 	time_t ts;
59 60
 	struct timeval tv;
... ...
@@ -79,8 +79,7 @@ struct acc_enviroment acc_env;
79 79
 static void tmcb_func( struct cell* t, int type, struct tmcb_params *ps );
80 80
 
81 81
 
82
-static inline struct hdr_field* get_rpl_to( struct cell *t,
83
-														struct sip_msg *reply)
82
+static inline struct hdr_field* get_rpl_to( struct cell *t, struct sip_msg *reply)
84 83
 {
85 84
 	if (reply==FAKED_REPLY || !reply || !reply->to)
86 85
 		return t->uas.request->to;
... ...
@@ -88,12 +87,21 @@ static inline struct hdr_field* get_rpl_to( struct cell *t,
88 87
 		return reply->to;
89 88
 }
90 89
 
90
+void get_rpl_totag(struct cell *t, struct sip_msg *reply, str *totag)
91
+{
92
+	if (reply==FAKED_REPLY || !reply || !reply->to)
93
+                tmb.t_get_reply_totag(t->uas.request, totag);
94
+}
91 95
 
92 96
 static inline void env_set_to(struct hdr_field *to)
93 97
 {
94 98
 	acc_env.to = to;
95 99
 }
96 100
 
101
+// static inline void env_set_totag(str *to_tag)
102
+// {
103
+// 	acc_env.to_tag = to_tag;
104
+// }
97 105
 
98 106
 static inline void env_set_text(char *p, int len)
99 107
 {
... ...
@@ -372,6 +380,9 @@ void acc_onreq( struct cell* t, int type, struct tmcb_params *ps )
372 380
 	int tmcb_types;
373 381
 	int is_invite;
374 382
 
383
+	LM_ERR("is_mc_on: %d\n", is_mc_on(ps->req));
384
+	LM_ERR("is_acc_on: %d\n", is_acc_on(ps->req));
385
+	LM_ERR("is_acc_prepare_on: %d\n", is_acc_prepare_on(ps->req));
375 386
 	if ( ps->req && !skip_cancel(ps->req) &&
376 387
 			( is_acc_on(ps->req) || is_mc_on(ps->req)
377 388
 				|| is_acc_prepare_on(ps->req) ) ) {
... ...
@@ -493,7 +504,9 @@ static inline void on_missed(struct cell *t, struct sip_msg *req,
493 504
 
494 505
 	/* set env variables */
495 506
 	env_set_to( get_rpl_to(t,reply) );
496
-	env_set_code_status( code, reply);
507
+	env_set_code_status(code, reply);
508
+	get_rpl_totag(t, reply, &acc_env.to_tag);
509
+	LM_ERR(">>> acc_env.to_tag[%p][%d][%.*s]\n", acc_env.to_tag.s, acc_env.to_tag.len, acc_env.to_tag.len, acc_env.to_tag.s);
497 510
 
498 511
 	/* we report on missed calls when the first
499 512
 	 * forwarding attempt fails; we do not wish to
... ...
@@ -512,7 +525,6 @@ static inline void on_missed(struct cell *t, struct sip_msg *req,
512 525
 		acc_db_request( req );
513 526
 		flags_to_reset |= 1 << db_missed_flag;
514 527
 	}
515
-
516 528
 	/* run extra acc engines */
517 529
 	acc_run_engines(req, 1, &flags_to_reset);
518 530