]> git.karo-electronics.de Git - linux-beck.git/blobdiff - net/tipc/addr.c
Merge tag 'cris-for-3.20' of git://git.kernel.org/pub/scm/linux/kernel/git/jesper...
[linux-beck.git] / net / tipc / addr.c
index 357b74b26f9e9d513d18797fd77834e00be1e12e..48fd3b5a73fbaf934178c444cbba07aa1a0f5b8c 100644 (file)
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
-#include "core.h"
+#include <linux/kernel.h>
 #include "addr.h"
+#include "core.h"
+
+/**
+ * in_own_cluster - test for cluster inclusion; <0.0.0> always matches
+ */
+int in_own_cluster(struct net *net, u32 addr)
+{
+       return in_own_cluster_exact(net, addr) || !addr;
+}
+
+int in_own_cluster_exact(struct net *net, u32 addr)
+{
+       struct tipc_net *tn = net_generic(net, tipc_net_id);
+
+       return !((addr ^ tn->own_addr) >> 12);
+}
+
+/**
+ * in_own_node - test for node inclusion; <0.0.0> always matches
+ */
+int in_own_node(struct net *net, u32 addr)
+{
+       struct tipc_net *tn = net_generic(net, tipc_net_id);
+
+       return (addr == tn->own_addr) || !addr;
+}
+
+/**
+ * addr_domain - convert 2-bit scope value to equivalent message lookup domain
+ *
+ * Needed when address of a named message must be looked up a second time
+ * after a network hop.
+ */
+u32 addr_domain(struct net *net, u32 sc)
+{
+       struct tipc_net *tn = net_generic(net, tipc_net_id);
+
+       if (likely(sc == TIPC_NODE_SCOPE))
+               return tn->own_addr;
+       if (sc == TIPC_CLUSTER_SCOPE)
+               return tipc_cluster_mask(tn->own_addr);
+       return tipc_zone_mask(tn->own_addr);
+}
 
 /**
  * tipc_addr_domain_valid - validates a network domain address