Commit 04d6fb0a authored by Marcin Siodelski's avatar Marcin Siodelski
Browse files

[master] Merge branch 'trac5458a'

parents 85cfee80 8bd5820a
// Copyright (C) 2014-2017 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2014-2018 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
......@@ -91,7 +91,7 @@ public:
/// @param timeout_ms Amount of time after which the method returns.
void runTimersWithTimeout(const IOServicePtr& io_service, const long timeout_ms) {
IntervalTimer timer(*io_service);
timer.setup([this, &io_service]() {
timer.setup([&io_service]() {
io_service->stop();
}, timeout_ms, IntervalTimer::ONE_SHOT);
io_service->run();
......
......@@ -1311,7 +1311,7 @@ TEST_F(Dhcpv4SharedNetworkTest, poolInSharedNetworkShortage) {
// the server has no more addresses to assign.
Dhcp4Client client3(client1.getServer(), Dhcp4Client::SELECTING);
client3.setIfaceName("eth1");
testAssigned([this, &client3]() {
testAssigned([&client3]() {
ASSERT_NO_THROW(client3.doDiscover());
Pkt4Ptr resp3 = client3.getContext().response_;
ASSERT_FALSE(resp3);
......@@ -1447,7 +1447,7 @@ TEST_F(Dhcpv4SharedNetworkTest, hintWithinSharedNetwork) {
// Asking for an address that is not in address pool should result in getting
// an address from one of the subnets, but generally hard to tell from which one.
testAssigned([this, &client] {
testAssigned([&client] {
ASSERT_NO_THROW(client.doDiscover(boost::shared_ptr<IOAddress>(new IOAddress("10.0.0.23"))));
});
......@@ -1481,7 +1481,7 @@ TEST_F(Dhcpv4SharedNetworkTest, subnetInSharedNetworkSelectedByClass) {
// Release the lease that the client has got, because we'll need this address
// further in the test.
testAssigned([this, &client1] {
testAssigned([&client1] {
ASSERT_NO_THROW(client1.doRelease());
});
......@@ -1770,7 +1770,7 @@ TEST_F(Dhcpv4SharedNetworkTest, variousFieldsInReservation) {
configure(NETWORKS_CONFIG[10], *client.getServer());
// Perform 4-way exchange.
testAssigned([this, &client] {
testAssigned([&client] {
ASSERT_NO_THROW(client.doDORA());
});
Pkt4Ptr resp = client.getContext().response_;
......@@ -1816,7 +1816,7 @@ TEST_F(Dhcpv4SharedNetworkTest, sharedNetworkSelectionByInterface) {
configure(NETWORKS_CONFIG[8], *client1.getServer());
// Perform 4-way exchange.
testAssigned([this, &client1] {
testAssigned([&client1] {
ASSERT_NO_THROW(client1.doDORA());
});
Pkt4Ptr resp1 = client1.getContext().response_;
......@@ -1831,7 +1831,7 @@ TEST_F(Dhcpv4SharedNetworkTest, sharedNetworkSelectionByInterface) {
client2.setIfaceName("eth0");
// Perform 4-way exchange.
testAssigned([this, &client2] {
testAssigned([&client2] {
ASSERT_NO_THROW(client2.doDORA());
});
Pkt4Ptr resp2 = client2.getContext().response_;
......@@ -1853,7 +1853,7 @@ TEST_F(Dhcpv4SharedNetworkTest, sharedNetworkSelectionByRelay) {
configure(NETWORKS_CONFIG[9], *client1.getServer());
// Perform 4-way exchange.
testAssigned([this, &client1] {
testAssigned([&client1] {
ASSERT_NO_THROW(client1.doDORA());
});
Pkt4Ptr resp1 = client1.getContext().response_;
......@@ -1868,7 +1868,7 @@ TEST_F(Dhcpv4SharedNetworkTest, sharedNetworkSelectionByRelay) {
client2.useRelay(true, IOAddress("192.1.2.3"));
// Perform 4-way exchange.
testAssigned([this, &client2] {
testAssigned([&client2] {
ASSERT_NO_THROW(client2.doDORA());
});
Pkt4Ptr resp2 = client2.getContext().response_;
......@@ -1892,7 +1892,7 @@ TEST_F(Dhcpv4SharedNetworkTest, matchClientId) {
configure(NETWORKS_CONFIG[11], *client.getServer());
// Perform 4-way exchange.
testAssigned([this, &client] {
testAssigned([&client] {
ASSERT_NO_THROW(client.doDORA());
});
Pkt4Ptr resp1 = client.getContext().response_;
......@@ -1909,7 +1909,7 @@ TEST_F(Dhcpv4SharedNetworkTest, matchClientId) {
client.setState(Dhcp4Client::RENEWING);
// Try to renew the lease with modified MAC address.
testAssigned([this, &client] {
testAssigned([&client] {
ASSERT_NO_THROW(client.doRequest());
});
Pkt4Ptr resp2 = client.getContext().response_;
......@@ -1936,7 +1936,7 @@ TEST_F(Dhcpv4SharedNetworkTest, sharedNetworkSelectedByClass) {
configure(NETWORKS_CONFIG[13], *client1.getServer());
// Simply send DHCPDISCOVER to avoid allocating a lease.
testAssigned([this, &client1] {
testAssigned([&client1] {
ASSERT_NO_THROW(client1.doDiscover());
});
Pkt4Ptr resp1 = client1.getContext().response_;
......@@ -1969,7 +1969,7 @@ TEST_F(Dhcpv4SharedNetworkTest, customServerIdentifier) {
// Configure DHCP server.
ASSERT_NO_THROW(configure(NETWORKS_CONFIG[15], *client1.getServer()));
testAssigned([this, &client1] {
testAssigned([&client1] {
ASSERT_NO_THROW(client1.doDORA());
});
......@@ -1986,7 +1986,7 @@ TEST_F(Dhcpv4SharedNetworkTest, customServerIdentifier) {
Dhcp4Client client2(client1.getServer(), Dhcp4Client::SELECTING);
client2.setIfaceName("eth0");
testAssigned([this, &client2] {
testAssigned([&client2] {
ASSERT_NO_THROW(client2.doDORA());
});
......@@ -2020,7 +2020,7 @@ TEST_F(Dhcpv4SharedNetworkTest, poolInSharedNetworkSelectedByClass) {
// Release the lease that the client has got, because we'll need this address
// further in the test.
testAssigned([this, &client1] {
testAssigned([&client1] {
ASSERT_NO_THROW(client1.doRelease());
});
......@@ -2079,7 +2079,7 @@ TEST_F(Dhcpv4SharedNetworkTest, poolInSubnetSelectedByClass) {
// Release the lease that the client has got, because we'll need this address
// further in the test.
testAssigned([this, &client1] {
testAssigned([&client1] {
ASSERT_NO_THROW(client1.doRelease());
});
......
......@@ -435,7 +435,7 @@ ControlledDhcpv6Srv::commandDhcpDisableHandler(const std::string&,
// The user specified that the DHCP service should resume not
// later than in max-period seconds. If the 'dhcp-enable' command
// is not sent, the DHCP service will resume automatically.
network_state_.delayedEnableAll(static_cast<unsigned>(max_period));
network_state_->delayedEnableAll(static_cast<unsigned>(max_period));
}
}
}
......@@ -443,7 +443,7 @@ ControlledDhcpv6Srv::commandDhcpDisableHandler(const std::string&,
// No error occurred, so let's disable the service.
if (message.tellp() == 0) {
network_state_.disableService();
network_state_->disableService();
message << "DHCPv6 service disabled";
if (max_period > 0) {
......@@ -459,7 +459,7 @@ ControlledDhcpv6Srv::commandDhcpDisableHandler(const std::string&,
ConstElementPtr
ControlledDhcpv6Srv::commandDhcpEnableHandler(const std::string&, ConstElementPtr) {
network_state_.enableService();
network_state_->enableService();
return (config::createAnswer(CONTROL_RESULT_SUCCESS, "DHCP service successfully enabled"));
}
......@@ -689,6 +689,7 @@ ControlledDhcpv6Srv::processConfig(isc::data::ConstElementPtr config) {
CalloutHandlePtr callout_handle = HooksManager::createCalloutHandle();
callout_handle->setArgument("io_context", srv->getIOService());
callout_handle->setArgument("network_state", srv->getNetworkState());
callout_handle->setArgument("json_config", config);
callout_handle->setArgument("server_config", CfgMgr::instance().getStagingCfg());
......@@ -885,7 +886,7 @@ ControlledDhcpv6Srv::dbReconnect(ReconnectCtlPtr db_reconnect_ctl) {
TimerMgr::instance()->cancel("Dhcp6DbReconnectTimer"); }
// Set network state to service enabled
network_state_.enableService();
network_state_->enableService();
// Toss the reconnct control, we're done with it
db_reconnect_ctl.reset();
......@@ -917,7 +918,7 @@ ControlledDhcpv6Srv::dbReconnect(ReconnectCtlPtr db_reconnect_ctl) {
bool
ControlledDhcpv6Srv::dbLostCallback(ReconnectCtlPtr db_reconnect_ctl) {
// Disable service until we recover
network_state_.disableService();
network_state_->disableService();
if (!db_reconnect_ctl) {
// This shouldn't never happen
......
......@@ -46,9 +46,10 @@ packet processing, but the exact order depends on the actual processing. Hook po
that are not specific to packet processing (e.g. lease expiration) will be added
to the end of this list.
@subsection dhcp6HooksDhcpv4SrvConfigured dhcp6_srv_configured
@subsection dhcp6HooksDhcpv6SrvConfigured dhcp6_srv_configured
- @b Arguments:
- name: @b io_context, type: isc::asiolink::IOServicePtr, direction: <b>in</b>
- name: @b network_state, type: isc::dhcp::NetworkStatePtr, direction: <b>in</b>
- name: @b json_config, type: isc::data::ConstElementPtr, direction: <b>in</b>
- name: @b server_config, type: isc::dhcp::SrvConfigPtr, direction: <b>in</b>
......@@ -58,7 +59,9 @@ to the end of this list.
object which is used by the server to run asynchronous operations. The hooks
libraries can use this IOService object to schedule asynchronous tasks which
are triggered by the DHCP server's main loop. The hook library should hold the
provided pointer until the library is unloaded.
provided pointer until the library is unloaded. The NetworkState object
provides access to the DHCP service state of the server and allows for
enabling and disabling the DHCP service from the hooks libraries.
- <b>Next step status</b>: Status codes retured by the callouts installed on
this hook point are ignored.
......@@ -283,6 +286,40 @@ to the end of this list.
remain in the database until it expires. However, the server will send out
the response back to the client as if it did.
@subsection dhcpv6Leases6Committed leases6_committed
- @b Arguments:
- name: @b query6, type: isc::dhcp::Pkt6Ptr, direction: <b>in</b>
- name: @b leases6, type: isc::dhcp::Leases6CollectionPtr, direction: <b>in</b>
- name: @b deleted_leases6, type: isc::dhcp::Leases6CollectionPtr, direction: <b>in</b>
- @b Description: this callout is executed when the server has
applied all lease changes as a result of DHCP message
processing. This includes writing new lease into the database,
releasing an old lease for this client or declining a lease. This
callout is executed only for the DHCP client messages which may
cause lease changes, i.e. SOLICIT with Rapid Commit option included
and when Rapid Commit is enabled, REQUEST, RENEW, REBIND, RELEASE and
DECLINE. This callout is not executed for SOLICIT without Rapid Commit,
CONFIRM and INFORMATION REQUEST. If the callouts are executed as a result of
REQUEST or RENEW message, it is possible that both leases
collections hold leases to be handled. This is the case when the
new lease allocation replaces an existing lease for the client. The
"deleted_leases6" object will hold a previous lease instance and
the "leases6" object will hold the new lease for this client. The
callouts should be prepared to handle such situation. When the
callout is executed as a result RELEASE or DECLINE, the callout
will typically receive one or more leases in the "deleted_leases6"
object. Both leases collections are always provided to the callouts,
even though they may sometimes be empty.
- <b>Next step status</b>: If any callout installed on the "leases6_committed"
sets the next step action to DROP the server will drop the processed query.
If it sets the next step action to PARK, the server will park the processed
packet (hold packet processing) until the hook libraries explicitly unpark
the packet after they are done performing asynchronous operations.
@subsection dhcpv6HooksPkt6Send pkt6_send
- @b Arguments:
......
......@@ -320,6 +320,14 @@ The server will skip the operation of moving the lease to the declined state and
will continue processing the packet. In particular, it will send a REPLY message
as if the decline actually took place.
% DHCP6_HOOK_LEASES6_COMMITTED_DROP %1: packet is dropped, because a callout set the next step to DROP
This debug message is printed when a callout installed on the leases6_committed
hook point sets the next step to DROP.
% DHCP6_HOOK_LEASES6_COMMITTED_PARK %1: packet is parked, because a callout set the next step to PARK
This debug message is printed when a callout installed on the lease6_committed
hook point sets the next step to PARK.
% DHCP6_HOOK_LEASE6_RELEASE_NA_SKIP %1: DHCPv6 address lease was not released because a callout set the next step to SKIP
This debug message is printed when a callout installed on the
lease6_release hook point set the next step to SKIP. For this particular hook
......
This diff is collapsed.
......@@ -17,6 +17,7 @@
#include <dhcp/option_definition.h>
#include <dhcp/pkt6.h>
#include <dhcpsrv/alloc_engine.h>
#include <dhcpsrv/callout_handle_store.h>
#include <dhcpsrv/cfg_option.h>
#include <dhcpsrv/d2_client_mgr.h>
#include <dhcpsrv/network_state.h>
......@@ -24,6 +25,7 @@
#include <hooks/callout_handle.h>
#include <dhcpsrv/daemon.h>
#include <functional>
#include <iostream>
#include <queue>
......@@ -89,6 +91,11 @@ public:
return (io_service_);
}
/// @brief Returns pointer to the network state used by the server.
NetworkStatePtr& getNetworkState() {
return (network_state_);
}
/// @brief returns Kea version on stdout and exit.
/// redeclaration/redefinition. @ref Daemon::getVersion()
static std::string getVersion(bool extended);
......@@ -191,6 +198,16 @@ protected:
/// not allowed according to RFC3315, section 15; true otherwise.
bool testUnicast(const Pkt6Ptr& pkt) const;
/// @brief Verifies if specified packet meets RFC requirements
///
/// Checks if mandatory option is really there, that forbidden option
/// is not there, and that client-id or server-id appears only once.
///
/// @param pkt packet to be checked
/// @return false if the message should be dropped as a result of the
/// sanity check.
bool sanityCheck(const Pkt6Ptr& pkt);
/// @brief verifies if specified packet meets RFC requirements
///
/// Checks if mandatory option is really there, that forbidden option
......@@ -214,10 +231,10 @@ protected:
/// instead of Advertise and requested leases will be assigned
/// immediately.
///
/// @param solicit Solicit message received from client
/// @param ctx Reference to client context
///
/// @return Advertise, Reply message or NULL.
Pkt6Ptr processSolicit(const Pkt6Ptr& solicit);
Pkt6Ptr processSolicit(AllocEngine::ClientContext6& ctx);
/// @brief Processes incoming Request and returns Reply response.
///
......@@ -227,16 +244,17 @@ protected:
/// prefixes, respectively. Uses LeaseMgr to allocate or update existing
/// leases.
///
/// @param request a message received from client
/// @param ctx Reference to client context
///
/// @return REPLY message or NULL
Pkt6Ptr processRequest(const Pkt6Ptr& request);
Pkt6Ptr processRequest(AllocEngine::ClientContext6& ctx);
/// @brief Processes incoming Renew message.
///
/// @param renew message received from the client
/// @param ctx Reference to client context
///
/// @return Reply message to be sent to the client.
Pkt6Ptr processRenew(const Pkt6Ptr& renew);
Pkt6Ptr processRenew(AllocEngine::ClientContext6& ctx);
/// @brief Processes incoming Rebind message.
///
......@@ -246,9 +264,10 @@ protected:
/// client is on the appropriate link or not. We don't seem to do it
/// now.
///
/// @param rebind message received from the client.
/// @param ctx Reference to client context
///
/// @return Reply message to be sent to the client.
Pkt6Ptr processRebind(const Pkt6Ptr& rebind);
Pkt6Ptr processRebind(AllocEngine::ClientContext6& ctx);
/// @brief Processes incoming Confirm message and returns Reply.
///
......@@ -269,17 +288,18 @@ protected:
/// code NotOnLink is returned. Otherwise, the Reply message with the
/// status code Success is returned.
///
/// @param confirm Confirm message sent by a client.
/// @param ctx Reference to client context
///
/// @return Reply message from the server or NULL pointer if Confirm
/// message should be discarded by the server.
Pkt6Ptr processConfirm(const Pkt6Ptr& confirm);
Pkt6Ptr processConfirm(AllocEngine::ClientContext6& ctx);
/// @brief Process incoming Release message.
///
/// @param release message received from client
/// @param ctx Reference to client context
///
/// @return Reply message to be sent to the client.
Pkt6Ptr processRelease(const Pkt6Ptr& release);
Pkt6Ptr processRelease(AllocEngine::ClientContext6& ctx);
/// @brief Process incoming Decline message.
///
......@@ -288,17 +308,17 @@ protected:
/// the client's message. Finally, it calls @ref declineLeases, where
/// the actual address processing takes place.
///
/// @throw RFCViolation if Decline message is invalid (lacking mandatory
/// options)
/// @param ctx Reference to client context
///
/// @param decline message received from client
Pkt6Ptr processDecline(const Pkt6Ptr& decline);
/// @return Reply message to be sent to the client.
Pkt6Ptr processDecline(AllocEngine::ClientContext6& ctx);
/// @brief Processes incoming Information-request message.
///
/// @param inf_request message received from client
/// @param ctx Reference to client context
///
/// @return Reply message to be sent to the client.
Pkt6Ptr processInfRequest(const Pkt6Ptr& inf_request);
Pkt6Ptr processInfRequest(AllocEngine::ClientContext6& ctx);
/// @brief Processes incoming DHCPv4-query message.
///
......@@ -308,6 +328,7 @@ protected:
/// to the client once we get back DHCP4-REPLY from the DHCPv4 server.
///
/// @param dhcp4_query message received from client
/// Does not throw
void processDhcp4Query(const Pkt6Ptr& dhcp4_query);
/// @brief Selects a subnet for a given client's packet.
......@@ -425,10 +446,12 @@ protected:
/// @param query client's message
/// @param general_status a global status (it may be updated in case of errors)
/// @param ia IA_NA option that is being released
/// @param old_lease a pointer to the lease being released
/// @return IA_NA option (server's response)
OptionPtr releaseIA_NA(const DuidPtr& duid, const Pkt6Ptr& query,
int& general_status,
boost::shared_ptr<Option6IA> ia);
boost::shared_ptr<Option6IA> ia,
Lease6Ptr& old_lease);
/// @brief Releases specific IA_PD option
///
......@@ -441,10 +464,12 @@ protected:
/// @param query client's message
/// @param general_status a global status (it may be updated in case of errors)
/// @param ia IA_PD option that is being released
/// @param old_lease a pointer to the lease being released
/// @return IA_PD option (server's response)
OptionPtr releaseIA_PD(const DuidPtr& duid, const Pkt6Ptr& query,
int& general_status,
boost::shared_ptr<Option6IA> ia);
boost::shared_ptr<Option6IA> ia,
Lease6Ptr& old_lease);
/// @brief Copies required options from client message to server answer.
///
......@@ -739,10 +764,11 @@ protected:
/// @param duid client's duid (used to verify if the client owns the lease)
/// @param general_status [out] status in top-level message (may be updated)
/// @param ia specific IA_NA option to process.
/// @param new_leases a collection of leases being declined.
/// @return IA_NA option with response (to be included in Reply message)
OptionPtr
declineIA(const Pkt6Ptr& decline, const DuidPtr& duid, int& general_status,
boost::shared_ptr<Option6IA> ia);
boost::shared_ptr<Option6IA> ia, Lease6Collection& new_leases);
/// @brief Declines specific IPv6 lease.
///
......@@ -881,6 +907,13 @@ public:
/// @return the index of the buffer6_send hook
static int getHookIndexBuffer6Send();
/// @brief Executes buffer6_send callout and sends the response.
///
/// @param callout_handle pointer to the callout handle.
/// @param rsp pointer to a response.
void processPacketBufferSend(hooks::CalloutHandlePtr& callout_handle,
Pkt6Ptr& rsp);
protected:
/// Server DUID (to be sent in server-identifier option)
......@@ -890,6 +923,14 @@ protected:
/// initiate server shutdown procedure.
volatile bool shutdown_;
/// @brief Executes pkt6_send callout.
///
/// @param callout_handle pointer to the callout handle.
/// @param query Pointer to a query.
/// @param rsp Pointer to a response.
void processPacketPktSend(hooks::CalloutHandlePtr& callout_handle,
Pkt6Ptr& query, Pkt6Ptr& rsp);
/// @brief Allocation Engine.
/// Pointer to the allocation engine that we are currently using
/// It must be a pointer, because we will support changing engines
......@@ -902,7 +943,7 @@ protected:
/// @brief Holds information about disabled DHCP service and/or
/// disabled subnet/network scopes.
NetworkState network_state_;
NetworkStatePtr network_state_;
};
......
......@@ -13,6 +13,7 @@
#include <dhcpsrv/cfgmgr.h>
#include <dhcp6/dhcp6to4_ipc.h>
#include <dhcp6/dhcp6_log.h>
#include <dhcp6/ctrl_dhcp6_srv.h>
#include <dhcp6/dhcp6_srv.h>
#include <exceptions/exceptions.h>
#include <hooks/callout_handle.h>
......@@ -99,8 +100,7 @@ void Dhcp6to4Ipc::handler() {
}
// Can't call the pkt6_send callout because we don't have the query
// Copied from Dhcpv6Srv::run_one() sending part
// From Dhcpv6Srv::processPacketBufferSend
try {
// Let's execute all callouts registered for buffer6_send
......@@ -125,7 +125,8 @@ void Dhcp6to4Ipc::handler() {
// stage means drop.
if ((callout_handle->getStatus() == CalloutHandle::NEXT_STEP_SKIP) ||
(callout_handle->getStatus() == CalloutHandle::NEXT_STEP_DROP)) {
LOG_DEBUG(hooks_logger, DBG_DHCP6_HOOKS, DHCP6_HOOK_BUFFER_SEND_SKIP)
LOG_DEBUG(hooks_logger, DBG_DHCP6_HOOKS,
DHCP6_HOOK_BUFFER_SEND_SKIP)
.arg(pkt->getLabel());
return;
}
......@@ -136,7 +137,6 @@ void Dhcp6to4Ipc::handler() {
LOG_DEBUG(packet6_logger, DBG_DHCP6_DETAIL_DATA, DHCP6_RESPONSE_DATA)
.arg(static_cast<int>(pkt->getType())).arg(pkt->toText());
// Forward packet to the client.
IfaceMgr::instance().send(pkt);
......
......@@ -57,7 +57,7 @@ if HAVE_GTEST
# to unexpected errors. For this reason, the --enable-static-link option is
# ignored for unit tests built here.
noinst_LTLIBRARIES = libco1.la libco2.la
noinst_LTLIBRARIES = libco1.la libco2.la libco3.la
# -rpath /nowhere is a hack to trigger libtool to not create a
# convenience archive, resulting in shared modules
......@@ -72,6 +72,11 @@ libco2_la_CXXFLAGS = $(AM_CXXFLAGS)
libco2_la_CPPFLAGS = $(AM_CPPFLAGS)
libco2_la_LDFLAGS = -avoid-version -export-dynamic -module -rpath /nowhere
libco3_la_SOURCES = callout_library_3.cc callout_library_common.h
libco3_la_CXXFLAGS = $(AM_CXXFLAGS)
libco3_la_CPPFLAGS = $(AM_CPPFLAGS)
libco3_la_LDFLAGS = -avoid-version -export-dynamic -module -rpath /nowhere
TESTS += dhcp6_unittests
dhcp6_unittests_SOURCES = dhcp6_unittests.cc
dhcp6_unittests_SOURCES += dhcp6_srv_unittest.cc
......
// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2013-2018 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
......@@ -13,4 +13,4 @@
static const int LIBRARY_NUMBER = 1;
#include <config.h>
#include "callout_library_common.h"
#include <dhcp6/tests/callout_library_common.h>
// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2013-2018 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
......@@ -13,4 +13,4 @@
static const int LIBRARY_NUMBER = 2;
#include <config.h>
#include "callout_library_common.h"
#include <dhcp6/tests/callout_library_common.h>
// Copyright (C) 2018 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
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
/// @file
/// @brief Callout library for tesing execution of the dhcp6_srv_configured
/// hook point.
///
static const int LIBRARY_NUMBER = 3;
#include <dhcp6/tests/callout_library_common.h>
#include <string>
#include <vector>
using namespace isc::hooks;
extern "C" {
/// @brief Callout which appends library number and provided arguments to
/// the marker file for dhcp6_srv_configured callout.
///
/// @param handle callout handle passed to the callout.
///
/// @return 0 on success, 1 otherwise.
int
dhcp6_srv_configured(CalloutHandle& handle) {
// Append library number.
if (appendDigit(SRV_CONFIG_MARKER_FILE)) {
return (1);
}
// Append argument names.
std::vector<std::string> args = handle.getArgumentNames();
for (auto arg = args.begin(); arg != args.end(); ++arg) {
if (appendArgument(SRV_CONFIG_MARKER_FILE, arg->c_str()) != 0) {
return (1);
}
}
return (0);
}
}
// Copyright (C) 2013-2015 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2013-2018 Internet Systems Consortium, Inc. ("ISC")