[sr-dev] git:master:b7c47ce4: siputils: contact encoding functions exported to kemi

Daniel-Constantin Mierla miconda at gmail.com
Wed Mar 4 12:20:20 CET 2020


Module: kamailio
Branch: master
Commit: b7c47ce4ceea9ce97431bdd921afa2a59617e1c5
URL: https://github.com/kamailio/kamailio/commit/b7c47ce4ceea9ce97431bdd921afa2a59617e1c5

Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at gmail.com>
Date: 2020-03-04T12:19:40+01:00

siputils: contact encoding functions exported to kemi

---

Modified: src/modules/siputils/contact_ops.c
Modified: src/modules/siputils/contact_ops.h
Modified: src/modules/siputils/siputils.c

---

Diff:  https://github.com/kamailio/kamailio/commit/b7c47ce4ceea9ce97431bdd921afa2a59617e1c5.diff
Patch: https://github.com/kamailio/kamailio/commit/b7c47ce4ceea9ce97431bdd921afa2a59617e1c5.patch

---

diff --git a/src/modules/siputils/contact_ops.c b/src/modules/siputils/contact_ops.c
index 5183f40ab6..bc48a8771b 100644
--- a/src/modules/siputils/contact_ops.c
+++ b/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
diff --git a/src/modules/siputils/contact_ops.h b/src/modules/siputils/contact_ops.h
index ef925c761b..939b80ac6c 100644
--- a/src/modules/siputils/contact_ops.h
+++ b/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);
diff --git a/src/modules/siputils/siputils.c b/src/modules/siputils/siputils.c
index aa847ae9c4..e9593da3b4 100644
--- a/src/modules/siputils/siputils.c
+++ b/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 } }
 };




More information about the sr-dev mailing list