Commit | Line | Data |
---|---|---|
6437945a IJ |
1 | #!/usr/bin/python |
2 | ||
3 | import sys | |
4 | import copy | |
5 | import os | |
6 | saved_path=copy.copy(sys.path) | |
7 | for p in ['','.',os.getcwd()]: | |
8 | try: sys.path.remove(p) | |
9 | except ValueError: pass | |
10 | ||
11 | import ipaddr | |
12 | from ipaddr import IPNetwork, IPAddress | |
13 | ||
14 | sys.path=saved_path | |
15 | ||
16 | import ipaddrset | |
17 | from ipaddrset import IPAddressSet | |
18 | ||
19 | v4a=IPAddress('172.18.45.6') | |
20 | ||
21 | s=IPAddressSet() | |
22 | print 's =', s | |
23 | s.append([IPNetwork('172.18.45.0/24')]) | |
24 | s.append([IPNetwork('2001:23:24::/40')]) | |
25 | print s | |
26 | ||
27 | t=IPAddressSet(map(IPNetwork,['172.31.80.8/32','172.18.45.192/28'])) | |
28 | print 't =', t | |
29 | print t <= s | |
30 | print t == s | |
31 | ||
32 | for n1s in ['172.18.44.0/23','172.18.45.6/32','172.18.45.0/24']: | |
33 | n1=IPNetwork(n1s) | |
34 | print n1 | |
35 | print s.contains(n1) | |
36 | print t.contains(n1) | |
37 | ||
38 | n=s.networks()[0] | |
39 | ||
40 | a=ipaddrset.complete_set() | |
41 | print 'a =', a | |
42 | print a >= s | |
43 | print a >= t | |
44 | ||
45 | print '^' | |
46 | print s.intersection(t) | |
47 | print t.intersection(s) | |
48 | ||
49 | print 'u' | |
50 | print s.union(t) | |
51 | print t.union(s) |