network.h 3.47 KB
Newer Older
1 2 3 4 5 6 7 8 9
// Copyright (C) 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
// file, You can obtain one at http://mozilla.org/MPL/2.0/.

#ifndef NETWORK_H
#define NETWORK_H

10 11 12 13
#include <cc/cfg_to_element.h>
#include <cc/data.h>
#include <dhcpsrv/cfg_option.h>
#include <dhcpsrv/cfg_4o6.h>
14
#include <boost/shared_ptr.hpp>
15
#include <boost/weak_ptr.hpp>
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
#include <string>

namespace isc {
namespace dhcp {

/// @brief Common interface representing a network to which the DHCP clients
/// are connected.
///
/// The most common type of network, in Kea's terminology, is a subnet. The
/// @ref Subnet implements this interface. Another types of objects implementing
/// this interface are @ref SharedNetwork objects. They group multiple subnets
/// together to provide means for extending available address pools (a single
/// client may obtain IP address from any of the pools belonging to subnets in
/// the shared network), or for selecting a subnet on a given link, depending
/// on the class of the client (e.g. cable network case: different subnet is
/// selected for cable modems, different one for routers).
///
/// The subnets and shared networks share many data structures, e.g. DHCP
/// options, local interface name, address manipulation methods, thus this
/// class provides an abstract interface that must be implemented by derived
/// classes and, where appropriate, implements common methods used by the
/// derived classes.
38
class Network : public data::CfgToElement {
39 40
public:

41 42 43 44 45
    /// @brief Constructor.
    Network()
        : iface_name_(), cfg_option_(new CfgOption()) {
    }

46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70
    /// @brief Virtual destructor.
    ///
    /// Does nothing at the moment.
    virtual ~Network() { };

    /// @brief Sets local name of the interface for which this network is
    /// selected.
    ///
    /// If the interface is specified, the server will use the network
    /// associated with this local interface to allocate IP addresses and
    /// other resources to a client.
    ///
    /// @param iface_name Interface name.
    void setIface(const std::string& iface_name) {
        iface_name_ = iface_name;
    }

    /// @brief Returns name of the local interface for which this network is
    /// selected.
    ///
    /// @return Interface name as text.
    std::string getIface() const {
        return (iface_name_);
    };

71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
    /// @brief Returns pointer to the option data configuration for this subnet.
    CfgOptionPtr getCfgOption() {
        return (cfg_option_);
    }

    /// @brief Returns const pointer to the option data configuration for this
    /// subnet.
    ConstCfgOptionPtr getCfgOption() const {
        return (cfg_option_);
    }

    /// @brief Unparses network object.
    ///
    /// @return A pointer to unparsed network configuration.
    virtual data::ElementPtr toElement() const;

87 88 89 90 91
protected:

    /// @brief Holds interface name for which this network is selected.
    std::string iface_name_;

92 93
    /// @brief Pointer to the option data configuration for this subnet.
    CfgOptionPtr cfg_option_;
94 95 96 97 98
};

/// @brief Pointer to the @ref Network object.
typedef boost::shared_ptr<Network> NetworkPtr;

99 100 101
/// @brief Weak pointer to the @ref Network object.
typedef boost::weak_ptr<Network> WeakNetworkPtr;

102 103 104 105 106 107 108 109
class Network4 : public Network {
public:
};

class Network6 : public Network {
public:
};

110 111 112 113
} // end of namespace isc::dhcp
} // end of namespace isc

#endif // NETWORK_H