Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
bpo-30512: add CAN Socket support for NetBSD
  • Loading branch information
0-wiz-0 committed Dec 11, 2021
commit 494b2d2d64a5755ccacb3451370e16114cbb77b2
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add CAN Socket support for NetBSD

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Add CAN Socket support for NetBSD
Add CAN Socket support for NetBSD.

14 changes: 14 additions & 0 deletions Modules/socketmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -7790,6 +7790,20 @@ PyInit__socket(void)

PyModule_AddIntMacro(m, J1939_FILTER_MAX);
#endif
#ifdef HAVE_NETCAN_CAN_H

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not merge this with blocks for HAVE_LINUX_CAN_H and HAVE_LINUX_CAN_RAW_H?

PyModule_AddIntMacro(m, CAN_EFF_FLAG);
PyModule_AddIntMacro(m, CAN_RTR_FLAG);
PyModule_AddIntMacro(m, CAN_ERR_FLAG);

PyModule_AddIntMacro(m, CAN_SFF_MASK);
PyModule_AddIntMacro(m, CAN_EFF_MASK);
PyModule_AddIntMacro(m, CAN_ERR_MASK);

PyModule_AddIntMacro(m, CAN_RAW_FILTER);
/* PyModule_AddIntMacro(m, CAN_RAW_ERR_FILTER); */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it not defined on NetBSD? Then after merging with the HAVE_LINUX_CAN_RAW_H case you can add #ifdef CAN_RAW_ERR_FILTER.

PyModule_AddIntMacro(m, CAN_RAW_LOOPBACK);
PyModule_AddIntMacro(m, CAN_RAW_RECV_OWN_MSGS);
#endif
#ifdef SOL_RDS
PyModule_AddIntMacro(m, SOL_RDS);
#endif
Expand Down
4 changes: 3 additions & 1 deletion Modules/socketmodule.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ typedef int socklen_t;

#ifdef HAVE_LINUX_CAN_H
# include <linux/can.h>
#elif defined(HAVE_NETCAN_CAN_H)
# include <netcan/can.h>
#else
# undef AF_CAN
# undef PF_CAN
Expand Down Expand Up @@ -253,7 +255,7 @@ typedef union sock_addr {
#ifdef HAVE_NETPACKET_PACKET_H
struct sockaddr_ll ll;
#endif
#ifdef HAVE_LINUX_CAN_H
#if defined(HAVE_LINUX_CAN_H) || defined(HAVE_NETCAN_CAN_H)
struct sockaddr_can can;
#endif
#ifdef HAVE_SYS_KERN_CONTROL_H
Expand Down
3 changes: 2 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -8782,7 +8782,8 @@ done


# On Linux, can.h, can/bcm.h, can/j1939.h, can/raw.h require sys/socket.h
for ac_header in linux/can.h linux/can/bcm.h linux/can/j1939.h linux/can/raw.h
# On NetBSD, netcan/can.h requires sys/socket.h
for ac_header in linux/can.h linux/can/bcm.h linux/can/j1939.h linux/can/raw.h netcan/can.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "
Expand Down
3 changes: 2 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2306,7 +2306,8 @@ AC_CHECK_HEADERS(linux/vm_sockets.h,,,[
])

# On Linux, can.h, can/bcm.h, can/j1939.h, can/raw.h require sys/socket.h
AC_CHECK_HEADERS(linux/can.h linux/can/bcm.h linux/can/j1939.h linux/can/raw.h,,,[
# On NetBSD, netcan/can.h requires sys/socket.h
AC_CHECK_HEADERS(linux/can.h linux/can/bcm.h linux/can/j1939.h linux/can/raw.h netcan/can.h,,,[
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
Expand Down
3 changes: 3 additions & 0 deletions pyconfig.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -769,6 +769,9 @@
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
#undef HAVE_NDIR_H

/* Define to 1 if you have the <netcan/can.h> header file. */
#undef HAVE_NETCAN_CAN_H

/* Define to 1 if you have the <netinet/in.h> header file. */
#undef HAVE_NETINET_IN_H

Expand Down