]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | #ifndef CEPH_MSGR_H |
2 | #define CEPH_MSGR_H | |
3 | ||
4 | #ifndef __KERNEL__ | |
5 | #include <sys/socket.h> // for struct sockaddr_storage | |
6 | #endif | |
7 | ||
8 | #include "include/int_types.h" | |
9 | ||
eafe8130 TL |
10 | /* See comment in ceph_fs.h. */ |
11 | #ifndef __KERNEL__ | |
12 | #include "byteorder.h" | |
13 | #define __le16 ceph_le16 | |
14 | #define __le32 ceph_le32 | |
15 | #define __le64 ceph_le64 | |
16 | #endif | |
17 | ||
7c673cae FG |
18 | /* |
19 | * Data types for message passing layer used by Ceph. | |
20 | */ | |
21 | ||
11fdf7f2 TL |
22 | #define CEPH_MON_PORT_LEGACY 6789 /* legacy default monitor port */ |
23 | #define CEPH_MON_PORT_IANA 3300 /* IANA monitor port */ | |
7c673cae FG |
24 | |
25 | /* | |
26 | * client-side processes will try to bind to ports in this | |
27 | * range, simply for the benefit of tools like nmap or wireshark | |
28 | * that would like to identify the protocol. | |
29 | */ | |
30 | #define CEPH_PORT_FIRST 6789 | |
31 | ||
32 | /* | |
33 | * tcp connection banner. include a protocol version. and adjust | |
34 | * whenever the wire protocol changes. try to keep this string length | |
35 | * constant. | |
36 | */ | |
37 | #define CEPH_BANNER "ceph v027" | |
38 | ||
11fdf7f2 TL |
39 | |
40 | /* | |
41 | * messenger V2 connection banner prefix. | |
42 | * The full banner string should have the form: "ceph v2\n<le16>" | |
43 | * the 2 bytes are the length of the remaining banner. | |
44 | */ | |
45 | #define CEPH_BANNER_V2_PREFIX "ceph v2\n" | |
46 | ||
47 | /* | |
48 | * messenger V2 features | |
49 | */ | |
50 | #define CEPH_MSGR2_INCARNATION_1 (0ull) | |
51 | ||
52 | #define DEFINE_MSGR2_FEATURE(bit, incarnation, name) \ | |
53 | const static uint64_t CEPH_MSGR2_FEATURE_##name = (1ULL << bit); \ | |
54 | const static uint64_t CEPH_MSGR2_FEATUREMASK_##name = \ | |
55 | (1ULL << bit | CEPH_FEATURE_INCARNATION_##incarnation); | |
56 | ||
57 | #define HAVE_MSGR2_FEATURE(x, name) \ | |
58 | (((x) & (CEPH_MSGR2_FEATUREMASK_##name)) == (CEPH_MSGR2_FEATUREMASK_##name)) | |
59 | ||
60 | ||
61 | #define CEPH_MSGR2_SUPPORTED_FEATURES (0ull) | |
62 | ||
63 | #define CEPH_MSGR2_REQUIRED_FEATURES (CEPH_MSGR2_SUPPORTED_FEATURES) | |
64 | ||
65 | ||
7c673cae FG |
66 | /* |
67 | * Rollover-safe type and comparator for 32-bit sequence numbers. | |
68 | * Comparator returns -1, 0, or 1. | |
69 | */ | |
70 | typedef __u32 ceph_seq_t; | |
71 | ||
72 | static inline __s32 ceph_seq_cmp(__u32 a, __u32 b) | |
73 | { | |
74 | return (__s32)a - (__s32)b; | |
75 | } | |
76 | ||
77 | ||
78 | /* | |
79 | * entity_name -- logical name for a process participating in the | |
80 | * network, e.g. 'mds0' or 'osd3'. | |
81 | */ | |
82 | struct ceph_entity_name { | |
83 | __u8 type; /* CEPH_ENTITY_TYPE_* */ | |
84 | __le64 num; | |
85 | } __attribute__ ((packed)); | |
86 | ||
87 | #define CEPH_ENTITY_TYPE_MON 0x01 | |
88 | #define CEPH_ENTITY_TYPE_MDS 0x02 | |
89 | #define CEPH_ENTITY_TYPE_OSD 0x04 | |
90 | #define CEPH_ENTITY_TYPE_CLIENT 0x08 | |
91 | #define CEPH_ENTITY_TYPE_MGR 0x10 | |
92 | #define CEPH_ENTITY_TYPE_AUTH 0x20 | |
93 | ||
94 | #define CEPH_ENTITY_TYPE_ANY 0xFF | |
95 | ||
96 | extern const char *ceph_entity_type_name(int type); | |
97 | ||
98 | /* | |
99 | * entity_addr -- network address | |
100 | */ | |
101 | struct ceph_entity_addr { | |
102 | __le32 type; | |
103 | __le32 nonce; /* unique id for process (e.g. pid) */ | |
104 | struct sockaddr_storage in_addr; | |
105 | } __attribute__ ((packed)); | |
106 | ||
107 | struct ceph_entity_inst { | |
108 | struct ceph_entity_name name; | |
109 | struct ceph_entity_addr addr; | |
110 | } __attribute__ ((packed)); | |
111 | ||
112 | ||
113 | /* used by message exchange protocol */ | |
114 | #define CEPH_MSGR_TAG_READY 1 /* server->client: ready for messages */ | |
115 | #define CEPH_MSGR_TAG_RESETSESSION 2 /* server->client: reset, try again */ | |
116 | #define CEPH_MSGR_TAG_WAIT 3 /* server->client: wait for racing | |
117 | incoming connection */ | |
118 | #define CEPH_MSGR_TAG_RETRY_SESSION 4 /* server->client + cseq: try again | |
119 | with higher cseq */ | |
120 | #define CEPH_MSGR_TAG_RETRY_GLOBAL 5 /* server->client + gseq: try again | |
121 | with higher gseq */ | |
122 | #define CEPH_MSGR_TAG_CLOSE 6 /* closing pipe */ | |
123 | #define CEPH_MSGR_TAG_MSG 7 /* message */ | |
124 | #define CEPH_MSGR_TAG_ACK 8 /* message ack */ | |
125 | #define CEPH_MSGR_TAG_KEEPALIVE 9 /* just a keepalive byte! */ | |
126 | #define CEPH_MSGR_TAG_BADPROTOVER 10 /* bad protocol version */ | |
127 | #define CEPH_MSGR_TAG_BADAUTHORIZER 11 /* bad authorizer */ | |
128 | #define CEPH_MSGR_TAG_FEATURES 12 /* insufficient features */ | |
129 | #define CEPH_MSGR_TAG_SEQ 13 /* 64-bit int follows with seen seq number */ | |
130 | #define CEPH_MSGR_TAG_KEEPALIVE2 14 | |
131 | #define CEPH_MSGR_TAG_KEEPALIVE2_ACK 15 /* keepalive reply */ | |
28e407b8 | 132 | #define CEPH_MSGR_TAG_CHALLENGE_AUTHORIZER 16 /* ceph v2 doing server challenge */ |
7c673cae FG |
133 | |
134 | /* | |
135 | * connection negotiation | |
136 | */ | |
137 | struct ceph_msg_connect { | |
138 | __le64 features; /* supported feature bits */ | |
139 | __le32 host_type; /* CEPH_ENTITY_TYPE_* */ | |
140 | __le32 global_seq; /* count connections initiated by this host */ | |
141 | __le32 connect_seq; /* count connections initiated in this session */ | |
142 | __le32 protocol_version; | |
143 | __le32 authorizer_protocol; | |
144 | __le32 authorizer_len; | |
145 | __u8 flags; /* CEPH_MSG_CONNECT_* */ | |
146 | } __attribute__ ((packed)); | |
147 | ||
148 | struct ceph_msg_connect_reply { | |
149 | __u8 tag; | |
150 | __le64 features; /* feature bits for this session */ | |
151 | __le32 global_seq; | |
152 | __le32 connect_seq; | |
153 | __le32 protocol_version; | |
154 | __le32 authorizer_len; | |
155 | __u8 flags; | |
156 | } __attribute__ ((packed)); | |
157 | ||
158 | #define CEPH_MSG_CONNECT_LOSSY 1 /* messages i send may be safely dropped */ | |
159 | ||
160 | ||
161 | /* | |
162 | * message header | |
163 | */ | |
164 | struct ceph_msg_header_old { | |
165 | __le64 seq; /* message seq# for this session */ | |
166 | __le64 tid; /* transaction id */ | |
167 | __le16 type; /* message type */ | |
168 | __le16 priority; /* priority. higher value == higher priority */ | |
169 | __le16 version; /* version of message encoding */ | |
170 | ||
171 | __le32 front_len; /* bytes in main payload */ | |
172 | __le32 middle_len;/* bytes in middle payload */ | |
173 | __le32 data_len; /* bytes of data payload */ | |
174 | __le16 data_off; /* sender: include full offset; | |
175 | receiver: mask against ~PAGE_MASK */ | |
176 | ||
177 | struct ceph_entity_inst src, orig_src; | |
178 | __le32 reserved; | |
179 | __le32 crc; /* header crc32c */ | |
180 | } __attribute__ ((packed)); | |
181 | ||
182 | struct ceph_msg_header { | |
183 | __le64 seq; /* message seq# for this session */ | |
184 | __le64 tid; /* transaction id */ | |
185 | __le16 type; /* message type */ | |
186 | __le16 priority; /* priority. higher value == higher priority */ | |
187 | __le16 version; /* version of message encoding */ | |
188 | ||
189 | __le32 front_len; /* bytes in main payload */ | |
190 | __le32 middle_len;/* bytes in middle payload */ | |
191 | __le32 data_len; /* bytes of data payload */ | |
192 | __le16 data_off; /* sender: include full offset; | |
193 | receiver: mask against ~PAGE_MASK */ | |
194 | ||
195 | struct ceph_entity_name src; | |
196 | ||
197 | /* oldest code we think can decode this. unknown if zero. */ | |
198 | __le16 compat_version; | |
199 | __le16 reserved; | |
200 | __le32 crc; /* header crc32c */ | |
201 | } __attribute__ ((packed)); | |
202 | ||
11fdf7f2 TL |
203 | struct ceph_msg_header2 { |
204 | __le64 seq; /* message seq# for this session */ | |
205 | __le64 tid; /* transaction id */ | |
206 | __le16 type; /* message type */ | |
207 | __le16 priority; /* priority. higher value == higher priority */ | |
208 | __le16 version; /* version of message encoding */ | |
209 | ||
210 | __le32 data_pre_padding_len; | |
211 | __le16 data_off; /* sender: include full offset; | |
212 | receiver: mask against ~PAGE_MASK */ | |
213 | ||
214 | __le64 ack_seq; | |
215 | __u8 flags; | |
216 | /* oldest code we think can decode this. unknown if zero. */ | |
217 | __le16 compat_version; | |
218 | __le16 reserved; | |
219 | } __attribute__ ((packed)); | |
220 | ||
7c673cae FG |
221 | #define CEPH_MSG_PRIO_LOW 64 |
222 | #define CEPH_MSG_PRIO_DEFAULT 127 | |
223 | #define CEPH_MSG_PRIO_HIGH 196 | |
224 | #define CEPH_MSG_PRIO_HIGHEST 255 | |
225 | ||
226 | /* | |
227 | * follows data payload | |
228 | * ceph_msg_footer_old does not support digital signatures on messages PLR | |
229 | */ | |
230 | ||
231 | struct ceph_msg_footer_old { | |
232 | __le32 front_crc, middle_crc, data_crc; | |
233 | __u8 flags; | |
234 | } __attribute__ ((packed)); | |
235 | ||
236 | struct ceph_msg_footer { | |
237 | __le32 front_crc, middle_crc, data_crc; | |
238 | // sig holds the 64 bits of the digital signature for the message PLR | |
239 | __le64 sig; | |
240 | __u8 flags; | |
241 | } __attribute__ ((packed)); | |
242 | ||
243 | #define CEPH_MSG_FOOTER_COMPLETE (1<<0) /* msg wasn't aborted */ | |
244 | #define CEPH_MSG_FOOTER_NOCRC (1<<1) /* no data crc */ | |
245 | #define CEPH_MSG_FOOTER_SIGNED (1<<2) /* msg was signed */ | |
246 | ||
eafe8130 TL |
247 | #ifndef __KERNEL__ |
248 | #undef __le16 | |
249 | #undef __le32 | |
250 | #undef __le64 | |
251 | #endif | |
7c673cae FG |
252 | |
253 | #endif |