diff options
Diffstat (limited to 'net/tipc/msg.h')
-rw-r--r-- | net/tipc/msg.h | 50 |
1 files changed, 13 insertions, 37 deletions
diff --git a/net/tipc/msg.h b/net/tipc/msg.h index e9ef6df26562..6ad070d87702 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,8 +70,10 @@ 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 | val = htonl(val); |
76 | m->hdr[w] |= htonl(val); | 74 | mask = htonl(mask << pos); |
75 | m->hdr[w] &= ~mask; | ||
76 | m->hdr[w] |= val; | ||
77 | } | 77 | } |
78 | 78 | ||
79 | /* | 79 | /* |
@@ -87,7 +87,7 @@ static inline u32 msg_version(struct tipc_msg *m) | |||
87 | 87 | ||
88 | static inline void msg_set_version(struct tipc_msg *m) | 88 | static inline void msg_set_version(struct tipc_msg *m) |
89 | { | 89 | { |
90 | msg_set_bits(m, 0, 29, 0xf, TIPC_VERSION); | 90 | msg_set_bits(m, 0, 29, 7, TIPC_VERSION); |
91 | } | 91 | } |
92 | 92 | ||
93 | static inline u32 msg_user(struct tipc_msg *m) | 93 | static inline u32 msg_user(struct tipc_msg *m) |
@@ -97,7 +97,7 @@ static inline u32 msg_user(struct tipc_msg *m) | |||
97 | 97 | ||
98 | static inline u32 msg_isdata(struct tipc_msg *m) | 98 | static inline u32 msg_isdata(struct tipc_msg *m) |
99 | { | 99 | { |
100 | return (msg_user(m) <= DATA_CRITICAL); | 100 | return (msg_user(m) <= TIPC_CRITICAL_IMPORTANCE); |
101 | } | 101 | } |
102 | 102 | ||
103 | static inline void msg_set_user(struct tipc_msg *m, u32 n) | 103 | static inline void msg_set_user(struct tipc_msg *m, u32 n) |
@@ -190,18 +190,6 @@ static inline void msg_set_lookup_scope(struct tipc_msg *m, u32 n) | |||
190 | msg_set_bits(m, 1, 19, 0x3, n); | 190 | msg_set_bits(m, 1, 19, 0x3, n); |
191 | } | 191 | } |
192 | 192 | ||
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) | 193 | static inline u32 msg_bcast_ack(struct tipc_msg *m) |
206 | { | 194 | { |
207 | return msg_bits(m, 1, 0, 0xffff); | 195 | return msg_bits(m, 1, 0, 0xffff); |
@@ -330,17 +318,6 @@ static inline struct tipc_msg *msg_get_wrapped(struct tipc_msg *m) | |||
330 | return (struct tipc_msg *)msg_data(m); | 318 | return (struct tipc_msg *)msg_data(m); |
331 | } | 319 | } |
332 | 320 | ||
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 | 321 | ||
345 | /* | 322 | /* |
346 | TIPC internal message header format, version 2 | 323 | TIPC internal message header format, version 2 |
@@ -388,7 +365,6 @@ static inline void msg_expand(struct tipc_msg *m, u32 destnode) | |||
388 | #define NAME_DISTRIBUTOR 11 | 365 | #define NAME_DISTRIBUTOR 11 |
389 | #define MSG_FRAGMENTER 12 | 366 | #define MSG_FRAGMENTER 12 |
390 | #define LINK_CONFIG 13 | 367 | #define LINK_CONFIG 13 |
391 | #define INT_H_SIZE 40 | ||
392 | #define DSC_H_SIZE 40 | 368 | #define DSC_H_SIZE 40 |
393 | 369 | ||
394 | /* | 370 | /* |