summaryrefslogtreecommitdiffstats
path: root/isys
diff options
context:
space:
mode:
authorDavid Cantrell <dcantrell@redhat.com>2006-10-03 20:24:38 +0000
committerDavid Cantrell <dcantrell@redhat.com>2006-10-03 20:24:38 +0000
commitd24c4410ace27384c7dd0f532f2f271b969f02b8 (patch)
treebdbf8e4379b9ef775668976b4a0d1dc515279812 /isys
parent1e752ea76185148825ba3984e543246b94a8f545 (diff)
downloadanaconda-d24c4410ace27384c7dd0f532f2f271b969f02b8.tar.gz
anaconda-d24c4410ace27384c7dd0f532f2f271b969f02b8.tar.xz
anaconda-d24c4410ace27384c7dd0f532f2f271b969f02b8.zip
* isys/isys.py (inet_calcNetBroad): Umm, use ntohl() so it works on all
platforms. * iw/network_gui.py (NetworkWindow.handleBroadCastError): Tell users the IPv4 information given is invalid, since this error message will occur when calculating the network and broadcast address using the IPv4 ip address and netmask. * textw/network_text.py (handleBroadCastError): Add missing error handling function for network and broadcast address calculation.
Diffstat (limited to 'isys')
-rw-r--r--isys/isys.py16
1 files changed, 6 insertions, 10 deletions
diff --git a/isys/isys.py b/isys/isys.py
index 62d6026cb..f96d5cefe 100644
--- a/isys/isys.py
+++ b/isys/isys.py
@@ -419,20 +419,16 @@ def mknod(pathname, mode, dev):
return os.mknod(pathname, mode, dev)
def inet_calcNetBroad (ip, nm):
- if isinstance (ip, type ("")):
- (ipaddr,) = struct.unpack('I', socket.inet_pton(socket.AF_INET, ip))
- else:
- ipaddr = ip
+ (ipaddr,) = struct.unpack('!I', socket.inet_pton(socket.AF_INET, ip))
+ ipaddr = socket.ntohl(ipaddr)
- if isinstance (nm, type ("")):
- (nmaddr,) = struct.unpack('I', socket.inet_pton(socket.AF_INET, nm))
- else:
- nmaddr = nm
+ (nmaddr,) = struct.unpack('!I', socket.inet_pton(socket.AF_INET, nm))
+ nmaddr = socket.ntohl(nmaddr)
netaddr = ipaddr & nmaddr
bcaddr = netaddr | (~nmaddr)
- nw = socket.inet_ntop(socket.AF_INET, struct.pack('i', netaddr))
- bc = socket.inet_ntop(socket.AF_INET, struct.pack('i', bcaddr))
+ nw = socket.inet_ntop(socket.AF_INET, struct.pack('I', netaddr))
+ bc = socket.inet_ntop(socket.AF_INET, struct.pack('I', bcaddr))
return (nw, bc)