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 truncation() const { return truncation_
; }
86 bool nx_domain() const { return nx_domain_
; }
88 DNS::RR_collection
get_records() const;
89 std::vector
<std::string
> get_strings() const;
92 ldns_pkt
* p_
{nullptr};
94 bool authentic_data_
{false};
95 bool bogus_or_indeterminate_
{false};
96 bool truncation_
{false};
97 bool nx_domain_
{false};
102 RR_list(RR_list
const&) = delete;
103 RR_list
& operator=(RR_list
const&) = delete;
105 explicit RR_list(Query
const& q
);
108 DNS::RR_collection
get_records() const;
109 std::vector
<std::string
> get_strings() const;
112 ldns_rr_list
* rrlst_answer_
{nullptr};
113 ldns_rr_list
* rrlst_additional_
{nullptr};
116 inline std::vector
<std::string
>
117 get_strings(Resolver
const& res
, DNS::RR_type type
, char const* domain
)
119 return res
.get_strings(type
, domain
);
122 inline std::vector
<std::string
>
123 get_strings(Resolver
const& res
, DNS::RR_type type
, std::string
const& domain
)
125 return res
.get_strings(type
, domain
.c_str());
129 has_record(Resolver
const& res
, DNS::RR_type type
, char const* domain
)
131 auto rr_set
= res
.get_records(type
, domain
);
132 return !rr_set
.empty();
136 has_record(Resolver
const& res
, DNS::RR_type type
, std::string
const& domain
)
138 return has_record(res
, type
, domain
.c_str());
141 } // namespace DNS_ldns
143 #endif // DNS_LDNS_DOT_HPP