Skip to main content

Module ethernet

Module ethernet 

Source
Expand description

Ethernet → VLAN → IP → UDP/TCP frame dissection.

This module walks a raw captured Ethernet frame down through optional VLAN tags, the IPv4 header, and finally UDP or TCP, handing back the transport-layer payload for protocol-specific parsers to consume.

Structs§

IpHeader
TcpSegment
A dissected TCP segment: ports plus payload past the header/options.

Constants§

ETHERTYPE_8021AD
802.1ad “Q-in-Q” outer service tag. Frames carrying this ethertype have a second, inner 802.1Q tag before the real payload ethertype.
ETHERTYPE_8021Q
802.1Q VLAN tag (single tag).
ETHERTYPE_IP
PROTO_TCP
PROTO_UDP

Functions§

extract_ip
Extracts the IPv4 header and payload from a raw Ethernet frame, transparently handling untagged, 802.1Q, and 802.1ad Q-in-Q framing.
extract_tcp
Extracts ports and payload from an IP payload whose protocol is PROTO_TCP, accounting for the variable-length TCP header (data offset field) so that TCP options don’t leak into payload.
extract_udp
Extracts (src_port, dst_port, udp_payload) from an IP payload whose protocol is PROTO_UDP.
strip_ethernet
Strips the Ethernet header (and any VLAN tags) from a raw frame, returning the IPv4 payload.