Skip to content

Commit

Permalink
The socket version is just a skeleton that fails if most functions
Browse files Browse the repository at this point in the history
are used.  These can eventually be filled in with the UNIX
equivalents, but I'm deferring this work as it's hard to get it
done quickly and portably, and noone needs this functionality
in the socket backend at present.
  • Loading branch information
avsm committed Apr 1, 2014
1 parent 35af1d2 commit e506918
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions unix/ipv4_socket.ml
@@ -0,0 +1,43 @@
(*
* Copyright (c) 2014 Anil Madhavapeddy <anil@recoil.org>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*)

open Lwt

type id = string
type ipv4 = unit
type t = unit
type +'a io = 'a Lwt.t
type error = [ `Unimplemented | `Unknown of string ]
type ipv4addr = Ipaddr.V4.t
type ethif = unit
type buffer = Cstruct.t
type callback = src:ipv4addr -> dst:ipv4addr -> buffer -> unit io

let id _ = ()
let disconnect () = return ()
let connect () = return (`Ok ())

let input ~tcp ~udp ~default _ _ = return ()
let allocate_frame ~proto ~dest_ip t = fail (Failure "Not implemented")
let write _ _ _ = fail (Failure "Not implemented")
let writev _ _ _ = fail (Failure "Not implemented")

let get_ipv4 _ = Ipaddr.V4.of_string_exn "0.0.0.0"
let set_ipv4 _ _ = fail (Failure "Not implemented")
let get_ipv4_netmask _ = Ipaddr.V4.of_string_exn "255.255.255.0"
let get_ipv4_gateways _ = raise (Failure "Not implemented")
let set_ipv4_netmask _ _ = fail (Failure "Not implemented")
let set_ipv4_gateways _ _ = fail (Failure "Not implemented")

0 comments on commit e506918

Please sign in to comment.