linux/net/tipc/addr.c
<<
333< /spa" 3< spa" class="lxr_search">3333Search33< /spa" op /div op form ac.12"="ajax+*" method="post" onsubmit="return false;">3< input typptihidden" namptiajax_lookup" idtiajax_lookup" 23op /form 3op div class="headingbott8m">
div idtifile_contents"
   1 /a> spa" class="comment">/* /spa"
	   2 /a> spa" class="comment"> * net/tipc/addr.c: TIPC address utility routines /spa"
	   3 /a> spa" class="comment"> * /spa"
	   4 /a> spa" class="comment"> * Copyright (c) 2000-2006, Ericss8.1AB /spa"
	   5 /a> spa" class="comment"> * Copyright (c) 2004-2005, 2010-2011, Wind River Systems /spa"
	   6 /a> spa" class="comment"> * All rights reserved. /spa"
	   7 /a> spa" class="comment"> * /spa"
	   8 /a> spa" class="comment"> * Redistribut18.1and use in source1and binary forms, with or without /spa"
	   9 /a> spa" class="comment"> * modificat18., are permitted provided that the following condit18.s are met: /spa"
	  7v3.a> spa" class="comment"> * /spa"
	  11 /a> spa" class="comment"> * 1. Redistribut18.s of source1code must retain the above1copyright /spa"
	  12 /a> spa" class="comment"> *    notice, this list of condit18.s and the following disclaimer. /spa"
	  13 /a> spa" class="comment"> * 2. Redistribut18.s in binary form must reproduce1the above1copyright /spa"
	  14 /a> spa" class="comment"> *    notice, this list of condit18.s and the following disclaimer in the /spa"
	  15 /a> spa" class="comment"> *    documentat18.1and/or other materials provided with the distribut18.. /spa"
	  16 /a> spa" class="comment"> * 3. Neither the namps of the copyright holders nor the namps of its /spa"
	  17 /a> spa" class="comment"> *    contributors may be used to endorse or promote products derived from /spa"
	  18 /a> spa" class="comment"> *    this software without specific prior written permiss18.. /spa"
	  19 /a> spa" class="comment"> * /spa"
	  2v3.a> spa" class="comment"> * Alternat1vely, this software may be distributed under the terms of the /spa"
	  21 /a> spa" class="comment"> * GNU General Public License ("GPL") vers18. 2 as published by the Free /spa"
	  22 /a> spa" class="comment"> * Software Foundat18.. /spa"
	  23 /a> spa" class="comment"> * /spa"
	  24 /a> spa" class="comment"> * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" /spa"
	  25 /a> spa" class="comment"> * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE /spa"
	  26 /a> spa" class="comment"> * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE /spa"
	  27 /a> spa" class="comment"> * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE /spa"
	  28 /a> spa" class="comment"> * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR /spa"
	  29 /a> spa" class="comment"> * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF /spa"
	  3v3.a> spa" class="comment"> * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS /spa"
	  31 /a> spa" class="comment"> * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN /spa"
	  32 /a> spa" class="comment"> * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) /spa"
	  33 /a> spa" class="comment"> * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE /spa"
	  34 /a> spa" class="comment"> * POSSIBILITY OF SUCH DAMAGE. /spa"
	  35 /a> spa" class="comment"> */ /spa"
	  36 /a>	  37 /a>#include " a href="net/tipc/core.h" class="fref">core.h /a>"	  38 /a>#include " a href="net/tipc/addr.h" class="fref">addr.h /a>"	  39 /a>	  4v3.a> spa" class="comment">/** /spa"
	  41 /a> spa" class="comment"> * tipc_addr_domain_valid - validates a network domain address /spa"
	  42 /a> spa" class="comment"> * /spa"
	  43 /a> spa" class="comment"> * Accepts <Z.C.N>, <Z.C.0>, <Z.0.0>, and <0.0.0>, /spa"
	  44 /a> spa" class="comment"> * where Z, C, and N are non-zero. /spa"
	  45 /a> spa" class="comment"> * /spa"
	  46 /a> spa" class="comment"> * Returns 1 if domain address is valid, otherwise 0 /spa"
	  47 /a> spa" class="comment"> */ /spa"
	  48 /a>int  a href="+code=tipc_addr_domain_valid" class="sref">tipc_addr_domain_valid /a>( a href="+code=u32" class="sref">u32 /a>  a href="+code=addr" class="sref">addr /a>)	  49 /a>{	  5v3.a>         a href="+code=u32" class="sref">u32 /a>  a href="+code=n" class="sref">n /a> =  a href="+code=tipc_node" class="sref">tipc_node /a>( a href="+code=addr" class="sref">addr /a>);	  513.a>         a href="+code=u32" class="sref">u32 /a>  a href="+code=c" class="sref">c /a> =  a href="+code=tipc_cluster" class="sref">tipc_cluster /a>( a href="+code=addr" class="sref">addr /a>);	  523.a>         a href="+code=u32" class="sref">u32 /a>  a href="+code=z" class="sref">z /a> =  a href="+code=tipc_zone" class="sref">tipc_zone /a>( a href="+code=addr" class="sref">addr /a>);	  53 /a>	  543.a>        if ( a href="+code=n" class="sref">n /a> && (! a href="+code=z" class="sref">z /a> || ! a href="+code=c" class="sref">c /a>))	  553.a>                return 0;	  563.a>        if ( a href="+code=c" class="sref">c /a> && ! a href="+code=z" class="sref">z /a>)	  573.a>                return 0;	  583.a>        return 1;	  59 /a>}	  60 /a>	  61 /a> spa" class="comment">/** /spa"
	  62 /a> spa" class="comment"> * tipc_addr_node_valid - validates a proposed network address for this node /spa"
	  63 /a> spa" class="comment"> * /spa"
	  64 /a> spa" class="comment"> * Accepts <Z.C.N>, where Z, C, and N are non-zero. /spa"
	  65 /a> spa" class="comment"> * /spa"
	  66 /a> spa" class="comment"> * Returns 1 if address ca" be used, otherwise 0 /spa"
	  67 /a> spa" class="comment"> */ /spa"
	  68 /a>int  a href="+code=tipc_addr_node_valid" class="sref">tipc_addr_node_valid /a>( a href="+code=u32" class="sref">u32 /a>  a href="+code=addr" class="sref">addr /a>)	  69 /a>{	  703.a>        return  a href="+code=tipc_addr_domain_valid" class="sref">tipc_addr_domain_valid /a>( a href="+code=addr" class="sref">addr /a>) &&  a href="+code=tipc_node" class="sref">tipc_node /a>( a href="+code=addr" class="sref">addr /a>);	  71 /a>}	  72 /a>	  73 /a>int  a href="+code=tipc_in_scope" class="sref">tipc_in_scope /a>( a href="+code=u32" class="sref">u32 /a>  a href="+code=domain" class="sref">domain /a>,  a href="+code=u32" class="sref">u32 /a>  a href="+code=addr" class="sref">addr /a>)	  74 /a>{	  753.a>        if (! a href="+code=domain" class="sref">domain /a> || ( a href="+code=domain" class="sref">domain /a> ==  a href="+code=addr" class="sref">addr /a>))	  763.a>                return 1;	  773.a>        if ( a href="+code=domain" class="sref">domain /a> ==  a href="+code=tipc_cluster_mask" class="sref">tipc_cluster_mask /a>( a href="+code=addr" class="sref">addr /a>))  spa" class="comment">/* domain <Z.C.0> */ /spa"
	  783.a>                return 1;	  793.a>        if ( a href="+code=domain" class="sref">domain /a> ==  a href="+code=tipc_zone_mask" class="sref">tipc_zone_mask /a>( a href="+code=addr" class="sref">addr /a>))  spa" class="comment">/* domain <Z.0.0> */ /spa"
	  803.a>                return 1;	  813.a>        return 0;	  82 /a>}	  83 /a>	  84 /a> spa" class="comment">/** /spa"
	  85 /a> spa" class="comment"> * tipc_addr_scope - convert message lookup domain to a 2-bit scope 2  86 /a> spa" class="comment"> */ /spa"
	  87 /a>int  a href="+code=tipc_addr_scope" class="sref">tipc_addr_scope /a>( a href="+code=u32" class="sref">u32 /a>  a href="+code=domain" class="sref">domain /a>)	  88 /a>{	  893.a>        if ( a href="+code=likely" class="sref">likely /a>(! a href="+code=domain" class="sref">domain /a>))	  903.a>                return  a href="+code=TIPC_ZONE_SCOPE" class="sref">TIPC_ZONE_SCOPE3.a>;	  913.a>        if ( a href="+code=tipc_node" class="sref">tipc_node /a>( a href="+code=domain" class="sref">domain /a>))	  923.a>                return  a href="+code=TIPC_NODE_SCOPE" class="sref">TIPC_NODE_SCOPE3.a>;	  933.a>        if ( a href="+code=tipc_cluster" class="sref">tipc_cluster /a>( a href="+code=domain" class="sref">domain /a>))	  943.a>                return  a href="+code=TIPC_CLUSTER_SCOPE" class="sref">TIPC_CLUSTER_SCOPE3.a>;	  953.a>        return  a href="+code=TIPC_ZONE_SCOPE" class="sref">TIPC_ZONE_SCOPE3.a>;	  96 /a>}	  97 /a>	  98 /a>char * a href="+code=tipc_addr_string_fill" class="sref">tipc_addr_string_fill /a>(char * a href="+code=string" class="sref">string /a>,  a href="+code=u32" class="sref">u32 /a>  a href="+code=addr" class="sref">addr /a>)	  99 /a>{	 1003.a>         a href="+code=snprintf" class="sref">snprintf /a>( a href="+code=string" class="sref">string /a>, 16,  spa" class="string">"<%u.%u.%u>" /spa"
,	 1013.a>                  a href="+code=tipc_zone" class="sref">tipc_zone /a>( a href="+code=addr" class="sref">addr /a>),  a href="+code=tipc_cluster" class="sref">tipc_cluster /a>( a href="+code=addr" class="sref">addr /a>),  a href="+code=tipc_node" class="sref">tipc_node /a>( a href="+code=addr" class="sref">addr /a>));	 1023.a>        return  a href="+code=string" class="sref">string /a>;	 103 /a>}	 104 /a> /pre>
The original LXR software by the LXR community /a>, this experimental vers18. by lxr@linux.no /a>. /div div class="subfooter"> lxr.linux.no kindly hosted by Redpill Linpro AS /a>, provider of Linux consulting and operat18.s services since 1995. /div /body /html