val opentun : ?pi:bool -> ?persist:bool -> ?user:int -> ?group:int -> ?devname:string -> unit -> Unix.file_descr * string
opentun ~pi ~persist ~user ~group ~devname () will create a TUN interface. If
devname is specified, or if
devname specify an unexistant device, a new device will be created, otherwise, the interface
devname will be opened.
no_pi is to indicate if you want packet information associated with your frames (tap) or packets (tun) (defaults to no information).
persist will set the device persistent with permissions set to
group if supported by your OS (currently MacOSX does not support it). The return value is a pair consisting of a fd opened on the freshly created interface, and its name as will be displayed by command
ifconfig for example.
val opentap : ?pi:bool -> ?persist:bool -> ?user:int -> ?group:int -> ?devname:string -> unit -> Unix.file_descr * string
opentun, but open TAP interfaces instead of TUN ones.
get_ifnamsiz () is the value of the constant IFNAMSIZ, defined in <net/if.h>. Useful for allocating buffers that contain interface names.
val get_macaddr : string -> Macaddr.t
get_hwaddr devname is the MAC address of interface
devname, as a raw string (not hexa).
set_ipv4 ~netmask dev ipaddr assigns an
ipaddr to interface
dev, with associated netmask
netmask if specified. If unspecified, the kernel will assign a default netmask automatically.
set_up_and_running devname sets interface
devname up and running. Note that when using the
set_ipv4 function, the interface will automatically be set up and running.
val getifaddrs : unit -> (string * [ `V4 of Ipaddr.V4.t * Ipaddr.V4.Prefix.t | `V6 of Ipaddr.V6.t * Ipaddr.V6.Prefix.t ]) list
getifaddrs () is the list that associates interface names with IP addresses and prefix. Only interfaces that have an IP address assigned are returned.
getifaddrs but only return interfaces that have an IPv4 assigned.
getifaddrs but only return interfaces that have an IPv6 assigned.
val addrs_of_ifname : string -> [ `V4 of Ipaddr.V4.t * Ipaddr.V4.Prefix.t | `V6 of Ipaddr.V6.t * Ipaddr.V6.Prefix.t ] list
addrs_of_ifname ifname is the list of IP addresses and their prefixes associated to interface
v4_of_ifname ifname is the list of IPv4 addresses and their prefixes associated to interface