Oliver Smith | deb80a6 | 2019-11-29 16:01:54 +0100 | [diff] [blame^] | 1 | |
| 2 | /* (C) 2020 by sysmocom s.f.m.c. GmbH <info@sysmocom.de> |
| 3 | * All Rights Reserved |
| 4 | * |
| 5 | * Released under the terms of GNU General Public License, Version 2 or |
| 6 | * (at your option) any later version. |
| 7 | * |
| 8 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 9 | */ |
| 10 | |
| 11 | module MSLookup_mDNS_Templates { |
| 12 | |
| 13 | import from DNS_Types all; |
| 14 | import from MSLookup_mDNS_Types all; |
| 15 | |
| 16 | template MSLookup_mDNS ts_MSLookup_mDNS_query(integer id, charstring domain) := { |
| 17 | dnsMessage := { |
| 18 | header := { |
| 19 | id := id, |
| 20 | qr := DNS_QUERY, |
| 21 | opCode := 0, |
| 22 | aa := false, |
| 23 | tc := false, |
| 24 | rd := false, |
| 25 | ra := false, |
| 26 | z := '000'B, |
| 27 | rCode := DNS_NO_ERROR, |
| 28 | qdCount := 1, |
| 29 | anCount := 0, |
| 30 | nsCount := 0, |
| 31 | arCount := 0 |
| 32 | }, |
| 33 | queries := { |
| 34 | { |
| 35 | qName := domain, |
| 36 | qType := 255, |
| 37 | qClass := DNS_IN |
| 38 | } |
| 39 | }, |
| 40 | answers := {}, |
| 41 | nameServerRecords := {}, |
| 42 | additionalRecords := {} |
| 43 | }, |
| 44 | udpAddress := "239.192.23.42", |
| 45 | udpPort := 4266 |
| 46 | } |
| 47 | |
| 48 | template MSLookup_mDNS tr_MSLookup_mDNS_result_IPv4(integer id, charstring domain, UInt32 ip_v4, integer port_v4) := { |
| 49 | dnsMessage := { |
| 50 | header := { |
| 51 | id := id, |
| 52 | qr := DNS_RESPONSE, |
| 53 | opCode := DNS_OP_QUERY, |
| 54 | aa := false, |
| 55 | tc := false, |
| 56 | rd := false, |
| 57 | ra := false, |
| 58 | z := '000'B, |
| 59 | rCode := DNS_NO_ERROR, |
| 60 | qdCount := 0, |
| 61 | anCount := 3, |
| 62 | nsCount := 0, |
| 63 | arCount := 0 |
| 64 | }, |
| 65 | queries := {}, |
| 66 | answers := { |
| 67 | { |
| 68 | name := domain, |
| 69 | rrType := DNS_TXT, |
| 70 | rrClass := DNS_IN, |
| 71 | ttl := ?, |
| 72 | rdLength := ?, |
| 73 | rData := {txt := {pattern "age=*"}} |
| 74 | }, |
| 75 | { |
| 76 | name := domain, |
| 77 | rrType := DNS_A, |
| 78 | rrClass := DNS_IN, |
| 79 | ttl := ?, |
| 80 | rdLength := ?, |
| 81 | rData := {a := ip_v4} |
| 82 | }, |
| 83 | { |
| 84 | name := domain, |
| 85 | rrType := DNS_TXT, |
| 86 | rrClass := DNS_IN, |
| 87 | ttl := ?, |
| 88 | rdLength := ?, |
| 89 | rData := {txt := {"port=" & int2str(port_v4)}} |
| 90 | } |
| 91 | }, |
| 92 | nameServerRecords := {}, |
| 93 | additionalRecords := {} |
| 94 | }, |
| 95 | udpAddress := ?, |
| 96 | udpPort := ? |
| 97 | } |
| 98 | |
| 99 | } |