"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "test/dns-proto.h" between
c-ares-1.17.1.tar.gz and c-ares-1.17.2.tar.gz

About: c-ares is a C library for asynchronous DNS requests (including name resolves).

dns-proto.h  (c-ares-1.17.1):dns-proto.h  (c-ares-1.17.2)
// -*- mode: c++ -*- // -*- mode: c++ -*-
#ifndef DNS_PROTO_H #ifndef DNS_PROTO_H
#define DNS_PROTO_H #define DNS_PROTO_H
// Utilities for processing DNS packet contents // Utilities for processing DNS packet contents
#include "ares_setup.h"
#include "ares.h"
// Include ares internal file for DNS protocol constants // Include ares internal file for DNS protocol constants
#include "nameser.h" #include "ares_nameser.h"
#include <memory> #include <memory>
#include <string> #include <string>
#include <vector> #include <vector>
namespace ares { namespace ares {
typedef unsigned char byte; typedef unsigned char byte;
std::string HexDump(std::vector<byte> data); std::string HexDump(std::vector<byte> data);
skipping to change at line 43 skipping to change at line 45
const byte** data, int* len); const byte** data, int* len);
std::string RRToString(const std::vector<byte>& packet, std::string RRToString(const std::vector<byte>& packet,
const byte** data, int* len); const byte** data, int* len);
// Manipulate DNS protocol data. // Manipulate DNS protocol data.
void PushInt32(std::vector<byte>* data, int value); void PushInt32(std::vector<byte>* data, int value);
void PushInt16(std::vector<byte>* data, int value); void PushInt16(std::vector<byte>* data, int value);
std::vector<byte> EncodeString(const std::string& name); std::vector<byte> EncodeString(const std::string& name);
struct DNSQuestion { struct DNSQuestion {
DNSQuestion(const std::string& name, ns_type rrtype, ns_class qclass) DNSQuestion(const std::string& name, int rrtype, int qclass)
: name_(name), rrtype_(rrtype), qclass_(qclass) {} : name_(name), rrtype_(rrtype), qclass_(qclass) {}
DNSQuestion(const std::string& name, ns_type rrtype) DNSQuestion(const std::string& name, int rrtype)
: name_(name), rrtype_(rrtype), qclass_(ns_c_in) {} : name_(name), rrtype_(rrtype), qclass_(C_IN) {}
virtual ~DNSQuestion() {} virtual ~DNSQuestion() {}
virtual std::vector<byte> data() const; virtual std::vector<byte> data() const;
std::string name_; std::string name_;
ns_type rrtype_; int rrtype_;
ns_class qclass_; int qclass_;
}; };
struct DNSRR : public DNSQuestion { struct DNSRR : public DNSQuestion {
DNSRR(const std::string& name, ns_type rrtype, ns_class qclass, int ttl) DNSRR(const std::string& name, int rrtype, int qclass, int ttl)
: DNSQuestion(name, rrtype, qclass), ttl_(ttl) {} : DNSQuestion(name, rrtype, qclass), ttl_(ttl) {}
DNSRR(const std::string& name, ns_type rrtype, int ttl) DNSRR(const std::string& name, int rrtype, int ttl)
: DNSQuestion(name, rrtype), ttl_(ttl) {} : DNSQuestion(name, rrtype), ttl_(ttl) {}
virtual ~DNSRR() {} virtual ~DNSRR() {}
virtual std::vector<byte> data() const = 0; virtual std::vector<byte> data() const = 0;
int ttl_; int ttl_;
}; };
struct DNSAddressRR : public DNSRR { struct DNSAddressRR : public DNSRR {
DNSAddressRR(const std::string& name, ns_type rrtype, int ttl, DNSAddressRR(const std::string& name, int rrtype, int ttl,
const byte* addr, int addrlen) const byte* addr, int addrlen)
: DNSRR(name, rrtype, ttl), addr_(addr, addr + addrlen) {} : DNSRR(name, rrtype, ttl), addr_(addr, addr + addrlen) {}
DNSAddressRR(const std::string& name, ns_type rrtype, int ttl, DNSAddressRR(const std::string& name, int rrtype, int ttl,
const std::vector<byte>& addr) const std::vector<byte>& addr)
: DNSRR(name, rrtype, ttl), addr_(addr) {} : DNSRR(name, rrtype, ttl), addr_(addr) {}
virtual std::vector<byte> data() const; virtual std::vector<byte> data() const;
std::vector<byte> addr_; std::vector<byte> addr_;
}; };
struct DNSARR : public DNSAddressRR { struct DNSARR : public DNSAddressRR {
DNSARR(const std::string& name, int ttl, const byte* addr, int addrlen) DNSARR(const std::string& name, int ttl, const byte* addr, int addrlen)
: DNSAddressRR(name, ns_t_a, ttl, addr, addrlen) {} : DNSAddressRR(name, T_A, ttl, addr, addrlen) {}
DNSARR(const std::string& name, int ttl, const std::vector<byte>& addr) DNSARR(const std::string& name, int ttl, const std::vector<byte>& addr)
: DNSAddressRR(name, ns_t_a, ttl, addr) {} : DNSAddressRR(name, T_A, ttl, addr) {}
}; };
struct DNSAaaaRR : public DNSAddressRR { struct DNSAaaaRR : public DNSAddressRR {
DNSAaaaRR(const std::string& name, int ttl, const byte* addr, int addrlen) DNSAaaaRR(const std::string& name, int ttl, const byte* addr, int addrlen)
: DNSAddressRR(name, ns_t_aaaa, ttl, addr, addrlen) {} : DNSAddressRR(name, T_AAAA, ttl, addr, addrlen) {}
DNSAaaaRR(const std::string& name, int ttl, const std::vector<byte>& addr) DNSAaaaRR(const std::string& name, int ttl, const std::vector<byte>& addr)
: DNSAddressRR(name, ns_t_aaaa, ttl, addr) {} : DNSAddressRR(name, T_AAAA, ttl, addr) {}
}; };
struct DNSSingleNameRR : public DNSRR { struct DNSSingleNameRR : public DNSRR {
DNSSingleNameRR(const std::string& name, ns_type rrtype, int ttl, DNSSingleNameRR(const std::string& name, int rrtype, int ttl,
const std::string& other) const std::string& other)
: DNSRR(name, rrtype, ttl), other_(other) {} : DNSRR(name, rrtype, ttl), other_(other) {}
virtual std::vector<byte> data() const; virtual std::vector<byte> data() const;
std::string other_; std::string other_;
}; };
struct DNSCnameRR : public DNSSingleNameRR { struct DNSCnameRR : public DNSSingleNameRR {
DNSCnameRR(const std::string& name, int ttl, const std::string& other) DNSCnameRR(const std::string& name, int ttl, const std::string& other)
: DNSSingleNameRR(name, ns_t_cname, ttl, other) {} : DNSSingleNameRR(name, T_CNAME, ttl, other) {}
}; };
struct DNSNsRR : public DNSSingleNameRR { struct DNSNsRR : public DNSSingleNameRR {
DNSNsRR(const std::string& name, int ttl, const std::string& other) DNSNsRR(const std::string& name, int ttl, const std::string& other)
: DNSSingleNameRR(name, ns_t_ns, ttl, other) {} : DNSSingleNameRR(name, T_NS, ttl, other) {}
}; };
struct DNSPtrRR : public DNSSingleNameRR { struct DNSPtrRR : public DNSSingleNameRR {
DNSPtrRR(const std::string& name, int ttl, const std::string& other) DNSPtrRR(const std::string& name, int ttl, const std::string& other)
: DNSSingleNameRR(name, ns_t_ptr, ttl, other) {} : DNSSingleNameRR(name, T_PTR, ttl, other) {}
}; };
struct DNSTxtRR : public DNSRR { struct DNSTxtRR : public DNSRR {
DNSTxtRR(const std::string& name, int ttl, const std::vector<std::string>& txt ) DNSTxtRR(const std::string& name, int ttl, const std::vector<std::string>& txt )
: DNSRR(name, ns_t_txt, ttl), txt_(txt) {} : DNSRR(name, T_TXT, ttl), txt_(txt) {}
virtual std::vector<byte> data() const; virtual std::vector<byte> data() const;
std::vector<std::string> txt_; std::vector<std::string> txt_;
}; };
struct DNSMxRR : public DNSRR { struct DNSMxRR : public DNSRR {
DNSMxRR(const std::string& name, int ttl, int pref, const std::string& other) DNSMxRR(const std::string& name, int ttl, int pref, const std::string& other)
: DNSRR(name, ns_t_mx, ttl), pref_(pref), other_(other) {} : DNSRR(name, T_MX, ttl), pref_(pref), other_(other) {}
virtual std::vector<byte> data() const; virtual std::vector<byte> data() const;
int pref_; int pref_;
std::string other_; std::string other_;
}; };
struct DNSSrvRR : public DNSRR { struct DNSSrvRR : public DNSRR {
DNSSrvRR(const std::string& name, int ttl, DNSSrvRR(const std::string& name, int ttl,
int prio, int weight, int port, const std::string& target) int prio, int weight, int port, const std::string& target)
: DNSRR(name, ns_t_srv, ttl), prio_(prio), weight_(weight), port_(port), tar get_(target) {} : DNSRR(name, T_SRV, ttl), prio_(prio), weight_(weight), port_(port), target _(target) {}
virtual std::vector<byte> data() const; virtual std::vector<byte> data() const;
int prio_; int prio_;
int weight_; int weight_;
int port_; int port_;
std::string target_; std::string target_;
}; };
struct DNSSoaRR : public DNSRR { struct DNSSoaRR : public DNSRR {
DNSSoaRR(const std::string& name, int ttl, DNSSoaRR(const std::string& name, int ttl,
const std::string& nsname, const std::string& rname, const std::string& nsname, const std::string& rname,
int serial, int refresh, int retry, int expire, int minimum) int serial, int refresh, int retry, int expire, int minimum)
: DNSRR(name, ns_t_soa, ttl), nsname_(nsname), rname_(rname), : DNSRR(name, T_SOA, ttl), nsname_(nsname), rname_(rname),
serial_(serial), refresh_(refresh), retry_(retry), serial_(serial), refresh_(refresh), retry_(retry),
expire_(expire), minimum_(minimum) {} expire_(expire), minimum_(minimum) {}
virtual std::vector<byte> data() const; virtual std::vector<byte> data() const;
std::string nsname_; std::string nsname_;
std::string rname_; std::string rname_;
int serial_; int serial_;
int refresh_; int refresh_;
int retry_; int retry_;
int expire_; int expire_;
int minimum_; int minimum_;
}; };
struct DNSNaptrRR : public DNSRR { struct DNSNaptrRR : public DNSRR {
DNSNaptrRR(const std::string& name, int ttl, DNSNaptrRR(const std::string& name, int ttl,
int order, int pref, int order, int pref,
const std::string& flags, const std::string& flags,
const std::string& service, const std::string& service,
const std::string& regexp, const std::string& regexp,
const std::string& replacement) const std::string& replacement)
: DNSRR(name, ns_t_naptr, ttl), order_(order), pref_(pref), : DNSRR(name, T_NAPTR, ttl), order_(order), pref_(pref),
flags_(flags), service_(service), regexp_(regexp), replacement_(replacemen t) {} flags_(flags), service_(service), regexp_(regexp), replacement_(replacemen t) {}
virtual std::vector<byte> data() const; virtual std::vector<byte> data() const;
int order_; int order_;
int pref_; int pref_;
std::string flags_; std::string flags_;
std::string service_; std::string service_;
std::string regexp_; std::string regexp_;
std::string replacement_; std::string replacement_;
}; };
struct DNSOption { struct DNSOption {
int code_; int code_;
std::vector<byte> data_; std::vector<byte> data_;
}; };
struct DNSOptRR : public DNSRR { struct DNSOptRR : public DNSRR {
DNSOptRR(int extrcode, int udpsize) DNSOptRR(int extrcode, int udpsize)
: DNSRR("", ns_t_opt, static_cast<ns_class>(udpsize), extrcode) {} : DNSRR("", T_OPT, static_cast<int>(udpsize), extrcode) {}
virtual std::vector<byte> data() const; virtual std::vector<byte> data() const;
std::vector<DNSOption> opts_; std::vector<DNSOption> opts_;
}; };
struct DNSPacket { struct DNSPacket {
DNSPacket() DNSPacket()
: qid_(0), response_(false), opcode_(ns_o_query), : qid_(0), response_(false), opcode_(O_QUERY),
aa_(false), tc_(false), rd_(false), ra_(false), aa_(false), tc_(false), rd_(false), ra_(false),
z_(false), ad_(false), cd_(false), rcode_(ns_r_noerror) {} z_(false), ad_(false), cd_(false), rcode_(NOERROR) {}
// Convenience functions that take ownership of given pointers. // Convenience functions that take ownership of given pointers.
DNSPacket& add_question(DNSQuestion *q) { DNSPacket& add_question(DNSQuestion *q) {
questions_.push_back(std::unique_ptr<DNSQuestion>(q)); questions_.push_back(std::unique_ptr<DNSQuestion>(q));
return *this; return *this;
} }
DNSPacket& add_answer(DNSRR *q) { DNSPacket& add_answer(DNSRR *q) {
answers_.push_back(std::unique_ptr<DNSRR>(q)); answers_.push_back(std::unique_ptr<DNSRR>(q));
return *this; return *this;
} }
DNSPacket& add_auth(DNSRR *q) { DNSPacket& add_auth(DNSRR *q) {
skipping to change at line 217 skipping to change at line 219
// Chainable setters. // Chainable setters.
DNSPacket& set_qid(int qid) { qid_ = qid; return *this; } DNSPacket& set_qid(int qid) { qid_ = qid; return *this; }
DNSPacket& set_response(bool v = true) { response_ = v; return *this; } DNSPacket& set_response(bool v = true) { response_ = v; return *this; }
DNSPacket& set_aa(bool v = true) { aa_ = v; return *this; } DNSPacket& set_aa(bool v = true) { aa_ = v; return *this; }
DNSPacket& set_tc(bool v = true) { tc_ = v; return *this; } DNSPacket& set_tc(bool v = true) { tc_ = v; return *this; }
DNSPacket& set_rd(bool v = true) { rd_ = v; return *this; } DNSPacket& set_rd(bool v = true) { rd_ = v; return *this; }
DNSPacket& set_ra(bool v = true) { ra_ = v; return *this; } DNSPacket& set_ra(bool v = true) { ra_ = v; return *this; }
DNSPacket& set_z(bool v = true) { z_ = v; return *this; } DNSPacket& set_z(bool v = true) { z_ = v; return *this; }
DNSPacket& set_ad(bool v = true) { ad_ = v; return *this; } DNSPacket& set_ad(bool v = true) { ad_ = v; return *this; }
DNSPacket& set_cd(bool v = true) { cd_ = v; return *this; } DNSPacket& set_cd(bool v = true) { cd_ = v; return *this; }
DNSPacket& set_rcode(ns_rcode rcode) { rcode_ = rcode; return *this; } DNSPacket& set_rcode(int rcode) { rcode_ = rcode; return *this; }
// Return the encoded packet. // Return the encoded packet.
std::vector<byte> data() const; std::vector<byte> data() const;
int qid_; int qid_;
bool response_; bool response_;
ns_opcode opcode_; int opcode_;
bool aa_; bool aa_;
bool tc_; bool tc_;
bool rd_; bool rd_;
bool ra_; bool ra_;
bool z_; bool z_;
bool ad_; bool ad_;
bool cd_; bool cd_;
ns_rcode rcode_; int rcode_;
std::vector<std::unique_ptr<DNSQuestion>> questions_; std::vector<std::unique_ptr<DNSQuestion>> questions_;
std::vector<std::unique_ptr<DNSRR>> answers_; std::vector<std::unique_ptr<DNSRR>> answers_;
std::vector<std::unique_ptr<DNSRR>> auths_; std::vector<std::unique_ptr<DNSRR>> auths_;
std::vector<std::unique_ptr<DNSRR>> adds_; std::vector<std::unique_ptr<DNSRR>> adds_;
}; };
} // namespace ares } // namespace ares
#endif #endif
 End of changes. 28 change blocks. 
29 lines changed or deleted 31 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)