Browse code

AVP support introduced (not tested yet)

Jiri Kuthan authored on 27/09/2004 03:11:07
Showing 3 changed files
... ...
@@ -285,3 +285,53 @@ qvalue_t get_ruri_q(void)
285 285
 {
286 286
 	return ruri_q;
287 287
 }
288
+
289
+
290
+
291
+/*
292
+ * Get actual Request-URI
293
+ */
294
+int get_request_uri(struct sip_msg* _m, str* _u)
295
+{
296
+	     /* Use new_uri if present */
297
+	if (_m->new_uri.s) {
298
+		_u->s = _m->new_uri.s;
299
+		_u->len = _m->new_uri.len;
300
+	} else {
301
+		_u->s = _m->first_line.u.request.uri.s;
302
+		_u->len = _m->first_line.u.request.uri.len;
303
+	}
304
+
305
+	return 0;
306
+}
307
+
308
+
309
+/*
310
+ * Rewrite Request-URI
311
+ */
312
+int rewrite_uri(struct sip_msg* _m, str* _s)
313
+{
314
+        char* buf;
315
+
316
+        buf = (char*)pkg_malloc(_s->len + 1);
317
+        if (!buf) {
318
+                LOG(L_ERR, "ERROR: TOI: rewrite_uri: No memory left\n");
319
+                return -1;
320
+        }
321
+
322
+        memcpy(buf, _s->s, _s->len);
323
+        buf[_s->len] = '\0';
324
+
325
+        _m->parsed_uri_ok = 0;
326
+        if (_m->new_uri.s) {
327
+                pkg_free(_m->new_uri.s);
328
+        }
329
+
330
+        _m->new_uri.s = buf;
331
+        _m->new_uri.len = _s->len;
332
+
333
+        DBG("TOI: rewrite_uri: Rewriting Request-URI with '%.*s'\n", _s->len, 
334
+																		   buf);
335
+        return 0;
336
+}
337
+
... ...
@@ -74,4 +74,8 @@ void set_ruri_q(qvalue_t q);
74 74
  */
75 75
 qvalue_t get_ruri_q(void);
76 76
 
77
+int get_request_uri(struct sip_msg* _m, str* _u);
78
+int rewrite_uri(struct sip_msg* _m, str* _s);
79
+
80
+
77 81
 #endif /* _DSET_H */
78 82
new file mode 100644
... ...
@@ -0,0 +1,37 @@
0
+/*
1
+ *$Id$
2
+ *
3
+ */
4
+
5
+
6
+#ifndef _modfix_h
7
+#define _modfix_h
8
+
9
+#include "mem/mem.h"
10
+#include "str.h"
11
+#include "error.h"
12
+
13
+
14
+/*  
15
+ * Convert char* parameter to str* parameter   
16
+ */
17
+static int str_fixup(void** param, int param_no)
18
+{
19
+	str* s;
20
+	
21
+	if (param_no == 1 || param_no == 2 ) {
22
+		s = (str*)pkg_malloc(sizeof(str));
23
+		if (!s) {
24
+			LOG(L_ERR, "str_fixup(): No memory left\n");
25
+			return E_UNSPEC;
26
+		}
27
+		
28
+		s->s = (char*)*param;
29
+		s->len = strlen(s->s);
30
+		*param = (void*)s;
31
+	}
32
+	
33
+	return 0;
34
+}
35
+
36
+#endif