Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose universal IP adresse converters #108

Merged
merged 1 commit into from
Feb 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/ipv4.ml
Original file line number Diff line number Diff line change
Expand Up @@ -230,4 +230,9 @@ module Make(Ethif : V1_LWT.ETHIF) = struct

let get_source t ~dst:_ =
t.ip

type uipaddr = Ipaddr.t
let to_uipaddr ip = Ipaddr.V4 ip
let of_uipaddr = Ipaddr.to_v4

end
7 changes: 7 additions & 0 deletions lib/ipv6.ml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ end

module Ipv6_wire = Wire_structs.Ipv6_wire

module I = Ipaddr

(* This is temporary. See https://github.com/mirage/ocaml-ipaddr/pull/36 *)
module Ipaddr = struct
include Ipaddr.V6
Expand Down Expand Up @@ -950,4 +952,9 @@ module Make (E : V1_LWT.ETHIF) (T : V1_LWT.TIME) (C : V1.CLOCK) = struct
let state = add_prefix ~now t.state pfx in
t.state <- state;
Lwt.return_unit

type uipaddr = I.t
let to_uipaddr ip = I.V6 ip
let of_uipaddr ip = Some (I.to_v6 ip)

end
4 changes: 4 additions & 0 deletions unix/ipv4_socket.ml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ type prefix = Ipaddr.V4.t (* FIXME *)
type ethif = unit
type buffer = Cstruct.t
type callback = src:ipaddr -> dst:ipaddr -> buffer -> unit io
type uipaddr = Ipaddr.t

let to_uipaddr ip = Ipaddr.V4 ip
let of_uipaddr = Ipaddr.to_v4

let id _ = ()
let disconnect _ = return_unit
Expand Down
4 changes: 4 additions & 0 deletions unix/ipv6_socket.ml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ type ipaddr = Ipaddr.V6.t
type ethif = unit
type buffer = Cstruct.t
type callback = src:ipaddr -> dst:ipaddr -> buffer -> unit io
type uipaddr = Ipaddr.t

let to_uipaddr ip = Ipaddr.V6 ip
let of_uipaddr ip = Some (Ipaddr.to_v6 ip)

let id _ = ()
let disconnect () = return_unit
Expand Down