Last change
on this file was 8615, checked in by rick, 14 years ago |
Bezempje door alle files. Rommel weg. Tooljes op de juiste locatie.
|
-
Property svn:executable
set to
*
|
File size:
1.1 KB
|
Rev | Line | |
---|
[5101] | 1 | # gegeven een lvrouted.mytree, kijk of alle adressen daarin wel in genesis
|
---|
| 2 | # staan.
|
---|
| 3 |
|
---|
| 4 | # lodewijk@wirelessleiden.nl
|
---|
| 5 | import popen2
|
---|
| 6 | import re
|
---|
| 7 | import sys
|
---|
| 8 |
|
---|
| 9 | size = 30
|
---|
| 10 | if len(sys.argv) > 1:
|
---|
| 11 | size = int(sys.argv[1])
|
---|
| 12 | numaddrs = 1 << (32 - size)
|
---|
| 13 |
|
---|
| 14 | ipre = re.compile("^IP=(172\.16\.[0-9]+\.[0-9]+)/([0-9]+) *")
|
---|
| 15 |
|
---|
| 16 | def 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 |
|
---|
| 23 | def showaddr(a):
|
---|
| 24 | return "%d.%d.%d.%d" % ((a >> 24) & 0xff, (a >> 16) & 0xff, (a >> 8) & 0xff, a & 0xff)
|
---|
| 25 |
|
---|
| 26 | bezet = {}
|
---|
| 27 |
|
---|
| 28 | (cout, cin) = popen2.popen2("cat */wleiden.conf | grep ^IP | grep 172.16\...*\/[28\|29\|30]")
|
---|
| 29 | cin.close()
|
---|
| 30 | for 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 |
|
---|
| 43 | for 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
|
---|
[6162] | 50 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.