Skip to content

Commit

Permalink
changes, and add ?fragment_cache_size to connect arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesm committed Nov 1, 2019
1 parent 5410cde commit b89cfc8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
15 changes: 15 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
### v4.0.0 (2019-11-01)

* Adapt to mirage-protocols 4.0.0, mirage-net 3.0.0, mirage-time 2.0.0,
mirage-clock 3.0.0, mirage-stack 2.0.0 interface changes (#420 @hannesm)
* Revise Static_ipv4.connect signature (for more safety):
val connect : ip:(Ipaddr.V4.Prefix.t * Ipaddr.V4.t) -> ?gateway:Ipaddr.V4.t ->
?fragment_cache_size:int -> E.t -> A.t -> t Lwt.t
it used to be:
val connect : ?ip:Ipaddr.V4.t -> ?network:Ipaddr.V4.Prefix.t ->
?gateway:Ipaddr.V4.t option -> C.t -> E.t -> A.t -> t Lwt.t
The clock `C.t` is gone (due to mirage-clock 3.0.0), `~ip` and `~network` are
now required and passed as pair `~ip`. The optional argument `?gateway` is
of type Ipaddr.V4.t. The new optional labeled argument `~fragment_cache_size`
specifies the byte size of the IPv4 fragment cache (#420 @hannesm)

### v3.7.9 (2019-10-15)

* Add ?ttl:int parameter to Udp and Icmp write (#416 @phaer)
Expand Down
5 changes: 3 additions & 2 deletions src/ipv4/static_ipv4.ml
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,12 @@ module Make (R: Mirage_random.S) (C: Mirage_clock.MCLOCK) (Ethernet: Mirage_prot
| Some `UDP -> udp ~src ~dst payload
| Some `ICMP | None -> default ~proto:packet.proto ~src ~dst payload

let connect ~ip:(network, ip) ?gateway ethif arp =
let connect
~ip:(network, ip) ?gateway ?(fragment_cache_size = 1024 * 256) ethif arp =
Arpv4.set_ips arp [ip] >>= fun () ->
(* TODO currently hardcoded to 256KB, should be configurable
and maybe limited per-src/dst-ip as well? *)
let cache = Fragments.Cache.create ~random:true (1024 * 256) in
let cache = Fragments.Cache.create ~random:true fragment_cache_size in
Lwt.return { ethif; arp; ip; network; gateway ; cache }

let disconnect _ = Lwt.return_unit
Expand Down
7 changes: 5 additions & 2 deletions src/ipv4/static_ipv4.mli
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ module Make (R: Mirage_random.S) (C: Mirage_clock.MCLOCK) (E: Mirage_protocols.E
include Mirage_protocols.IP with type ipaddr = Ipaddr.V4.t

val connect : ip:(Ipaddr.V4.Prefix.t * Ipaddr.V4.t) -> ?gateway:Ipaddr.V4.t ->
E.t -> A.t -> t Lwt.t
(** Connect to an ipv4 device. *)
?fragment_cache_size:int -> E.t -> A.t -> t Lwt.t
(** [connect ~ip ~gateway ~fragment_cache_size eth arp] connects the ipv4
device using [ip] and [gateway] for network communication. The size of
the IPv4 fragment cache (for reassembly) can be provided in byte-size of
fragments (defaults to 256kB). *)
end

0 comments on commit b89cfc8

Please sign in to comment.