summaryrefslogtreecommitdiffstats
path: root/src/bin/dhcp4/tests/dhcp4_client.cc
diff options
context:
space:
mode:
authorMarcin Siodelski <marcin@isc.org>2015-03-20 09:14:36 +0100
committerMarcin Siodelski <marcin@isc.org>2015-03-20 09:14:36 +0100
commit38d6de2b6c7e09c04de09855d34dc77153a8bb86 (patch)
tree8a3762f0e53994bd45c8223f1dc4d520159175d8 /src/bin/dhcp4/tests/dhcp4_client.cc
parent[3678] Tidy up some typos (diff)
downloadkea-38d6de2b6c7e09c04de09855d34dc77153a8bb86.tar.xz
kea-38d6de2b6c7e09c04de09855d34dc77153a8bb86.zip
[3768] Address review comments.
Diffstat (limited to 'src/bin/dhcp4/tests/dhcp4_client.cc')
-rw-r--r--src/bin/dhcp4/tests/dhcp4_client.cc110
1 files changed, 55 insertions, 55 deletions
diff --git a/src/bin/dhcp4/tests/dhcp4_client.cc b/src/bin/dhcp4/tests/dhcp4_client.cc
index dc80fb718a..a3c3436d74 100644
--- a/src/bin/dhcp4/tests/dhcp4_client.cc
+++ b/src/bin/dhcp4/tests/dhcp4_client.cc
@@ -87,6 +87,54 @@ Dhcp4Client::addRequestedAddress(const asiolink::IOAddress& addr) {
}
void
+Dhcp4Client::appendClientId() {
+ if (!context_.query_) {
+ isc_throw(Dhcp4ClientError, "pointer to the query must not be NULL"
+ " when adding Client Identifier option");
+ }
+
+ if (clientid_) {
+ OptionPtr opt(new Option(Option::V4, DHO_DHCP_CLIENT_IDENTIFIER,
+ clientid_->getClientId()));
+ context_.query_->addOption(opt);
+ }
+}
+
+void
+Dhcp4Client::appendName() {
+ if (!context_.query_) {
+ isc_throw(Dhcp4ClientError, "pointer to the query must not be NULL"
+ " when adding FQDN or Hostname option");
+ }
+
+ if (fqdn_) {
+ context_.query_->addOption(fqdn_);
+
+ } else if (hostname_) {
+ context_.query_->addOption(hostname_);
+ }
+}
+
+void
+Dhcp4Client::appendPRL() {
+ if (!context_.query_) {
+ isc_throw(Dhcp4ClientError, "pointer to the query must not be NULL"
+ " when adding option codes to the PRL option");
+
+ } else if (!requested_options_.empty()) {
+ // Include Parameter Request List if at least one option code
+ // has been specified to be requested.
+ OptionUint8ArrayPtr prl(new OptionUint8Array(Option::V4,
+ DHO_DHCP_PARAMETER_REQUEST_LIST));
+ for (std::set<uint8_t>::const_iterator opt = requested_options_.begin();
+ opt != requested_options_.end(); ++opt) {
+ prl->addValue(*opt);
+ }
+ context_.query_->addOption(prl);
+ }
+}
+
+void
Dhcp4Client::applyConfiguration() {
Pkt4Ptr resp = context_.response_;
if (!resp) {
@@ -152,11 +200,11 @@ void
Dhcp4Client::doDiscover(const boost::shared_ptr<IOAddress>& requested_addr) {
context_.query_ = createMsg(DHCPDISCOVER);
// Request options if any.
- includePRL();
+ appendPRL();
// Include FQDN or Hostname.
- includeName();
+ appendName();
// Include Client Identifier
- includeClientId();
+ appendClientId();
if (requested_addr) {
addRequestedAddress(*requested_addr);
}
@@ -182,7 +230,7 @@ void
Dhcp4Client::doInform(const bool set_ciaddr) {
context_.query_ = createMsg(DHCPINFORM);
// Request options if any.
- includePRL();
+ appendPRL();
// The client sending a DHCPINFORM message has an IP address obtained
// by some other means, e.g. static configuration. The lease which we
// are using here is most likely set by the createLease method.
@@ -245,11 +293,11 @@ Dhcp4Client::doRequest() {
}
// Request options if any.
- includePRL();
+ appendPRL();
// Include FQDN or Hostname.
- includeName();
+ appendName();
// Include Client Identifier
- includeClientId();
+ appendClientId();
// Send the message to the server.
sendMsg(context_.query_);
// Expect response.
@@ -271,20 +319,6 @@ Dhcp4Client::includeClientId(const std::string& clientid) {
}
void
-Dhcp4Client::includeClientId() {
- if (!context_.query_) {
- isc_throw(Dhcp4ClientError, "pointer to the query must not be NULL"
- " when adding Client Identifier option");
- }
-
- if (clientid_) {
- OptionPtr opt(new Option(Option::V4, DHO_DHCP_CLIENT_IDENTIFIER,
- clientid_->getClientId()));
- context_.query_->addOption(opt);
- }
-}
-
-void
Dhcp4Client::includeFQDN(const uint8_t flags, const std::string& fqdn_name,
Option4ClientFqdn::DomainNameType fqdn_type) {
fqdn_.reset(new Option4ClientFqdn(flags, Option4ClientFqdn::RCODE_CLIENT(),
@@ -296,39 +330,6 @@ Dhcp4Client::includeHostname(const std::string& name) {
hostname_.reset(new OptionString(Option::V4, DHO_HOST_NAME, name));
}
-void
-Dhcp4Client::includeName() {
- if (!context_.query_) {
- isc_throw(Dhcp4ClientError, "pointer to the query must not be NULL"
- " when adding FQDN or Hostname option");
- }
-
- if (fqdn_) {
- context_.query_->addOption(fqdn_);
-
- } else if (hostname_) {
- context_.query_->addOption(hostname_);
- }
-}
-
-void
-Dhcp4Client::includePRL() {
- if (!context_.query_) {
- isc_throw(Dhcp4ClientError, "pointer to the query must not be NULL"
- " when adding option codes to the PRL option");
-
- } else if (!requested_options_.empty()) {
- // Include Parameter Request List if at least one option code
- // has been specified to be requested.
- OptionUint8ArrayPtr prl(new OptionUint8Array(Option::V4,
- DHO_DHCP_PARAMETER_REQUEST_LIST));
- for (std::set<uint8_t>::const_iterator opt = requested_options_.begin();
- opt != requested_options_.end(); ++opt) {
- prl->addValue(*opt);
- }
- context_.query_->addOption(prl);
- }
-}
HWAddrPtr
Dhcp4Client::generateHWAddr(const uint8_t htype) const {
@@ -369,7 +370,6 @@ Dhcp4Client::requestOptions(const uint8_t option1, const uint8_t option2,
requestOption(option3);
}
-
Pkt4Ptr
Dhcp4Client::receiveOneMsg() {
// Return empty pointer if server hasn't responded.