5 #include <sys/socket.h> // for struct sockaddr_storage
8 #include "include/int_types.h"
10 /* See comment in ceph_fs.h. */
12 #include "byteorder.h"
13 #define __le16 ceph_le16
14 #define __le32 ceph_le32
15 #define __le64 ceph_le64
19 * Data types for message passing layer used by Ceph.
22 #define CEPH_MON_PORT_LEGACY 6789 /* legacy default monitor port */
23 #define CEPH_MON_PORT_IANA 3300 /* IANA monitor port */
26 * tcp connection banner. include a protocol version. and adjust
27 * whenever the wire protocol changes. try to keep this string length
30 #define CEPH_BANNER "ceph v027"
34 * messenger V2 connection banner prefix.
35 * The full banner string should have the form: "ceph v2\n<le16>"
36 * the 2 bytes are the length of the remaining banner.
38 #define CEPH_BANNER_V2_PREFIX "ceph v2\n"
41 * messenger V2 features
43 #define CEPH_MSGR2_INCARNATION_1 (0ull)
45 #define DEFINE_MSGR2_FEATURE(bit, incarnation, name) \
46 const static uint64_t CEPH_MSGR2_FEATURE_##name = (1ULL << bit); \
47 const static uint64_t CEPH_MSGR2_FEATUREMASK_##name = \
48 (1ULL << bit | CEPH_MSGR2_INCARNATION_##incarnation);
50 #define HAVE_MSGR2_FEATURE(x, name) \
51 (((x) & (CEPH_MSGR2_FEATUREMASK_##name)) == (CEPH_MSGR2_FEATUREMASK_##name))
53 DEFINE_MSGR2_FEATURE( 0, 1, REVISION_1
) // msgr2.1
55 #define CEPH_MSGR2_SUPPORTED_FEATURES (CEPH_MSGR2_FEATURE_REVISION_1)
57 #define CEPH_MSGR2_REQUIRED_FEATURES (0ull)
61 * Rollover-safe type and comparator for 32-bit sequence numbers.
62 * Comparator returns -1, 0, or 1.
64 typedef __u32 ceph_seq_t
;
66 static inline __s32
ceph_seq_cmp(__u32 a
, __u32 b
)
68 return (__s32
)a
- (__s32
)b
;
73 * entity_name -- logical name for a process participating in the
74 * network, e.g. 'mds0' or 'osd3'.
76 struct ceph_entity_name
{
77 __u8 type
; /* CEPH_ENTITY_TYPE_* */
79 } __attribute__ ((packed
));
81 #define CEPH_ENTITY_TYPE_MON 0x01
82 #define CEPH_ENTITY_TYPE_MDS 0x02
83 #define CEPH_ENTITY_TYPE_OSD 0x04
84 #define CEPH_ENTITY_TYPE_CLIENT 0x08
85 #define CEPH_ENTITY_TYPE_MGR 0x10
86 #define CEPH_ENTITY_TYPE_AUTH 0x20
88 #define CEPH_ENTITY_TYPE_ANY 0xFF
90 extern const char *ceph_entity_type_name(int type
);
93 * entity_addr -- network address
95 struct ceph_entity_addr
{
97 __le32 nonce
; /* unique id for process (e.g. pid) */
98 struct sockaddr_storage in_addr
;
99 } __attribute__ ((packed
));
101 struct ceph_entity_inst
{
102 struct ceph_entity_name name
;
103 struct ceph_entity_addr addr
;
104 } __attribute__ ((packed
));
107 /* used by message exchange protocol */
108 #define CEPH_MSGR_TAG_READY 1 /* server->client: ready for messages */
109 #define CEPH_MSGR_TAG_RESETSESSION 2 /* server->client: reset, try again */
110 #define CEPH_MSGR_TAG_WAIT 3 /* server->client: wait for racing
111 incoming connection */
112 #define CEPH_MSGR_TAG_RETRY_SESSION 4 /* server->client + cseq: try again
114 #define CEPH_MSGR_TAG_RETRY_GLOBAL 5 /* server->client + gseq: try again
116 #define CEPH_MSGR_TAG_CLOSE 6 /* closing pipe */
117 #define CEPH_MSGR_TAG_MSG 7 /* message */
118 #define CEPH_MSGR_TAG_ACK 8 /* message ack */
119 #define CEPH_MSGR_TAG_KEEPALIVE 9 /* just a keepalive byte! */
120 #define CEPH_MSGR_TAG_BADPROTOVER 10 /* bad protocol version */
121 #define CEPH_MSGR_TAG_BADAUTHORIZER 11 /* bad authorizer */
122 #define CEPH_MSGR_TAG_FEATURES 12 /* insufficient features */
123 #define CEPH_MSGR_TAG_SEQ 13 /* 64-bit int follows with seen seq number */
124 #define CEPH_MSGR_TAG_KEEPALIVE2 14
125 #define CEPH_MSGR_TAG_KEEPALIVE2_ACK 15 /* keepalive reply */
126 #define CEPH_MSGR_TAG_CHALLENGE_AUTHORIZER 16 /* ceph v2 doing server challenge */
129 * connection negotiation
131 struct ceph_msg_connect
{
132 __le64 features
; /* supported feature bits */
133 __le32 host_type
; /* CEPH_ENTITY_TYPE_* */
134 __le32 global_seq
; /* count connections initiated by this host */
135 __le32 connect_seq
; /* count connections initiated in this session */
136 __le32 protocol_version
;
137 __le32 authorizer_protocol
;
138 __le32 authorizer_len
;
139 __u8 flags
; /* CEPH_MSG_CONNECT_* */
140 } __attribute__ ((packed
));
142 struct ceph_msg_connect_reply
{
144 __le64 features
; /* feature bits for this session */
147 __le32 protocol_version
;
148 __le32 authorizer_len
;
150 } __attribute__ ((packed
));
152 #define CEPH_MSG_CONNECT_LOSSY 1 /* messages i send may be safely dropped */
158 struct ceph_msg_header_old
{
159 __le64 seq
; /* message seq# for this session */
160 __le64 tid
; /* transaction id */
161 __le16 type
; /* message type */
162 __le16 priority
; /* priority. higher value == higher priority */
163 __le16 version
; /* version of message encoding */
165 __le32 front_len
; /* bytes in main payload */
166 __le32 middle_len
;/* bytes in middle payload */
167 __le32 data_len
; /* bytes of data payload */
168 __le16 data_off
; /* sender: include full offset;
169 receiver: mask against ~PAGE_MASK */
171 struct ceph_entity_inst src
, orig_src
;
173 __le32 crc
; /* header crc32c */
174 } __attribute__ ((packed
));
176 struct ceph_msg_header
{
177 __le64 seq
; /* message seq# for this session */
178 __le64 tid
; /* transaction id */
179 __le16 type
; /* message type */
180 __le16 priority
; /* priority. higher value == higher priority */
181 __le16 version
; /* version of message encoding */
183 __le32 front_len
; /* bytes in main payload */
184 __le32 middle_len
;/* bytes in middle payload */
185 __le32 data_len
; /* bytes of data payload */
186 __le16 data_off
; /* sender: include full offset;
187 receiver: mask against ~PAGE_MASK */
189 struct ceph_entity_name src
;
191 /* oldest code we think can decode this. unknown if zero. */
192 __le16 compat_version
;
194 __le32 crc
; /* header crc32c */
195 } __attribute__ ((packed
));
197 struct ceph_msg_header2
{
198 __le64 seq
; /* message seq# for this session */
199 __le64 tid
; /* transaction id */
200 __le16 type
; /* message type */
201 __le16 priority
; /* priority. higher value == higher priority */
202 __le16 version
; /* version of message encoding */
204 __le32 data_pre_padding_len
;
205 __le16 data_off
; /* sender: include full offset;
206 receiver: mask against ~PAGE_MASK */
210 /* oldest code we think can decode this. unknown if zero. */
211 __le16 compat_version
;
213 } __attribute__ ((packed
));
215 #define CEPH_MSG_PRIO_LOW 64
216 #define CEPH_MSG_PRIO_DEFAULT 127
217 #define CEPH_MSG_PRIO_HIGH 196
218 #define CEPH_MSG_PRIO_HIGHEST 255
221 * follows data payload
222 * ceph_msg_footer_old does not support digital signatures on messages PLR
225 struct ceph_msg_footer_old
{
226 __le32 front_crc
, middle_crc
, data_crc
;
228 } __attribute__ ((packed
));
230 struct ceph_msg_footer
{
231 __le32 front_crc
, middle_crc
, data_crc
;
232 // sig holds the 64 bits of the digital signature for the message PLR
235 } __attribute__ ((packed
));
237 #define CEPH_MSG_FOOTER_COMPLETE (1<<0) /* msg wasn't aborted */
238 #define CEPH_MSG_FOOTER_NOCRC (1<<1) /* no data crc */
239 #define CEPH_MSG_FOOTER_SIGNED (1<<2) /* msg was signed */