diff options
author | Oliver Smith <osmith@sysmocom.de> | 2019-11-29 16:01:54 +0100 |
---|---|---|
committer | Oliver Smith <osmith@sysmocom.de> | 2020-01-24 15:39:51 +0100 |
commit | ed1b5f6ad5b6f8b9d601586490bec28fa844eaf2 (patch) | |
tree | 7f3da39648dc1bce439dc8513ca5e1eda1150582 /library | |
parent | b6cec43ed7c578c86e582ed2cd91561db6e03472 (diff) |
hlr: add TC_MSLookup_mDNS_server
Send an mslookup mDNS request to OsmoHLR and verify the answer.
Related: SYS#4618
Depends: osmo-hlr I2fe453553c90e6ee527ed13a13089900efd488aa
Change-Id: Ia7f92d33691f910549353b16a7b0efc18e521719
Diffstat (limited to 'library')
-rw-r--r-- | library/MSLookup_mDNS_Emulation.ttcn | 45 | ||||
-rw-r--r-- | library/MSLookup_mDNS_Templates.ttcn | 99 | ||||
-rw-r--r-- | library/MSLookup_mDNS_Types.ttcn | 31 |
3 files changed, 175 insertions, 0 deletions
diff --git a/library/MSLookup_mDNS_Emulation.ttcn b/library/MSLookup_mDNS_Emulation.ttcn new file mode 100644 index 00000000..029091de --- /dev/null +++ b/library/MSLookup_mDNS_Emulation.ttcn @@ -0,0 +1,45 @@ +module MSLookup_mDNS_Emulation { + +/* (C) 2020 sysmocom s.f.m.c. GmbH <info@sysmocom.de> + * All rights reserved. + * + * Released under the terms of GNU General Public License, Version 2 or + * (at your option) any later version. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +import from DNS_Types all; +import from UDPasp_Types all; +import from MSLookup_mDNS_Types all; + +/* Transcode between mDNS and UDP: + Wait for DNS packets on the mDNS port, encode them as UDP and forward them to the mDNS_UDP port. + Wait for UDP packets on mDNS_UDP port, decode them as DNS and forward them to the mDNS port. */ +function f_main() runs on MSLookup_mDNS_Emulation_CT +{ + var MSLookup_mDNS vl_dnsmsg; + var ASP_UDP vl_udpmsg; + map(self:mDNS_UDP, system:UDP); + alt { + [] mDNS_UDP.receive(ASP_UDP:?) -> value vl_udpmsg { + mDNS.send(MSLookup_mDNS: { + dec_PDU_DNS(vl_udpmsg.data), + vl_udpmsg.addressf, + vl_udpmsg.portf + }); + repeat; + } + [] mDNS.receive(MSLookup_mDNS:?) -> value vl_dnsmsg { + mDNS_UDP.send(ASP_UDP: { + enc_PDU_DNS(vl_dnsmsg.dnsMessage, false, true), + vl_dnsmsg.udpAddress, + vl_dnsmsg.udpPort + }); + repeat; + } + } + unmap(self:mDNS_UDP, system:UDP); +} + +} diff --git a/library/MSLookup_mDNS_Templates.ttcn b/library/MSLookup_mDNS_Templates.ttcn new file mode 100644 index 00000000..e2426fab --- /dev/null +++ b/library/MSLookup_mDNS_Templates.ttcn @@ -0,0 +1,99 @@ + +/* (C) 2020 by sysmocom s.f.m.c. GmbH <info@sysmocom.de> + * All Rights Reserved + * + * Released under the terms of GNU General Public License, Version 2 or + * (at your option) any later version. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +module MSLookup_mDNS_Templates { + +import from DNS_Types all; +import from MSLookup_mDNS_Types all; + +template MSLookup_mDNS t_MSLookup_mDNS_query(integer id, charstring domain) := { + dnsMessage := { + header := { + id := id, + qr := DNS_QUERY, + opCode := 0, + aa := false, + tc := false, + rd := false, + ra := false, + z := '000'B, + rCode := DNS_NO_ERROR, + qdCount := 1, + anCount := 0, + nsCount := 0, + arCount := 0 + }, + queries := { + { + qName := domain, + qType := 255, + qClass := DNS_IN + } + }, + answers := {}, + nameServerRecords := {}, + additionalRecords := {} + }, + udpAddress := "239.192.23.42", + udpPort := 4266 +} + +template MSLookup_mDNS tr_MSLookup_mDNS_result_IPv4(integer id, charstring domain, UInt32 ip_v4, integer port_v4) := { + dnsMessage := { + header := { + id := id, + qr := DNS_RESPONSE, + opCode := DNS_OP_QUERY, + aa := false, + tc := false, + rd := false, + ra := false, + z := '000'B, + rCode := DNS_NO_ERROR, + qdCount := 0, + anCount := 3, + nsCount := 0, + arCount := 0 + }, + queries := {}, + answers := { + { + name := domain, + rrType := DNS_TXT, + rrClass := DNS_IN, + ttl := ?, + rdLength := ?, + rData := {txt := {pattern "age=*"}} + }, + { + name := domain, + rrType := DNS_A, + rrClass := DNS_IN, + ttl := ?, + rdLength := ?, + rData := {a := ip_v4} + }, + { + name := domain, + rrType := DNS_TXT, + rrClass := DNS_IN, + ttl := ?, + rdLength := ?, + rData := {txt := {"port=" & int2str(port_v4)}} + } + }, + nameServerRecords := {}, + additionalRecords := {} + }, + udpAddress := ?, + udpPort := ? +} + +} diff --git a/library/MSLookup_mDNS_Types.ttcn b/library/MSLookup_mDNS_Types.ttcn new file mode 100644 index 00000000..dacbb2bc --- /dev/null +++ b/library/MSLookup_mDNS_Types.ttcn @@ -0,0 +1,31 @@ +module MSLookup_mDNS_Types { + +/* (C) 2020 sysmocom s.f.m.c. GmbH <info@sysmocom.de> + * All rights reserved. + * + * Released under the terms of GNU General Public License, Version 2 or + * (at your option) any later version. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +import from DNS_Types all; +import from UDPasp_Types all; +import from UDPasp_PortType all; + +type record MSLookup_mDNS { + PDU_DNS dnsMessage, + AddressType udpAddress, + PortType udpPort +} + +type port MSLookup_mDNS_PT message { + inout MSLookup_mDNS +} with { extension "internal" } + +type component MSLookup_mDNS_Emulation_CT { + port MSLookup_mDNS_PT mDNS; + port UDPasp_PT mDNS_UDP; +} + +} |