# This file has been autogenerated by `just gen-constants`.
# !! DO NOT CHANGE MANUALLY !!

# SPDX-FileCopyrightText: AISEC Pentesting Team
#
# SPDX-License-Identifier: Apache-2.0

import struct

CANFD_MTU = 72
CAN_MTU = 16

# https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/can.h
CAN_HEADER_FMT = struct.Struct("=IBB2x")

CANFD_BRS = 0x01
CANFD_ESI = 0x02

CAN_EFF_FLAG = 2147483648
CAN_ERR_FLAG = 536870912
CAN_RTR_FLAG = 1073741824

CAN_EFF_MASK = 536870911
CAN_INV_FILTER = 0x20000000  # TODO: Add to CPython
CAN_SFF_MASK = 2047

CAN_RAW = 1
CAN_RAW_FD_FRAMES = 5
CAN_RAW_FILTER = 1
CAN_RAW_JOIN_FILTERS = 6
SOL_CAN_RAW = 101

# Socket Constants not available in the socket module,
# see linux/can/isotp.h
# TODO: This is now available in Python 3.15+.
# https://github.com/python/cpython/pull/23794
SOL_CAN_ISOTP = 106

# Valuetypes for SOL_CAN_ISOTP
CAN_ISOTP_OPTS = 1
CAN_ISOTP_RECV_FC = 2
CAN_ISOTP_TX_STMIN = 3
CAN_ISOTP_RX_STMIN = 4
CAN_ISOTP_LL_OPTS = 5

# Flags for setsockopt CAN_ISOTP_OPTS
CAN_ISOTP_LISTEN_MODE = 0x001
CAN_ISOTP_EXTEND_ADDR = 0x002
CAN_ISOTP_TX_PADDING = 0x004
CAN_ISOTP_RX_PADDING = 0x008
CAN_ISOTP_CHK_PAD_LEN = 0x010
CAN_ISOTP_CHK_PAD_DATA = 0x020
CAN_ISOTP_HALF_DUPLEX = 0x040
CAN_ISOTP_FORCE_TXSTMIN = 0x080
CAN_ISOTP_FORCE_RXSTMIN = 0x100
CAN_ISOTP_RX_EXT_ADDR = 0x200
