diff options
author | David Cantrell <dcantrell@redhat.com> | 2006-09-06 18:20:08 +0000 |
---|---|---|
committer | David Cantrell <dcantrell@redhat.com> | 2006-09-06 18:20:08 +0000 |
commit | 8ffb06e432e3432efe95796730ef9f879c1d1957 (patch) | |
tree | 2d26277f3ac33c28ecbff0cab124b208364d7033 | |
parent | d2e8a32bd2e7146d90106867a12554be50559fbe (diff) | |
download | anaconda-8ffb06e432e3432efe95796730ef9f879c1d1957.tar.gz anaconda-8ffb06e432e3432efe95796730ef9f879c1d1957.tar.xz anaconda-8ffb06e432e3432efe95796730ef9f879c1d1957.zip |
* isys/isys.py: Remove inet_aton() and inet_ntoa(). Replaced calls
to these functions with inet_pton() and inet_ntop().
* isys/isys.py: Added inet_convertNetmaskToPrefix() utility function
to convert dotted-quad IPv4 netmasks to CIDR prefix values.
* iw/network_gui.py (createIPRepr): Renamed to createIPV4Repr() and
have it write out ip/prefix rather than ip/netmask.
* iw/network_gui.py (createIPV4Repr): Added to handle IPv6 write
outs to the tree store.
* iw/network_gui.py (NetworkWindow.editDevice): Add IPv6 info to
the tree store.
* iw/network_gui.py (NetworkWindow.setupDevices): Initialize tree
store with IPv4 and IPv6 information.
-rw-r--r-- | ChangeLog | 20 | ||||
-rw-r--r-- | isys/isys.py | 35 | ||||
-rw-r--r-- | iw/network_gui.py | 23 |
3 files changed, 58 insertions, 20 deletions
@@ -1,3 +1,23 @@ +2006-09-06 David Cantrell <dcantrell@redhat.com> + + * isys/isys.py: Remove inet_aton() and inet_ntoa(). Replaced calls + to these functions with inet_pton() and inet_ntop(). + + * isys/isys.py: Added inet_convertNetmaskToPrefix() utility function + to convert dotted-quad IPv4 netmasks to CIDR prefix values. + + * iw/network_gui.py (createIPRepr): Renamed to createIPV4Repr() and + have it write out ip/prefix rather than ip/netmask. + + * iw/network_gui.py (createIPV4Repr): Added to handle IPv6 write + outs to the tree store. + + * iw/network_gui.py (NetworkWindow.editDevice): Add IPv6 info to + the tree store. + + * iw/network_gui.py (NetworkWindow.setupDevices): Initialize tree + store with IPv4 and IPv6 information. + 2006-09-06 Chris Lumens <clumens@redhat.com> * yuminstal.py (YumBackend.doRepoSetup): Iterate over enabled repos, diff --git a/isys/isys.py b/isys/isys.py index efedeef1d..da51abd4d 100644 --- a/isys/isys.py +++ b/isys/isys.py @@ -413,31 +413,36 @@ def mknod(pathname, mode, dev): DeprecationWarning, stacklevel=2) return os.mknod(pathname, mode, dev) -# XXX: Use socket.getnameinfo for ipv6 compatibility -def inet_ntoa (addr): - return socket.inet_ntoa(struct.pack('i', addr)) - -def inet_aton (addr): - try: - return struct.unpack('I', socket.inet_aton(addr))[0] - except: - raise ValueError - def inet_calcNetBroad (ip, nm): if isinstance (ip, type ("")): - ipaddr = inet_aton (ip) + (ipaddr,) = struct.unpack('I', socket.inet_pton(socket.AF_INET, ip)) else: ipaddr = ip if isinstance (nm, type ("")): - nmaddr = inet_aton (nm) + (nmaddr,) = struct.unpack('I', socket.inet_pton(socket.AF_INET, nm)) else: nmaddr = nm netaddr = ipaddr & nmaddr - bcaddr = netaddr | (~nmaddr); - - return (inet_ntoa (netaddr), inet_ntoa (bcaddr)) + 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)) + + return (nw, bc) + +# Converts IPv4 netmasks in dotted-quad notation to the CIDR prefix +def inet_convertNetmaskToPrefix (netmask): + (nm,) = struct.unpack('I', socket.inet_pton(socket.AF_INET, netmask)) + prefix = 0 + + while prefix < 33: + if (nm >> prefix) == 0: + return prefix + + prefix += 1 + + return prefix def getopt(*args): warnings.warn("isys.getopt is deprecated. Use optparse instead.", diff --git a/iw/network_gui.py b/iw/network_gui.py index 6c94661f0..bbf4aec96 100644 --- a/iw/network_gui.py +++ b/iw/network_gui.py @@ -485,7 +485,8 @@ class NetworkWindow(InstallWindow): self.devices[dev].set(('bootproto', bootproto)) self.devices[dev].set(('ONBOOT', onboot)) model.set_value(iter, 0, onboot == 'yes') - model.set_value(iter, 2, self.createIPRepr(self.devices[dev])) + model.set_value(iter, 2, self.createIPV4Repr(self.devices[dev])) + model.set_value(iter, 3, self.createIPV6Repr(self.devices[dev])) editWin.destroy() @@ -494,12 +495,22 @@ class NetworkWindow(InstallWindow): return - def createIPRepr(self, device): + def createIPV4Repr(self, device): bootproto = device.get("bootproto") if bootproto == "dhcp": ip = "DHCP" else: - ip = "%s/%s" % (device.get("ipaddr"), device.get("netmask")) + prefix = isys.inet_convertNetmaskToPrefix(device.get("netmask")) + ip = "%s/%s" % (device.get("ipaddr"), prefix,) + + return ip + + def createIPV6Repr(self, device): + bootproto = device.get("bootproto") + if bootproto == "dhcp": + ip = "DHCP" + else: + ip = "%s" % (device.get("ipv6addr"),) return ip @@ -550,6 +561,7 @@ class NetworkWindow(InstallWindow): store = gtk.TreeStore(gobject.TYPE_BOOLEAN, gobject.TYPE_STRING, + gobject.TYPE_STRING, gobject.TYPE_STRING) self.ethdevices = NetworkDeviceCheckList(3, store, clickCB=self.onbootToggleCB) @@ -566,7 +578,8 @@ class NetworkWindow(InstallWindow): bootproto = 'dhcp' self.devices[device].set(("bootproto", bootproto)) - ip = self.createIPRepr(self.devices[device]) + ipv4 = self.createIPV4Repr(self.devices[device]) + ipv6 = self.createIPV6Repr(self.devices[device]) # only if we want descriptions in the master device list # currently too wide, but might be able to do it with a tooltip on @@ -580,7 +593,7 @@ class NetworkWindow(InstallWindow): # self.ethdevices.append_row((device, ip, descr), active) # # use this for now - self.ethdevices.append_row((device, ip), active) + self.ethdevices.append_row((device, ipv4, ipv6), active) num += 1 |