]> git.sesse.net Git - nms/blobdiff - zyxel/zyxelcommon.py
Merge.
[nms] / zyxel / zyxelcommon.py
index 739be4447d42505425a43aa1b506a0cd16d57d2b..d35c540a04ebf3416fa4dfd0805f206e0d63f312 100644 (file)
@@ -5,23 +5,29 @@ LOGHOST="194.0.255.20"
 # No Z-constant for you!
 def retSubnet(sw):
     (rad,num) = sw
-    drad = (rad - 1) / 2
-    if drad <= 7 or (drad == 8 and (sw <= 3 or sw == 6)):
+    drad = (rad + 1) / 2
+    if drad <= 4 or (drad == 5 and (num <= 2)):
         return "241"
-    if drad <= 13 or (drad == 14 and sw != 4) or (drad == 15 and sw <= 3):
+    if drad <= 7 or (drad == 8 and (num <= 3 or num == 6)):
         return "242"
-    if drad <= 22 or (drad == 23 and sw >= 4) or (drad == 24 and sw == 4):
+    if drad <= 13 or (drad == 14 and num != 4) or (drad == 15 and num <= 3):
         return "243"
-    if drad <= 29 or (drad == 30 and (sw == 4 or sw == 5)):
+    if drad <= 22 or (drad == 23 and num >= 4) or (drad == 24 and num == 4):
         return "244"
-    return "245"
+    if drad <= 29 or (drad == 30 and (num == 4 or num == 5)):
+        return "245"
+    if drad <= 31 or (drad == 32 and (num <= 5)):
+        return "246"
+    if drad <= 33 or (num >= 4):
+       return "247"
+    return "248"
 
 def retIP(sw):
     (rad,num) = sw
-    gangefaktor = rad - ((rad - 1) / 2)
-    lopenr = 2 + 6 * gangefaktor + num
+    drad = (rad + 1) / 2
+    lopenr = 6 * drad + num - 5
     return NETWORK + ".%s.%s" % (retSubnet(sw), lopenr)
 
 # ooh, fugly
 def retColor(sw):
-    return "\e[%um" % (int(retSubnet(sw)) - 209)
+    return "\e[%um" % (int(retSubnet(sw)) - 210)