marvin-zhao / ipaddr-py

Automatically exported from code.google.com/p/ipaddr-py
0 stars 0 forks source link

Support for rfc6598 space in IPv4Network/Address.is_private #102

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. ipaddr.IPv4Network('100.64.1.0/24').is_private == False

What is the expected output? What do you see instead?

Given RFC6598, 100.64.0.0/10 is now approved for use as CGN space, and also for 
rfc1918-like private usage. Could the code to altered so that is_private will 
return true for 100.64.0.0/10 as well??

What version of the product are you using? On what operating system?

all versions.. Ubuntu

Please provide any additional information below.

1.1.1.0/24: is_private=False
192.168.1.0/24: is_private=True
172.16.1.0/24: is_private=True
10.16.1.0/24: is_private=True
100.96.1.0/24: is_private=False
100.64.1.0/24: is_private=False

Original issue reported on code.google.com by l...@google.com on 1 Mar 2013 at 12:29

GoogleCodeExporter commented 9 years ago
hello, could we please have an update to this issue?

Original comment by l...@google.com on 12 Mar 2013 at 12:07

GoogleCodeExporter commented 9 years ago
This is a patch against the 3144 branch:

diff -ruN 3144/ipaddr.py 3144.RFC6598/ipaddr.py
--- 3144/ipaddr.py  2012-08-09 09:22:12.649041896 +0200
+++ 3144.RFC6598/ipaddr.py  2013-03-20 10:26:59.569456478 +0100
@@ -1173,6 +1173,7 @@

         """
         return (self in IPv4Network('10.0.0.0/8') or
+                self in IPv4Network('100.64.0.0/10') or
                 self in IPv4Network('172.16.0.0/12') or
                 self in IPv4Network('192.168.0.0/16'))

diff -ruN 3144/ipaddr_test.py 3144.RFC6598/ipaddr_test.py
--- 3144/ipaddr_test.py 2013-03-20 10:28:28.708508165 +0100
+++ 3144.RFC6598/ipaddr_test.py 2013-03-20 10:29:09.151991621 +0100
@@ -20,7 +20,9 @@

 import unittest
 import time
-import ipaddress
+import ipaddr
+
+ipaddress = ipaddr

 # Compatibility function to cast str to bytes objects
 if ipaddress._compat_has_real_bytes:
@@ -788,6 +790,7 @@
         self.assertEqual(False, ipaddress.ip_network('11.0.0.0').is_private)
         self.assertEqual(True, ipaddress.ip_network('172.31.255.255').is_private)
         self.assertEqual(False, ipaddress.ip_network('172.32.0.0').is_private)
+        self.assertEqual(True, ipaddress.ip_network('100.64.1.0').is_private)

         self.assertEqual(True,
                           ipaddress.ip_interface(
@@ -812,6 +815,7 @@
         self.assertEqual(False, ipaddress.ip_address('11.0.0.0').is_private)
         self.assertEqual(True, ipaddress.ip_address('172.31.255.255').is_private)
         self.assertEqual(False, ipaddress.ip_address('172.32.0.0').is_private)
+        self.assertEqual(True, ipaddress.ip_address('100.64.3.4').is_private)

         self.assertEqual(True,
                           ipaddress.ip_address('169.254.100.200').is_link_local)

Original comment by gurub...@gmail.com on 20 Mar 2013 at 9:30