Lines Matching defs:prefix
88 * Generate an IPv6 mask from prefix notation
90 * This will convert a prefix to an IPv6 address mask (used for IPv6 math)
92 * @param integer $prefix The prefix size, an integer between 1 and 127 (inclusive)
93 * @return string The IPv6 mask address for the prefix size
95 function inet6_prefix_to_mask($prefix)
97 /* Make sure the prefix is a number between 1 and 127 (inclusive) */
98 $prefix = intval($prefix);
99 if ($prefix < 0 || $prefix > 128) return false;
101 for ($i = 0; $i < $prefix; $i++) $mask .= '1';
112 * Convert an IPv6 address and prefix size to an address range for the network.
114 * This will take an IPv6 address and prefix and return the first and last address available for the network.
117 * @param integer $prefix The prefix size, an integer between 1 and 127 (inclusive)
120 function inet6_to_range($addr, $prefix)
122 $size = 128 - $prefix;
124 $mask = gmp_init('0x' . str_replace(':', '', inet6_expand(inet6_prefix_to_mask($prefix))));
125 $prefix = gmp_and($addr, $mask);
126 $start = gmp_strval(gmp_add($prefix, '0x1'), 16);
129 $end = gmp_strval(gmp_add($prefix, gmp_init($end)), 16);