Skip to main content

Module ethernet

Module ethernet 

Source
Expand description

Ethernet frame parsing, construction, and ARP handling.

Provides minimal L2 utilities for the custom network datapath:

  • Ethernet header parse/construct
  • ARP responder (gateway only)
  • UDP/IP/Ethernet packet builder for DHCP and DNS responses

Structs§

ArpResponder
Responds to ARP requests targeting the gateway IP.
EthernetHeader
Parsed Ethernet header fields.
SynAckParams
Parameters for constructing a TCP SYN-ACK frame.
SynParams
Parameters for constructing a TCP SYN frame (active open).
TcpFrameParams
Parameters for constructing TCP frames on the fast path.
TcpSynOptions
Peer TCP options observed on an incoming SYN or SYN-ACK frame.

Enums§

EtherType
EtherType values.

Constants§

ETH_HEADER_LEN
Ethernet header size in bytes.
MAX_UDP_PAYLOAD
Largest UDP payload an IPv4 datagram can carry: the 16-bit IP total-length field (65535) minus the IPv4 header (20) and the UDP header (8).

Functions§

build_tcp_ack_frame
Builds a TCP ACK frame (no payload) to acknowledge data from the guest.
build_tcp_data_frame
Builds a TCP data frame carrying payload from the host to the guest.
build_tcp_data_frame_partial_csum
Builds a TCP data frame with only a pseudo-header checksum (for GSO).
build_tcp_fin_frame
Builds a TCP FIN+ACK frame for connection teardown.
build_tcp_rst_frame
Builds a TCP RST frame for connection abort.
build_tcp_syn_ack_frame
Builds a TCP SYN-ACK frame that accepts a guest SYN.
build_tcp_syn_frame
Builds a TCP SYN frame for active open toward the guest.
build_udp_ip_ethernet
Builds a guest-bound UDP/IPv4 datagram as one or more Ethernet frames.
ipv4_header_checksum
Computes the IPv4 header checksum (RFC 1071).
parse_tcp_syn_options
Parses the TCP options field of a SYN (or SYN-ACK) segment.
prepend_ethernet_header
Prepends a 14-byte Ethernet header (IPv4 EtherType) to an IP packet.
strip_ethernet_header
Returns the payload slice after the 14-byte Ethernet header.
tcp_checksum
Computes the TCP checksum over the pseudo-header + TCP segment.
tcp_pseudo_header_checksum
Computes the TCP pseudo-header checksum only (for GSO offload).