2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-09-01 22:45:18 +00:00

[2949] Changes after review

This commit is contained in:
Tomek Mrugalski
2015-02-03 18:54:02 +01:00
parent e8deacea8b
commit 085d17aede
6 changed files with 37 additions and 23 deletions

View File

@@ -1,5 +1,5 @@
# A very simply stateless configuration that provides DNS servers information # A very simply stateless configuration that provides information about DNS
# to all clients, regardless of their point of attachment. # servers to all clients, regardless of their point of attachment.
# #
# It is also possible to specify options on a per subnet basis # It is also possible to specify options on a per subnet basis
# in the same way as in stateful mode. # in the same way as in stateful mode.

View File

@@ -2459,20 +2459,26 @@ Pkt6Ptr
Dhcpv6Srv::processDecline(const Pkt6Ptr& decline) { Dhcpv6Srv::processDecline(const Pkt6Ptr& decline) {
/// @todo: Implement this /// @todo: Implement this
Pkt6Ptr reply(new Pkt6(DHCPV6_REPLY, decline->getTransid())); Pkt6Ptr reply(new Pkt6(DHCPV6_REPLY, decline->getTransid()));
return reply; return (reply);
} }
Pkt6Ptr Pkt6Ptr
Dhcpv6Srv::processInfRequest(const Pkt6Ptr& infRequest) { Dhcpv6Srv::processInfRequest(const Pkt6Ptr& infRequest) {
// Create a Reply packet, with the same trans-id as the client's.
Pkt6Ptr reply(new Pkt6(DHCPV6_REPLY, infRequest->getTransid())); Pkt6Ptr reply(new Pkt6(DHCPV6_REPLY, infRequest->getTransid()));
// Copy default options (client-id, also relay information if present)
copyDefaultOptions(infRequest, reply); copyDefaultOptions(infRequest, reply);
// Append default options (server-id for now, but possibly other options
// once we start supporting authentication)
appendDefaultOptions(infRequest, reply); appendDefaultOptions(infRequest, reply);
// Try to assign options that were requested by the client.
appendRequestedOptions(infRequest, reply); appendRequestedOptions(infRequest, reply);
return reply; return (reply);
} }
size_t size_t

View File

@@ -41,8 +41,8 @@ Dhcp6Client::Dhcp6Client() :
use_na_(false), use_na_(false),
use_pd_(false), use_pd_(false),
use_relay_(false), use_relay_(false),
send_oro_(false), use_oro_(false),
send_client_id_(true), use_client_id_(true),
prefix_hint_() { prefix_hint_() {
} }
@@ -56,8 +56,8 @@ Dhcp6Client::Dhcp6Client(boost::shared_ptr<NakedDhcpv6Srv>& srv) :
use_na_(false), use_na_(false),
use_pd_(false), use_pd_(false),
use_relay_(false), use_relay_(false),
send_oro_(false), use_oro_(false),
send_client_id_(true), use_client_id_(true),
prefix_hint_() { prefix_hint_() {
} }
@@ -252,10 +252,10 @@ Pkt6Ptr
Dhcp6Client::createMsg(const uint8_t msg_type) { Dhcp6Client::createMsg(const uint8_t msg_type) {
Pkt6Ptr msg(new Pkt6(msg_type, curr_transid_++)); Pkt6Ptr msg(new Pkt6(msg_type, curr_transid_++));
if (send_client_id_) { if (use_client_id_) {
msg->addOption(getClientId()); msg->addOption(getClientId());
} }
if (send_oro_) { if (use_oro_) {
OptionUint16ArrayPtr oro(new OptionUint16Array(Option::V6, D6O_ORO)); OptionUint16ArrayPtr oro(new OptionUint16Array(Option::V6, D6O_ORO));
oro->setValues(oro_); oro->setValues(oro_);
@@ -315,14 +315,17 @@ void
Dhcp6Client::doInfRequest() { Dhcp6Client::doInfRequest() {
context_.query_ = createMsg(DHCPV6_INFORMATION_REQUEST); context_.query_ = createMsg(DHCPV6_INFORMATION_REQUEST);
// Not allowed in INF-REQUEST, but hey! Let's test it. // IA_NA, IA_TA and IA_PD options are not allowed in INF-REQUEST,
// but hey! Let's test it.
if (use_na_) { if (use_na_) {
// Insert IA_NA option with iaid=1234.
context_.query_->addOption(Option6IAPtr(new Option6IA(D6O_IA_NA, context_.query_->addOption(Option6IAPtr(new Option6IA(D6O_IA_NA,
1234))); 1234)));
} }
// IA-PD is also not allowed. So it may be useful in testing, too. // IA-PD is also not allowed. So it may be useful in testing, too.
if (use_pd_) { if (use_pd_) {
// Insert IA_PD option with iaid=5678
Option6IAPtr ia(new Option6IA(D6O_IA_PD, 5678)); Option6IAPtr ia(new Option6IA(D6O_IA_PD, 5678));
if (prefix_hint_) { if (prefix_hint_) {
ia->addOption(prefix_hint_); ia->addOption(prefix_hint_);

View File

@@ -1,4 +1,4 @@
// Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC") // Copyright (C) 2014-2015 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
@@ -221,7 +221,11 @@ public:
/// @brief Performs stateless (inf-request / reply) exchange. /// @brief Performs stateless (inf-request / reply) exchange.
/// ///
/// This function generates /// This function generates Information-request message, sends it
/// to the server and then receives the reply. Contents of the Inf-Request
/// are controlled by use_na_, use_pd_, use_client_id_ and use_oro_
/// fields. This method does not process the response in any specific
/// way, just stores it.
void doInfRequest(); void doInfRequest();
/// @brief Removes the stateful configuration obtained from the server. /// @brief Removes the stateful configuration obtained from the server.
@@ -374,8 +378,8 @@ public:
/// @brief Controls whether the client should send a client-id or not /// @brief Controls whether the client should send a client-id or not
/// @param send should the client-id be sent? /// @param send should the client-id be sent?
void sendClientId(bool send) { void useClientId(bool send) {
send_client_id_ = send; use_client_id_ = send;
} }
/// @brief Lease configuration obtained by the client. /// @brief Lease configuration obtained by the client.
@@ -384,26 +388,26 @@ public:
/// @brief Link address of the relay to be used for relayed messages. /// @brief Link address of the relay to be used for relayed messages.
asiolink::IOAddress relay_link_addr_; asiolink::IOAddress relay_link_addr_;
/// @brief Controls whether client will send ORO /// @brief Controls whether the client will send ORO
/// ///
/// The actual content of the ORO is specified in oro_. /// The actual content of the ORO is specified in oro_.
/// It is useful to split the actual content and the ORO sending /// It is useful to split the actual content and the ORO sending
/// decision, so we could test cases of sending empty ORO. /// decision, so we could test cases of sending empty ORO.
void sendORO(bool send) { void useORO(bool send) {
send_oro_ = send; use_oro_ = send;
} }
/// @brief Instructs client to request specified option in ORO /// @brief Instructs client to request specified option in ORO
/// ///
/// @param option_code client will request this option code /// @param option_code client will request this option code
void requestOption(uint16_t option_code) { void requestOption(uint16_t option_code) {
send_oro_ = true; use_oro_ = true;
oro_.push_back(option_code); oro_.push_back(option_code);
} }
/// @brief List of options to be requested /// @brief List of options to be requested
/// ///
/// Content of this vector will be sent as ORO if send_oro_ is set /// Content of this vector will be sent as ORO if use_oro_ is set
/// to true. See @ref sendORO for details. /// to true. See @ref sendORO for details.
std::vector<uint16_t> oro_; std::vector<uint16_t> oro_;
private: private:
@@ -505,8 +509,8 @@ private:
bool use_pd_; ///< Enable prefix delegation. bool use_pd_; ///< Enable prefix delegation.
bool use_relay_; ///< Enable relaying messages to the server. bool use_relay_; ///< Enable relaying messages to the server.
bool send_oro_; bool use_oro_; ///< Conth
bool send_client_id_; bool use_client_id_;
/// @brief Pointer to the option holding a prefix hint. /// @brief Pointer to the option holding a prefix hint.
Option6IAPrefixPtr prefix_hint_; Option6IAPrefixPtr prefix_hint_;

View File

@@ -16,6 +16,7 @@
#include <dhcp6/tests/dhcp6_test_utils.h> #include <dhcp6/tests/dhcp6_test_utils.h>
#include <dhcp6/json_config_parser.h> #include <dhcp6/json_config_parser.h>
#include <config/ccsession.h> #include <config/ccsession.h>
#include <string.h>
using namespace isc::data; using namespace isc::data;
using namespace isc::dhcp; using namespace isc::dhcp;

View File

@@ -179,7 +179,7 @@ TEST_F(InfRequestTest, infRequestAnonymous) {
// Perform 2-way exchange (Inf-request/reply) // Perform 2-way exchange (Inf-request/reply)
client.requestOption(D6O_NAME_SERVERS); client.requestOption(D6O_NAME_SERVERS);
client.sendClientId(false); client.useClientId(false);
ASSERT_NO_THROW(client.doInfRequest()); ASSERT_NO_THROW(client.doInfRequest());
// Confirm that there's a response // Confirm that there's a response