tipc: Reduce footprint by un-inlining address routines
[pandora-kernel.git] / net / tipc / addr.c
index eca2226..c048543 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * net/tipc/addr.c: TIPC address utility routines
- *     
+ *
  * Copyright (c) 2000-2006, Ericsson AB
  * Copyright (c) 2004-2005, Wind River Systems
  * All rights reserved.
@@ -47,15 +47,15 @@ u32 tipc_get_addr(void)
 }
 
 /**
- * addr_domain_valid - validates a network domain address
- * 
- * Accepts <Z.C.N>, <Z.C.0>, <Z.0.0>, and <0.0.0>, 
+ * tipc_addr_domain_valid - validates a network domain address
+ *
+ * Accepts <Z.C.N>, <Z.C.0>, <Z.0.0>, and <0.0.0>,
  * where Z, C, and N are non-zero and do not exceed the configured limits.
- * 
+ *
  * Returns 1 if domain address is valid, otherwise 0
  */
 
-int addr_domain_valid(u32 addr)
+int tipc_addr_domain_valid(u32 addr)
 {
        u32 n = tipc_node(addr);
        u32 c = tipc_cluster(addr);
@@ -79,16 +79,48 @@ int addr_domain_valid(u32 addr)
 }
 
 /**
- * addr_node_valid - validates a proposed network address for this node
- * 
- * Accepts <Z.C.N>, where Z, C, and N are non-zero and do not exceed 
+ * tipc_addr_node_valid - validates a proposed network address for this node
+ *
+ * Accepts <Z.C.N>, where Z, C, and N are non-zero and do not exceed
  * the configured limits.
- * 
+ *
  * Returns 1 if address can be used, otherwise 0
  */
 
-int addr_node_valid(u32 addr)
+int tipc_addr_node_valid(u32 addr)
+{
+       return (tipc_addr_domain_valid(addr) && tipc_node(addr));
+}
+
+int tipc_in_scope(u32 domain, u32 addr)
+{
+       if (!domain || (domain == addr))
+               return 1;
+       if (domain == (addr & 0xfffff000u)) /* domain <Z.C.0> */
+               return 1;
+       if (domain == (addr & 0xff000000u)) /* domain <Z.0.0> */
+               return 1;
+       return 0;
+}
+
+/**
+ * tipc_addr_scope - convert message lookup domain to a 2-bit scope value
+ */
+
+int tipc_addr_scope(u32 domain)
 {
-       return (addr_domain_valid(addr) && tipc_node(addr));
+       if (likely(!domain))
+               return TIPC_ZONE_SCOPE;
+       if (tipc_node(domain))
+               return TIPC_NODE_SCOPE;
+       if (tipc_cluster(domain))
+               return TIPC_CLUSTER_SCOPE;
+       return TIPC_ZONE_SCOPE;
 }
 
+char *tipc_addr_string_fill(char *string, u32 addr)
+{
+       snprintf(string, 16, "<%u.%u.%u>",
+                tipc_zone(addr), tipc_cluster(addr), tipc_node(addr));
+       return string;
+}