Skip to content

Commit 97e0de0

Browse files
bpo-25780: Expose CAN_RAW_JOIN_FILTERS in the socket module (GH-19190)
Co-Authored-By: Stefan Tatschner <[email protected]>
1 parent b54a99d commit 97e0de0

File tree

8 files changed

+66
-0
lines changed

8 files changed

+66
-0
lines changed

Doc/library/socket.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,17 @@ Constants
408408

409409
.. versionadded:: 3.5
410410

411+
.. data:: CAN_RAW_JOIN_FILTERS
412+
413+
Joins the applied CAN filters such that only CAN frames that match all
414+
given CAN filters are passed to user space.
415+
416+
This constant is documented in the Linux documentation.
417+
418+
.. availability:: Linux >= 4.1.
419+
420+
.. versionadded:: 3.9
421+
411422
.. data:: CAN_ISOTP
412423

413424
CAN_ISOTP, in the CAN protocol family, is the ISO-TP (ISO 15765-2) protocol.

Doc/whatsnew/3.9.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,13 @@ a non-blocking socket. (Contributed by Dong-hee Na in :issue:`39259`.)
362362
:class:`~smtplib.LMTP` constructor now has an optional *timeout* parameter.
363363
(Contributed by Dong-hee Na in :issue:`39329`.)
364364

365+
socket
366+
------
367+
368+
The :mod:`socket` module now exports the :data:`~socket.CAN_RAW_JOIN_FILTERS`
369+
constant on Linux 4.1 and greater.
370+
(Contributed by Stefan Tatschner and Zackery Spytz in :issue:`25780`.)
371+
365372
threading
366373
---------
367374

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1682,6 +1682,7 @@ William Tanksley
16821682
Christian Tanzer
16831683
Steven Taschuk
16841684
Batuhan Taskaya
1685+
Stefan Tatschner
16851686
Amy Taylor
16861687
Julian Taylor
16871688
Monty Taylor
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Expose :data:`~socket.CAN_RAW_JOIN_FILTERS` in the :mod:`socket` module.

Modules/socketmodule.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7702,6 +7702,9 @@ PyInit__socket(void)
77027702
#ifdef HAVE_LINUX_CAN_RAW_FD_FRAMES
77037703
PyModule_AddIntMacro(m, CAN_RAW_FD_FRAMES);
77047704
#endif
7705+
#ifdef HAVE_LINUX_CAN_RAW_JOIN_FILTERS
7706+
PyModule_AddIntMacro(m, CAN_RAW_JOIN_FILTERS);
7707+
#endif
77057708
#ifdef HAVE_LINUX_CAN_BCM_H
77067709
PyModule_AddIntMacro(m, CAN_BCM);
77077710

configure

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11307,6 +11307,36 @@ $as_echo "no" >&6; }
1130711307
fi
1130811308
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
1130911309

11310+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for CAN_RAW_JOIN_FILTERS" >&5
11311+
$as_echo_n "checking for CAN_RAW_JOIN_FILTERS... " >&6; }
11312+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
11313+
/* end confdefs.h. */
11314+
11315+
#include <linux/can/raw.h>
11316+
int
11317+
main ()
11318+
{
11319+
int can_raw_join_filters = CAN_RAW_JOIN_FILTERS;
11320+
;
11321+
return 0;
11322+
}
11323+
_ACEOF
11324+
if ac_fn_c_try_compile "$LINENO"; then :
11325+
11326+
11327+
$as_echo "#define HAVE_LINUX_CAN_RAW_JOIN_FILTERS 1" >>confdefs.h
11328+
11329+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
11330+
$as_echo "yes" >&6; }
11331+
11332+
else
11333+
11334+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
11335+
$as_echo "no" >&6; }
11336+
11337+
fi
11338+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
11339+
1131011340
# Check for --with-doc-strings
1131111341
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for --with-doc-strings" >&5
1131211342
$as_echo_n "checking for --with-doc-strings... " >&6; }

configure.ac

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3447,6 +3447,16 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ /* CAN_RAW_FD_FRAMES available check */
34473447
AC_MSG_RESULT(no)
34483448
])
34493449

3450+
AC_MSG_CHECKING(for CAN_RAW_JOIN_FILTERS)
3451+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3452+
#include <linux/can/raw.h>]],
3453+
[[int can_raw_join_filters = CAN_RAW_JOIN_FILTERS;]])],[
3454+
AC_DEFINE(HAVE_LINUX_CAN_RAW_JOIN_FILTERS, 1, [Define if compiling using Linux 4.1 or later.])
3455+
AC_MSG_RESULT(yes)
3456+
],[
3457+
AC_MSG_RESULT(no)
3458+
])
3459+
34503460
# Check for --with-doc-strings
34513461
AC_MSG_CHECKING(for --with-doc-strings)
34523462
AC_ARG_WITH(doc-strings,

pyconfig.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,9 @@
628628
/* Define to 1 if you have the <linux/can/raw.h> header file. */
629629
#undef HAVE_LINUX_CAN_RAW_H
630630

631+
/* Define if compiling using Linux 4.1 or later. */
632+
#undef HAVE_LINUX_CAN_RAW_JOIN_FILTERS
633+
631634
/* Define to 1 if you have the <linux/memfd.h> header file. */
632635
#undef HAVE_LINUX_MEMFD_H
633636

0 commit comments

Comments
 (0)