Commit Graph

39 Commits (008f9f8e227d116b7bf2be7d8e6082b8a08c5203)

Author SHA1 Message Date
Oliver Hartkopp dd16f2603b can-utils: make local functions static
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2024-03-12 20:10:00 +01:00
Oliver Hartkopp dfb607c807 remove obsolete char pointer casts
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2022-03-14 18:21:45 +01:00
Oliver Hartkopp f7307b8290 can-utils: check for return values of if_nametoindex()
if_nametoindex() returns zero and a specific errno in the case the network
interface does not exist. The missing check leads to the use of the 'any'
CAN device but leaves the user alone as the user gets no error message.

Reported-by: Lothar Rubusch <lotophagon@protonmail.com>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2021-10-18 09:37:46 +02:00
Oliver Hartkopp c3d9cc2027 cangw: support len8_dlc for Classical CAN frames
The can_dlc value that is passed to the kernel is not sanitized in cangw
therefore we only update the help text and some comments in gw.h.

In the case that the CAN interface supports len8_dlc by setting
CAN_CTRLMODE_CC_LEN8_DLC the can-gw module can modify the full DLC value
range (0 .. 15) for Classic CAN frames.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-11-22 19:57:27 +01:00
Rosen Penev 204235c9ce make struct initialization C99 compatible again
Mainly change {} to { 0 } to remove a pedantic warning.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-10-14 13:29:13 +02:00
Oliver Hartkopp a591dadd96 cangw: fix sscanf() signed/unsigned warning
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-10-13 10:28:52 +02:00
Rosen Penev 48bb69bc7b
remove basic usages of memset with {}
Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-10-12 23:28:58 -07:00
Rosen Penev b153fe3f35
clang-tidy: sort includes alphabetically
Found with llvm-include-order

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-10-12 23:28:58 -07:00
Gary Bisson 43610bd621 Fix arithmetic on a pointer warning
Signed-off-by: Gary Bisson <gary.bisson@boundarydevices.com>
2020-05-28 20:54:37 +02:00
Gary Bisson 46895a41c5 Fix comparison type mismatch warnings
Signed-off-by: Gary Bisson <gary.bisson@boundarydevices.com>
2020-05-28 20:54:37 +02:00
Oliver Hartkopp f3ced10007 cangw: make help text fit into 80 colums again
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2020-04-28 19:01:07 +02:00
Alexander GQ Gerasiov 1127609357 cangw.c: Reformat help/usage output to be compatible with help2man.
Gbp-Pq: Name 0007-cangw.c-Reformat-help-usage-output-to-be-compatible-.patch
2020-04-27 08:20:08 +03:00
Yegor Yefremov 14ccc06eba Fix spelling in various files
codespell parameters:

codespell -q 3 --skip="*.in,*.sh,*.m4,config,configure,autom4te.cache"

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
2019-11-11 14:21:49 +01:00
Oliver Hartkopp d45f3f46bd cangw: add CAN FD support
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2019-08-16 15:32:16 +02:00
Oliver Hartkopp 07054c06f5 cangw: remove sanity checks that are better handled in the kernel
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2019-08-16 15:26:58 +02:00
Oliver Hartkopp 24923df749 cangw: add new command line option '-X' to handle CAN FD rules
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2019-08-16 15:26:50 +02:00
Yegor Yefremov 7b7331976a Add SPDX identifiers
Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
2019-06-19 12:24:24 +02:00
Tomasz Wasilczyk f6e07960d3 Silence false positive unaligned pointer access warning
This is a warning coming up on Android (ARM) platform.
Clang 4.x creates a false positive here: the can_id is the first
(and aligned) value in the packed struct modattr, so it's always
aligned if the struct itself is aligned.
2019-01-10 10:04:37 -08:00
Oliver Hartkopp 8af831f377 cangw: introduce uid command line option
Similar to referencing iptables rules by their line number this UID allows to
reference created routing jobs, e.g. to alter configured data modifications.

The UID is an optional non-zero value which can be provided at routing job
creation time. When the UID is set the UID replaces the data modification
configuration as job identification attribute e.g. at job removal time.

The UID option is provided by mainline Linux 4.2+

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2015-06-11 20:48:43 +02:00
Oliver Hartkopp ad7f44095a cangw: add an option for the per rule limitation of frame hops
Usually the received CAN frames can be processed/routed as much as 'max_hops'
times (which is given at module load time of the can-gw module).
Introduce a new configuration option ( -l <hops> ) to reduce the number of
possible hops for a specific gateway rule to a value smaller then max_hops.

Mainline upstream commit:

http://git.kernel.org/cgit/linux/kernel/git/davem/net-next.git/commit/?id=391ac1282dd7ff1cb8245cccc5262e8e4173edc4

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2013-09-04 20:30:34 +02:00
Oliver Hartkopp 29c3e344a5 cangw: fix inverse filter display when printing the configured rules
A configured inverse filter e.g.

cangw -A -s can0 -d can1 -e -f 123~7FF

has been displayed with 'cangw -L' like this:

cangw -A -s can0 -d can1 -e -f 20000123:7FF # 0 handled 0 dropped 0 deleted

While 0x20000000 was the value of CAN_INV_FILTER.

This patch fixes the output to the expected display:

cangw -A -s can0 -d can1 -e -f 123~7FF # 0 handled 0 dropped 0 deleted

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2013-01-29 20:50:46 +01:00
Oliver Hartkopp 9dad9f7354 cangw: support new can-gw features for Linux 3.9+
Added new option '-i' for can-gw rules to allow to route CAN frames back to the
originating/incoming CAN interface (which is disabled by default).

CAN frames that are deleted due to the violation of the max_hops limit are now
printed when displaying the configured rules with 'cangw -L'.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2013-01-29 20:17:52 +01:00
Oliver Hartkopp 836d3cc012 remove obsolete SVN ID tags
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2012-11-14 20:57:16 +01:00
Oliver Hartkopp f123d73d9a cangw: add semantic check for checksum options
The options to for adding checksums (-c or -x) can only be used in conjunction
with modifications (-m) applied to the routed CAN frames.

Signed-off-by: Andre Naujoks <nautsch2@googlemail.com>
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
2012-11-14 20:20:38 +01:00
Marc Kleine-Budde 722a09116d treewide: replace berlios contact email by linux-can@vger.kernel.org
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2012-01-11 12:14:15 +01:00
Oliver Hartkopp d3468d907f Fix datatype issue in sscanf() on 64bit systems.
On 64bit systems a 'long' is a 64bit value but the target values of scanf()
are always 32bit in the affected code - which means just an 'unsigned int'.
Unsigned int is fine on 32 and 64 bit systems.

Thanks to Andre Naujoks for reporting this issue.
2010-09-25 10:24:37 +00:00
Oliver Hartkopp 1463ee4ce4 Added support for inverted CAN ID filters. 2010-09-24 18:23:42 +00:00
Marc Kleine-Budde f7be786e9a cangw: replace obsolete bzero by memset
uclibc for example doesn't implement bzero

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
2010-04-19 12:11:49 +00:00
Oliver Hartkopp c6b3ceff83 Added CRC8 profiles to handle additional data for checksum generation. 2010-04-16 08:46:17 +00:00
Oliver Hartkopp 9e8f9200fb Added checksum functionality and some documentation in gw.h 2010-04-12 14:41:14 +00:00
Oliver Hartkopp a784e1e46f Complete rework of CAN netlink gateway.
Major changes:

- rework internal structures to prepare routings and modifications of CAN traffic also to non-CAN interfaces
- fix reading of netlink messages in cangw.c (added RTCAN_RTA / RTCAN_PAYLOAD macros)
- rework reading of gw-job lists in cgw_dump_jobs()
- rename of functions and API definitions to have a common namespace cgw_
- added infrastructure to perform crc8 and xor checksums in CAN frame data[]

TODO:

- add and test functionality for crc8 and xor checksums in CAN frame data[]
- add help text for crc8 and xor checksums in CAN frame data[]
2010-04-10 16:38:48 +00:00
Oliver Hartkopp 3765e1d25b Initialize packet counters when printing each routing entry. 2010-03-04 10:59:24 +00:00
Oliver Hartkopp d81a13866b Rework of help text. 2010-02-27 16:07:58 +00:00
Oliver Hartkopp 3a0612c14a Added funtionality to flush all GW jobs in one netlink message. 2010-02-23 19:13:17 +00:00
Oliver Hartkopp 37744ac503 Beautify the listing of registered gwjobs (cangw -L). 2010-02-22 18:57:45 +00:00
Oliver Hartkopp a48038d82b Added feature to list created gateway jobs.
Also added some fixes and removed debug printf's.
2010-02-22 09:57:12 +00:00
Oliver Hartkopp bd1ebaaf28 Added netlink error message support to be able to provide return values.
Renamed some structure elements. Updated usage text.
2010-02-21 12:34:34 +00:00
Oliver Hartkopp 0dc9fcc98e Moved kernel parsing of netlink attributes into can_can_parse_attr().
Added functionalitiy to remove formerly created CAN GW jobs.
2010-02-20 20:41:24 +00:00
Oliver Hartkopp 67b604e53b Added cangw netlink gateway configuration tool.
TODO (in both cangw and can-gw.ko) : Support removal and listing of rules.
So far the gateway jobs are only removed on can-gw.ko module unload or when
the used CAN netdevices disappear.
2010-02-19 13:33:59 +00:00