Net-Interface

 view release on metacpan or  search on metacpan

ni_in6_classify.c  view on Meta::CPAN

#define byte13 s6_bytes[13]
#define byte14 s6_bytes[14]
#define byte15 s6_bytes[15]
#define bytes0_1 (s6_bytes[0] | s6_bytes[1])
#define bytes2_3 (s6_bytes[2] | s6_bytes[3])
#define bytes4_5 (s6_bytes[4] | s6_bytes[5])
#define bytes6_7 (s6_bytes[6] | s6_bytes[7])
#define bytes8_9 (s6_bytes[8] | s6_bytes[9])
#define bytes10_11 (s6_bytes[10] | s6_bytes[11])
#define bytes12_13 (s6_bytes[12] | s6_bytes[13])
#define bytes14_15 (s6_bytes[14] | s6_bytes[15])
#define bytes0_3 (bytes0_1 | bytes2_3)
#define bytes4_7 (bytes4_5 | bytes6_7)
#define bytes8_11 (bytes8_9 | bytes10_11)
#define bytes12_15 (bytes12_13 | bytes14_15)
#define allbytes (bytes0_3 | bytes4_7 | bytes8_11 | bytes12_15)

/* ************************************************************	*
 *	unspecified address - all zeros				*
 * ************************************************************	*/

	if (allbytes == 0)
	    type |= IPV6_ADDR_UNSPECIFIED;

/* ************************************************************	*
 *	FC00::/7              Unique Local Unicast    [RFC4193]	*
 * ************************************************************	*/

	 if ((byte0 & 0xFEu) == 0xFCu)
	    type |= IPV6_ADDR_ULUA;

/* ************************************************************	*
 *	2000::/3              Global Unicast          [RFC4291]	*
 * ************************************************************	*/

	if ((byte0 & 0xE0u) == 0x20u)
	    type |= IPV6_ADDR_AGU;

/* ****************************************************************************	*
 *   ftp://ftp.isi.edu/in-notes/rfc2471.txt					*
 *   IPv6 Testing Address Allocation						*
 *   The Aggregatable Global Unicast Address Allocation format defined in	*
 *   [AGGR] is as follows:							*
 *										*
 *      | 3 |  13 |    32     |   16   |          64 bits               |	*
 *      +---+-----+-----------+--------+--------------------------------+	*
 *      |FP | TLA | NLA ID    | SLA ID |         Interface ID           |	*
 *      |   | ID  |           |        |                                |	*
 *      +---+-----+-----------+--------+--------------------------------+	*
 *										*
 *   where:									*
 *										*
 *      FP = 001 = Format Prefix						*
 *										*
 *           This is the Format Prefix used to identify aggregatable		*
 *           global unicast addresses.						*
 *										*
 *      TLA = 0x1FFE = Top-Level Aggregation Identifier				*
 *										*
 *           This is a TLA ID assigned by the IANA for 6bone testing under	*
 *           the auspices of the IETF IPng Transition Working Group 6bone	*
 *           testbed activity.							*
 *										*
 *	3ffe::/16 - experimental 6bone	- obsolete 6/6/2006			*
 * ****************************************************************************	*/

	if (byte0 == 0x3Fu && byte1 == 0xFEu)
	    type |= IPV6_ADDR_6BONE;
	
/* ****************************************************************************	*
 *	http://www.ipv6day.org/action.php?n=En.GetConnected-Teredo		*
 *	Teredo Prefix has been changed from 3ffe:831f::/32 to 2001:0000::/32 	*
 *	once the Teredo specification has been published as RFC4380		*
 *										*
 *	http://www.ietf.org/rfc/rfc4380.txt					*
 *	2.6.  Global Teredo IPv6 Service Prefix					*
 *	An IPv6 addressing prefix whose value is 2001:0000:/32			*
 * ****************************************************************************	*
 *										*
 * ****************************************************************************	*
 *				OLD TEREDO					*
 * if (byte0 == 0x3fu && byte1 == 0xfeu && byte2 == 0x83u && byte3 == 0x1f) {	*
 *	type |= IPV6_ADDR_TEREDO;						*  
 * ****************************************************************************	*/
 
	if (byte0 == 0x20 && byte1 == 0x1u) {
	    if (bytes2_3 == 0)
		type |= IPV6_ADDR_TEREDO;

/* ****************************************************************************	*
 *	http://www.iana.org/assignments/ipv6-address-space			*
 *	http://tools.ietf.org/html/rfc3849					*
 *	2001:0DB8::/32 has been assigned as a NON-ROUTABLE for documentation	*
 * ****************************************************************************	*/

	    if (byte2 == 0xDu && byte3 == 0xB8u)
		type |= IPV6_ADDR_NON_ROUTE_DOC;
	} /* 2001::/16

/* ****************************************************************************	*
 *	http://www.ietf.org/rfc/rfc3056.txt?number=3056				*
 *										*
 *   The IANA has permanently assigned one 13-bit IPv6 Top Level		*
 *   Aggregator (TLA) identifier under the IPv6 Format Prefix 001 [AARCH,	*
 *   AGGR] for the 6to4 scheme.Its numeric value is 0x0002, i.e., it is		*
 *   2002::/16 when expressed as an IPv6 address prefix.			*
 *										*
 *   The subscriber site is then deemed to have the following IPv6 address	*
 *   prefix, without any further assignment procedures being necessary:		*
 *										*
 *      Prefix length: 48 bits							*
 *      Format prefix: 001							*
 *      TLA value: 0x0002							*
 *      NLA value: V4ADDR							*
 *										*
 *   This is illustrated as follows:						*
 *										*
 *     | 3 |  13  |    32     |   16   |          64 bits               |	*
 *     +---+------+-----------+--------+--------------------------------+	*
 *     |FP | TLA  | V4ADDR    | SLA ID |         Interface ID           |	*
 *     |001|0x0002|           |        |                                |	*



( run in 1.451 second using v1.01-cache-2.11-cpan-39bf76dae61 )