mirror of
https://gitlab.isc.org/isc-projects/kea
synced 2025-08-29 13:07:50 +00:00
[82-improve-kea-test-capabilities] Made "server" port
This commit is contained in:
parent
102feb5bdb
commit
0487f6fc96
@ -38,7 +38,7 @@
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<command>-p <replaceable>port</replaceable></command> -
|
||||
<command>-p <replaceable>server-port</replaceable></command> -
|
||||
specifies UDP port on which the server will listen. This is only
|
||||
useful during testing, as a DHCPv4 server listening on
|
||||
ports other than the standard ones will not be able to
|
||||
|
@ -38,7 +38,7 @@
|
||||
</listitem>
|
||||
<listitem>
|
||||
<simpara>
|
||||
<command>-p <replaceable>port</replaceable></command> -
|
||||
<command>-p <replaceable>server-port</replaceable></command> -
|
||||
specifies UDP port on which the server will listen. This is only
|
||||
useful during testing, as a DHCPv6 server listening on
|
||||
ports other than the standard ones will not be able to
|
||||
|
@ -657,7 +657,8 @@ ControlledDhcpv4Srv::processConfig(isc::data::ConstElementPtr config) {
|
||||
// is no need to rollback configuration if socket fails to open on any
|
||||
// of the interfaces.
|
||||
CfgMgr::instance().getStagingCfg()->getCfgIface()->
|
||||
openSockets(AF_INET, srv->getPort(), getInstance()->useBroadcast());
|
||||
openSockets(AF_INET, srv->getServerPort(),
|
||||
getInstance()->useBroadcast());
|
||||
|
||||
// Install the timers for handling leases reclamation.
|
||||
try {
|
||||
@ -715,8 +716,8 @@ ControlledDhcpv4Srv::checkConfig(isc::data::ConstElementPtr config) {
|
||||
return (configureDhcp4Server(*srv, config, true));
|
||||
}
|
||||
|
||||
ControlledDhcpv4Srv::ControlledDhcpv4Srv(uint16_t port /*= DHCP4_SERVER_PORT*/)
|
||||
: Dhcpv4Srv(port), io_service_(), timer_mgr_(TimerMgr::instance()) {
|
||||
ControlledDhcpv4Srv::ControlledDhcpv4Srv(uint16_t server_port /*= DHCP4_SERVER_PORT*/)
|
||||
: Dhcpv4Srv(server_port), io_service_(), timer_mgr_(TimerMgr::instance()) {
|
||||
if (getInstance()) {
|
||||
isc_throw(InvalidOperation,
|
||||
"There is another Dhcpv4Srv instance already.");
|
||||
|
@ -27,8 +27,8 @@ public:
|
||||
|
||||
/// @brief Constructor
|
||||
///
|
||||
/// @param port UDP port to be opened for DHCP traffic
|
||||
ControlledDhcpv4Srv(uint16_t port = DHCP4_SERVER_PORT);
|
||||
/// @param server_port UDP port to be opened for DHCP traffic
|
||||
ControlledDhcpv4Srv(uint16_t server_port = DHCP4_SERVER_PORT);
|
||||
|
||||
/// @brief Destructor.
|
||||
~ControlledDhcpv4Srv();
|
||||
|
@ -421,7 +421,7 @@ This message is printed when the DHCPv4 server is attempting to open a
|
||||
configuration database. The database access string with password redacted
|
||||
is logged.
|
||||
|
||||
% DHCP4_OPEN_SOCKET opening sockets on port %1
|
||||
% DHCP4_OPEN_SOCKET opening service sockets on port %1
|
||||
A debug message issued during startup, this indicates that the DHCPv4
|
||||
server is about to open sockets on the specified port.
|
||||
|
||||
@ -739,7 +739,7 @@ This informational message indicates that the DHCPv4 server has
|
||||
processed any command-line switches and is starting. The version
|
||||
is also printed.
|
||||
|
||||
% DHCP4_START_INFO pid: %1, port: %2, verbose: %3
|
||||
% DHCP4_START_INFO pid: %1, server port: %2, verbose: %3
|
||||
This is a debug message issued during the DHCPv4 server startup.
|
||||
It lists some information about the parameters with which the server
|
||||
is running.
|
||||
|
@ -441,17 +441,19 @@ Dhcpv4Exchange::setReservedMessageFields() {
|
||||
|
||||
const std::string Dhcpv4Srv::VENDOR_CLASS_PREFIX("VENDOR_CLASS_");
|
||||
|
||||
Dhcpv4Srv::Dhcpv4Srv(uint16_t port, const bool use_bcast,
|
||||
Dhcpv4Srv::Dhcpv4Srv(uint16_t server_port, const bool use_bcast,
|
||||
const bool direct_response_desired)
|
||||
: io_service_(new IOService()), shutdown_(true), alloc_engine_(), port_(port),
|
||||
use_bcast_(use_bcast), network_state_(new NetworkState(NetworkState::DHCPv4)) {
|
||||
: io_service_(new IOService()), shutdown_(true), alloc_engine_(),
|
||||
server_port_(server_port), use_bcast_(use_bcast),
|
||||
network_state_(new NetworkState(NetworkState::DHCPv4)) {
|
||||
|
||||
LOG_DEBUG(dhcp4_logger, DBG_DHCP4_START, DHCP4_OPEN_SOCKET).arg(port);
|
||||
LOG_DEBUG(dhcp4_logger, DBG_DHCP4_START, DHCP4_OPEN_SOCKET)
|
||||
.arg(server_port);
|
||||
try {
|
||||
// Port 0 is used for testing purposes where we don't open broadcast
|
||||
// capable sockets. So, set the packet filter handling direct traffic
|
||||
// only if we are in non-test mode.
|
||||
if (port) {
|
||||
if (server_port) {
|
||||
// First call to instance() will create IfaceMgr (it's a singleton)
|
||||
// it may throw something if things go wrong.
|
||||
// The 'true' value of the call to setMatchingPacketFilter imposes
|
||||
|
@ -219,11 +219,11 @@ public:
|
||||
/// class for unit testing because features they enable require
|
||||
/// root privileges.
|
||||
///
|
||||
/// @param port specifies port number to listen on
|
||||
/// @param server_port specifies port number to listen on
|
||||
/// @param use_bcast configure sockets to support broadcast messages.
|
||||
/// @param direct_response_desired specifies if it is desired to
|
||||
/// use direct V4 traffic.
|
||||
Dhcpv4Srv(uint16_t port = DHCP4_SERVER_PORT,
|
||||
Dhcpv4Srv(uint16_t server_port = DHCP4_SERVER_PORT,
|
||||
const bool use_bcast = true,
|
||||
const bool direct_response_desired = true);
|
||||
|
||||
@ -285,8 +285,8 @@ public:
|
||||
/// for testing purposes only.
|
||||
///
|
||||
/// @return UDP port on which server should listen.
|
||||
uint16_t getPort() const {
|
||||
return (port_);
|
||||
uint16_t getServerPort() const {
|
||||
return (server_port_);
|
||||
}
|
||||
|
||||
/// @brief Return bool value indicating that broadcast flags should be set
|
||||
@ -954,8 +954,11 @@ private:
|
||||
/// @return Option that contains netmask information
|
||||
static OptionPtr getNetmaskOption(const Subnet4Ptr& subnet);
|
||||
|
||||
uint16_t port_; ///< UDP port number on which server listens.
|
||||
bool use_bcast_; ///< Should broadcast be enabled on sockets (if true).
|
||||
/// UDP port number on which server listens.
|
||||
uint16_t server_port_;
|
||||
|
||||
/// Should broadcast be enabled on sockets (if true).
|
||||
bool use_bcast_;
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -49,7 +49,7 @@
|
||||
<arg choice="opt" rep="norepeat"><option>-d</option></arg>
|
||||
<arg choice="opt" rep="norepeat"><option>-c <replaceable class="parameter">config-file</replaceable></option></arg>
|
||||
<arg choice="opt" rep="norepeat"><option>-t <replaceable class="parameter">config-file</replaceable></option></arg>
|
||||
<arg choice="opt" rep="norepeat"><option>-p <replaceable class="parameter">port-number</replaceable></option></arg>
|
||||
<arg choice="opt" rep="norepeat"><option>-p <replaceable class="parameter">server-port-number</replaceable></option></arg>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
@ -118,8 +118,8 @@
|
||||
<varlistentry>
|
||||
<term><option>-p</option></term>
|
||||
<listitem><para>
|
||||
Port number (1-65535) on which the server listens. This is useful
|
||||
for testing purposes only.
|
||||
Server port number (1-65535) on which the server listens.
|
||||
This is useful for testing purposes only.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
@ -51,7 +51,7 @@ usage() {
|
||||
cerr << " -d: debug mode with extra verbosity (former -v)" << endl;
|
||||
cerr << " -c file: specify configuration file" << endl;
|
||||
cerr << " -t file: check the configuration file syntax and exit" << endl;
|
||||
cerr << " -p number: specify non-standard port number 1-65535 "
|
||||
cerr << " -p number: specify non-standard server port number 1-65535 "
|
||||
<< "(useful for testing only)" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@ -60,8 +60,8 @@ usage() {
|
||||
int
|
||||
main(int argc, char* argv[]) {
|
||||
int ch;
|
||||
int port_number = DHCP4_SERVER_PORT; // The default. any other values are
|
||||
// useful for testing only.
|
||||
// The default. any other values are useful for testing only.
|
||||
int server_port_number = DHCP4_SERVER_PORT;
|
||||
bool verbose_mode = false; // Should server be verbose?
|
||||
bool check_mode = false; // Check syntax
|
||||
|
||||
@ -96,13 +96,13 @@ main(int argc, char* argv[]) {
|
||||
|
||||
case 'p':
|
||||
try {
|
||||
port_number = boost::lexical_cast<int>(optarg);
|
||||
server_port_number = boost::lexical_cast<int>(optarg);
|
||||
} catch (const boost::bad_lexical_cast &) {
|
||||
cerr << "Failed to parse port number: [" << optarg
|
||||
<< "], 1-65535 allowed." << endl;
|
||||
usage();
|
||||
}
|
||||
if (port_number <= 0 || port_number > 65535) {
|
||||
if (server_port_number <= 0 || server_port_number > 65535) {
|
||||
cerr << "Failed to parse port number: [" << optarg
|
||||
<< "], 1-65535 allowed." << endl;
|
||||
usage();
|
||||
@ -187,12 +187,13 @@ main(int argc, char* argv[]) {
|
||||
// Initialize logging. If verbose, we'll use maximum verbosity.
|
||||
Daemon::loggerInit(DHCP4_ROOT_LOGGER_NAME, verbose_mode);
|
||||
LOG_DEBUG(dhcp4_logger, DBG_DHCP4_START, DHCP4_START_INFO)
|
||||
.arg(getpid()).arg(port_number).arg(verbose_mode ? "yes" : "no");
|
||||
.arg(getpid()).arg(server_port_number)
|
||||
.arg(verbose_mode ? "yes" : "no");
|
||||
|
||||
LOG_INFO(dhcp4_logger, DHCP4_STARTING).arg(VERSION);
|
||||
|
||||
// Create the server instance.
|
||||
ControlledDhcpv4Srv server(port_number);
|
||||
ControlledDhcpv4Srv server(server_port_number);
|
||||
|
||||
// Remember verbose-mode
|
||||
server.setVerbose(verbose_mode);
|
||||
|
@ -676,7 +676,8 @@ ControlledDhcpv6Srv::processConfig(isc::data::ConstElementPtr config) {
|
||||
// log warnings. Since we allow that this fails for some interfaces there
|
||||
// is no need to rollback configuration if socket fails to open on any
|
||||
// of the interfaces.
|
||||
CfgMgr::instance().getStagingCfg()->getCfgIface()->openSockets(AF_INET6, srv->getPort());
|
||||
CfgMgr::instance().getStagingCfg()->getCfgIface()->
|
||||
openSockets(AF_INET6, srv->getServerPort());
|
||||
|
||||
// Install the timers for handling leases reclamation.
|
||||
try {
|
||||
@ -737,8 +738,8 @@ ControlledDhcpv6Srv::checkConfig(isc::data::ConstElementPtr config) {
|
||||
return (configureDhcp6Server(*srv, config, true));
|
||||
}
|
||||
|
||||
ControlledDhcpv6Srv::ControlledDhcpv6Srv(uint16_t port)
|
||||
: Dhcpv6Srv(port), io_service_(), timer_mgr_(TimerMgr::instance()) {
|
||||
ControlledDhcpv6Srv::ControlledDhcpv6Srv(uint16_t server_port)
|
||||
: Dhcpv6Srv(server_port), io_service_(), timer_mgr_(TimerMgr::instance()) {
|
||||
if (server_) {
|
||||
isc_throw(InvalidOperation,
|
||||
"There is another Dhcpv6Srv instance already.");
|
||||
|
@ -27,8 +27,8 @@ public:
|
||||
|
||||
/// @brief Constructor
|
||||
///
|
||||
/// @param port UDP port to be opened for DHCP traffic
|
||||
ControlledDhcpv6Srv(uint16_t port = DHCP6_SERVER_PORT);
|
||||
/// @param server_port UDP port to be opened for DHCP traffic
|
||||
ControlledDhcpv6Srv(uint16_t server_port = DHCP6_SERVER_PORT);
|
||||
|
||||
/// @brief Destructor.
|
||||
virtual ~ControlledDhcpv6Srv();
|
||||
|
@ -101,7 +101,7 @@ extern isc::log::Logger packet6_logger;
|
||||
/// @brief Logger for options parser.
|
||||
///
|
||||
/// This logger is used to issue log messages related to processing of the
|
||||
/// DHCP options
|
||||
/// DHCP options.
|
||||
extern isc::log::Logger options6_logger;
|
||||
|
||||
/// @brief Logger for Hostname or FQDN processing.
|
||||
|
@ -472,7 +472,7 @@ This warning message is issued when current server configuration specifies
|
||||
no interfaces that server should listen on, or specified interfaces are not
|
||||
configured to receive the traffic.
|
||||
|
||||
% DHCP6_OPEN_SOCKET opening sockets on port %1
|
||||
% DHCP6_OPEN_SOCKET opening service sockets on port %1
|
||||
A debug message issued during startup, this indicates that the IPv6 DHCP
|
||||
server is about to open sockets on the specified port.
|
||||
|
||||
@ -782,7 +782,7 @@ This informational message indicates that the IPv6 DHCP server has
|
||||
processed any command-line switches and is starting. The version
|
||||
is also printed.
|
||||
|
||||
% DHCP6_START_INFO pid: %1, port: %2, verbose: %3
|
||||
% DHCP6_START_INFO pid: %1, server port: %2, verbose: %3
|
||||
This is a debug message issued during the IPv6 DHCP server startup.
|
||||
It lists some information about the parameters with which the server
|
||||
is running.
|
||||
|
@ -179,20 +179,21 @@ namespace dhcp {
|
||||
|
||||
const std::string Dhcpv6Srv::VENDOR_CLASS_PREFIX("VENDOR_CLASS_");
|
||||
|
||||
Dhcpv6Srv::Dhcpv6Srv(uint16_t port)
|
||||
: io_service_(new IOService()), port_(port), serverid_(), shutdown_(true),
|
||||
alloc_engine_(), name_change_reqs_(),
|
||||
Dhcpv6Srv::Dhcpv6Srv(uint16_t server_port)
|
||||
: io_service_(new IOService()), server_port_(server_port), serverid_(),
|
||||
shutdown_(true), alloc_engine_(), name_change_reqs_(),
|
||||
network_state_(new NetworkState(NetworkState::DHCPv6))
|
||||
{
|
||||
|
||||
LOG_DEBUG(dhcp6_logger, DBG_DHCP6_START, DHCP6_OPEN_SOCKET).arg(port);
|
||||
LOG_DEBUG(dhcp6_logger, DBG_DHCP6_START, DHCP6_OPEN_SOCKET)
|
||||
.arg(server_port);
|
||||
|
||||
// Initialize objects required for DHCP server operation.
|
||||
try {
|
||||
// Port 0 is used for testing purposes where in most cases we don't
|
||||
// rely on the physical interfaces. Therefore, it should be possible
|
||||
// to create an object even when there are no usable interfaces.
|
||||
if ((port > 0) && (IfaceMgr::instance().countIfaces() == 0)) {
|
||||
if ((server_port > 0) && (IfaceMgr::instance().countIfaces() == 0)) {
|
||||
LOG_ERROR(dhcp6_logger, DHCP6_NO_INTERFACES);
|
||||
return;
|
||||
}
|
||||
|
@ -80,8 +80,8 @@ public:
|
||||
/// network interaction. Will instantiate lease manager, and load
|
||||
/// old or create new DUID.
|
||||
///
|
||||
/// @param port port on will all sockets will listen
|
||||
Dhcpv6Srv(uint16_t port = DHCP6_SERVER_PORT);
|
||||
/// @param server_port port on will all sockets will listen
|
||||
Dhcpv6Srv(uint16_t server_port = DHCP6_SERVER_PORT);
|
||||
|
||||
/// @brief Destructor. Used during DHCPv6 service shutdown.
|
||||
virtual ~Dhcpv6Srv();
|
||||
@ -138,8 +138,8 @@ public:
|
||||
/// used for testing purposes.
|
||||
///
|
||||
/// @return UDP port on which server should listen.
|
||||
uint16_t getPort() const {
|
||||
return (port_);
|
||||
uint16_t getServerPort() const {
|
||||
return (server_port_);
|
||||
}
|
||||
|
||||
/// @brief Starts DHCP_DDNS client IO if DDNS updates are enabled.
|
||||
@ -941,7 +941,7 @@ private:
|
||||
bool requestedInORO(const Pkt6Ptr& query, const uint16_t code) const;
|
||||
|
||||
/// UDP port number on which server listens.
|
||||
uint16_t port_;
|
||||
uint16_t server_port_;
|
||||
|
||||
public:
|
||||
/// @note used by DHCPv4-over-DHCPv6 so must be public and static
|
||||
|
@ -48,7 +48,7 @@
|
||||
<arg choice="opt" rep="norepeat"><option>-d</option></arg>
|
||||
<arg choice="opt" rep="norepeat"><option>-c <replaceable class="parameter">config-file</replaceable></option></arg>
|
||||
<arg choice="opt" rep="norepeat"><option>-t <replaceable class="parameter">config-file</replaceable></option></arg>
|
||||
<arg choice="opt" rep="norepeat"><option>-p <replaceable class="parameter">port-number</replaceable></option></arg>
|
||||
<arg choice="opt" rep="norepeat"><option>-p <replaceable class="parameter">server-port-number</replaceable></option></arg>
|
||||
</cmdsynopsis>
|
||||
</refsynopsisdiv>
|
||||
|
||||
@ -118,8 +118,8 @@
|
||||
<varlistentry>
|
||||
<term><option>-p</option></term>
|
||||
<listitem><para>
|
||||
Port number (1-65535) on which the server listens. This is useful
|
||||
for testing purposes only.
|
||||
Server port number (1-65535) on which the server listens.
|
||||
This is useful for testing purposes only.
|
||||
</para></listitem>
|
||||
</varlistentry>
|
||||
|
||||
|
@ -49,14 +49,14 @@ usage() {
|
||||
cerr << "Kea DHCPv6 server, version " << VERSION << endl;
|
||||
cerr << endl;
|
||||
cerr << "Usage: " << DHCP6_NAME
|
||||
<< " -[v|V|W] [-d] [-{c|t} cfgfile] [-p port_number]" << endl;
|
||||
<< " -[v|V|W] [-d] [-{c|t} cfgfile] [-p server_port_number]" << endl;
|
||||
cerr << " -v: print version number and exit." << endl;
|
||||
cerr << " -V: print extended version and exit" << endl;
|
||||
cerr << " -W: display the configuration report and exit" << endl;
|
||||
cerr << " -d: debug mode with extra verbosity (former -v)" << endl;
|
||||
cerr << " -c file: specify configuration file" << endl;
|
||||
cerr << " -t file: check the configuration file syntax and exit" << endl;
|
||||
cerr << " -p number: specify non-standard port number 1-65535 "
|
||||
cerr << " -p number: specify non-standard server port number 1-65535 "
|
||||
<< "(useful for testing only)" << endl;
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
@ -65,8 +65,8 @@ usage() {
|
||||
int
|
||||
main(int argc, char* argv[]) {
|
||||
int ch;
|
||||
int port_number = DHCP6_SERVER_PORT; // The default. Any other values are
|
||||
// useful for testing only.
|
||||
// The default. Any other values are useful for testing only.
|
||||
int server_port_number = DHCP6_SERVER_PORT;
|
||||
bool verbose_mode = false; // Should server be verbose?
|
||||
bool check_mode = false; // Check syntax
|
||||
|
||||
@ -101,13 +101,13 @@ main(int argc, char* argv[]) {
|
||||
|
||||
case 'p': // port number
|
||||
try {
|
||||
port_number = boost::lexical_cast<int>(optarg);
|
||||
server_port_number = boost::lexical_cast<int>(optarg);
|
||||
} catch (const boost::bad_lexical_cast &) {
|
||||
cerr << "Failed to parse port number: [" << optarg
|
||||
<< "], 1-65535 allowed." << endl;
|
||||
usage();
|
||||
}
|
||||
if (port_number <= 0 || port_number > 65535) {
|
||||
if (server_port_number <= 0 || server_port_number > 65535) {
|
||||
cerr << "Failed to parse port number: [" << optarg
|
||||
<< "], 1-65535 allowed." << endl;
|
||||
usage();
|
||||
@ -194,12 +194,13 @@ main(int argc, char* argv[]) {
|
||||
Daemon::loggerInit(DHCP6_LOGGER_NAME, verbose_mode);
|
||||
|
||||
LOG_DEBUG(dhcp6_logger, DBG_DHCP6_START, DHCP6_START_INFO)
|
||||
.arg(getpid()).arg(port_number).arg(verbose_mode ? "yes" : "no");
|
||||
.arg(getpid()).arg(server_port_number)
|
||||
.arg(verbose_mode ? "yes" : "no");
|
||||
|
||||
LOG_INFO(dhcp6_logger, DHCP6_STARTING).arg(VERSION);
|
||||
|
||||
// Create the server instance.
|
||||
ControlledDhcpv6Srv server(port_number);
|
||||
ControlledDhcpv6Srv server(server_port_number);
|
||||
|
||||
// Remember verbose-mode
|
||||
server.setVerbose(verbose_mode);
|
||||
|
Loading…
x
Reference in New Issue
Block a user