Last change
on this file since 7923 was 7460, checked in by huub, 15 years ago |
release parameter updated for 7.2-RELEASE info
|
-
Property svn:eol-style
set to
native
-
Property svn:executable
set to
*
|
File size:
1.4 KB
|
Rev | Line | |
---|
[7089] | 1 | #!/usr/bin/env python
|
---|
[4150] | 2 | # zoek de eerste vrije (== niet in een wleiden.conf gedefinieerde) interlink
|
---|
| 3 | # range
|
---|
[5283] | 4 | # lodewijk@wirelessleiden.nl
|
---|
[3130] | 5 | import popen2
|
---|
| 6 | import re
|
---|
[4150] | 7 | import sys
|
---|
[3130] | 8 |
|
---|
[4150] | 9 | size = 30
|
---|
[7325] | 10 | if len(sys.argv) < 2:
|
---|
| 11 | print "Gebruik: python getrange.py <interlink|subnet> <size>"
|
---|
| 12 | print "dus voor een /28 interlink is het 'python getrange.py interlink 28'"
|
---|
| 13 | print "en voor een /25 subnet is het 'python getrange.py subnet 25'"
|
---|
| 14 | interlink = sys.argv[1] == 'interlink'
|
---|
| 15 | size = int(sys.argv[2])
|
---|
[4150] | 16 | numaddrs = 1 << (32 - size)
|
---|
| 17 |
|
---|
[4149] | 18 | ipre = re.compile("^IP=(172\.16\.[0-9]+\.[0-9]+)/([0-9]+) *")
|
---|
[3130] | 19 |
|
---|
| 20 | def parseaddr(s):
|
---|
| 21 | f = s.split('.')
|
---|
| 22 | return (long(f[0]) << 24L) + \
|
---|
| 23 | (long(f[1]) << 16L) + \
|
---|
| 24 | (long(f[2]) << 8L) + \
|
---|
| 25 | long(f[3])
|
---|
| 26 |
|
---|
| 27 | def showaddr(a):
|
---|
| 28 | return "%d.%d.%d.%d" % ((a >> 24) & 0xff, (a >> 16) & 0xff, (a >> 8) & 0xff, a & 0xff)
|
---|
| 29 |
|
---|
| 30 | bezet = {}
|
---|
| 31 |
|
---|
[7460] | 32 | (cout, cin) = popen2.popen2("cat */wleiden.conf | grep ^IP | grep 172.16\...*\/[24\|26\|28\|29\|30]")
|
---|
[3130] | 33 | cin.close()
|
---|
| 34 | for l in cout.readlines():
|
---|
| 35 | l = l[:-1]
|
---|
| 36 | match = ipre.match(l)
|
---|
| 37 | if match == None:
|
---|
[5809] | 38 | #print "'" + l + "'"
|
---|
| 39 | continue
|
---|
| 40 | if len(match.groups()) == 0:
|
---|
| 41 | continue
|
---|
[3130] | 42 | addr = parseaddr(match.group(1))
|
---|
[4149] | 43 | mask = int(match.group(2))
|
---|
| 44 | addr = addr & ~((1 << (32 - mask)) - 1)
|
---|
[3130] | 45 | bezet[addr] = 1
|
---|
| 46 |
|
---|
| 47 | i = 0xffffffffL
|
---|
| 48 | for k in bezet.keys():
|
---|
| 49 | if k < i:
|
---|
| 50 | i = k
|
---|
| 51 |
|
---|
[6024] | 52 |
|
---|
| 53 | i = 0xac100300
|
---|
[7325] | 54 | if not interlink:
|
---|
[5519] | 55 | i = 0xac110000
|
---|
[3130] | 56 | while bezet.has_key(i):
|
---|
[4150] | 57 | i = i + numaddrs
|
---|
[3130] | 58 |
|
---|
[4150] | 59 | print "%s/%d:" % (showaddr(i), size),
|
---|
| 60 | print " en ".join([showaddr(i) for i in range(i + 1, i + numaddrs - 1)])
|
---|
Note:
See
TracBrowser
for help on using the repository browser.