CANGW(1)

๐Ÿ“ฆ
version 2023.03 ยท 3 versions
, in ubuntu resolute, ubuntu stonking

โœจ NAME โœจ

hiii bestie, meet cangw ๐Ÿ’– โ€” she's the manual page for cangw 2023.03-1build1, living her best life in the CANGW(1) section of the User Commands chapter. her whole thing? managing the PF_CAN netlink gateway. that's it, that's the girl. ๐Ÿฆ‹


๐ŸŒธ SYNOPSIS ๐ŸŒธ

cangw [options]

๐ŸŽ€ DESCRIPTION ๐ŸŽ€

okay so cangw โ€” she manages the PF_CAN netlink gateway. iconic behaviour, no notes. ๐Ÿ’…

๐Ÿ‘‘ Commands ๐Ÿ‘‘

these are the four things she Actually Does. pick one, bestie:

  • -A โ€” add a new rule โœจ
  • -D โ€” delete a rule ๐Ÿ™ˆ
  • -F โ€” flush / delete all rules ๐Ÿ’€
  • -L โ€” list all rules ๐Ÿ“‹

๐Ÿซถ Mandatory ๐Ÿซถ

these are not optional, like fr fr, you literally cannot skip these:

  • -s <src_dev> โ€” the source netdevice ๐ŸŽ€
  • -d <dst_dev> โ€” the destination netdevice ๐Ÿฆ‹

๐Ÿ’– OPTIONS ๐Ÿ’–

  • -X โ€” this is a CAN FD rule ๐Ÿš—โœจ
  • -t โ€” preserve the src_dev rx timestamp โฐ
  • -e โ€” echo sent frames โ€” lowkey recommended on vcanx ๐Ÿ—ฃ๏ธ
  • -i โ€” allow it to route to the incoming interface ๐Ÿ”
  • -u <uid> โ€” a user defined modification identifier ๐Ÿท๏ธ
  • -l <hops> โ€” limit the number of frame hops / routings ๐Ÿ‡
  • -f <filter> โ€” set the CAN filter ๐Ÿ”
  • -m <mod> โ€” set Classical CAN frame modifications ๐Ÿ› ๏ธ
  • -M <MOD> โ€” set CAN FD 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, she doesn't care. ๐Ÿ’…

๐ŸŽ€ <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 Classical CAN frame modification instruction, and it's built like this:

<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 in hex (0 .. F)
  • <can_data> โ€” is always eight(!) u8 values containing the CAN frames data ๐Ÿ‘€

๐Ÿš— <MOD> is a CAN FD frame modification instruction, and she's built like this:

<instruction>:<canfd_frame-elements>:<can_id>.<flags>.<len>.<can_data>
  • <instruction> โ€” is one of 'AND' 'OR' 'XOR' 'SET'
  • <canfd_frame-elements> โ€” is _one_ or _more_ of 'I'd 'F'lags 'L'ength 'D'ata
  • <can_id> โ€” is an u32 value containing the CAN FD Identifier
  • <flags> โ€” is an u8 value containing CAN FD flags (CANFD_BRS, CANFD_ESI)
  • <len> โ€” is an u8 value containing the data length in hex (0 .. 40)
  • <can_data> โ€” is always 64(!) u8 values containing the CAN FD frames data ๐Ÿคฏ
the max. four modifications are performed in the order AND -> OR -> XOR -> SET. that's the pipeline bestie, don't fight it. ๐Ÿ”ฅ

๐Ÿงš 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) ๐ŸŒˆ

๐Ÿ”ฅ EXAMPLES ๐Ÿ”ฅ

the moment you've all been waiting for, the demonstration, the main character moment:

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

and that's the whole page bestie!! ๐Ÿซถ this was cangw 2023.03-1build1, brought to you in December 2025, straight out of the CANGW(1) manual. go route some frames, you absolute icon. ๐Ÿ’…โœจ๐ŸŽ€๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from