]> git.proxmox.com Git - ceph.git/blame - ceph/src/messages/MMonMap.h
import 15.2.0 Octopus source
[ceph.git] / ceph / src / messages / MMonMap.h
CommitLineData
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) 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_MMONMAP_H
16#define CEPH_MMONMAP_H
17
9f95a23c 18#include "include/encoding.h"
7c673cae
FG
19#include "include/ceph_features.h"
20#include "msg/Message.h"
9f95a23c 21#include "msg/MessageRef.h"
7c673cae
FG
22#include "mon/MonMap.h"
23
9f95a23c 24class MMonMap : public Message {
7c673cae 25public:
9f95a23c 26 ceph::buffer::list monmapbl;
11fdf7f2 27
9f95a23c
TL
28 MMonMap() : Message{CEPH_MSG_MON_MAP} { }
29 explicit MMonMap(ceph::buffer::list &bl) : Message{CEPH_MSG_MON_MAP} {
7c673cae
FG
30 monmapbl.claim(bl);
31 }
32private:
33 ~MMonMap() override {}
34
35public:
11fdf7f2 36 std::string_view get_type_name() const override { return "mon_map"; }
7c673cae
FG
37
38 void encode_payload(uint64_t features) override {
39 if (monmapbl.length() &&
40 ((features & CEPH_FEATURE_MONENC) == 0 ||
41 (features & CEPH_FEATURE_MSG_ADDR2) == 0)) {
42 // reencode old-format monmap
43 MonMap t;
44 t.decode(monmapbl);
45 monmapbl.clear();
46 t.encode(monmapbl, features);
47 }
48
11fdf7f2
TL
49 using ceph::encode;
50 encode(monmapbl, payload);
7c673cae
FG
51 }
52 void decode_payload() override {
9f95a23c 53 using ceph::decode;
11fdf7f2
TL
54 auto p = payload.cbegin();
55 decode(monmapbl, p);
7c673cae 56 }
9f95a23c
TL
57private:
58 template<class T, typename... Args>
59 friend boost::intrusive_ptr<T> ceph::make_message(Args&&... args);
7c673cae
FG
60};
61
62#endif