package mirage-types

  1. Overview
  2. Docs

An Ethernet stack that parses frames from a network device and can associate them with IP address via ARP.

type buffer

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

type netif

Abstract type for an Ethernet network interface.

type ipv4addr

Abstract type for an IPv4 address representation.

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 and type id := netif
type +'a io

A potentially blocking I/O operation

type t

The type representing the internal state of the device

val id : t -> netif

Return the identifier that was used to construct this device

val connect : netif -> [ `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 mac : t -> macaddr

mac nf is the MAC address of nf.

val input : ipv4:(buffer -> unit io) -> ipv6:(buffer -> unit io) -> t -> buffer -> 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 query_arpv4 : t -> ipv4addr -> macaddr io

Query the association from an IPV4 address to a MAC address. TODO: clarify if this task is guaranteed to be cancelable or not.

val add_ipv4 : t -> ipv4addr -> unit io

Bind an IPv4 address to this interface, to be used when replying to ARPv4 requests.

OCaml

Innovation. Community. Security.