18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * net/tipc/name_table.h: Include file for TIPC name table code 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright (c) 2000-2006, 2014-2018, Ericsson AB 58c2ecf20Sopenharmony_ci * Copyright (c) 2004-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_NAME_TABLE_H 388c2ecf20Sopenharmony_ci#define _TIPC_NAME_TABLE_H 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_cistruct tipc_subscription; 418c2ecf20Sopenharmony_cistruct tipc_plist; 428c2ecf20Sopenharmony_cistruct tipc_nlist; 438c2ecf20Sopenharmony_cistruct tipc_group; 448c2ecf20Sopenharmony_ci 458c2ecf20Sopenharmony_ci/* 468c2ecf20Sopenharmony_ci * TIPC name types reserved for internal TIPC use (both current and planned) 478c2ecf20Sopenharmony_ci */ 488c2ecf20Sopenharmony_ci#define TIPC_ZM_SRV 3 /* zone master service name type */ 498c2ecf20Sopenharmony_ci#define TIPC_PUBL_SCOPE_NUM (TIPC_NODE_SCOPE + 1) 508c2ecf20Sopenharmony_ci#define TIPC_NAMETBL_SIZE 1024 /* must be a power of 2 */ 518c2ecf20Sopenharmony_ci 528c2ecf20Sopenharmony_ci/** 538c2ecf20Sopenharmony_ci * struct publication - info about a published (name or) name sequence 548c2ecf20Sopenharmony_ci * @type: name sequence type 558c2ecf20Sopenharmony_ci * @lower: name sequence lower bound 568c2ecf20Sopenharmony_ci * @upper: name sequence upper bound 578c2ecf20Sopenharmony_ci * @scope: scope of publication, TIPC_NODE_SCOPE or TIPC_CLUSTER_SCOPE 588c2ecf20Sopenharmony_ci * @node: network address of publishing socket's node 598c2ecf20Sopenharmony_ci * @port: publishing port 608c2ecf20Sopenharmony_ci * @key: publication key, unique across the cluster 618c2ecf20Sopenharmony_ci * @id: publication id 628c2ecf20Sopenharmony_ci * @binding_node: all publications from the same node which bound this one 638c2ecf20Sopenharmony_ci * - Remote publications: in node->publ_list; 648c2ecf20Sopenharmony_ci * Used by node/name distr to withdraw publications when node is lost 658c2ecf20Sopenharmony_ci * - Local/node scope publications: in name_table->node_scope list 668c2ecf20Sopenharmony_ci * - Local/cluster scope publications: in name_table->cluster_scope list 678c2ecf20Sopenharmony_ci * @binding_sock: all publications from the same socket which bound this one 688c2ecf20Sopenharmony_ci * Used by socket to withdraw publications when socket is unbound/released 698c2ecf20Sopenharmony_ci * @local_publ: list of identical publications made from this node 708c2ecf20Sopenharmony_ci * Used by closest_first and multicast receive lookup algorithms 718c2ecf20Sopenharmony_ci * @all_publ: all publications identical to this one, whatever node and scope 728c2ecf20Sopenharmony_ci * Used by round-robin lookup algorithm 738c2ecf20Sopenharmony_ci * @list: to form a list of publications in temporal order 748c2ecf20Sopenharmony_ci * @rcu: RCU callback head used for deferred freeing 758c2ecf20Sopenharmony_ci */ 768c2ecf20Sopenharmony_cistruct publication { 778c2ecf20Sopenharmony_ci u32 type; 788c2ecf20Sopenharmony_ci u32 lower; 798c2ecf20Sopenharmony_ci u32 upper; 808c2ecf20Sopenharmony_ci u32 scope; 818c2ecf20Sopenharmony_ci u32 node; 828c2ecf20Sopenharmony_ci u32 port; 838c2ecf20Sopenharmony_ci u32 key; 848c2ecf20Sopenharmony_ci u32 id; 858c2ecf20Sopenharmony_ci struct list_head binding_node; 868c2ecf20Sopenharmony_ci struct list_head binding_sock; 878c2ecf20Sopenharmony_ci struct list_head local_publ; 888c2ecf20Sopenharmony_ci struct list_head all_publ; 898c2ecf20Sopenharmony_ci struct list_head list; 908c2ecf20Sopenharmony_ci struct rcu_head rcu; 918c2ecf20Sopenharmony_ci}; 928c2ecf20Sopenharmony_ci 938c2ecf20Sopenharmony_ci/** 948c2ecf20Sopenharmony_ci * struct name_table - table containing all existing port name publications 958c2ecf20Sopenharmony_ci * @services: name sequence hash lists 968c2ecf20Sopenharmony_ci * @node_scope: all local publications with node scope 978c2ecf20Sopenharmony_ci * - used by name_distr during re-init of name table 988c2ecf20Sopenharmony_ci * @cluster_scope: all local publications with cluster scope 998c2ecf20Sopenharmony_ci * - used by name_distr to send bulk updates to new nodes 1008c2ecf20Sopenharmony_ci * - used by name_distr during re-init of name table 1018c2ecf20Sopenharmony_ci * @cluster_scope_lock: lock for accessing @cluster_scope 1028c2ecf20Sopenharmony_ci * @local_publ_count: number of publications issued by this node 1038c2ecf20Sopenharmony_ci * @rc_dests: destination node counter 1048c2ecf20Sopenharmony_ci * @snd_nxt: next sequence number to be used 1058c2ecf20Sopenharmony_ci */ 1068c2ecf20Sopenharmony_cistruct name_table { 1078c2ecf20Sopenharmony_ci struct hlist_head services[TIPC_NAMETBL_SIZE]; 1088c2ecf20Sopenharmony_ci struct list_head node_scope; 1098c2ecf20Sopenharmony_ci struct list_head cluster_scope; 1108c2ecf20Sopenharmony_ci rwlock_t cluster_scope_lock; 1118c2ecf20Sopenharmony_ci u32 local_publ_count; 1128c2ecf20Sopenharmony_ci u32 rc_dests; 1138c2ecf20Sopenharmony_ci u32 snd_nxt; 1148c2ecf20Sopenharmony_ci}; 1158c2ecf20Sopenharmony_ci 1168c2ecf20Sopenharmony_ciint tipc_nl_name_table_dump(struct sk_buff *skb, struct netlink_callback *cb); 1178c2ecf20Sopenharmony_ci 1188c2ecf20Sopenharmony_ciu32 tipc_nametbl_translate(struct net *net, u32 type, u32 instance, u32 *node); 1198c2ecf20Sopenharmony_civoid tipc_nametbl_mc_lookup(struct net *net, u32 type, u32 lower, u32 upper, 1208c2ecf20Sopenharmony_ci u32 scope, bool exact, struct list_head *dports); 1218c2ecf20Sopenharmony_civoid tipc_nametbl_build_group(struct net *net, struct tipc_group *grp, 1228c2ecf20Sopenharmony_ci u32 type, u32 domain); 1238c2ecf20Sopenharmony_civoid tipc_nametbl_lookup_dst_nodes(struct net *net, u32 type, u32 lower, 1248c2ecf20Sopenharmony_ci u32 upper, struct tipc_nlist *nodes); 1258c2ecf20Sopenharmony_cibool tipc_nametbl_lookup(struct net *net, u32 type, u32 instance, u32 domain, 1268c2ecf20Sopenharmony_ci struct list_head *dsts, int *dstcnt, u32 exclude, 1278c2ecf20Sopenharmony_ci bool all); 1288c2ecf20Sopenharmony_cistruct publication *tipc_nametbl_publish(struct net *net, u32 type, u32 lower, 1298c2ecf20Sopenharmony_ci u32 upper, u32 scope, u32 port, 1308c2ecf20Sopenharmony_ci u32 key); 1318c2ecf20Sopenharmony_ciint tipc_nametbl_withdraw(struct net *net, u32 type, u32 lower, u32 upper, 1328c2ecf20Sopenharmony_ci u32 key); 1338c2ecf20Sopenharmony_cistruct publication *tipc_nametbl_insert_publ(struct net *net, u32 type, 1348c2ecf20Sopenharmony_ci u32 lower, u32 upper, u32 scope, 1358c2ecf20Sopenharmony_ci u32 node, u32 ref, u32 key); 1368c2ecf20Sopenharmony_cistruct publication *tipc_nametbl_remove_publ(struct net *net, u32 type, 1378c2ecf20Sopenharmony_ci u32 lower, u32 upper, 1388c2ecf20Sopenharmony_ci u32 node, u32 key); 1398c2ecf20Sopenharmony_cibool tipc_nametbl_subscribe(struct tipc_subscription *s); 1408c2ecf20Sopenharmony_civoid tipc_nametbl_unsubscribe(struct tipc_subscription *s); 1418c2ecf20Sopenharmony_ciint tipc_nametbl_init(struct net *net); 1428c2ecf20Sopenharmony_civoid tipc_nametbl_stop(struct net *net); 1438c2ecf20Sopenharmony_ci 1448c2ecf20Sopenharmony_cistruct tipc_dest { 1458c2ecf20Sopenharmony_ci struct list_head list; 1468c2ecf20Sopenharmony_ci u32 port; 1478c2ecf20Sopenharmony_ci u32 node; 1488c2ecf20Sopenharmony_ci}; 1498c2ecf20Sopenharmony_ci 1508c2ecf20Sopenharmony_cistruct tipc_dest *tipc_dest_find(struct list_head *l, u32 node, u32 port); 1518c2ecf20Sopenharmony_cibool tipc_dest_push(struct list_head *l, u32 node, u32 port); 1528c2ecf20Sopenharmony_cibool tipc_dest_pop(struct list_head *l, u32 *node, u32 *port); 1538c2ecf20Sopenharmony_cibool tipc_dest_del(struct list_head *l, u32 node, u32 port); 1548c2ecf20Sopenharmony_civoid tipc_dest_list_purge(struct list_head *l); 1558c2ecf20Sopenharmony_ciint tipc_dest_list_len(struct list_head *l); 1568c2ecf20Sopenharmony_ci 1578c2ecf20Sopenharmony_ci#endif 158