@@ -100,8 +100,7 @@ int _ethtool_etherinfo_init(etherinfo_py *self, PyObject *args, PyObject *kwds)
100100
101101 The return value is a *borrowed reference* (or NULL)
102102*/
103- static PyNetlinkIPv4Address *
104- get_last_address (etherinfo_py * self )
103+ static PyNetlinkIPaddress * get_last_ipv4_address (etherinfo_py * self )
105104{
106105 Py_ssize_t size ;
107106 PyObject * list ;
@@ -119,8 +118,8 @@ get_last_address(etherinfo_py *self)
119118 size = PyList_Size (list );
120119 if (size > 0 ) {
121120 PyObject * item = PyList_GetItem (list , size - 1 );
122- if (Py_TYPE (item ) == & ethtool_netlink_ipv4_address_Type ) {
123- return (PyNetlinkIPv4Address * )item ;
121+ if (Py_TYPE (item ) == & ethtool_netlink_ip_address_Type ) {
122+ return (PyNetlinkIPaddress * )item ;
124123 }
125124 }
126125
@@ -138,7 +137,7 @@ get_last_address(etherinfo_py *self)
138137PyObject * _ethtool_etherinfo_getter (etherinfo_py * self , PyObject * attr_o )
139138{
140139 char * attr = PyString_AsString (attr_o );
141- PyNetlinkIPv4Address * py_addr ;
140+ PyNetlinkIPaddress * py_addr ;
142141
143142 if ( !self || !self -> data ) {
144143 PyErr_SetString (PyExc_AttributeError , "No data available" );
@@ -153,24 +152,24 @@ PyObject *_ethtool_etherinfo_getter(etherinfo_py *self, PyObject *attr_o)
153152 } else if ( strcmp (attr , "ipv4_address" ) == 0 ) {
154153 get_etherinfo (self -> data , NLQRY_ADDR );
155154 /* For compatiblity with old approach, return last IPv4 address: */
156- py_addr = get_last_address (self );
155+ py_addr = get_last_ipv4_address (self );
157156 if (py_addr ) {
158- if (py_addr -> ipv4_address ) {
159- Py_INCREF (py_addr -> ipv4_address );
160- return py_addr -> ipv4_address ;
157+ if (py_addr -> local ) {
158+ Py_INCREF (py_addr -> local );
159+ return py_addr -> local ;
161160 }
162161 }
163162 Py_RETURN_NONE ;
164163 } else if ( strcmp (attr , "ipv4_netmask" ) == 0 ) {
165164 get_etherinfo (self -> data , NLQRY_ADDR );
166- py_addr = get_last_address (self );
165+ py_addr = get_last_ipv4_address (self );
167166 if (py_addr ) {
168- return PyInt_FromLong (py_addr -> ipv4_netmask );
167+ return PyInt_FromLong (py_addr -> prefixlen );
169168 }
170169 return PyInt_FromLong (0 );
171170 } else if ( strcmp (attr , "ipv4_broadcast" ) == 0 ) {
172171 get_etherinfo (self -> data , NLQRY_ADDR );
173- py_addr = get_last_address (self );
172+ py_addr = get_last_ipv4_address (self );
174173 if (py_addr ) {
175174 if (py_addr -> ipv4_broadcast ) {
176175 Py_INCREF (py_addr -> ipv4_broadcast );
@@ -229,10 +228,10 @@ PyObject *_ethtool_etherinfo_str(etherinfo_py *self)
229228 if ( self -> data -> ethinfo -> ipv4_addresses ) {
230229 Py_ssize_t i ;
231230 for (i = 0 ; i < PyList_Size (self -> data -> ethinfo -> ipv4_addresses ); i ++ ) {
232- PyNetlinkIPv4Address * py_addr = (PyNetlinkIPv4Address * )PyList_GetItem (self -> data -> ethinfo -> ipv4_addresses , i );
231+ PyNetlinkIPaddress * py_addr = (PyNetlinkIPaddress * )PyList_GetItem (self -> data -> ethinfo -> ipv4_addresses , i );
233232 PyObject * tmp = PyString_FromFormat ("\tIPv4 address: " );
234- PyString_Concat (& tmp , py_addr -> ipv4_address );
235- PyString_ConcatAndDel (& tmp , PyString_FromFormat ("/%d" , py_addr -> ipv4_netmask ));
233+ PyString_Concat (& tmp , py_addr -> local );
234+ PyString_ConcatAndDel (& tmp , PyString_FromFormat ("/%d" , py_addr -> prefixlen ));
236235 if (py_addr -> ipv4_broadcast ) {
237236 PyString_ConcatAndDel (& tmp ,
238237 PyString_FromString (" Broadcast: " ));
@@ -246,12 +245,12 @@ PyObject *_ethtool_etherinfo_str(etherinfo_py *self)
246245 if ( self -> data -> ethinfo -> ipv6_addresses ) {
247246 Py_ssize_t i ;
248247 for (i = 0 ; i < PyList_Size (self -> data -> ethinfo -> ipv6_addresses ); i ++ ) {
249- PyNetlinkIPv6Address * py_addr = (PyNetlinkIPv6Address * )PyList_GetItem (self -> data -> ethinfo -> ipv6_addresses , i );
248+ PyNetlinkIPaddress * py_addr = (PyNetlinkIPaddress * )PyList_GetItem (self -> data -> ethinfo -> ipv6_addresses , i );
250249 PyObject * tmp = PyString_FromFormat ("\tIPv6 address: [" );
251- PyString_Concat (& tmp , py_addr -> ipv6_scope );
250+ PyString_Concat (& tmp , py_addr -> scope );
252251 PyString_ConcatAndDel (& tmp , PyString_FromString ("] " ));
253- PyString_Concat (& tmp , py_addr -> ipv6_address );
254- PyString_ConcatAndDel (& tmp , PyString_FromFormat ("/%d" , py_addr -> ipv6_netmask ));
252+ PyString_Concat (& tmp , py_addr -> local );
253+ PyString_ConcatAndDel (& tmp , PyString_FromFormat ("/%d" , py_addr -> prefixlen ));
255254 PyString_ConcatAndDel (& tmp , PyString_FromString ("\n" ));
256255 PyString_ConcatAndDel (& ret , tmp );
257256 }
@@ -318,10 +317,9 @@ static PyObject *_ethtool_etherinfo_get_ipv6_addresses(etherinfo_py *self, PyObj
318317 */
319318static PyMethodDef _ethtool_etherinfo_methods [] = {
320319 {"get_ipv4_addresses" , (PyCFunction )_ethtool_etherinfo_get_ipv4_addresses , METH_NOARGS ,
321- "Retrieve configured IPv4 addresses. Returns a list of NetlinkIP4Address objects" },
320+ "Retrieve configured IPv4 addresses. Returns a list of NetlinkIPaddress objects" },
322321 {"get_ipv6_addresses" , (PyCFunction )_ethtool_etherinfo_get_ipv6_addresses , METH_NOARGS ,
323- "Retrieve configured IPv6 addresses. Returns a list of NetlinkIP6Address objects" },
324-
322+ "Retrieve configured IPv6 addresses. Returns a list of NetlinkIPaddress objects" },
325323 {NULL } /**< No methods defined */
326324};
327325
0 commit comments