summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Wilson <msw@redhat.com>1999-08-02 21:43:02 +0000
committerMatt Wilson <msw@redhat.com>1999-08-02 21:43:02 +0000
commitda05722407562f9ba8d9d7df7767b0b6a175046c (patch)
tree6337a2f33f80fc71934efbdd045eb9871d784f6b
parent07db2ba7a7edaf89d1f18077baecfd28baf482de (diff)
downloadanaconda-da05722407562f9ba8d9d7df7767b0b6a175046c.tar.gz
anaconda-da05722407562f9ba8d9d7df7767b0b6a175046c.tar.xz
anaconda-da05722407562f9ba8d9d7df7767b0b6a175046c.zip
better netmask function
-rw-r--r--isys/isys.py34
1 files changed, 26 insertions, 8 deletions
diff --git a/isys/isys.py b/isys/isys.py
index 76de07592..82808cbef 100644
--- a/isys/isys.py
+++ b/isys/isys.py
@@ -50,19 +50,37 @@ def inet_aton (addr):
return rc
def inet_calcNetmask (ip):
+ if isinstance (ip, type (0)):
+ addr = inet_ntoa (ip)
+ else:
+ addr = ip
+ quad = string.splitfields (addr, ".")
+ if len (quad) > 0:
+ klass = string.atoi (quad[0])
+ if klass <= 127:
+ mask = "255.0.0.0";
+ if klass <= 191:
+ mask = "255.255.0.0";
+ else:
+ mask = "255.255.255.0";
+ return mask
+
+def inet_calcNetBroad (ip, nm):
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";
+
+ if isinstance (nm, type ("")):
+ ipaddr = inet_aton (ip)
else:
- mask = "255.255.255.0";
-
- return mask
-
+ ipaddr = ip
+
+ netaddr = ipaddr & nmaddr
+ bcaddr = netaddr | (~nmaddr);
+
+ return (inet_ntoa (netaddr), inet_ntoa (bcaddr))
+
try:
_isys.readmoduleinfo("/modules/module-info")
except IOError: