tcpip

OCaml TCP/IP networking stack, used in MirageOS
Library tcpip_ipv4
Module Fragments
module V : sig ... end
module K : sig ... end
module Cache : sig ... end
val max_duration : int64

max_duration is the maximum delta between first and last received fragment, in nanoseconds. At the moment it is 10 seconds.

val process : Cache.t -> int64 -> Ipv4_packet.t -> Cstruct.t -> Cache.t * (Ipv4_packet.t * Cstruct.t) option

process t timestamp hdr payload is t', a new cache, and maybe a fully reassembled IPv4 packet. If reassembly fails, e.g. too many fragments, delta between receive timestamp of first and last packet exceeds max_duration, overlapping packets, these packets will be dropped from the cache. The IPv4 header options are always taken from the first fragment (where offset is 0). If the provided IPv4 header has an fragmentation offset of 0, and the more fragments bit is not set, the given header and payload is directly returned. Handles out-of-order fragments gracefully.

val fragment : mtu:int -> Ipv4_packet.t -> Cstruct.t -> Cstruct.t list

fragment ~mtu hdr payload is called with the IPv4 header of the first fragment and the remaining payload (which did not fit into the first fragment). The data_length = ((mtu - header_length hdr) / 8) * 8 is used for each fragment (and it is assumed that the first fragment contains exactly that much data). The number of packets returned is len payload / data_len. If data_len <= 0, the empty list is returned.