5 * Data types for message passing layer used by Ceph.
8 #define CEPH_MON_PORT 6789 /* default monitor port */
11 * client-side processes will try to bind to ports in this
12 * range, simply for the benefit of tools like nmap or wireshark
13 * that would like to identify the protocol.
15 #define CEPH_PORT_FIRST 6789
16 #define CEPH_PORT_START 6800 /* non-monitors start here */
17 #define CEPH_PORT_LAST 6900
20 * tcp connection banner. include a protocol version. and adjust
21 * whenever the wire protocol changes. try to keep this string length
24 #define CEPH_BANNER "ceph v027"
25 #define CEPH_BANNER_MAX_LEN 30
29 * Rollover-safe type and comparator for 32-bit sequence numbers.
30 * Comparator returns -1, 0, or 1.
32 typedef __u32 ceph_seq_t
;
34 static inline __s32
ceph_seq_cmp(__u32 a
, __u32 b
)
36 return (__s32
)a
- (__s32
)b
;
41 * entity_name -- logical name for a process participating in the
42 * network, e.g. 'mds0' or 'osd3'.
44 struct ceph_entity_name
{
45 __u8 type
; /* CEPH_ENTITY_TYPE_* */
47 } __attribute__ ((packed
));
49 #define CEPH_ENTITY_TYPE_MON 0x01
50 #define CEPH_ENTITY_TYPE_MDS 0x02
51 #define CEPH_ENTITY_TYPE_OSD 0x04
52 #define CEPH_ENTITY_TYPE_CLIENT 0x08
53 #define CEPH_ENTITY_TYPE_ADMIN 0x10
54 #define CEPH_ENTITY_TYPE_AUTH 0x20
56 #define CEPH_ENTITY_TYPE_ANY 0xFF
58 extern const char *ceph_entity_type_name(int type
);
61 * entity_addr -- network address
63 struct ceph_entity_addr
{
65 __le32 nonce
; /* unique id for process (e.g. pid) */
66 struct sockaddr_storage in_addr
;
67 } __attribute__ ((packed
));
69 struct ceph_entity_inst
{
70 struct ceph_entity_name name
;
71 struct ceph_entity_addr addr
;
72 } __attribute__ ((packed
));
75 /* used by message exchange protocol */
76 #define CEPH_MSGR_TAG_READY 1 /* server->client: ready for messages */
77 #define CEPH_MSGR_TAG_RESETSESSION 2 /* server->client: reset, try again */
78 #define CEPH_MSGR_TAG_WAIT 3 /* server->client: wait for racing
79 incoming connection */
80 #define CEPH_MSGR_TAG_RETRY_SESSION 4 /* server->client + cseq: try again
82 #define CEPH_MSGR_TAG_RETRY_GLOBAL 5 /* server->client + gseq: try again
84 #define CEPH_MSGR_TAG_CLOSE 6 /* closing pipe */
85 #define CEPH_MSGR_TAG_MSG 7 /* message */
86 #define CEPH_MSGR_TAG_ACK 8 /* message ack */
87 #define CEPH_MSGR_TAG_KEEPALIVE 9 /* just a keepalive byte! */
88 #define CEPH_MSGR_TAG_BADPROTOVER 10 /* bad protocol version */
89 #define CEPH_MSGR_TAG_BADAUTHORIZER 11 /* bad authorizer */
90 #define CEPH_MSGR_TAG_FEATURES 12 /* insufficient features */
94 * connection negotiation
96 struct ceph_msg_connect
{
97 __le64 features
; /* supported feature bits */
98 __le32 host_type
; /* CEPH_ENTITY_TYPE_* */
99 __le32 global_seq
; /* count connections initiated by this host */
100 __le32 connect_seq
; /* count connections initiated in this session */
101 __le32 protocol_version
;
102 __le32 authorizer_protocol
;
103 __le32 authorizer_len
;
104 __u8 flags
; /* CEPH_MSG_CONNECT_* */
105 } __attribute__ ((packed
));
107 struct ceph_msg_connect_reply
{
109 __le64 features
; /* feature bits for this session */
112 __le32 protocol_version
;
113 __le32 authorizer_len
;
115 } __attribute__ ((packed
));
117 #define CEPH_MSG_CONNECT_LOSSY 1 /* messages i send may be safely dropped */
123 struct ceph_msg_header
{
124 __le64 seq
; /* message seq# for this session */
125 __le64 tid
; /* transaction id */
126 __le16 type
; /* message type */
127 __le16 priority
; /* priority. higher value == higher priority */
128 __le16 version
; /* version of message encoding */
130 __le32 front_len
; /* bytes in main payload */
131 __le32 middle_len
;/* bytes in middle payload */
132 __le32 data_len
; /* bytes of data payload */
133 __le16 data_off
; /* sender: include full offset;
134 receiver: mask against ~PAGE_MASK */
136 struct ceph_entity_inst src
, orig_src
;
138 __le32 crc
; /* header crc32c */
139 } __attribute__ ((packed
));
141 #define CEPH_MSG_PRIO_LOW 64
142 #define CEPH_MSG_PRIO_DEFAULT 127
143 #define CEPH_MSG_PRIO_HIGH 196
144 #define CEPH_MSG_PRIO_HIGHEST 255
147 * follows data payload
149 struct ceph_msg_footer
{
150 __le32 front_crc
, middle_crc
, data_crc
;
152 } __attribute__ ((packed
));
154 #define CEPH_MSG_FOOTER_COMPLETE (1<<0) /* msg wasn't aborted */
155 #define CEPH_MSG_FOOTER_NOCRC (1<<1) /* no data crc */