Last change
on this file since 7484 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
|
Line | |
---|
1 | #!/usr/bin/env python
|
---|
2 | # zoek de eerste vrije (== niet in een wleiden.conf gedefinieerde) interlink
|
---|
3 | # range
|
---|
4 | # lodewijk@wirelessleiden.nl
|
---|
5 | import popen2
|
---|
6 | import re
|
---|
7 | import sys
|
---|
8 |
|
---|
9 | size = 30
|
---|
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])
|
---|
16 | numaddrs = 1 << (32 - size)
|
---|
17 |
|
---|
18 | ipre = re.compile("^IP=(172\.16\.[0-9]+\.[0-9]+)/([0-9]+) *")
|
---|
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 |
|
---|
32 | (cout, cin) = popen2.popen2("cat */wleiden.conf | grep ^IP | grep 172.16\...*\/[24\|26\|28\|29\|30]")
|
---|
33 | cin.close()
|
---|
34 | for l in cout.readlines():
|
---|
35 | l = l[:-1]
|
---|
36 | match = ipre.match(l)
|
---|
37 | if match == None:
|
---|
38 | #print "'" + l + "'"
|
---|
39 | continue
|
---|
40 | if len(match.groups()) == 0:
|
---|
41 | continue
|
---|
42 | addr = parseaddr(match.group(1))
|
---|
43 | mask = int(match.group(2))
|
---|
44 | addr = addr & ~((1 << (32 - mask)) - 1)
|
---|
45 | bezet[addr] = 1
|
---|
46 |
|
---|
47 | i = 0xffffffffL
|
---|
48 | for k in bezet.keys():
|
---|
49 | if k < i:
|
---|
50 | i = k
|
---|
51 |
|
---|
52 |
|
---|
53 | i = 0xac100300
|
---|
54 | if not interlink:
|
---|
55 | i = 0xac110000
|
---|
56 | while bezet.has_key(i):
|
---|
57 | i = i + numaddrs
|
---|
58 |
|
---|
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.