From 97e0de04b8cd44474e452a028761e34407192041 Mon Sep 17 00:00:00 2001 From: Zackery Spytz Date: Thu, 9 Apr 2020 06:03:49 -0600 Subject: bpo-25780: Expose CAN_RAW_JOIN_FILTERS in the socket module (GH-19190) Co-Authored-By: Stefan Tatschner --- Doc/library/socket.rst | 11 ++++++++ Doc/whatsnew/3.9.rst | 7 +++++ Misc/ACKS | 1 + .../2020-03-27-08-57-46.bpo-25780.kIjVge.rst | 1 + Modules/socketmodule.c | 3 +++ configure | 30 ++++++++++++++++++++++ configure.ac | 10 ++++++++ pyconfig.h.in | 3 +++ 8 files changed, 66 insertions(+) create mode 100644 Misc/NEWS.d/next/Library/2020-03-27-08-57-46.bpo-25780.kIjVge.rst diff --git a/Doc/library/socket.rst b/Doc/library/socket.rst index 5426b5a..87dee1a 100755 --- a/Doc/library/socket.rst +++ b/Doc/library/socket.rst @@ -408,6 +408,17 @@ Constants .. versionadded:: 3.5 +.. data:: CAN_RAW_JOIN_FILTERS + + Joins the applied CAN filters such that only CAN frames that match all + given CAN filters are passed to user space. + + This constant is documented in the Linux documentation. + + .. availability:: Linux >= 4.1. + + .. versionadded:: 3.9 + .. data:: CAN_ISOTP CAN_ISOTP, in the CAN protocol family, is the ISO-TP (ISO 15765-2) protocol. diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst index ef499f5..e49d426 100644 --- a/Doc/whatsnew/3.9.rst +++ b/Doc/whatsnew/3.9.rst @@ -362,6 +362,13 @@ a non-blocking socket. (Contributed by Dong-hee Na in :issue:`39259`.) :class:`~smtplib.LMTP` constructor now has an optional *timeout* parameter. (Contributed by Dong-hee Na in :issue:`39329`.) +socket +------ + +The :mod:`socket` module now exports the :data:`~socket.CAN_RAW_JOIN_FILTERS` +constant on Linux 4.1 and greater. +(Contributed by Stefan Tatschner and Zackery Spytz in :issue:`25780`.) + threading --------- diff --git a/Misc/ACKS b/Misc/ACKS index ce100b9..8cb95dc 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1682,6 +1682,7 @@ William Tanksley Christian Tanzer Steven Taschuk Batuhan Taskaya +Stefan Tatschner Amy Taylor Julian Taylor Monty Taylor diff --git a/Misc/NEWS.d/next/Library/2020-03-27-08-57-46.bpo-25780.kIjVge.rst b/Misc/NEWS.d/next/Library/2020-03-27-08-57-46.bpo-25780.kIjVge.rst new file mode 100644 index 0000000..119e149 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2020-03-27-08-57-46.bpo-25780.kIjVge.rst @@ -0,0 +1 @@ +Expose :data:`~socket.CAN_RAW_JOIN_FILTERS` in the :mod:`socket` module. diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index b5c241e..722c06e 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -7702,6 +7702,9 @@ PyInit__socket(void) #ifdef HAVE_LINUX_CAN_RAW_FD_FRAMES PyModule_AddIntMacro(m, CAN_RAW_FD_FRAMES); #endif +#ifdef HAVE_LINUX_CAN_RAW_JOIN_FILTERS + PyModule_AddIntMacro(m, CAN_RAW_JOIN_FILTERS); +#endif #ifdef HAVE_LINUX_CAN_BCM_H PyModule_AddIntMacro(m, CAN_BCM); diff --git a/configure b/configure index a7a3ac2..d3e8149 100755 --- a/configure +++ b/configure @@ -11307,6 +11307,36 @@ $as_echo "no" >&6; } fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CAN_RAW_JOIN_FILTERS" >&5 +$as_echo_n "checking for CAN_RAW_JOIN_FILTERS... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +#include +int +main () +{ +int can_raw_join_filters = CAN_RAW_JOIN_FILTERS; + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + +$as_echo "#define HAVE_LINUX_CAN_RAW_JOIN_FILTERS 1" >>confdefs.h + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } + +else + + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } + +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + # Check for --with-doc-strings { $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-doc-strings" >&5 $as_echo_n "checking for --with-doc-strings... " >&6; } diff --git a/configure.ac b/configure.ac index 8eed015..6bc8499 100644 --- a/configure.ac +++ b/configure.ac @@ -3447,6 +3447,16 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ /* CAN_RAW_FD_FRAMES available check */ AC_MSG_RESULT(no) ]) +AC_MSG_CHECKING(for CAN_RAW_JOIN_FILTERS) +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include ]], +[[int can_raw_join_filters = CAN_RAW_JOIN_FILTERS;]])],[ + AC_DEFINE(HAVE_LINUX_CAN_RAW_JOIN_FILTERS, 1, [Define if compiling using Linux 4.1 or later.]) + AC_MSG_RESULT(yes) +],[ + AC_MSG_RESULT(no) +]) + # Check for --with-doc-strings AC_MSG_CHECKING(for --with-doc-strings) AC_ARG_WITH(doc-strings, diff --git a/pyconfig.h.in b/pyconfig.h.in index 2a72e9e..76a1047 100644 --- a/pyconfig.h.in +++ b/pyconfig.h.in @@ -628,6 +628,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_CAN_RAW_H +/* Define if compiling using Linux 4.1 or later. */ +#undef HAVE_LINUX_CAN_RAW_JOIN_FILTERS + /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_MEMFD_H -- cgit v0.12