]> git.proxmox.com Git - ceph.git/blob - ceph/src/messages/MAuth.h
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / messages / MAuth.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_MAUTH_H
16 #define CEPH_MAUTH_H
17
18 #include <string_view>
19
20 #include "include/encoding.h"
21
22 #include "msg/Message.h"
23 #include "msg/MessageRef.h"
24 #include "messages/PaxosServiceMessage.h"
25
26 class MAuth final : public PaxosServiceMessage {
27 public:
28 __u32 protocol;
29 ceph::buffer::list auth_payload;
30 epoch_t monmap_epoch;
31
32 /* if protocol == 0, then auth_payload is a set<__u32> listing protocols the client supports */
33
34 MAuth() : PaxosServiceMessage{CEPH_MSG_AUTH, 0}, protocol(0), monmap_epoch(0) { }
35 private:
36 ~MAuth() final {}
37
38 public:
39 std::string_view get_type_name() const override { return "auth"; }
40 void print(std::ostream& out) const override {
41 out << "auth(proto " << protocol << " " << auth_payload.length() << " bytes"
42 << " epoch " << monmap_epoch << ")";
43 }
44
45 void decode_payload() override {
46 using ceph::decode;
47 auto p = payload.cbegin();
48 paxos_decode(p);
49 decode(protocol, p);
50 decode(auth_payload, p);
51 if (!p.end())
52 decode(monmap_epoch, p);
53 else
54 monmap_epoch = 0;
55 }
56 void encode_payload(uint64_t features) override {
57 using ceph::encode;
58 paxos_encode();
59 encode(protocol, payload);
60 encode(auth_payload, payload);
61 encode(monmap_epoch, payload);
62 }
63 ceph::buffer::list& get_auth_payload() { return auth_payload; }
64 };
65
66 #endif