]> git.proxmox.com Git - ceph.git/blame - ceph/src/include/msgr.h
update sources to 12.2.7
[ceph.git] / ceph / src / include / msgr.h
CommitLineData
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
10/*
11 * Data types for message passing layer used by Ceph.
12 */
13
14#define CEPH_MON_PORT 6789 /* default monitor port */
15
16/*
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.
20 */
21#define CEPH_PORT_FIRST 6789
22
23/*
24 * tcp connection banner. include a protocol version. and adjust
25 * whenever the wire protocol changes. try to keep this string length
26 * constant.
27 */
28#define CEPH_BANNER "ceph v027"
29
30/*
31 * Rollover-safe type and comparator for 32-bit sequence numbers.
32 * Comparator returns -1, 0, or 1.
33 */
34typedef __u32 ceph_seq_t;
35
36static inline __s32 ceph_seq_cmp(__u32 a, __u32 b)
37{
38 return (__s32)a - (__s32)b;
39}
40
41
42/*
43 * entity_name -- logical name for a process participating in the
44 * network, e.g. 'mds0' or 'osd3'.
45 */
46struct ceph_entity_name {
47 __u8 type; /* CEPH_ENTITY_TYPE_* */
48 __le64 num;
49} __attribute__ ((packed));
50
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
57
58#define CEPH_ENTITY_TYPE_ANY 0xFF
59
60extern const char *ceph_entity_type_name(int type);
61
62/*
63 * entity_addr -- network address
64 */
65struct ceph_entity_addr {
66 __le32 type;
67 __le32 nonce; /* unique id for process (e.g. pid) */
68 struct sockaddr_storage in_addr;
69} __attribute__ ((packed));
70
71struct ceph_entity_inst {
72 struct ceph_entity_name name;
73 struct ceph_entity_addr addr;
74} __attribute__ ((packed));
75
76
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
83 with higher cseq */
84#define CEPH_MSGR_TAG_RETRY_GLOBAL 5 /* server->client + gseq: try again
85 with higher gseq */
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 */
28e407b8 96#define CEPH_MSGR_TAG_CHALLENGE_AUTHORIZER 16 /* ceph v2 doing server challenge */
7c673cae
FG
97
98/*
99 * connection negotiation
100 */
101struct 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));
111
112struct ceph_msg_connect_reply {
113 __u8 tag;
114 __le64 features; /* feature bits for this session */
115 __le32 global_seq;
116 __le32 connect_seq;
117 __le32 protocol_version;
118 __le32 authorizer_len;
119 __u8 flags;
120} __attribute__ ((packed));
121
122#define CEPH_MSG_CONNECT_LOSSY 1 /* messages i send may be safely dropped */
123
124
125/*
126 * message header
127 */
128struct 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 */
134
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 */
140
141 struct ceph_entity_inst src, orig_src;
142 __le32 reserved;
143 __le32 crc; /* header crc32c */
144} __attribute__ ((packed));
145
146struct 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 */
152
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 */
158
159 struct ceph_entity_name src;
160
161 /* oldest code we think can decode this. unknown if zero. */
162 __le16 compat_version;
163 __le16 reserved;
164 __le32 crc; /* header crc32c */
165} __attribute__ ((packed));
166
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
171
172/*
173 * follows data payload
174 * ceph_msg_footer_old does not support digital signatures on messages PLR
175 */
176
177struct ceph_msg_footer_old {
178 __le32 front_crc, middle_crc, data_crc;
179 __u8 flags;
180} __attribute__ ((packed));
181
182struct 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
185 __le64 sig;
186 __u8 flags;
187} __attribute__ ((packed));
188
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 */
192
193
194#endif