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.
16 # This software is distributed in the hope that it will be useful,
17 # but WITHOUT ANY WARRANTY; without even the implied warranty of
18 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 # GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License
22 # along with this software; if not, see
23 # https://www.gnu.org/licenses/gpl.html.
25 # The corresponding test vector file ise ipaddrset-test.expected. I
26 # don't believe it is a creative work that attracts copyright. -iwj.
28 from __future__ import print_function
29 from __future__ import unicode_literals
32 from ipaddress import ip_network, ip_address
35 from ipaddrset import IPAddressSet
37 v4a=ip_address('172.18.45.6')
41 s.append([ip_network('172.18.45.0/24')])
42 s.append([ip_network('2001:23:24::/48')])
45 t=IPAddressSet(map(ip_network,['172.31.80.8/32','172.18.45.192/28']))
50 for n1s in ['172.18.44.0/23','172.18.45.6/32','172.18.45.0/24']:
58 a=ipaddrset.complete_set()
64 print(s.intersection(t))
65 print(t.intersection(s))