source: genesis/nodes/rogue.py@ 8067

Last change on this file since 8067 was 7304, checked in by rick, 15 years ago

Deleted bunch of old curft

  • Property svn:executable set to *
File size: 1.1 KB
Line 
1# gegeven een lvrouted.mytree, kijk of alle adressen daarin wel in genesis
2# staan.
3
4# lodewijk@wirelessleiden.nl
5import popen2
6import re
7import sys
8
9size = 30
10if len(sys.argv) > 1:
11 size = int(sys.argv[1])
12numaddrs = 1 << (32 - size)
13
14ipre = re.compile("^IP=(172\.16\.[0-9]+\.[0-9]+)/([0-9]+) *")
15
16def parseaddr(s):
17 f = s.split('.')
18 return (long(f[0]) << 24L) + \
19 (long(f[1]) << 16L) + \
20 (long(f[2]) << 8L) + \
21 long(f[3])
22
23def showaddr(a):
24 return "%d.%d.%d.%d" % ((a >> 24) & 0xff, (a >> 16) & 0xff, (a >> 8) & 0xff, a & 0xff)
25
26bezet = {}
27
28(cout, cin) = popen2.popen2("cat */wleiden.conf | grep ^IP | grep 172.16\...*\/[28\|29\|30]")
29cin.close()
30for l in cout.readlines():
31 l = l[:-1]
32 match = ipre.match(l)
33 if match == None:
34 print "'" + l + "'"
35 addr = parseaddr(match.group(1))
36 mask = int(match.group(2))
37 addr = addr & ~((1 << (32 - mask)) - 1)
38 upper = addr + (1 << (32 - mask))
39 while addr < upper:
40 bezet[addr] = 1
41 addr = addr + 1
42
43for line in open('lvrouted.mytree').readlines():
44 line = line.strip()
45 addr = parseaddr(line)
46 if addr > 0xac110000:
47 continue
48 if not bezet.has_key(addr):
49 print line
50
Note: See TracBrowser for help on using the repository browser.