1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2013 CohortFS, LLC
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
15 #ifndef XIODISPATCHER_H_
16 #define XIODISPATCHER_H_
18 #include "msg/Dispatcher.h"
19 #include "msg/Messenger.h"
21 class XioDispatcher: public Dispatcher {
27 explicit XioDispatcher(Messenger *msgr);
28 virtual ~XioDispatcher();
30 uint64_t get_dcount() { return dcount; }
36 // how i receive messages
37 virtual bool ms_dispatch(Message *m);
40 * This function will be called whenever a new Connection is made to the
43 * @param con The new Connection which has been established. You are not
44 * granted a reference to it -- take one if you need one!
46 virtual void ms_handle_connect(Connection *con) { };
49 * Callback indicating we have accepted an incoming connection.
51 * @param con The (new or existing) Connection associated with the session
53 virtual void ms_handle_accept(Connection *con) { };
56 * this indicates that the ordered+reliable delivery semantics have
57 * been violated. Messages may have been lost due to a fault
58 * in the network connection.
59 * Only called on lossy Connections or those you've
60 * designated mark_down_on_empty().
62 * @param con The Connection which broke. You are not granted
65 virtual bool ms_handle_reset(Connection *con);
68 * This indicates that the ordered+reliable delivery semantics
69 * have been violated because the remote somehow reset.
70 * It implies that incoming messages were dropped, and
71 * probably some of our previous outgoing messages were too.
73 * @param con The Connection which broke. You are not granted
76 virtual void ms_handle_remote_reset(Connection *con);
78 virtual bool ms_handle_refused(Connection *con) { return false; }
81 * @defgroup test_xio_dispatcher_h_auth Authentication
85 * Retrieve the AuthAuthorizer for the given peer type. It might not
86 * provide one if it knows there is no AuthAuthorizer for that type.
88 * @param dest_type The peer type we want the authorizer for.
89 * @param a Double pointer to an AuthAuthorizer. The Dispatcher will fill
90 * in *a with the correct AuthAuthorizer, if it can. Make sure that you have
91 * set *a to NULL before calling in.
92 * @param force_new Force the Dispatcher to wait for a new set of keys before
93 * returning the authorizer.
95 * @return True if this function call properly filled in *a, false otherwise.
97 virtual bool ms_get_authorizer(int dest_type, AuthAuthorizer **a,
98 bool force_new) { return false; };
101 * Verify the authorizer for a new incoming Connection.
103 * @param con The new incoming Connection
104 * @param peer_type The type of the endpoint which initiated this Connection
105 * @param protocol The ID of the protocol in use (at time of writing, cephx
107 * @param authorizer The authorization string supplied by the remote
108 * @param authorizer_reply Output param: The string we should send back to
109 * the remote to authorize ourselves. Only filled in if isvalid
110 * @param isvalid Output param: True if authorizer is valid, false otherwise
112 * @return True if we were able to prove or disprove correctness of
113 * authorizer, false otherwise.
115 virtual bool ms_verify_authorizer(Connection *con, int peer_type,
116 int protocol, bufferlist& authorizer,
117 bufferlist& authorizer_reply,
118 bool& isvalid, CryptoKey& session_key) {
126 #endif /* XIODISPATCHER_H_ */