By using C99 initializers for struct sockaddr_can addr the not
assigned members are automatically set to 0x0, resulting in not
passing uninitialized memory to the bind() syscall.
Also remove the printing of the socket family, type and proto, this
was interesting back in the days, when the numbers were not fixed, yet.
By using C99 initializers for struct sockaddr_can addr the not
assigned members are automatically set to 0x0, resulting in not
passing uninitialized memory to the bind() syscall.
The ASC file banner, e.g.
date Thu Jan 1 01:00:00 1970
base hex timestamps absolute
no internal events logged
should be printed when the first timestamp from the logfile has been
processed. But for logfiles starting with zero (e.g. candump -tz option)
this banner is printed every time the timestamps seconds equals zero.
As it was obviously not a good idea to stick the condition for printing
the banner based on some assumption about the timestamp a new variable
'print_banner' has been introduced.
Reported-by: https://github.com/CaSchmidt
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
When canbusload is executed without bit rate, it exits with an exit
code of 1 and prints help, but without explaining why. Users cannot
know what was wrong. When other errors occur, though, canbusload
prints an error message along with the help.
Print an error message when bit rate is not given or "@" is not found.
Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
The check for CAN FD capable interfaces only checked for CANFD_MTU to
enable the generation of CAN FD frame content. As CAN XL capable CAN
interfaces are able to handle CAN FD frames too the check has to be
extended for CANXL_MTU interfaces.
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
The check for CAN FD capable interfaces only checked for CANFD_MTU to
enable the generation of CAN FD frame content. As CAN XL capable CAN
interfaces are able to handle CAN FD frames too the check has to be
extended for CANXL_MTU interfaces.
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Systems that lack a MMU cannot use fork() to create the child process.
The patch does not compile the affected programs on MMU-less systems.
Co-developed-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Dario Binacchi <dario.binacchi@amarulasolutions.com>
| cangen.c: In function ‘parse_dataoptarg’:
| cangen.c:422:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
| for (int i = 0; i < CANFD_MAX_DLEN && i < arglen / 2; i++) {
| ^
| cangen.c:422:2: note: use option -std=c99 or -std=gnu99 to compile your code
| cangen.c: In function ‘main’:
| cangen.c:796:4: error: ‘for’ loop initial declarations are only allowed in C99 mode
| for (int i = 0; i < frame.len; i++) {
| ^
Reported-by: https://github.com/yannS2016
Link: https://github.com/linux-can/can-utils/issues/428
Fixes: e409aa4c8c ("cangen: new generation mode - partially randomized payload (-D)")
| cangen.c: In function ‘parse_dataoptarg’:
| cangen.c:422:2: error: ‘for’ loop initial declarations are only allowed in C99 mode
| for (int i = 0; i < CANFD_MAX_DLEN && i < arglen / 2; i++) {
| ^
| cangen.c:422:2: note: use option -std=c99 or -std=gnu99 to compile your code
| cangen.c: In function ‘main’:
| cangen.c:796:4: error: ‘for’ loop initial declarations are only allowed in C99 mode
| for (int i = 0; i < frame.len; i++) {
| ^
Reported-by: https://github.com/yannS2016
Link: https://github.com/linux-can/can-utils/issues/428
Fixes: e409aa4c8c ("cangen: new generation mode - partially randomized payload (-D)")
Bash and many other shells use 128 + signum as the exit status when a
program get signal and exit. Follow the common behavior so that we
know how the programs are killed.
slcand was returning 0 when SIGINT and SIGTERM is received. This
commit, instead, return 128 + signum when it gets a signal.
Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
Bash and many other shells use 128 + signum as the exit status when a
program get signal and exit. Follow the common behavior so that we
know how the programs are killed.
For j1939acd.c, it was using s.sig_term as a boolean key to exit from
the while loop. This commit replaces a.sig_term with a.signal_num,
which holds the signal it received.
Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
Bash and many other shells use 128 + signum as the exit status when a
program get signal and exit. Follow the common behavior so that we
know how the programs are killed.
canfdtest.c was effectively raising the received signal again to run
the default signal handler. This has been declined by the maintainer
because it's over-engineering. This commit replaces it with the
method proposed by the maintainer.
Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
Bash and many other shells use 128 + signum as the exit status when a
program get signal and exit. Follow the common behavior so that we
know how the programs are killed.
canlogserver.c was using a non-safe function, exit(3), in the signal
handler. This commit replaces it with the way other programs in
can-utils are using; set running = 0 to exit from the while loop.
Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
Bash and many other shells use 128 + signum as the exit status when a
program get signal and exit. Follow the common behavior so that we
know how the programs are killed.
canbusload.c was using a non-safe function, exit(3), in the signal
handler. This commit replaces it with the way other programs in
can-utils are using; set running = 0 to exit from the while loop.
Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
Bash and many other shells use 128 + signum as the exit status when a
program get signal and exit. Follow the common behavior so that we
know how the programs are killed.
Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
Bash and many other shells use 128 + signum as the exit status when a
program get signal and exit. Follow the common behavior so that we
know how the programs are killed.
Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
Bash and many other shells use 128 + signum as the exit status when a
program get signal and exit. Follow the common behavior so that we
know how the programs are killed.
Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
Bash and many other shells use 128 + signum as the exit status when a
program get signal and exit. Follow the common behavior so that we
know how the programs are killed.
Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
Bash and many other shells use 128 + signum as the exit status when a
program get signal and exit. Follow the common behavior so that we
know how the programs are killed.
Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
Update includes to support CAN XL and latest CAN netlink features.
Upstream commits:
(1a3e3034c049) "can: canxl: introduce CAN XL data structure"
(061834624c87) "can: set CANFD_FDF flag in all CAN FD frame structures"
(94dfc73e7cf4) "treewide: uapi: Replace zero-length arrays with flexible-array members"
(383f0993fc77) "can: netlink: report the CAN controller mode supported flags"
(d99755f71a80) "can: netlink: add interface for CAN-FD Transmitter Delay Compensation (TDC)"
(63dfe0709643) "can: bittiming: allow TDC{V,O} to be zero and add can_tdc_const::tdc{v,o,f}_min"
(626332696d75) "can: raw: add CAN XL support"
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Part of the fixed data payload can be randomized using the 'x' character.
Nibbles marked with 'x' will be randomized.
For example $ vcan0 -D 11xx3344DEADBEEF -L 8:
-> second byte of the payload will be randomized.
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
The commit c6f2cf7c2f ("cangen: add support for SO_TXTIME") relies
on several toolchain features ("CLOCK_TAI", "SO_TXTIME", "SCM_TXTIME")
which are not present in old toolchain.
Add defines to fix compilation on older toolchains.
Reported-by: https://github.com/b-thomson
Link: https://github.com/linux-can/can-utils/issues/398
Fixes: c6f2cf7c2f ("cangen: add support for SO_TXTIME")
Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>