diff options
Diffstat (limited to 'net/tipc/addr.c')
-rw-r--r-- | net/tipc/addr.c | 45 |
1 files changed, 44 insertions, 1 deletions
diff --git a/net/tipc/addr.c b/net/tipc/addr.c index 357b74b26f9e..48fd3b5a73fb 100644 --- a/net/tipc/addr.c +++ b/net/tipc/addr.c | |||
@@ -34,8 +34,51 @@ | |||
34 | * POSSIBILITY OF SUCH DAMAGE. | 34 | * POSSIBILITY OF SUCH DAMAGE. |
35 | */ | 35 | */ |
36 | 36 | ||
37 | #include "core.h" | 37 | #include <linux/kernel.h> |
38 | #include "addr.h" | 38 | #include "addr.h" |
39 | #include "core.h" | ||
40 | |||
41 | /** | ||
42 | * in_own_cluster - test for cluster inclusion; <0.0.0> always matches | ||
43 | */ | ||
44 | int in_own_cluster(struct net *net, u32 addr) | ||
45 | { | ||
46 | return in_own_cluster_exact(net, addr) || !addr; | ||
47 | } | ||
48 | |||
49 | int in_own_cluster_exact(struct net *net, u32 addr) | ||
50 | { | ||
51 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
52 | |||
53 | return !((addr ^ tn->own_addr) >> 12); | ||
54 | } | ||
55 | |||
56 | /** | ||
57 | * in_own_node - test for node inclusion; <0.0.0> always matches | ||
58 | */ | ||
59 | int in_own_node(struct net *net, u32 addr) | ||
60 | { | ||
61 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
62 | |||
63 | return (addr == tn->own_addr) || !addr; | ||
64 | } | ||
65 | |||
66 | /** | ||
67 | * addr_domain - convert 2-bit scope value to equivalent message lookup domain | ||
68 | * | ||
69 | * Needed when address of a named message must be looked up a second time | ||
70 | * after a network hop. | ||
71 | */ | ||
72 | u32 addr_domain(struct net *net, u32 sc) | ||
73 | { | ||
74 | struct tipc_net *tn = net_generic(net, tipc_net_id); | ||
75 | |||
76 | if (likely(sc == TIPC_NODE_SCOPE)) | ||
77 | return tn->own_addr; | ||
78 | if (sc == TIPC_CLUSTER_SCOPE) | ||
79 | return tipc_cluster_mask(tn->own_addr); | ||
80 | return tipc_zone_mask(tn->own_addr); | ||
81 | } | ||
39 | 82 | ||
40 | /** | 83 | /** |
41 | * tipc_addr_domain_valid - validates a network domain address | 84 | * tipc_addr_domain_valid - validates a network domain address |