Project

General

Profile

« Previous | Next » 

Revision de645734

Added by Renato Botelho almost 9 years ago

Ticket #3734: Add function to convert IPv6 address <-> binary

- ip6_to_bin() and bin_to_ip6() are copies obtained from pear-Net_IPv6
since the version available in the class is protected and we don't
want to add more patches to thirdy part software. If upstream accept
to change them to public we can retire them
- bin_to_compressed_ip6 is just a short way to conver binary direct to
a compressed IPv6 address

Reported at: https://forum.pfsense.org/index.php?topic=117601.0

View differences:

src/etc/inc/interfaces.inc
3704 3704
	$rd6prefix = explode("/", $wancfg['prefix-6rd']);
3705 3705
	$rd6prefixlen = $rd6prefix[1];
3706 3706
	$brgw = explode('.', $wancfg['gateway-6rd']);
3707
	$rd6brgw = substr(Net_IPv6::_ip2Bin($rd6prefix[0]), 0, $rd6prefixlen);
3707
	$rd6brgw = substr(ip6_to_bin($rd6prefix[0]), 0, $rd6prefixlen);
3708 3708
	$rd6brgw .= str_pad(decbin($brgw[0]), 8, '0', STR_PAD_LEFT) . str_pad(decbin($brgw[1]), 8, '0', STR_PAD_LEFT) . str_pad(decbin($brgw[2]), 8, '0', STR_PAD_LEFT) . str_pad(decbin($brgw[3]), 8, '0', STR_PAD_LEFT);
3709 3709
	if (strlen($rd6brgw) < 128) {
3710 3710
		$rd6brgw = str_pad($rd6brgw, 128, '0', STR_PAD_RIGHT);
3711 3711
	}
3712
	$rd6brgw = Net_IPv6::compress(Net_IPv6::_bin2Ip($rd6brgw));
3712
	$rd6brgw = bin_to_compressed_ip6($rd6brgw);
3713 3713
	unset($brgw);
3714 3714
	$rd6prefix = Net_IPv6::uncompress($rd6prefix[0]);
3715 3715

  

Also available in: Unified diff