thuermann [Mon, 27 Nov 2006 19:34:34 +0000 (19:34 +0000)]
add and change some comments.
simplify the code for CAN_RAW_FILTER socket option.
don't remove filters in CAN_RAW_FILTER when an invalid address for a single
filter was given causing -EFAULT.
bug fix in CAN_RAW_FILTER: changed & to &&.
disallow optlen == 0 for CAN_RAW_LOOPBACK and CAN_RAW_RECV_OWN_MSGS.
remove a couple unnecessary type casts.
change prefix "af_can" to "CAN" in printk message.
thuermann [Mon, 27 Nov 2006 11:45:55 +0000 (11:45 +0000)]
backport from the 2.6 version:
- add 'loop' parameter to can_send().
- do loopback only if the interface hasn't IFF_LOOPBACK set.
- add struct can_proto and use that in can_proto_{,un}register().
- define type, protocol, and capability fields in struct can_proto instead
of doing a switch() on type and proto in can_create().
- call protocol init function if defined.
- split off new function find_dev_rcv_lists() from find_rcv_list().
- rename struct rcv_list and rcv_dev_list to receiver and dev_rcv_lists.
- move memory allocation out of spin-locked region.
- rename struct notifier_list to notifier, and variable nlist to notifier_list.
- use kernel list implementation for notifier_list.
- protect access to notifier list by holding notifier_lock.
- use kmem_caches for struct receiver instead of kmalloc.
- do allocation/freeing of dev_rcv_lists in NETDEV_{,UN}REGISTER.
+ new element pprev in struct dev_rcv_lists to ease removal of list elements.
- rename CAN_MAX to CAN_NPROTO.
- rename some local variables for readability.
- rename raw_{init,exit}() to raw_module_{init,exit}().
- new function raw_init() to be called from can_create().
- return EINVAL from raw_bind() if already bound.
still TODO
- new ioctl's in raw.c: CAN_RAW_LOOPBACK, CAN_RAW_RECV_OWN_MSGS.
- allow setsockopt in raw.c to set 0 filters.
hartkopp [Wed, 22 Nov 2006 19:36:42 +0000 (19:36 +0000)]
Added debugging info to BCM procfs output to detect dataloss due to
socket-queue overflow to the userspace application.
E.g. when the user-app is not able to deal with the (fast) data-updates from
the CAN-bus.
hartkopp [Fri, 17 Nov 2006 15:55:09 +0000 (15:55 +0000)]
Added the possibility to set _no_ RX filter in CAN_RAW sockets as requested
by Wolfgang Grandegger on the socketcan-core mailinglist.
Updated tst-raw-filter testtool to checkout the functionality.
Indeed the setting of the default filter turned out to be much clearer in the
source code of raw.c. There's no swap-back to any default if the filter was
once changed by the user-space. Just a straight behavior. Tnx Wolfgang.
hartkopp [Tue, 31 Oct 2006 10:41:21 +0000 (10:41 +0000)]
Added include <sys/socket.h> to lib.c after discussion on commit-mailing-list.
Fixed comments.
Fixed Makefile (remove all *.o files / added empty line at end of file).
hartkopp [Mon, 30 Oct 2006 13:14:36 +0000 (13:14 +0000)]
Added tiny tool cansend and a library to parse ASCII CAN frames (e.g. from
the command line) that are defined in one concatenated string.
This is a requirement for the comming command line tool 'bcmsend' that allows
to send more than one CAN frame at a time.
hartkopp [Wed, 25 Oct 2006 15:44:50 +0000 (15:44 +0000)]
Fixed compiler warning & memory leak from Urs' last change.
Reworked rx-packet counting: Only count the rx-path on performed loopback
operation (in vcan.c or af_can.c). This gives the rx-counter a usable
content ...
hartkopp [Wed, 25 Oct 2006 07:53:31 +0000 (07:53 +0000)]
Added support for interfaces that can perform the loopback inside the driver.
If so, set the IFF_LOOPBACK flag in your device.
If not, the loopback is still performed in af_can.c .
thuermann [Tue, 24 Oct 2006 13:55:43 +0000 (13:55 +0000)]
changed user space programs to use new include files.
added missing include file <net/if.h> in most programs.
added volatile modifier to "int running" in candump.c.
thuermann [Tue, 24 Oct 2006 13:49:12 +0000 (13:49 +0000)]
reorganized kernel include files:
- move code from af_can.h to can.h
- move can.h to include/linux
- rename can_error.h and can_ioctl.h to error.h and ioctl.h
- changed all include directives accordingly
user space programs now include only linux/can.h, and linux/can/{raw,bcm.h}.
Move type, proto, and capability information about CAN protocols into
struct can_proto. This simplifies can_create() significantly and allows
future CAN protocols to be loaded without the need to change af_can.c
Rename CAN_MAX to CAN_NPROTO.
Check for protocol numbers that are out of range in can_create().
Use find_dev_rcv_lists() in can_rcv() instead of scanning the list on our own.
Move comment on scanning the hlist.
alloc/free dev_rcv_lists struct in device notifier for NETDEV_(UN)REGISTER
instead of can_rx_(un)register.
WARNING: the code compiles but is untested. Test results appreciated.
cleanup in kernel 2.4 sources to prepare backporting from 2.6.
white-space change: indentation and line breaks, moved some comments.
remove false semicolons after function bodies.
rename structs and variables to improve readability.
minor bug fix: don't accidentally free a random receiver list item in
can_rx_unregister(), when no one was found because of a bug in a CAN
protocol implementation.
thuermann [Tue, 29 Aug 2006 11:49:49 +0000 (11:49 +0000)]
support calling init functions when creating a new socket.
rename raw_{init,exit} functions to raw_module_{init,exit}.
add raw_init() function to initialize the raw_opt structure
of newly created CAN_RAW sockets.
hartkopp [Tue, 29 Aug 2006 08:57:05 +0000 (08:57 +0000)]
Added discussed sockopts() for RAW-sockets to control the CAN-frames loopback
and the receiption of self created CAN-frames.
Added Kconfig option for capabilities on BCM sockets.
TODO: Set loopback as default with sock_init-function (under construction).
hartkopp [Tue, 22 Aug 2006 12:27:04 +0000 (12:27 +0000)]
added sja1000_mem due to hint of Pavel Pisa.
fixed bcm.c handling of error frames.
added CAN_RAW_USER in Kconfig
added include of linux/config.h in most files and therefore
changed some local DEBUG-defines in CONFIG_CAN_DEBUG_*
removed MODULE_PARM-macros.
Added CAN_ERR_BUSERROR and CAN_ERR_RESTARTED to can_error.h
Sorted the CAN_ERR_* defines of the error class mask.
Introduced CAN_ERR_CRTL_[RT]X_PASSIVE defines due to discussion.
Changed the procfs-directory from /proc/sys/net/can back to /proc/net/can.
Remove remnants of the projects VW history (Email addresses, Makefile targets).
Move version.h to include/linux/can.
Fix Makefiles to include raw.ko and bcm.ko in compilation and to make
vcan compile again.
Change ioctl names in SJA1000 driver to make it compile again.
Add parenthesis around assignment in vcan.c to eliminate gcc warning.
thuermann [Fri, 23 Jun 2006 07:17:39 +0000 (07:17 +0000)]
changes compile but are untested. no functional changes.
add some missing static declarations.
minor changes to improve readability, reduce indentation level,
improve performance and reduce code size.
thuermann [Fri, 9 Jun 2006 10:26:34 +0000 (10:26 +0000)]
changed indentation to 8, other white space changes.
removed a couple misplaced ';' after function bodies.
bcm.c stills needs some work to reduce line lengths.
thuermann [Fri, 12 May 2006 02:57:54 +0000 (02:57 +0000)]
Security fix:
- allow raw sockets only with CAP_NET_RAW.
- clear skbuff data before writing CAN frame to it in order to avoid passing
random bytes to user space.