Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * net/tipc/bcast.h: Include file for TIPC broadcast code
0003  *
0004  * Copyright (c) 2003-2006, 2014-2015, Ericsson AB
0005  * Copyright (c) 2005, 2010-2011, Wind River Systems
0006  * All rights reserved.
0007  *
0008  * Redistribution and use in source and binary forms, with or without
0009  * modification, are permitted provided that the following conditions are met:
0010  *
0011  * 1. Redistributions of source code must retain the above copyright
0012  *    notice, this list of conditions and the following disclaimer.
0013  * 2. Redistributions in binary form must reproduce the above copyright
0014  *    notice, this list of conditions and the following disclaimer in the
0015  *    documentation and/or other materials provided with the distribution.
0016  * 3. Neither the names of the copyright holders nor the names of its
0017  *    contributors may be used to endorse or promote products derived from
0018  *    this software without specific prior written permission.
0019  *
0020  * Alternatively, this software may be distributed under the terms of the
0021  * GNU General Public License ("GPL") version 2 as published by the Free
0022  * Software Foundation.
0023  *
0024  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0025  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0026  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0027  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0028  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0029  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0030  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0031  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0032  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0033  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0034  * POSSIBILITY OF SUCH DAMAGE.
0035  */
0036 
0037 #ifndef _TIPC_BCAST_H
0038 #define _TIPC_BCAST_H
0039 
0040 #include "core.h"
0041 
0042 struct tipc_node;
0043 struct tipc_msg;
0044 struct tipc_nl_msg;
0045 struct tipc_nlist;
0046 struct tipc_nitem;
0047 extern const char tipc_bclink_name[];
0048 extern unsigned long sysctl_tipc_bc_retruni;
0049 
0050 #define TIPC_METHOD_EXPIRE msecs_to_jiffies(5000)
0051 
0052 #define BCLINK_MODE_BCAST  0x1
0053 #define BCLINK_MODE_RCAST  0x2
0054 #define BCLINK_MODE_SEL    0x4
0055 
0056 struct tipc_nlist {
0057     struct list_head list;
0058     u32 self;
0059     u16 remote;
0060     bool local;
0061 };
0062 
0063 void tipc_nlist_init(struct tipc_nlist *nl, u32 self);
0064 void tipc_nlist_purge(struct tipc_nlist *nl);
0065 void tipc_nlist_add(struct tipc_nlist *nl, u32 node);
0066 void tipc_nlist_del(struct tipc_nlist *nl, u32 node);
0067 
0068 /* Cookie to be used between socket and broadcast layer
0069  * @rcast: replicast (instead of broadcast) was used at previous xmit
0070  * @mandatory: broadcast/replicast indication was set by user
0071  * @deferredq: defer queue to make message in order
0072  * @expires: re-evaluate non-mandatory transmit method if we are past this
0073  */
0074 struct tipc_mc_method {
0075     bool rcast;
0076     bool mandatory;
0077     struct sk_buff_head deferredq;
0078     unsigned long expires;
0079 };
0080 
0081 int tipc_bcast_init(struct net *net);
0082 void tipc_bcast_stop(struct net *net);
0083 void tipc_bcast_add_peer(struct net *net, struct tipc_link *l,
0084              struct sk_buff_head *xmitq);
0085 void tipc_bcast_remove_peer(struct net *net, struct tipc_link *rcv_bcl);
0086 void tipc_bcast_inc_bearer_dst_cnt(struct net *net, int bearer_id);
0087 void tipc_bcast_dec_bearer_dst_cnt(struct net *net, int bearer_id);
0088 int  tipc_bcast_get_mtu(struct net *net);
0089 void tipc_bcast_toggle_rcast(struct net *net, bool supp);
0090 int tipc_mcast_xmit(struct net *net, struct sk_buff_head *pkts,
0091             struct tipc_mc_method *method, struct tipc_nlist *dests,
0092             u16 *cong_link_cnt);
0093 int tipc_bcast_xmit(struct net *net, struct sk_buff_head *pkts,
0094             u16 *cong_link_cnt);
0095 int tipc_bcast_rcv(struct net *net, struct tipc_link *l, struct sk_buff *skb);
0096 void tipc_bcast_ack_rcv(struct net *net, struct tipc_link *l,
0097             struct tipc_msg *hdr);
0098 int tipc_bcast_sync_rcv(struct net *net, struct tipc_link *l,
0099             struct tipc_msg *hdr,
0100             struct sk_buff_head *retrq);
0101 int tipc_nl_add_bc_link(struct net *net, struct tipc_nl_msg *msg,
0102             struct tipc_link *bcl);
0103 int tipc_nl_bc_link_set(struct net *net, struct nlattr *attrs[]);
0104 int tipc_bclink_reset_stats(struct net *net, struct tipc_link *l);
0105 
0106 u32 tipc_bcast_get_mode(struct net *net);
0107 u32 tipc_bcast_get_broadcast_ratio(struct net *net);
0108 
0109 void tipc_mcast_filter_msg(struct net *net, struct sk_buff_head *defq,
0110                struct sk_buff_head *inputq);
0111 
0112 static inline void tipc_bcast_lock(struct net *net)
0113 {
0114     spin_lock_bh(&tipc_net(net)->bclock);
0115 }
0116 
0117 static inline void tipc_bcast_unlock(struct net *net)
0118 {
0119     spin_unlock_bh(&tipc_net(net)->bclock);
0120 }
0121 
0122 static inline struct tipc_link *tipc_bc_sndlink(struct net *net)
0123 {
0124     return tipc_net(net)->bcl;
0125 }
0126 
0127 #endif