June 2025 | ||||||
Mo | Tu | We | Th | Fr | Sa | Su |
26 | 27 | 28 | 29 | 30 | 31 | 1 |
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 |
30 | 1 | 2 | 3 | 4 | 5 | 6 |
001: /* 002: * linux/can.h 003: * 004: * Definitions for CAN network layer (socket addr / CAN frame / CAN filter) 005: * 006: * Authors: Oliver Hartkopp <oliver.hartkopp@volkswagen.de> 007: * Urs Thuermann <urs.thuermann@volkswagen.de> 008: * Copyright (c) 2002-2007 Volkswagen Group Electronic Research 009: * All rights reserved. 010: * 011: */ 012: 013: #ifndef CAN_H 014: #define CAN_H 015: 016: #include <linux/types.h> 017: #include <linux/socket.h> 018: 019: /* controller area network (CAN) kernel definitions */ 020: 021: /* special address description flags for the CAN_ID */ 022: #define CAN_EFF_FLAG 0x80000000U /* EFF/SFF is set in the MSB */ 023: #define CAN_RTR_FLAG 0x40000000U /* remote transmission request */ 024: #define CAN_ERR_FLAG 0x20000000U /* error frame */ 025: 026: /* valid bits in CAN ID for frame formats */ 027: #define CAN_SFF_MASK 0x000007FFU /* standard frame format (SFF) */ 028: #define CAN_EFF_MASK 0x1FFFFFFFU /* extended frame format (EFF) */ 029: #define CAN_ERR_MASK 0x1FFFFFFFU /* omit EFF, RTR, ERR flags */ 030: 031: /* 032: * Controller Area Network Identifier structure 033: * 034: * bit 0-28 : CAN identifier (11/29 bit) 035: * bit 29 : error frame flag (0 = data frame, 1 = error frame) 036: * bit 30 : remote transmission request flag (1 = rtr frame) 037: * bit 31 : frame format flag (0 = standard 11 bit, 1 = extended 29 bit) 038: */ 039: typedef __u32 canid_t; 040: 041: /* 042: * Controller Area Network Error Frame Mask structure 043: * 044: * bit 0-28 : error class mask (see include/linux/can/error.h) 045: * bit 29-31 : set to zero 046: */ 047: typedef __u32 can_err_mask_t; 048: 049: /** 050: * struct can_frame - basic CAN frame structure 051: * @can_id: the CAN ID of the frame and CAN_*_FLAG flags, see above. 052: * @can_dlc: the data length field of the CAN frame 053: * @data: the CAN frame payload. 054: */ 055: struct can_frame { 056: canid_t can_id; /* 32 bit CAN_ID + EFF/RTR/ERR flags */ 057: __u8 can_dlc; /* data length code: 0 .. 8 */ 058: __u8 data[8] __attribute__((aligned(8))); 059: }; 060: 061: /* particular protocols of the protocol family PF_CAN */ 062: #define CAN_RAW 1 /* RAW sockets */ 063: #define CAN_BCM 2 /* Broadcast Manager */ 064: #define CAN_TP16 3 /* VAG Transport Protocol v1.6 */ 065: #define CAN_TP20 4 /* VAG Transport Protocol v2.0 */ 066: #define CAN_MCNET 5 /* Bosch MCNet */ 067: #define CAN_ISOTP 6 /* ISO 15765-2 Transport Protocol */ 068: #define CAN_NPROTO 7 069: 070: #define SOL_CAN_BASE 100 071: 072: /** 073: * struct sockaddr_can - the sockaddr structure for CAN sockets 074: * @can_family: address family number AF_CAN. 075: * @can_ifindex: CAN network interface index. 076: * @can_addr: protocol specific address information 077: */ 078: struct sockaddr_can { 079: __kernel_sa_family_t can_family; 080: int can_ifindex; 081: union { 082: /* transport protocol class address information (e.g. ISOTP) */ 083: struct { canid_t rx_id, tx_id; } tp; 084: 085: /* reserved for future CAN protocols address information */ 086: } can_addr; 087: }; 088: 089: /** 090: * struct can_filter - CAN ID based filter in can_register(). 091: * @can_id: relevant bits of CAN ID which are not masked out. 092: * @can_mask: CAN mask (see description) 093: * 094: * Description: 095: * A filter matches, when 096: * 097: * <received_can_id> & mask == can_id & mask 098: * 099: * The filter can be inverted (CAN_INV_FILTER bit set in can_id) or it can 100: * filter for error frames (CAN_ERR_FLAG bit set in mask). 101: */ 102: struct can_filter { 103: canid_t can_id; 104: canid_t can_mask; 105: }; 106: 107: #define CAN_INV_FILTER 0x20000000U /* to be set in can_filter.can_id */ 108: 109: #endif /* CAN_H */ 110: