diff options
author | Allan Stephens <allan.stephens@windriver.com> | 2012-04-17 18:02:01 -0400 |
---|---|---|
committer | Paul Gortmaker <paul.gortmaker@windriver.com> | 2012-04-19 15:46:39 -0400 |
commit | 336ebf5bf524e447227cb1d785b22ca722e6afa7 (patch) | |
tree | 72e72c183cf43ccfbb756a7866c8b3cf90eb6781 /net/tipc/addr.h | |
parent | fd6eced8a482986784eb1f3aa0838dbdd725e71c (diff) |
tipc: Add routines for safe checking of node's network address
Introduces routines that test whether a given network address is
equal to a node's own network address or if it lies within the node's
own network cluster, and which work properly regardless of whether
the node is using the default network address <0.0.0> or a non-zero
network address that is assigned later on. In essence, these routines
ensure that address <0.0.0> is treated as an alias for "this node",
regardless of which network address the node is actually using.
Old users of the pre-existing more strict match in_own_cluster()
have been accordingly redirected to what is now called
in_own_cluster_exact() --- which does not extend matching to <0,0,0>.
Signed-off-by: Allan Stephens <allan.stephens@windriver.com>
Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Diffstat (limited to 'net/tipc/addr.h')
-rw-r--r-- | net/tipc/addr.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/net/tipc/addr.h b/net/tipc/addr.h index e4f35afe3207..d706a1d92be8 100644 --- a/net/tipc/addr.h +++ b/net/tipc/addr.h | |||
@@ -50,12 +50,30 @@ static inline u32 tipc_cluster_mask(u32 addr) | |||
50 | return addr & TIPC_CLUSTER_MASK; | 50 | return addr & TIPC_CLUSTER_MASK; |
51 | } | 51 | } |
52 | 52 | ||
53 | static inline int in_own_cluster(u32 addr) | 53 | static inline int in_own_cluster_exact(u32 addr) |
54 | { | 54 | { |
55 | return !((addr ^ tipc_own_addr) >> 12); | 55 | return !((addr ^ tipc_own_addr) >> 12); |
56 | } | 56 | } |
57 | 57 | ||
58 | /** | 58 | /** |
59 | * in_own_node - test for node inclusion; <0.0.0> always matches | ||
60 | */ | ||
61 | |||
62 | static inline int in_own_node(u32 addr) | ||
63 | { | ||
64 | return (addr == tipc_own_addr) || !addr; | ||
65 | } | ||
66 | |||
67 | /** | ||
68 | * in_own_cluster - test for cluster inclusion; <0.0.0> always matches | ||
69 | */ | ||
70 | |||
71 | static inline int in_own_cluster(u32 addr) | ||
72 | { | ||
73 | return in_own_cluster_exact(addr) || !addr; | ||
74 | } | ||
75 | |||
76 | /** | ||
59 | * addr_domain - convert 2-bit scope value to equivalent message lookup domain | 77 | * addr_domain - convert 2-bit scope value to equivalent message lookup domain |
60 | * | 78 | * |
61 | * Needed when address of a named message must be looked up a second time | 79 | * Needed when address of a named message must be looked up a second time |