blob: 1c1887206ffa928264acbc1cf63aa3b36717b3b9 [file] [log] [blame]
Sage Weil5cd068c2010-07-07 08:38:17 -07001#ifndef CEPH_MSGR_H
2#define CEPH_MSGR_H
Sage Weil0dee3c22009-10-06 11:31:06 -07003
4/*
5 * Data types for message passing layer used by Ceph.
6 */
7
8#define CEPH_MON_PORT 6789 /* default monitor port */
9
10/*
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.
14 */
15#define CEPH_PORT_FIRST 6789
16#define CEPH_PORT_START 6800 /* non-monitors start here */
17#define CEPH_PORT_LAST 6900
18
19/*
20 * tcp connection banner. include a protocol version. and adjust
21 * whenever the wire protocol changes. try to keep this string length
22 * constant.
23 */
Sage Weilac8839d2010-01-27 14:28:10 -080024#define CEPH_BANNER "ceph v027"
Sage Weil0dee3c22009-10-06 11:31:06 -070025#define CEPH_BANNER_MAX_LEN 30
26
27
28/*
29 * Rollover-safe type and comparator for 32-bit sequence numbers.
30 * Comparator returns -1, 0, or 1.
31 */
32typedef __u32 ceph_seq_t;
33
34static inline __s32 ceph_seq_cmp(__u32 a, __u32 b)
35{
36 return (__s32)a - (__s32)b;
37}
38
39
40/*
41 * entity_name -- logical name for a process participating in the
42 * network, e.g. 'mds0' or 'osd3'.
43 */
44struct ceph_entity_name {
45 __u8 type; /* CEPH_ENTITY_TYPE_* */
46 __le64 num;
47} __attribute__ ((packed));
48
Sage Weil4e7a5dc2009-11-18 16:19:57 -080049#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
Sage Weil4e7a5dc2009-11-18 16:19:57 -080053#define CEPH_ENTITY_TYPE_AUTH 0x20
54
55#define CEPH_ENTITY_TYPE_ANY 0xFF
56
57extern const char *ceph_entity_type_name(int type);
Sage Weil0dee3c22009-10-06 11:31:06 -070058
59/*
60 * entity_addr -- network address
61 */
62struct ceph_entity_addr {
Sage Weilac8839d2010-01-27 14:28:10 -080063 __le32 type;
64 __le32 nonce; /* unique id for process (e.g. pid) */
Sage Weil0dee3c22009-10-06 11:31:06 -070065 struct sockaddr_storage in_addr;
66} __attribute__ ((packed));
67
Sage Weil0dee3c22009-10-06 11:31:06 -070068struct ceph_entity_inst {
69 struct ceph_entity_name name;
70 struct ceph_entity_addr addr;
71} __attribute__ ((packed));
72
73
74/* used by message exchange protocol */
75#define CEPH_MSGR_TAG_READY 1 /* server->client: ready for messages */
76#define CEPH_MSGR_TAG_RESETSESSION 2 /* server->client: reset, try again */
77#define CEPH_MSGR_TAG_WAIT 3 /* server->client: wait for racing
78 incoming connection */
79#define CEPH_MSGR_TAG_RETRY_SESSION 4 /* server->client + cseq: try again
80 with higher cseq */
81#define CEPH_MSGR_TAG_RETRY_GLOBAL 5 /* server->client + gseq: try again
82 with higher gseq */
83#define CEPH_MSGR_TAG_CLOSE 6 /* closing pipe */
84#define CEPH_MSGR_TAG_MSG 7 /* message */
85#define CEPH_MSGR_TAG_ACK 8 /* message ack */
86#define CEPH_MSGR_TAG_KEEPALIVE 9 /* just a keepalive byte! */
87#define CEPH_MSGR_TAG_BADPROTOVER 10 /* bad protocol version */
Sage Weil4e7a5dc2009-11-18 16:19:57 -080088#define CEPH_MSGR_TAG_BADAUTHORIZER 11 /* bad authorizer */
Sage Weil04a419f2009-12-23 09:30:21 -080089#define CEPH_MSGR_TAG_FEATURES 12 /* insufficient features */
Sage Weil3a230832013-03-25 08:47:40 -070090#define CEPH_MSGR_TAG_SEQ 13 /* 64-bit int follows with seen seq number */
Sage Weil0dee3c22009-10-06 11:31:06 -070091
92
93/*
94 * connection negotiation
95 */
96struct ceph_msg_connect {
Sage Weil04a419f2009-12-23 09:30:21 -080097 __le64 features; /* supported feature bits */
Sage Weil0dee3c22009-10-06 11:31:06 -070098 __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;
Sage Weil4e7a5dc2009-11-18 16:19:57 -0800102 __le32 authorizer_protocol;
103 __le32 authorizer_len;
Sage Weil0dee3c22009-10-06 11:31:06 -0700104 __u8 flags; /* CEPH_MSG_CONNECT_* */
105} __attribute__ ((packed));
106
107struct ceph_msg_connect_reply {
108 __u8 tag;
Sage Weil04a419f2009-12-23 09:30:21 -0800109 __le64 features; /* feature bits for this session */
Sage Weil0dee3c22009-10-06 11:31:06 -0700110 __le32 global_seq;
111 __le32 connect_seq;
112 __le32 protocol_version;
Sage Weil4e7a5dc2009-11-18 16:19:57 -0800113 __le32 authorizer_len;
Sage Weil0dee3c22009-10-06 11:31:06 -0700114 __u8 flags;
115} __attribute__ ((packed));
116
117#define CEPH_MSG_CONNECT_LOSSY 1 /* messages i send may be safely dropped */
118
119
120/*
121 * message header
122 */
Sage Weildbad1852010-03-25 15:45:38 -0700123struct ceph_msg_header_old {
Sage Weil0dee3c22009-10-06 11:31:06 -0700124 __le64 seq; /* message seq# for this session */
Sage Weil6df058c2009-12-22 11:24:33 -0800125 __le64 tid; /* transaction id */
Sage Weil0dee3c22009-10-06 11:31:06 -0700126 __le16 type; /* message type */
127 __le16 priority; /* priority. higher value == higher priority */
Sage Weil535bbb52009-10-13 12:55:26 -0700128 __le16 version; /* version of message encoding */
Sage Weil0dee3c22009-10-06 11:31:06 -0700129
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 */
135
136 struct ceph_entity_inst src, orig_src;
Sage Weil103e2d32010-01-07 16:12:36 -0800137 __le32 reserved;
Sage Weil0dee3c22009-10-06 11:31:06 -0700138 __le32 crc; /* header crc32c */
139} __attribute__ ((packed));
140
Sage Weildbad1852010-03-25 15:45:38 -0700141struct ceph_msg_header {
142 __le64 seq; /* message seq# for this session */
143 __le64 tid; /* transaction id */
144 __le16 type; /* message type */
145 __le16 priority; /* priority. higher value == higher priority */
146 __le16 version; /* version of message encoding */
147
148 __le32 front_len; /* bytes in main payload */
149 __le32 middle_len;/* bytes in middle payload */
150 __le32 data_len; /* bytes of data payload */
151 __le16 data_off; /* sender: include full offset;
152 receiver: mask against ~PAGE_MASK */
153
154 struct ceph_entity_name src;
John Sprayd4e1a4e2014-10-16 12:05:34 +0100155 __le16 compat_version;
156 __le16 reserved;
Sage Weildbad1852010-03-25 15:45:38 -0700157 __le32 crc; /* header crc32c */
158} __attribute__ ((packed));
159
Sage Weil0dee3c22009-10-06 11:31:06 -0700160#define CEPH_MSG_PRIO_LOW 64
161#define CEPH_MSG_PRIO_DEFAULT 127
162#define CEPH_MSG_PRIO_HIGH 196
163#define CEPH_MSG_PRIO_HIGHEST 255
164
165/*
166 * follows data payload
167 */
Yan, Zheng33d07332014-11-04 16:33:37 +0800168struct ceph_msg_footer_old {
169 __le32 front_crc, middle_crc, data_crc;
170 __u8 flags;
171} __attribute__ ((packed));
172
Sage Weil0dee3c22009-10-06 11:31:06 -0700173struct ceph_msg_footer {
174 __le32 front_crc, middle_crc, data_crc;
Yan, Zheng33d07332014-11-04 16:33:37 +0800175 // sig holds the 64 bits of the digital signature for the message PLR
176 __le64 sig;
Sage Weil0dee3c22009-10-06 11:31:06 -0700177 __u8 flags;
178} __attribute__ ((packed));
179
180#define CEPH_MSG_FOOTER_COMPLETE (1<<0) /* msg wasn't aborted */
181#define CEPH_MSG_FOOTER_NOCRC (1<<1) /* no data crc */
Yan, Zheng33d07332014-11-04 16:33:37 +0800182#define CEPH_MSG_FOOTER_SIGNED (1<<2) /* msg was signed */
Sage Weil0dee3c22009-10-06 11:31:06 -0700183
184
185#endif