Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 1 | /* |
| 2 | * net/tipc/msg.c: TIPC message header routines |
YOSHIFUJI Hideaki | c430728 | 2007-02-09 23:25:21 +0900 | [diff] [blame] | 3 | * |
Per Liden | 593a5f2 | 2006-01-11 19:14:19 +0100 | [diff] [blame] | 4 | * Copyright (c) 2000-2006, Ericsson AB |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 5 | * Copyright (c) 2005, Wind River Systems |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 6 | * All rights reserved. |
| 7 | * |
Per Liden | 9ea1fd3 | 2006-01-11 13:30:43 +0100 | [diff] [blame] | 8 | * Redistribution and use in source and binary forms, with or without |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 9 | * modification, are permitted provided that the following conditions are met: |
| 10 | * |
Per Liden | 9ea1fd3 | 2006-01-11 13:30:43 +0100 | [diff] [blame] | 11 | * 1. Redistributions of source code must retain the above copyright |
| 12 | * notice, this list of conditions and the following disclaimer. |
| 13 | * 2. Redistributions in binary form must reproduce the above copyright |
| 14 | * notice, this list of conditions and the following disclaimer in the |
| 15 | * documentation and/or other materials provided with the distribution. |
| 16 | * 3. Neither the names of the copyright holders nor the names of its |
| 17 | * contributors may be used to endorse or promote products derived from |
| 18 | * this software without specific prior written permission. |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 19 | * |
Per Liden | 9ea1fd3 | 2006-01-11 13:30:43 +0100 | [diff] [blame] | 20 | * Alternatively, this software may be distributed under the terms of the |
| 21 | * GNU General Public License ("GPL") version 2 as published by the Free |
| 22 | * Software Foundation. |
| 23 | * |
| 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 27 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 28 | * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 29 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 30 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 31 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 32 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 34 | * POSSIBILITY OF SUCH DAMAGE. |
| 35 | */ |
| 36 | |
| 37 | #include "core.h" |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 38 | #include "msg.h" |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 39 | |
Allan Stephens | 23461e8 | 2010-05-11 14:30:18 +0000 | [diff] [blame] | 40 | u32 tipc_msg_tot_importance(struct tipc_msg *m) |
| 41 | { |
| 42 | if (likely(msg_isdata(m))) { |
| 43 | if (likely(msg_orignode(m) == tipc_own_addr)) |
| 44 | return msg_importance(m); |
| 45 | return msg_importance(m) + 4; |
| 46 | } |
| 47 | if ((msg_user(m) == MSG_FRAGMENTER) && |
| 48 | (msg_type(m) == FIRST_FRAGMENT)) |
| 49 | return msg_importance(msg_get_wrapped(m)); |
| 50 | return msg_importance(m); |
| 51 | } |
| 52 | |
| 53 | |
| 54 | void tipc_msg_init(struct tipc_msg *m, u32 user, u32 type, |
| 55 | u32 hsize, u32 destnode) |
| 56 | { |
| 57 | memset(m, 0, hsize); |
| 58 | msg_set_version(m); |
| 59 | msg_set_user(m, user); |
| 60 | msg_set_hdr_sz(m, hsize); |
| 61 | msg_set_size(m, hsize); |
| 62 | msg_set_prevnode(m, tipc_own_addr); |
| 63 | msg_set_type(m, type); |
| 64 | if (!msg_short(m)) { |
| 65 | msg_set_orignode(m, tipc_own_addr); |
| 66 | msg_set_destnode(m, destnode); |
| 67 | } |
| 68 | } |
| 69 | |
| 70 | /** |
| 71 | * tipc_msg_calc_data_size - determine total data size for message |
| 72 | */ |
| 73 | |
| 74 | int tipc_msg_calc_data_size(struct iovec const *msg_sect, u32 num_sect) |
| 75 | { |
| 76 | int dsz = 0; |
| 77 | int i; |
| 78 | |
| 79 | for (i = 0; i < num_sect; i++) |
| 80 | dsz += msg_sect[i].iov_len; |
| 81 | return dsz; |
| 82 | } |
| 83 | |
| 84 | /** |
| 85 | * tipc_msg_build - create message using specified header and data |
| 86 | * |
| 87 | * Note: Caller must not hold any locks in case copy_from_user() is interrupted! |
| 88 | * |
| 89 | * Returns message data size or errno |
| 90 | */ |
| 91 | |
| 92 | int tipc_msg_build(struct tipc_msg *hdr, |
| 93 | struct iovec const *msg_sect, u32 num_sect, |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame^] | 94 | int max_size, int usrmem, struct sk_buff **buf) |
Allan Stephens | 23461e8 | 2010-05-11 14:30:18 +0000 | [diff] [blame] | 95 | { |
| 96 | int dsz, sz, hsz, pos, res, cnt; |
| 97 | |
| 98 | dsz = tipc_msg_calc_data_size(msg_sect, num_sect); |
| 99 | if (unlikely(dsz > TIPC_MAX_USER_MSG_SIZE)) { |
| 100 | *buf = NULL; |
| 101 | return -EINVAL; |
| 102 | } |
| 103 | |
| 104 | pos = hsz = msg_hdr_sz(hdr); |
| 105 | sz = hsz + dsz; |
| 106 | msg_set_size(hdr, sz); |
| 107 | if (unlikely(sz > max_size)) { |
| 108 | *buf = NULL; |
| 109 | return dsz; |
| 110 | } |
| 111 | |
stephen hemminger | 31e3c3f | 2010-10-13 13:20:35 +0000 | [diff] [blame] | 112 | *buf = tipc_buf_acquire(sz); |
Allan Stephens | 23461e8 | 2010-05-11 14:30:18 +0000 | [diff] [blame] | 113 | if (!(*buf)) |
| 114 | return -ENOMEM; |
| 115 | skb_copy_to_linear_data(*buf, hdr, hsz); |
| 116 | for (res = 1, cnt = 0; res && (cnt < num_sect); cnt++) { |
| 117 | if (likely(usrmem)) |
| 118 | res = !copy_from_user((*buf)->data + pos, |
| 119 | msg_sect[cnt].iov_base, |
| 120 | msg_sect[cnt].iov_len); |
| 121 | else |
| 122 | skb_copy_to_linear_data_offset(*buf, pos, |
| 123 | msg_sect[cnt].iov_base, |
| 124 | msg_sect[cnt].iov_len); |
| 125 | pos += msg_sect[cnt].iov_len; |
| 126 | } |
| 127 | if (likely(res)) |
| 128 | return dsz; |
| 129 | |
| 130 | buf_discard(*buf); |
| 131 | *buf = NULL; |
| 132 | return -EFAULT; |
| 133 | } |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 134 | |
Allan Stephens | 48c9713 | 2008-05-05 01:24:06 -0700 | [diff] [blame] | 135 | #ifdef CONFIG_TIPC_DEBUG |
| 136 | |
| 137 | void tipc_msg_dbg(struct print_buf *buf, struct tipc_msg *msg, const char *str) |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 138 | { |
| 139 | u32 usr = msg_user(msg); |
Allan Stephens | 6e7e309 | 2010-12-31 18:59:28 +0000 | [diff] [blame] | 140 | tipc_printf(buf, KERN_DEBUG); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 141 | tipc_printf(buf, str); |
| 142 | |
| 143 | switch (usr) { |
| 144 | case MSG_BUNDLER: |
| 145 | tipc_printf(buf, "BNDL::"); |
| 146 | tipc_printf(buf, "MSGS(%u):", msg_msgcnt(msg)); |
| 147 | break; |
| 148 | case BCAST_PROTOCOL: |
| 149 | tipc_printf(buf, "BCASTP::"); |
| 150 | break; |
| 151 | case MSG_FRAGMENTER: |
| 152 | tipc_printf(buf, "FRAGM::"); |
| 153 | switch (msg_type(msg)) { |
| 154 | case FIRST_FRAGMENT: |
| 155 | tipc_printf(buf, "FIRST:"); |
| 156 | break; |
| 157 | case FRAGMENT: |
| 158 | tipc_printf(buf, "BODY:"); |
| 159 | break; |
| 160 | case LAST_FRAGMENT: |
| 161 | tipc_printf(buf, "LAST:"); |
| 162 | break; |
| 163 | default: |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame^] | 164 | tipc_printf(buf, "UNKNOWN:%x", msg_type(msg)); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 165 | |
| 166 | } |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame^] | 167 | tipc_printf(buf, "NO(%u/%u):", msg_long_msgno(msg), |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 168 | msg_fragm_no(msg)); |
| 169 | break; |
Allan Stephens | 06d82c9 | 2008-03-06 15:06:55 -0800 | [diff] [blame] | 170 | case TIPC_LOW_IMPORTANCE: |
| 171 | case TIPC_MEDIUM_IMPORTANCE: |
| 172 | case TIPC_HIGH_IMPORTANCE: |
| 173 | case TIPC_CRITICAL_IMPORTANCE: |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 174 | tipc_printf(buf, "DAT%u:", msg_user(msg)); |
| 175 | if (msg_short(msg)) { |
| 176 | tipc_printf(buf, "CON:"); |
| 177 | break; |
| 178 | } |
| 179 | switch (msg_type(msg)) { |
| 180 | case TIPC_CONN_MSG: |
| 181 | tipc_printf(buf, "CON:"); |
| 182 | break; |
| 183 | case TIPC_MCAST_MSG: |
| 184 | tipc_printf(buf, "MCST:"); |
| 185 | break; |
| 186 | case TIPC_NAMED_MSG: |
| 187 | tipc_printf(buf, "NAM:"); |
| 188 | break; |
| 189 | case TIPC_DIRECT_MSG: |
| 190 | tipc_printf(buf, "DIR:"); |
| 191 | break; |
| 192 | default: |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame^] | 193 | tipc_printf(buf, "UNKNOWN TYPE %u", msg_type(msg)); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 194 | } |
| 195 | if (msg_routed(msg) && !msg_non_seq(msg)) |
| 196 | tipc_printf(buf, "ROUT:"); |
| 197 | if (msg_reroute_cnt(msg)) |
| 198 | tipc_printf(buf, "REROUTED(%u):", |
| 199 | msg_reroute_cnt(msg)); |
| 200 | break; |
| 201 | case NAME_DISTRIBUTOR: |
| 202 | tipc_printf(buf, "NMD::"); |
| 203 | switch (msg_type(msg)) { |
| 204 | case PUBLICATION: |
| 205 | tipc_printf(buf, "PUBL(%u):", (msg_size(msg) - msg_hdr_sz(msg)) / 20); /* Items */ |
| 206 | break; |
| 207 | case WITHDRAWAL: |
| 208 | tipc_printf(buf, "WDRW:"); |
| 209 | break; |
| 210 | default: |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame^] | 211 | tipc_printf(buf, "UNKNOWN:%x", msg_type(msg)); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 212 | } |
| 213 | if (msg_routed(msg)) |
| 214 | tipc_printf(buf, "ROUT:"); |
| 215 | if (msg_reroute_cnt(msg)) |
| 216 | tipc_printf(buf, "REROUTED(%u):", |
| 217 | msg_reroute_cnt(msg)); |
| 218 | break; |
| 219 | case CONN_MANAGER: |
| 220 | tipc_printf(buf, "CONN_MNG:"); |
| 221 | switch (msg_type(msg)) { |
| 222 | case CONN_PROBE: |
| 223 | tipc_printf(buf, "PROBE:"); |
| 224 | break; |
| 225 | case CONN_PROBE_REPLY: |
| 226 | tipc_printf(buf, "PROBE_REPLY:"); |
| 227 | break; |
| 228 | case CONN_ACK: |
| 229 | tipc_printf(buf, "CONN_ACK:"); |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame^] | 230 | tipc_printf(buf, "ACK(%u):", msg_msgcnt(msg)); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 231 | break; |
| 232 | default: |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame^] | 233 | tipc_printf(buf, "UNKNOWN TYPE:%x", msg_type(msg)); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 234 | } |
| 235 | if (msg_routed(msg)) |
| 236 | tipc_printf(buf, "ROUT:"); |
| 237 | if (msg_reroute_cnt(msg)) |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame^] | 238 | tipc_printf(buf, "REROUTED(%u):", msg_reroute_cnt(msg)); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 239 | break; |
| 240 | case LINK_PROTOCOL: |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame^] | 241 | tipc_printf(buf, "PROT:TIM(%u):", msg_timestamp(msg)); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 242 | switch (msg_type(msg)) { |
| 243 | case STATE_MSG: |
| 244 | tipc_printf(buf, "STATE:"); |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame^] | 245 | tipc_printf(buf, "%s:", msg_probe(msg) ? "PRB" : ""); |
| 246 | tipc_printf(buf, "NXS(%u):", msg_next_sent(msg)); |
| 247 | tipc_printf(buf, "GAP(%u):", msg_seq_gap(msg)); |
| 248 | tipc_printf(buf, "LSTBC(%u):", msg_last_bcast(msg)); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 249 | break; |
| 250 | case RESET_MSG: |
| 251 | tipc_printf(buf, "RESET:"); |
| 252 | if (msg_size(msg) != msg_hdr_sz(msg)) |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame^] | 253 | tipc_printf(buf, "BEAR:%s:", msg_data(msg)); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 254 | break; |
| 255 | case ACTIVATE_MSG: |
| 256 | tipc_printf(buf, "ACTIVATE:"); |
| 257 | break; |
| 258 | default: |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame^] | 259 | tipc_printf(buf, "UNKNOWN TYPE:%x", msg_type(msg)); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 260 | } |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame^] | 261 | tipc_printf(buf, "PLANE(%c):", msg_net_plane(msg)); |
| 262 | tipc_printf(buf, "SESS(%u):", msg_session(msg)); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 263 | break; |
| 264 | case CHANGEOVER_PROTOCOL: |
| 265 | tipc_printf(buf, "TUNL:"); |
| 266 | switch (msg_type(msg)) { |
| 267 | case DUPLICATE_MSG: |
| 268 | tipc_printf(buf, "DUPL:"); |
| 269 | break; |
| 270 | case ORIGINAL_MSG: |
| 271 | tipc_printf(buf, "ORIG:"); |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame^] | 272 | tipc_printf(buf, "EXP(%u)", msg_msgcnt(msg)); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 273 | break; |
| 274 | default: |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame^] | 275 | tipc_printf(buf, "UNKNOWN TYPE:%x", msg_type(msg)); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 276 | } |
| 277 | break; |
| 278 | case ROUTE_DISTRIBUTOR: |
| 279 | tipc_printf(buf, "ROUTING_MNG:"); |
| 280 | switch (msg_type(msg)) { |
| 281 | case EXT_ROUTING_TABLE: |
| 282 | tipc_printf(buf, "EXT_TBL:"); |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame^] | 283 | tipc_printf(buf, "TO:%x:", msg_remote_node(msg)); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 284 | break; |
| 285 | case LOCAL_ROUTING_TABLE: |
| 286 | tipc_printf(buf, "LOCAL_TBL:"); |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame^] | 287 | tipc_printf(buf, "TO:%x:", msg_remote_node(msg)); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 288 | break; |
| 289 | case SLAVE_ROUTING_TABLE: |
| 290 | tipc_printf(buf, "DP_TBL:"); |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame^] | 291 | tipc_printf(buf, "TO:%x:", msg_remote_node(msg)); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 292 | break; |
| 293 | case ROUTE_ADDITION: |
| 294 | tipc_printf(buf, "ADD:"); |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame^] | 295 | tipc_printf(buf, "TO:%x:", msg_remote_node(msg)); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 296 | break; |
| 297 | case ROUTE_REMOVAL: |
| 298 | tipc_printf(buf, "REMOVE:"); |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame^] | 299 | tipc_printf(buf, "TO:%x:", msg_remote_node(msg)); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 300 | break; |
| 301 | default: |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame^] | 302 | tipc_printf(buf, "UNKNOWN TYPE:%x", msg_type(msg)); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 303 | } |
| 304 | break; |
| 305 | case LINK_CONFIG: |
| 306 | tipc_printf(buf, "CFG:"); |
| 307 | switch (msg_type(msg)) { |
| 308 | case DSC_REQ_MSG: |
| 309 | tipc_printf(buf, "DSC_REQ:"); |
| 310 | break; |
| 311 | case DSC_RESP_MSG: |
| 312 | tipc_printf(buf, "DSC_RESP:"); |
| 313 | break; |
| 314 | default: |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame^] | 315 | tipc_printf(buf, "UNKNOWN TYPE:%x:", msg_type(msg)); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 316 | break; |
| 317 | } |
| 318 | break; |
| 319 | default: |
| 320 | tipc_printf(buf, "UNKNOWN USER:"); |
| 321 | } |
| 322 | |
| 323 | switch (usr) { |
| 324 | case CONN_MANAGER: |
Allan Stephens | 06d82c9 | 2008-03-06 15:06:55 -0800 | [diff] [blame] | 325 | case TIPC_LOW_IMPORTANCE: |
| 326 | case TIPC_MEDIUM_IMPORTANCE: |
| 327 | case TIPC_HIGH_IMPORTANCE: |
| 328 | case TIPC_CRITICAL_IMPORTANCE: |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 329 | switch (msg_errcode(msg)) { |
| 330 | case TIPC_OK: |
| 331 | break; |
| 332 | case TIPC_ERR_NO_NAME: |
| 333 | tipc_printf(buf, "NO_NAME:"); |
| 334 | break; |
| 335 | case TIPC_ERR_NO_PORT: |
| 336 | tipc_printf(buf, "NO_PORT:"); |
| 337 | break; |
| 338 | case TIPC_ERR_NO_NODE: |
| 339 | tipc_printf(buf, "NO_PROC:"); |
| 340 | break; |
| 341 | case TIPC_ERR_OVERLOAD: |
| 342 | tipc_printf(buf, "OVERLOAD:"); |
| 343 | break; |
| 344 | case TIPC_CONN_SHUTDOWN: |
| 345 | tipc_printf(buf, "SHUTDOWN:"); |
| 346 | break; |
| 347 | default: |
| 348 | tipc_printf(buf, "UNKNOWN ERROR(%x):", |
| 349 | msg_errcode(msg)); |
| 350 | } |
| 351 | default:{} |
| 352 | } |
| 353 | |
| 354 | tipc_printf(buf, "HZ(%u):", msg_hdr_sz(msg)); |
| 355 | tipc_printf(buf, "SZ(%u):", msg_size(msg)); |
| 356 | tipc_printf(buf, "SQNO(%u):", msg_seqno(msg)); |
| 357 | |
| 358 | if (msg_non_seq(msg)) |
| 359 | tipc_printf(buf, "NOSEQ:"); |
| 360 | else { |
| 361 | tipc_printf(buf, "ACK(%u):", msg_ack(msg)); |
| 362 | } |
| 363 | tipc_printf(buf, "BACK(%u):", msg_bcast_ack(msg)); |
| 364 | tipc_printf(buf, "PRND(%x)", msg_prevnode(msg)); |
| 365 | |
| 366 | if (msg_isdata(msg)) { |
| 367 | if (msg_named(msg)) { |
| 368 | tipc_printf(buf, "NTYP(%u):", msg_nametype(msg)); |
| 369 | tipc_printf(buf, "NINST(%u)", msg_nameinst(msg)); |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | if ((usr != LINK_PROTOCOL) && (usr != LINK_CONFIG) && |
| 374 | (usr != MSG_BUNDLER)) { |
| 375 | if (!msg_short(msg)) { |
| 376 | tipc_printf(buf, ":ORIG(%x:%u):", |
| 377 | msg_orignode(msg), msg_origport(msg)); |
| 378 | tipc_printf(buf, ":DEST(%x:%u):", |
| 379 | msg_destnode(msg), msg_destport(msg)); |
| 380 | } else { |
| 381 | tipc_printf(buf, ":OPRT(%u):", msg_origport(msg)); |
| 382 | tipc_printf(buf, ":DPRT(%u):", msg_destport(msg)); |
| 383 | } |
| 384 | if (msg_routed(msg) && !msg_non_seq(msg)) |
| 385 | tipc_printf(buf, ":TSEQN(%u)", msg_transp_seqno(msg)); |
| 386 | } |
| 387 | if (msg_user(msg) == NAME_DISTRIBUTOR) { |
| 388 | tipc_printf(buf, ":ONOD(%x):", msg_orignode(msg)); |
| 389 | tipc_printf(buf, ":DNOD(%x):", msg_destnode(msg)); |
| 390 | if (msg_routed(msg)) { |
| 391 | tipc_printf(buf, ":CSEQN(%u)", msg_transp_seqno(msg)); |
| 392 | } |
| 393 | } |
| 394 | |
| 395 | if (msg_user(msg) == LINK_CONFIG) { |
Allan Stephens | 0e65967 | 2010-12-31 18:59:32 +0000 | [diff] [blame^] | 396 | u32 *raw = (u32 *)msg; |
| 397 | struct tipc_media_addr *orig = (struct tipc_media_addr *)&raw[5]; |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 398 | tipc_printf(buf, ":REQL(%u):", msg_req_links(msg)); |
| 399 | tipc_printf(buf, ":DDOM(%x):", msg_dest_domain(msg)); |
| 400 | tipc_printf(buf, ":NETID(%u):", msg_bc_netid(msg)); |
Per Liden | 4323add | 2006-01-18 00:38:21 +0100 | [diff] [blame] | 401 | tipc_media_addr_printf(buf, orig); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 402 | } |
| 403 | if (msg_user(msg) == BCAST_PROTOCOL) { |
| 404 | tipc_printf(buf, "BCNACK:AFTER(%u):", msg_bcgap_after(msg)); |
| 405 | tipc_printf(buf, "TO(%u):", msg_bcgap_to(msg)); |
| 406 | } |
| 407 | tipc_printf(buf, "\n"); |
| 408 | if ((usr == CHANGEOVER_PROTOCOL) && (msg_msgcnt(msg))) { |
Allan Stephens | 48c9713 | 2008-05-05 01:24:06 -0700 | [diff] [blame] | 409 | tipc_msg_dbg(buf, msg_get_wrapped(msg), " /"); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 410 | } |
| 411 | if ((usr == MSG_FRAGMENTER) && (msg_type(msg) == FIRST_FRAGMENT)) { |
Allan Stephens | 48c9713 | 2008-05-05 01:24:06 -0700 | [diff] [blame] | 412 | tipc_msg_dbg(buf, msg_get_wrapped(msg), " /"); |
Per Liden | b97bf3f | 2006-01-02 19:04:38 +0100 | [diff] [blame] | 413 | } |
| 414 | } |
Allan Stephens | 48c9713 | 2008-05-05 01:24:06 -0700 | [diff] [blame] | 415 | |
| 416 | #endif |