2 * net/tipc/node.h: Include file for TIPC node management routines
4 * Copyright (c) 2003-2005, Ericsson Research Canada
5 * Copyright (c) 2005, Wind River Systems
6 * Copyright (c) 2005-2006, Ericsson AB
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions are met:
12 * Redistributions of source code must retain the above copyright notice, this
13 * list of conditions and the following disclaimer.
14 * Redistributions in binary form must reproduce the above copyright notice,
15 * this list of conditions and the following disclaimer in the documentation
16 * and/or other materials provided with the distribution.
17 * Neither the names of the copyright holders nor the names of its
18 * contributors may be used to endorse or promote products derived from this
19 * software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
25 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
26 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
27 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
29 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31 * POSSIBILITY OF SUCH DAMAGE.
37 #include "node_subscr.h"
43 * struct node - TIPC node structure
44 * @addr: network address of node
45 * @lock: spinlock governing access to structure
46 * @owner: pointer to cluster that node belongs to
47 * @next: pointer to next node in sorted list of cluster's nodes
48 * @nsub: list of "node down" subscriptions monitoring node
49 * @active_links: pointers to active links to node
50 * @links: pointers to all links to node
51 * @link_cnt: number of links to node
52 * @permit_changeover: non-zero if node has redundant links to this system
53 * @routers: bitmap (used for multicluster communication)
54 * @last_router: (used for multicluster communication)
55 * @bclink: broadcast-related info
56 * @supported: non-zero if node supports TIPC b'cast capability
57 * @acked: sequence # of last outbound b'cast message acknowledged by node
58 * @last_in: sequence # of last in-sequence b'cast message received from node
59 * @gap_after: sequence # of last message not requiring a NAK request
60 * @gap_to: sequence # of last message requiring a NAK request
61 * @nack_sync: counter that determines when NAK requests should be sent
62 * @deferred_head: oldest OOS b'cast message received from node
63 * @deferred_tail: newest OOS b'cast message received from node
64 * @defragm: list of partially reassembled b'cast message fragments from node
70 struct cluster
*owner
;
72 struct list_head nsub
;
73 struct link
*active_links
[2];
74 struct link
*links
[MAX_BEARERS
];
76 int permit_changeover
;
86 struct sk_buff
*deferred_head
;
87 struct sk_buff
*deferred_tail
;
88 struct sk_buff
*defragm
;
92 extern struct node
*nodes
;
93 extern u32 tipc_own_tag
;
95 struct node
*node_create(u32 addr
);
96 void node_delete(struct node
*n_ptr
);
97 struct node
*node_attach_link(struct link
*l_ptr
);
98 void node_detach_link(struct node
*n_ptr
, struct link
*l_ptr
);
99 void node_link_down(struct node
*n_ptr
, struct link
*l_ptr
);
100 void node_link_up(struct node
*n_ptr
, struct link
*l_ptr
);
101 int node_has_active_links(struct node
*n_ptr
);
102 int node_has_redundant_links(struct node
*n_ptr
);
103 u32
node_select_router(struct node
*n_ptr
, u32 ref
);
104 struct node
*node_select_next_hop(u32 addr
, u32 selector
);
105 int node_is_up(struct node
*n_ptr
);
106 void node_add_router(struct node
*n_ptr
, u32 router
);
107 void node_remove_router(struct node
*n_ptr
, u32 router
);
108 struct sk_buff
*node_get_links(const void *req_tlv_area
, int req_tlv_space
);
109 struct sk_buff
*node_get_nodes(const void *req_tlv_area
, int req_tlv_space
);
111 static inline struct node
*node_find(u32 addr
)
113 if (likely(in_own_cluster(addr
)))
114 return local_nodes
[tipc_node(addr
)];
115 else if (addr_domain_valid(addr
)) {
116 struct cluster
*c_ptr
= cluster_find(addr
);
119 return c_ptr
->nodes
[tipc_node(addr
)];
124 static inline struct node
*node_select(u32 addr
, u32 selector
)
126 if (likely(in_own_cluster(addr
)))
127 return local_nodes
[tipc_node(addr
)];
128 return node_select_next_hop(addr
, selector
);
131 static inline void node_lock(struct node
*n_ptr
)
133 spin_lock_bh(&n_ptr
->lock
);
136 static inline void node_unlock(struct node
*n_ptr
)
138 spin_unlock_bh(&n_ptr
->lock
);