5 #include <sys/socket.h> // for struct sockaddr_storage
8 #include "include/int_types.h"
11 * Data types for message passing layer used by Ceph.
14 #define CEPH_MON_PORT 6789 /* default monitor port */
17 * client-side processes will try to bind to ports in this
18 * range, simply for the benefit of tools like nmap or wireshark
19 * that would like to identify the protocol.
21 #define CEPH_PORT_FIRST 6789
24 * tcp connection banner. include a protocol version. and adjust
25 * whenever the wire protocol changes. try to keep this string length
28 #define CEPH_BANNER "ceph v027"
31 * Rollover-safe type and comparator for 32-bit sequence numbers.
32 * Comparator returns -1, 0, or 1.
34 typedef __u32 ceph_seq_t
;
36 static inline __s32
ceph_seq_cmp(__u32 a
, __u32 b
)
38 return (__s32
)a
- (__s32
)b
;
43 * entity_name -- logical name for a process participating in the
44 * network, e.g. 'mds0' or 'osd3'.
46 struct ceph_entity_name
{
47 __u8 type
; /* CEPH_ENTITY_TYPE_* */
49 } __attribute__ ((packed
));
51 #define CEPH_ENTITY_TYPE_MON 0x01
52 #define CEPH_ENTITY_TYPE_MDS 0x02
53 #define CEPH_ENTITY_TYPE_OSD 0x04
54 #define CEPH_ENTITY_TYPE_CLIENT 0x08
55 #define CEPH_ENTITY_TYPE_MGR 0x10
56 #define CEPH_ENTITY_TYPE_AUTH 0x20
58 #define CEPH_ENTITY_TYPE_ANY 0xFF
60 extern const char *ceph_entity_type_name(int type
);
63 * entity_addr -- network address
65 struct ceph_entity_addr
{
67 __le32 nonce
; /* unique id for process (e.g. pid) */
68 struct sockaddr_storage in_addr
;
69 } __attribute__ ((packed
));
71 struct ceph_entity_inst
{
72 struct ceph_entity_name name
;
73 struct ceph_entity_addr addr
;
74 } __attribute__ ((packed
));
77 /* used by message exchange protocol */
78 #define CEPH_MSGR_TAG_READY 1 /* server->client: ready for messages */
79 #define CEPH_MSGR_TAG_RESETSESSION 2 /* server->client: reset, try again */
80 #define CEPH_MSGR_TAG_WAIT 3 /* server->client: wait for racing
81 incoming connection */
82 #define CEPH_MSGR_TAG_RETRY_SESSION 4 /* server->client + cseq: try again
84 #define CEPH_MSGR_TAG_RETRY_GLOBAL 5 /* server->client + gseq: try again
86 #define CEPH_MSGR_TAG_CLOSE 6 /* closing pipe */
87 #define CEPH_MSGR_TAG_MSG 7 /* message */
88 #define CEPH_MSGR_TAG_ACK 8 /* message ack */
89 #define CEPH_MSGR_TAG_KEEPALIVE 9 /* just a keepalive byte! */
90 #define CEPH_MSGR_TAG_BADPROTOVER 10 /* bad protocol version */
91 #define CEPH_MSGR_TAG_BADAUTHORIZER 11 /* bad authorizer */
92 #define CEPH_MSGR_TAG_FEATURES 12 /* insufficient features */
93 #define CEPH_MSGR_TAG_SEQ 13 /* 64-bit int follows with seen seq number */
94 #define CEPH_MSGR_TAG_KEEPALIVE2 14
95 #define CEPH_MSGR_TAG_KEEPALIVE2_ACK 15 /* keepalive reply */
96 #define CEPH_MSGR_TAG_CHALLENGE_AUTHORIZER 16 /* ceph v2 doing server challenge */
99 * connection negotiation
101 struct ceph_msg_connect
{
102 __le64 features
; /* supported feature bits */
103 __le32 host_type
; /* CEPH_ENTITY_TYPE_* */
104 __le32 global_seq
; /* count connections initiated by this host */
105 __le32 connect_seq
; /* count connections initiated in this session */
106 __le32 protocol_version
;
107 __le32 authorizer_protocol
;
108 __le32 authorizer_len
;
109 __u8 flags
; /* CEPH_MSG_CONNECT_* */
110 } __attribute__ ((packed
));
112 struct ceph_msg_connect_reply
{
114 __le64 features
; /* feature bits for this session */
117 __le32 protocol_version
;
118 __le32 authorizer_len
;
120 } __attribute__ ((packed
));
122 #define CEPH_MSG_CONNECT_LOSSY 1 /* messages i send may be safely dropped */
128 struct ceph_msg_header_old
{
129 __le64 seq
; /* message seq# for this session */
130 __le64 tid
; /* transaction id */
131 __le16 type
; /* message type */
132 __le16 priority
; /* priority. higher value == higher priority */
133 __le16 version
; /* version of message encoding */
135 __le32 front_len
; /* bytes in main payload */
136 __le32 middle_len
;/* bytes in middle payload */
137 __le32 data_len
; /* bytes of data payload */
138 __le16 data_off
; /* sender: include full offset;
139 receiver: mask against ~PAGE_MASK */
141 struct ceph_entity_inst src
, orig_src
;
143 __le32 crc
; /* header crc32c */
144 } __attribute__ ((packed
));
146 struct ceph_msg_header
{
147 __le64 seq
; /* message seq# for this session */
148 __le64 tid
; /* transaction id */
149 __le16 type
; /* message type */
150 __le16 priority
; /* priority. higher value == higher priority */
151 __le16 version
; /* version of message encoding */
153 __le32 front_len
; /* bytes in main payload */
154 __le32 middle_len
;/* bytes in middle payload */
155 __le32 data_len
; /* bytes of data payload */
156 __le16 data_off
; /* sender: include full offset;
157 receiver: mask against ~PAGE_MASK */
159 struct ceph_entity_name src
;
161 /* oldest code we think can decode this. unknown if zero. */
162 __le16 compat_version
;
164 __le32 crc
; /* header crc32c */
165 } __attribute__ ((packed
));
167 #define CEPH_MSG_PRIO_LOW 64
168 #define CEPH_MSG_PRIO_DEFAULT 127
169 #define CEPH_MSG_PRIO_HIGH 196
170 #define CEPH_MSG_PRIO_HIGHEST 255
173 * follows data payload
174 * ceph_msg_footer_old does not support digital signatures on messages PLR
177 struct ceph_msg_footer_old
{
178 __le32 front_crc
, middle_crc
, data_crc
;
180 } __attribute__ ((packed
));
182 struct ceph_msg_footer
{
183 __le32 front_crc
, middle_crc
, data_crc
;
184 // sig holds the 64 bits of the digital signature for the message PLR
187 } __attribute__ ((packed
));
189 #define CEPH_MSG_FOOTER_COMPLETE (1<<0) /* msg wasn't aborted */
190 #define CEPH_MSG_FOOTER_NOCRC (1<<1) /* no data crc */
191 #define CEPH_MSG_FOOTER_SIGNED (1<<2) /* msg was signed */