Blame SOURCES/python-ethtool-0.6-make-pifconfig-output-all-ipv4-addresses-for-interface.patch

becf37
--- python-ethtool-0.6/pifconfig.py.orig	2013-08-07 17:11:51.483883885 +0200
becf37
+++ python-ethtool-0.6/pifconfig.py	2013-08-07 17:20:31.004075388 +0200
becf37
@@ -14,7 +14,7 @@
becf37
 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
becf37
 #   General Public License for more details.
becf37
 
becf37
-import getopt, ethtool, sys
becf37
+import getopt, ethtool, socket, struct, sys
becf37
 from optparse import OptionParser
becf37
 
becf37
 def flags2str(flags):
becf37
@@ -54,18 +54,23 @@
becf37
 
becf37
 	return string.strip()
becf37
 
becf37
+def bits2netmask(bits):
becf37
+	mask = (1<<32) - (1<<32>>bits)
becf37
+	return socket.inet_ntoa(struct.pack(">L", mask))
becf37
+
becf37
 def show_config(device):
becf37
-	ipaddr = ethtool.get_ipaddr(device)
becf37
-	netmask = ethtool.get_netmask(device)
becf37
+	info = ethtool.get_interfaces_info(device)[0]
becf37
 	flags = ethtool.get_flags(device)
becf37
 	print '%-9.9s' % device,
becf37
 	if not (flags & ethtool.IFF_LOOPBACK):
becf37
-		print "HWaddr %s" % ethtool.get_hwaddr(device),
becf37
-	print '''
becf37
-          inet addr:%s''' % ipaddr,
becf37
-	if not (flags & (ethtool.IFF_LOOPBACK | ethtool.IFF_POINTOPOINT)):
becf37
-		print "Bcast:%s" % ethtool.get_broadcast(device),
becf37
-	print '  Mask:%s' % netmask
becf37
+		print "HWaddr %s" % ethtool.get_hwaddr(device)
becf37
+	else:
becf37
+		print
becf37
+	for addr in info.get_ipv4_addresses():
becf37
+		print '          inet addr:%s' % addr.address,
becf37
+		if not (flags & (ethtool.IFF_LOOPBACK | ethtool.IFF_POINTOPOINT)):
becf37
+			print "Bcast:%s" % ethtool.get_broadcast(device),
becf37
+		print '  Mask:%s' % bits2netmask(addr.netmask)
becf37
 	for info in ethtool.get_interfaces_info(device):
becf37
 		for addr in info.get_ipv6_addresses():
becf37
 			print ("	  inet6 addr: %s/%s Scope: %s"