Change in osmo-remsim[master]: rspro_util: Add rspro_IpAddr2str() to get stringified version of IpAd...

Harald Welte gerrit-no-reply at lists.osmocom.org
Sun Mar 3 21:01:44 UTC 2019


Harald Welte has uploaded this change for review. ( https://gerrit.osmocom.org/13107


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

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

Change-Id: Ic6cccb00d1d65bdab84178acb1e0525e11bc1315
---
M src/rspro_util.c
M src/rspro_util.h
2 files changed, 18 insertions(+), 0 deletions(-)



  git pull ssh://gerrit.osmocom.org:29418/osmo-remsim refs/changes/07/13107/1

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);

-- 
To view, visit https://gerrit.osmocom.org/13107
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-remsim
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic6cccb00d1d65bdab84178acb1e0525e11bc1315
Gerrit-Change-Number: 13107
Gerrit-PatchSet: 1
Gerrit-Owner: Harald Welte <laforge at gnumonks.org>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190303/4ace6842/attachment.html>


More information about the gerrit-log mailing list