From: Tomek Mrugalski Date: Thu, 5 Mar 2015 10:02:18 +0000 (+0100) Subject: [3705] Dhcp6Client improvements: X-Git-Tag: kea-0.9.1~19^2~8 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=33f7238e0ccff38cafa184048ca820c0b01adead;p=thirdparty%2Fkea.git [3705] Dhcp6Client improvements: - is now able to use specified relay information - stores received options --- diff --git a/src/bin/dhcp6/tests/dhcp6_client.cc b/src/bin/dhcp6/tests/dhcp6_client.cc index 73720695a9..40988f6835 100644 --- a/src/bin/dhcp6/tests/dhcp6_client.cc +++ b/src/bin/dhcp6/tests/dhcp6_client.cc @@ -76,6 +76,8 @@ Dhcp6Client::applyRcvdConfiguration(const Pkt6Ptr& reply) { for (Opts::const_iterator opt = opts.begin(); opt != opts.end(); ++opt) { Option6IAPtr ia = boost::dynamic_pointer_cast(opt->second); if (!ia) { + // This is not IA, so let's just store it. + config_.options_.insert(*opt); continue; } @@ -453,13 +455,19 @@ Dhcp6Client::sendMsg(const Pkt6Ptr& msg) { srv_->shutdown_ = false; // The client is configured to send through the relay. We achieve that // adding the relay structure. - if (use_relay_) { - Pkt6::RelayInfo relay; - relay.linkaddr_ = relay_link_addr_; - relay.peeraddr_ = asiolink::IOAddress("fe80::1"); - relay.msg_type_ = DHCPV6_RELAY_FORW; - relay.hop_count_ = 1; - msg->relay_info_.push_back(relay); + if (use_relay_ || !relay_info_.empty()) { + if (relay_info_.empty()) { + // Let's craft the relay info by hand + Pkt6::RelayInfo relay; + relay.linkaddr_ = relay_link_addr_; + relay.peeraddr_ = asiolink::IOAddress("fe80::1"); + relay.msg_type_ = DHCPV6_RELAY_FORW; + relay.hop_count_ = 1; + msg->relay_info_.push_back(relay); + } else { + // The test provided relay_info_, let's use that. + msg->relay_info_ = relay_info_; + } } // Repack the message to simulate wire-data parsing. msg->pack(); diff --git a/src/bin/dhcp6/tests/dhcp6_client.h b/src/bin/dhcp6/tests/dhcp6_client.h index bb63220647..8b04890a7a 100644 --- a/src/bin/dhcp6/tests/dhcp6_client.h +++ b/src/bin/dhcp6/tests/dhcp6_client.h @@ -74,10 +74,17 @@ public: /// @brief Holds the current client configuration obtained from the /// server over DHCP. /// - /// Currently it simply contains the collection of leases acquired. + /// Currently it simply contains the collection of leases acquired + /// and a list of options. Note: this is a simple copy of all + /// non-IA options and often includes "protocol" options, like + /// server-id and client-id. struct Configuration { + /// @brief List of received leases std::vector leases_; + /// @brief List of received options + OptionCollection options_; + /// @brief Status code received in the global option scope. uint16_t status_code_; @@ -388,6 +395,12 @@ public: /// @brief Link address of the relay to be used for relayed messages. asiolink::IOAddress relay_link_addr_; + /// @brief RelayInfo (information about relays) + /// + /// Dhcp6Client will typically contruct this info itself, but if + /// it is provided here by the test, this data will be used as is. + std::vector relay_info_; + /// @brief Controls whether the client will send ORO /// /// The actual content of the ORO is specified in oro_.