GeezerVison is showing github.com — gh-86819: Add ISO-TP CAN socket constants by rumpelsepp · Pull Request #23794 · python/cpython
gh-86819: Add ISO-TP CAN socket constants
#23794
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement . We’ll occasionally send you account related emails.
Already on GitHub?
Sign in
to your account
Uh oh!
There was an error while loading. Please reload this page.
Show file tree
Hide file tree
Changes from all commits
Commits
File filter
Filter by extension
.ac
(1)
.c
(1)
.h
(1)
.in
(1)
.py
(1)
.rst
(2)
No extension
(1)
All 7 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Hide whitespace
Diff view
Hide whitespace
There are no files selected for viewing
Original file line number
Diff line number
Diff line change
Expand Up
@@ -404,6 +404,13 @@ shelve
(Contributed by Andrea Oliveri in :gh:`134004`.)
socket
------
* Add constants for the ISO-TP CAN protocol.
(Contributed by Patrick Menschel and Stefan Tatschner in :gh:`86819`.)
sqlite3
-------
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -2393,6 +2393,45 @@ def testCrucialConstants(self):
socket.CAN_ISOTP
socket.SOCK_DGRAM
@unittest.skipUnless(hasattr(socket, "SOL_CAN_ISOTP"),
"missing <linux/can/isotp.h>")
def testISOTP(self):
socket.SOL_CAN_ISOTP
socket.CAN_ISOTP_OPTS
socket.CAN_ISOTP_RECV_FC
socket.CAN_ISOTP_TX_STMIN
socket.CAN_ISOTP_RX_STMIN
socket.CAN_ISOTP_LL_OPTS
socket.CAN_ISOTP_LISTEN_MODE
socket.CAN_ISOTP_EXTEND_ADDR
socket.CAN_ISOTP_TX_PADDING
socket.CAN_ISOTP_RX_PADDING
socket.CAN_ISOTP_CHK_PAD_LEN
socket.CAN_ISOTP_CHK_PAD_DATA
socket.CAN_ISOTP_HALF_DUPLEX
socket.CAN_ISOTP_FORCE_TXSTMIN
socket.CAN_ISOTP_FORCE_RXSTMIN
socket.CAN_ISOTP_RX_EXT_ADDR
socket.CAN_ISOTP_WAIT_TX_DONE
# This constant is not always available
# socket.CAN_ISOTP_SF_BROADCAST
socket.CAN_ISOTP_DEFAULT_FLAGS
socket.CAN_ISOTP_DEFAULT_EXT_ADDRESS
socket.CAN_ISOTP_DEFAULT_PAD_CONTENT
socket.CAN_ISOTP_DEFAULT_FRAME_TXTIME
socket.CAN_ISOTP_DEFAULT_RECV_BS
socket.CAN_ISOTP_DEFAULT_EXT_ADDRESS
socket.CAN_ISOTP_DEFAULT_RECV_STMIN
socket.CAN_ISOTP_DEFAULT_RECV_WFTMAX
socket.CAN_ISOTP_DEFAULT_LL_MTU
socket.CAN_ISOTP_DEFAULT_LL_TX_DL
socket.CAN_ISOTP_DEFAULT_LL_TX_FLAGS
def testCreateSocket(self):
with socket.socket(socket.PF_CAN, socket.SOCK_RAW, socket.CAN_RAW) as s:
pass
Expand Down
Original file line number
Diff line number
Diff line change
@@ -0,0 +1 @@
:mod:`socket`: Add missing constants for ISO-TP sockets.
Original file line number
Diff line number
Diff line change
Expand Up
@@ -8528,6 +8528,43 @@ socket_exec(PyObject *m)
ADD_INT_MACRO(m, J1939_FILTER_MAX);
#endif
#ifdef HAVE_LINUX_CAN_ISOTP_H
ADD_INT_MACRO(m, SOL_CAN_ISOTP);
ADD_INT_MACRO(m, CAN_ISOTP_OPTS);
ADD_INT_MACRO(m, CAN_ISOTP_RECV_FC);
ADD_INT_MACRO(m, CAN_ISOTP_TX_STMIN);
ADD_INT_MACRO(m, CAN_ISOTP_RX_STMIN);
ADD_INT_MACRO(m, CAN_ISOTP_LL_OPTS);
ADD_INT_MACRO(m, CAN_ISOTP_LISTEN_MODE);
ADD_INT_MACRO(m, CAN_ISOTP_EXTEND_ADDR);
ADD_INT_MACRO(m, CAN_ISOTP_TX_PADDING);
ADD_INT_MACRO(m, CAN_ISOTP_RX_PADDING);
ADD_INT_MACRO(m, CAN_ISOTP_CHK_PAD_LEN);
ADD_INT_MACRO(m, CAN_ISOTP_CHK_PAD_DATA);
ADD_INT_MACRO(m, CAN_ISOTP_HALF_DUPLEX);
ADD_INT_MACRO(m, CAN_ISOTP_FORCE_TXSTMIN);
ADD_INT_MACRO(m, CAN_ISOTP_FORCE_RXSTMIN);
ADD_INT_MACRO(m, CAN_ISOTP_RX_EXT_ADDR);
ADD_INT_MACRO(m, CAN_ISOTP_WAIT_TX_DONE);
#ifdef CAN_ISOTP_SF_BROADCAST
ADD_INT_MACRO(m, CAN_ISOTP_SF_BROADCAST);
#endif
ADD_INT_MACRO(m, CAN_ISOTP_DEFAULT_FLAGS);
ADD_INT_MACRO(m, CAN_ISOTP_DEFAULT_EXT_ADDRESS);
ADD_INT_MACRO(m, CAN_ISOTP_DEFAULT_PAD_CONTENT);
ADD_INT_MACRO(m, CAN_ISOTP_DEFAULT_FRAME_TXTIME);
ADD_INT_MACRO(m, CAN_ISOTP_DEFAULT_RECV_BS);
ADD_INT_MACRO(m, CAN_ISOTP_DEFAULT_RECV_STMIN);
ADD_INT_MACRO(m, CAN_ISOTP_DEFAULT_RECV_WFTMAX);
ADD_INT_MACRO(m, CAN_ISOTP_DEFAULT_LL_MTU);
ADD_INT_MACRO(m, CAN_ISOTP_DEFAULT_LL_TX_DL);
ADD_INT_MACRO(m, CAN_ISOTP_DEFAULT_LL_TX_FLAGS);
#endif
#ifdef SOL_RDS
ADD_INT_MACRO(m, SOL_RDS);
#endif
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -165,6 +165,10 @@ typedef int socklen_t;
#include <linux/can/bcm.h>
#endif
#ifdef HAVE_LINUX_CAN_ISOTP_H
#include <linux/can/isotp.h>
#endif
#ifdef HAVE_LINUX_CAN_J1939_H
#include <linux/can/j1939.h>
#endif
Expand Down
13 changes: 12 additions & 1 deletion
13
configure
Oops, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Original file line number
Diff line number
Diff line change
Expand Up
@@ -3053,10 +3053,10 @@ AC_CHECK_HEADERS([linux/vm_sockets.h], [], [], [
#endif
])
# On Linux, can.h, can/bcm.h, can/j1939.h, can/raw.h require sys/socket.h
# On Linux, can.h, can/bcm.h, can/isotp.h, can/ j1939.h, can/raw.h require sys/socket.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],
[linux/can.h linux/can/bcm.h linux/can/isotp.h linux/can/ j1939.h linux/can/raw.h netcan/can.h],
[], [], [
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
Expand Down
Original file line number
Diff line number
Diff line change
Expand Up
@@ -727,6 +727,9 @@
/* Define to 1 if you have the <linux/can.h> header file. */
#undef HAVE_LINUX_CAN_H
/* Define to 1 if you have the <linux/can/isotp.h> header file. */
#undef HAVE_LINUX_CAN_ISOTP_H
/* Define to 1 if you have the <linux/can/j1939.h> header file. */
#undef HAVE_LINUX_CAN_J1939_H
Expand Down
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.