Change in osmo-ttcn3-hacks[master]: library/DNS_Helpers: add f_enc_IPv4

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

laforge gerrit-no-reply at lists.osmocom.org
Thu Feb 6 16:21:50 UTC 2020


laforge has submitted this change. ( https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/17063 )

Change subject: library/DNS_Helpers: add f_enc_IPv4
......................................................................

library/DNS_Helpers: add f_enc_IPv4

Used by upcoming D-GSM test, to pass the IP of the emulated GSUP server.
The code is based on f_enc_dns_hostname() in the same file.

Related: OS#4380
Change-Id: I8a5450988711680c93cfd657a34db759a56bc41e
---
M library/DNS_Helpers.ttcn
1 file changed, 23 insertions(+), 0 deletions(-)

Approvals:
  laforge: Looks good to me, approved
  Jenkins Builder: Verified



diff --git a/library/DNS_Helpers.ttcn b/library/DNS_Helpers.ttcn
index 122adff..85040fc 100644
--- a/library/DNS_Helpers.ttcn
+++ b/library/DNS_Helpers.ttcn
@@ -70,4 +70,27 @@
 }
 
 
+function f_enc_IPv4(charstring str) return octetstring {
+	var octetstring ret := ''O;
+
+	while (lengthof(str) > 0) {
+		var integer dot_idx;
+		var charstring num;
+
+		dot_idx := f_strchr(str, ".");
+		if (dot_idx >= 0) {
+			/* there is another dot */
+			num := substr(str, 0, dot_idx);
+			str := substr(str, dot_idx+1, lengthof(str)-dot_idx-1);
+		} else {
+			/* no more dot */
+			num := str;
+			str := "";
+		}
+		ret := ret & int2oct(str2int(num), 1);
+	}
+
+	return ret;
+}
+
 }

-- 
To view, visit https://gerrit.osmocom.org/c/osmo-ttcn3-hacks/+/17063
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-ttcn3-hacks
Gerrit-Branch: master
Gerrit-Change-Id: I8a5450988711680c93cfd657a34db759a56bc41e
Gerrit-Change-Number: 17063
Gerrit-PatchSet: 3
Gerrit-Owner: osmith <osmith at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: laforge <laforge at osmocom.org>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20200206/8db30041/attachment.htm>


More information about the gerrit-log mailing list