1 #ifndef DNS_LDNS_DOT_HPP
2 #define DNS_LDNS_DOT_HPP
9 #include <netinet/in.h>
11 #include "DNS-rrs.hpp"
14 typedef struct ldns_struct_pkt ldns_pkt
;
15 typedef struct ldns_struct_rdf ldns_rdf
;
16 typedef struct ldns_struct_resolver ldns_resolver
;
17 typedef struct ldns_struct_rr_list ldns_rr_list
;
23 Domain(Domain
const&) = delete;
24 Domain
& operator=(Domain
const&) = delete;
26 explicit Domain(char const* domain
);
27 explicit Domain(std::string
const& domain
);
30 std::string
const& str() const { return str_
; }
31 ldns_rdf
* get() const { return rdfp_
; }
37 friend std::ostream
& operator<<(std::ostream
& os
, Domain
const& dom
)
39 return os
<< dom
.str();
45 Resolver(Resolver
const&) = delete;
46 Resolver
& operator=(Resolver
const&) = delete;
51 DNS::RR_collection
get_records(DNS::RR_type typ
,
52 std::string
const& domain
) const
54 return get_records(typ
, domain
.c_str());
56 DNS::RR_collection
get_records(DNS::RR_type typ
, char const* domain
) const;
58 std::vector
<std::string
> get_strings(DNS::RR_type typ
,
59 std::string
const& domain
) const
61 return get_strings(typ
, domain
.c_str());
63 std::vector
<std::string
> get_strings(DNS::RR_type typ
,
64 char const* domain
) const;
66 ldns_resolver
* get() const { return res_
; }
74 Query(Query
const&) = delete;
75 Query
& operator=(Query
const&) = delete;
77 Query(Resolver
const& res
, DNS::RR_type type
, std::string
const& dom
);
78 Query(Resolver
const& res
, DNS::RR_type type
, char const* dom
);
81 ldns_pkt
* get() const { return p_
; }
83 bool authentic_data() const { return authentic_data_
; }
84 bool bogus_or_indeterminate() const { return bogus_or_indeterminate_
; }
85 bool nx_domain() const { return nx_domain_
; }
87 DNS::RR_collection
get_records() const;
88 std::vector
<std::string
> get_strings() const;
91 ldns_pkt
* p_
{nullptr};
93 bool authentic_data_
{false};
94 bool bogus_or_indeterminate_
{false};
95 bool nx_domain_
{false};
100 RR_list(RR_list
const&) = delete;
101 RR_list
& operator=(RR_list
const&) = delete;
103 explicit RR_list(Query
const& q
);
106 DNS::RR_collection
get_records() const;
107 std::vector
<std::string
> get_strings() const;
110 ldns_rr_list
* rrlst_answer_
{nullptr};
111 ldns_rr_list
* rrlst_additional_
{nullptr};
114 inline std::vector
<std::string
>
115 get_strings(Resolver
const& res
, DNS::RR_type type
, char const* domain
)
117 return res
.get_strings(type
, domain
);
120 inline std::vector
<std::string
>
121 get_strings(Resolver
const& res
, DNS::RR_type type
, std::string
const& domain
)
123 return res
.get_strings(type
, domain
.c_str());
127 has_record(Resolver
const& res
, DNS::RR_type type
, char const* domain
)
129 auto rr_set
= res
.get_records(type
, domain
);
130 return !rr_set
.empty();
134 has_record(Resolver
const& res
, DNS::RR_type type
, std::string
const& domain
)
136 return has_record(res
, type
, domain
.c_str());
139 } // namespace DNS_ldns
141 #endif // DNS_LDNS_DOT_HPP