From e9aa46ab32a45bd7fc0ad32573d1db84f5049554 Mon Sep 17 00:00:00 2001 From: David Sommerseth Date: Fri, 30 Jul 2010 19:30:30 +0200 Subject: Improved IPv6 support As the IPv6 protocol allows a single device to have more than one IPv6 address, the previous implementation did not provide all IPv6 information. It would reject all except the last parsed IPv6 address. NOTE: This implementation will break the previous API. This change removes the ethtool.etherinfo.ipv6_address and ethtool.etherinfo.ipv6_netmask members. A new member is added, ethtool.etherinfo.ipv6_addresses (in plural). This contains a tupple list containing of ethtool.etherinfo_ipv6addr objects, one object for each configured IPv6 address on the device. These objects have the following members available: .address - The IPv6 address .netmask - The IPv6 netmask (in bit notation) .scope - A string with the IPv6 address scope Example code: import ethtool devs = ethtool.get_interfaces_info('eth0') for ip6 in devs[0].ipv6_addresses: print "[%s] %s/%i" % (ip6.scope, ip6.address, ip6.netmask) Signed-off-by: David Sommerseth --- python-ethtool/ethtool.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'python-ethtool/ethtool.c') diff --git a/python-ethtool/ethtool.c b/python-ethtool/ethtool.c index c6a9af4..7115fb0 100644 --- a/python-ethtool/ethtool.c +++ b/python-ethtool/ethtool.c @@ -32,6 +32,7 @@ static struct _nlconnection nlconnection; extern PyTypeObject ethtool_etherinfoType; +extern PyTypeObject ethtool_etherinfoIPv6Type; #ifndef IFF_DYNAMIC #define IFF_DYNAMIC 0x8000 /* dialup device with changing addresses*/ @@ -1025,6 +1026,12 @@ PyMODINIT_FUNC initethtool(void) Py_INCREF(ðtool_etherinfoType); PyModule_AddObject(m, "etherinfo", (PyObject *)ðtool_etherinfoType); + // Prepare the ethtool.etherinfo_ipv6addr class + if (PyType_Ready(ðtool_etherinfoIPv6Type) < 0) + return; + Py_INCREF(ðtool_etherinfoIPv6Type); + PyModule_AddObject(m, "etherinfo_ipv6addr", (PyObject *)ðtool_etherinfoIPv6Type); + // Prepare an internal netlink connection object if( open_netlink(&nlconnection) ) { PyModule_AddObject(m, "__nlconnection", -- cgit