Commit | Line | Data |
---|---|---|
5cd068c2 SW |
1 | #ifndef CEPH_MSGR_H |
2 | #define CEPH_MSGR_H | |
0dee3c28 SW |
3 | |
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 | */ | |
ac8839d7 | 24 | #define CEPH_BANNER "ceph v027" |
0dee3c28 SW |
25 | #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 | */ | |
32 | typedef __u32 ceph_seq_t; | |
33 | ||
34 | static 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 | */ | |
44 | struct ceph_entity_name { | |
45 | __u8 type; /* CEPH_ENTITY_TYPE_* */ | |
46 | __le64 num; | |
47 | } __attribute__ ((packed)); | |
48 | ||
4e7a5dcd SW |
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 | |
4e7a5dcd SW |
53 | #define CEPH_ENTITY_TYPE_AUTH 0x20 |
54 | ||
55 | #define CEPH_ENTITY_TYPE_ANY 0xFF | |
56 | ||
57 | extern const char *ceph_entity_type_name(int type); | |
0dee3c28 SW |
58 | |
59 | /* | |
60 | * entity_addr -- network address | |
61 | */ | |
62 | struct ceph_entity_addr { | |
ac8839d7 SW |
63 | __le32 type; |
64 | __le32 nonce; /* unique id for process (e.g. pid) */ | |
0dee3c28 SW |
65 | struct sockaddr_storage in_addr; |
66 | } __attribute__ ((packed)); | |
67 | ||
0dee3c28 SW |
68 | struct 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 */ | |
4e7a5dcd | 88 | #define CEPH_MSGR_TAG_BADAUTHORIZER 11 /* bad authorizer */ |
04a419f9 | 89 | #define CEPH_MSGR_TAG_FEATURES 12 /* insufficient features */ |
0dee3c28 SW |
90 | |
91 | ||
92 | /* | |
93 | * connection negotiation | |
94 | */ | |
95 | struct ceph_msg_connect { | |
04a419f9 | 96 | __le64 features; /* supported feature bits */ |
0dee3c28 SW |
97 | __le32 host_type; /* CEPH_ENTITY_TYPE_* */ |
98 | __le32 global_seq; /* count connections initiated by this host */ | |
99 | __le32 connect_seq; /* count connections initiated in this session */ | |
100 | __le32 protocol_version; | |
4e7a5dcd SW |
101 | __le32 authorizer_protocol; |
102 | __le32 authorizer_len; | |
0dee3c28 SW |
103 | __u8 flags; /* CEPH_MSG_CONNECT_* */ |
104 | } __attribute__ ((packed)); | |
105 | ||
106 | struct ceph_msg_connect_reply { | |
107 | __u8 tag; | |
04a419f9 | 108 | __le64 features; /* feature bits for this session */ |
0dee3c28 SW |
109 | __le32 global_seq; |
110 | __le32 connect_seq; | |
111 | __le32 protocol_version; | |
4e7a5dcd | 112 | __le32 authorizer_len; |
0dee3c28 SW |
113 | __u8 flags; |
114 | } __attribute__ ((packed)); | |
115 | ||
116 | #define CEPH_MSG_CONNECT_LOSSY 1 /* messages i send may be safely dropped */ | |
117 | ||
118 | ||
119 | /* | |
120 | * message header | |
121 | */ | |
dbad185d | 122 | struct ceph_msg_header_old { |
0dee3c28 | 123 | __le64 seq; /* message seq# for this session */ |
6df058c0 | 124 | __le64 tid; /* transaction id */ |
0dee3c28 SW |
125 | __le16 type; /* message type */ |
126 | __le16 priority; /* priority. higher value == higher priority */ | |
535bbb53 | 127 | __le16 version; /* version of message encoding */ |
0dee3c28 SW |
128 | |
129 | __le32 front_len; /* bytes in main payload */ | |
130 | __le32 middle_len;/* bytes in middle payload */ | |
131 | __le32 data_len; /* bytes of data payload */ | |
132 | __le16 data_off; /* sender: include full offset; | |
133 | receiver: mask against ~PAGE_MASK */ | |
134 | ||
135 | struct ceph_entity_inst src, orig_src; | |
103e2d3a | 136 | __le32 reserved; |
0dee3c28 SW |
137 | __le32 crc; /* header crc32c */ |
138 | } __attribute__ ((packed)); | |
139 | ||
dbad185d SW |
140 | struct ceph_msg_header { |
141 | __le64 seq; /* message seq# for this session */ | |
142 | __le64 tid; /* transaction id */ | |
143 | __le16 type; /* message type */ | |
144 | __le16 priority; /* priority. higher value == higher priority */ | |
145 | __le16 version; /* version of message encoding */ | |
146 | ||
147 | __le32 front_len; /* bytes in main payload */ | |
148 | __le32 middle_len;/* bytes in middle payload */ | |
149 | __le32 data_len; /* bytes of data payload */ | |
150 | __le16 data_off; /* sender: include full offset; | |
151 | receiver: mask against ~PAGE_MASK */ | |
152 | ||
153 | struct ceph_entity_name src; | |
154 | __le32 reserved; | |
155 | __le32 crc; /* header crc32c */ | |
156 | } __attribute__ ((packed)); | |
157 | ||
0dee3c28 SW |
158 | #define CEPH_MSG_PRIO_LOW 64 |
159 | #define CEPH_MSG_PRIO_DEFAULT 127 | |
160 | #define CEPH_MSG_PRIO_HIGH 196 | |
161 | #define CEPH_MSG_PRIO_HIGHEST 255 | |
162 | ||
163 | /* | |
164 | * follows data payload | |
165 | */ | |
166 | struct ceph_msg_footer { | |
167 | __le32 front_crc, middle_crc, data_crc; | |
168 | __u8 flags; | |
169 | } __attribute__ ((packed)); | |
170 | ||
171 | #define CEPH_MSG_FOOTER_COMPLETE (1<<0) /* msg wasn't aborted */ | |
172 | #define CEPH_MSG_FOOTER_NOCRC (1<<1) /* no data crc */ | |
173 | ||
174 | ||
175 | #endif |