l2ethernet 0.3.0 copy "l2ethernet: ^0.3.0" to clipboard
l2ethernet: ^0.3.0 copied to clipboard

PlatformLinux
outdated

Sending raw Ethernet frames in Dart via FFI. Usable for generating WOL packets or non-standard protocols running on Ethernet. Sending only. Linux only.

package:l2ethernet #

Sending raw Ethernet frames in Dart

What is this? #

This is a small Dart package to make it possible to send raw Ethernet frames out. My use-case was to send data to a Colorlight 5A receiver card which expect Ethernet frames and I found no way to do that with Dart. The miss-leadingly named RawSocket class used TCP.

Thus this package was born: via FFI it uses the Linux socket() interface to send out raw Ethernet frames. Can be used to send arbitrary Ethernet packets. WOL packets, ARP spoofing, custom protocols come into mind.

Testing #

Tests contain two parts: one which can be run as non-root and one which requires root (or similar permissions) as it actually opens a raw socket. I do run tcpdump in the background to capture the sent Ethernet packet and verify it's what I expect it to be.

Compiling the shared library #

This is actually simple as the C layer is very short. I added a buildme.sh script. It's that simple.

macOS, Windows, Android, iOS #

Sorry, no support from my side for those.

Limitations #

  • Receiving frames is not currently implemented.
  • This is nor performance optimized: A single frame is sent out synchronously. If performance is required, sendmmsg() should be used.
  • Only Linux supported and the shared library is only available for x86_64 and aarch64. It's very simple to compile the library though (see buildme.sh).
1
likes
110
pub points
31%
popularity

Publisher

unverified uploader

Sending raw Ethernet frames in Dart via FFI. Usable for generating WOL packets or non-standard protocols running on Ethernet. Sending only. Linux only.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

ffi, path

More

Packages that depend on l2ethernet