package mirage-types

  1. Overview
  2. Docs

A network interface that serves Ethernet frames.

type page_aligned_buffer

Abstract type for a page-aligned memory buffer

type buffer

Abstract type for a memory buffer that may not be page aligned

type error = [
  1. | `Unknown of string
    (*

    an undiagnosed error

    *)
  2. | `Unimplemented
    (*

    operation not yet implemented in the code

    *)
  3. | `Disconnected
    (*

    the device has been previously disconnected

    *)
]

IO operation errors

type macaddr

Unique MAC identifier for the device

include DEVICE with type error := error
type +'a io

A potentially blocking I/O operation

type t

The type representing the internal state of the device

type id

Type defining an identifier for this device that uniquely identifies it among a device tree.

val id : t -> id

Return the identifier that was used to construct this device

val connect : id -> [ `Error of error | `Ok of t ] io

Connect to the device identified by id

val disconnect : t -> unit io

Disconnect from the device. While this might take some time to complete, it can never result in an error.

val write : t -> buffer -> unit io

write nf buf outputs buf to netfront nf.

val writev : t -> buffer list -> unit io

writev nf bufs output a list of buffers to netfront nf as a single packet.

val listen : t -> (buffer -> unit io) -> unit io

listen nf fn is a blocking operation that calls fn buf with every packet that is read from the interface. It returns as soon as it has initialised, and the function can be stopped by calling disconnect in the device layer.

val mac : t -> macaddr

mac nf is the MAC address of nf.

type stats = {
  1. mutable rx_bytes : int64;
  2. mutable rx_pkts : int32;
  3. mutable tx_bytes : int64;
  4. mutable tx_pkts : int32;
}

Frame statistics to track the usage of the device.

val get_stats_counters : t -> stats

Obtain the most recent snapshot of the device statistics.

val reset_stats_counters : t -> unit

Reset the statistics associated with this device to their defaults.

OCaml

Innovation. Community. Security.