summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlastair Houghton <alastair@coriolis-systems.com>2014-05-06 16:21:50 +0100
committerAlastair Houghton <alastair@coriolis-systems.com>2014-05-06 16:21:50 +0100
commit337a357f1ea2d4ac81b0d42747919d685cf0962e (patch)
tree53dd13f0f1c8602d83acc086e01cbf6da1832f68
parentdfa7b1ceb1062cf9dfa0444ef29c15686299fb65 (diff)
downloadnetifaces-337a357f1ea2d4ac81b0d42747919d685cf0962e.tar.gz
Fix builds on older Linux kernel versions (no NLM_F_DUMP_INTR). Also, test for RTF_IFSCOPE in a more sensible manner.
-rw-r--r--CHANGELOG5
-rw-r--r--README.rst6
-rw-r--r--netifaces.c9
-rw-r--r--setup.py33
4 files changed, 15 insertions, 38 deletions
diff --git a/CHANGELOG b/CHANGELOG
index b322b50..8159cf7 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,8 @@
+2014-05-06 Version 0.10.3
+
+ * When using Netlink (i.e. Linux), check for the constant
+ NLM_F_DUMP_INTR, since it only appeared in kernel version 3.1
+
2014-05-03 Version 0.10.2
* Added a workaround for broken netlink headers on certain Linux
diff --git a/README.rst b/README.rst
index 9158ced..2b2a886 100644
--- a/README.rst
+++ b/README.rst
@@ -1,4 +1,4 @@
-netifaces 0.10.2
+netifaces 0.10.3
================
.. image:: https://drone.io/bitbucket.org/al45tair/netifaces/status.png
@@ -24,8 +24,8 @@ This package attempts to solve that problem.
First you need to install it, which you can do by typing::
- tar xvzf netifaces-0.10.2.tar.gz
- cd netifaces-0.10.2
+ tar xvzf netifaces-0.10.3.tar.gz
+ cd netifaces-0.10.3
python setup.py install
Once that's done, you'll need to start Python and do something like the
diff --git a/netifaces.c b/netifaces.c
index 36bacf3..e0f7dd2 100644
--- a/netifaces.c
+++ b/netifaces.c
@@ -1585,12 +1585,15 @@ gateways (PyObject *self)
if (pmsg->hdr.nlmsg_seq != seq || pmsg->hdr.nlmsg_pid != sanl.nl_pid)
goto next;
+ /* This is only defined on Linux kernel versions 3.1 and higher */
+#ifdef NLM_F_DUMP_INTR
if (pmsg->hdr.nlmsg_flags & NLM_F_DUMP_INTR) {
/* The dump was interrupted by a signal; we need to go round again */
interrupted = 1;
is_multi = 0;
break;
}
+#endif
is_multi = pmsg->hdr.nlmsg_flags & NLM_F_MULTI;
@@ -1805,7 +1808,7 @@ gateways (PyObject *self)
if (string_from_sockaddr (sa, buffer, sizeof(buffer)) == 0) {
PyObject *pyaddr = PyString_FromString (buffer);
-#if HAVE_RTF_IFSCOPE
+#ifdef RTF_IFSCOPE
PyObject *isdefault = PyBool_FromLong (!(msg->rtm_flags & RTF_IFSCOPE));
#else
PyObject *isdefault = Py_INCREF(Py_True);
@@ -2031,7 +2034,7 @@ gateways (PyObject *self)
buffer, sizeof(buffer)) == 0) {
PyObject *pyifname = PyString_FromString (ifname);
PyObject *pyaddr = PyString_FromString (buffer);
-#if HAVE_RTF_IFSCOPE
+#ifdef RTF_IFSCOPE
PyObject *isdefault = PyBool_FromLong (!(pmsg->rtm_flags & RTF_IFSCOPE));
#else
PyObject *isdefault = Py_True;
@@ -2210,7 +2213,7 @@ gateways (PyObject *self)
buffer, sizeof(buffer)) == 0) {
PyObject *pyifname = PyString_FromString (ifname);
PyObject *pyaddr = PyString_FromString (buffer);
-#if HAVE_RTF_IFSCOPE
+#ifdef RTF_IFSCOPE
PyObject *isdefault = PyBool_FromLong (!(pmsg->rtm_flags & RTF_IFSCOPE));
#else
PyObject *isdefault = Py_True;
diff --git a/setup.py b/setup.py
index db46b11..a090f9a 100644
--- a/setup.py
+++ b/setup.py
@@ -16,7 +16,7 @@ if sys.version_info[0] == 2:
else:
output = getattr(__builtins__, 'print')
-__version__ = "0.10.2"
+__version__ = "0.10.3"
# Disable hard links, otherwise building distributions fails on OS X
try:
@@ -493,37 +493,6 @@ class my_build_ext(build_ext):
elif results['have_pf_route']:
output('will use routing socket to read routing table')
- # Also check for RTF_IFSCOPE
- output("checking for RTF_IFSCOPE...", end='')
-
- result = results.get('have_rtf_ifscope', None)
- if result is not None:
- cached = '(cached)'
- else:
- cached = ''
-
- testrig = """
- #include <sys/types.h>
- #include <sys/socket.h>
- #include <sys/sysctl.h>
- #include <net/route.h>
-
- int main (void) {
- int scope = RTF_IFSCOPE;
- return 0;
- }
- """
-
- result = self.test_build(testrig)
-
- if result:
- output('yes. %s' % cached)
- self.compiler.define_macro('HAVE_RTF_IFSCOPE', 1)
- else:
- output('no. %s' % cached)
-
- results['have_rtf_ifscope'] = result
-
# Save the results to our config.cache file
myfile = open(cache_file, 'wb')
try: