aboutsummaryrefslogtreecommitdiffstats
path: root/net/tipc/addr.h
diff options
context:
space:
mode:
Diffstat (limited to 'net/tipc/addr.h')
-rw-r--r--net/tipc/addr.h45
1 files changed, 8 insertions, 37 deletions
diff --git a/net/tipc/addr.h b/net/tipc/addr.h
index a74acf9ee804..c700c2d28e09 100644
--- a/net/tipc/addr.h
+++ b/net/tipc/addr.h
@@ -37,7 +37,10 @@
37#ifndef _TIPC_ADDR_H 37#ifndef _TIPC_ADDR_H
38#define _TIPC_ADDR_H 38#define _TIPC_ADDR_H
39 39
40#include "core.h" 40#include <linux/types.h>
41#include <linux/tipc.h>
42#include <net/net_namespace.h>
43#include <net/netns/generic.h>
41 44
42#define TIPC_ZONE_MASK 0xff000000u 45#define TIPC_ZONE_MASK 0xff000000u
43#define TIPC_CLUSTER_MASK 0xfffff000u 46#define TIPC_CLUSTER_MASK 0xfffff000u
@@ -52,42 +55,10 @@ static inline u32 tipc_cluster_mask(u32 addr)
52 return addr & TIPC_CLUSTER_MASK; 55 return addr & TIPC_CLUSTER_MASK;
53} 56}
54 57
55static inline int in_own_cluster_exact(u32 addr) 58int in_own_cluster(struct net *net, u32 addr);
56{ 59int in_own_cluster_exact(struct net *net, u32 addr);
57 return !((addr ^ tipc_own_addr) >> 12); 60int in_own_node(struct net *net, u32 addr);
58} 61u32 addr_domain(struct net *net, u32 sc);
59
60/**
61 * in_own_node - test for node inclusion; <0.0.0> always matches
62 */
63static inline int in_own_node(u32 addr)
64{
65 return (addr == tipc_own_addr) || !addr;
66}
67
68/**
69 * in_own_cluster - test for cluster inclusion; <0.0.0> always matches
70 */
71static inline int in_own_cluster(u32 addr)
72{
73 return in_own_cluster_exact(addr) || !addr;
74}
75
76/**
77 * addr_domain - convert 2-bit scope value to equivalent message lookup domain
78 *
79 * Needed when address of a named message must be looked up a second time
80 * after a network hop.
81 */
82static inline u32 addr_domain(u32 sc)
83{
84 if (likely(sc == TIPC_NODE_SCOPE))
85 return tipc_own_addr;
86 if (sc == TIPC_CLUSTER_SCOPE)
87 return tipc_cluster_mask(tipc_own_addr);
88 return tipc_zone_mask(tipc_own_addr);
89}
90
91int tipc_addr_domain_valid(u32); 62int tipc_addr_domain_valid(u32);
92int tipc_addr_node_valid(u32 addr); 63int tipc_addr_node_valid(u32 addr);
93int tipc_in_scope(u32 domain, u32 addr); 64int tipc_in_scope(u32 domain, u32 addr);