Fix some bugs when testing opensds ansible
[stor4nfv.git] / src / ceph / src / messages / MAuthReply.h
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) 2004-2006 Sage Weil <sage@newdream.net>
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 CEPH_MAUTHREPLY_H
16 #define CEPH_MAUTHREPLY_H
17
18 #include "msg/Message.h"
19 #include "common/errno.h"
20
21 struct MAuthReply : public Message {
22   __u32 protocol;
23   errorcode32_t result;
24   uint64_t global_id;      // if zero, meaningless
25   string result_msg;
26   bufferlist result_bl;
27
28   MAuthReply() : Message(CEPH_MSG_AUTH_REPLY), protocol(0), result(0), global_id(0) {}
29   MAuthReply(__u32 p, bufferlist *bl = NULL, int r = 0, uint64_t gid=0, const char *msg = "") :
30     Message(CEPH_MSG_AUTH_REPLY),
31     protocol(p), result(r), global_id(gid),
32     result_msg(msg) {
33     if (bl)
34       result_bl = *bl;
35   }
36 private:
37   ~MAuthReply() override {}
38
39 public:
40   const char *get_type_name() const override { return "auth_reply"; }
41   void print(ostream& o) const override {
42     o << "auth_reply(proto " << protocol << " " << result << " " << cpp_strerror(result);
43     if (result_msg.length())
44       o << ": " << result_msg;
45     o << ")";
46   }
47
48   void decode_payload() override {
49     bufferlist::iterator p = payload.begin();
50     ::decode(protocol, p);
51     ::decode(result, p);
52     ::decode(global_id, p);
53     ::decode(result_bl, p);
54     ::decode(result_msg, p);
55   }
56   void encode_payload(uint64_t features) override {
57     ::encode(protocol, payload);
58     ::encode(result, payload);
59     ::encode(global_id, payload);
60     ::encode(result_bl, payload);
61     ::encode(result_msg, payload);
62   }
63 };
64
65 #endif