slcand: accept both tty* and /dev/tty* device names

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
include: Remove two unused header files

These seem to have never been used. They entered can-utils in commit
77de10356fe0 (include: import kernel header files into tree) and already
back then only consisted in an #include of a non-existing file.

Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
ioctl.h: drop unused header

This header doesn't exist in the Linux tree and it's unused by can-utils,
so drop it.

Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
isotp.h: add explicit license information

The copyright suggests to use the license used by the other files created by
Volkswagen.

Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
include/socketcan: prepare headers to be moved to include/linux

This patch changes the include from the socketcan folder to the linux folder:

-#include <socketcan/can.h>
+#include <linux/can.h>

so that the socketcan folder can be eliminated in a later patch.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
include: Move all includes from include/socketcan to include/linux

This makes it possible to import header from the kernel more easily, e.g.:

	cd $path_to_linux_repo
	make headers_install
	rsync -a --exclude .\* usr/include/linux/can* $path_to_can_utils/include/linux

[mkl: also move isotp.h although Uwe skipped it as it is not
      part of the upstream kernel; adapt commit log accordingly]

Acked-by: Oliver Hartkopp <socketcan@hartkopp.net>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
include: fix paths mentioned in files

This patch fixes paths mentioned in the files which are wrong now, due the move
of the files in the previous patch.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
include: can.h: remove unused include of version.h

This patch remove the include of version.h, as it's not used and also not
present in the kernel headers.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
include: can.h: add typedef for __kernel_sa_family_t to make headers self-contained

This patch adds the typedef for __kernel_sa_family_t that was introduced in
Linux v3.1-rc2 (commit 6602a4b net: Make userland include of netlink.h more sane)
in <linux/socket.h>. It must be duplicated here to make the CAN headers
self-contained.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
include: gw.h: update comment

This comment was added to the kernel in patch:

    391ac12 can: gw: add a per rule limitation of frame hops

The corresponding can-utils commit is:

    ad7f44095ac3 (cangw: add an option for the per rule limitation of frame hops)

which somehow introduced the difference even though it referenced commit
391ac12.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
include: import copyright information from the kernel

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
isotp: fix path mentioned in file

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
trivial: fix typo concerning "bandwidth"

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
canbusload: Add exact CAN frame length calculation (including bitstuffing)

This adds an algorithm for calculating the exact number of bits a CAN
frame occupies on the bus and uses this algorithm in canbusload. It
also moves the other methods for CAN frame length calculation, already
present in canbusload, to the new file.

The added algorithm calculates the exact number of stuffed bit in a
CAN frame. Note that in order to calculate that correctly, we must
also know the frame's CRC. Hence, the algorithm also includes CRC
calculation routine.

The correctness of the algorithm was verified on an oscilloscope for
several different SFF and EFF frames.

Currently only CAN frames are supported. For CANFD frames, a different
algorithm is needed. CANFD uses different CRC polynomials and
calculates the CRC from the staffed bit-stream (CAN calculates CRC
from de-stuffed bit-stream).

Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
canbusload: Fix worst-case frame length estimation

The Tindell's method used previously is incorrect. It does not account for
the fact that the stuffed bits are themselves also subject to bit stuffing.

Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Add license to canframelen.h

Signed-off-by: Michal Sojka <sojkam1@fel.cvut.cz>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Android.mk: canbusload: fix compilation, make use of libcan

In commit

    2206f92 canbusload: Add exact CAN frame length calculation (including bitstuffing)

the function to calculate the can_frame_length was moved into a seperate file
(canframelen.c). This patch for the Android makefile adds canframelen.c to the
lib, too and lets canbusload link against the lib.

Tested-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
slcand: include <sys/socket.h>

Linux build compiles without errors, but Android build
complains about undefined routines and macros.

Signed-off-by: Yegor Yefremov <yegorslists@googlemail.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
canbusload: print bitstuffing mode when showing current time is enabled

When printing the current time on the first line the bitstuffing mode is
displayed depending on the command line settings.

Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
Makefile: move cpp related flags from CFLAGS to CPPFLAGS

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>