diff --git a/src/bin/dhcp4/dhcp4to6_ipc.cc b/src/bin/dhcp4/dhcp4to6_ipc.cc index 573078cb3e58c36e347ae0c5ba59cac38217ffd0..b21920726552923e99288edbb3005d522a1c1c0c 100644 --- a/src/bin/dhcp4/dhcp4to6_ipc.cc +++ b/src/bin/dhcp4/dhcp4to6_ipc.cc @@ -1,4 +1,4 @@ -// 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 // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -35,7 +35,7 @@ Dhcp4to6Ipc& Dhcp4to6Ipc::instance() { } void Dhcp4to6Ipc::open() { - uint32_t port = CfgMgr::instance().getStagingCfg()->getDhcp4o6Port(); + uint16_t port = CfgMgr::instance().getStagingCfg()->getDhcp4o6Port(); if (port == 0) { Dhcp4o6IpcBase::close(); return; @@ -45,8 +45,7 @@ void Dhcp4to6Ipc::open() { } int old_fd = socket_fd_; - socket_fd_ = Dhcp4o6IpcBase::open(static_cast(port), - ENDPOINT_TYPE_V4); + socket_fd_ = Dhcp4o6IpcBase::open(port, ENDPOINT_TYPE_V4); if ((old_fd == -1) && (socket_fd_ != old_fd)) { IfaceMgr::instance().addExternalSocket(socket_fd_, Dhcp4to6Ipc::handler); diff --git a/src/bin/dhcp4/json_config_parser.cc b/src/bin/dhcp4/json_config_parser.cc index 7e49264c03d2a048129a230f7a90b39e57d85d25..1ab22bfef8bcb7fc2f03f1922b709cfe7d3a3168 100644 --- a/src/bin/dhcp4/json_config_parser.cc +++ b/src/bin/dhcp4/json_config_parser.cc @@ -339,8 +339,7 @@ public: cfg->setDeclinePeriod(probation_period); // Set the DHCPv4-over-DHCPv6 interserver port. - // @todo Change for uint16_t - uint32_t dhcp4o6_port = getUint32(global, "dhcp4o6-port"); + uint16_t dhcp4o6_port = getUint16(global, "dhcp4o6-port"); cfg->setDhcp4o6Port(dhcp4o6_port); } @@ -357,6 +356,18 @@ private: const std::string& name) { return (getIntType(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(scope, name)); + } }; } // anonymous namespace diff --git a/src/bin/dhcp6/dhcp6to4_ipc.cc b/src/bin/dhcp6/dhcp6to4_ipc.cc index 72001a4f87ed7114edbb02607e54b455b55348a0..7ec9397973e7216ff87bd7ff24f849868532f347 100644 --- a/src/bin/dhcp6/dhcp6to4_ipc.cc +++ b/src/bin/dhcp6/dhcp6to4_ipc.cc @@ -1,4 +1,4 @@ -// 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 // License, v. 2.0. If a copy of the MPL was not distributed with this @@ -34,7 +34,7 @@ Dhcp6to4Ipc& Dhcp6to4Ipc::instance() { } void Dhcp6to4Ipc::open() { - uint32_t port = CfgMgr::instance().getStagingCfg()->getDhcp4o6Port(); + uint16_t port = CfgMgr::instance().getStagingCfg()->getDhcp4o6Port(); if (port == 0) { Dhcp4o6IpcBase::close(); return; @@ -44,8 +44,7 @@ void Dhcp6to4Ipc::open() { } int old_fd = socket_fd_; - socket_fd_ = Dhcp4o6IpcBase::open(static_cast(port), - ENDPOINT_TYPE_V6); + socket_fd_ = Dhcp4o6IpcBase::open(port, ENDPOINT_TYPE_V6); if ((old_fd == -1) && (socket_fd_ != old_fd)) { IfaceMgr::instance().addExternalSocket(socket_fd_, Dhcp6to4Ipc::handler); diff --git a/src/bin/dhcp6/json_config_parser.cc b/src/bin/dhcp6/json_config_parser.cc index d34260ce9552ade56cf23b3906d77ae32cdafee3..3521174b3e1e354c31d4c1c1512c3e51743bc637 100644 --- a/src/bin/dhcp6/json_config_parser.cc +++ b/src/bin/dhcp6/json_config_parser.cc @@ -545,8 +545,7 @@ public: srv_config->setDeclinePeriod(probation_period); // Set the DHCPv4-over-DHCPv6 interserver port. - // @todo Change for uint16_t - uint32_t dhcp4o6_port = getUint32(global, "dhcp4o6-port"); + uint16_t dhcp4o6_port = getUint16(global, "dhcp4o6-port"); srv_config->setDhcp4o6Port(dhcp4o6_port); } @@ -563,6 +562,18 @@ private: const std::string& name) { return (getIntType(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(scope, name)); + } }; } // anonymous namespace diff --git a/src/lib/dhcpsrv/srv_config.h b/src/lib/dhcpsrv/srv_config.h index dcf91049841fa77d71879b2c278cec1fcde9055c..f70b4dc93211332dee5f4415e1667e607bea0773 100644 --- a/src/lib/dhcpsrv/srv_config.h +++ b/src/lib/dhcpsrv/srv_config.h @@ -476,7 +476,7 @@ public: /// this socket is bound and connected to this port and port + 1 /// /// @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 dhcp4o6_port_ = port; } @@ -485,7 +485,7 @@ public: /// /// See @ref setDhcp4o6Port for brief discussion. /// @return value of DHCP4o6 IPC port - uint32_t getDhcp4o6Port() { + uint16_t getDhcp4o6Port() { return (dhcp4o6_port_); } @@ -587,7 +587,7 @@ private: /// /// DHCPv4-over-DHCPv6 uses a UDP socket for interserver communication, /// this socket is bound and connected to this port and port + 1 - uint32_t dhcp4o6_port_; + uint16_t dhcp4o6_port_; D2ClientConfigPtr d2_client_config_; };