| 1 | #!/usr/bin/python |
| 2 | |
| 3 | import ipaddr |
| 4 | from ipaddr import IPNetwork, IPAddress |
| 5 | |
| 6 | import ipaddrset |
| 7 | from ipaddrset import IPAddressSet |
| 8 | |
| 9 | v4a=IPAddress('172.18.45.6') |
| 10 | |
| 11 | s=IPAddressSet() |
| 12 | print 's =', s |
| 13 | s.append([IPNetwork('172.18.45.0/24')]) |
| 14 | s.append([IPNetwork('2001:23:24::/40')]) |
| 15 | print s |
| 16 | |
| 17 | t=IPAddressSet(map(IPNetwork,['172.31.80.8/32','172.18.45.192/28'])) |
| 18 | print 't =', t |
| 19 | print t <= s |
| 20 | print t == s |
| 21 | |
| 22 | for n1s in ['172.18.44.0/23','172.18.45.6/32','172.18.45.0/24']: |
| 23 | n1=IPNetwork(n1s) |
| 24 | print n1 |
| 25 | print s.contains(n1) |
| 26 | print t.contains(n1) |
| 27 | |
| 28 | n=s.networks()[0] |
| 29 | |
| 30 | a=ipaddrset.complete_set() |
| 31 | print 'a =', a |
| 32 | print a >= s |
| 33 | print a >= t |
| 34 | |
| 35 | print '^' |
| 36 | print s.intersection(t) |
| 37 | print t.intersection(s) |
| 38 | |
| 39 | print 'u' |
| 40 | print s.union(t) |
| 41 | print t.union(s) |