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