diff options
author | Guy Harris <gharris@sonic.net> | 2021-10-20 00:55:00 -0700 |
---|---|---|
committer | Guy Harris <gharris@sonic.net> | 2021-10-20 00:55:00 -0700 |
commit | 95ab535a720079c92295213981e5495d8865d981 (patch) | |
tree | b3c271aac88b5829df98d5721547572e05de6e18 | |
parent | e9eaad85f3888c72f79de705fae7e0768d8a622d (diff) |
Revert "linux: clean up the SocketCAN header for classic CAN frames."
This reverts commit e9eaad85f3888c72f79de705fae7e0768d8a622d.
We only need to do this for CAN FD frames; readers of the frames can use
thse heuristics to determine whether to trust the len8_dlc field without
our help.
-rw-r--r-- | pcap-linux.c | 39 | ||||
-rw-r--r-- | pcap/can_socketcan.h | 6 |
2 files changed, 12 insertions, 33 deletions
diff --git a/pcap-linux.c b/pcap-linux.c index 52decc31..e931f84f 100644 --- a/pcap-linux.c +++ b/pcap-linux.c @@ -3936,41 +3936,20 @@ static int pcap_handle_packet_mmap( * does happen.) * * Update this if Linux adds more flag - * bits to the fd_flags field, uses the - * len8_dlc field for CAN FD frames, or - * uses the reserved frame for CAN FD - * frames. + * bits to the fd_flags field or uses + * either of the reserved fields for + * FD frames. */ canhdr->fd_flags &= ~(CANFD_FDF|CANFD_ESI|CANFD_BRS); - canhdr->len8_dlc = 0; - canhdr->reserved = 0; + canhdr->reserved1 = 0; + canhdr->reserved2 = 0; } else { /* - * The FD flags field is CAN FD-only, - * so it should be zero. - * - * If it's not zero, or the reserved - * field is not zero, or the len8_dlc - * field does not have a value between - * 8 and 15, assume the header was not - * initialized past the payload_length - * field, and zero out the len8_dlc field. - * - * Then zero out the fd_flags and reserved - * fields. - * - * Update this if Linux uses the fd_flags - * field or the reserved field, or puts - * values not between 8 and 15 in the - * len8_dlc field, for classic CAN frames. + * Clear CANFD_FDF if it's set (probably + * again meaning that that field is + * uninitialized junk). */ - if (canhdr->fd_flags != 0 || - canhdr->reserved != 0 || - (canhdr->len8_dlc < 8 || - canhdr->len8_dlc > 15)) - canhdr->len8_dlc = 0; - canhdr->fd_flags = 0; - canhdr->reserved = 0; + canhdr->fd_flags &= ~CANFD_FDF; } } } diff --git a/pcap/can_socketcan.h b/pcap/can_socketcan.h index dfe58591..0cb3584a 100644 --- a/pcap/can_socketcan.h +++ b/pcap/can_socketcan.h @@ -48,9 +48,9 @@ typedef struct { uint32_t can_id; uint8_t payload_length; - uint8_t fd_flags; /* not used for classic CAN; flags for CAN FD */ - uint8_t len8_dlc; /* Data Length Code for classic CAN; not used for CAN FD */ - uint8_t reserved; + uint8_t fd_flags; + uint8_t reserved1; + uint8_t reserved2; } pcap_can_socketcan_hdr; /* Bits in the fd_flags field */ |