1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef DISCOVERY_DNSSD_PUBLIC_INSTANCE_RECORD_H_
#define DISCOVERY_DNSSD_PUBLIC_INSTANCE_RECORD_H_
#include "absl/strings/string_view.h"
#include "absl/types/optional.h"
#include "discovery/dnssd/public/txt_record.h"
#include "platform/base/ip_address.h"
namespace openscreen {
namespace discovery {
// Represents the data stored in DNS records of types SRV, TXT, A, and AAAA
class DnsSdInstanceRecord {
public:
// These ctors expect valid input, and will cause a crash if they are not.
// TODO(rwkeane): Add validation methods for instance_id, service_id,
// domain_id.
DnsSdInstanceRecord(std::string instance_id,
std::string service_id,
std::string domain_id,
IPEndpoint endpoint,
DnsSdTxtRecord txt);
// NOTE: This constructor expects one endpoint to be an IPv4 address and the
// other to be an IPv6 address.
DnsSdInstanceRecord(std::string instance_id,
std::string service_id,
std::string domain_id,
IPEndpoint ipv4_endpoint,
IPEndpoint ipv6_endpoint,
DnsSdTxtRecord txt);
// Returns the instance name for this DNS-SD record.
const std::string& instance_id() const { return instance_id_; }
// Returns the service id for this DNS-SD record.
const std::string& service_id() const { return service_id_; }
// Returns the domain id for this DNS-SD record.
const std::string& domain_id() const { return domain_id_; }
// Returns the addess associated with this DNS-SD record. In any valid record,
// at least one will be set.
const absl::optional<IPEndpoint>& address_v4() const { return address_v4_; }
const absl::optional<IPEndpoint>& address_v6() const { return address_v6_; }
// Returns the TXT record associated with this DNS-SD record
const DnsSdTxtRecord& txt() const { return txt_; };
private:
std::string instance_id_;
std::string service_id_;
std::string domain_id_;
absl::optional<IPEndpoint> address_v4_;
absl::optional<IPEndpoint> address_v6_;
DnsSdTxtRecord txt_;
};
} // namespace discovery
} // namespace openscreen
#endif // DISCOVERY_DNSSD_PUBLIC_INSTANCE_RECORD_H_
|