1
2#ifndef CEPH_MSGR_H
3#define CEPH_MSGR_H
4
5
6
7
8
9#define CEPH_MON_PORT 6789
10
11
12
13
14
15
16#define CEPH_BANNER "ceph v027"
17#define CEPH_BANNER_LEN 9
18#define CEPH_BANNER_MAX_LEN 30
19
20
21
22
23
24
25
26#define CEPH_BANNER_V2 "ceph v2\n"
27#define CEPH_BANNER_V2_LEN 8
28#define CEPH_BANNER_V2_PREFIX_LEN (CEPH_BANNER_V2_LEN + sizeof(__le16))
29
30
31
32
33#define CEPH_MSGR2_INCARNATION_1 (0ull)
34
35#define DEFINE_MSGR2_FEATURE(bit, incarnation, name) \
36 static const uint64_t __maybe_unused CEPH_MSGR2_FEATURE_##name = (1ULL << bit); \
37 static const uint64_t __maybe_unused CEPH_MSGR2_FEATUREMASK_##name = \
38 (1ULL << bit | CEPH_MSGR2_INCARNATION_##incarnation);
39
40#define HAVE_MSGR2_FEATURE(x, name) \
41 (((x) & (CEPH_MSGR2_FEATUREMASK_##name)) == (CEPH_MSGR2_FEATUREMASK_##name))
42
43DEFINE_MSGR2_FEATURE( 0, 1, REVISION_1)
44
45#define CEPH_MSGR2_SUPPORTED_FEATURES (CEPH_MSGR2_FEATURE_REVISION_1)
46
47#define CEPH_MSGR2_REQUIRED_FEATURES (CEPH_MSGR2_FEATURE_REVISION_1)
48
49
50
51
52
53
54typedef __u32 ceph_seq_t;
55
56static inline __s32 ceph_seq_cmp(__u32 a, __u32 b)
57{
58 return (__s32)a - (__s32)b;
59}
60
61
62
63
64
65
66struct ceph_entity_name {
67 __u8 type;
68 __le64 num;
69} __attribute__ ((packed));
70
71#define CEPH_ENTITY_TYPE_MON 0x01
72#define CEPH_ENTITY_TYPE_MDS 0x02
73#define CEPH_ENTITY_TYPE_OSD 0x04
74#define CEPH_ENTITY_TYPE_CLIENT 0x08
75#define CEPH_ENTITY_TYPE_AUTH 0x20
76
77#define CEPH_ENTITY_TYPE_ANY 0xFF
78
79extern const char *ceph_entity_type_name(int type);
80
81
82
83
84struct ceph_entity_addr {
85 __le32 type;
86 __le32 nonce;
87 struct sockaddr_storage in_addr;
88} __attribute__ ((packed));
89
90static inline bool ceph_addr_equal_no_type(const struct ceph_entity_addr *lhs,
91 const struct ceph_entity_addr *rhs)
92{
93 return !memcmp(&lhs->in_addr, &rhs->in_addr, sizeof(lhs->in_addr)) &&
94 lhs->nonce == rhs->nonce;
95}
96
97struct ceph_entity_inst {
98 struct ceph_entity_name name;
99 struct ceph_entity_addr addr;
100} __attribute__ ((packed));
101
102
103
104#define CEPH_MSGR_TAG_READY 1
105#define CEPH_MSGR_TAG_RESETSESSION 2
106#define CEPH_MSGR_TAG_WAIT 3
107
108#define CEPH_MSGR_TAG_RETRY_SESSION 4
109
110#define CEPH_MSGR_TAG_RETRY_GLOBAL 5
111
112#define CEPH_MSGR_TAG_CLOSE 6
113#define CEPH_MSGR_TAG_MSG 7
114#define CEPH_MSGR_TAG_ACK 8
115#define CEPH_MSGR_TAG_KEEPALIVE 9
116#define CEPH_MSGR_TAG_BADPROTOVER 10
117#define CEPH_MSGR_TAG_BADAUTHORIZER 11
118#define CEPH_MSGR_TAG_FEATURES 12
119#define CEPH_MSGR_TAG_SEQ 13
120#define CEPH_MSGR_TAG_KEEPALIVE2 14
121#define CEPH_MSGR_TAG_KEEPALIVE2_ACK 15
122#define CEPH_MSGR_TAG_CHALLENGE_AUTHORIZER 16
123
124
125
126
127struct ceph_msg_connect {
128 __le64 features;
129 __le32 host_type;
130 __le32 global_seq;
131 __le32 connect_seq;
132 __le32 protocol_version;
133 __le32 authorizer_protocol;
134 __le32 authorizer_len;
135 __u8 flags;
136} __attribute__ ((packed));
137
138struct ceph_msg_connect_reply {
139 __u8 tag;
140 __le64 features;
141 __le32 global_seq;
142 __le32 connect_seq;
143 __le32 protocol_version;
144 __le32 authorizer_len;
145 __u8 flags;
146} __attribute__ ((packed));
147
148#define CEPH_MSG_CONNECT_LOSSY 1
149
150
151
152
153
154struct ceph_msg_header_old {
155 __le64 seq;
156 __le64 tid;
157 __le16 type;
158 __le16 priority;
159 __le16 version;
160
161 __le32 front_len;
162 __le32 middle_len;
163 __le32 data_len;
164 __le16 data_off;
165
166
167 struct ceph_entity_inst src, orig_src;
168 __le32 reserved;
169 __le32 crc;
170} __attribute__ ((packed));
171
172struct ceph_msg_header {
173 __le64 seq;
174 __le64 tid;
175 __le16 type;
176 __le16 priority;
177 __le16 version;
178
179 __le32 front_len;
180 __le32 middle_len;
181 __le32 data_len;
182 __le16 data_off;
183
184
185 struct ceph_entity_name src;
186 __le16 compat_version;
187 __le16 reserved;
188 __le32 crc;
189} __attribute__ ((packed));
190
191struct ceph_msg_header2 {
192 __le64 seq;
193 __le64 tid;
194 __le16 type;
195 __le16 priority;
196 __le16 version;
197
198 __le32 data_pre_padding_len;
199 __le16 data_off;
200
201
202 __le64 ack_seq;
203 __u8 flags;
204
205 __le16 compat_version;
206 __le16 reserved;
207} __attribute__ ((packed));
208
209#define CEPH_MSG_PRIO_LOW 64
210#define CEPH_MSG_PRIO_DEFAULT 127
211#define CEPH_MSG_PRIO_HIGH 196
212#define CEPH_MSG_PRIO_HIGHEST 255
213
214
215
216
217struct ceph_msg_footer_old {
218 __le32 front_crc, middle_crc, data_crc;
219 __u8 flags;
220} __attribute__ ((packed));
221
222struct ceph_msg_footer {
223 __le32 front_crc, middle_crc, data_crc;
224
225 __le64 sig;
226 __u8 flags;
227} __attribute__ ((packed));
228
229#define CEPH_MSG_FOOTER_COMPLETE (1<<0)
230#define CEPH_MSG_FOOTER_NOCRC (1<<1)
231#define CEPH_MSG_FOOTER_SIGNED (1<<2)
232
233
234#endif
235