addr.c (08c80e9a031df0a8f0269477a32f5eae47d7a146) addr.c (8f92df6ad49da958d97e171762d0a97a3dc738f1)
1/*
2 * net/tipc/addr.c: TIPC address utility routines
3 *
4 * Copyright (c) 2000-2006, Ericsson AB
5 * Copyright (c) 2004-2005, Wind River Systems
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 21 unchanged lines hidden (view full) ---

30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#include "core.h"
1/*
2 * net/tipc/addr.c: TIPC address utility routines
3 *
4 * Copyright (c) 2000-2006, Ericsson AB
5 * Copyright (c) 2004-2005, Wind River Systems
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without

--- 21 unchanged lines hidden (view full) ---

30 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 */
36
37#include "core.h"
38#include "cluster.h"
38#include "node.h"
39#include "addr.h"
39
40/**
41 * tipc_addr_domain_valid - validates a network domain address
42 *
43 * Accepts <Z.C.N>, <Z.C.0>, <Z.0.0>, and <0.0.0>,
44 * where Z, C, and N are non-zero and do not exceed the configured limits.
45 *
46 * Returns 1 if domain address is valid, otherwise 0
47 */
48
49int tipc_addr_domain_valid(u32 addr)
50{
51 u32 n = tipc_node(addr);
52 u32 c = tipc_cluster(addr);
53 u32 z = tipc_zone(addr);
54 u32 max_nodes = tipc_max_nodes;
55
56 if (n > max_nodes)
57 return 0;
40
41/**
42 * tipc_addr_domain_valid - validates a network domain address
43 *
44 * Accepts <Z.C.N>, <Z.C.0>, <Z.0.0>, and <0.0.0>,
45 * where Z, C, and N are non-zero and do not exceed the configured limits.
46 *
47 * Returns 1 if domain address is valid, otherwise 0
48 */
49
50int tipc_addr_domain_valid(u32 addr)
51{
52 u32 n = tipc_node(addr);
53 u32 c = tipc_cluster(addr);
54 u32 z = tipc_zone(addr);
55 u32 max_nodes = tipc_max_nodes;
56
57 if (n > max_nodes)
58 return 0;
58 if (c > tipc_max_clusters)
59 return 0;
60
61 if (n && (!z || !c))
62 return 0;
63 if (c && !z)
64 return 0;
65 return 1;
66}
67

--- 46 unchanged lines hidden ---
59
60 if (n && (!z || !c))
61 return 0;
62 if (c && !z)
63 return 0;
64 return 1;
65}
66

--- 46 unchanged lines hidden ---