[svn] commit: r145 - in /branches/f2f200910/src/lib/dns: buffer.cc buffer.h message.cc message.h message_unittest.cc name.cc name.h name_unittest.cc rrset.cc rrset.h rrset_unittest.cc
BIND 10 source code commits
bind10-changes at lists.isc.org
Wed Oct 28 22:56:10 UTC 2009
Author: jinmei
Date: Wed Oct 28 22:56:10 2009
New Revision: 145
Log:
change method names to likeThis() based on coding guidelines
Modified:
branches/f2f200910/src/lib/dns/buffer.cc
branches/f2f200910/src/lib/dns/buffer.h
branches/f2f200910/src/lib/dns/message.cc
branches/f2f200910/src/lib/dns/message.h
branches/f2f200910/src/lib/dns/message_unittest.cc
branches/f2f200910/src/lib/dns/name.cc
branches/f2f200910/src/lib/dns/name.h
branches/f2f200910/src/lib/dns/name_unittest.cc
branches/f2f200910/src/lib/dns/rrset.cc
branches/f2f200910/src/lib/dns/rrset.h
branches/f2f200910/src/lib/dns/rrset_unittest.cc
Modified: branches/f2f200910/src/lib/dns/buffer.cc
==============================================================================
--- branches/f2f200910/src/lib/dns/buffer.cc (original)
+++ branches/f2f200910/src/lib/dns/buffer.cc Wed Oct 28 22:56:10 2009
@@ -23,7 +23,7 @@
// The interface should be revisited.
int
-SingleBuffer::send_to(int s, const struct sockaddr& to, socklen_t to_len)
+SingleBuffer::sendTo(int s, const struct sockaddr& to, socklen_t to_len)
{
int cc;
@@ -32,7 +32,7 @@
}
int
-SingleBuffer::recv_from(int s, struct sockaddr* from, socklen_t* from_len)
+SingleBuffer::recvFrom(int s, struct sockaddr* from, socklen_t* from_len)
{
int cc;
Modified: branches/f2f200910/src/lib/dns/buffer.h
==============================================================================
--- branches/f2f200910/src/lib/dns/buffer.h (original)
+++ branches/f2f200910/src/lib/dns/buffer.h Wed Oct 28 22:56:10 2009
@@ -39,20 +39,20 @@
public:
virtual ~Buffer() {}
virtual void reserve(size_t len) = 0;
- virtual void write_data(const void *cp, size_t len) = 0;
- virtual void write_uint32(uint32_t data) = 0;
- virtual void write_uint16(uint16_t data) = 0;
- virtual void write_uint16_at(uint16_t data, size_t pos) = 0;
- virtual void write_uint8(uint8_t data) = 0;
- virtual int send_to(int s, const struct sockaddr& to, socklen_t to_len) = 0;
+ virtual void writeData(const void *cp, size_t len) = 0;
+ virtual void writeUint32(uint32_t data) = 0;
+ virtual void writeUint16(uint16_t data) = 0;
+ virtual void writeUint16At(uint16_t data, size_t pos) = 0;
+ virtual void writeUint8(uint8_t data) = 0;
+ virtual int sendTo(int s, const struct sockaddr& to, socklen_t to_len) = 0;
- virtual size_t get_size() const = 0;
- virtual size_t get_space() const = 0;
- virtual size_t get_current() const = 0;
- virtual uint8_t read_uint8() = 0;
- virtual uint16_t read_uint16() = 0;
- virtual int recv_from(int s, struct sockaddr *from,
- socklen_t *from_len) = 0;
+ virtual size_t getSize() const = 0;
+ virtual size_t getSpace() const = 0;
+ virtual size_t getCurrent() const = 0;
+ virtual uint8_t readUint8() = 0;
+ virtual uint16_t readUint16() = 0;
+ virtual int recvFrom(int s, struct sockaddr *from,
+ socklen_t *from_len) = 0;
};
// I/O Buffer with a single array-style storage
@@ -64,24 +64,24 @@
{
buf_.resize(len);
}
- void write_data(const void *data, size_t len)
+ void writeData(const void *data, size_t len)
{
const uint8_t* cp = static_cast<const uint8_t*>(data);
buf_.insert(buf_.end(), cp, cp + len);
}
- void write_uint32(uint32_t data)
+ void writeUint32(uint32_t data)
{
data = htonl(data);
uint8_t* cp = static_cast<uint8_t*>((void*)&data);
buf_.insert(buf_.end(), cp, cp + sizeof(uint32_t));
}
- void write_uint16(uint16_t data)
+ void writeUint16(uint16_t data)
{
data = htons(data);
uint8_t* cp = static_cast<uint8_t*>((void*)&data);
buf_.insert(buf_.end(), cp, cp + sizeof(uint16_t));
}
- void write_uint16_at(uint16_t data, size_t pos)
+ void writeUint16At(uint16_t data, size_t pos)
{
if (pos + sizeof(data) >= buf_.size())
throw isc::ISCBufferInvalidPosition();
@@ -90,18 +90,18 @@
uint8_t* cp = static_cast<uint8_t*>((void*)&data);
copy(cp, cp + sizeof(uint16_t), buf_.begin() + pos);
}
- void write_uint8(uint8_t data)
+ void writeUint8(uint8_t data)
{
buf_.push_back(data);
}
- int send_to(int s, const struct sockaddr& to, socklen_t to_len);
+ int sendTo(int s, const struct sockaddr& to, socklen_t to_len);
- size_t get_size() const { return (buf_.size()); }
- size_t get_space() const { return (buf_.size() - _readpos); }
- size_t get_current() const { return (_readpos); }
- uint8_t read_uint8();
- uint16_t read_uint16();
- int recv_from(int s, struct sockaddr* from, socklen_t* from_len);
+ size_t getSize() const { return (buf_.size()); }
+ size_t getSpace() const { return (buf_.size() - _readpos); }
+ size_t getCurrent() const { return (_readpos); }
+ uint8_t readUint8();
+ uint16_t readUint16();
+ int recvFrom(int s, struct sockaddr* from, socklen_t* from_len);
private:
size_t _readpos;
@@ -109,7 +109,7 @@
};
inline uint8_t
-SingleBuffer::read_uint8()
+SingleBuffer::readUint8()
{
if (_readpos + sizeof(uint8_t) > buf_.size())
throw ISCBufferInvalidPosition();
@@ -118,7 +118,7 @@
}
inline uint16_t
-SingleBuffer::read_uint16()
+SingleBuffer::readUint16()
{
uint16_t data;
Modified: branches/f2f200910/src/lib/dns/message.cc
==============================================================================
--- branches/f2f200910/src/lib/dns/message.cc (original)
+++ branches/f2f200910/src/lib/dns/message.cc Wed Oct 28 22:56:10 2009
@@ -77,7 +77,7 @@
}
void
-Message::add_rrset(section_t section, RRsetPtr rrsetp)
+Message::addRrset(section_t section, RRsetPtr rrsetp)
{
if (section >= SECTION_MAX)
throw DNSInvalidMessageSection();
@@ -87,14 +87,14 @@
}
void
-Message::add_question(const Name& qname, const RRClass& qclass,
+Message::addQuestion(const Name& qname, const RRClass& qclass,
const RRType& qtype)
{
- add_rrset(SECTION_QUESTION, RRsetPtr(new Question(qname, qclass, qtype)));
-}
-
-void
-Message::to_wire()
+ addRrset(SECTION_QUESTION, RRsetPtr(new Question(qname, qclass, qtype)));
+}
+
+void
+Message::toWire()
{
uint16_t codes_and_flags;
@@ -109,12 +109,12 @@
sorter_->sort(*this, (section_t)section); //TBD
counts_[section] = 0;
for (std::vector<RRsetPtr>::const_iterator it =
- get_section((section_t)section).begin();
- it != get_section((section_t)section).end();
+ getSection((section_t)section).begin();
+ it != getSection((section_t)section).end();
++it)
{
- int counter = (*it)->to_wire(*buffer_, get_compressor(),
- (section_t)section);
+ int counter = (*it)->toWire(*buffer_, getCompressor(),
+ (section_t)section);
// TBD: if truncation is necessary, do something special.
// throw an exception, return an error code (in which case the
@@ -128,37 +128,37 @@
// fill in the header
size_t header_pos = 0;
- buffer_->write_uint16_at(qid_, header_pos);
+ buffer_->writeUint16At(qid_, header_pos);
header_pos += sizeof(uint16_t);
codes_and_flags = (opcode_ << OPCODE_SHIFT) & OPCODE_MASK;
codes_and_flags |= (rcode_ & RCODE_MASK);
codes_and_flags |= (flags_ & FLAG_MASK);
- buffer_->write_uint16_at(codes_and_flags, header_pos);
+ buffer_->writeUint16At(codes_and_flags, header_pos);
header_pos += sizeof(uint16_t);
for (int section = SECTION_QUESTION; section < SECTION_MAX; ++section) {
- buffer_->write_uint16_at(counts_[section], header_pos);
+ buffer_->writeUint16At(counts_[section], header_pos);
header_pos += sizeof(uint16_t);
}
}
void
-Message::from_wire()
+Message::fromWire()
{
if (buffer_ == NULL)
throw DNSNoMessageBuffer();
- if (buffer_->get_space() < HEADERLEN)
+ if (buffer_->getSpace() < HEADERLEN)
throw DNSMessageTooShort();
- qid_ = buffer_->read_uint16();
- uint16_t codes_and_flags = buffer_->read_uint16();
+ qid_ = buffer_->readUint16();
+ uint16_t codes_and_flags = buffer_->readUint16();
opcode_ = ((codes_and_flags & OPCODE_MASK) >> OPCODE_SHIFT);
rcode_ = (codes_and_flags & RCODE_MASK);
flags_ = (codes_and_flags & FLAG_MASK);
- counts_[SECTION_QUESTION] = buffer_->read_uint16();
- counts_[SECTION_ANSWER] = buffer_->read_uint16();
- counts_[SECTION_AUTHORITY] = buffer_->read_uint16();
- counts_[SECTION_ADDITIONAL] = buffer_->read_uint16();
+ counts_[SECTION_QUESTION] = buffer_->readUint16();
+ counts_[SECTION_ANSWER] = buffer_->readUint16();
+ counts_[SECTION_AUTHORITY] = buffer_->readUint16();
+ counts_[SECTION_ADDITIONAL] = buffer_->readUint16();
parse_question();
// parse other sections (TBD)
@@ -173,20 +173,20 @@
throw DNSNoMessageBuffer();
for (int count = 0; count < this->counts_[SECTION_QUESTION]; count++) {
- Name name(*buffer_, get_decompressor());
+ Name name(*buffer_, getDecompressor());
// Get type and class
- if (buffer_->get_space() < 2 * sizeof(uint16_t))
+ if (buffer_->getSpace() < 2 * sizeof(uint16_t))
throw DNSMessageTooShort();
// XXX: need a duplicate check. We might also want to have an optimized
// algorithm that requires the question section contain exactly one
// RR.
- RRType rrtype(buffer_->read_uint16());
- RRClass rrclass(buffer_->read_uint16());
- add_rrset(SECTION_QUESTION,
- RRsetPtr(new Question(name, rrclass, rrtype)));
+ RRType rrtype(buffer_->readUint16());
+ RRClass rrclass(buffer_->readUint16());
+ addRrset(SECTION_QUESTION,
+ RRsetPtr(new Question(name, rrclass, rrtype)));
}
}
@@ -236,7 +236,7 @@
};
std::string
-Message::to_text() const
+Message::toText() const
{
std::string s;
@@ -245,19 +245,19 @@
s += ", status: " + std::string(rcodetext[rcode_]);
s += ", id: " + boost::lexical_cast<std::string>(qid_);
s += "\n;; flags: ";
- if (get_qr())
+ if (getQr())
s += "qr ";
- if (get_aa())
+ if (getAa())
s += "aa ";
- if (get_tc())
+ if (getTc())
s += "tc ";
- if (get_rd())
+ if (getRd())
s += "rd ";
- if (get_ra())
+ if (getRa())
s += "ra ";
- if (get_ad())
+ if (getAd())
s += "ad ";
- if (get_cd())
+ if (getCd())
s += "cd ";
// for simply, don't consider the update case
@@ -283,7 +283,7 @@
{
if (section == SECTION_QUESTION)
s += ";";
- s += (**it).to_text() + "\n";
+ s += (**it).toText() + "\n";
}
}
@@ -293,34 +293,34 @@
struct MatchRR : public std::binary_function<RRsetPtr, RR, bool> {
bool operator()(const RRsetPtr& rrset, const RR& rr) const
{
- return (rrset->get_type() == rr.get_type() &&
- rrset->get_class() == rr.get_class() &&
- rrset->get_name() == rr.get_name());
+ return (rrset->getType() == rr.getType() &&
+ rrset->getClass() == rr.getClass() &&
+ rrset->getName() == rr.getName());
}
};
void
-Message::add_rr(section_t section, const RR& rr)
+Message::addRr(section_t section, const RR& rr)
{
std::vector<RRsetPtr>::iterator it;
it = find_if(sections_[section].begin(), sections_[section].end(),
std::bind2nd(MatchRR(), rr));
if (it != sections_[section].end()) {
- (*it)->set_ttl(std::min((*it)->get_ttl(), rr.get_ttl()));
- (*it)->add_rdata(Rdata::RDATAPTR(rr.get_rdata()->copy()));
+ (*it)->setTtl(std::min((*it)->getTtl(), rr.getTtl()));
+ (*it)->addRdata(Rdata::RDATAPTR(rr.getRdata()->copy()));
} else {
- RRset *rrset = new RRset(rr.get_name(), rr.get_class(), rr.get_type(),
- rr.get_ttl());
- rrset->add_rdata(Rdata::RDATAPTR(rr.get_rdata()->copy()));
+ RRset *rrset = new RRset(rr.getName(), rr.getClass(), rr.getType(),
+ rr.getTtl());
+ rrset->addRdata(Rdata::RDATAPTR(rr.getRdata()->copy()));
sections_[section].push_back(RRsetPtr(rrset));
}
}
void
-Message::make_response()
+Message::makeResponse()
{
flags_ &= MESSAGE_REPLYPRESERVE;
- set_qr(true);
+ setQr(true);
for (int section = SECTION_ANSWER; section < SECTION_MAX; ++section) {
sections_[section].clear();
Modified: branches/f2f200910/src/lib/dns/message.h
==============================================================================
--- branches/f2f200910/src/lib/dns/message.h (original)
+++ branches/f2f200910/src/lib/dns/message.h Wed Oct 28 22:56:10 2009
@@ -46,10 +46,10 @@
void sort(Message& message, section_t section) {} // dummy for now.
};
-#define get_msgflg(flg, capflg) \
-bool get_ ## flg() const { return ((flags_ & FLAG_ ## capflg) != 0); }
-#define set_msgflg(flg, capflg) \
-bool set_ ## flg(bool on) { \
+#define getMsgFlg(flg, capflg) \
+bool get ## flg() const { return ((flags_ & FLAG_ ## capflg) != 0); }
+#define setMsgFlg(flg, capflg) \
+bool set ## flg(bool on) { \
if (on) \
flags_ |= FLAG_ ## capflg; \
else \
@@ -60,27 +60,27 @@
public:
Message();
~Message();
- qid_t get_qid() const { return (qid_); }
- void set_qid(qid_t qid) { qid_ = qid; }
- get_msgflg(rd, RD)
- set_msgflg(rd, RD)
- get_msgflg(aa, AA)
- set_msgflg(aa, AA)
- get_msgflg(qr, QR)
- set_msgflg(qr, QR)
- get_msgflg(tc, TC)
- set_msgflg(tc, TC)
- get_msgflg(ra, RA)
- set_msgflg(ra, RA)
- get_msgflg(ad, AD)
- set_msgflg(ad, AD)
- get_msgflg(cd, CD)
- set_msgflg(cd, CD)
- rcode_t get_rcode() const { return (rcode_); }
- void set_rcode(rcode_t rcode) { rcode_ = rcode; }
- opcode_t get_opcode() const { return (opcode_); }
- void set_opcode(opcode_t opcode) { opcode_ = opcode; }
- std::string to_text() const;
+ qid_t getQid() const { return (qid_); }
+ void setQid(qid_t qid) { qid_ = qid; }
+ getMsgFlg(Rd, RD)
+ setMsgFlg(Rd, RD)
+ getMsgFlg(Aa, AA)
+ setMsgFlg(Aa, AA)
+ getMsgFlg(Qr, QR)
+ setMsgFlg(Qr, QR)
+ getMsgFlg(Tc, TC)
+ setMsgFlg(Tc, TC)
+ getMsgFlg(Ra, RA)
+ setMsgFlg(Ra, RA)
+ getMsgFlg(Ad, AD)
+ setMsgFlg(Ad, AD)
+ getMsgFlg(Cd, CD)
+ setMsgFlg(Cd, CD)
+ rcode_t getRcode() const { return (rcode_); }
+ void setRcode(rcode_t rcode) { rcode_ = rcode; }
+ opcode_t getOpcode() const { return (opcode_); }
+ void setOpcode(opcode_t opcode) { opcode_ = opcode; }
+ std::string toText() const;
// we don't provide accessors to QD/AN/NS/AR counters as this information
// is included in the corresponding RRsets.
@@ -89,16 +89,16 @@
// - may want to provide an "iterator" for all RRsets/RRs
// - may want to provide a "find" method for a specified type
// of RR in the message
- const std::vector<RRsetPtr>& get_section(section_t section) const
+ const std::vector<RRsetPtr>& getSection(section_t section) const
{ return (sections_[section]); }
- void add_rrset(section_t section, RRsetPtr rrset);
- // add_question() is redundant in that it's a special case of add_rrset,
+ void addRrset(section_t section, RRsetPtr rrset);
+ // addQuestion() is redundant in that it's a special case of add_rrset,
// but it'd be convenient for general purpose applications.
- void add_question(const Name& qname, const RRClass& qclass,
- const RRType& qtype);
- void remove_rrset(section_t section, RRsetPtr rrset);
- void add_rr(section_t section, const RR& rr);
- void remove_rr(section_t section, const RR& rr);
+ void addQuestion(const Name& qname, const RRClass& qclass,
+ const RRType& qtype);
+ void removeRrset(section_t section, RRsetPtr rrset);
+ void addRr(section_t section, const RR& rr);
+ void removeRr(section_t section, const RR& rr);
// should we separate methods for different EDNS0-related
// parameters/options? it would probably be better to have a
@@ -106,33 +106,33 @@
// on the other hand, considering we're going to use EDNS0 pretty
// ubiquitously, perhaps we should include currently-defined EDNS0
// parameters and options by default.
- void set_edns(EDNS* edns); // TBD
- const EDNS* get_edns() const; // TBD
+ void setEdns(EDNS* edns); // TBD
+ const EDNS* getEdns() const; // TBD
// prepare for making a response from a request. This will clear the
// DNS header except those fields that should be kept for the response,
// and clear answer and the following sections.
// see also dns_message_reply() of BIND9.
- void make_response();
+ void makeResponse();
// Render message
- void to_wire(); // should probably return some result code?
-
- Buffer& get_buffer()
+ void toWire(); // should probably return some result code?
+
+ Buffer& getBuffer()
{
if (buffer_ == NULL)
throw DNSNoMessageBuffer();
return (*buffer_);
}
- NameCompressor& get_compressor()
+ NameCompressor& getCompressor()
{
if (compressor_ == NULL)
throw DNSNoNameCompressor();
return (*compressor_);
}
- NameDecompressor& get_decompressor()
+ NameDecompressor& getDecompressor()
{
if (decompressor_ == NULL)
throw DNSNoNameDecompressor();
@@ -141,7 +141,7 @@
// Parse message:
// This function may throw exceptions. We may revisit this design.
- void from_wire();
+ void fromWire();
public:
// public protocol constants
Modified: branches/f2f200910/src/lib/dns/message_unittest.cc
==============================================================================
--- branches/f2f200910/src/lib/dns/message_unittest.cc (original)
+++ branches/f2f200910/src/lib/dns/message_unittest.cc Wed Oct 28 22:56:10 2009
@@ -41,7 +41,7 @@
protected:
MessageTest()
{
- query.add_question(Name("www.example.com"), RRClass::IN, RRType::A);
+ query.addQuestion(Name("www.example.com"), RRClass::IN, RRType::A);
}
Message query;
Message response;
@@ -49,76 +49,76 @@
TEST_F(MessageTest, check_flags)
{
- EXPECT_EQ(false, query.get_qr());
- query.set_qr(true);
- EXPECT_EQ(true, query.get_qr());
+ EXPECT_EQ(false, query.getQr());
+ query.setQr(true);
+ EXPECT_EQ(true, query.getQr());
- EXPECT_EQ(false, query.get_aa());
- query.set_aa(true);
- EXPECT_EQ(true, query.get_aa());
+ EXPECT_EQ(false, query.getAa());
+ query.setAa(true);
+ EXPECT_EQ(true, query.getAa());
- EXPECT_EQ(false, query.get_tc());
- query.set_tc(true);
- EXPECT_EQ(true, query.get_tc());
+ EXPECT_EQ(false, query.getTc());
+ query.setTc(true);
+ EXPECT_EQ(true, query.getTc());
- EXPECT_EQ(false, query.get_rd());
- query.set_rd(true);
- EXPECT_EQ(true, query.get_rd());
+ EXPECT_EQ(false, query.getRd());
+ query.setRd(true);
+ EXPECT_EQ(true, query.getRd());
- EXPECT_EQ(false, query.get_ra());
- query.set_ra(true);
- EXPECT_EQ(true, query.get_ra());
+ EXPECT_EQ(false, query.getRa());
+ query.setRa(true);
+ EXPECT_EQ(true, query.getRa());
- EXPECT_EQ(false, query.get_ad());
- query.set_ad(true);
- EXPECT_EQ(true, query.get_ad());
+ EXPECT_EQ(false, query.getAd());
+ query.setAd(true);
+ EXPECT_EQ(true, query.getAd());
- EXPECT_EQ(false, query.get_cd());
- query.set_cd(true);
- EXPECT_EQ(true, query.get_cd());
+ EXPECT_EQ(false, query.getCd());
+ query.setCd(true);
+ EXPECT_EQ(true, query.getCd());
}
-TEST_F(MessageTest, get_question)
+TEST_F(MessageTest, getQuestion)
{
- const std::vector<RRsetPtr>& question = query.get_section(SECTION_QUESTION);
+ const std::vector<RRsetPtr>& question = query.getSection(SECTION_QUESTION);
EXPECT_EQ(1, question.size());
- EXPECT_EQ("www.example.com. IN A", (**question.begin()).to_text());
+ EXPECT_EQ("www.example.com. IN A", (**question.begin()).toText());
}
-TEST_F(MessageTest, make_response)
+TEST_F(MessageTest, makeResponse)
{
- query.make_response();
- EXPECT_EQ(true, query.get_qr());
+ query.makeResponse();
+ EXPECT_EQ(true, query.getQr());
EXPECT_EQ("www.example.com. IN A",
- (**query.get_section(SECTION_QUESTION).begin()).to_text());
- EXPECT_EQ(0, query.get_section(SECTION_ANSWER).size());
- EXPECT_EQ(0, query.get_section(SECTION_AUTHORITY).size());
- EXPECT_EQ(0, query.get_section(SECTION_ADDITIONAL).size());
+ (**query.getSection(SECTION_QUESTION).begin()).toText());
+ EXPECT_EQ(0, query.getSection(SECTION_ANSWER).size());
+ EXPECT_EQ(0, query.getSection(SECTION_AUTHORITY).size());
+ EXPECT_EQ(0, query.getSection(SECTION_ADDITIONAL).size());
}
-TEST_F(MessageTest, add_rr)
+TEST_F(MessageTest, addRr)
{
// Add one RR to the answer section.
- response.add_rr(SECTION_ANSWER, RR(Name("www.example.com"), RRClass::IN,
+ response.addRr(SECTION_ANSWER, RR(Name("www.example.com"), RRClass::IN,
RRType::A, TTL(3600), A("192.0.2.1")));
EXPECT_EQ("www.example.com. 3600 IN A 192.0.2.1",
- (**response.get_section(SECTION_ANSWER).begin()).to_text());
+ (**response.getSection(SECTION_ANSWER).begin()).toText());
// Add another RR of the same RRset with a larger TTL. The original
// (smaller) TTL should remain.
- response.add_rr(SECTION_ANSWER, RR(Name("www.example.com"), RRClass::IN,
+ response.addRr(SECTION_ANSWER, RR(Name("www.example.com"), RRClass::IN,
RRType::A, TTL(7200), A("192.0.2.2")));
EXPECT_EQ("www.example.com. 3600 IN A 192.0.2.1\n"
"www.example.com. 3600 IN A 192.0.2.2",
- (**response.get_section(SECTION_ANSWER).begin()).to_text());
+ (**response.getSection(SECTION_ANSWER).begin()).toText());
// Add one more RR of the same RRset with a smaller TTL. The new (smaller)
// TTL should replace with the old one.
- response.add_rr(SECTION_ANSWER, RR(Name("www.example.com"), RRClass::IN,
+ response.addRr(SECTION_ANSWER, RR(Name("www.example.com"), RRClass::IN,
RRType::A, TTL(1800), A("192.0.2.3")));
EXPECT_EQ("www.example.com. 1800 IN A 192.0.2.1\n"
"www.example.com. 1800 IN A 192.0.2.2\n"
"www.example.com. 1800 IN A 192.0.2.3",
- (**response.get_section(SECTION_ANSWER).begin()).to_text());
+ (**response.getSection(SECTION_ANSWER).begin()).toText());
}
}
Modified: branches/f2f200910/src/lib/dns/name.cc
==============================================================================
--- branches/f2f200910/src/lib/dns/name.cc (original)
+++ branches/f2f200910/src/lib/dns/name.cc Wed Oct 28 22:56:10 2009
@@ -296,14 +296,14 @@
*/
nmax = MAXWIRE;
- current = buffer.get_current();
+ current = buffer.getCurrent();
/*
* Note: The following code is not optimized for speed, but
* rather for correctness. Speed will be addressed in the future.
*/
- while (current < buffer.get_size() && !done) {
- c = buffer.read_uint8();
+ while (current < buffer.getSize() && !done) {
+ c = buffer.readUint8();
current++;
switch (state) {
@@ -362,7 +362,7 @@
}
string
-Name::to_text(bool omit_final_dot) const
+Name::toText(bool omit_final_dot) const
{
string tdata;
unsigned int nlen;
@@ -476,10 +476,10 @@
}
void
-Name::to_wire(Buffer& buffer, NameCompressor& c) const
+Name::toWire(Buffer& buffer, NameCompressor& c) const
{
// TBD: very simple version for prototyping; e.g. it omits compression.
- buffer.write_data(ndata_.c_str(), ndata_.size());
+ buffer.writeData(ndata_.c_str(), ndata_.size());
}
// Are 'this' name and 'other' equal?
@@ -520,6 +520,6 @@
ostream&
operator<<(ostream& os, const Name& name)
{
- os << name.to_text();
+ os << name.toText();
return (os);
}
Modified: branches/f2f200910/src/lib/dns/name.h
==============================================================================
--- branches/f2f200910/src/lib/dns/name.h (original)
+++ branches/f2f200910/src/lib/dns/name.h Wed Oct 28 22:56:10 2009
@@ -41,9 +41,9 @@
explicit NameComparisonResult(int order, int nlabels,
NameRelation relation) :
order_(order), nlabels_(nlabels), relation_(relation) {}
- int get_order() const { return (order_); }
- int get_common_labels() const { return (nlabels_); }
- NameRelation get_relation() const { return (relation_); }
+ int getOrder() const { return (order_); }
+ int getCommonLabels() const { return (nlabels_); }
+ NameRelation getRelation() const { return (relation_); }
private:
int order_;
int nlabels_;
@@ -60,14 +60,14 @@
// destructor (default dtor should work fine)
//~Name();
- std::string to_text(bool omit_final_dot = false) const;
- void to_wire(Buffer& buffer, NameCompressor& compressor) const;
- size_t get_length() const { return (length_); }
- unsigned int get_labels() const { return (labels_); }
+ std::string toText(bool omit_final_dot = false) const;
+ void toWire(Buffer& buffer, NameCompressor& compressor) const;
+ size_t getLength() const { return (length_); }
+ unsigned int getLabels() const { return (labels_); }
NameComparisonResult compare(const Name& other) const;
Name split(unsigned int first, unsigned int n) const;
Name concatenate(const Name& suffix) const;
- bool is_wildcard() const;
+ bool isWildcard() const;
bool equals(const Name& other) const;
bool operator==(const Name& other) const { return (this->equals(other)); }
bool operator!=(const Name& other) const { return (!(*this == other)); }
@@ -88,8 +88,6 @@
std::vector<char> offsets_;
unsigned int length_;
unsigned int labels_;
-
- void from_string(const std::string& namestr);
};
std::ostream& operator<<(std::ostream& os, const Name& name);
Modified: branches/f2f200910/src/lib/dns/name_unittest.cc
==============================================================================
--- branches/f2f200910/src/lib/dns/name_unittest.cc (original)
+++ branches/f2f200910/src/lib/dns/name_unittest.cc Wed Oct 28 22:56:10 2009
@@ -42,15 +42,15 @@
isc::dns::Name *example_name;
};
-TEST_F(NameTest, get_length)
+TEST_F(NameTest, getLength)
{
- EXPECT_EQ(17, static_cast<int>(example_name->get_length()));
+ EXPECT_EQ(17, static_cast<int>(example_name->getLength()));
}
-TEST_F(NameTest, to_text)
+TEST_F(NameTest, toText)
{
- EXPECT_EQ(std::string("www.example.com"), example_name->to_text(true));
- EXPECT_EQ(std::string("www.example.com."), example_name->to_text(false));
+ EXPECT_EQ(std::string("www.example.com"), example_name->toText(true));
+ EXPECT_EQ(std::string("www.example.com."), example_name->toText(false));
}
TEST_F(NameTest, invalid_label)
@@ -72,14 +72,14 @@
EXPECT_EQ(true, *example_name == Name("www.example.com."));
}
-TEST_F(NameTest, to_from_wire)
+TEST_F(NameTest, toFromWire)
{
isc::SingleBuffer buffer;
isc::dns::NameCompressor compressor;
isc::dns::NameDecompressor decompressor;
- example_name->to_wire(buffer, compressor);
+ example_name->toWire(buffer, compressor);
EXPECT_EQ(std::string("www.example.com."),
- Name(buffer, decompressor).to_text(false));
+ Name(buffer, decompressor).toText(false));
}
}
Modified: branches/f2f200910/src/lib/dns/rrset.cc
==============================================================================
--- branches/f2f200910/src/lib/dns/rrset.cc (original)
+++ branches/f2f200910/src/lib/dns/rrset.cc Wed Oct 28 22:56:10 2009
@@ -49,7 +49,7 @@
}
const std::string
-RRClass::to_text() const
+RRClass::toText() const
{
// XXX: quick hack
if (classval_ == 1)
@@ -60,9 +60,9 @@
}
void
-RRClass::to_wire(isc::Buffer& b) const
-{
- b.write_uint16(classval_);
+RRClass::toWire(isc::Buffer& b) const
+{
+ b.writeUint16(classval_);
}
const RRClass RRClass::IN("IN");
@@ -83,7 +83,7 @@
}
const std::string
-RRType::to_text() const
+RRType::toText() const
{
if (typeval_ == 1)
return ("A");
@@ -95,9 +95,9 @@
}
void
-RRType::to_wire(Buffer& buffer) const
-{
- buffer.write_uint16(typeval_);
+RRType::toWire(Buffer& buffer) const
+{
+ buffer.writeUint16(typeval_);
}
const RRType RRType::A("A");
@@ -106,9 +106,9 @@
// ...more to follow
void
-TTL::to_wire(Buffer& buffer) const
-{
- buffer.write_uint32(ttlval_);
+TTL::toWire(Buffer& buffer) const
+{
+ buffer.writeUint32(ttlval_);
}
A::A(const std::string& addrstr)
@@ -118,20 +118,20 @@
}
void
-A::from_wire(Buffer& buffer, NameDecompressor& decompressor)
+A::fromWire(Buffer& buffer, NameDecompressor& decompressor)
{
//TBD
}
void
-A::to_wire(Buffer& buffer, NameCompressor& compressor) const
-{
- buffer.write_uint16(sizeof(addr_));
- buffer.write_data(&addr_, sizeof(addr_));
-}
-
-std::string
-A::to_text() const
+A::toWire(Buffer& buffer, NameCompressor& compressor) const
+{
+ buffer.writeUint16(sizeof(addr_));
+ buffer.writeData(&addr_, sizeof(addr_));
+}
+
+std::string
+A::toText() const
{
char addrbuf[sizeof("255.255.255.255")];
@@ -144,7 +144,7 @@
Rdata*
A::copy() const
{
- return (new A(to_text()));
+ return (new A(toText()));
}
AAAA::AAAA(const std::string& addrstr)
@@ -154,20 +154,20 @@
}
void
-AAAA::from_wire(Buffer& buffer, NameDecompressor& decompressor)
+AAAA::fromWire(Buffer& buffer, NameDecompressor& decompressor)
{
//TBD
}
void
-AAAA::to_wire(Buffer& buffer, NameCompressor& compressor) const
-{
- buffer.write_uint16(sizeof(addr_));
- buffer.write_data(&addr_, sizeof(addr_));
-}
-
-std::string
-AAAA::to_text() const
+AAAA::toWire(Buffer& buffer, NameCompressor& compressor) const
+{
+ buffer.writeUint16(sizeof(addr_));
+ buffer.writeData(&addr_, sizeof(addr_));
+}
+
+std::string
+AAAA::toText() const
{
char addrbuf[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")];
@@ -180,38 +180,38 @@
Rdata*
AAAA::copy() const
{
- return (new AAAA(to_text()));
-}
-
-void
-NS::from_wire(Buffer& buffer, NameDecompressor& decompressor)
+ return (new AAAA(toText()));
+}
+
+void
+NS::fromWire(Buffer& buffer, NameDecompressor& decompressor)
{
//TBD
}
void
-NS::to_wire(Buffer& buffer, NameCompressor& compressor) const
+NS::toWire(Buffer& buffer, NameCompressor& compressor) const
{
// XXX: note that a complete implementation cannot be this simple
// because we need to disable compression for the NS name.
- buffer.write_uint16(nsname_.get_length());
- nsname_.to_wire(buffer, compressor);
-}
-
-std::string
-NS::to_text() const
-{
- return (nsname_.to_text());
+ buffer.writeUint16(nsname_.getLength());
+ nsname_.toWire(buffer, compressor);
+}
+
+std::string
+NS::toText() const
+{
+ return (nsname_.toText());
}
Rdata*
NS::copy() const
{
- return (new NS(to_text()));
-}
-
-std::string
-RRset::to_text() const
+ return (new NS(toText()));
+}
+
+std::string
+RRset::toText() const
{
std::string s;
@@ -221,24 +221,24 @@
{
if (!s.empty())
s.push_back('\n');
- s += name_.to_text() + " ";
- s += ttl_.to_text() + " " + rrclass_.to_text() + " " +
- rrtype_.to_text() + " " + (**it).to_text();
+ s += name_.toText() + " ";
+ s += ttl_.toText() + " " + rrclass_.toText() + " " +
+ rrtype_.toText() + " " + (**it).toText();
}
return (s);
}
void
-RRset::add_rdata(Rdata::RDATAPTR rdata)
-{
- if (rdata->get_type() != rrtype_)
+RRset::addRdata(Rdata::RDATAPTR rdata)
+{
+ if (rdata->getType() != rrtype_)
throw DNSRRtypeMismatch();
rdatalist_.push_back(rdata);
}
int
-RRset::to_wire(Buffer& buffer, NameCompressor& compressor, section_t section)
+RRset::toWire(Buffer& buffer, NameCompressor& compressor, section_t section)
{
int num_rrs = 0;
@@ -251,11 +251,11 @@
it != rdatalist_.end();
++it, ++num_rrs)
{
- name_.to_wire(buffer, compressor);
- rrtype_.to_wire(buffer);
- rrclass_.to_wire(buffer);
- ttl_.to_wire(buffer);
- (**it).to_wire(buffer, compressor);
+ name_.toWire(buffer, compressor);
+ rrtype_.toWire(buffer);
+ rrclass_.toWire(buffer);
+ ttl_.toWire(buffer);
+ (**it).toWire(buffer, compressor);
// TBD: handle truncation case
}
@@ -264,20 +264,20 @@
}
std::string
-Question::to_text() const
+Question::toText() const
{
// return in dig-style format. note that in the wire format class follows
// type.
- return (name_.to_text() + " " + rrclass_.to_text() + " " +
- rrtype_.to_text());
+ return (name_.toText() + " " + rrclass_.toText() + " " +
+ rrtype_.toText());
}
int
-Question::to_wire(Buffer& buffer, NameCompressor& compressor, section_t section)
-{
- name_.to_wire(buffer, compressor);
- rrtype_.to_wire(buffer);
- rrclass_.to_wire(buffer);
+Question::toWire(Buffer& buffer, NameCompressor& compressor, section_t section)
+{
+ name_.toWire(buffer, compressor);
+ rrtype_.toWire(buffer);
+ rrclass_.toWire(buffer);
return (1);
}
@@ -289,11 +289,11 @@
// XXX: this implementation is BAD. we took the ugly bad fastest approach
// for rapid experiment. should rewrite it.
if (rrtype == RRType::A) {
- rrset_.add_rdata(Rdata::RDATAPTR(new A(rdata.to_text())));
+ rrset_.addRdata(Rdata::RDATAPTR(new A(rdata.toText())));
} else if (rrtype == RRType::AAAA) {
- rrset_.add_rdata(Rdata::RDATAPTR(new AAAA(rdata.to_text())));
+ rrset_.addRdata(Rdata::RDATAPTR(new AAAA(rdata.toText())));
} else if (rrtype == RRType::NS) {
- rrset_.add_rdata(Rdata::RDATAPTR(new NS(rdata.to_text())));
+ rrset_.addRdata(Rdata::RDATAPTR(new NS(rdata.toText())));
} else {
// XXX
throw std::runtime_error("RR constructor encountered "
Modified: branches/f2f200910/src/lib/dns/rrset.h
==============================================================================
--- branches/f2f200910/src/lib/dns/rrset.h (original)
+++ branches/f2f200910/src/lib/dns/rrset.h Wed Oct 28 22:56:10 2009
@@ -46,9 +46,9 @@
RRClass() {}
explicit RRClass(uint16_t classval) : classval_(classval) {}
explicit RRClass(const std::string& classstr);
- const std::string to_text() const;
- void to_wire(Buffer& b) const;
- uint16_t get_value() const { return (classval_); }
+ const std::string toText() const;
+ void toWire(Buffer& b) const;
+ uint16_t getValue() const { return (classval_); }
bool operator==(const RRClass& other) const
{ return (classval_ == other.classval_); }
bool operator!=(const RRClass& other) const
@@ -66,9 +66,9 @@
RRType() {}
explicit RRType(uint16_t typeval) : typeval_(typeval) {}
explicit RRType(const std::string& typestr);
- const std::string to_text() const;
- void to_wire(Buffer& b) const;
- uint16_t get_value() const { return (typeval_); }
+ const std::string toText() const;
+ void toWire(Buffer& b) const;
+ uint16_t getValue() const { return (typeval_); }
bool operator==(const RRType& other) const
{ return (typeval_ == other.typeval_); }
bool operator!=(const RRType& other) const
@@ -88,10 +88,10 @@
public:
TTL() {}
explicit TTL(uint32_t ttlval) : ttlval_(ttlval) {}
- std::string to_text() const
+ std::string toText() const
{ return (boost::lexical_cast<std::string>(ttlval_)); }
- void to_wire(Buffer& b) const;
- uint32_t get_value() { return (ttlval_); }
+ void toWire(Buffer& b) const;
+ uint32_t getValue() { return (ttlval_); }
bool operator==(const TTL& other) const
{ return (ttlval_ == other.ttlval_); }
bool operator!=(const TTL& other) const
@@ -123,10 +123,10 @@
public:
virtual ~Rdata() {};
virtual unsigned int count() const = 0;
- virtual const RRType& get_type() const = 0;
- virtual std::string to_text() const = 0;
- virtual void from_wire(Buffer& b, NameDecompressor& c) = 0;
- virtual void to_wire(Buffer& b, NameCompressor& c) const = 0;
+ virtual const RRType& getType() const = 0;
+ virtual std::string toText() const = 0;
+ virtual void fromWire(Buffer& b, NameDecompressor& c) = 0;
+ virtual void toWire(Buffer& b, NameCompressor& c) const = 0;
// need generic method for getting n-th field? c.f. ldns
// e.g. string getField(int n);
@@ -141,12 +141,12 @@
explicit NS(const std::string& namestr) : nsname_(namestr) {}
explicit NS(const Name& nsname) : nsname_(nsname) {}
unsigned int count() const { return (1); }
- const RRType& get_type() const { return (RRType::NS); }
- static const RRType& get_type_static() { return (RRType::NS); }
- std::string to_text() const;
- void from_wire(Buffer& b, NameDecompressor& c);
- void to_wire(Buffer& b, NameCompressor& c) const;
- const std::string get_nsname() const { return (nsname_.to_text(false)); }
+ const RRType& getType() const { return (RRType::NS); }
+ static const RRType& getTypeStatic() { return (RRType::NS); }
+ std::string toText() const;
+ void fromWire(Buffer& b, NameDecompressor& c);
+ void toWire(Buffer& b, NameCompressor& c) const;
+ const std::string getNsname() const { return (nsname_.toText(false)); }
bool operator==(const NS &other) const
{ return (nsname_ == other.nsname_); }
virtual bool operator!=(const NS &other) const { return !(*this == other); }
@@ -164,11 +164,11 @@
// constructor from a textual IPv4 address
explicit A(const std::string& addrstr);
unsigned int count() const { return (1); }
- const RRType& get_type() const { return (RRType::A); }
- static const RRType& get_type_static() { return (RRType::A); }
- std::string to_text() const;
- void from_wire(Buffer& b, NameDecompressor& c);
- void to_wire(Buffer& b, NameCompressor& c) const;
+ const RRType& getType() const { return (RRType::A); }
+ static const RRType& getTypeStatic() { return (RRType::A); }
+ std::string toText() const;
+ void fromWire(Buffer& b, NameDecompressor& c);
+ void toWire(Buffer& b, NameCompressor& c) const;
const struct in_addr& getAddress() const { return (addr_); }
bool operator==(const A &other) const
{ return (addr_.s_addr == other.addr_.s_addr); }
@@ -186,11 +186,11 @@
// constructor from a textual IPv6 address
explicit AAAA(const std::string& addrstr);
unsigned int count() const { return (1); }
- std::string to_text() const;
- const RRType& get_type() const { return (RRType::AAAA); }
- static const RRType& get_type_static() { return (RRType::AAAA); }
- void from_wire(Buffer& b, NameDecompressor& c);
- void to_wire(Buffer& b, NameCompressor& c) const;
+ std::string toText() const;
+ const RRType& getType() const { return (RRType::AAAA); }
+ static const RRType& getTypeStatic() { return (RRType::AAAA); }
+ void fromWire(Buffer& b, NameDecompressor& c);
+ void toWire(Buffer& b, NameCompressor& c) const;
const struct in6_addr& getAddress() const { return (addr_); }
bool operator==(const AAAA &other) const
{ return (IN6_ARE_ADDR_EQUAL(&addr_, &other.addr_)); }
@@ -229,16 +229,16 @@
class AbstractRRset {
public:
virtual ~AbstractRRset() {}
- virtual std::string to_text() const = 0;
- virtual int to_wire(Buffer& buffer, NameCompressor& compressor,
+ virtual std::string toText() const = 0;
+ virtual int toWire(Buffer& buffer, NameCompressor& compressor,
section_t section) = 0;
- virtual void add_rdata(Rdata::RDATAPTR rdata) = 0;
- virtual unsigned int count_rdata() const = 0;
- virtual const Name& get_name() const = 0;
- virtual const RRClass& get_class() const = 0;
- virtual const RRType& get_type() const = 0;
- virtual const TTL& get_ttl() const = 0;
- virtual void set_ttl(const TTL& ttl) = 0;
+ virtual void addRdata(Rdata::RDATAPTR rdata) = 0;
+ virtual unsigned int countRdata() const = 0;
+ virtual const Name& getName() const = 0;
+ virtual const RRClass& getClass() const = 0;
+ virtual const RRType& getType() const = 0;
+ virtual const TTL& getTtl() const = 0;
+ virtual void setTtl(const TTL& ttl) = 0;
};
class RRset : public AbstractRRset {
@@ -247,20 +247,20 @@
explicit RRset(const Name &name, const RRClass &rrclass,
const RRType &rrtype, const TTL &ttl) :
name_(name), rrclass_(rrclass), rrtype_(rrtype), ttl_(ttl) {}
- unsigned int count_rdata() const { return (rdatalist_.size()); }
- void add_rdata(Rdata::RDATAPTR rdata);
- void remove_rdata(const Rdata::Rdata& rdata);
- std::string to_text() const;
- int to_wire(Buffer& buffer, NameCompressor& compressor, section_t section);
- const Name& get_name() const { return (name_); }
- const RRClass& get_class() const { return (rrclass_); }
- const RRType& get_type() const { return (rrtype_); }
- const TTL& get_ttl() const { return (ttl_); }
+ unsigned int countRdata() const { return (rdatalist_.size()); }
+ void addRdata(Rdata::RDATAPTR rdata);
+ void removeRdata(const Rdata::Rdata& rdata);
+ std::string toText() const;
+ int toWire(Buffer& buffer, NameCompressor& compressor, section_t section);
+ const Name& getName() const { return (name_); }
+ const RRClass& getClass() const { return (rrclass_); }
+ const RRType& getType() const { return (rrtype_); }
+ const TTL& getTtl() const { return (ttl_); }
// once constructed, only TTL and rdatalist can be modified.
- void set_ttl(const TTL& ttl) { ttl_ = ttl; }
- const std::vector<Rdata::RDATAPTR>& get_rdatalist() const
+ void setTtl(const TTL& ttl) { ttl_ = ttl; }
+ const std::vector<Rdata::RDATAPTR>& getRdatalist() const
{ return (rdatalist_); }
- template <typename T> void get_rdatalist(std::vector<T>&) const;
+ template <typename T> void getRdatalist(std::vector<T>&) const;
private:
Name name_;
RRClass rrclass_;
@@ -279,15 +279,15 @@
explicit Question(const Name& name, const RRClass& rrclass,
const RRType& rrtype) :
name_(name), rrclass_(rrclass), rrtype_(rrtype), ttl_(0) {}
- std::string to_text() const;
- int to_wire(Buffer& buffer, NameCompressor& compressor, section_t section);
- unsigned int count_rdata() const { return (0); }
- const Name& get_name() const { return (name_); }
- const RRClass& get_class() const { return (rrclass_); }
- const RRType& get_type() const { return (rrtype_); }
- const TTL& get_ttl() const { return (ttl_); } // XXX
- void set_ttl(const TTL& ttl) {} // XXX
- void add_rdata(Rdata::RDATAPTR rdata) {} // XXX
+ std::string toText() const;
+ int toWire(Buffer& buffer, NameCompressor& compressor, section_t section);
+ unsigned int countRdata() const { return (0); }
+ const Name& getName() const { return (name_); }
+ const RRClass& getClass() const { return (rrclass_); }
+ const RRType& getType() const { return (rrtype_); }
+ const TTL& getTtl() const { return (ttl_); } // XXX
+ void setTtl(const TTL& ttl) {} // XXX
+ void addRdata(Rdata::RDATAPTR rdata) {} // XXX
private:
Name name_;
RRClass rrclass_;
@@ -298,12 +298,12 @@
// TBD: this interface should be revisited.
template <typename T>
void
-RRset::get_rdatalist(std::vector<T>& v) const
+RRset::getRdatalist(std::vector<T>& v) const
{
std::vector<Rdata::RDATAPTR>::const_iterator it;
for (it = rdatalist_.begin(); it != rdatalist_.end(); ++it) {
const T& concreteRdata = static_cast<const T&>(**it); // XXX
- if (T::get_type_static() != (**it).get_type()) {
+ if (T::getTypeStatic() != (**it).getType()) {
throw DNSRRtypeMismatch();
}
v.push_back(concreteRdata);
@@ -322,14 +322,14 @@
explicit RR(const Name& name, const RRClass& rrclass,
const RRType& rrtype, const TTL& ttl,
const Rdata::Rdata& rdata);
- std::string to_text() const { return (rrset_.to_text()); }
- const Name& get_name() const { return (rrset_.get_name()); }
- const RRClass& get_class() const { return (rrset_.get_class()); }
- const RRType& get_type() const { return (rrset_.get_type()); }
- const TTL& get_ttl() const { return (rrset_.get_ttl()); }
- const Rdata::RDATAPTR get_rdata() const
- { return (*rrset_.get_rdatalist().begin()); }
- void set_ttl(const TTL& ttl) { rrset_.set_ttl(ttl); }
+ std::string toText() const { return (rrset_.toText()); }
+ const Name& getName() const { return (rrset_.getName()); }
+ const RRClass& getClass() const { return (rrset_.getClass()); }
+ const RRType& getType() const { return (rrset_.getType()); }
+ const TTL& getTtl() const { return (rrset_.getTtl()); }
+ const Rdata::RDATAPTR getRdata() const
+ { return (*rrset_.getRdatalist().begin()); }
+ void setTtl(const TTL& ttl) { rrset_.setTtl(ttl); }
private:
// An RR is (could be) actually implemented as an RRset containing at most
// one RR.
Modified: branches/f2f200910/src/lib/dns/rrset_unittest.cc
==============================================================================
--- branches/f2f200910/src/lib/dns/rrset_unittest.cc (original)
+++ branches/f2f200910/src/lib/dns/rrset_unittest.cc Wed Oct 28 22:56:10 2009
@@ -41,10 +41,10 @@
RRClass rrclass_ch;
};
-TEST_F(RRClassTest, from_to_text)
-{
- EXPECT_EQ("IN", rrclass_in.to_text());
- EXPECT_EQ("CH", rrclass_ch.to_text());
+TEST_F(RRClassTest, fromToText)
+{
+ EXPECT_EQ("IN", rrclass_in.toText());
+ EXPECT_EQ("CH", rrclass_ch.toText());
}
// The fixture for testing class RRType.
@@ -57,11 +57,11 @@
RRType rrtype_ns;
};
-TEST_F(RRTypeTest, from_to_text)
-{
- EXPECT_EQ("A", rrtype_a.to_text());
- EXPECT_EQ("AAAA", rrtype_aaaa.to_text());
- EXPECT_EQ("NS", rrtype_ns.to_text());
+TEST_F(RRTypeTest, fromToText)
+{
+ EXPECT_EQ("A", rrtype_a.toText());
+ EXPECT_EQ("AAAA", rrtype_aaaa.toText());
+ EXPECT_EQ("NS", rrtype_ns.toText());
}
// The fixture for testing class TTL.
@@ -72,16 +72,16 @@
TTL ttl0;
};
-TEST_F(TTLTest, to_text)
-{
- EXPECT_EQ("3600", ttl3600.to_text());
- EXPECT_EQ("0", ttl0.to_text());
-}
-
-TEST_F(TTLTest, get_value)
-{
- EXPECT_EQ(3600, ttl3600.get_value());
- EXPECT_EQ(0, ttl0.get_value());
+TEST_F(TTLTest, toText)
+{
+ EXPECT_EQ("3600", ttl3600.toText());
+ EXPECT_EQ("0", ttl0.toText());
+}
+
+TEST_F(TTLTest, getValue)
+{
+ EXPECT_EQ(3600, ttl3600.getValue());
+ EXPECT_EQ(0, ttl0.getValue());
}
// The fixture for testing class IN/A Rdata
@@ -91,9 +91,9 @@
A rdata;
};
-TEST_F(Rdata_IN_A_Test, from_to_text)
-{
- EXPECT_EQ("192.0.2.1", rdata.to_text());
+TEST_F(Rdata_IN_A_Test, fromToText)
+{
+ EXPECT_EQ("192.0.2.1", rdata.toText());
EXPECT_THROW(A("2001:db8::1234"), isc::ISCInvalidAddressString);
}
@@ -104,9 +104,9 @@
AAAA rdata;
};
-TEST_F(Rdata_IN_AAAA_Test, from_to_text)
-{
- EXPECT_EQ("2001:db8::abcd", rdata.to_text());
+TEST_F(Rdata_IN_AAAA_Test, fromToText)
+{
+ EXPECT_EQ("2001:db8::abcd", rdata.toText());
EXPECT_THROW(AAAA("192.0.2.255"), isc::ISCInvalidAddressString);
}
@@ -117,9 +117,9 @@
NS rdata;
};
-TEST_F(Rdata_Generic_NS_Test, from_to_text)
-{
- EXPECT_EQ("ns.example.com.", rdata.to_text());
+TEST_F(Rdata_Generic_NS_Test, fromToText)
+{
+ EXPECT_EQ("ns.example.com.", rdata.toText());
}
// The fixture for testing class RRset
@@ -129,28 +129,28 @@
rrset_a(Name("www.example.com"), RRClass::IN, RRType::A, TTL(3600)),
rrset_aaaa(Name("ns.example.net"), RRClass::IN, RRType::AAAA, TTL(60))
{
- rrset_a.add_rdata(RDATAPTR(new A("192.0.2.1")));
- rrset_a.add_rdata(RDATAPTR(new A("192.0.2.255")));
- rrset_aaaa.add_rdata(RDATAPTR(new AAAA("2001:db8::1234")));
+ rrset_a.addRdata(RDATAPTR(new A("192.0.2.1")));
+ rrset_a.addRdata(RDATAPTR(new A("192.0.2.255")));
+ rrset_aaaa.addRdata(RDATAPTR(new AAAA("2001:db8::1234")));
}
RRset rrset_a;
RRset rrset_aaaa;
};
-TEST_F(RRsetTest, to_text)
+TEST_F(RRsetTest, toText)
{
EXPECT_EQ("www.example.com. 3600 IN A 192.0.2.1\n"
"www.example.com. 3600 IN A 192.0.2.255",
- rrset_a.to_text());
+ rrset_a.toText());
EXPECT_EQ("ns.example.net. 60 IN AAAA 2001:db8::1234",
- rrset_aaaa.to_text());
+ rrset_aaaa.toText());
}
TEST_F(RRsetTest, count_rdata)
{
- EXPECT_EQ(2, rrset_a.count_rdata());
- EXPECT_EQ(1, rrset_aaaa.count_rdata());
+ EXPECT_EQ(2, rrset_a.countRdata());
+ EXPECT_EQ(1, rrset_aaaa.countRdata());
}
// The fixture for testing class Question
@@ -163,16 +163,16 @@
Question question_aaaa;
};
-TEST_F(QuestionTest, to_text)
-{
- EXPECT_EQ("www.example.com. IN A", question_a.to_text());
- EXPECT_EQ("ns.example.net. IN AAAA", question_aaaa.to_text());
+TEST_F(QuestionTest, toText)
+{
+ EXPECT_EQ("www.example.com. IN A", question_a.toText());
+ EXPECT_EQ("ns.example.net. IN AAAA", question_aaaa.toText());
}
TEST_F(QuestionTest, count_rdata)
{
- EXPECT_EQ(0, question_a.count_rdata());
- EXPECT_EQ(0, question_aaaa.count_rdata());
+ EXPECT_EQ(0, question_a.countRdata());
+ EXPECT_EQ(0, question_aaaa.countRdata());
}
// The fixture for testing class RR
@@ -191,10 +191,10 @@
RR rr_ns;
};
-TEST_F(RRTest, to_text)
-{
- EXPECT_EQ("www.example.com. 3600 IN A 192.0.2.1", rr_a.to_text());
- EXPECT_EQ("ns.example.net. 60 IN AAAA 2001:db8::1234", rr_aaaa.to_text());
- EXPECT_EQ("example.net. 1800 IN NS ns.example.net.", rr_ns.to_text());
-}
-}
+TEST_F(RRTest, toText)
+{
+ EXPECT_EQ("www.example.com. 3600 IN A 192.0.2.1", rr_a.toText());
+ EXPECT_EQ("ns.example.net. 60 IN AAAA 2001:db8::1234", rr_aaaa.toText());
+ EXPECT_EQ("example.net. 1800 IN NS ns.example.net.", rr_ns.toText());
+}
+}
More information about the bind10-changes
mailing list