package mirage-dns
Library
Module
Module type
Parameter
Class
Class type
include Mirage_protocols.IP
with type +'a io = 'a io
with type ipaddr = ipv4addr
with type buffer = buffer
with type t = ipv4
The type for IP errors.
type buffer = buffer
The type for memory buffers.
type ipaddr = ipv4addr
The type for IP addresses.
An input continuation used by the parsing functions to pass on an input packet down the stack.
callback ~src ~dst buf
will be called with src
and dst
containing the source and destination IP address respectively, and buf
will be a buffer pointing at the start of the IP payload.
val input :
t ->
tcp:callback ->
udp:callback ->
default:(proto:int -> callback) ->
buffer ->
unit io
input ~tcp ~udp ~default ip buf
demultiplexes an incoming buffer
that contains an IP frame. It examines the protocol header and passes the result onto either the tcp
or udp
function, or the default
function for unknown IP protocols.
allocate_frame t ~dst ~proto
returns a pair (pkt, len)
such that Cstruct.sub pkt 0 len
is the IP header (including the link layer part) of a packet going to dst
for protocol proto
. The space in pkt
after the first len
bytes can be used by the client.
write t frame buf
writes the packet frame :: buf :: []
to the address dst
.
writev t frame bufs
writes the packet frame :: bufs
.
checksum frame bufs
computes the IP checksum of bufs
computing the pseudo-header from the actual header frame
. It assumes that frame is of the form returned by allocate_frame
, i.e., that it contains the link-layer part.
pseudoheader t dst proto len
gives a pseudoheader suitable for use in TCP or UDP checksum calculation based on t
.
src ip ~dst
is the source address to be used to send a packet to dst
. In the case of IPv4, this will always return the same IP, which is the only one set.
Set the IP address associated with this interface. For IPv4, currently only supports a single IPv4 address, and aliases will be added in a future revision.
Get the IP addresses associated with this interface. For IPv4, only * one IP address can be set at a time, so the list will always be of * length 1 (and may be the default value, 0.0.0.0).
Convert an IP address with a specific version (eg. V4) into a universal IP address.
Project a universal IP address into the version supported by the current implementation. Return None
if there is a version mismatch.
val mtu : t -> int
mtu ip
is the Maximum Transmission Unit of the ip
i.e. the maximum size of the payload, not including the IP header.