package ethernet

  1. Overview
  2. Docs
Module type
Class type
type proto = [
  1. | `ARP
  2. | `IPv4
  3. | `IPv6

Ethernet protocols.

val pp_proto : proto Fmt.t

pp_proto ppf proto pretty-prints the ethernet protocol proto on ppf.

type t = {
  1. source : Macaddr.t;
  2. destination : Macaddr.t;
  3. ethertype : proto;

The type of an Ethernet packet.

val sizeof_ethernet : int

sizeof_ethernet is the byte size of the ethernet header.

val of_cstruct : Cstruct.t -> (t * Cstruct.t, string) Stdlib.result

of_cstruct buffer attempts to decode the buffer as ethernet packet. It may result an error if the buffer is too small, or the protocol is not supported.

val into_cstruct : t -> Cstruct.t -> (unit, string) Stdlib.result

into_cstruct t cs attempts to encode the ethernet packet t into the buffer cs (at offset 0). This may fail if the buffer is not big enough.

val make_cstruct : t -> Cstruct.t

make_cstruct t encodes the ethernet packet t into a freshly allocated buffer.