Browse code

added features: - possibility of automatical tag generation when creating dialog - exported uac_t function (will be used from dialog module) - added parameter next_hop to t_request for sending request through "proxy"

Vaclav Kubart authored on 30/01/2006 15:56:29
Showing 6 changed files
... ...
@@ -45,6 +45,9 @@
45 45
 #include "t_reply.h"
46 46
 #include "../../parser/parser_f.h"
47 47
 
48
+/* next added to allow automatical tag generation */
49
+#include "callid.h"
50
+#include "uac.h"
48 51
 
49 52
 #define NORMAL_ORDER 0  /* Create route set in normal order - UAS */
50 53
 #define REVERSE_ORDER 1 /* Create route set in reverse order - UAC */
... ...
@@ -130,7 +133,10 @@ static inline int calculate_hooks(dlg_t* _d)
130 133
 			_d->hooks.request_uri = &_d->route_set->nameaddr.uri;
131 134
 			_d->hooks.next_hop = _d->hooks.request_uri;
132 135
 			_d->hooks.first_route = _d->route_set->next;
133
-			_d->hooks.last_route = &_d->rem_target;
136
+			if (_d->rem_target.len > 0) 
137
+				_d->hooks.last_route = &_d->rem_target;
138
+			else 
139
+				_d->hooks.last_route = NULL; /* ? */
134 140
 		}
135 141
 	} else {
136 142
 		if (_d->rem_target.s) _d->hooks.request_uri = &_d->rem_target;
... ...
@@ -169,6 +175,18 @@ int w_calculate_hooks(dlg_t* _d)
169 175
 int new_dlg_uac(str* _cid, str* _ltag, unsigned int _lseq, str* _luri, str* _ruri, dlg_t** _d)
170 176
 {
171 177
 	dlg_t* res;
178
+	str generated_cid;
179
+	str generated_ltag;
180
+
181
+	if (!_cid) { /* if not given, compute new one */
182
+		generate_callid(&generated_cid);
183
+		_cid = &generated_cid;
184
+	}
185
+	if (_cid && (!_ltag)) { /* if not given, compute new one */
186
+		generate_fromtag(&generated_ltag, _cid);
187
+		_ltag = &generated_ltag;
188
+	}
189
+	if (_lseq == 0) _lseq = DEFAULT_CSEQ;
172 190
 
173 191
 	if (!_cid || !_ltag || !_luri || !_ruri || !_d) {
174 192
 		LOG(L_ERR, "new_dlg_uac(): Invalid parameter value\n");
... ...
@@ -262,6 +262,7 @@ static cmd_export_t cmds[]={
262 262
 	{"print_dlg",          (cmd_function)print_dlg,         NO_SCRIPT,   0, 0},
263 263
 	{T_GETT,               (cmd_function)get_t,             NO_SCRIPT,   0, 0},
264 264
 	{"calculate_hooks",    (cmd_function)w_calculate_hooks, NO_SCRIPT,   0, 0},
265
+	{"t_uac",              (cmd_function)t_uac,             NO_SCRIPT,   0, 0},
265 266
 	{0,0,0,0,0}
266 267
 };
267 268
 
... ...
@@ -152,6 +152,10 @@ int load_tm( struct tm_binds *tmb)
152 152
 		LOG( L_ERR, LOAD_ERROR "' calculate_hooks ' not found\n");
153 153
 		return -1;
154 154
 	}
155
+	if (!(tmb->t_uac=(t_uac_t)find_export("t_uac", NO_SCRIPT, 0)) ) {
156
+		LOG( L_ERR, LOAD_ERROR "'t_uac' not found\n");
157
+		return -1;
158
+	}
155 159
 
156 160
 	tmb->route_mode = &rmode;
157 161
 	return 1;
... ...
@@ -99,6 +99,7 @@ struct tm_binds {
99 99
 	print_dlg_f        print_dlg;
100 100
 	tgett_f            t_gett;
101 101
 	calculate_hooks_f  calculate_hooks;
102
+	t_uac_t            t_uac;
102 103
 	enum route_mode*   route_mode;
103 104
 };
104 105
 
... ...
@@ -332,7 +332,7 @@ int req_outside(str* method, str* to, str* from, str* headers, str* body, dlg_t*
332 332
 /*
333 333
  * Send a transactional request, no dialogs involved
334 334
  */
335
-int request(str* m, str* ruri, str* to, str* from, str* h, str* b, transaction_cb c, void* cp)
335
+int request(str* m, str* ruri, str* to, str* from, str* h, str* b, str *next_hop, transaction_cb c, void* cp)
336 336
 {
337 337
 	str callid, fromtag;
338 338
 	dlg_t* dialog;
... ...
@@ -355,6 +355,9 @@ int request(str* m, str* ruri, str* to, str* from, str* h, str* b, transaction_c
355 355
 	}
356 356
 	w_calculate_hooks(dialog);
357 357
 
358
+	if (next_hop) 
359
+		if ((next_hop->len > 0) && next_hop->s) dialog->hooks.next_hop = next_hop;
360
+
358 361
 	res = t_uac(m, h, b, dialog, c, cp);
359 362
 	dialog->rem_target.s = 0;
360 363
 	free_dlg(dialog);
... ...
@@ -48,7 +48,8 @@ extern int pass_provisional_replies; /* Pass provisional replies to fifo applica
48 48
  */
49 49
 typedef int (*reqwith_t)(str* m, str* h, str* b, dlg_t* d, transaction_cb c, void* cp);
50 50
 typedef int (*reqout_t)(str* m, str* t, str* f, str* h, str* b, dlg_t** d, transaction_cb c, void* cp);
51
-typedef int (*req_t)(str* m, str* ruri, str* t, str* f, str* h, str* b, transaction_cb c, void* cp);
51
+typedef int (*req_t)(str* m, str* ruri, str* t, str* f, str* h, str* b, str *next_hop, transaction_cb c, void* cp);
52
+typedef int (*t_uac_t)(str* method, str* headers, str* body, dlg_t* dialog, transaction_cb cb, void* cbp);
52 53
 
53 54
 
54 55
 /*
... ...
@@ -80,11 +81,10 @@ int req_within(str* m, str* h, str* b, dlg_t* d, transaction_cb c, void* cp);
80 81
  */
81 82
 int req_outside(str* m, str* t, str* f, str* h, str* b, dlg_t** d, transaction_cb c, void* cp);
82 83
 
83
-
84 84
 /*
85 85
  * Send a transactional request, no dialogs involved
86 86
  */
87
-int request(str* m, str* ruri, str* to, str* from, str* h, str* b, transaction_cb c, void* cp);
87
+int request(str* m, str* ruri, str* to, str* from, str* h, str* b, str *next_hop, transaction_cb c, void* cp);
88 88
 
89 89
 
90 90
 #endif