Edit report at http://pear.php.net/bugs/bug.php?id=18687&edit=1
ID: 18687
Comment by: [email protected]
Reported By: koyama at hoge dot org
Summary: support RFC5952 compatible format
Status: Open
Type: Feature/Change Request
Package: Net_IPv6
Operating System: CentOS
Package Version: 1.2.1
PHP Version: 5.3.6
Roadmap Versions:
New Comment:
Uploading a patch is not working. paste here.
--- IPv6.php 2011-07-26 20:38:19.000000000 +0900
+++ IPv6.php.new 2011-07-26 20:37:46.000000000 +0900
@@ -748,6 +748,32 @@
}
// }}}
+ // {{{ recommendedFormat()
+ /**
+ * represent IPv6 address in RFC5952 format.
+ *
+ * @param String $ip a valid IPv6-adress (hex format)
+ *
+ * @return String the recommended representation of IPv6-adress
(hex format)
+ * @access public
+ * @see compress()
+ * @static
+ * @author koyama at hoge dot org
+ */
+ function recommendedFormat($ip)
+ {
+ $compressed = self::compress($ip, true);
+ // RFC5952 4.2.2
+ // The symbol "::" MUST NOT be used to shorten just one
+ // 16-bit 0 field.
+ if ((substr_count($compressed, ':') == 7) &&
+ (strpos($compressed, '::') !== false)) {
+ $compressed = str_replace('::', ':0:', $compressed);
+ }
+ return $compressed;
+ }
+
+ // }}}
// {{{ isCompressible()
/**
Previous Comments:
------------------------------------------------------------------------
[2011-07-26 13:55:17] koyama
Description:
------------
The new RFC5952, has established a recommended text representation of
IPv6 address. The compress () output will conform to it almost a little
different.
In RFC5952 4.2.2, "The symbol "::" MUST NOT be used to shorten just one
16-bit 0 field." I wrote new method for it.
------------------------------------------------------------------------