History

tipc: introduce constants for tipc address validation

In this commit, we introduce defines for tipc address size, offset and mask specification for Zone.Cluster.Node. There is no functional change in this commit.

Parthasarathy Bhuvaragan committed 10 years ago

Commit 9ff26e91 parent d1c2b503 files · +29 −10Browse files

Showing the changes to include/uapi (1 of 3 files). Show all

Unified · Split

include/uapi/linux/tipc.h+26−4
@@ -60,26 +60,48 @@ struct tipc_name_seq { · 59 unmodified lines
60 __u32 upper;60 __u32 upper;
61};61};
62 62
63/* TIPC Address Size, Offset, Mask specification for Z.C.N
64 */
65#define TIPC_NODE_BITS 12
66#define TIPC_CLUSTER_BITS 12
67#define TIPC_ZONE_BITS 8
68
69#define TIPC_NODE_OFFSET 0
70#define TIPC_CLUSTER_OFFSET TIPC_NODE_BITS
71#define TIPC_ZONE_OFFSET (TIPC_CLUSTER_OFFSET + TIPC_CLUSTER_BITS)
72
73#define TIPC_NODE_SIZE ((1UL << TIPC_NODE_BITS) - 1)
74#define TIPC_CLUSTER_SIZE ((1UL << TIPC_CLUSTER_BITS) - 1)
75#define TIPC_ZONE_SIZE ((1UL << TIPC_ZONE_BITS) - 1)
76
77#define TIPC_NODE_MASK (TIPC_NODE_SIZE << TIPC_NODE_OFFSET)
78#define TIPC_CLUSTER_MASK (TIPC_CLUSTER_SIZE << TIPC_CLUSTER_OFFSET)
79#define TIPC_ZONE_MASK (TIPC_ZONE_SIZE << TIPC_ZONE_OFFSET)
80
81#define TIPC_ZONE_CLUSTER_MASK (TIPC_ZONE_MASK | TIPC_CLUSTER_MASK)
82
63static inline __u32 tipc_addr(unsigned int zone,83static inline __u32 tipc_addr(unsigned int zone,
64 unsigned int cluster,84 unsigned int cluster,
65 unsigned int node)85 unsigned int node)
66{86{
67 return (zone << 24) | (cluster << 12) | node;87 return (zone << TIPC_ZONE_OFFSET) |
88 (cluster << TIPC_CLUSTER_OFFSET) |
89 node;
68}90}
69 91
70static inline unsigned int tipc_zone(__u32 addr)92static inline unsigned int tipc_zone(__u32 addr)
71{93{
72 return addr >> 24;94 return addr >> TIPC_ZONE_OFFSET;
73}95}
74 96
75static inline unsigned int tipc_cluster(__u32 addr)97static inline unsigned int tipc_cluster(__u32 addr)
76{98{
77 return (addr >> 12) & 0xfff;99 return (addr & TIPC_CLUSTER_MASK) >> TIPC_CLUSTER_OFFSET;
78}100}
79 101
80static inline unsigned int tipc_node(__u32 addr)102static inline unsigned int tipc_node(__u32 addr)
81{103{
82 return addr & 0xfff;104 return addr & TIPC_NODE_MASK;
83}105}
84 106
85/*107/*

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t