^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * net/tipc/bcast.h: Include file for TIPC broadcast code
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (c) 2003-2006, 2014-2015, Ericsson AB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (c) 2005, 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_BCAST_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #define _TIPC_BCAST_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #include "core.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) struct tipc_node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) struct tipc_msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) struct tipc_nl_msg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) struct tipc_nlist;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) struct tipc_nitem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) extern const char tipc_bclink_name[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) extern unsigned long sysctl_tipc_bc_retruni;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) #define TIPC_METHOD_EXPIRE msecs_to_jiffies(5000)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) #define BCLINK_MODE_BCAST 0x1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) #define BCLINK_MODE_RCAST 0x2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) #define BCLINK_MODE_SEL 0x4
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) struct tipc_nlist {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) struct list_head list;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) u32 self;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) u16 remote;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) bool local;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) void tipc_nlist_init(struct tipc_nlist *nl, u32 self);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) void tipc_nlist_purge(struct tipc_nlist *nl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) void tipc_nlist_add(struct tipc_nlist *nl, u32 node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) void tipc_nlist_del(struct tipc_nlist *nl, u32 node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) /* Cookie to be used between socket and broadcast layer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) * @rcast: replicast (instead of broadcast) was used at previous xmit
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) * @mandatory: broadcast/replicast indication was set by user
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) * @deferredq: defer queue to make message in order
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) * @expires: re-evaluate non-mandatory transmit method if we are past this
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) struct tipc_mc_method {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) bool rcast;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) bool mandatory;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) struct sk_buff_head deferredq;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) unsigned long expires;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) int tipc_bcast_init(struct net *net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) void tipc_bcast_stop(struct net *net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) void tipc_bcast_add_peer(struct net *net, struct tipc_link *l,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) struct sk_buff_head *xmitq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) void tipc_bcast_remove_peer(struct net *net, struct tipc_link *rcv_bcl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) void tipc_bcast_inc_bearer_dst_cnt(struct net *net, int bearer_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) void tipc_bcast_dec_bearer_dst_cnt(struct net *net, int bearer_id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) int tipc_bcast_get_mtu(struct net *net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) void tipc_bcast_toggle_rcast(struct net *net, bool supp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) int tipc_mcast_xmit(struct net *net, struct sk_buff_head *pkts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) struct tipc_mc_method *method, struct tipc_nlist *dests,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) u16 *cong_link_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) int tipc_bcast_xmit(struct net *net, struct sk_buff_head *pkts,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) u16 *cong_link_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) int tipc_bcast_rcv(struct net *net, struct tipc_link *l, struct sk_buff *skb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) void tipc_bcast_ack_rcv(struct net *net, struct tipc_link *l,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) struct tipc_msg *hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) int tipc_bcast_sync_rcv(struct net *net, struct tipc_link *l,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) struct tipc_msg *hdr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) struct sk_buff_head *retrq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) int tipc_nl_add_bc_link(struct net *net, struct tipc_nl_msg *msg,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) struct tipc_link *bcl);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) int tipc_nl_bc_link_set(struct net *net, struct nlattr *attrs[]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) int tipc_bclink_reset_stats(struct net *net, struct tipc_link *l);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) u32 tipc_bcast_get_mode(struct net *net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) u32 tipc_bcast_get_broadcast_ratio(struct net *net);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) void tipc_mcast_filter_msg(struct net *net, struct sk_buff_head *defq,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) struct sk_buff_head *inputq);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) static inline void tipc_bcast_lock(struct net *net)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) spin_lock_bh(&tipc_net(net)->bclock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) static inline void tipc_bcast_unlock(struct net *net)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) spin_unlock_bh(&tipc_net(net)->bclock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) static inline struct tipc_link *tipc_bc_sndlink(struct net *net)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) return tipc_net(net)->bcl;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) #endif