0001
0002 #ifndef CEPH_MSGR_H
0003 #define CEPH_MSGR_H
0004
0005
0006
0007
0008
0009 #define CEPH_MON_PORT 6789
0010
0011
0012
0013
0014
0015
0016 #define CEPH_BANNER "ceph v027"
0017 #define CEPH_BANNER_LEN 9
0018 #define CEPH_BANNER_MAX_LEN 30
0019
0020
0021
0022
0023
0024
0025
0026 #define CEPH_BANNER_V2 "ceph v2\n"
0027 #define CEPH_BANNER_V2_LEN 8
0028 #define CEPH_BANNER_V2_PREFIX_LEN (CEPH_BANNER_V2_LEN + sizeof(__le16))
0029
0030
0031
0032
0033 #define CEPH_MSGR2_INCARNATION_1 (0ull)
0034
0035 #define DEFINE_MSGR2_FEATURE(bit, incarnation, name) \
0036 static const uint64_t __maybe_unused CEPH_MSGR2_FEATURE_##name = (1ULL << bit); \
0037 static const uint64_t __maybe_unused CEPH_MSGR2_FEATUREMASK_##name = \
0038 (1ULL << bit | CEPH_MSGR2_INCARNATION_##incarnation);
0039
0040 #define HAVE_MSGR2_FEATURE(x, name) \
0041 (((x) & (CEPH_MSGR2_FEATUREMASK_##name)) == (CEPH_MSGR2_FEATUREMASK_##name))
0042
0043 DEFINE_MSGR2_FEATURE( 0, 1, REVISION_1)
0044
0045 #define CEPH_MSGR2_SUPPORTED_FEATURES (CEPH_MSGR2_FEATURE_REVISION_1)
0046
0047 #define CEPH_MSGR2_REQUIRED_FEATURES (CEPH_MSGR2_FEATURE_REVISION_1)
0048
0049
0050
0051
0052
0053
0054 typedef __u32 ceph_seq_t;
0055
0056 static inline __s32 ceph_seq_cmp(__u32 a, __u32 b)
0057 {
0058 return (__s32)a - (__s32)b;
0059 }
0060
0061
0062
0063
0064
0065
0066 struct ceph_entity_name {
0067 __u8 type;
0068 __le64 num;
0069 } __attribute__ ((packed));
0070
0071 #define CEPH_ENTITY_TYPE_MON 0x01
0072 #define CEPH_ENTITY_TYPE_MDS 0x02
0073 #define CEPH_ENTITY_TYPE_OSD 0x04
0074 #define CEPH_ENTITY_TYPE_CLIENT 0x08
0075 #define CEPH_ENTITY_TYPE_AUTH 0x20
0076
0077 #define CEPH_ENTITY_TYPE_ANY 0xFF
0078
0079 extern const char *ceph_entity_type_name(int type);
0080
0081
0082
0083
0084 struct ceph_entity_addr {
0085 __le32 type;
0086 __le32 nonce;
0087 struct sockaddr_storage in_addr;
0088 } __attribute__ ((packed));
0089
0090 static inline bool ceph_addr_equal_no_type(const struct ceph_entity_addr *lhs,
0091 const struct ceph_entity_addr *rhs)
0092 {
0093 return !memcmp(&lhs->in_addr, &rhs->in_addr, sizeof(lhs->in_addr)) &&
0094 lhs->nonce == rhs->nonce;
0095 }
0096
0097 struct ceph_entity_inst {
0098 struct ceph_entity_name name;
0099 struct ceph_entity_addr addr;
0100 } __attribute__ ((packed));
0101
0102
0103
0104 #define CEPH_MSGR_TAG_READY 1
0105 #define CEPH_MSGR_TAG_RESETSESSION 2
0106 #define CEPH_MSGR_TAG_WAIT 3
0107
0108 #define CEPH_MSGR_TAG_RETRY_SESSION 4
0109
0110 #define CEPH_MSGR_TAG_RETRY_GLOBAL 5
0111
0112 #define CEPH_MSGR_TAG_CLOSE 6
0113 #define CEPH_MSGR_TAG_MSG 7
0114 #define CEPH_MSGR_TAG_ACK 8
0115 #define CEPH_MSGR_TAG_KEEPALIVE 9
0116 #define CEPH_MSGR_TAG_BADPROTOVER 10
0117 #define CEPH_MSGR_TAG_BADAUTHORIZER 11
0118 #define CEPH_MSGR_TAG_FEATURES 12
0119 #define CEPH_MSGR_TAG_SEQ 13
0120 #define CEPH_MSGR_TAG_KEEPALIVE2 14
0121 #define CEPH_MSGR_TAG_KEEPALIVE2_ACK 15
0122 #define CEPH_MSGR_TAG_CHALLENGE_AUTHORIZER 16
0123
0124
0125
0126
0127 struct ceph_msg_connect {
0128 __le64 features;
0129 __le32 host_type;
0130 __le32 global_seq;
0131 __le32 connect_seq;
0132 __le32 protocol_version;
0133 __le32 authorizer_protocol;
0134 __le32 authorizer_len;
0135 __u8 flags;
0136 } __attribute__ ((packed));
0137
0138 struct ceph_msg_connect_reply {
0139 __u8 tag;
0140 __le64 features;
0141 __le32 global_seq;
0142 __le32 connect_seq;
0143 __le32 protocol_version;
0144 __le32 authorizer_len;
0145 __u8 flags;
0146 } __attribute__ ((packed));
0147
0148 #define CEPH_MSG_CONNECT_LOSSY 1
0149
0150
0151
0152
0153
0154 struct ceph_msg_header_old {
0155 __le64 seq;
0156 __le64 tid;
0157 __le16 type;
0158 __le16 priority;
0159 __le16 version;
0160
0161 __le32 front_len;
0162 __le32 middle_len;
0163 __le32 data_len;
0164 __le16 data_off;
0165
0166
0167 struct ceph_entity_inst src, orig_src;
0168 __le32 reserved;
0169 __le32 crc;
0170 } __attribute__ ((packed));
0171
0172 struct ceph_msg_header {
0173 __le64 seq;
0174 __le64 tid;
0175 __le16 type;
0176 __le16 priority;
0177 __le16 version;
0178
0179 __le32 front_len;
0180 __le32 middle_len;
0181 __le32 data_len;
0182 __le16 data_off;
0183
0184
0185 struct ceph_entity_name src;
0186 __le16 compat_version;
0187 __le16 reserved;
0188 __le32 crc;
0189 } __attribute__ ((packed));
0190
0191 struct ceph_msg_header2 {
0192 __le64 seq;
0193 __le64 tid;
0194 __le16 type;
0195 __le16 priority;
0196 __le16 version;
0197
0198 __le32 data_pre_padding_len;
0199 __le16 data_off;
0200
0201
0202 __le64 ack_seq;
0203 __u8 flags;
0204
0205 __le16 compat_version;
0206 __le16 reserved;
0207 } __attribute__ ((packed));
0208
0209 #define CEPH_MSG_PRIO_LOW 64
0210 #define CEPH_MSG_PRIO_DEFAULT 127
0211 #define CEPH_MSG_PRIO_HIGH 196
0212 #define CEPH_MSG_PRIO_HIGHEST 255
0213
0214
0215
0216
0217 struct ceph_msg_footer_old {
0218 __le32 front_crc, middle_crc, data_crc;
0219 __u8 flags;
0220 } __attribute__ ((packed));
0221
0222 struct ceph_msg_footer {
0223 __le32 front_crc, middle_crc, data_crc;
0224
0225 __le64 sig;
0226 __u8 flags;
0227 } __attribute__ ((packed));
0228
0229 #define CEPH_MSG_FOOTER_COMPLETE (1<<0)
0230 #define CEPH_MSG_FOOTER_NOCRC (1<<1)
0231 #define CEPH_MSG_FOOTER_SIGNED (1<<2)
0232
0233
0234 #endif