linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Wolfgang <wutz@unterderbruecke.de>
Cc: linux-can@vger.kernel.org
Subject: bridging with can-gw - was Re: recv list
Date: Thu, 12 Jan 2012 19:08:21 +0100	[thread overview]
Message-ID: <4F0F2195.7050109@hartkopp.net> (raw)
In-Reply-To: <loom.20120112T155904-850@post.gmane.org>

On 12.01.2012 16:23, Wolfgang wrote:

> is it possible when I create a promiscuous socket with 
> ...
> 
> static struct {
> 	struct sockaddr_can src;
> 	int pkt_len;
> } ss = {
> 	.pkt_len = 1024,
> 	.src.can_addr.j1939 = {
> 		.name = J1939_NO_NAME,
> 		.addr = J1939_NO_ADDR,
> 		.pgn = J1939_NO_PGN,
> 	},
> };
> ....
> addr.can_ifindex = ss.src.can_ifindex;
> ...
> 
> and then receive a msg with recvfrom and  send that msg with sendto to tell 
> the promiscuous socket to ignore the send msg. That the promiscuous socket only
> receives 'extern' messages. I am totally floored, or am I on the wrong track?


Hello Wolfgang,

as you are always writing about the bridging of J1939 frames - what does this
mean on the bus?

Do you only bridge single frames?

If so the kernel based CAN gateway (can-gw) may be something to fit to your
requirements. See:

http://old.nabble.com/netlink-based-CAN-gateway-kernel-module-td27707326.html

The can-gw is in the SocketCAN repos and part of the recently released 
kernel 3.2.

It's performance has been talked about in the 13th Real Time Linux Workshop in
Prague: https://lwn.net/images/conf/rtlws-2011/

PDF is here: https://lwn.net/images/conf/rtlws-2011/paper.22.html

The cangw tool improved since the original posting, see below.

Regards,
Oliver

---8<--- 

Usage: cangw [options]

Commands:  -A (add a new rule)
           -D (delete a rule)
           -F (flush / delete all rules)
           -L (list all rules)
Mandatory: -s <src_dev>  (source netdevice)
           -d <dst_dev>  (destination netdevice)
Options:   -t (preserve src_dev rx timestamp)
           -e (echo sent frames - recommended on vcanx)
           -f <filter> (set CAN filter)
           -m <mod> (set frame modifications)
           -x <from_idx>:<to_idx>:<result_idx>:<init_xor_val> (XOR checksum)
           -c <from>:<to>:<result>:<init_val>:<xor_val>:<crctab[256]> (CRC8 cs)
           -p <profile>:[<profile_data>] (CRC8 checksum profile & parameters)

Values are given and expected in hexadecimal values. Leading 0s can be omitted.

<filter> is a <value><mask> CAN identifier filter
   <can_id>:<can_mask> (matches when <received_can_id> & mask == can_id & mask)
   <can_id>~<can_mask> (matches when <received_can_id> & mask != can_id & mask)

<mod> is a CAN frame modification instruction consisting of
<instruction>:<can_frame-elements>:<can_id>.<can_dlc>.<can_data>
 - <instruction> is one of 'AND' 'OR' 'XOR' 'SET'
 - <can_frame-elements> is _one_ or _more_ of 'I'dentifier 'L'ength 'D'ata
 - <can_id> is an u32 value containing the CAN Identifier
 - <can_dlc> is an u8 value containing the data length code (0 .. 8)
 - <can_data> is always eight(!) u8 values containing the CAN frames data
The max. four modifications are performed in the order AND -> OR -> XOR -> SET

Example:
cangw -A -s can0 -d vcan3 -e -f 123:C00007FF -m SET:IL:333.4.1122334455667788

Supported CRC 8 profiles:
Profile '1' (1U8)       - add one additional u8 value
Profile '2' (16U8)      - add u8 value from table[16] indexed by (data[1] & 0xF)
Profile '3' (SFFID_XOR) - add u8 value (can_id & 0xFF) ^ (can_id >> 8 & 0xFF)


  parent reply	other threads:[~2012-01-12 18:08 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-09 13:26 recv list Kurt Van Dijck
2012-01-09 16:35 ` Wolfgang
2012-01-10  8:51   ` Kurt Van Dijck
2012-01-10 10:45     ` Wolfgang
2012-01-10 15:23       ` Kurt Van Dijck
2012-01-11 16:06         ` promiscuous mode Wolfgang
2012-01-12 15:37           ` bridge Kurt Van Dijck
2012-01-12 15:23         ` recv list Wolfgang
2012-01-12 15:43           ` Kurt Van Dijck
2012-01-12 18:08           ` Oliver Hartkopp [this message]
2012-01-13 11:12             ` bridging with can-gw Kurt Van Dijck
2012-01-13 11:31               ` Wolfgang
2012-01-16 10:04                 ` MSG_DONTROUTE Wolfgang
2012-01-16 13:31                   ` MSG_DONTROUTE Kurt Van Dijck
2012-01-16 15:28                     ` sendmsg Wolfgang
2012-01-16 15:36                       ` sendmsg Kurt Van Dijck
2012-02-07 14:21                         ` max dlc Wolfgang
2012-02-07 15:11                         ` sendmsg Wolfgang
2012-02-08  8:46                           ` sendmsg Kurt Van Dijck
2012-02-16  9:58                             ` How to get the DA Wolfgang Wagner
2012-02-16 19:49                               ` Kurt Van Dijck
2012-02-24 15:23                                 ` Transport Protocol Wolfgang Wagner
2012-02-27 14:05                                   ` Kurt Van Dijck
2012-02-28 10:46                                   ` Transport Protocol: example Kurt Van Dijck
2012-02-28 15:21                                     ` Wolfgang Wagner
2012-02-28 16:26                                       ` Kurt Van Dijck

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4F0F2195.7050109@hartkopp.net \
    --to=socketcan@hartkopp.net \
    --cc=linux-can@vger.kernel.org \
    --cc=wutz@unterderbruecke.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).