auth_srv.h 4.72 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
// Copyright (C) 2009  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.

// $Id$

#ifndef __AUTH_SRV_H
#define __AUTH_SRV_H 1

JINMEI Tatuya's avatar
cleanup  
JINMEI Tatuya committed
20 21
#include <string>

22
#include <cc/data.h>
23
#include <config/ccsession.h>
24

25
#include <asiolink/asiolink.h>
26

27
namespace isc {
28 29
namespace xfr {
class AbstractXfroutClient;
30
}
31 32
}

33
class AuthSrvImpl;
34 35

class AuthSrv {
36 37 38
    ///
    /// \name Constructors, Assignment Operator and Destructor.
    ///
39 40
    /// Note: The copy constructor and the assignment operator are
    /// intentionally defined as private.
41 42 43 44
    //@{
private:
    AuthSrv(const AuthSrv& source);
    AuthSrv& operator=(const AuthSrv& source);
45
public:
46 47 48 49 50 51 52
    /// The constructor.
    ///
    /// \param use_cache Whether to enable hot spot cache for lookup results.
    /// \param xfrout_client Communication interface with a separate xfrout
    /// process.  It's normally a reference to an xfr::XfroutClient object,
    /// but can refer to a local mock object for testing (or other
    /// experimental) purposes.
53 54
    AuthSrv(const bool use_cache,
            isc::xfr::AbstractXfroutClient& xfrout_client);
55
    ~AuthSrv();
56
    //@}
57 58

    /// \brief Process an incoming DNS message, then signal 'server' to resume 
Evan Hunt's avatar
Evan Hunt committed
59 60 61 62 63 64 65 66 67 68
    ///
    /// A DNS query (or other message) has been received by a \c DNSServer
    /// object.  Find an answer, then post the \c DNSServer object on the
    /// I/O service queue and return.  When the server resumes, it can
    /// send the reply.
    ///
    /// \param io_message The I/O service queue
    /// \param message Pointer to the \c Message object
    /// \param buffer Pointer to an \c OutputBuffer for the resposne
    /// \param server Pointer to the \c DNSServer
69
    void processMessage(const asiolink::IOMessage& io_message,
70 71
                        isc::dns::MessagePtr message,
                        isc::dns::OutputBufferPtr buffer,
72
                        asiolink::DNSServer* server);
Evan Hunt's avatar
Evan Hunt committed
73 74 75 76

    /// \brief Set verbose flag
    ///
    /// \param on The new value of the verbose flag
77
    void setVerbose(bool on);
Evan Hunt's avatar
Evan Hunt committed
78 79

    /// \brief Get the current value of the verbose flag
80
    bool getVerbose() const;
81 82

    /// \brief Set and get the config session
83
    void setConfigSession(isc::config::ModuleCCSession* config_session);
84
    isc::config::ModuleCCSession* getConfigSession() const;
85

86 87 88 89
    /// \brief Handle commands from the config session
    isc::data::ConstElementPtr updateConfig(isc::data::ConstElementPtr config);

    /// \brief Assign an ASIO IO Service queue to this Recursor object
90
    void setIOService(asiolink::IOService& ios) { io_service_ = &ios; }
91 92

    /// \brief Return this object's ASIO IO Service queue
93 94
    asiolink::IOService& getIOService() const { return (*io_service_); }

95 96 97 98 99 100 101 102
    /// \brief Return pointer to the DNS Lookup callback function
    asiolink::DNSLookup* getDNSLookupProvider() const { return (dns_lookup_); }

    /// \brief Return pointer to the DNS Answer callback function
    asiolink::DNSAnswer* getDNSAnswerProvider() const { return (dns_answer_); }

    /// \brief Return pointer to the Checkin callback function
    asiolink::SimpleCallback* getCheckinProvider() const { return (checkin_); }
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117

    ///
    /// Note: this interface is tentative.  We'll revisit the ASIO and session
    /// frameworks, at which point the session will probably be passed on
    /// construction of the server.
    ///
    /// \param xfrin_session A Session object over which NOTIFY message
    /// information is exchanged with a XFRIN handler.
    /// The session must be established before setting in the server
    /// object.
    /// Ownership isn't transferred: the caller is responsible for keeping
    /// this object to be valid while the server object is working and for
    /// disconnecting the session and destroying the object when the server
    ///
    void setXfrinSession(isc::cc::AbstractSession* xfrin_session);
118
private:
119
    AuthSrvImpl* impl_;
120
    asiolink::IOService* io_service_;
121
    asiolink::SimpleCallback* checkin_;
122 123
    asiolink::DNSLookup* dns_lookup_;
    asiolink::DNSAnswer* dns_answer_;
124 125 126 127
};

#endif // __AUTH_SRV_H

JINMEI Tatuya's avatar
cleanup  
JINMEI Tatuya committed
128 129 130
// Local Variables: 
// mode: c++
// End: