3 * Copyright (c) 2020 Project CHIP Authors
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at
9 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
20 #include <inet/IPAddress.h>
22 #include <mdns/minimal/core/BytesRange.h>
23 #include <mdns/minimal/core/QName.h>
28 class TxtRecordDelegate
31 virtual ~TxtRecordDelegate() {}
33 /// Reports that a record was found
36 /// value will be empty if '=' is missing in the TXT record. I.e code does
37 /// *NOT* differentiate between "foo=" and "foo" as record.
38 virtual void OnRecord(const BytesRange & name, const BytesRange & value) = 0;
41 /// Parses TXT record data
42 /// https://tools.ietf.org/html/rfc1035 (included in base RFC)
43 bool ParseTxtRecord(const BytesRange & data, TxtRecordDelegate * callback);
45 /// Parses SRV record data
46 /// https://tools.ietf.org/html/rfc2782
52 /// Parses a SRV record within [data]
54 /// [packet] specifies the range of valid data for PTR addresses within
56 bool Parse(const BytesRange & data, const BytesRange & packet);
58 uint16_t GetPriority() const { return mPriority; }
59 uint16_t GetWeight() const { return mWeight; }
60 uint16_t GetPort() const { return mPort; }
61 SerializedQNameIterator GetName() const { return mName; }
64 uint16_t mPriority = 0;
67 SerializedQNameIterator mName;
70 /// Parses an IPV4 (A) record data
71 /// https://tools.ietf.org/html/rfc1035 (included in base RFC)
72 bool ParseARecord(const BytesRange & data, chip::Inet::IPAddress * addr);
74 /// Parses an IPV6 (AAAA) record data
75 /// https://tools.ietf.org/html/rfc3596
76 bool ParseAAAARecord(const BytesRange & data, chip::Inet::IPAddress * addr);
78 /// Parses a PTR record data
79 /// https://tools.ietf.org/html/rfc1035 (included in base RFC)
80 bool ParsePtrRecord(const BytesRange & data, const BytesRange & packet, SerializedQNameIterator * name);
82 } // namespace Minimal