Commit efaa41c9 authored by Francis Dupont's avatar Francis Dupont

[5126] Made DHCPv4o6 port uint16_t

parent ca4a11ca
// Copyright (C) 2015-2016 Internet Systems Consortium, Inc. ("ISC") // Copyright (C) 2015-2017 Internet Systems Consortium, Inc. ("ISC")
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
...@@ -35,7 +35,7 @@ Dhcp4to6Ipc& Dhcp4to6Ipc::instance() { ...@@ -35,7 +35,7 @@ Dhcp4to6Ipc& Dhcp4to6Ipc::instance() {
} }
void Dhcp4to6Ipc::open() { void Dhcp4to6Ipc::open() {
uint32_t port = CfgMgr::instance().getStagingCfg()->getDhcp4o6Port(); uint16_t port = CfgMgr::instance().getStagingCfg()->getDhcp4o6Port();
if (port == 0) { if (port == 0) {
Dhcp4o6IpcBase::close(); Dhcp4o6IpcBase::close();
return; return;
...@@ -45,8 +45,7 @@ void Dhcp4to6Ipc::open() { ...@@ -45,8 +45,7 @@ void Dhcp4to6Ipc::open() {
} }
int old_fd = socket_fd_; int old_fd = socket_fd_;
socket_fd_ = Dhcp4o6IpcBase::open(static_cast<uint16_t>(port), socket_fd_ = Dhcp4o6IpcBase::open(port, ENDPOINT_TYPE_V4);
ENDPOINT_TYPE_V4);
if ((old_fd == -1) && (socket_fd_ != old_fd)) { if ((old_fd == -1) && (socket_fd_ != old_fd)) {
IfaceMgr::instance().addExternalSocket(socket_fd_, IfaceMgr::instance().addExternalSocket(socket_fd_,
Dhcp4to6Ipc::handler); Dhcp4to6Ipc::handler);
......
...@@ -339,8 +339,7 @@ public: ...@@ -339,8 +339,7 @@ public:
cfg->setDeclinePeriod(probation_period); cfg->setDeclinePeriod(probation_period);
// Set the DHCPv4-over-DHCPv6 interserver port. // Set the DHCPv4-over-DHCPv6 interserver port.
// @todo Change for uint16_t uint16_t dhcp4o6_port = getUint16(global, "dhcp4o6-port");
uint32_t dhcp4o6_port = getUint32(global, "dhcp4o6-port");
cfg->setDhcp4o6Port(dhcp4o6_port); cfg->setDhcp4o6Port(dhcp4o6_port);
} }
...@@ -357,6 +356,18 @@ private: ...@@ -357,6 +356,18 @@ private:
const std::string& name) { const std::string& name) {
return (getIntType<uint32_t>(scope, name)); return (getIntType<uint32_t>(scope, name));
} }
/// @brief Returns a value converted to uint16_t
///
/// Instantiation of getIntType() to uint16_t
///
/// @param scope specified parameter will be extracted from this scope
/// @param name name of the parameter
/// @return an uint16_t value
uint16_t getUint16(isc::data::ConstElementPtr scope,
const std::string& name) {
return (getIntType<uint16_t>(scope, name));
}
}; };
} // anonymous namespace } // anonymous namespace
......
// Copyright (C) 2015-2016 Internet Systems Consortium, Inc. ("ISC") // Copyright (C) 2015-2017 Internet Systems Consortium, Inc. ("ISC")
// //
// This Source Code Form is subject to the terms of the Mozilla Public // This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this // License, v. 2.0. If a copy of the MPL was not distributed with this
...@@ -34,7 +34,7 @@ Dhcp6to4Ipc& Dhcp6to4Ipc::instance() { ...@@ -34,7 +34,7 @@ Dhcp6to4Ipc& Dhcp6to4Ipc::instance() {
} }
void Dhcp6to4Ipc::open() { void Dhcp6to4Ipc::open() {
uint32_t port = CfgMgr::instance().getStagingCfg()->getDhcp4o6Port(); uint16_t port = CfgMgr::instance().getStagingCfg()->getDhcp4o6Port();
if (port == 0) { if (port == 0) {
Dhcp4o6IpcBase::close(); Dhcp4o6IpcBase::close();
return; return;
...@@ -44,8 +44,7 @@ void Dhcp6to4Ipc::open() { ...@@ -44,8 +44,7 @@ void Dhcp6to4Ipc::open() {
} }
int old_fd = socket_fd_; int old_fd = socket_fd_;
socket_fd_ = Dhcp4o6IpcBase::open(static_cast<uint16_t>(port), socket_fd_ = Dhcp4o6IpcBase::open(port, ENDPOINT_TYPE_V6);
ENDPOINT_TYPE_V6);
if ((old_fd == -1) && (socket_fd_ != old_fd)) { if ((old_fd == -1) && (socket_fd_ != old_fd)) {
IfaceMgr::instance().addExternalSocket(socket_fd_, IfaceMgr::instance().addExternalSocket(socket_fd_,
Dhcp6to4Ipc::handler); Dhcp6to4Ipc::handler);
......
...@@ -545,8 +545,7 @@ public: ...@@ -545,8 +545,7 @@ public:
srv_config->setDeclinePeriod(probation_period); srv_config->setDeclinePeriod(probation_period);
// Set the DHCPv4-over-DHCPv6 interserver port. // Set the DHCPv4-over-DHCPv6 interserver port.
// @todo Change for uint16_t uint16_t dhcp4o6_port = getUint16(global, "dhcp4o6-port");
uint32_t dhcp4o6_port = getUint32(global, "dhcp4o6-port");
srv_config->setDhcp4o6Port(dhcp4o6_port); srv_config->setDhcp4o6Port(dhcp4o6_port);
} }
...@@ -563,6 +562,18 @@ private: ...@@ -563,6 +562,18 @@ private:
const std::string& name) { const std::string& name) {
return (getIntType<uint32_t>(scope, name)); return (getIntType<uint32_t>(scope, name));
} }
/// @brief Returns a value converted to uint16_t
///
/// Instantiation of getIntType() to uint16_t
///
/// @param scope specified parameter will be extracted from this scope
/// @param name name of the parameter
/// @return an uint16_t value
uint16_t getUint16(isc::data::ConstElementPtr scope,
const std::string& name) {
return (getIntType<uint16_t>(scope, name));
}
}; };
} // anonymous namespace } // anonymous namespace
......
...@@ -476,7 +476,7 @@ public: ...@@ -476,7 +476,7 @@ public:
/// this socket is bound and connected to this port and port + 1 /// this socket is bound and connected to this port and port + 1
/// ///
/// @param port port and port + 1 to use /// @param port port and port + 1 to use
void setDhcp4o6Port(uint32_t port) { void setDhcp4o6Port(uint16_t port) {
/// @todo: Port is supposed to be uint16_t, not uint32_t /// @todo: Port is supposed to be uint16_t, not uint32_t
dhcp4o6_port_ = port; dhcp4o6_port_ = port;
} }
...@@ -485,7 +485,7 @@ public: ...@@ -485,7 +485,7 @@ public:
/// ///
/// See @ref setDhcp4o6Port for brief discussion. /// See @ref setDhcp4o6Port for brief discussion.
/// @return value of DHCP4o6 IPC port /// @return value of DHCP4o6 IPC port
uint32_t getDhcp4o6Port() { uint16_t getDhcp4o6Port() {
return (dhcp4o6_port_); return (dhcp4o6_port_);
} }
...@@ -587,7 +587,7 @@ private: ...@@ -587,7 +587,7 @@ private:
/// ///
/// DHCPv4-over-DHCPv6 uses a UDP socket for interserver communication, /// DHCPv4-over-DHCPv6 uses a UDP socket for interserver communication,
/// this socket is bound and connected to this port and port + 1 /// this socket is bound and connected to this port and port + 1
uint32_t dhcp4o6_port_; uint16_t dhcp4o6_port_;
D2ClientConfigPtr d2_client_config_; D2ClientConfigPtr d2_client_config_;
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment