package ipaddr

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type

A library for manipulation of MAC address representations.

2.7.2 - homepage

exception Parse_error of string * string

Raised when parsing of MAC address syntax fails.

include sig ... end
type t

Type of the hardware address (MAC) of an ethernet interface.

include sig ... end
val t_of_sexp : Sexplib.Sexp.t -> t
val sexp_of_t : t -> Sexplib.Sexp.t

Functions converting MAC addresses to bytes/string and vice versa.

val of_bytes_exn : string -> t

of_bytes_exn buf is the hardware address extracted from buf. Raises Parse_error if buf has not length 6.

val of_bytes : string -> t option

Same as above but returns an option type instead of raising an exception.

val of_string_exn : string -> t

of_string_exn mac_string is the hardware address represented by mac_string. Raises Parse_error if mac_string is not a valid representation of a MAC address.

val of_string : string -> t option

Same as above but returns an option type instead of raising an exception.

val to_bytes : t -> string

to_bytes mac_addr is a string of size 6 encoding mac_addr.

val to_string : ?sep:char -> t -> string

to_string ?(sep=':') mac_addr is the sep-separated string representation of mac_addr, i.e. xx:xx:xx:xx:xx:xx.

val broadcast : t

broadcast is ff:ff:ff:ff:ff:ff.

val make_local : (int -> int) -> t

make_local bytegen creates a unicast, locally administered MAC address given a function mapping octet offset to octet value.

val get_oui : t -> int

get_oui macaddr is the integer organization identifier for macaddr.

val is_local : t -> bool

is_local macaddr is the predicate on the locally administered bit of macaddr.

val is_unicast : t -> bool

is_unicast macaddr the is the predicate on the unicast bit of macaddr.

include Map.OrderedType with type t := t
val compare : t -> t -> int
OCaml

Innovation. Community. Security.