dnsname_check.h 2.69 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14
// Copyright (C) 2011  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.

15 16
#ifndef DNSNAME_CHECK_H
#define DNSNAME_CHECK_H 1
17 18 19 20 21 22 23 24 25

#include <dns/name.h>

#include <acl/check.h>

namespace isc {
namespace acl {
namespace dns {

26 27 28 29 30 31 32 33 34 35 36 37 38 39
/// ACL check for DNS names
///
/// This class is intended to perform a match between a domain name
/// specified in an ACL and a given name.  The primary usage of this class
/// is an ACL match for TSIG keys, where an ACL would contain a list of
/// acceptable key names and the \c match() method would compare the owner
/// name of a TSIG record against the specified names.
///
/// This class could be used for other kinds of names such as the query name
/// of normal DNS queries.
///
/// The class is templated on the type of a context structure passed to the
/// matches() method, and a template specialisation for that method must be
/// supplied for the class to be used.
40 41 42
template <typename Context>
class NameCheck : public Check<Context> {
public:
43 44 45 46 47 48
    /// The constructor
    ///
    /// \exception std::bad_alloc Resource allocation fails in copying the
    /// name
    ///
    /// \param name The domain name to be matched in \c matches().
49 50
    NameCheck(const isc::dns::Name& name) : name_(name) {}

51
    /// Destructor
52 53
    virtual ~NameCheck() {}

54
    /// The check method
55 56
    ///
    /// Matches the passed argument to the condition stored here.  Different
57
    /// specializations must be provided for different argument types, and the
58 59 60 61 62 63
    /// program will fail to compile if a required specialisation is not
    /// provided.
    ///
    /// \param context Information to be matched
    virtual bool matches(const Context& context) const;

64 65 66 67 68
    /// Returns the name specified on construction.
    ///
    /// This is mainly for testing purposes.
    ///
    /// \exception None
69 70
    const isc::dns::Name& getName() const { return (name_); }

71 72 73 74 75 76 77 78
private:
    const isc::dns::Name name_;
};

} // namespace dns
} // namespace acl
} // namespace isc

79
#endif // DNSNAME_CHECK_H
80 81 82 83

// Local Variables:
// mode: c++
// End: