mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-30 21:45:37 +00:00
[2976] Trivial: folded long lines.
This commit is contained in:
@@ -179,7 +179,8 @@ D2UpdateMessage::ddnsToDnsSection(const UpdateMsgSection section) {
|
||||
default:
|
||||
;
|
||||
}
|
||||
isc_throw(dns::InvalidMessageSection, "unknown message section " << section);
|
||||
isc_throw(dns::InvalidMessageSection,
|
||||
"unknown message section " << section);
|
||||
}
|
||||
|
||||
void
|
||||
@@ -190,22 +191,25 @@ D2UpdateMessage::validate() const {
|
||||
// stop further processing, because it is likely that the message was
|
||||
// directed to someone else.
|
||||
if (message_.getOpcode() != Opcode::UPDATE()) {
|
||||
isc_throw(NotUpdateMessage, "received message is not a DDNS update, received"
|
||||
" message code is " << message_.getOpcode().getCode());
|
||||
isc_throw(NotUpdateMessage, "received message is not a DDNS update,"
|
||||
<< " received message code is "
|
||||
<< message_.getOpcode().getCode());
|
||||
}
|
||||
// Received message should have QR flag set, which indicates that it is
|
||||
// a RESPONSE.
|
||||
if (getQRFlag() == REQUEST) {
|
||||
isc_throw(InvalidQRFlag, "received message should should have QR flag set,"
|
||||
" to indicate that it is a RESPONSE message, the QR flag is unset");
|
||||
isc_throw(InvalidQRFlag, "received message should should have QR flag"
|
||||
<< " set, to indicate that it is a RESPONSE message, the QR"
|
||||
<< " flag is unset");
|
||||
}
|
||||
// DNS server may copy a Zone record from the query message. Since query must
|
||||
// comprise exactly one Zone record (RFC 2136, section 2.3), the response message
|
||||
// may contain 1 record at most. It may also contain no records if a server
|
||||
// chooses not to copy Zone section.
|
||||
// DNS server may copy a Zone record from the query message. Since query
|
||||
// must comprise exactly one Zone record (RFC 2136, section 2.3), the
|
||||
// response message may contain 1 record at most. It may also contain no
|
||||
// records if a server chooses not to copy Zone section.
|
||||
if (getRRCount(SECTION_ZONE) > 1) {
|
||||
isc_throw(InvalidZoneSection, "received message contains " << getRRCount(SECTION_ZONE)
|
||||
<< " Zone records, it should contain at most 1 record");
|
||||
isc_throw(InvalidZoneSection, "received message contains "
|
||||
<< getRRCount(SECTION_ZONE) << " Zone records,"
|
||||
<< " it should contain at most 1 record");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -1,4 +1,4 @@
|
||||
// Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
|
||||
// Copyright (C) 2013 Internet Systems Consortium, Inc. ("ISC")
|
||||
//
|
||||
// Permission to use, copy, modify, and/or distribute this software for any
|
||||
// purpose with or without fee is hereby granted, provided that the above
|
||||
@@ -73,11 +73,11 @@ public:
|
||||
///
|
||||
/// <b>Design choice:</b> A dedicated class has been created to encapsulate
|
||||
/// DNS Update message because existing @c isc::dns::Message is designed to
|
||||
/// support regular DNS messages (described in RFC 1035) only. Although DNS Update
|
||||
/// has the same format, particular sections serve different purposes. In order
|
||||
/// to avoid rewrite of significant portions of @c isc::dns::Message class, this
|
||||
/// class is implemented in-terms-of @c isc::dns::Message class to reuse its
|
||||
/// functionality where possible.
|
||||
/// support regular DNS messages (described in RFC 1035) only. Although DNS
|
||||
/// Update has the same format, particular sections serve different purposes.
|
||||
/// In order to avoid rewrite of significant portions of @c isc::dns::Message
|
||||
/// class, this class is implemented in-terms-of @c isc::dns::Message class
|
||||
/// to reuse its functionality where possible.
|
||||
class D2UpdateMessage {
|
||||
public:
|
||||
|
||||
@@ -112,8 +112,9 @@ public:
|
||||
/// outgoing DNS Update message. The boolean argument indicates wheteher it
|
||||
/// is incoming (true) or outgoing (false) message. For incoming messages
|
||||
/// the @c D2UpdateMessage::fromWire function is used to parse on-wire data.
|
||||
/// For outgoing messages, modifier functions should be used to set the message
|
||||
/// contents and @c D2UpdateMessage::toWire function to create on-wire data.
|
||||
/// For outgoing messages, modifier functions should be used to set the
|
||||
/// message contents and @c D2UpdateMessage::toWire function to create
|
||||
/// on-wire data.
|
||||
///
|
||||
/// @param parse indicates if this is an incoming message (true) or outgoing
|
||||
/// message (false).
|
||||
@@ -229,41 +230,44 @@ public:
|
||||
/// @brief Encode outgoing message into wire format.
|
||||
///
|
||||
/// This function encodes the DNS Update into the wire format. The format of
|
||||
/// such a message is described in the RFC2136, section 2. Some of the sections
|
||||
/// which belong to encoded message may be empty. If a particular message section
|
||||
/// is empty (does not comprise any RRs), the corresponding counter in the
|
||||
/// message header is set to 0. These counters are: PRCOUNT, UPCOUNT,
|
||||
/// ADCOUNT for the Prerequisites, Update RRs and Additional Data RRs respectively.
|
||||
/// The ZOCOUNT must be equal to 1 because RFC2136 requires that the message
|
||||
/// comprises exactly one Zone record.
|
||||
/// such a message is described in the RFC2136, section 2. Some of the
|
||||
/// sections which belong to encoded message may be empty. If a particular
|
||||
/// message section is empty (does not comprise any RRs), the corresponding
|
||||
/// counter in the message header is set to 0. These counters are: PRCOUNT,
|
||||
/// UPCOUNT, ADCOUNT for the Prerequisites, Update RRs and Additional Data
|
||||
/// RRs respectively. The ZOCOUNT must be equal to 1 because RFC2136
|
||||
/// requires that the message comprises exactly one Zone record.
|
||||
///
|
||||
/// This function does not guarantee exception safety. However, exceptions
|
||||
/// should be rare because @c D2UpdateMessage class API prevents invalid
|
||||
/// use of the class. The typical case, when this function may throw an
|
||||
/// exception is when this it is called on the object representing
|
||||
/// incoming (instead of outgoing) message. In such case, the QR field
|
||||
/// will be set to RESPONSE, which is invalid setting when calling this function.
|
||||
/// will be set to RESPONSE, which is invalid setting when calling this
|
||||
/// function.
|
||||
///
|
||||
/// @param renderer A renderer object used to generate the message wire format.
|
||||
/// @param renderer A renderer object used to generate the message wire
|
||||
/// format.
|
||||
void toWire(dns::AbstractMessageRenderer& renderer);
|
||||
|
||||
/// @brief Decode incoming message from the wire format.
|
||||
///
|
||||
/// This function decodes the DNS Update message stored in the buffer specified
|
||||
/// by the function argument. In the first turn, this function parses message
|
||||
/// header and extracts the section counters: ZOCOUNT, PRCOUNT, UPCOUNT and
|
||||
/// ADCOUNT. Using these counters, function identifies message sections, which
|
||||
/// follow message header. These sections can be later accessed using:
|
||||
/// @c D2UpdateMessage::getZone, @c D2UpdateMessage::beginSection and
|
||||
/// @c D2UpdateMessage::endSection functions.
|
||||
/// This function decodes the DNS Update message stored in the buffer
|
||||
/// specified by the function argument. In the first turn, this function
|
||||
/// parses message header and extracts the section counters: ZOCOUNT,
|
||||
/// PRCOUNT, UPCOUNT and ADCOUNT. Using these counters, function identifies
|
||||
/// message sections, which follow message header. These sections can be
|
||||
/// later accessed using: @c D2UpdateMessage::getZone,
|
||||
/// @c D2UpdateMessage::beginSection and @c D2UpdateMessage::endSection
|
||||
/// functions.
|
||||
///
|
||||
/// This function is NOT exception safe. It signals message decoding errors
|
||||
/// through exceptions. Message decoding error may occur if the received
|
||||
/// message does not conform to the general DNS Message format, specified in
|
||||
/// RFC 1035. Errors which are specific to DNS Update messages include:
|
||||
/// - Invalid Opcode - not an UPDATE.
|
||||
/// - Invalid QR flag - the QR bit should be set to indicate that the message
|
||||
/// is the server response.
|
||||
/// - Invalid QR flag - the QR bit should be set to indicate that the
|
||||
/// message is the server response.
|
||||
/// - The number of records in the Zone section is greater than 1.
|
||||
///
|
||||
/// @param buffer input buffer, holding DNS Update message to be parsed.
|
||||
@@ -276,12 +280,13 @@ private:
|
||||
/// mapping is required here because this class uses @c isc::dns::Message
|
||||
/// class to do the actual processing of the DNS Update message.
|
||||
///
|
||||
/// @param section An enum indicating the section for which the corresponding
|
||||
/// enum value from @c isc::dns::Message will be returned.
|
||||
/// @param section An enum indicating the section for which the
|
||||
/// corresponding enum value from @c isc::dns::Message will be returned.
|
||||
///
|
||||
/// @return The enum value indicating the section in the DNS message
|
||||
/// represented by the @c isc::dns::Message class.
|
||||
static dns::Message::Section ddnsToDnsSection(const UpdateMsgSection section);
|
||||
static
|
||||
dns::Message::Section ddnsToDnsSection(const UpdateMsgSection section);
|
||||
|
||||
/// @brief Checks received response message for correctness.
|
||||
///
|
||||
|
@@ -27,16 +27,16 @@ namespace d2 {
|
||||
///
|
||||
/// This class is used by the @c D2UpdateMessage to encapsulate the Zone section
|
||||
/// of the DNS Update message. Class members hold corresponding values of
|
||||
/// section's fields: NAME, CLASS. This class does not hold the RTYPE field value
|
||||
/// because RTYPE is always equal to SOA for DNS Update message (see RFC 2136,
|
||||
/// section 2.3).
|
||||
/// section's fields: NAME, CLASS. This class does not hold the RTYPE field
|
||||
/// value because RTYPE is always equal to SOA for DNS Update message (see
|
||||
/// RFC 2136, section 2.3).
|
||||
///
|
||||
/// Note, that this @c D2Zone class neither exposes functions to decode messages
|
||||
/// from wire format nor to encode to wire format. This is not needed, because
|
||||
/// @c isc::d2::D2UpdateMessage class uses @c D2Zone only to return the parsed Zone
|
||||
/// information to the caller. Internally, D2UpdateMessage parses and stores Zone
|
||||
/// section using @c isc::dns::Question class, and the @c toWire and @c fromWire
|
||||
/// functions of the @c isc::dns::Question class are used.
|
||||
/// @c isc::d2::D2UpdateMessage class uses @c D2Zone only to return the parsed
|
||||
/// Zone information to the caller. Internally, D2UpdateMessage parses and
|
||||
/// stores Zone section using @c isc::dns::Question class, and the @c toWire
|
||||
/// and @c fromWire functions of the @c isc::dns::Question class are used.
|
||||
class D2Zone {
|
||||
public:
|
||||
/// @brief Constructor from Name and RRClass.
|
||||
@@ -72,8 +72,8 @@ public:
|
||||
/// @name Comparison Operators
|
||||
///
|
||||
//@{
|
||||
/// @brief Equality operator to compare @c D2Zone objects in query and response
|
||||
/// messages.
|
||||
/// @brief Equality operator to compare @c D2Zone objects in query and
|
||||
/// response messages.
|
||||
///
|
||||
/// @param rhs Zone to compare against.
|
||||
///
|
||||
|
@@ -148,7 +148,7 @@ TEST_F(D2UpdateMessageTest, fromWire) {
|
||||
// by a length of the following label. The whole Zone name is
|
||||
// terminated with a NULL char.
|
||||
// For Zone section format see (RFC 2136, section 2.3).
|
||||
0x7, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, // example (0x7 is a length)
|
||||
0x7, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, // example (7 is length)
|
||||
0x3, 0x63, 0x6F, 0x6D, //.com. (0x3 is a length)
|
||||
0x0, // NULL character terminates the Zone name.
|
||||
0x0, 0x6, // ZTYPE='SOA'
|
||||
@@ -222,13 +222,15 @@ TEST_F(D2UpdateMessageTest, fromWire) {
|
||||
ASSERT_EQ(2, msg.getRRCount(D2UpdateMessage::SECTION_PREREQUISITE));
|
||||
|
||||
// Proceed to the first prerequisite.
|
||||
RRsetIterator rrset_it = msg.beginSection(D2UpdateMessage::SECTION_PREREQUISITE);
|
||||
RRsetIterator rrset_it =
|
||||
msg.beginSection(D2UpdateMessage::SECTION_PREREQUISITE);
|
||||
RRsetPtr prereq1 = *rrset_it;
|
||||
ASSERT_TRUE(prereq1);
|
||||
// Check record fields.
|
||||
EXPECT_EQ("foo.example.com.", prereq1->getName().toText()); // NAME
|
||||
EXPECT_EQ(RRType::AAAA().getCode(), prereq1->getType().getCode()); // TYPE
|
||||
EXPECT_EQ(RRClass::NONE().getCode(), prereq1->getClass().getCode()); // CLASS
|
||||
EXPECT_EQ(RRClass::NONE().getCode(),
|
||||
prereq1->getClass().getCode()); // CLASS
|
||||
EXPECT_EQ(0, prereq1->getTTL().getValue()); // TTL
|
||||
EXPECT_EQ(0, prereq1->getRdataCount()); // RDLENGTH
|
||||
|
||||
@@ -331,7 +333,7 @@ TEST_F(D2UpdateMessageTest, fromWireTooManyZones) {
|
||||
0x0, 0x0, // ADCOUNT=0
|
||||
|
||||
// Start first Zone record.
|
||||
0x7, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, // example (0x7 is a length)
|
||||
0x7, 0x65, 0x78, 0x61, 0x6D, 0x70, 0x6C, 0x65, // example (7 is length)
|
||||
0x3, 0x63, 0x6F, 0x6D, //.com. (0x3 is a length)
|
||||
0x0, // NULL character terminates the Zone name.
|
||||
0x0, 0x6, // ZTYPE='SOA'
|
||||
|
Reference in New Issue
Block a user