diff options
Diffstat (limited to 'net/tipc/msg.h')
| -rw-r--r-- | net/tipc/msg.h | 47 |
1 files changed, 11 insertions, 36 deletions
diff --git a/net/tipc/msg.h b/net/tipc/msg.h index e9ef6df26562..ad487e8abcc2 100644 --- a/net/tipc/msg.h +++ b/net/tipc/msg.h | |||
| @@ -40,18 +40,16 @@ | |||
| 40 | #include "core.h" | 40 | #include "core.h" |
| 41 | 41 | ||
| 42 | #define TIPC_VERSION 2 | 42 | #define TIPC_VERSION 2 |
| 43 | #define DATA_LOW TIPC_LOW_IMPORTANCE | 43 | |
| 44 | #define DATA_MEDIUM TIPC_MEDIUM_IMPORTANCE | 44 | #define SHORT_H_SIZE 24 /* Connected, in-cluster messages */ |
| 45 | #define DATA_HIGH TIPC_HIGH_IMPORTANCE | ||
| 46 | #define DATA_CRITICAL TIPC_CRITICAL_IMPORTANCE | ||
| 47 | #define SHORT_H_SIZE 24 /* Connected,in cluster */ | ||
| 48 | #define DIR_MSG_H_SIZE 32 /* Directly addressed messages */ | 45 | #define DIR_MSG_H_SIZE 32 /* Directly addressed messages */ |
| 49 | #define CONN_MSG_H_SIZE 36 /* Routed connected msgs*/ | 46 | #define LONG_H_SIZE 40 /* Named messages */ |
| 50 | #define LONG_H_SIZE 40 /* Named Messages */ | ||
| 51 | #define MCAST_H_SIZE 44 /* Multicast messages */ | 47 | #define MCAST_H_SIZE 44 /* Multicast messages */ |
| 52 | #define MAX_H_SIZE 60 /* Inclusive full options */ | 48 | #define INT_H_SIZE 40 /* Internal messages */ |
| 49 | #define MIN_H_SIZE 24 /* Smallest legal TIPC header size */ | ||
| 50 | #define MAX_H_SIZE 60 /* Largest possible TIPC header size */ | ||
| 51 | |||
| 53 | #define MAX_MSG_SIZE (MAX_H_SIZE + TIPC_MAX_USER_MSG_SIZE) | 52 | #define MAX_MSG_SIZE (MAX_H_SIZE + TIPC_MAX_USER_MSG_SIZE) |
| 54 | #define LINK_CONFIG 13 | ||
| 55 | 53 | ||
| 56 | 54 | ||
| 57 | /* | 55 | /* |
| @@ -72,7 +70,8 @@ static inline void msg_set_bits(struct tipc_msg *m, u32 w, | |||
| 72 | u32 pos, u32 mask, u32 val) | 70 | u32 pos, u32 mask, u32 val) |
| 73 | { | 71 | { |
| 74 | val = (val & mask) << pos; | 72 | val = (val & mask) << pos; |
| 75 | m->hdr[w] &= ~htonl(mask << pos); | 73 | mask = mask << pos; |
| 74 | m->hdr[w] &= ~htonl(mask); | ||
| 76 | m->hdr[w] |= htonl(val); | 75 | m->hdr[w] |= htonl(val); |
| 77 | } | 76 | } |
| 78 | 77 | ||
| @@ -87,7 +86,7 @@ static inline u32 msg_version(struct tipc_msg *m) | |||
| 87 | 86 | ||
| 88 | static inline void msg_set_version(struct tipc_msg *m) | 87 | static inline void msg_set_version(struct tipc_msg *m) |
| 89 | { | 88 | { |
| 90 | msg_set_bits(m, 0, 29, 0xf, TIPC_VERSION); | 89 | msg_set_bits(m, 0, 29, 7, TIPC_VERSION); |
| 91 | } | 90 | } |
| 92 | 91 | ||
| 93 | static inline u32 msg_user(struct tipc_msg *m) | 92 | static inline u32 msg_user(struct tipc_msg *m) |
| @@ -97,7 +96,7 @@ static inline u32 msg_user(struct tipc_msg *m) | |||
| 97 | 96 | ||
| 98 | static inline u32 msg_isdata(struct tipc_msg *m) | 97 | static inline u32 msg_isdata(struct tipc_msg *m) |
| 99 | { | 98 | { |
| 100 | return (msg_user(m) <= DATA_CRITICAL); | 99 | return (msg_user(m) <= TIPC_CRITICAL_IMPORTANCE); |
| 101 | } | 100 | } |
| 102 | 101 | ||
| 103 | static inline void msg_set_user(struct tipc_msg *m, u32 n) | 102 | static inline void msg_set_user(struct tipc_msg *m, u32 n) |
| @@ -190,18 +189,6 @@ static inline void msg_set_lookup_scope(struct tipc_msg *m, u32 n) | |||
| 190 | msg_set_bits(m, 1, 19, 0x3, n); | 189 | msg_set_bits(m, 1, 19, 0x3, n); |
| 191 | } | 190 | } |
| 192 | 191 | ||
| 193 | static inline void msg_set_options(struct tipc_msg *m, const char *opt, u32 sz) | ||
| 194 | { | ||
| 195 | u32 hsz = msg_hdr_sz(m); | ||
| 196 | char *to = (char *)&m->hdr[hsz/4]; | ||
| 197 | |||
| 198 | if ((hsz < DIR_MSG_H_SIZE) || ((hsz + sz) > MAX_H_SIZE)) | ||
| 199 | return; | ||
| 200 | msg_set_bits(m, 1, 16, 0x7, (hsz - 28)/4); | ||
| 201 | msg_set_hdr_sz(m, hsz + sz); | ||
| 202 | memcpy(to, opt, sz); | ||
| 203 | } | ||
| 204 | |||
| 205 | static inline u32 msg_bcast_ack(struct tipc_msg *m) | 192 | static inline u32 msg_bcast_ack(struct tipc_msg *m) |
| 206 | { | 193 | { |
| 207 | return msg_bits(m, 1, 0, 0xffff); | 194 | return msg_bits(m, 1, 0, 0xffff); |
| @@ -330,17 +317,6 @@ static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m) | |||
| 330 | return (struct tipc_msg *)msg_data(m); | 317 | return (struct tipc_msg *)msg_data(m); |
| 331 | } | 318 | } |
| 332 | 319 | ||
| 333 | static inline void msg_expand(struct tipc_msg *m, u32 destnode) | ||
| 334 | { | ||
| 335 | if (!msg_short(m)) | ||
| 336 | return; | ||
| 337 | msg_set_hdr_sz(m, LONG_H_SIZE); | ||
| 338 | msg_set_orignode(m, msg_prevnode(m)); | ||
| 339 | msg_set_destnode(m, destnode); | ||
| 340 | memset(&m->hdr[8], 0, 12); | ||
| 341 | } | ||
| 342 | |||
| 343 | |||
| 344 | 320 | ||
| 345 | /* | 321 | /* |
| 346 | TIPC internal message header format, version 2 | 322 | TIPC internal message header format, version 2 |
| @@ -388,7 +364,6 @@ static inline void msg_expand(struct tipc_msg *m, u32 destnode) | |||
| 388 | #define NAME_DISTRIBUTOR 11 | 364 | #define NAME_DISTRIBUTOR 11 |
| 389 | #define MSG_FRAGMENTER 12 | 365 | #define MSG_FRAGMENTER 12 |
| 390 | #define LINK_CONFIG 13 | 366 | #define LINK_CONFIG 13 |
| 391 | #define INT_H_SIZE 40 | ||
| 392 | #define DSC_H_SIZE 40 | 367 | #define DSC_H_SIZE 40 |
| 393 | 368 | ||
| 394 | /* | 369 | /* |
