Blame view

net/tipc/addr.h 2.79 KB
b97bf3fd8   Per Liden   [TIPC] Initial merge
1
2
  /*
   * net/tipc/addr.h: Include file for TIPC address utility routines
c43072852   YOSHIFUJI Hideaki   [NET] TIPC: Fix w...
3
   *
593a5f22d   Per Liden   [TIPC] More updat...
4
   * Copyright (c) 2000-2006, Ericsson AB
b97bf3fd8   Per Liden   [TIPC] Initial merge
5
   * Copyright (c) 2004-2005, Wind River Systems
b97bf3fd8   Per Liden   [TIPC] Initial merge
6
7
   * All rights reserved.
   *
9ea1fd3c1   Per Liden   [TIPC] License he...
8
   * Redistribution and use in source and binary forms, with or without
b97bf3fd8   Per Liden   [TIPC] Initial merge
9
10
   * modification, are permitted provided that the following conditions are met:
   *
9ea1fd3c1   Per Liden   [TIPC] License he...
11
12
13
14
15
16
17
18
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in the
   *    documentation and/or other materials provided with the distribution.
   * 3. Neither the names of the copyright holders nor the names of its
   *    contributors may be used to endorse or promote products derived from
   *    this software without specific prior written permission.
b97bf3fd8   Per Liden   [TIPC] Initial merge
19
   *
9ea1fd3c1   Per Liden   [TIPC] License he...
20
21
22
23
24
25
26
27
28
29
30
31
32
33
   * Alternatively, this software may be distributed under the terms of the
   * GNU General Public License ("GPL") version 2 as published by the Free
   * Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
   * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
   * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
   * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
b97bf3fd8   Per Liden   [TIPC] Initial merge
34
35
36
37
38
   * POSSIBILITY OF SUCH DAMAGE.
   */
  
  #ifndef _TIPC_ADDR_H
  #define _TIPC_ADDR_H
1f3de471a   Paul Gortmaker   tipc: make zone/c...
39
40
  #define TIPC_ZONE_MASK		0xff000000u
  #define TIPC_CLUSTER_MASK	0xfffff000u
a3796f895   Allan Stephens   tipc: Add network...
41
42
  static inline u32 tipc_zone_mask(u32 addr)
  {
1f3de471a   Paul Gortmaker   tipc: make zone/c...
43
  	return addr & TIPC_ZONE_MASK;
a3796f895   Allan Stephens   tipc: Add network...
44
45
46
47
  }
  
  static inline u32 tipc_cluster_mask(u32 addr)
  {
1f3de471a   Paul Gortmaker   tipc: make zone/c...
48
  	return addr & TIPC_CLUSTER_MASK;
a3796f895   Allan Stephens   tipc: Add network...
49
  }
b97bf3fd8   Per Liden   [TIPC] Initial merge
50
51
52
53
  static inline int in_own_cluster(u32 addr)
  {
  	return !((addr ^ tipc_own_addr) >> 12);
  }
b97bf3fd8   Per Liden   [TIPC] Initial merge
54
55
  /**
   * addr_domain - convert 2-bit scope value to equivalent message lookup domain
c43072852   YOSHIFUJI Hideaki   [NET] TIPC: Fix w...
56
57
   *
   * Needed when address of a named message must be looked up a second time
b97bf3fd8   Per Liden   [TIPC] Initial merge
58
59
   * after a network hop.
   */
a3796f895   Allan Stephens   tipc: Add network...
60
  static inline u32 addr_domain(u32 sc)
b97bf3fd8   Per Liden   [TIPC] Initial merge
61
62
63
64
  {
  	if (likely(sc == TIPC_NODE_SCOPE))
  		return tipc_own_addr;
  	if (sc == TIPC_CLUSTER_SCOPE)
a3796f895   Allan Stephens   tipc: Add network...
65
66
  		return tipc_cluster_mask(tipc_own_addr);
  	return tipc_zone_mask(tipc_own_addr);
b97bf3fd8   Per Liden   [TIPC] Initial merge
67
  }
4323add67   Per Liden   [TIPC] Avoid poll...
68
69
  int tipc_addr_domain_valid(u32);
  int tipc_addr_node_valid(u32 addr);
80e0c3306   Allan Stephens   tipc: Reduce foot...
70
71
72
  int tipc_in_scope(u32 domain, u32 addr);
  int tipc_addr_scope(u32 domain);
  char *tipc_addr_string_fill(char *string, u32 addr);
b97bf3fd8   Per Liden   [TIPC] Initial merge
73
  #endif