blob: 029091deb944d4379bbb1b3201e25ada16f50b13 [file] [log] [blame]
Oliver Smithdeb80a62019-11-29 16:01:54 +01001module MSLookup_mDNS_Emulation {
2
3/* (C) 2020 sysmocom s.f.m.c. GmbH <info@sysmocom.de>
4 * All rights reserved.
5 *
6 * Released under the terms of GNU General Public License, Version 2 or
7 * (at your option) any later version.
8 *
9 * SPDX-License-Identifier: GPL-2.0-or-later
10 */
11
12import from DNS_Types all;
13import from UDPasp_Types all;
14import from MSLookup_mDNS_Types all;
15
16/* Transcode between mDNS and UDP:
17 Wait for DNS packets on the mDNS port, encode them as UDP and forward them to the mDNS_UDP port.
18 Wait for UDP packets on mDNS_UDP port, decode them as DNS and forward them to the mDNS port. */
19function f_main() runs on MSLookup_mDNS_Emulation_CT
20{
21 var MSLookup_mDNS vl_dnsmsg;
22 var ASP_UDP vl_udpmsg;
23 map(self:mDNS_UDP, system:UDP);
24 alt {
25 [] mDNS_UDP.receive(ASP_UDP:?) -> value vl_udpmsg {
26 mDNS.send(MSLookup_mDNS: {
27 dec_PDU_DNS(vl_udpmsg.data),
28 vl_udpmsg.addressf,
29 vl_udpmsg.portf
30 });
31 repeat;
32 }
33 [] mDNS.receive(MSLookup_mDNS:?) -> value vl_dnsmsg {
34 mDNS_UDP.send(ASP_UDP: {
35 enc_PDU_DNS(vl_dnsmsg.dnsMessage, false, true),
36 vl_dnsmsg.udpAddress,
37 vl_dnsmsg.udpPort
38 });
39 repeat;
40 }
41 }
42 unmap(self:mDNS_UDP, system:UDP);
43}
44
45}