diff options
author | Oliver Smith <osmith@sysmocom.de> | 2020-01-29 14:58:21 +0100 |
---|---|---|
committer | Oliver Smith <osmith@sysmocom.de> | 2020-01-29 15:24:07 +0100 |
commit | 043a73ac3e31e47eb8a1041743d423d3162da8e3 (patch) | |
tree | c2f26513ab381b6f3688c7bc644b8bba2d9ae4fb /library | |
parent | dbe2756f496125827d5959e9da212ebd88e799d3 (diff) |
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
Diffstat (limited to 'library')
-rw-r--r-- | library/DNS_Helpers.ttcn | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/library/DNS_Helpers.ttcn b/library/DNS_Helpers.ttcn index 122adff3..85040fc2 100644 --- a/library/DNS_Helpers.ttcn +++ b/library/DNS_Helpers.ttcn @@ -70,4 +70,27 @@ function f_dec_dns_hostname(octetstring inp) return charstring { } +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; +} + } |