3 # This file is Free Software. It was originally written for secnet.
5 # Copyright 2014 Ian Jackson
7 # You may redistribute secnet as a whole and/or modify it under the
8 # terms of the GNU General Public License as published by the Free
9 # Software Foundation; either version 3, or (at your option) any
12 # You may redistribute this fileand/or modify it under the terms of
13 # the GNU General Public License as published by the Free Software
14 # Foundation; either version 2, or (at your option) any later version.
15 # Note however that this version of ipaddrset.py uses the Python
16 # ipaddr library from Google, which is licenced only under the Apache
17 # Licence, version 2.0, which is only compatible with the GNU GPL v3
18 # (or perhaps later versions), and not with the GNU GPL v2.
20 # This software is distributed in the hope that it will be useful,
21 # but WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 # GNU General Public License for more details.
25 # You should have received a copy of the GNU General Public License
26 # along with this software; if not, see
27 # https://www.gnu.org/licenses/gpl.html.
29 # The corresponding test vector file ise ipaddrset-test.expected. I
30 # don't believe it is a creative work that attracts copyright. -iwj.
33 from ipaddr import IPNetwork, IPAddress
36 from ipaddrset import IPAddressSet
38 v4a=IPAddress('172.18.45.6')
42 s.append([IPNetwork('172.18.45.0/24')])
43 s.append([IPNetwork('2001:23:24::/40')])
46 t=IPAddressSet(map(IPNetwork,['172.31.80.8/32','172.18.45.192/28']))
51 for n1s in ['172.18.44.0/23','172.18.45.6/32','172.18.45.0/24']:
59 a=ipaddrset.complete_set()
65 print s.intersection(t)
66 print t.intersection(s)