source: genesis/nodes/getrange.py@ 4108

Last change on this file since 4108 was 3130, checked in by lodewijk, 20 years ago

tooltje om een vrije interlink te zoeken

File size: 872 bytes
Line 
1# zoek de eerste vrije (== niet in een wleiden.conf gedefinieerde) /30
2# lvoge@cs.vu.nl
3import popen2
4import re
5
6ipre = re.compile("^IP=(172\.16\.[0-9]+\.[0-9]+)/30 *")
7
8def 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
15def showaddr(a):
16 return "%d.%d.%d.%d" % ((a >> 24) & 0xff, (a >> 16) & 0xff, (a >> 8) & 0xff, a & 0xff)
17
18bezet = {}
19
20(cout, cin) = popen2.popen2("cat */wleiden.conf | grep ^IP | grep 172.16\\\\..*\/30")
21cin.close()
22for 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
31i = 0xffffffffL
32for k in bezet.keys():
33 if k < i:
34 i = k
35
36while bezet.has_key(i):
37 i = i + 4
38
39print "%s/30: %s en %s\n" % (showaddr(i), showaddr(i + 1), showaddr(i + 2))
Note: See TracBrowser for help on using the repository browser.