d2_controller.cc 2.41 KB
Newer Older
1
// Copyright (C) 2013  Internet Systems Consortium, Inc. ("ISC")
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//
// Permission to use, copy, modify, and/or distribute this software for any
// purpose with or without fee is hereby granted, provided that the above
// copyright notice and this permission notice appear in all copies.
//
// THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
// REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS.  IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
// INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
// LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
// OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
// PERFORMANCE OF THIS SOFTWARE.

#include <d2/d2_controller.h>
#include <d2/d2_process.h>
#include <d2/spec_config.h>

namespace isc {
namespace d2 {

22
23
/// @brief Defines the application name, this is passed into base class
/// and appears in log statements.
24
const char* D2Controller::d2_app_name_ = "DHCP-DDNS";
25
26
27
28
29

/// @brief Defines the executable name. This is passed into the base class
/// by convention this should match the BIND10 module name.
const char* D2Controller::d2_bin_name_ = "b10-dhcp-ddns";

30
DControllerBasePtr&
31
D2Controller::instance() {
32
    // If the instance hasn't been created yet, create it.  Note this method
33
    // must use the base class singleton instance methods.  The base class
34
    // must have access to the singleton in order to use it within BIND10
35
    // static function callbacks.
36
    if (!getController()) {
37
38
        DControllerBasePtr controller_ptr(new D2Controller());
        setController(controller_ptr);
39
40
41
42
43
44
45
46
    }

    return (getController());
}

DProcessBase* D2Controller::createProcess() {
    // Instantiate and return an instance of the D2 application process. Note
    // that the process is passed the controller's io_service.
47
    return (new D2Process(getAppName().c_str(), getIOService()));
48
49
50
}

D2Controller::D2Controller()
51
    : DControllerBase(d2_app_name_, d2_bin_name_) {
52
53
54
55
    // set the BIND10 spec file either from the environment or
    // use the production value.
    if (getenv("B10_FROM_BUILD")) {
        setSpecFileName(std::string(getenv("B10_FROM_BUILD")) +
56
            "/src/bin/d2/dhcp-ddns.spec");
57
58
59
60
61
62
63
64
65
66
    } else {
        setSpecFileName(D2_SPECFILE_LOCATION);
    }
}

D2Controller::~D2Controller() {
}

}; // end namespace isc::d2
}; // end namespace isc