package mirage-net-unix

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
include V1.NETWORK with type 'a io = 'a Lwt.t and type page_aligned_buffer = Io_page.t and type buffer = Cstruct.t and type id = string and type macaddr = Macaddr.t
type page_aligned_buffer = Io_page.t

Abstract type for a page-aligned memory buffer

type buffer = Cstruct.t

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 = Macaddr.t

Unique MAC identifier for the device

include V1.DEVICE with type error := error with type 'a io = 'a Lwt.t with type id = string
type 'a io = 'a Lwt.t

A potentially blocking I/O operation

type t

The type representing the internal state of the device

type id = string

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.