18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * net/tipc/bcast.h: Include file for TIPC broadcast code 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright (c) 2003-2006, 2014-2015, Ericsson AB 58c2ecf20Sopenharmony_ci * Copyright (c) 2005, 2010-2011, Wind River Systems 68c2ecf20Sopenharmony_ci * All rights reserved. 78c2ecf20Sopenharmony_ci * 88c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or without 98c2ecf20Sopenharmony_ci * modification, are permitted provided that the following conditions are met: 108c2ecf20Sopenharmony_ci * 118c2ecf20Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright 128c2ecf20Sopenharmony_ci * notice, this list of conditions and the following disclaimer. 138c2ecf20Sopenharmony_ci * 2. Redistributions in binary form must reproduce the above copyright 148c2ecf20Sopenharmony_ci * notice, this list of conditions and the following disclaimer in the 158c2ecf20Sopenharmony_ci * documentation and/or other materials provided with the distribution. 168c2ecf20Sopenharmony_ci * 3. Neither the names of the copyright holders nor the names of its 178c2ecf20Sopenharmony_ci * contributors may be used to endorse or promote products derived from 188c2ecf20Sopenharmony_ci * this software without specific prior written permission. 198c2ecf20Sopenharmony_ci * 208c2ecf20Sopenharmony_ci * Alternatively, this software may be distributed under the terms of the 218c2ecf20Sopenharmony_ci * GNU General Public License ("GPL") version 2 as published by the Free 228c2ecf20Sopenharmony_ci * Software Foundation. 238c2ecf20Sopenharmony_ci * 248c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 258c2ecf20Sopenharmony_ci * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 268c2ecf20Sopenharmony_ci * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 278c2ecf20Sopenharmony_ci * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 288c2ecf20Sopenharmony_ci * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 298c2ecf20Sopenharmony_ci * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 308c2ecf20Sopenharmony_ci * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 318c2ecf20Sopenharmony_ci * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 328c2ecf20Sopenharmony_ci * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 338c2ecf20Sopenharmony_ci * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 348c2ecf20Sopenharmony_ci * POSSIBILITY OF SUCH DAMAGE. 358c2ecf20Sopenharmony_ci */ 368c2ecf20Sopenharmony_ci 378c2ecf20Sopenharmony_ci#ifndef _TIPC_BCAST_H 388c2ecf20Sopenharmony_ci#define _TIPC_BCAST_H 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci#include "core.h" 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_cistruct tipc_node; 438c2ecf20Sopenharmony_cistruct tipc_msg; 448c2ecf20Sopenharmony_cistruct tipc_nl_msg; 458c2ecf20Sopenharmony_cistruct tipc_nlist; 468c2ecf20Sopenharmony_cistruct tipc_nitem; 478c2ecf20Sopenharmony_ciextern const char tipc_bclink_name[]; 488c2ecf20Sopenharmony_ciextern unsigned long sysctl_tipc_bc_retruni; 498c2ecf20Sopenharmony_ci 508c2ecf20Sopenharmony_ci#define TIPC_METHOD_EXPIRE msecs_to_jiffies(5000) 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci#define BCLINK_MODE_BCAST 0x1 538c2ecf20Sopenharmony_ci#define BCLINK_MODE_RCAST 0x2 548c2ecf20Sopenharmony_ci#define BCLINK_MODE_SEL 0x4 558c2ecf20Sopenharmony_ci 568c2ecf20Sopenharmony_cistruct tipc_nlist { 578c2ecf20Sopenharmony_ci struct list_head list; 588c2ecf20Sopenharmony_ci u32 self; 598c2ecf20Sopenharmony_ci u16 remote; 608c2ecf20Sopenharmony_ci bool local; 618c2ecf20Sopenharmony_ci}; 628c2ecf20Sopenharmony_ci 638c2ecf20Sopenharmony_civoid tipc_nlist_init(struct tipc_nlist *nl, u32 self); 648c2ecf20Sopenharmony_civoid tipc_nlist_purge(struct tipc_nlist *nl); 658c2ecf20Sopenharmony_civoid tipc_nlist_add(struct tipc_nlist *nl, u32 node); 668c2ecf20Sopenharmony_civoid tipc_nlist_del(struct tipc_nlist *nl, u32 node); 678c2ecf20Sopenharmony_ci 688c2ecf20Sopenharmony_ci/* Cookie to be used between socket and broadcast layer 698c2ecf20Sopenharmony_ci * @rcast: replicast (instead of broadcast) was used at previous xmit 708c2ecf20Sopenharmony_ci * @mandatory: broadcast/replicast indication was set by user 718c2ecf20Sopenharmony_ci * @deferredq: defer queue to make message in order 728c2ecf20Sopenharmony_ci * @expires: re-evaluate non-mandatory transmit method if we are past this 738c2ecf20Sopenharmony_ci */ 748c2ecf20Sopenharmony_cistruct tipc_mc_method { 758c2ecf20Sopenharmony_ci bool rcast; 768c2ecf20Sopenharmony_ci bool mandatory; 778c2ecf20Sopenharmony_ci struct sk_buff_head deferredq; 788c2ecf20Sopenharmony_ci unsigned long expires; 798c2ecf20Sopenharmony_ci}; 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ciint tipc_bcast_init(struct net *net); 828c2ecf20Sopenharmony_civoid tipc_bcast_stop(struct net *net); 838c2ecf20Sopenharmony_civoid tipc_bcast_add_peer(struct net *net, struct tipc_link *l, 848c2ecf20Sopenharmony_ci struct sk_buff_head *xmitq); 858c2ecf20Sopenharmony_civoid tipc_bcast_remove_peer(struct net *net, struct tipc_link *rcv_bcl); 868c2ecf20Sopenharmony_civoid tipc_bcast_inc_bearer_dst_cnt(struct net *net, int bearer_id); 878c2ecf20Sopenharmony_civoid tipc_bcast_dec_bearer_dst_cnt(struct net *net, int bearer_id); 888c2ecf20Sopenharmony_ciint tipc_bcast_get_mtu(struct net *net); 898c2ecf20Sopenharmony_civoid tipc_bcast_toggle_rcast(struct net *net, bool supp); 908c2ecf20Sopenharmony_ciint tipc_mcast_xmit(struct net *net, struct sk_buff_head *pkts, 918c2ecf20Sopenharmony_ci struct tipc_mc_method *method, struct tipc_nlist *dests, 928c2ecf20Sopenharmony_ci u16 *cong_link_cnt); 938c2ecf20Sopenharmony_ciint tipc_bcast_xmit(struct net *net, struct sk_buff_head *pkts, 948c2ecf20Sopenharmony_ci u16 *cong_link_cnt); 958c2ecf20Sopenharmony_ciint tipc_bcast_rcv(struct net *net, struct tipc_link *l, struct sk_buff *skb); 968c2ecf20Sopenharmony_civoid tipc_bcast_ack_rcv(struct net *net, struct tipc_link *l, 978c2ecf20Sopenharmony_ci struct tipc_msg *hdr); 988c2ecf20Sopenharmony_ciint tipc_bcast_sync_rcv(struct net *net, struct tipc_link *l, 998c2ecf20Sopenharmony_ci struct tipc_msg *hdr, 1008c2ecf20Sopenharmony_ci struct sk_buff_head *retrq); 1018c2ecf20Sopenharmony_ciint tipc_nl_add_bc_link(struct net *net, struct tipc_nl_msg *msg, 1028c2ecf20Sopenharmony_ci struct tipc_link *bcl); 1038c2ecf20Sopenharmony_ciint tipc_nl_bc_link_set(struct net *net, struct nlattr *attrs[]); 1048c2ecf20Sopenharmony_ciint tipc_bclink_reset_stats(struct net *net, struct tipc_link *l); 1058c2ecf20Sopenharmony_ci 1068c2ecf20Sopenharmony_ciu32 tipc_bcast_get_mode(struct net *net); 1078c2ecf20Sopenharmony_ciu32 tipc_bcast_get_broadcast_ratio(struct net *net); 1088c2ecf20Sopenharmony_ci 1098c2ecf20Sopenharmony_civoid tipc_mcast_filter_msg(struct net *net, struct sk_buff_head *defq, 1108c2ecf20Sopenharmony_ci struct sk_buff_head *inputq); 1118c2ecf20Sopenharmony_ci 1128c2ecf20Sopenharmony_cistatic inline void tipc_bcast_lock(struct net *net) 1138c2ecf20Sopenharmony_ci{ 1148c2ecf20Sopenharmony_ci spin_lock_bh(&tipc_net(net)->bclock); 1158c2ecf20Sopenharmony_ci} 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_cistatic inline void tipc_bcast_unlock(struct net *net) 1188c2ecf20Sopenharmony_ci{ 1198c2ecf20Sopenharmony_ci spin_unlock_bh(&tipc_net(net)->bclock); 1208c2ecf20Sopenharmony_ci} 1218c2ecf20Sopenharmony_ci 1228c2ecf20Sopenharmony_cistatic inline struct tipc_link *tipc_bc_sndlink(struct net *net) 1238c2ecf20Sopenharmony_ci{ 1248c2ecf20Sopenharmony_ci return tipc_net(net)->bcl; 1258c2ecf20Sopenharmony_ci} 1268c2ecf20Sopenharmony_ci 1278c2ecf20Sopenharmony_ci#endif 128