aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAllan Stephens <Allan.Stephens@windriver.com>2011-02-23 11:44:49 -0500
committerPaul Gortmaker <paul.gortmaker@windriver.com>2011-03-13 16:35:16 -0400
commita3796f895ff2917aea331a8d40036c73452b2203 (patch)
tree38487e8b7cc5b66a815966410e8ddcdcd5f44783
parentaa8472948487432bacbd099b86e313bc16319495 (diff)
tipc: Add network address mask helper routines
Introduces a pair of helper routines that convert the network address for a TIPC node into the network address for its cluster or zone. This is a cosmetic change designed to avoid future errors caused by the incorrect use of address bitmasks, and does not alter the existing operation of TIPC. Signed-off-by: Allan Stephens <Allan.Stephens@windriver.com> Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
-rw-r--r--net/tipc/addr.c4
-rw-r--r--net/tipc/addr.h17
-rw-r--r--net/tipc/node.c2
3 files changed, 16 insertions, 7 deletions
diff --git a/net/tipc/addr.c b/net/tipc/addr.c
index 88463d9a6f12..087e399518c1 100644
--- a/net/tipc/addr.c
+++ b/net/tipc/addr.c
@@ -81,9 +81,9 @@ int tipc_in_scope(u32 domain, u32 addr)
81{ 81{
82 if (!domain || (domain == addr)) 82 if (!domain || (domain == addr))
83 return 1; 83 return 1;
84 if (domain == (addr & 0xfffff000u)) /* domain <Z.C.0> */ 84 if (domain == tipc_cluster_mask(addr)) /* domain <Z.C.0> */
85 return 1; 85 return 1;
86 if (domain == (addr & 0xff000000u)) /* domain <Z.0.0> */ 86 if (domain == tipc_zone_mask(addr)) /* domain <Z.0.0> */
87 return 1; 87 return 1;
88 return 0; 88 return 0;
89} 89}
diff --git a/net/tipc/addr.h b/net/tipc/addr.h
index 2490fadd0caf..8971aba99aea 100644
--- a/net/tipc/addr.h
+++ b/net/tipc/addr.h
@@ -37,6 +37,16 @@
37#ifndef _TIPC_ADDR_H 37#ifndef _TIPC_ADDR_H
38#define _TIPC_ADDR_H 38#define _TIPC_ADDR_H
39 39
40static inline u32 tipc_zone_mask(u32 addr)
41{
42 return addr & 0xff000000u;
43}
44
45static inline u32 tipc_cluster_mask(u32 addr)
46{
47 return addr & 0xfffff000u;
48}
49
40static inline int in_own_cluster(u32 addr) 50static inline int in_own_cluster(u32 addr)
41{ 51{
42 return !((addr ^ tipc_own_addr) >> 12); 52 return !((addr ^ tipc_own_addr) >> 12);
@@ -49,14 +59,13 @@ static inline int in_own_cluster(u32 addr)
49 * after a network hop. 59 * after a network hop.
50 */ 60 */
51 61
52static inline int addr_domain(int sc) 62static inline u32 addr_domain(u32 sc)
53{ 63{
54 if (likely(sc == TIPC_NODE_SCOPE)) 64 if (likely(sc == TIPC_NODE_SCOPE))
55 return tipc_own_addr; 65 return tipc_own_addr;
56 if (sc == TIPC_CLUSTER_SCOPE) 66 if (sc == TIPC_CLUSTER_SCOPE)
57 return tipc_addr(tipc_zone(tipc_own_addr), 67 return tipc_cluster_mask(tipc_own_addr);
58 tipc_cluster(tipc_own_addr), 0); 68 return tipc_zone_mask(tipc_own_addr);
59 return tipc_addr(tipc_zone(tipc_own_addr), 0, 0);
60} 69}
61 70
62int tipc_addr_domain_valid(u32); 71int tipc_addr_domain_valid(u32);
diff --git a/net/tipc/node.c b/net/tipc/node.c
index d040d4754e39..14f98c81d313 100644
--- a/net/tipc/node.c
+++ b/net/tipc/node.c
@@ -470,7 +470,7 @@ struct sk_buff *tipc_node_get_links(const void *req_tlv_area, int req_tlv_space)
470 470
471 /* Add TLV for broadcast link */ 471 /* Add TLV for broadcast link */
472 472
473 link_info.dest = htonl(tipc_own_addr & 0xfffff000); 473 link_info.dest = htonl(tipc_cluster_mask(tipc_own_addr));
474 link_info.up = htonl(1); 474 link_info.up = htonl(1);
475 strlcpy(link_info.str, tipc_bclink_name, TIPC_MAX_LINK_NAME); 475 strlcpy(link_info.str, tipc_bclink_name, TIPC_MAX_LINK_NAME);
476 tipc_cfg_append_tlv(buf, TIPC_TLV_LINK_INFO, &link_info, sizeof(link_info)); 476 tipc_cfg_append_tlv(buf, TIPC_TLV_LINK_INFO, &link_info, sizeof(link_info));