Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ShExBy/shex_roo.../usr/include/linux/can
File: gw.h
/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */
[0] Fix | Delete
/*
[1] Fix | Delete
* linux/can/gw.h
[2] Fix | Delete
*
[3] Fix | Delete
* Definitions for CAN frame Gateway/Router/Bridge
[4] Fix | Delete
*
[5] Fix | Delete
* Author: Oliver Hartkopp <oliver.hartkopp@volkswagen.de>
[6] Fix | Delete
* Copyright (c) 2011 Volkswagen Group Electronic Research
[7] Fix | Delete
* All rights reserved.
[8] Fix | Delete
*
[9] Fix | Delete
* Redistribution and use in source and binary forms, with or without
[10] Fix | Delete
* modification, are permitted provided that the following conditions
[11] Fix | Delete
* are met:
[12] Fix | Delete
* 1. Redistributions of source code must retain the above copyright
[13] Fix | Delete
* notice, this list of conditions and the following disclaimer.
[14] Fix | Delete
* 2. Redistributions in binary form must reproduce the above copyright
[15] Fix | Delete
* notice, this list of conditions and the following disclaimer in the
[16] Fix | Delete
* documentation and/or other materials provided with the distribution.
[17] Fix | Delete
* 3. Neither the name of Volkswagen nor the names of its contributors
[18] Fix | Delete
* may be used to endorse or promote products derived from this software
[19] Fix | Delete
* without specific prior written permission.
[20] Fix | Delete
*
[21] Fix | Delete
* Alternatively, provided that this notice is retained in full, this
[22] Fix | Delete
* software may be distributed under the terms of the GNU General
[23] Fix | Delete
* Public License ("GPL") version 2, in which case the provisions of the
[24] Fix | Delete
* GPL apply INSTEAD OF those given above.
[25] Fix | Delete
*
[26] Fix | Delete
* The provided data structures and external interfaces from this code
[27] Fix | Delete
* are not restricted to be used by modules with a GPL compatible license.
[28] Fix | Delete
*
[29] Fix | Delete
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
[30] Fix | Delete
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
[31] Fix | Delete
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
[32] Fix | Delete
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
[33] Fix | Delete
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
[34] Fix | Delete
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
[35] Fix | Delete
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
[36] Fix | Delete
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
[37] Fix | Delete
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
[38] Fix | Delete
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
[39] Fix | Delete
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
[40] Fix | Delete
* DAMAGE.
[41] Fix | Delete
*/
[42] Fix | Delete
[43] Fix | Delete
#ifndef _CAN_GW_H
[44] Fix | Delete
#define _CAN_GW_H
[45] Fix | Delete
[46] Fix | Delete
#include <linux/types.h>
[47] Fix | Delete
#include <linux/can.h>
[48] Fix | Delete
[49] Fix | Delete
struct rtcanmsg {
[50] Fix | Delete
__u8 can_family;
[51] Fix | Delete
__u8 gwtype;
[52] Fix | Delete
__u16 flags;
[53] Fix | Delete
};
[54] Fix | Delete
[55] Fix | Delete
/* CAN gateway types */
[56] Fix | Delete
enum {
[57] Fix | Delete
CGW_TYPE_UNSPEC,
[58] Fix | Delete
CGW_TYPE_CAN_CAN, /* CAN->CAN routing */
[59] Fix | Delete
__CGW_TYPE_MAX
[60] Fix | Delete
};
[61] Fix | Delete
[62] Fix | Delete
#define CGW_TYPE_MAX (__CGW_TYPE_MAX - 1)
[63] Fix | Delete
[64] Fix | Delete
/* CAN rtnetlink attribute definitions */
[65] Fix | Delete
enum {
[66] Fix | Delete
CGW_UNSPEC,
[67] Fix | Delete
CGW_MOD_AND, /* CAN frame modification binary AND */
[68] Fix | Delete
CGW_MOD_OR, /* CAN frame modification binary OR */
[69] Fix | Delete
CGW_MOD_XOR, /* CAN frame modification binary XOR */
[70] Fix | Delete
CGW_MOD_SET, /* CAN frame modification set alternate values */
[71] Fix | Delete
CGW_CS_XOR, /* set data[] XOR checksum into data[index] */
[72] Fix | Delete
CGW_CS_CRC8, /* set data[] CRC8 checksum into data[index] */
[73] Fix | Delete
CGW_HANDLED, /* number of handled CAN frames */
[74] Fix | Delete
CGW_DROPPED, /* number of dropped CAN frames */
[75] Fix | Delete
CGW_SRC_IF, /* ifindex of source network interface */
[76] Fix | Delete
CGW_DST_IF, /* ifindex of destination network interface */
[77] Fix | Delete
CGW_FILTER, /* specify struct can_filter on source CAN device */
[78] Fix | Delete
CGW_DELETED, /* number of deleted CAN frames (see max_hops param) */
[79] Fix | Delete
CGW_LIM_HOPS, /* limit the number of hops of this specific rule */
[80] Fix | Delete
CGW_MOD_UID, /* user defined identifier for modification updates */
[81] Fix | Delete
__CGW_MAX
[82] Fix | Delete
};
[83] Fix | Delete
[84] Fix | Delete
#define CGW_MAX (__CGW_MAX - 1)
[85] Fix | Delete
[86] Fix | Delete
#define CGW_FLAGS_CAN_ECHO 0x01
[87] Fix | Delete
#define CGW_FLAGS_CAN_SRC_TSTAMP 0x02
[88] Fix | Delete
#define CGW_FLAGS_CAN_IIF_TX_OK 0x04
[89] Fix | Delete
[90] Fix | Delete
#define CGW_MOD_FUNCS 4 /* AND OR XOR SET */
[91] Fix | Delete
[92] Fix | Delete
/* CAN frame elements that are affected by curr. 3 CAN frame modifications */
[93] Fix | Delete
#define CGW_MOD_ID 0x01
[94] Fix | Delete
#define CGW_MOD_DLC 0x02
[95] Fix | Delete
#define CGW_MOD_DATA 0x04
[96] Fix | Delete
[97] Fix | Delete
#define CGW_FRAME_MODS 3 /* ID DLC DATA */
[98] Fix | Delete
[99] Fix | Delete
#define MAX_MODFUNCTIONS (CGW_MOD_FUNCS * CGW_FRAME_MODS)
[100] Fix | Delete
[101] Fix | Delete
struct cgw_frame_mod {
[102] Fix | Delete
struct can_frame cf;
[103] Fix | Delete
__u8 modtype;
[104] Fix | Delete
} __attribute__((packed));
[105] Fix | Delete
[106] Fix | Delete
#define CGW_MODATTR_LEN sizeof(struct cgw_frame_mod)
[107] Fix | Delete
[108] Fix | Delete
struct cgw_csum_xor {
[109] Fix | Delete
__s8 from_idx;
[110] Fix | Delete
__s8 to_idx;
[111] Fix | Delete
__s8 result_idx;
[112] Fix | Delete
__u8 init_xor_val;
[113] Fix | Delete
} __attribute__((packed));
[114] Fix | Delete
[115] Fix | Delete
struct cgw_csum_crc8 {
[116] Fix | Delete
__s8 from_idx;
[117] Fix | Delete
__s8 to_idx;
[118] Fix | Delete
__s8 result_idx;
[119] Fix | Delete
__u8 init_crc_val;
[120] Fix | Delete
__u8 final_xor_val;
[121] Fix | Delete
__u8 crctab[256];
[122] Fix | Delete
__u8 profile;
[123] Fix | Delete
__u8 profile_data[20];
[124] Fix | Delete
} __attribute__((packed));
[125] Fix | Delete
[126] Fix | Delete
/* length of checksum operation parameters. idx = index in CAN frame data[] */
[127] Fix | Delete
#define CGW_CS_XOR_LEN sizeof(struct cgw_csum_xor)
[128] Fix | Delete
#define CGW_CS_CRC8_LEN sizeof(struct cgw_csum_crc8)
[129] Fix | Delete
[130] Fix | Delete
/* CRC8 profiles (compute CRC for additional data elements - see below) */
[131] Fix | Delete
enum {
[132] Fix | Delete
CGW_CRC8PRF_UNSPEC,
[133] Fix | Delete
CGW_CRC8PRF_1U8, /* compute one additional u8 value */
[134] Fix | Delete
CGW_CRC8PRF_16U8, /* u8 value table indexed by data[1] & 0xF */
[135] Fix | Delete
CGW_CRC8PRF_SFFID_XOR, /* (can_id & 0xFF) ^ (can_id >> 8 & 0xFF) */
[136] Fix | Delete
__CGW_CRC8PRF_MAX
[137] Fix | Delete
};
[138] Fix | Delete
[139] Fix | Delete
#define CGW_CRC8PRF_MAX (__CGW_CRC8PRF_MAX - 1)
[140] Fix | Delete
[141] Fix | Delete
/*
[142] Fix | Delete
* CAN rtnetlink attribute contents in detail
[143] Fix | Delete
*
[144] Fix | Delete
* CGW_XXX_IF (length 4 bytes):
[145] Fix | Delete
* Sets an interface index for source/destination network interfaces.
[146] Fix | Delete
* For the CAN->CAN gwtype the indices of _two_ CAN interfaces are mandatory.
[147] Fix | Delete
*
[148] Fix | Delete
* CGW_FILTER (length 8 bytes):
[149] Fix | Delete
* Sets a CAN receive filter for the gateway job specified by the
[150] Fix | Delete
* struct can_filter described in include/linux/can.h
[151] Fix | Delete
*
[152] Fix | Delete
* CGW_MOD_(AND|OR|XOR|SET) (length 17 bytes):
[153] Fix | Delete
* Specifies a modification that's done to a received CAN frame before it is
[154] Fix | Delete
* send out to the destination interface.
[155] Fix | Delete
*
[156] Fix | Delete
* <struct can_frame> data used as operator
[157] Fix | Delete
* <u8> affected CAN frame elements
[158] Fix | Delete
*
[159] Fix | Delete
* CGW_LIM_HOPS (length 1 byte):
[160] Fix | Delete
* Limit the number of hops of this specific rule. Usually the received CAN
[161] Fix | Delete
* frame can be processed as much as 'max_hops' times (which is given at module
[162] Fix | Delete
* load time of the can-gw module). This value is used to reduce the number of
[163] Fix | Delete
* possible hops for this gateway rule to a value smaller then max_hops.
[164] Fix | Delete
*
[165] Fix | Delete
* CGW_MOD_UID (length 4 bytes):
[166] Fix | Delete
* Optional non-zero user defined routing job identifier to alter existing
[167] Fix | Delete
* modification settings at runtime.
[168] Fix | Delete
*
[169] Fix | Delete
* CGW_CS_XOR (length 4 bytes):
[170] Fix | Delete
* Set a simple XOR checksum starting with an initial value into
[171] Fix | Delete
* data[result-idx] using data[start-idx] .. data[end-idx]
[172] Fix | Delete
*
[173] Fix | Delete
* The XOR checksum is calculated like this:
[174] Fix | Delete
*
[175] Fix | Delete
* xor = init_xor_val
[176] Fix | Delete
*
[177] Fix | Delete
* for (i = from_idx .. to_idx)
[178] Fix | Delete
* xor ^= can_frame.data[i]
[179] Fix | Delete
*
[180] Fix | Delete
* can_frame.data[ result_idx ] = xor
[181] Fix | Delete
*
[182] Fix | Delete
* CGW_CS_CRC8 (length 282 bytes):
[183] Fix | Delete
* Set a CRC8 value into data[result-idx] using a given 256 byte CRC8 table,
[184] Fix | Delete
* a given initial value and a defined input data[start-idx] .. data[end-idx].
[185] Fix | Delete
* Finally the result value is XOR'ed with the final_xor_val.
[186] Fix | Delete
*
[187] Fix | Delete
* The CRC8 checksum is calculated like this:
[188] Fix | Delete
*
[189] Fix | Delete
* crc = init_crc_val
[190] Fix | Delete
*
[191] Fix | Delete
* for (i = from_idx .. to_idx)
[192] Fix | Delete
* crc = crctab[ crc ^ can_frame.data[i] ]
[193] Fix | Delete
*
[194] Fix | Delete
* can_frame.data[ result_idx ] = crc ^ final_xor_val
[195] Fix | Delete
*
[196] Fix | Delete
* The calculated CRC may contain additional source data elements that can be
[197] Fix | Delete
* defined in the handling of 'checksum profiles' e.g. shown in AUTOSAR specs
[198] Fix | Delete
* like http://www.autosar.org/download/R4.0/AUTOSAR_SWS_E2ELibrary.pdf
[199] Fix | Delete
* E.g. the profile_data[] may contain additional u8 values (called DATA_IDs)
[200] Fix | Delete
* that are used depending on counter values inside the CAN frame data[].
[201] Fix | Delete
* So far only three profiles have been implemented for illustration.
[202] Fix | Delete
*
[203] Fix | Delete
* Remark: In general the attribute data is a linear buffer.
[204] Fix | Delete
* Beware of sending unpacked or aligned structs!
[205] Fix | Delete
*/
[206] Fix | Delete
[207] Fix | Delete
#endif /* !_UAPI_CAN_GW_H */
[208] Fix | Delete
[209] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function