Răsfoiți Sursa

siputils: contact encoding functions exported to kemi

Daniel-Constantin Mierla 5 ani în urmă
părinte
comite
b7c47ce4ce

+ 27 - 8
src/modules/siputils/contact_ops.c

@@ -44,7 +44,7 @@
 #include <string.h>
 
 
-int encode_contact (struct sip_msg *msg, char *encoding_prefix,char *public_ip)
+int ki_encode_contact (sip_msg_t *msg, str *eprefix, str *eaddr)
 {
 	contact_body_t *cb;
 	contact_t *c;
@@ -85,7 +85,7 @@ int encode_contact (struct sip_msg *msg, char *encoding_prefix,char *public_ip)
 	/* we visit each contact */
 	if(c != NULL) {
 		uri = c->uri;
-		res = encode_uri(uri, encoding_prefix, public_ip, separator, &newUri);
+		res = encode_uri(uri, eprefix->s, eaddr->s, separator, &newUri);
 
 		if(res != 0) {
 			LM_ERR("failed encoding contact.Code %d\n", res);
@@ -103,8 +103,7 @@ int encode_contact (struct sip_msg *msg, char *encoding_prefix,char *public_ip)
 			c = c->next;
 			uri = c->uri;
 
-			res = encode_uri(
-					uri, encoding_prefix, public_ip, separator, &newUri);
+			res = encode_uri(uri, eprefix->s, eaddr->s, separator, &newUri);
 			if(res != 0) {
 				LM_ERR("failed encode_uri.Code %d\n", res);
 #ifdef STRICT_CHECK
@@ -121,8 +120,20 @@ int encode_contact (struct sip_msg *msg, char *encoding_prefix,char *public_ip)
 	return 1;
 }
 
-	int
-decode_contact (struct sip_msg *msg,char *unused1,char *unused2)
+int encode_contact(sip_msg_t *msg, char *encoding_prefix, char *public_ip)
+{
+	str eprefix = STR_NULL;
+	str eaddr = STR_NULL;
+
+	eprefix.s = encoding_prefix;
+	eprefix.len = strlen(eprefix.s);
+	eaddr.s = public_ip;
+	eaddr.len = strlen(eaddr.s);
+
+	return ki_encode_contact(msg, &eprefix, &eaddr);
+}
+
+int ki_decode_contact(sip_msg_t *msg)
 {
 
 	str uri;
@@ -177,8 +188,12 @@ decode_contact (struct sip_msg *msg,char *unused1,char *unused2)
 	return 1;
 }
 
-	int
-decode_contact_header (struct sip_msg *msg,char *unused1,char *unused2)
+int decode_contact(sip_msg_t *msg, char *unused1, char *unused2)
+{
+	return ki_decode_contact(msg);
+}
+
+int ki_decode_contact_header(sip_msg_t *msg)
 {
 
 	contact_body_t *cb;
@@ -255,6 +270,10 @@ decode_contact_header (struct sip_msg *msg,char *unused1,char *unused2)
 }
 
 
+int decode_contact_header(sip_msg_t *msg, char *unused1, char *unused2)
+{
+	return ki_decode_contact_header(msg);
+}
 
 
 	int

+ 3 - 0
src/modules/siputils/contact_ops.h

@@ -64,6 +64,9 @@ struct uri_format
 
 typedef struct uri_format contact_fields_t;
 
+int ki_encode_contact (sip_msg_t *msg, str *eprefix, str *eaddr);
+int ki_decode_contact(sip_msg_t *msg);
+int ki_decode_contact_header(sip_msg_t *msg);
 
 int encode_contact (struct sip_msg *msg, char *encoding_prefix,char *public_ip);
 int decode_contact (struct sip_msg *msg, char *unused1,char *unused2);

+ 15 - 0
src/modules/siputils/siputils.c

@@ -546,6 +546,21 @@ static sr_kemi_t sr_kemi_siputils_exports[] = {
 		{ SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE,
 			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
 	},
+	{ str_init("siputils"), str_init("encode_contact"),
+		SR_KEMIP_INT, ki_encode_contact,
+		{ SR_KEMIP_STR, SR_KEMIP_STR, SR_KEMIP_NONE,
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+	},
+	{ str_init("siputils"), str_init("decode_contact"),
+		SR_KEMIP_INT, ki_decode_contact,
+		{ SR_KEMIP_NULL, SR_KEMIP_NULL, SR_KEMIP_NONE,
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+	},
+	{ str_init("siputils"), str_init("decode_contact_header"),
+		SR_KEMIP_INT, ki_decode_contact_header,
+		{ SR_KEMIP_NULL, SR_KEMIP_NULL, SR_KEMIP_NONE,
+			SR_KEMIP_NONE, SR_KEMIP_NONE, SR_KEMIP_NONE }
+	},
 
 	{ {0, 0}, {0, 0}, 0, NULL, { 0, 0, 0, 0, 0, 0 } }
 };