summaryrefslogtreecommitdiffstats
path: root/src/bin/dhcp6/tests/callout_library_3.cc
blob: 10bb0e6bc7ada440d55b5c869c531ca4beb8e037 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (C) 2018-2020 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 testing execution of the dhcp6_srv_configured
/// hook point.
///
static const int LIBRARY_NUMBER = 3;
#include <config.h>

#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);
}

}