Skip to main content

Crate raw_ether

Crate raw_ether 

Source
Expand description

Raw Ethernet on Linux, macOS and Windows: MAC addresses, the computer’s interfaces, frames of one ethertype, frames with the times the hardware stamped on them, PTP hardware clocks, and capturing whole frames. It moves frames and reads clocks, and parses no payload: gPTP, MRP and AVTP are other crates’ business.

Without the std feature only the address types remain, so protocol crates built on them also run on microcontrollers.

Re-exports§

pub use interfaces::Interface;
pub use interfaces::LinkPower;
pub use interfaces::interfaces;
pub use socket::Blocked;
pub use socket::Received;
pub use socket::Socket;
pub use socket::check_access;

Modules§

broker
Raw sockets from a helper, so the program using them holds no capability. On Linux a raw Ethernet socket takes CAP_NET_RAW only to be created; once open it works for whoever holds it. A program holding the capability itself runs as one other programs may not look into: the desktop portals refuse it file dialogs and screen sharing, and debuggers and crash reports pass it by. So an app ships a tiny helper of its own, the one file granted the capability, whose main calls serve; the app starts it with Broker::start and installs it, and every raw socket this crate opens comes from it from then on.
capture
Whole frames crossing an interface, both ways, for capturing: those of chosen ethertypes the interface receives and sends, a bridge port’s forwarded frames among them, each with the time the kernel saw it and its VLAN tag put back where the kernel had taken it off. The filter runs in the kernel, so frames of other ethertypes cost the program nothing, and the kernel hands frames over in blocks of a ring shared with the program, so a busy capture wakes it a few times a second rather than once a frame. Linux only so far; elsewhere opening fails as unsupported.
clock
A network interface’s PTP hardware clock, which gPTP keeps on the network’s time, read from Linux’s /dev/ptpN, and two such clocks compared. Elsewhere opening fails as unsupported.
interfaces
The Ethernet interfaces of this computer and what each can do.
socket
Raw Ethernet frames of one ethertype on one interface.
stamped
Frames of one ethertype sent and received with the times the interface’s hardware put on them, as gPTP needs: when each received frame crossed the wire in, and when each sent one went out, by the interface’s PTP hardware clock. The kernel adds and removes the Ethernet header, as for a crate::socket::Socket.

Structs§

MacAddress
ParseError