package ipaddr

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

A module for manipulating IPv4 network prefixes.

type addr = t
val sexp_of_addr : addr -> Ppx_sexp_conv_lib.Sexp.t
val addr_of_sexp : Ppx_sexp_conv_lib.Sexp.t -> addr
type t

Type of a internet protocol subnet

include Ppx_sexp_conv_lib.Sexpable.S with type t := t
val t_of_sexp : Sexplib0.Sexp.t -> t
val sexp_of_t : t -> Sexplib0.Sexp.t
val mask : int -> addr

mask n is the pseudo-address of an n bit subnet mask.

val make : int -> addr -> t

make n addr is the n bit subnet prefix to which addr belongs.

val network_address : t -> addr -> addr

network_address prefix addr is the address with prefix prefix and suffix from addr. See <http://tools.ietf.org/html/rfc4291#section-2.3>.

val of_string_exn : string -> t

of_string_exn cidr is the subnet prefix represented by the CIDR string, cidr. Raises Parse_error if cidr is not a valid representation of a CIDR notation routing prefix.

val of_string : string -> t option

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

val of_string_raw : string -> int Pervasives.ref -> t

Same as of_string_exn but takes as an extra argument the offset into the string for reading.

val to_string : t -> string

to_string prefix is the CIDR notation string representation of prefix, i.e. XXX.XX.X.XXX/XX.

val pp : Format.formatter -> t -> unit

pp f prefix outputs a human-readable representation of prefix to the formatter f.

val pp_hum : Format.formatter -> t -> unit

pp_hum f prefix outputs a human-readable representation of prefix to the formatter f.

  • deprecated

    This function will be deprecated in a future version of this library. Please use pp instead.

val of_address_string_exn : string -> t * addr

of_address_string_exn cidr_addr is the address and prefix represented by cidr_addr. Raises Parse_error if cidr_addr is not a valid representation of a CIDR-scoped address.

val of_address_string : string -> (t * addr) option

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

val to_address_string : t -> addr -> string

to_address_string prefix addr is the network address constructed from prefix and addr.

val to_buffer : Buffer.t -> t -> unit

to_buffer buf prefix writes the string representation of prefix into the buffer buf.

val to_address_buffer : Buffer.t -> t -> addr -> unit

to_address_buffer buf prefix addr writes string representation of the network address representing addr in prefix to the buffer buf.

val of_netmask : addr -> addr -> t

of_netmask netmask addr is the subnet prefix of addr with netmask netmask.

val mem : addr -> t -> bool

mem ip subnet checks whether ip is found within subnet.

val subset : subnet:t -> network:t -> bool

subset ~subnet ~network checks whether subnet is contained within network.

val of_addr : addr -> t

of_addr ip create a subnet composed of only one address, ip. It is the same as make 32 ip.

val global : t

The default route, all addresses in IPv4-space, 0.0.0.0/0.

val loopback : t

The host loopback network, 127.0.0.0/8.

The local-link network, 169.254.0.0/16.

val relative : t

The relative addressing network, 0.0.0.0/8.

val multicast : t

The multicast network, 224.0.0.0/4.

val private_10 : t

The private subnet with 10 as first octet, 10.0.0.0/8.

val private_172 : t

The private subnet with 172 as first octet, 172.16.0.0/12.

val private_192 : t

The private subnet with 192 as first octet, 192.168.0.0/16.

val private_blocks : t list

The privately addressable networks: loopback, link, private_10, private_172, private_192.

val broadcast : t -> addr

broadcast subnet is the broadcast address for subnet.

val network : t -> addr

network subnet is the address for subnet.

val netmask : t -> addr

netmask subnet is the netmask for subnet.

val bits : t -> int

bits subnet is the bit size of the subnet prefix.

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

Innovation. Community. Security.