Last change
on this file since 3529 was 3130, checked in by lodewijk, 20 years ago |
tooltje om een vrije interlink te zoeken
|
File size:
872 bytes
|
Rev | Line | |
---|
[3130] | 1 | # zoek de eerste vrije (== niet in een wleiden.conf gedefinieerde) /30
|
---|
| 2 | # lvoge@cs.vu.nl
|
---|
| 3 | import popen2
|
---|
| 4 | import re
|
---|
| 5 |
|
---|
| 6 | ipre = re.compile("^IP=(172\.16\.[0-9]+\.[0-9]+)/30 *")
|
---|
| 7 |
|
---|
| 8 | def parseaddr(s):
|
---|
| 9 | f = s.split('.')
|
---|
| 10 | return (long(f[0]) << 24L) + \
|
---|
| 11 | (long(f[1]) << 16L) + \
|
---|
| 12 | (long(f[2]) << 8L) + \
|
---|
| 13 | long(f[3])
|
---|
| 14 |
|
---|
| 15 | def showaddr(a):
|
---|
| 16 | return "%d.%d.%d.%d" % ((a >> 24) & 0xff, (a >> 16) & 0xff, (a >> 8) & 0xff, a & 0xff)
|
---|
| 17 |
|
---|
| 18 | bezet = {}
|
---|
| 19 |
|
---|
| 20 | (cout, cin) = popen2.popen2("cat */wleiden.conf | grep ^IP | grep 172.16\\\\..*\/30")
|
---|
| 21 | cin.close()
|
---|
| 22 | for l in cout.readlines():
|
---|
| 23 | l = l[:-1]
|
---|
| 24 | match = ipre.match(l)
|
---|
| 25 | if match == None:
|
---|
| 26 | print "'" + l + "'"
|
---|
| 27 | addr = parseaddr(match.group(1))
|
---|
| 28 | addr = addr & 0xfffffffcL
|
---|
| 29 | bezet[addr] = 1
|
---|
| 30 |
|
---|
| 31 | i = 0xffffffffL
|
---|
| 32 | for k in bezet.keys():
|
---|
| 33 | if k < i:
|
---|
| 34 | i = k
|
---|
| 35 |
|
---|
| 36 | while bezet.has_key(i):
|
---|
| 37 | i = i + 4
|
---|
| 38 |
|
---|
| 39 | print "%s/30: %s en %s\n" % (showaddr(i), showaddr(i + 1), showaddr(i + 2))
|
---|
Note:
See
TracBrowser
for help on using the repository browser.