Skip to content

Commit 40fcd16

Browse files
authored
bpo-30512: Add CAN Socket support for NetBSD (GH-30066)
1 parent cfadcc3 commit 40fcd16

File tree

8 files changed

+26
-6
lines changed

8 files changed

+26
-6
lines changed

Doc/library/socket.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,10 +396,13 @@ Constants
396396
Many constants of these forms, documented in the Linux documentation, are
397397
also defined in the socket module.
398398

399-
.. availability:: Linux >= 2.6.25.
399+
.. availability:: Linux >= 2.6.25, NetBSD >= 8.
400400

401401
.. versionadded:: 3.3
402402

403+
.. versionchanged:: 3.11
404+
NetBSD support was added.
405+
403406
.. data:: CAN_BCM
404407
CAN_BCM_*
405408

Doc/whatsnew/3.11.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,13 @@ os
264264
(Contributed by Dong-hee Na in :issue:`44611`.)
265265

266266

267+
socket
268+
------
269+
270+
* Add CAN Socket support for NetBSD.
271+
(Contributed by Thomas Klausner in :issue:`30512`.)
272+
273+
267274
sqlite3
268275
-------
269276

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add CAN Socket support for NetBSD.

Modules/socketmodule.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7703,7 +7703,7 @@ PyInit__socket(void)
77037703
PyModule_AddIntMacro(m, SOL_CAN_RAW);
77047704
PyModule_AddIntMacro(m, CAN_RAW);
77057705
#endif
7706-
#ifdef HAVE_LINUX_CAN_H
7706+
#if defined(HAVE_LINUX_CAN_H) || defined(HAVE_NETCAN_CAN_H)
77077707
PyModule_AddIntMacro(m, CAN_EFF_FLAG);
77087708
PyModule_AddIntMacro(m, CAN_RTR_FLAG);
77097709
PyModule_AddIntMacro(m, CAN_ERR_FLAG);
@@ -7718,9 +7718,11 @@ PyInit__socket(void)
77187718
PyModule_AddIntMacro(m, CAN_J1939);
77197719
#endif
77207720
#endif
7721-
#ifdef HAVE_LINUX_CAN_RAW_H
7721+
#if defined(HAVE_LINUX_CAN_RAW_H) || defined(HAVE_NETCAN_CAN_H)
77227722
PyModule_AddIntMacro(m, CAN_RAW_FILTER);
7723+
#ifdef CAN_RAW_ERR_FILTER
77237724
PyModule_AddIntMacro(m, CAN_RAW_ERR_FILTER);
7725+
#endif
77247726
PyModule_AddIntMacro(m, CAN_RAW_LOOPBACK);
77257727
PyModule_AddIntMacro(m, CAN_RAW_RECV_OWN_MSGS);
77267728
#endif

Modules/socketmodule.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,8 @@ typedef int socklen_t;
129129

130130
#ifdef HAVE_LINUX_CAN_H
131131
# include <linux/can.h>
132+
#elif defined(HAVE_NETCAN_CAN_H)
133+
# include <netcan/can.h>
132134
#else
133135
# undef AF_CAN
134136
# undef PF_CAN
@@ -253,7 +255,7 @@ typedef union sock_addr {
253255
#ifdef HAVE_NETPACKET_PACKET_H
254256
struct sockaddr_ll ll;
255257
#endif
256-
#ifdef HAVE_LINUX_CAN_H
258+
#if defined(HAVE_LINUX_CAN_H) || defined(HAVE_NETCAN_CAN_H)
257259
struct sockaddr_can can;
258260
#endif
259261
#ifdef HAVE_SYS_KERN_CONTROL_H

configure

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8940,7 +8940,8 @@ done
89408940

89418941

89428942
# On Linux, can.h, can/bcm.h, can/j1939.h, can/raw.h require sys/socket.h
8943-
for ac_header in linux/can.h linux/can/bcm.h linux/can/j1939.h linux/can/raw.h
8943+
# On NetBSD, netcan/can.h requires sys/socket.h
8944+
for ac_header in linux/can.h linux/can/bcm.h linux/can/j1939.h linux/can/raw.h netcan/can.h
89448945
do :
89458946
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
89468947
ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "

configure.ac

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2411,7 +2411,8 @@ AC_CHECK_HEADERS(linux/vm_sockets.h,,,[
24112411
])
24122412

24132413
# On Linux, can.h, can/bcm.h, can/j1939.h, can/raw.h require sys/socket.h
2414-
AC_CHECK_HEADERS(linux/can.h linux/can/bcm.h linux/can/j1939.h linux/can/raw.h,,,[
2414+
# On NetBSD, netcan/can.h requires sys/socket.h
2415+
AC_CHECK_HEADERS(linux/can.h linux/can/bcm.h linux/can/j1939.h linux/can/raw.h netcan/can.h,,,[
24152416
#ifdef HAVE_SYS_SOCKET_H
24162417
#include <sys/socket.h>
24172418
#endif

pyconfig.h.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,9 @@
772772
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
773773
#undef HAVE_NDIR_H
774774

775+
/* Define to 1 if you have the <netcan/can.h> header file. */
776+
#undef HAVE_NETCAN_CAN_H
777+
775778
/* Define to 1 if you have the <netinet/in.h> header file. */
776779
#undef HAVE_NETINET_IN_H
777780

0 commit comments

Comments
 (0)