host_reservation_parser.h 3.66 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// Copyright (C) 2014 Internet Systems Consortium, Inc. ("ISC")
//
// 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.

#ifndef HOST_RESERVATION_PARSER_H
#define HOST_RESERVATION_PARSER_H

#include <cc/data.h>
#include <dhcpsrv/host.h>
20
#include <dhcpsrv/parsers/dhcp_config_parser.h>
21
22
23
24
25
26
27
28

namespace isc {
namespace dhcp {

/// @brief Parser for a single host reservation entry.
class HostReservationParser : public DhcpConfigParser {
public:

29
30
31
32
33
    /// @brief Constructor.
    ///
    /// @param subnet_id Identifier of the subnet that the host is
    /// connected to.
    HostReservationParser(const SubnetID& subnet_id);
34
35
36
37
38
39
40
41
42
43
44
45
46
47

    /// @brief Parses a single entry for host reservation.
    ///
    /// @param reservation_data Data element holding map with a host
    /// reservation configuration.
    ///
    /// @throw DhcpConfigError If the configuration is invalid.
    virtual void build(isc::data::ConstElementPtr reservation_data);

    /// @brief Commit, unused.
    virtual void commit() { }

protected:

48
49
50
51
52
53
54
55
56
57
58
59
60
61
    /// @brief Inserts @c host_ object to the staging configuration.
    ///
    /// This method should be called by derived classes to insert the fully
    /// parsed host reservation configuration to the @c CfgMgr.
    ///
    /// @param reservation_data Data element holding host reservation. It
    /// used by this method to append the line number to the error string.
    ///
    /// @throw DhcpConfigError When operation to add a configured host fails.
    void addHost(isc::data::ConstElementPtr reservation_data);

    /// @brief Identifier of the subnet that the host is connected to.
    SubnetID subnet_id_;

62
63
64
65
66
67
    /// @brief Holds a pointer to @c Host object representing a parsed
    /// host reservation configuration.
    HostPtr host_;

};

68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/// @brief Parser for a single host reservation for DHCPv4.
class HostReservationParser4 : public HostReservationParser {
public:

    /// @brief Constructor.
    ///
    /// @param subnet_id Identifier of the subnet that the host is
    /// connected to.
    HostReservationParser4(const SubnetID& subnet_id);

    /// @brief Parses a single host reservation for DHCPv4.
    ///
    /// @param reservation_data Data element holding map with a host
    /// reservation configuration.
    ///
    /// @throw DhcpConfigError If the configuration is invalid.
    virtual void build(isc::data::ConstElementPtr reservation_data);
};

/// @brief Parser for a single host reservation for DHCPv6.
class HostReservationParser6 : public HostReservationParser {
public:

    /// @brief Constructor.
    ///
    /// @param subnet_id Identifier of the subnet that the host is
    /// connected to.
    HostReservationParser6(const SubnetID& subnet_id);

    /// @brief Parses a single host reservation for DHCPv6.
    ///
    /// @param reservation_data Data element holding map with a host
    /// reservation configuration.
    ///
    /// @throw DhcpConfigError If the configuration is invalid.
    virtual void build(isc::data::ConstElementPtr reservation_data);
};


107
108
109
110
}
} // end of namespace isc

#endif // HOST_RESERVATION_PARSER_H