From: TizenOpenSource Date: Tue, 26 Dec 2023 07:54:40 +0000 (+0900) Subject: Imported Upstream version 0.11.0 X-Git-Tag: upstream/0.11.0^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=40afcbd12be1ae3d97a5261d850510097484aabe;p=platform%2Fupstream%2Fpython3-netifaces.git Imported Upstream version 0.11.0 --- diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0b5bad0 --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ +Copyright (c) 2007-2018 Alastair Houghton + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/MANIFEST.in b/MANIFEST.in new file mode 100644 index 0000000..c8a4237 --- /dev/null +++ b/MANIFEST.in @@ -0,0 +1,2 @@ +include LICENSE +include test.py diff --git a/PKG-INFO b/PKG-INFO index 53a4c01..910d98d 100644 --- a/PKG-INFO +++ b/PKG-INFO @@ -1,17 +1,32 @@ Metadata-Version: 1.1 Name: netifaces -Version: 0.10.5 +Version: 0.11.0 Summary: Portable network interface information. -Home-page: https://bitbucket.org/al45tair/netifaces +Home-page: https://github.com/al45tair/netifaces Author: Alastair Houghton Author-email: alastair@alastairs-place.net License: MIT License -Description: netifaces 0.10.4 +Description: netifaces 0.10.8 ================ - .. image:: https://drone.io/bitbucket.org/al45tair/netifaces/status.png - :target: https://drone.io/bitbucket.org/al45tair/netifaces/latest - :alt: Build Status + +-------------+------------------+ + | Linux/macOS | |BuildStatus| | + +-------------+------------------+ + | Windows | |WinBuildStatus| | + +-------------+------------------+ + + .. |BuildStatus| image:: https://travis-ci.org/al45tair/netifaces.svg?branch=master + :target: https://travis-ci.org/al45tair/netifaces + :alt: Build Status (Linux/Mac) + + .. |WinBuildStatus| image:: https://ci.appveyor.com/api/projects/status/3ctn1bl0aigpfjoo/branch/master?svg=true + :target: https://ci.appveyor.com/project/al45tair/netifaces/branch/master + :alt: Build Status (Windows) + + .. warning:: + + netifaces needs a new maintainer. al45tair is no longer able to maintain it + or make new releases due to work commitments. 1. What is this? ---------------- @@ -32,10 +47,13 @@ Description: netifaces 0.10.4 First you need to install it, which you can do by typing:: - tar xvzf netifaces-0.10.4.tar.gz - cd netifaces-0.10.4 + tar xvzf netifaces-0.10.8.tar.gz + cd netifaces-0.10.8 python setup.py install + **Note that you will need the relevant developer tools for your platform**, + as netifaces is written in C and installing this way will compile the extension. + Once that's done, you'll need to start Python and do something like the following:: @@ -165,39 +183,19 @@ Description: netifaces 0.10.4 It gets regular testing on OS X, Linux and Windows. It has also been used successfully on Solaris, and it's expected to work properly on other UNIX-like systems as well. If you are running something that is not supported, and - wish to contribute a patch, please use BitBucket to send a pull request. + wish to contribute a patch, please use Github to send a pull request. 4. What license is this under? ------------------------------ - It's an MIT-style license. Here goes: - - Copyright (c) 2007-2014 Alastair Houghton - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. + It's an MIT-style license. See `LICENSE <./LICENSE>`_. 5. Why the jump to 0.10.0? -------------------------- Because someone released a fork of netifaces with the version 0.9.0. - Hopefully skipping the version number should remove any confusion. In - addition starting with 0.10.0 Python 3 is now supported and other + Hopefully skipping the version number should remove any confusion. In + addition starting with 0.10.0 Python 3 is now supported and other features/bugfixes have been included as well. See the CHANGELOG for a more complete list of changes. @@ -208,7 +206,10 @@ Classifier: License :: OSI Approved :: MIT License Classifier: Topic :: System :: Networking Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 -Classifier: Programming Language :: Python :: 2.5 -Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 +Classifier: Programming Language :: Python :: 3.4 +Classifier: Programming Language :: Python :: 3.5 +Classifier: Programming Language :: Python :: 3.6 +Classifier: Programming Language :: Python :: 3.7 +Classifier: Programming Language :: Python :: 3.8 diff --git a/README.rst b/README.rst index 67889c8..6625714 100644 --- a/README.rst +++ b/README.rst @@ -1,9 +1,24 @@ -netifaces 0.10.4 +netifaces 0.10.8 ================ -.. image:: https://drone.io/bitbucket.org/al45tair/netifaces/status.png - :target: https://drone.io/bitbucket.org/al45tair/netifaces/latest - :alt: Build Status ++-------------+------------------+ +| Linux/macOS | |BuildStatus| | ++-------------+------------------+ +| Windows | |WinBuildStatus| | ++-------------+------------------+ + +.. |BuildStatus| image:: https://travis-ci.org/al45tair/netifaces.svg?branch=master + :target: https://travis-ci.org/al45tair/netifaces + :alt: Build Status (Linux/Mac) + +.. |WinBuildStatus| image:: https://ci.appveyor.com/api/projects/status/3ctn1bl0aigpfjoo/branch/master?svg=true + :target: https://ci.appveyor.com/project/al45tair/netifaces/branch/master + :alt: Build Status (Windows) + +.. warning:: + + netifaces needs a new maintainer. al45tair is no longer able to maintain it + or make new releases due to work commitments. 1. What is this? ---------------- @@ -24,10 +39,13 @@ This package attempts to solve that problem. First you need to install it, which you can do by typing:: - tar xvzf netifaces-0.10.4.tar.gz - cd netifaces-0.10.4 + tar xvzf netifaces-0.10.8.tar.gz + cd netifaces-0.10.8 python setup.py install +**Note that you will need the relevant developer tools for your platform**, +as netifaces is written in C and installing this way will compile the extension. + Once that's done, you'll need to start Python and do something like the following:: @@ -157,38 +175,18 @@ system out there where this just won't work. It gets regular testing on OS X, Linux and Windows. It has also been used successfully on Solaris, and it's expected to work properly on other UNIX-like systems as well. If you are running something that is not supported, and -wish to contribute a patch, please use BitBucket to send a pull request. +wish to contribute a patch, please use Github to send a pull request. 4. What license is this under? ------------------------------ -It's an MIT-style license. Here goes: - -Copyright (c) 2007-2014 Alastair Houghton - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. +It's an MIT-style license. See `LICENSE <./LICENSE>`_. 5. Why the jump to 0.10.0? -------------------------- Because someone released a fork of netifaces with the version 0.9.0. -Hopefully skipping the version number should remove any confusion. In -addition starting with 0.10.0 Python 3 is now supported and other +Hopefully skipping the version number should remove any confusion. In +addition starting with 0.10.0 Python 3 is now supported and other features/bugfixes have been included as well. See the CHANGELOG for a more complete list of changes. diff --git a/netifaces.c b/netifaces.c index 27e7688..839c42c 100644 --- a/netifaces.c +++ b/netifaces.c @@ -1,9 +1,21 @@ #include +/* Before Python 2.6, PyUnicode_FromString doesn't exist */ +#if PY_MAJOR_VERSION < 2 || (PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION < 6) +PyObject *PyUnicode_FromString(const char *s) +{ + Py_ssize_t len = strlen(s); + if (!len) { + Py_UNICODE uc = 0; + return PyUnicode_FromUnicode(&uc, 0); + } + return PyUnicode_DecodeUTF8(s, len, NULL); +} +#endif + /* Python 3 compatibility */ #if PY_MAJOR_VERSION >= 3 #define PyInt_FromLong PyLong_FromLong -#define PyString_FromString PyUnicode_FromString #define MODULE_ERROR NULL #define MODULE_RETURN(v) return (v) @@ -38,10 +50,15 @@ # include # endif +/* RTNL_FAMILY_MAX not there yet in old kernels, see linux commit 25239ce */ # if HAVE_PF_NETLINK # include # include # include +# if !defined(RTNL_FAMILY_MAX) +# include +# define RTNL_FAMILY_MAX NPROTO +# endif # include # endif @@ -323,7 +340,7 @@ getnameinfo (const struct sockaddr *addr, int addr_len, static int string_from_sockaddr (struct sockaddr *addr, char *buffer, - int buflen) + size_t buflen) { struct sockaddr* bigaddr = 0; int failure; @@ -420,7 +437,7 @@ string_from_sockaddr (struct sockaddr *addr, static int string_from_netmask (struct sockaddr *addr, char *buffer, - int buflen) + size_t buflen) { #ifdef AF_INET6 if (addr && addr->sa_family == AF_INET6) { @@ -445,9 +462,9 @@ string_from_netmask (struct sockaddr *addr, --zx; if (x & 0x0f) zx -= 4; - if (x & 0x03) + if (x & 0x33) zx -= 2; - if (x & 0x05) + if (x & 0x55) zx -= 1; zeroes += zx; @@ -490,7 +507,7 @@ string_from_netmask (struct sockaddr *addr, sprintf (pfxbuf, "/%u", prefix); - if (bufend - bufptr > strlen(pfxbuf)) + if (bufend - bufptr > (int)strlen(pfxbuf)) strcpy (bufptr, pfxbuf); if (buflen) @@ -596,7 +613,7 @@ netmask_from_prefix (unsigned prefix) buffer[sizeof(buffer) - 1] = '\0'; - return PyString_FromString(buffer); + return PyUnicode_FromString(buffer); } /* We dynamically bind to WSAAddressToStringW or WSAAddressToStringA @@ -661,7 +678,7 @@ string_from_address(SOCKADDR *addr, DWORD addrlen) iRet = AddressToStringA (addr, addrlen, NULL, buffer, &dwLen); if (iRet == 0) - return PyString_FromString (buffer); + return PyUnicode_FromString (buffer); } return NULL; @@ -785,7 +802,7 @@ ifaddrs (PyObject *self, PyObject *args) } *--ptr = '\0'; - hwaddr = PyString_FromString (buffer); + hwaddr = PyUnicode_FromString (buffer); dict = PyDict_New (); if (!dict) { @@ -838,7 +855,9 @@ ifaddrs (PyObject *self, PyObject *args) = (struct sockaddr_in *)pPrefix->Address.lpSockaddr; if (pPrefixAddr->sin_family != AF_INET - || (prefix_len >= 0 && pPrefix->PrefixLength < prefix_len)) + || (prefix_len >= 0 + && pPrefix->PrefixLength < (unsigned)prefix_len) + || (prefix_len >= 0 && pPrefix->PrefixLength == 32)) continue; if (compare_bits (&pPrefixAddr->sin_addr, @@ -911,7 +930,9 @@ ifaddrs (PyObject *self, PyObject *args) = (struct sockaddr_in6 *)pPrefix->Address.lpSockaddr; if (pPrefixAddr->sin6_family != AF_INET6 - || (prefix_len >= 0 && pPrefix->PrefixLength < prefix_len)) + || (prefix_len >= 0 + && pPrefix->PrefixLength < (unsigned)prefix_len) + || (prefix_len >= 0 && pPrefix->PrefixLength == 128)) continue; if (compare_bits (&pPrefixAddr->sin6_addr, @@ -1003,7 +1024,7 @@ ifaddrs (PyObject *self, PyObject *args) char buffer[256]; PyObject *pyaddr = NULL, *netmask = NULL, *braddr = NULL, *flags = NULL; - if (strcmp (addr->ifa_name, ifname) != 0) + if (addr->ifa_name == NULL || strcmp (addr->ifa_name, ifname) != 0) continue; /* We mark the interface as found, even if there are no addresses; @@ -1045,13 +1066,13 @@ ifaddrs (PyObject *self, PyObject *args) #endif /* HAVE_IPV6_SOCKET_IOCTLS */ if (string_from_sockaddr (addr->ifa_addr, buffer, sizeof (buffer)) == 0) - pyaddr = PyString_FromString (buffer); + pyaddr = PyUnicode_FromString (buffer); if (string_from_netmask (addr->ifa_netmask, buffer, sizeof (buffer)) == 0) - netmask = PyString_FromString (buffer); + netmask = PyUnicode_FromString (buffer); if (string_from_sockaddr (addr->ifa_broadaddr, buffer, sizeof (buffer)) == 0) - braddr = PyString_FromString (buffer); + braddr = PyUnicode_FromString (buffer); /* Cygwin's implementation of getaddrinfo() is buggy and returns broadcast addresses for 169.254.0.0/16. Nix them here. */ @@ -1129,7 +1150,7 @@ ifaddrs (PyObject *self, PyObject *args) found = TRUE; if (string_from_sockaddr ((struct sockaddr *)&ifr.CNAME(ifr_addr), buffer, sizeof (buffer)) == 0) { - PyObject *hwaddr = PyString_FromString (buffer); + PyObject *hwaddr = PyUnicode_FromString (buffer); PyObject *dict = PyDict_New (); if (!hwaddr || !dict) { @@ -1161,7 +1182,7 @@ ifaddrs (PyObject *self, PyObject *args) found = TRUE; if (string_from_sockaddr ((struct sockaddr *)&ifr.CNAME(ifr_addr), buffer, sizeof (buffer)) == 0) - addr = PyString_FromString (buffer); + addr = PyUnicode_FromString (buffer); } #endif @@ -1174,7 +1195,7 @@ ifaddrs (PyObject *self, PyObject *args) found = TRUE; if (string_from_sockaddr ((struct sockaddr *)&ifr.CNAME(ifr_addr), buffer, sizeof (buffer)) == 0) - netmask = PyString_FromString (buffer); + netmask = PyUnicode_FromString (buffer); } #endif @@ -1200,7 +1221,7 @@ ifaddrs (PyObject *self, PyObject *args) found = TRUE; if (string_from_sockaddr ((struct sockaddr *)&ifr.CNAME(ifr_addr), buffer, sizeof (buffer)) == 0) - braddr = PyString_FromString (buffer); + braddr = PyUnicode_FromString (buffer); } #endif @@ -1213,7 +1234,7 @@ ifaddrs (PyObject *self, PyObject *args) found = TRUE; if (string_from_sockaddr ((struct sockaddr *)&ifr.CNAME(ifr_addr), buffer, sizeof (buffer)) == 0) - dstaddr = PyString_FromString (buffer); + dstaddr = PyUnicode_FromString (buffer); } #endif @@ -1313,7 +1334,7 @@ interfaces (PyObject *self) } for (pInfo = pAdapterAddresses; pInfo; pInfo = pInfo->Next) { - PyObject *ifname = (PyObject *)PyString_FromString (pInfo->AdapterName); + PyObject *ifname = (PyObject *)PyUnicode_FromString (pInfo->AdapterName); PyList_Append (result, ifname); Py_DECREF (ifname); @@ -1336,8 +1357,11 @@ interfaces (PyObject *self) } for (addr = addrs; addr; addr = addr->ifa_next) { + if (addr->ifa_name == NULL) + continue; + if (!prev_name || strncmp (addr->ifa_name, prev_name, IFNAMSIZ) != 0) { - PyObject *ifname = PyString_FromString (addr->ifa_name); + PyObject *ifname = PyUnicode_FromString (addr->ifa_name); if (!PySequence_Contains (result, ifname)) PyList_Append (result, ifname); @@ -1407,7 +1431,7 @@ interfaces (PyObject *self) + ifc.CNAME(ifc_len)); while (pfreq < pfreqend) { if (!prev_name || strncmp (prev_name, pfreq->CNAME(ifr_name), IFNAMSIZ) != 0) { - PyObject *name = PyString_FromString (pfreq->CNAME(ifr_name)); + PyObject *name = PyUnicode_FromString (pfreq->CNAME(ifr_name)); if (!PySequence_Contains (result, name)) PyList_Append (result, name); @@ -1543,7 +1567,7 @@ gateways (PyObject *self) break; } - ifname = PyUnicode_FromUnicode (pwcsName, wcslen (pwcsName)); + ifname = PyUnicode_FromWideChar (pwcsName, wcslen (pwcsName)); isdefault = bBest ? Py_True : Py_False; tuple = PyTuple_Pack (3, gateway, ifname, isdefault); @@ -1650,8 +1674,8 @@ gateways (PyObject *self) if (bBest) dwBestMetric = table->table[n].dwForwardMetric1; - ifname = PyUnicode_FromUnicode (pwcsName, wcslen (pwcsName)); - gateway = PyString_FromString (gwbuf); + ifname = PyUnicode_FromWideChar (pwcsName, wcslen (pwcsName)); + gateway = PyUnicode_FromString (gwbuf); isdefault = bBest ? Py_True : Py_False; tuple = PyTuple_Pack (3, gateway, ifname, isdefault); @@ -1870,8 +1894,14 @@ gateways (PyObject *self) attr = RTA_NEXT(attr, len); } + static const unsigned char ipv4_default[4] = {}; + static const unsigned char ipv6_default[16] = {}; + /* We're looking for gateways with no destination */ - if (!dst && gw && ifndx >= 0) { + if ((!dst + || (pmsg->rt.rtm_family == AF_INET && !memcmp(dst, ipv4_default, sizeof(ipv4_default))) + || (pmsg->rt.rtm_family == AF_INET6 && !memcmp(dst, ipv6_default, sizeof(ipv6_default))) + ) && gw && ifndx >= 0) { char buffer[256]; char ifnamebuf[IF_NAMESIZE]; char *ifname; @@ -1897,20 +1927,26 @@ gateways (PyObject *self) isdefault = pmsg->rt.rtm_table == RT_TABLE_MAIN ? Py_True : Py_False; + /* Priority starts at 0, having none means we use kernel default (0) */ + if (priority < 0) { + priority = 0; + } + /* Try to pick the active default route based on priority (which is displayed in the UI as "metric", confusingly) */ if (pmsg->rt.rtm_family < RTNL_FAMILY_MAX) { - if (def_priorities[pmsg->rt.rtm_family] == -1) + /* If no active default route found, or metric is lower */ + if (def_priorities[pmsg->rt.rtm_family] == -1 + || priority < def_priorities[pmsg->rt.rtm_family]) + /* Set new default */ def_priorities[pmsg->rt.rtm_family] = priority; - else { - if (priority == -1 - || priority > def_priorities[pmsg->rt.rtm_family]) - isdefault = Py_False; - } + else + /* Leave default, but unset isdefault for iface tuple */ + isdefault = Py_False; } - pyifname = PyString_FromString (ifname); - pyaddr = PyString_FromString (buffer); + pyifname = PyUnicode_FromString (ifname); + pyaddr = PyUnicode_FromString (buffer); tuple = PyTuple_Pack (3, pyaddr, pyifname, isdefault); @@ -1986,7 +2022,7 @@ gateways (PyObject *self) buffer = ptr; ret = sysctl (mib, 6, buffer, &len, 0, 0); - } while (ret != 0 || errno == ENOMEM || errno == EINTR); + } while (ret != 0 && (errno == ENOMEM || errno == EINTR)); if (ret < 0) { PyErr_SetFromErrno (PyExc_OSError); @@ -2015,7 +2051,7 @@ gateways (PyObject *self) continue; } - pyifname = PyString_FromString (ifname); + pyifname = PyUnicode_FromString (ifname); ptr = (char *)(msg + 1); while (ptr + sizeof (struct sockaddr) <= msgend && addrs) { @@ -2052,12 +2088,12 @@ gateways (PyObject *self) } if (addr == RTA_GATEWAY) { - char buffer[256]; + char strbuf[256]; PyObject *tuple = NULL; PyObject *deftuple = NULL; - if (string_from_sockaddr (sa, buffer, sizeof(buffer)) == 0) { - PyObject *pyaddr = PyString_FromString (buffer); + if (string_from_sockaddr (sa, strbuf, sizeof(strbuf)) == 0) { + PyObject *pyaddr = PyUnicode_FromString (strbuf); #ifdef RTF_IFSCOPE PyObject *isdefault = PyBool_FromLong (!(msg->rtm_flags & RTF_IFSCOPE)); #else @@ -2283,8 +2319,8 @@ gateways (PyObject *self) if (string_from_sockaddr ((struct sockaddr *)gw, buffer, sizeof(buffer)) == 0) { - PyObject *pyifname = PyString_FromString (ifname); - PyObject *pyaddr = PyString_FromString (buffer); + PyObject *pyifname = PyUnicode_FromString (ifname); + PyObject *pyaddr = PyUnicode_FromString (buffer); #ifdef RTF_IFSCOPE PyObject *isdefault = PyBool_FromLong (!(pmsg->rtm_flags & RTF_IFSCOPE)); #else @@ -2462,8 +2498,8 @@ gateways (PyObject *self) if (string_from_sockaddr ((struct sockaddr *)gw, buffer, sizeof(buffer)) == 0) { - PyObject *pyifname = PyString_FromString (ifname); - PyObject *pyaddr = PyString_FromString (buffer); + PyObject *pyifname = PyUnicode_FromString (ifname); + PyObject *pyaddr = PyUnicode_FromString (buffer); #ifdef RTF_IFSCOPE PyObject *isdefault = PyBool_FromLong (!(pmsg->rtm_flags & RTF_IFSCOPE)); #else @@ -2561,297 +2597,297 @@ MODULE_INIT(netifaces) #ifdef AF_UNSPEC PyModule_AddIntConstant (m, "AF_UNSPEC", AF_UNSPEC); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_UNSPEC), - PyString_FromString("AF_UNSPEC")); + PyUnicode_FromString("AF_UNSPEC")); #endif #ifdef AF_UNIX PyModule_AddIntConstant (m, "AF_UNIX", AF_UNIX); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_UNIX), - PyString_FromString("AF_UNIX")); + PyUnicode_FromString("AF_UNIX")); #endif #ifdef AF_FILE PyModule_AddIntConstant (m, "AF_FILE", AF_FILE); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_FILE), - PyString_FromString("AF_FILE")); + PyUnicode_FromString("AF_FILE")); #endif #ifdef AF_INET PyModule_AddIntConstant (m, "AF_INET", AF_INET); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_INET), - PyString_FromString("AF_INET")); + PyUnicode_FromString("AF_INET")); #endif #ifdef AF_AX25 PyModule_AddIntConstant (m, "AF_AX25", AF_AX25); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_AX25), - PyString_FromString("AF_AX25")); + PyUnicode_FromString("AF_AX25")); #endif #ifdef AF_IMPLINK PyModule_AddIntConstant (m, "AF_IMPLINK", AF_IMPLINK); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_IMPLINK), - PyString_FromString("AF_IMPLINK")); + PyUnicode_FromString("AF_IMPLINK")); #endif #ifdef AF_PUP PyModule_AddIntConstant (m, "AF_PUP", AF_PUP); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_PUP), - PyString_FromString("AF_PUP")); + PyUnicode_FromString("AF_PUP")); #endif #ifdef AF_CHAOS PyModule_AddIntConstant (m, "AF_CHAOS", AF_CHAOS); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_CHAOS), - PyString_FromString("AF_CHAOS")); + PyUnicode_FromString("AF_CHAOS")); #endif #ifdef AF_NS PyModule_AddIntConstant (m, "AF_NS", AF_NS); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_NS), - PyString_FromString("AF_NS")); + PyUnicode_FromString("AF_NS")); #endif #ifdef AF_ISO PyModule_AddIntConstant (m, "AF_ISO", AF_ISO); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_ISO), - PyString_FromString("AF_ISO")); + PyUnicode_FromString("AF_ISO")); #endif #ifdef AF_ECMA PyModule_AddIntConstant (m, "AF_ECMA", AF_ECMA); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_ECMA), - PyString_FromString("AF_ECMA")); + PyUnicode_FromString("AF_ECMA")); #endif #ifdef AF_DATAKIT PyModule_AddIntConstant (m, "AF_DATAKIT", AF_DATAKIT); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_DATAKIT), - PyString_FromString("AF_DATAKIT")); + PyUnicode_FromString("AF_DATAKIT")); #endif #ifdef AF_CCITT PyModule_AddIntConstant (m, "AF_CCITT", AF_CCITT); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_CCITT), - PyString_FromString("AF_CCITT")); + PyUnicode_FromString("AF_CCITT")); #endif #ifdef AF_SNA PyModule_AddIntConstant (m, "AF_SNA", AF_SNA); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_SNA), - PyString_FromString("AF_SNA")); + PyUnicode_FromString("AF_SNA")); #endif #ifdef AF_DECnet PyModule_AddIntConstant (m, "AF_DECnet", AF_DECnet); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_DECnet), - PyString_FromString("AF_DECnet")); + PyUnicode_FromString("AF_DECnet")); #endif #ifdef AF_DLI PyModule_AddIntConstant (m, "AF_DLI", AF_DLI); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_DLI), - PyString_FromString("AF_DLI")); + PyUnicode_FromString("AF_DLI")); #endif #ifdef AF_LAT PyModule_AddIntConstant (m, "AF_LAT", AF_LAT); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_LAT), - PyString_FromString("AF_LAT")); + PyUnicode_FromString("AF_LAT")); #endif #ifdef AF_HYLINK PyModule_AddIntConstant (m, "AF_HYLINK", AF_HYLINK); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_HYLINK), - PyString_FromString("AF_HYLINK")); + PyUnicode_FromString("AF_HYLINK")); #endif #ifdef AF_APPLETALK PyModule_AddIntConstant (m, "AF_APPLETALK", AF_APPLETALK); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_APPLETALK), - PyString_FromString("AF_APPLETALK")); + PyUnicode_FromString("AF_APPLETALK")); #endif #ifdef AF_ROUTE PyModule_AddIntConstant (m, "AF_ROUTE", AF_ROUTE); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_ROUTE), - PyString_FromString("AF_ROUTE")); + PyUnicode_FromString("AF_ROUTE")); #endif #ifdef AF_LINK PyModule_AddIntConstant (m, "AF_LINK", AF_LINK); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_LINK), - PyString_FromString("AF_LINK")); + PyUnicode_FromString("AF_LINK")); #endif #ifdef AF_PACKET PyModule_AddIntConstant (m, "AF_PACKET", AF_PACKET); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_PACKET), - PyString_FromString("AF_PACKET")); + PyUnicode_FromString("AF_PACKET")); #endif #ifdef AF_COIP PyModule_AddIntConstant (m, "AF_COIP", AF_COIP); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_COIP), - PyString_FromString("AF_COIP")); + PyUnicode_FromString("AF_COIP")); #endif #ifdef AF_CNT PyModule_AddIntConstant (m, "AF_CNT", AF_CNT); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_CNT), - PyString_FromString("AF_CNT")); + PyUnicode_FromString("AF_CNT")); #endif #ifdef AF_IPX PyModule_AddIntConstant (m, "AF_IPX", AF_IPX); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_IPX), - PyString_FromString("AF_IPX")); + PyUnicode_FromString("AF_IPX")); #endif #ifdef AF_SIP PyModule_AddIntConstant (m, "AF_SIP", AF_SIP); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_SIP), - PyString_FromString("AF_SIP")); + PyUnicode_FromString("AF_SIP")); #endif #ifdef AF_NDRV PyModule_AddIntConstant (m, "AF_NDRV", AF_NDRV); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_NDRV), - PyString_FromString("AF_NDRV")); + PyUnicode_FromString("AF_NDRV")); #endif #ifdef AF_ISDN PyModule_AddIntConstant (m, "AF_ISDN", AF_ISDN); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_ISDN), - PyString_FromString("AF_ISDN")); + PyUnicode_FromString("AF_ISDN")); #endif #ifdef AF_INET6 PyModule_AddIntConstant (m, "AF_INET6", AF_INET6); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_INET6), - PyString_FromString("AF_INET6")); + PyUnicode_FromString("AF_INET6")); #endif #ifdef AF_NATM PyModule_AddIntConstant (m, "AF_NATM", AF_NATM); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_NATM), - PyString_FromString("AF_NATM")); + PyUnicode_FromString("AF_NATM")); #endif #ifdef AF_SYSTEM PyModule_AddIntConstant (m, "AF_SYSTEM", AF_SYSTEM); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_SYSTEM), - PyString_FromString("AF_SYSTEM")); + PyUnicode_FromString("AF_SYSTEM")); #endif #ifdef AF_NETBIOS PyModule_AddIntConstant (m, "AF_NETBIOS", AF_NETBIOS); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_NETBIOS), - PyString_FromString("AF_NETBIOS")); + PyUnicode_FromString("AF_NETBIOS")); #endif #ifdef AF_NETBEUI PyModule_AddIntConstant (m, "AF_NETBEUI", AF_NETBEUI); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_NETBEUI), - PyString_FromString("AF_NETBEUI")); + PyUnicode_FromString("AF_NETBEUI")); #endif #ifdef AF_PPP PyModule_AddIntConstant (m, "AF_PPP", AF_PPP); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_PPP), - PyString_FromString("AF_PPP")); + PyUnicode_FromString("AF_PPP")); #endif #ifdef AF_ATM PyModule_AddIntConstant (m, "AF_ATM", AF_ATM); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_ATM), - PyString_FromString("AF_ATM")); + PyUnicode_FromString("AF_ATM")); #endif #ifdef AF_ATMPVC PyModule_AddIntConstant (m, "AF_ATMPVC", AF_ATMPVC); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_ATMPVC), - PyString_FromString("AF_ATMPVC")); + PyUnicode_FromString("AF_ATMPVC")); #endif #ifdef AF_ATMSVC PyModule_AddIntConstant (m, "AF_ATMSVC", AF_ATMSVC); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_ATMSVC), - PyString_FromString("AF_ATMSVC")); + PyUnicode_FromString("AF_ATMSVC")); #endif #ifdef AF_NETGRAPH PyModule_AddIntConstant (m, "AF_NETGRAPH", AF_NETGRAPH); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_NETGRAPH), - PyString_FromString("AF_NETGRAPH")); + PyUnicode_FromString("AF_NETGRAPH")); #endif #ifdef AF_VOICEVIEW PyModule_AddIntConstant (m, "AF_VOICEVIEW", AF_VOICEVIEW); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_VOICEVIEW), - PyString_FromString("AF_VOICEVIEW")); + PyUnicode_FromString("AF_VOICEVIEW")); #endif #ifdef AF_FIREFOX PyModule_AddIntConstant (m, "AF_FIREFOX", AF_FIREFOX); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_FIREFOX), - PyString_FromString("AF_FIREFOX")); + PyUnicode_FromString("AF_FIREFOX")); #endif #ifdef AF_UNKNOWN1 PyModule_AddIntConstant (m, "AF_UNKNOWN1", AF_UNKNOWN1); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_UNKNOWN1), - PyString_FromString("AF_UNKNOWN1")); + PyUnicode_FromString("AF_UNKNOWN1")); #endif #ifdef AF_BAN PyModule_AddIntConstant (m, "AF_BAN", AF_BAN); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_BAN), - PyString_FromString("AF_BAN")); + PyUnicode_FromString("AF_BAN")); #endif #ifdef AF_CLUSTER PyModule_AddIntConstant (m, "AF_CLUSTER", AF_CLUSTER); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_CLUSTER), - PyString_FromString("AF_CLUSTER")); + PyUnicode_FromString("AF_CLUSTER")); #endif #ifdef AF_12844 PyModule_AddIntConstant (m, "AF_12844", AF_12844); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_12844), - PyString_FromString("AF_12844")); + PyUnicode_FromString("AF_12844")); #endif #ifdef AF_IRDA PyModule_AddIntConstant (m, "AF_IRDA", AF_IRDA); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_IRDA), - PyString_FromString("AF_IRDA")); + PyUnicode_FromString("AF_IRDA")); #endif #ifdef AF_NETDES PyModule_AddIntConstant (m, "AF_NETDES", AF_NETDES); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_NETDES), - PyString_FromString("AF_NETDES")); + PyUnicode_FromString("AF_NETDES")); #endif #ifdef AF_NETROM PyModule_AddIntConstant (m, "AF_NETROM", AF_NETROM); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_NETROM), - PyString_FromString("AF_NETROM")); + PyUnicode_FromString("AF_NETROM")); #endif #ifdef AF_BRIDGE PyModule_AddIntConstant (m, "AF_BRIDGE", AF_BRIDGE); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_BRIDGE), - PyString_FromString("AF_BRIDGE")); + PyUnicode_FromString("AF_BRIDGE")); #endif #ifdef AF_X25 PyModule_AddIntConstant (m, "AF_X25", AF_X25); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_X25), - PyString_FromString("AF_X25")); + PyUnicode_FromString("AF_X25")); #endif #ifdef AF_ROSE PyModule_AddIntConstant (m, "AF_ROSE", AF_ROSE); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_ROSE), - PyString_FromString("AF_ROSE")); + PyUnicode_FromString("AF_ROSE")); #endif #ifdef AF_SECURITY PyModule_AddIntConstant (m, "AF_SECURITY", AF_SECURITY); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_SECURITY), - PyString_FromString("AF_SECURITY")); + PyUnicode_FromString("AF_SECURITY")); #endif #ifdef AF_KEY PyModule_AddIntConstant (m, "AF_KEY", AF_KEY); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_KEY), - PyString_FromString("AF_KEY")); + PyUnicode_FromString("AF_KEY")); #endif #ifdef AF_NETLINK PyModule_AddIntConstant (m, "AF_NETLINK", AF_NETLINK); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_NETLINK), - PyString_FromString("AF_NETLINK")); + PyUnicode_FromString("AF_NETLINK")); #endif #ifdef AF_ASH PyModule_AddIntConstant (m, "AF_ASH", AF_ASH); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_ASH), - PyString_FromString("AF_ASH")); + PyUnicode_FromString("AF_ASH")); #endif #ifdef AF_ECONET PyModule_AddIntConstant (m, "AF_ECONET", AF_ECONET); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_ECONET), - PyString_FromString("AF_ECONET")); + PyUnicode_FromString("AF_ECONET")); #endif #ifdef AF_SNA PyModule_AddIntConstant (m, "AF_SNA", AF_SNA); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_SNA), - PyString_FromString("AF_SNA")); + PyUnicode_FromString("AF_SNA")); #endif #ifdef AF_PPPOX PyModule_AddIntConstant (m, "AF_PPPOX", AF_PPPOX); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_PPPOX), - PyString_FromString("AF_PPPOX")); + PyUnicode_FromString("AF_PPPOX")); #endif #ifdef AF_WANPIPE PyModule_AddIntConstant (m, "AF_WANPIPE", AF_WANPIPE); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_WANPIPE), - PyString_FromString("AF_WANPIPE")); + PyUnicode_FromString("AF_WANPIPE")); #endif #ifdef AF_BLUETOOTH PyModule_AddIntConstant (m, "AF_BLUETOOTH", AF_BLUETOOTH); PyDict_SetItem(address_family_dict, PyInt_FromLong(AF_BLUETOOTH), - PyString_FromString("AF_BLUETOOTH")); + PyUnicode_FromString("AF_BLUETOOTH")); #endif #ifdef IN6_IFF_AUTOCONF PyModule_AddIntConstant (m, "IN6_IFF_AUTOCONF", IN6_IFF_AUTOCONF); diff --git a/netifaces.egg-info/PKG-INFO b/netifaces.egg-info/PKG-INFO index 53a4c01..910d98d 100644 --- a/netifaces.egg-info/PKG-INFO +++ b/netifaces.egg-info/PKG-INFO @@ -1,17 +1,32 @@ Metadata-Version: 1.1 Name: netifaces -Version: 0.10.5 +Version: 0.11.0 Summary: Portable network interface information. -Home-page: https://bitbucket.org/al45tair/netifaces +Home-page: https://github.com/al45tair/netifaces Author: Alastair Houghton Author-email: alastair@alastairs-place.net License: MIT License -Description: netifaces 0.10.4 +Description: netifaces 0.10.8 ================ - .. image:: https://drone.io/bitbucket.org/al45tair/netifaces/status.png - :target: https://drone.io/bitbucket.org/al45tair/netifaces/latest - :alt: Build Status + +-------------+------------------+ + | Linux/macOS | |BuildStatus| | + +-------------+------------------+ + | Windows | |WinBuildStatus| | + +-------------+------------------+ + + .. |BuildStatus| image:: https://travis-ci.org/al45tair/netifaces.svg?branch=master + :target: https://travis-ci.org/al45tair/netifaces + :alt: Build Status (Linux/Mac) + + .. |WinBuildStatus| image:: https://ci.appveyor.com/api/projects/status/3ctn1bl0aigpfjoo/branch/master?svg=true + :target: https://ci.appveyor.com/project/al45tair/netifaces/branch/master + :alt: Build Status (Windows) + + .. warning:: + + netifaces needs a new maintainer. al45tair is no longer able to maintain it + or make new releases due to work commitments. 1. What is this? ---------------- @@ -32,10 +47,13 @@ Description: netifaces 0.10.4 First you need to install it, which you can do by typing:: - tar xvzf netifaces-0.10.4.tar.gz - cd netifaces-0.10.4 + tar xvzf netifaces-0.10.8.tar.gz + cd netifaces-0.10.8 python setup.py install + **Note that you will need the relevant developer tools for your platform**, + as netifaces is written in C and installing this way will compile the extension. + Once that's done, you'll need to start Python and do something like the following:: @@ -165,39 +183,19 @@ Description: netifaces 0.10.4 It gets regular testing on OS X, Linux and Windows. It has also been used successfully on Solaris, and it's expected to work properly on other UNIX-like systems as well. If you are running something that is not supported, and - wish to contribute a patch, please use BitBucket to send a pull request. + wish to contribute a patch, please use Github to send a pull request. 4. What license is this under? ------------------------------ - It's an MIT-style license. Here goes: - - Copyright (c) 2007-2014 Alastair Houghton - - Permission is hereby granted, free of charge, to any person obtaining a copy - of this software and associated documentation files (the "Software"), to deal - in the Software without restriction, including without limitation the rights - to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - copies of the Software, and to permit persons to whom the Software is - furnished to do so, subject to the following conditions: - - The above copyright notice and this permission notice shall be included in all - copies or substantial portions of the Software. - - THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - SOFTWARE. + It's an MIT-style license. See `LICENSE <./LICENSE>`_. 5. Why the jump to 0.10.0? -------------------------- Because someone released a fork of netifaces with the version 0.9.0. - Hopefully skipping the version number should remove any confusion. In - addition starting with 0.10.0 Python 3 is now supported and other + Hopefully skipping the version number should remove any confusion. In + addition starting with 0.10.0 Python 3 is now supported and other features/bugfixes have been included as well. See the CHANGELOG for a more complete list of changes. @@ -208,7 +206,10 @@ Classifier: License :: OSI Approved :: MIT License Classifier: Topic :: System :: Networking Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 2 -Classifier: Programming Language :: Python :: 2.5 -Classifier: Programming Language :: Python :: 2.6 Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 +Classifier: Programming Language :: Python :: 3.4 +Classifier: Programming Language :: Python :: 3.5 +Classifier: Programming Language :: Python :: 3.6 +Classifier: Programming Language :: Python :: 3.7 +Classifier: Programming Language :: Python :: 3.8 diff --git a/netifaces.egg-info/SOURCES.txt b/netifaces.egg-info/SOURCES.txt index a382c6c..e6ca92e 100644 --- a/netifaces.egg-info/SOURCES.txt +++ b/netifaces.egg-info/SOURCES.txt @@ -1,7 +1,10 @@ +LICENSE +MANIFEST.in README.rst netifaces.c setup.cfg setup.py +test.py netifaces.egg-info/PKG-INFO netifaces.egg-info/SOURCES.txt netifaces.egg-info/dependency_links.txt diff --git a/setup.cfg b/setup.cfg index 861a9f5..5185252 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,3 +3,6 @@ tag_build = tag_date = 0 tag_svn_revision = 0 +[metadata] +license_file = LICENSE + diff --git a/setup.py b/setup.py index 0ce3742..191f363 100644 --- a/setup.py +++ b/setup.py @@ -19,10 +19,10 @@ else: except ImportError: import __builtin__ builtins = __builtin__ - + output = getattr(builtins, 'print', lambda x: True) - -__version__ = "0.10.5" + +__version__ = "0.11.0" # Disable hard links, otherwise building distributions fails on OS X try: @@ -97,7 +97,7 @@ class my_build_ext(build_ext): result = True if status != 0: result = False - + finally: os.dup2(mystdout, 1) os.dup2(mystderr, 2) @@ -123,7 +123,7 @@ class my_build_ext(build_ext): results = {} self.conftestidx = 0 - + output("checking for getifaddrs...", end='') result = results.get('have_getifaddrs', None) @@ -187,7 +187,7 @@ class my_build_ext(build_ext): sin.sin_family = AF_INET; sin.sin_port = 0; sin.sin_addr.s_addr = htonl (INADDR_LOOPBACK); - + ret = getnameinfo ((struct sockaddr *)&sin, sizeof (sin), buffer, sizeof (buffer), NULL, 0, @@ -409,7 +409,7 @@ class my_build_ext(build_ext): # lengths, because they're in the sa_len field on just about # everything but Linux. output("checking which sockaddr_xxx structs are defined...", end='') - + result = results.get('have_sockaddrs', None) if result is not None: cached = '(cached)' @@ -434,7 +434,7 @@ class my_build_ext(build_ext): #include #include %(includes)s - + int main (void) { struct sockaddr_%(sockaddr)s sa; return 0; @@ -446,7 +446,7 @@ class my_build_ext(build_ext): if self.test_build(testrig): result.append(sockaddr) - + if result: output('%s. %s' % (' '.join(result), cached)) for sockaddr in result: @@ -570,7 +570,8 @@ if not getattr(sys, 'getwindowsversion', None): readme_path = os.path.join(os.path.abspath(os.path.dirname(__file__)), 'README.rst') -long_desc = open(readme_path, 'r').read() +with open(readme_path, 'r') as fp: + long_desc = fp.read() setup (name='netifaces', version=__version__, @@ -580,7 +581,7 @@ setup (name='netifaces', long_description=long_desc, author='Alastair Houghton', author_email='alastair@alastairs-place.net', - url='https://bitbucket.org/al45tair/netifaces', + url='https://github.com/al45tair/netifaces', classifiers=[ 'Development Status :: 4 - Beta', 'Intended Audience :: Developers', @@ -588,9 +589,12 @@ setup (name='netifaces', 'Topic :: System :: Networking', 'Programming Language :: Python', 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.5', - 'Programming Language :: Python :: 2.6', 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.4', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8' ], ext_modules=[iface_mod]) diff --git a/test.py b/test.py new file mode 100644 index 0000000..ccaba0e --- /dev/null +++ b/test.py @@ -0,0 +1,50 @@ +import netifaces + +print('Found interfaces:') +for iface in netifaces.interfaces(): + print(' %s' % iface) + +print('') + +for iface in netifaces.interfaces(): + allAddrs = netifaces.ifaddresses(iface) + + print('Interface %s:' % iface) + + for family in allAddrs: + addrs = allAddrs[family] + fam_name = netifaces.address_families[family] + print(' Address family: %s' % fam_name) + for addr in addrs: + print(' Address : %s' % addr['addr']) + nmask = addr.get('netmask', None) + if nmask: + print(' Netmask : %s' % nmask) + bcast = addr.get('broadcast', None) + if bcast: + print(' Broadcast: %s' % bcast) + + print('') + +print('Found gateways:') +gateway_info = netifaces.gateways() +for family in gateway_info: + if family == 'default': + continue + + fam_name = netifaces.address_families[family] + print(' Family: %s' % fam_name) + for gateway,interface,default in gateway_info[family]: + if default: + def_text = ', default' + else: + def_text = '' + print(' %s (via %s%s)' % (gateway, interface, def_text)) + print('') + +print('Default gateways:') +default_gateways = gateway_info['default'] +for family in default_gateways: + fam_name = netifaces.address_families[family] + gateway, interface = default_gateways[family] + print(' %s: %s (via %s)' % (fam_name, gateway, interface))