summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Wilson <msw@redhat.com>1999-08-02 21:22:35 +0000
committerMatt Wilson <msw@redhat.com>1999-08-02 21:22:35 +0000
commit07db2ba7a7edaf89d1f18077baecfd28baf482de (patch)
tree47f5ba7c08a635374dde274fed4ce246dcb97594
parenta1a4273893ad8b13c8a42be4f91fc2e32fcade0f (diff)
downloadanaconda-07db2ba7a7edaf89d1f18077baecfd28baf482de.tar.gz
anaconda-07db2ba7a7edaf89d1f18077baecfd28baf482de.tar.xz
anaconda-07db2ba7a7edaf89d1f18077baecfd28baf482de.zip
added calcNetmask
-rw-r--r--isys/isys.py26
1 files changed, 22 insertions, 4 deletions
diff --git a/isys/isys.py b/isys/isys.py
index 664cbbfe7..76de07592 100644
--- a/isys/isys.py
+++ b/isys/isys.py
@@ -40,11 +40,29 @@ def inet_ntoa (addr):
def inet_aton (addr):
quad = string.splitfields (addr, ".")
- return ((string.atoi (quad[0]) << 24) +
- (string.atoi (quad[1]) << 16) +
- (string.atoi (quad[2]) << 8) +
- string.atoi (quad[3]))
+ try:
+ rc = ((string.atoi (quad[0]) << 24) +
+ (string.atoi (quad[1]) << 16) +
+ (string.atoi (quad[2]) << 8) +
+ string.atoi (quad[3]))
+ except IndexError:
+ raise ValueError
+ return rc
+def inet_calcNetmask (ip):
+ if isinstance (ip, type ("")):
+ ipaddr = inet_aton (ip)
+ else:
+ ipaddr = ip
+ if (ipaddr >> 24 & 0x000000ff) <= 127:
+ mask = "255.0.0.0";
+ elif (ipaddr >> 24 & 0x000000ff) <= 191:
+ mask = "255.255.0.0";
+ else:
+ mask = "255.255.255.0";
+
+ return mask
+
try:
_isys.readmoduleinfo("/modules/module-info")
except IOError: