Browse Source

AVP support introduced (not tested yet)

Jiri Kuthan 21 years ago
parent
commit
7c8890f0d7
3 changed files with 91 additions and 0 deletions
  1. 50 0
      dset.c
  2. 4 0
      dset.h
  3. 37 0
      mod_fix.h

+ 50 - 0
dset.c

@@ -285,3 +285,53 @@ qvalue_t get_ruri_q(void)
 {
 {
 	return ruri_q;
 	return ruri_q;
 }
 }
+
+
+
+/*
+ * Get actual Request-URI
+ */
+int get_request_uri(struct sip_msg* _m, str* _u)
+{
+	     /* Use new_uri if present */
+	if (_m->new_uri.s) {
+		_u->s = _m->new_uri.s;
+		_u->len = _m->new_uri.len;
+	} else {
+		_u->s = _m->first_line.u.request.uri.s;
+		_u->len = _m->first_line.u.request.uri.len;
+	}
+
+	return 0;
+}
+
+
+/*
+ * Rewrite Request-URI
+ */
+int rewrite_uri(struct sip_msg* _m, str* _s)
+{
+        char* buf;
+
+        buf = (char*)pkg_malloc(_s->len + 1);
+        if (!buf) {
+                LOG(L_ERR, "ERROR: TOI: rewrite_uri: No memory left\n");
+                return -1;
+        }
+
+        memcpy(buf, _s->s, _s->len);
+        buf[_s->len] = '\0';
+
+        _m->parsed_uri_ok = 0;
+        if (_m->new_uri.s) {
+                pkg_free(_m->new_uri.s);
+        }
+
+        _m->new_uri.s = buf;
+        _m->new_uri.len = _s->len;
+
+        DBG("TOI: rewrite_uri: Rewriting Request-URI with '%.*s'\n", _s->len, 
+																		   buf);
+        return 0;
+}
+

+ 4 - 0
dset.h

@@ -74,4 +74,8 @@ void set_ruri_q(qvalue_t q);
  */
  */
 qvalue_t get_ruri_q(void);
 qvalue_t get_ruri_q(void);
 
 
+int get_request_uri(struct sip_msg* _m, str* _u);
+int rewrite_uri(struct sip_msg* _m, str* _s);
+
+
 #endif /* _DSET_H */
 #endif /* _DSET_H */

+ 37 - 0
mod_fix.h

@@ -0,0 +1,37 @@
+/*
+ *$Id$
+ *
+ */
+
+
+#ifndef _modfix_h
+#define _modfix_h
+
+#include "mem/mem.h"
+#include "str.h"
+#include "error.h"
+
+
+/*  
+ * Convert char* parameter to str* parameter   
+ */
+static int str_fixup(void** param, int param_no)
+{
+	str* s;
+	
+	if (param_no == 1 || param_no == 2 ) {
+		s = (str*)pkg_malloc(sizeof(str));
+		if (!s) {
+			LOG(L_ERR, "str_fixup(): No memory left\n");
+			return E_UNSPEC;
+		}
+		
+		s->s = (char*)*param;
+		s->len = strlen(s->s);
+		*param = (void*)s;
+	}
+	
+	return 0;
+}
+
+#endif