]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- |
2 | // vim: ts=8 sw=2 smarttab | |
3 | /* | |
4 | * Ceph - scalable distributed file system | |
5 | * | |
6 | * Copyright (C) 2013 CohortFS, LLC | |
7 | * | |
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. | |
12 | * | |
13 | */ | |
14 | ||
15 | #ifndef XIODISPATCHER_H_ | |
16 | #define XIODISPATCHER_H_ | |
17 | ||
18 | #include "msg/Dispatcher.h" | |
19 | #include "msg/Messenger.h" | |
20 | ||
21 | class XioDispatcher: public Dispatcher { | |
22 | private: | |
23 | bool active; | |
24 | Messenger *messenger; | |
25 | uint64_t dcount; | |
26 | public: | |
27 | explicit XioDispatcher(Messenger *msgr); | |
28 | virtual ~XioDispatcher(); | |
29 | ||
30 | uint64_t get_dcount() { return dcount; } | |
31 | ||
32 | void set_active() { | |
33 | active = true; | |
34 | }; | |
35 | ||
36 | // how i receive messages | |
37 | virtual bool ms_dispatch(Message *m); | |
38 | ||
39 | /** | |
40 | * This function will be called whenever a new Connection is made to the | |
41 | * Messenger. | |
42 | * | |
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! | |
45 | */ | |
46 | virtual void ms_handle_connect(Connection *con) { }; | |
47 | ||
48 | /** | |
49 | * Callback indicating we have accepted an incoming connection. | |
50 | * | |
51 | * @param con The (new or existing) Connection associated with the session | |
52 | */ | |
53 | virtual void ms_handle_accept(Connection *con) { }; | |
54 | ||
55 | /* | |
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(). | |
61 | * | |
62 | * @param con The Connection which broke. You are not granted | |
63 | * a reference to it. | |
64 | */ | |
65 | virtual bool ms_handle_reset(Connection *con); | |
66 | ||
67 | /** | |
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. | |
72 | * | |
73 | * @param con The Connection which broke. You are not granted | |
74 | * a reference to it. | |
75 | */ | |
76 | virtual void ms_handle_remote_reset(Connection *con); | |
77 | ||
78 | virtual bool ms_handle_refused(Connection *con) { return false; } | |
79 | ||
80 | /** | |
81 | * @defgroup test_xio_dispatcher_h_auth Authentication | |
82 | * @{ | |
83 | */ | |
84 | /** | |
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. | |
87 | * | |
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. | |
94 | * | |
95 | * @return True if this function call properly filled in *a, false otherwise. | |
96 | */ | |
97 | virtual bool ms_get_authorizer(int dest_type, AuthAuthorizer **a, | |
98 | bool force_new) { return false; }; | |
99 | ||
100 | /** | |
101 | * Verify the authorizer for a new incoming Connection. | |
102 | * | |
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 | |
106 | * or none) | |
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 | |
111 | * | |
112 | * @return True if we were able to prove or disprove correctness of | |
113 | * authorizer, false otherwise. | |
114 | */ | |
115 | virtual bool ms_verify_authorizer(Connection *con, int peer_type, | |
116 | int protocol, bufferlist& authorizer, | |
117 | bufferlist& authorizer_reply, | |
28e407b8 AA |
118 | bool& isvalid, CryptoKey& session_key, |
119 | std::unique_ptr<AuthAuthorizerChallenge> *challenge) { | |
7c673cae FG |
120 | /* always succeed */ |
121 | isvalid = true; | |
122 | return true; | |
123 | }; | |
124 | ||
125 | }; | |
126 | ||
127 | #endif /* XIODISPATCHER_H_ */ |