^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * net/tipc/msg.h: Include file for TIPC message header routines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (c) 2000-2007, 2014-2017 Ericsson AB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (c) 2005-2008, 2010-2011, Wind River Systems
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * All rights reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * Redistribution and use in source and binary forms, with or without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * modification, are permitted provided that the following conditions are met:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) * 1. Redistributions of source code must retain the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) * notice, this list of conditions and the following disclaimer.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) * 2. Redistributions in binary form must reproduce the above copyright
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) * notice, this list of conditions and the following disclaimer in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) * documentation and/or other materials provided with the distribution.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) * 3. Neither the names of the copyright holders nor the names of its
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) * contributors may be used to endorse or promote products derived from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) * this software without specific prior written permission.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) * Alternatively, this software may be distributed under the terms of the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) * GNU General Public License ("GPL") version 2 as published by the Free
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) * Software Foundation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) * POSSIBILITY OF SUCH DAMAGE.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #ifndef _TIPC_MSG_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #define _TIPC_MSG_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #include <linux/tipc.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #include "core.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) * Constants and routines used to read and write TIPC payload message headers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) * Note: Some items are also used with TIPC internal message headers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #define TIPC_VERSION 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) struct plist;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * Payload message users are defined in TIPC's public API:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * - TIPC_LOW_IMPORTANCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * - TIPC_MEDIUM_IMPORTANCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) * - TIPC_HIGH_IMPORTANCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) * - TIPC_CRITICAL_IMPORTANCE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) #define TIPC_SYSTEM_IMPORTANCE 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) * Payload message types
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) #define TIPC_CONN_MSG 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) #define TIPC_MCAST_MSG 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) #define TIPC_NAMED_MSG 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) #define TIPC_DIRECT_MSG 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) #define TIPC_GRP_MEMBER_EVT 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) #define TIPC_GRP_BCAST_MSG 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) #define TIPC_GRP_MCAST_MSG 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) #define TIPC_GRP_UCAST_MSG 7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) * Internal message users
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) #define BCAST_PROTOCOL 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) #define MSG_BUNDLER 6
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) #define LINK_PROTOCOL 7
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) #define CONN_MANAGER 8
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) #define GROUP_PROTOCOL 9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) #define TUNNEL_PROTOCOL 10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) #define NAME_DISTRIBUTOR 11
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) #define MSG_FRAGMENTER 12
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) #define LINK_CONFIG 13
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) #define MSG_CRYPTO 14
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) #define SOCK_WAKEUP 14 /* pseudo user */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) #define TOP_SRV 15 /* pseudo user */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) * Message header sizes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) #define SHORT_H_SIZE 24 /* In-cluster basic payload message */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) #define BASIC_H_SIZE 32 /* Basic payload message */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) #define NAMED_H_SIZE 40 /* Named payload message */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) #define MCAST_H_SIZE 44 /* Multicast payload message */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) #define GROUP_H_SIZE 44 /* Group payload message */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) #define INT_H_SIZE 40 /* Internal messages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) #define MIN_H_SIZE 24 /* Smallest legal TIPC header size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) #define MAX_H_SIZE 60 /* Largest possible TIPC header size */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) #define MAX_MSG_SIZE (MAX_H_SIZE + TIPC_MAX_USER_MSG_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) #define TIPC_MEDIA_INFO_OFFSET 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) extern const int one_page_mtu;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) struct tipc_skb_cb {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) struct sk_buff *tail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) unsigned long nxt_retr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) unsigned long retr_stamp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) u32 bytes_read;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) u32 orig_member;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) u16 chain_imp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) u16 ackers;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) u16 retr_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) #ifdef CONFIG_TIPC_CRYPTO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) struct tipc_crypto *rx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) struct tipc_aead *last;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) u8 recurs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) } tx_clone_ctx __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) u8 validated:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) #ifdef CONFIG_TIPC_CRYPTO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) u8 encrypted:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) u8 decrypted:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) #define SKB_PROBING 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) #define SKB_GRACING 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) u8 xmit_type:2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) u8 tx_clone_deferred:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) u8 flags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) u8 reserved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) #ifdef CONFIG_TIPC_CRYPTO
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) void *crypto_ctx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) } __packed;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) #define TIPC_SKB_CB(__skb) ((struct tipc_skb_cb *)&((__skb)->cb[0]))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) struct tipc_msg {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) __be32 hdr[15];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) /* struct tipc_gap_ack - TIPC Gap ACK block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) * @ack: seqno of the last consecutive packet in link deferdq
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) * @gap: number of gap packets since the last ack
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) * E.g:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) * link deferdq: 1 2 3 4 10 11 13 14 15 20
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) * --> Gap ACK blocks: <4, 5>, <11, 1>, <15, 4>, <20, 0>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) struct tipc_gap_ack {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) __be16 ack;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) __be16 gap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) /* struct tipc_gap_ack_blks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) * @len: actual length of the record
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) * @ugack_cnt: number of Gap ACK blocks for unicast (following the broadcast
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) * ones)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) * @start_index: starting index for "valid" broadcast Gap ACK blocks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) * @bgack_cnt: number of Gap ACK blocks for broadcast in the record
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) * @gacks: array of Gap ACK blocks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) * 31 16 15 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) * +-------------+-------------+-------------+-------------+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) * | bgack_cnt | ugack_cnt | len |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) * +-------------+-------------+-------------+-------------+ -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) * | gap | ack | |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) * +-------------+-------------+-------------+-------------+ > bc gacks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) * : : : |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) * +-------------+-------------+-------------+-------------+ -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) * | gap | ack | |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) * +-------------+-------------+-------------+-------------+ > uc gacks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) * : : : |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) * +-------------+-------------+-------------+-------------+ -
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) struct tipc_gap_ack_blks {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) __be16 len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) union {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) u8 ugack_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) u8 start_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) u8 bgack_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) struct tipc_gap_ack gacks[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) #define MAX_GAP_ACK_BLKS 128
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) #define MAX_GAP_ACK_BLKS_SZ (sizeof(struct tipc_gap_ack_blks) + \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) sizeof(struct tipc_gap_ack) * MAX_GAP_ACK_BLKS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) static inline struct tipc_msg *buf_msg(struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) return (struct tipc_msg *)skb->data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) static inline u32 msg_word(struct tipc_msg *m, u32 pos)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) return ntohl(m->hdr[pos]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) static inline void msg_set_word(struct tipc_msg *m, u32 w, u32 val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) m->hdr[w] = htonl(val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) static inline u32 msg_bits(struct tipc_msg *m, u32 w, u32 pos, u32 mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) return (msg_word(m, w) >> pos) & mask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) static inline void msg_set_bits(struct tipc_msg *m, u32 w,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) u32 pos, u32 mask, u32 val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) val = (val & mask) << pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) mask = mask << pos;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) m->hdr[w] &= ~htonl(mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) m->hdr[w] |= htonl(val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) static inline void msg_swap_words(struct tipc_msg *msg, u32 a, u32 b)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) u32 temp = msg->hdr[a];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) msg->hdr[a] = msg->hdr[b];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) msg->hdr[b] = temp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) * Word 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) static inline u32 msg_version(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) return msg_bits(m, 0, 29, 7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) static inline void msg_set_version(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) msg_set_bits(m, 0, 29, 7, TIPC_VERSION);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) static inline u32 msg_user(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) return msg_bits(m, 0, 25, 0xf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) static inline u32 msg_isdata(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) return msg_user(m) <= TIPC_CRITICAL_IMPORTANCE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) static inline void msg_set_user(struct tipc_msg *m, u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) msg_set_bits(m, 0, 25, 0xf, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) static inline u32 msg_hdr_sz(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) return msg_bits(m, 0, 21, 0xf) << 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) static inline void msg_set_hdr_sz(struct tipc_msg *m, u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) msg_set_bits(m, 0, 21, 0xf, n>>2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) static inline u32 msg_size(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) return msg_bits(m, 0, 0, 0x1ffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) static inline u32 msg_blocks(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) return (msg_size(m) / 1024) + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) static inline u32 msg_data_sz(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) return msg_size(m) - msg_hdr_sz(m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) static inline int msg_non_seq(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) return msg_bits(m, 0, 20, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) static inline void msg_set_non_seq(struct tipc_msg *m, u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) msg_set_bits(m, 0, 20, 1, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) static inline int msg_is_syn(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) return msg_bits(m, 0, 17, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) static inline void msg_set_syn(struct tipc_msg *m, u32 d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) msg_set_bits(m, 0, 17, 1, d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) static inline int msg_dest_droppable(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) return msg_bits(m, 0, 19, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) static inline void msg_set_dest_droppable(struct tipc_msg *m, u32 d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) msg_set_bits(m, 0, 19, 1, d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) static inline int msg_is_keepalive(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) return msg_bits(m, 0, 19, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) static inline void msg_set_is_keepalive(struct tipc_msg *m, u32 d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) msg_set_bits(m, 0, 19, 1, d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) static inline int msg_src_droppable(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) return msg_bits(m, 0, 18, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) static inline void msg_set_src_droppable(struct tipc_msg *m, u32 d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) msg_set_bits(m, 0, 18, 1, d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) static inline int msg_ack_required(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) return msg_bits(m, 0, 18, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) static inline void msg_set_ack_required(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) msg_set_bits(m, 0, 18, 1, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) static inline int msg_nagle_ack(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) return msg_bits(m, 0, 18, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) static inline void msg_set_nagle_ack(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) msg_set_bits(m, 0, 18, 1, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) static inline bool msg_is_rcast(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) return msg_bits(m, 0, 18, 0x1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) static inline void msg_set_is_rcast(struct tipc_msg *m, bool d)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) msg_set_bits(m, 0, 18, 0x1, d);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) static inline void msg_set_size(struct tipc_msg *m, u32 sz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) m->hdr[0] = htonl((msg_word(m, 0) & ~0x1ffff) | sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) static inline unchar *msg_data(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) return ((unchar *)m) + msg_hdr_sz(m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) static inline struct tipc_msg *msg_inner_hdr(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) return (struct tipc_msg *)msg_data(m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) * Word 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) static inline u32 msg_type(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) return msg_bits(m, 1, 29, 0x7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) static inline void msg_set_type(struct tipc_msg *m, u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) msg_set_bits(m, 1, 29, 0x7, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) static inline int msg_in_group(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) int mtyp = msg_type(m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) return mtyp >= TIPC_GRP_MEMBER_EVT && mtyp <= TIPC_GRP_UCAST_MSG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) static inline bool msg_is_grp_evt(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) return msg_type(m) == TIPC_GRP_MEMBER_EVT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) static inline u32 msg_named(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) return msg_type(m) == TIPC_NAMED_MSG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) static inline u32 msg_mcast(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) int mtyp = msg_type(m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) return ((mtyp == TIPC_MCAST_MSG) || (mtyp == TIPC_GRP_BCAST_MSG) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) (mtyp == TIPC_GRP_MCAST_MSG));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) static inline u32 msg_connected(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) return msg_type(m) == TIPC_CONN_MSG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) static inline u32 msg_direct(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) return msg_type(m) == TIPC_DIRECT_MSG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) static inline u32 msg_errcode(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) return msg_bits(m, 1, 25, 0xf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) static inline void msg_set_errcode(struct tipc_msg *m, u32 err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) msg_set_bits(m, 1, 25, 0xf, err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) static inline void msg_set_bulk(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) msg_set_bits(m, 1, 28, 0x1, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) static inline u32 msg_is_bulk(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) return msg_bits(m, 1, 28, 0x1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) static inline void msg_set_last_bulk(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) msg_set_bits(m, 1, 27, 0x1, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) static inline u32 msg_is_last_bulk(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) return msg_bits(m, 1, 27, 0x1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) static inline void msg_set_non_legacy(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) msg_set_bits(m, 1, 26, 0x1, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) static inline u32 msg_is_legacy(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) return !msg_bits(m, 1, 26, 0x1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) static inline u32 msg_reroute_cnt(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) return msg_bits(m, 1, 21, 0xf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) static inline void msg_incr_reroute_cnt(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) msg_set_bits(m, 1, 21, 0xf, msg_reroute_cnt(m) + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) static inline void msg_reset_reroute_cnt(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) msg_set_bits(m, 1, 21, 0xf, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) static inline u32 msg_lookup_scope(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) return msg_bits(m, 1, 19, 0x3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) static inline void msg_set_lookup_scope(struct tipc_msg *m, u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) msg_set_bits(m, 1, 19, 0x3, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) static inline u16 msg_bcast_ack(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) return msg_bits(m, 1, 0, 0xffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) static inline void msg_set_bcast_ack(struct tipc_msg *m, u16 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) msg_set_bits(m, 1, 0, 0xffff, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) /* Note: reusing bits in word 1 for ACTIVATE_MSG only, to re-synch
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) * link peer session number
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) static inline bool msg_dest_session_valid(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) return msg_bits(m, 1, 16, 0x1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) static inline void msg_set_dest_session_valid(struct tipc_msg *m, bool valid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) msg_set_bits(m, 1, 16, 0x1, valid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) static inline u16 msg_dest_session(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) return msg_bits(m, 1, 0, 0xffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) static inline void msg_set_dest_session(struct tipc_msg *m, u16 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) msg_set_bits(m, 1, 0, 0xffff, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) * Word 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) static inline u16 msg_ack(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) return msg_bits(m, 2, 16, 0xffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) static inline void msg_set_ack(struct tipc_msg *m, u16 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) msg_set_bits(m, 2, 16, 0xffff, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) static inline u16 msg_seqno(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) return msg_bits(m, 2, 0, 0xffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) static inline void msg_set_seqno(struct tipc_msg *m, u16 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) msg_set_bits(m, 2, 0, 0xffff, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) * Words 3-10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) static inline u32 msg_importance(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) int usr = msg_user(m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) if (likely((usr <= TIPC_CRITICAL_IMPORTANCE) && !msg_errcode(m)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) return usr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) if ((usr == MSG_FRAGMENTER) || (usr == MSG_BUNDLER))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) return msg_bits(m, 9, 0, 0x7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) return TIPC_SYSTEM_IMPORTANCE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) static inline void msg_set_importance(struct tipc_msg *m, u32 i)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) int usr = msg_user(m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) if (likely((usr == MSG_FRAGMENTER) || (usr == MSG_BUNDLER)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) msg_set_bits(m, 9, 0, 0x7, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) else if (i < TIPC_SYSTEM_IMPORTANCE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) msg_set_user(m, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) pr_warn("Trying to set illegal importance in message\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) static inline u32 msg_prevnode(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) return msg_word(m, 3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) static inline void msg_set_prevnode(struct tipc_msg *m, u32 a)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) msg_set_word(m, 3, a);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) static inline u32 msg_origport(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) if (msg_user(m) == MSG_FRAGMENTER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) m = msg_inner_hdr(m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) return msg_word(m, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) static inline void msg_set_origport(struct tipc_msg *m, u32 p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) msg_set_word(m, 4, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) static inline u16 msg_named_seqno(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) return msg_bits(m, 4, 0, 0xffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) static inline void msg_set_named_seqno(struct tipc_msg *m, u16 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) msg_set_bits(m, 4, 0, 0xffff, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) static inline u32 msg_destport(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) return msg_word(m, 5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) static inline void msg_set_destport(struct tipc_msg *m, u32 p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) msg_set_word(m, 5, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) static inline u32 msg_mc_netid(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) return msg_word(m, 5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) static inline void msg_set_mc_netid(struct tipc_msg *m, u32 p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) msg_set_word(m, 5, p);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) static inline int msg_short(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634) return msg_hdr_sz(m) == SHORT_H_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) static inline u32 msg_orignode(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) if (likely(msg_short(m)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) return msg_prevnode(m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641) return msg_word(m, 6);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) static inline void msg_set_orignode(struct tipc_msg *m, u32 a)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) msg_set_word(m, 6, a);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) static inline u32 msg_destnode(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) return msg_word(m, 7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) static inline void msg_set_destnode(struct tipc_msg *m, u32 a)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) msg_set_word(m, 7, a);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) static inline u32 msg_nametype(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) return msg_word(m, 8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 662) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 663)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 664) static inline void msg_set_nametype(struct tipc_msg *m, u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 665) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 666) msg_set_word(m, 8, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 667) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 668)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 669) static inline u32 msg_nameinst(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 670) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 671) return msg_word(m, 9);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 672) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 673)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 674) static inline u32 msg_namelower(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 675) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 676) return msg_nameinst(m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 677) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 678)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 679) static inline void msg_set_namelower(struct tipc_msg *m, u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 680) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 681) msg_set_word(m, 9, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 682) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 683)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 684) static inline void msg_set_nameinst(struct tipc_msg *m, u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 685) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 686) msg_set_namelower(m, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 687) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 688)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 689) static inline u32 msg_nameupper(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 690) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 691) return msg_word(m, 10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 692) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 693)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 694) static inline void msg_set_nameupper(struct tipc_msg *m, u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 695) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 696) msg_set_word(m, 10, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 697) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 698)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 699) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 700) * Constants and routines used to read and write TIPC internal message headers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 701) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 702)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 703) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 704) * Connection management protocol message types
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 705) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 706) #define CONN_PROBE 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 707) #define CONN_PROBE_REPLY 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 708) #define CONN_ACK 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 709)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 710) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 711) * Name distributor message types
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 712) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 713) #define PUBLICATION 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 714) #define WITHDRAWAL 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 715)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 716) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 717) * Segmentation message types
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 718) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 719) #define FIRST_FRAGMENT 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 720) #define FRAGMENT 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 721) #define LAST_FRAGMENT 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 722)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 723) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 724) * Link management protocol message types
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 725) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 726) #define STATE_MSG 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 727) #define RESET_MSG 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 728) #define ACTIVATE_MSG 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 729)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 730) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 731) * Changeover tunnel message types
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 732) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 733) #define SYNCH_MSG 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 734) #define FAILOVER_MSG 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 735)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 736) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 737) * Config protocol message types
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 738) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 739) #define DSC_REQ_MSG 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 740) #define DSC_RESP_MSG 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 741) #define DSC_TRIAL_MSG 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 742) #define DSC_TRIAL_FAIL_MSG 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 743)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 744) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 745) * Group protocol message types
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 746) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 747) #define GRP_JOIN_MSG 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 748) #define GRP_LEAVE_MSG 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 749) #define GRP_ADV_MSG 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 750) #define GRP_ACK_MSG 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 751) #define GRP_RECLAIM_MSG 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 752) #define GRP_REMIT_MSG 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 753)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 754) /* Crypto message types */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 755) #define KEY_DISTR_MSG 0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 756)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 757) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 758) * Word 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 759) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 760) static inline u32 msg_seq_gap(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 761) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 762) return msg_bits(m, 1, 16, 0x1fff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 763) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 764)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 765) static inline void msg_set_seq_gap(struct tipc_msg *m, u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 766) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 767) msg_set_bits(m, 1, 16, 0x1fff, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 768) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 769)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 770) static inline u32 msg_node_sig(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 771) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 772) return msg_bits(m, 1, 0, 0xffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 773) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 774)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 775) static inline void msg_set_node_sig(struct tipc_msg *m, u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 776) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 777) msg_set_bits(m, 1, 0, 0xffff, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 778) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 779)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 780) static inline u32 msg_node_capabilities(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 781) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 782) return msg_bits(m, 1, 15, 0x1fff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 783) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 784)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 785) static inline void msg_set_node_capabilities(struct tipc_msg *m, u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 786) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 787) msg_set_bits(m, 1, 15, 0x1fff, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 788) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 789)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 790) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 791) * Word 2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 792) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 793) static inline u32 msg_dest_domain(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 794) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 795) return msg_word(m, 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 796) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 797)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 798) static inline void msg_set_dest_domain(struct tipc_msg *m, u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 799) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 800) msg_set_word(m, 2, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 801) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 802)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 803) static inline u32 msg_bcgap_after(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 804) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 805) return msg_bits(m, 2, 16, 0xffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 806) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 807)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 808) static inline void msg_set_bcgap_after(struct tipc_msg *m, u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 809) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 810) msg_set_bits(m, 2, 16, 0xffff, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 811) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 812)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 813) static inline u32 msg_bcgap_to(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 814) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 815) return msg_bits(m, 2, 0, 0xffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 816) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 817)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 818) static inline void msg_set_bcgap_to(struct tipc_msg *m, u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 819) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 820) msg_set_bits(m, 2, 0, 0xffff, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 821) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 822)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 823) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 824) * Word 4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 825) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 826) static inline u32 msg_last_bcast(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 827) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 828) return msg_bits(m, 4, 16, 0xffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 829) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 830)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 831) static inline u32 msg_bc_snd_nxt(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 832) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 833) return msg_last_bcast(m) + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 834) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 835)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 836) static inline void msg_set_last_bcast(struct tipc_msg *m, u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 837) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 838) msg_set_bits(m, 4, 16, 0xffff, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 839) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 840)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 841) static inline u32 msg_nof_fragms(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 842) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 843) return msg_bits(m, 4, 0, 0xffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 844) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 845)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 846) static inline void msg_set_nof_fragms(struct tipc_msg *m, u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 847) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 848) msg_set_bits(m, 4, 0, 0xffff, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 849) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 850)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 851) static inline u32 msg_fragm_no(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 852) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 853) return msg_bits(m, 4, 16, 0xffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 854) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 855)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 856) static inline void msg_set_fragm_no(struct tipc_msg *m, u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 857) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 858) msg_set_bits(m, 4, 16, 0xffff, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 859) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 860)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 861) static inline u16 msg_next_sent(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 862) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 863) return msg_bits(m, 4, 0, 0xffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 864) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 865)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 866) static inline void msg_set_next_sent(struct tipc_msg *m, u16 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 867) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 868) msg_set_bits(m, 4, 0, 0xffff, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 869) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 870)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 871) static inline void msg_set_long_msgno(struct tipc_msg *m, u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 872) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 873) msg_set_bits(m, 4, 0, 0xffff, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 874) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 875)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 876) static inline u32 msg_bc_netid(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 877) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 878) return msg_word(m, 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 879) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 880)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 881) static inline void msg_set_bc_netid(struct tipc_msg *m, u32 id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 882) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 883) msg_set_word(m, 4, id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 884) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 885)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 886) static inline u32 msg_link_selector(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 887) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 888) if (msg_user(m) == MSG_FRAGMENTER)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 889) m = (void *)msg_data(m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 890) return msg_bits(m, 4, 0, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 891) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 892)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 893) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 894) * Word 5
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 895) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 896) static inline u16 msg_session(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 897) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 898) return msg_bits(m, 5, 16, 0xffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 899) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 900)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 901) static inline void msg_set_session(struct tipc_msg *m, u16 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 902) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 903) msg_set_bits(m, 5, 16, 0xffff, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 904) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 905)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 906) static inline u32 msg_probe(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 907) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 908) return msg_bits(m, 5, 0, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 909) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 910)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 911) static inline void msg_set_probe(struct tipc_msg *m, u32 val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 912) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 913) msg_set_bits(m, 5, 0, 1, val);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 914) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 915)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 916) static inline char msg_net_plane(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 917) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 918) return msg_bits(m, 5, 1, 7) + 'A';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 919) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 920)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 921) static inline void msg_set_net_plane(struct tipc_msg *m, char n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 922) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 923) msg_set_bits(m, 5, 1, 7, (n - 'A'));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 924) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 925)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 926) static inline u32 msg_linkprio(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 927) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 928) return msg_bits(m, 5, 4, 0x1f);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 929) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 930)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 931) static inline void msg_set_linkprio(struct tipc_msg *m, u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 932) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 933) msg_set_bits(m, 5, 4, 0x1f, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 934) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 935)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 936) static inline u32 msg_bearer_id(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 937) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 938) return msg_bits(m, 5, 9, 0x7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 939) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 940)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 941) static inline void msg_set_bearer_id(struct tipc_msg *m, u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 942) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 943) msg_set_bits(m, 5, 9, 0x7, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 944) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 945)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 946) static inline u32 msg_redundant_link(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 947) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 948) return msg_bits(m, 5, 12, 0x1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 949) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 950)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 951) static inline void msg_set_redundant_link(struct tipc_msg *m, u32 r)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 952) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 953) msg_set_bits(m, 5, 12, 0x1, r);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 954) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 955)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 956) static inline u32 msg_peer_stopping(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 957) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 958) return msg_bits(m, 5, 13, 0x1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 959) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 960)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 961) static inline void msg_set_peer_stopping(struct tipc_msg *m, u32 s)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 962) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 963) msg_set_bits(m, 5, 13, 0x1, s);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 964) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 965)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 966) static inline bool msg_bc_ack_invalid(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 967) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 968) switch (msg_user(m)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 969) case BCAST_PROTOCOL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 970) case NAME_DISTRIBUTOR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 971) case LINK_PROTOCOL:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 972) return msg_bits(m, 5, 14, 0x1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 973) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 974) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 975) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 976) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 977)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 978) static inline void msg_set_bc_ack_invalid(struct tipc_msg *m, bool invalid)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 979) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 980) msg_set_bits(m, 5, 14, 0x1, invalid);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 981) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 982)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 983) static inline char *msg_media_addr(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 984) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 985) return (char *)&m->hdr[TIPC_MEDIA_INFO_OFFSET];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 986) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 987)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 988) static inline u32 msg_bc_gap(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 989) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 990) return msg_bits(m, 8, 0, 0x3ff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 991) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 992)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 993) static inline void msg_set_bc_gap(struct tipc_msg *m, u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 994) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 995) msg_set_bits(m, 8, 0, 0x3ff, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 996) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 997)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 998) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 999) * Word 9
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) static inline u16 msg_msgcnt(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) return msg_bits(m, 9, 16, 0xffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) static inline void msg_set_msgcnt(struct tipc_msg *m, u16 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) msg_set_bits(m, 9, 16, 0xffff, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) static inline u16 msg_syncpt(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) return msg_bits(m, 9, 16, 0xffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) static inline void msg_set_syncpt(struct tipc_msg *m, u16 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) msg_set_bits(m, 9, 16, 0xffff, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) static inline u32 msg_conn_ack(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) return msg_bits(m, 9, 16, 0xffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) static inline void msg_set_conn_ack(struct tipc_msg *m, u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) msg_set_bits(m, 9, 16, 0xffff, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) static inline u16 msg_adv_win(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) return msg_bits(m, 9, 0, 0xffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) static inline void msg_set_adv_win(struct tipc_msg *m, u16 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) msg_set_bits(m, 9, 0, 0xffff, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) static inline u32 msg_max_pkt(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) return msg_bits(m, 9, 16, 0xffff) * 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046) static inline void msg_set_max_pkt(struct tipc_msg *m, u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048) msg_set_bits(m, 9, 16, 0xffff, (n / 4));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) static inline u32 msg_link_tolerance(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) return msg_bits(m, 9, 0, 0xffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) static inline void msg_set_link_tolerance(struct tipc_msg *m, u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) msg_set_bits(m, 9, 0, 0xffff, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) static inline u16 msg_grp_bc_syncpt(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) return msg_bits(m, 9, 16, 0xffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) static inline void msg_set_grp_bc_syncpt(struct tipc_msg *m, u16 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) msg_set_bits(m, 9, 16, 0xffff, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) static inline u16 msg_grp_bc_acked(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) return msg_bits(m, 9, 16, 0xffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) static inline void msg_set_grp_bc_acked(struct tipc_msg *m, u16 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) msg_set_bits(m, 9, 16, 0xffff, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) static inline u16 msg_grp_remitted(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) return msg_bits(m, 9, 16, 0xffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) static inline void msg_set_grp_remitted(struct tipc_msg *m, u16 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) msg_set_bits(m, 9, 16, 0xffff, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) /* Word 10
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) static inline u16 msg_grp_evt(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) return msg_bits(m, 10, 0, 0x3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) static inline void msg_set_grp_evt(struct tipc_msg *m, int n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) msg_set_bits(m, 10, 0, 0x3, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) static inline u16 msg_grp_bc_ack_req(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) return msg_bits(m, 10, 0, 0x1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) static inline void msg_set_grp_bc_ack_req(struct tipc_msg *m, bool n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) msg_set_bits(m, 10, 0, 0x1, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) static inline u16 msg_grp_bc_seqno(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) return msg_bits(m, 10, 16, 0xffff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) static inline void msg_set_grp_bc_seqno(struct tipc_msg *m, u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) msg_set_bits(m, 10, 16, 0xffff, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) static inline bool msg_peer_link_is_up(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) if (likely(msg_user(m) != LINK_PROTOCOL))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) if (msg_type(m) == STATE_MSG)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) return false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) static inline bool msg_peer_node_is_up(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) if (msg_peer_link_is_up(m))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) return msg_redundant_link(m);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139) static inline bool msg_is_reset(struct tipc_msg *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) return (msg_user(hdr) == LINK_PROTOCOL) && (msg_type(hdr) == RESET_MSG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) /* Word 13
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) static inline void msg_set_peer_net_hash(struct tipc_msg *m, u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) msg_set_word(m, 13, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) static inline u32 msg_peer_net_hash(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) return msg_word(m, 13);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) /* Word 14
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) static inline u32 msg_sugg_node_addr(struct tipc_msg *m)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) return msg_word(m, 14);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) static inline void msg_set_sugg_node_addr(struct tipc_msg *m, u32 n)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) msg_set_word(m, 14, n);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) static inline void msg_set_node_id(struct tipc_msg *hdr, u8 *id)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) memcpy(msg_data(hdr), id, 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) static inline u8 *msg_node_id(struct tipc_msg *hdr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) return (u8 *)msg_data(hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) struct sk_buff *tipc_buf_acquire(u32 size, gfp_t gfp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) bool tipc_msg_validate(struct sk_buff **_skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) bool tipc_msg_reverse(u32 own_addr, struct sk_buff **skb, int err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) void tipc_skb_reject(struct net *net, int err, struct sk_buff *skb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) struct sk_buff_head *xmitq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) void tipc_msg_init(u32 own_addr, struct tipc_msg *m, u32 user, u32 type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) u32 hsize, u32 destnode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) struct sk_buff *tipc_msg_create(uint user, uint type, uint hdr_sz,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) uint data_sz, u32 dnode, u32 onode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) u32 dport, u32 oport, int errcode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) int tipc_buf_append(struct sk_buff **headbuf, struct sk_buff **buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) bool tipc_msg_try_bundle(struct sk_buff *tskb, struct sk_buff **skb, u32 mss,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) u32 dnode, bool *new_bundle);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) bool tipc_msg_extract(struct sk_buff *skb, struct sk_buff **iskb, int *pos);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) int tipc_msg_fragment(struct sk_buff *skb, const struct tipc_msg *hdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) int pktmax, struct sk_buff_head *frags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) int tipc_msg_build(struct tipc_msg *mhdr, struct msghdr *m,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) int offset, int dsz, int mtu, struct sk_buff_head *list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) int tipc_msg_append(struct tipc_msg *hdr, struct msghdr *m, int dlen,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) int mss, struct sk_buff_head *txq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) bool tipc_msg_lookup_dest(struct net *net, struct sk_buff *skb, int *err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) bool tipc_msg_assemble(struct sk_buff_head *list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) bool tipc_msg_reassemble(struct sk_buff_head *list, struct sk_buff_head *rcvq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) bool tipc_msg_pskb_copy(u32 dst, struct sk_buff_head *msg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) struct sk_buff_head *cpy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) bool __tipc_skb_queue_sorted(struct sk_buff_head *list, u16 seqno,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) bool tipc_msg_skb_clone(struct sk_buff_head *msg, struct sk_buff_head *cpy);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) static inline u16 buf_seqno(struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) return msg_seqno(buf_msg(skb));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) static inline int buf_roundup_len(struct sk_buff *skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) return (skb->len / 1024 + 1) * 1024;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) /* tipc_skb_peek(): peek and reserve first buffer in list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) * @list: list to be peeked in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) * Returns pointer to first buffer in list, if any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) static inline struct sk_buff *tipc_skb_peek(struct sk_buff_head *list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) spinlock_t *lock)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) struct sk_buff *skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) spin_lock_bh(lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) skb = skb_peek(list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) if (skb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) skb_get(skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) spin_unlock_bh(lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) return skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) /* tipc_skb_peek_port(): find a destination port, ignoring all destinations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) * up to and including 'filter'.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) * Note: ignoring previously tried destinations minimizes the risk of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) * contention on the socket lock
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) * @list: list to be peeked in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) * @filter: last destination to be ignored from search
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) * Returns a destination port number, of applicable.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) static inline u32 tipc_skb_peek_port(struct sk_buff_head *list, u32 filter)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) struct sk_buff *skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) u32 dport = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) bool ignore = true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) spin_lock_bh(&list->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) skb_queue_walk(list, skb) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) dport = msg_destport(buf_msg(skb));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) if (!filter || skb_queue_is_last(list, skb))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) if (dport == filter)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) ignore = false;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) else if (!ignore)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) spin_unlock_bh(&list->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) return dport;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) /* tipc_skb_dequeue(): unlink first buffer with dest 'dport' from list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) * @list: list to be unlinked from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) * @dport: selection criteria for buffer to unlink
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) static inline struct sk_buff *tipc_skb_dequeue(struct sk_buff_head *list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) u32 dport)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) struct sk_buff *_skb, *tmp, *skb = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) spin_lock_bh(&list->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) skb_queue_walk_safe(list, _skb, tmp) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) if (msg_destport(buf_msg(_skb)) == dport) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) __skb_unlink(_skb, list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) skb = _skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) spin_unlock_bh(&list->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) return skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) /* tipc_skb_queue_splice_tail - append an skb list to lock protected list
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) * @list: the new list to append. Not lock protected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) * @head: target list. Lock protected.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) static inline void tipc_skb_queue_splice_tail(struct sk_buff_head *list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) struct sk_buff_head *head)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) spin_lock_bh(&head->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) skb_queue_splice_tail(list, head);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) spin_unlock_bh(&head->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) /* tipc_skb_queue_splice_tail_init - merge two lock protected skb lists
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) * @list: the new list to add. Lock protected. Will be reinitialized
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) * @head: target list. Lock protected.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) static inline void tipc_skb_queue_splice_tail_init(struct sk_buff_head *list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) struct sk_buff_head *head)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) struct sk_buff_head tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) __skb_queue_head_init(&tmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) spin_lock_bh(&list->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) skb_queue_splice_tail_init(list, &tmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) spin_unlock_bh(&list->lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) tipc_skb_queue_splice_tail(&tmp, head);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) /* __tipc_skb_dequeue() - dequeue the head skb according to expected seqno
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) * @list: list to be dequeued from
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) * @seqno: seqno of the expected msg
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) * returns skb dequeued from the list if its seqno is less than or equal to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) * the expected one, otherwise the skb is still hold
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) * Note: must be used with appropriate locks held only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) static inline struct sk_buff *__tipc_skb_dequeue(struct sk_buff_head *list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) u16 seqno)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) struct sk_buff *skb = skb_peek(list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) if (skb && less_eq(buf_seqno(skb), seqno)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) __skb_unlink(skb, list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) return skb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) #endif