Teensy 4.1 - Raw ethernet frames parsing/access

Hello everyone,

I am using Teensy 4.1 development board with the native ethernet chip and an external Wiznet W5500 ethernet chip.

As the W5500 chip is concerned, I figured out that the ioLibrary allows me to access RAW ethernet frames so that I can add a security protocol like IPSec on a specific incoming packet.

The problem is that I haven't find yet a library for the native ethernet chip which to allow the same thing. I looked after QNEthernet but the documentation specificallt mentions this:
"There is support for sending and receiving raw Ethernet frames. See the EthernetFrame API, above.
This API doesn't receive any known Ethernet frame types. These include:
  1. IPv4 (0x0800)
  2. ARP (0x0806)
  3. IPv6 (0x86DD) (if enabled)"
Is anyone who has done this before? Or has a solution in mind? I mention that it is not mandatory for me to add that IPSec protocol, the use case may be for packet sniffing etc. everything which needs to have access to the raw ethernet frames in order to modify/reconstruct etc. (eventually permitting ARP requests / PINGs)

Thank you!
 
Try setting LWIP_IPV4 to 0 in lwipopts.h.

The relevant code that determines what gets sent to LWIP_HOOK_UNKNOWN_ETH_PROTOCOL (ending up in unknown_eth_protocol() in EthernetFrameClass) is in src/netif/ethernet.c:
C:
  switch (type) {
#if LWIP_IPV4 && LWIP_ARP

This will disable the IP portion of the stack and allow you to access all raw frames.
 
Last edited:
So you suggest to try setting LWIP_IPV4 to 0, and then keep only #if LWIP_ARP in src/netif/ethernet.c?

Sorry for being late with the response, somehow I was not notified…
 
access to the raw ethernet frames in order to modify/reconstruct etc. (eventually permitting ARP requests / PINGs)

QNEthernet is the most well tested code.

But if you want the simplest direct packet access, this code just listens for ARP and PING requests and sends replies. Not sure if this is what you really want, but it seems to match up to your question. If you create something new (different from NativeEthernet and QNEthernet) that does communication more useful than only ping, I hope you'll consider sharing?
 
Thank you for your response!
But if you want the simplest direct packet access, this code just listens for ARP and PING requests and sends replies. Not sure if this is what you really want, but it seems to match up to your question.
Well, I looked on the code you provided and it seems to be helpful. I do not develop a new library for ethernet communication, I just look for a method to receive frames and to modify them, but preserving ARP and PING requests working. It is for a university project, where I want to receive ethernet frames and construct IPSec on top of it.

This is the main reason I want full access to the frame, but also keeping ARP and PING up.
 
Back
Top