Module Eth.Addr

module Addr: sig .. end
Ethernet addresses are implemented as bitstring internally but the abstract type Eth.Addr.t has a batter printer (which support such thing as vendor decoding).

Anyway, one is able to cast from/to a bitstring with (addr :> bitstring) for instance.


val print_with_vendor : bool Batteries.ref
If true, use the vendor database to decode address names:
# Eth.Addr.of_string "a4:ba:db:e6:15:fa";;
- : Eth.Addr.t = Dell:e6:15:fa
# Eth.Addr.print_with_vendor := false;;
- : unit = ()
# Eth.Addr.of_string "a4:ba:db:e6:15:fa";;
- : Eth.Addr.t = a4:ba:db:e6:15:fa

This only affect the printing of Ethernet addresses in the toplevel and Eth.Addr.to_string.

val string_of_sfx : int -> int64 -> string
val vendor_lookup : int64 -> (string * int) option
Low level wrapper around the C vendor database.
include struct ... end
val of_string : string -> t
Converts a string to an address. Note that the string must be in hexadecimal notation ("a4:ba:db:e6:15:fa", not "Dell:e6:15:fa"). So Eth.Addr.of_string (Eth.Addr.to_string "a4:ba:db:e6:15:fa") will not work if Eth.Addr.print_with_vendor is true!
val broadcast : t
Constant for Ethernet broadcast address.
val zero : t
Constant for Ethernet all zeroes address.
val eq : t -> t -> bool
Since Ethernet addresses are bitstrings, which cannot be compared using the built-in = operator, here is a dedicated comparison operator for addresses.
val random : unit -> t
Returns a random Ethernet address (but neither broadcast nor zero).