Browse Source

[2949] Changes after review

Tomek Mrugalski 10 years ago
parent
commit
085d17aede

+ 2 - 2
doc/examples/kea6/stateless.json

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

+ 8 - 2
src/bin/dhcp6/dhcp6_srv.cc

@@ -2459,20 +2459,26 @@ Pkt6Ptr
 Dhcpv6Srv::processDecline(const Pkt6Ptr& decline) {
     /// @todo: Implement this
     Pkt6Ptr reply(new Pkt6(DHCPV6_REPLY, decline->getTransid()));
-    return reply;
+    return (reply);
 }
 
 Pkt6Ptr
 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()));
 
+    // Copy default options (client-id, also relay information if present)
     copyDefaultOptions(infRequest, reply);
 
+    // Append default options (server-id for now, but possibly other options
+    // once we start supporting authentication)
     appendDefaultOptions(infRequest, reply);
 
+    // Try to assign options that were requested by the client.
     appendRequestedOptions(infRequest, reply);
 
-    return reply;
+    return (reply);
 }
 
 size_t

+ 10 - 7
src/bin/dhcp6/tests/dhcp6_client.cc

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

+ 15 - 11
src/bin/dhcp6/tests/dhcp6_client.h

@@ -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
 // purpose with or without fee is hereby granted, provided that the above
@@ -221,7 +221,11 @@ public:
 
     /// @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();
 
     /// @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
     /// @param send should the client-id be sent?
-    void sendClientId(bool send) {
-        send_client_id_ = send;
+    void useClientId(bool send) {
+        use_client_id_ = send;
     }
 
     /// @brief Lease configuration obtained by the client.
@@ -384,26 +388,26 @@ public:
     /// @brief Link address of the relay to be used for relayed messages.
     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_.
     /// It is useful to split the actual content and the ORO sending
     /// decision, so we could test cases of sending empty ORO.
-    void sendORO(bool send) {
-        send_oro_ = send;
+    void useORO(bool send) {
+        use_oro_ = send;
     }
 
     /// @brief Instructs client to request specified option in ORO
     ///
     /// @param option_code client will request this option code
     void requestOption(uint16_t option_code) {
-        send_oro_ = true;
+        use_oro_ = true;
         oro_.push_back(option_code);
     }
 
     /// @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.
     std::vector<uint16_t> oro_;
 private:
@@ -505,8 +509,8 @@ private:
     bool use_pd_;    ///< Enable prefix delegation.
     bool use_relay_; ///< Enable relaying messages to the server.
 
-    bool send_oro_;
-    bool send_client_id_;
+    bool use_oro_;  ///< Conth
+    bool use_client_id_;
 
     /// @brief Pointer to the option holding a prefix hint.
     Option6IAPrefixPtr prefix_hint_;

+ 1 - 0
src/bin/dhcp6/tests/dhcp6_test_utils.cc

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

+ 1 - 1
src/bin/dhcp6/tests/infrequest_unittest.cc

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