rspro_util: Add rspro_IpAddr2str() to get stringified version of IpAddr_t

Change-Id: Ic6cccb00d1d65bdab84178acb1e0525e11bc1315
diff --git a/src/rspro_util.c b/src/rspro_util.c
index efcc848..ed0678e 100644
--- a/src/rspro_util.c
+++ b/src/rspro_util.c
@@ -1,5 +1,8 @@
 
 
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
 #include <asn_application.h>
 #include <der_encoder.h>
 
@@ -114,6 +117,20 @@
 	string_fromOCTET_STRING_ARRAY(out->fw_version, in->fwVersion);
 }
 
+const char *rspro_IpAddr2str(const IpAddress_t *in)
+{
+	static char buf[128];
+
+	switch (in->present) {
+	case IpAddress_PR_ipv4:
+		return inet_ntop(AF_INET, in->choice.ipv4.buf, buf, sizeof(buf));
+	case IpAddress_PR_ipv6:
+		return inet_ntop(AF_INET6, in->choice.ipv6.buf, buf, sizeof(buf));
+	default:
+		return NULL;
+	}
+}
+
 static void fill_ip4_port(IpPort_t *out, uint32_t ip, uint16_t port)
 {
 	uint32_t ip_n = htonl(ip);
diff --git a/src/rspro_util.h b/src/rspro_util.h
index 7a0c8ed..26b3883 100644
--- a/src/rspro_util.h
+++ b/src/rspro_util.h
@@ -38,3 +38,4 @@
 				     const uint8_t *tpdu, unsigned int tpdu_len);
 
 void rspro_comp_id_retrieve(struct app_comp_id *out, const ComponentIdentity_t *in);
+const char *rspro_IpAddr2str(const IpAddress_t *in);