package ipaddr

  1. Overview
  2. Docs

Module V4.PrefixSource

A module for manipulating IPv4 network prefixes (CIDR).

Sourcetype addr = t
Sourcetype t

Type of a internet protocol subnet: an address and prefix length.

Sourceval mask : int -> addr

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

Sourceval make : int -> addr -> t

make n addr is the cidr of addr with n bits prefix.

Sourceval prefix : t -> t

prefix cidr is the subnet prefix of cidr where all non-prefix bits set to 0.

Sourceval network_address : t -> addr -> addr

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

Sourceval of_string : string -> (t, [> `Msg of string ]) result

of_string cidr is the subnet prefix represented by the CIDR string, cidr. Returns a human-readable parsing error message if cidr is not a valid representation of a CIDR notation routing prefix.

Sourceval 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.

Sourceval of_string_raw : string -> int ref -> t

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

Sourceval to_string : t -> string

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

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

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

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

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

Sourceval of_netmask_exn : netmask:addr -> address:addr -> t

of_netmask_exn ~netmask ~address is the subnet prefix of address with netmask netmask.

Sourceval of_netmask : netmask:addr -> address:addr -> (t, [> `Msg of string ]) result

of_netmask ~netmask ~address is the cidr of address with netmask netmask.

Sourceval mem : addr -> t -> bool

mem ip subnet checks whether ip is found within subnet.

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

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

Sourceval of_addr : addr -> t

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

Sourceval global : t

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

Sourceval loopback : t

The host loopback network, 127.0.0.0/8.

The local-link network, 169.254.0.0/16.

Sourceval relative : t

The relative addressing network, 0.0.0.0/8.

Sourceval multicast : t

The multicast network, 224.0.0.0/4.

Sourceval private_10 : t

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

Sourceval private_172 : t

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

Sourceval private_192 : t

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

Sourceval private_blocks : t list

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

Sourceval broadcast : t -> addr

broadcast subnet is the broadcast address for subnet.

Sourceval network : t -> addr

network subnet is the address for subnet.

Sourceval netmask : t -> addr

netmask subnet is the netmask for subnet.

Sourceval address : t -> addr

address cidr is the address for cidr.

Sourceval bits : t -> int

bits cidr is the bit size of the cidr prefix.

Sourceval first : t -> addr

first cidr is first valid unicast address in this cidr.

Sourceval last : t -> addr

last cidr is last valid unicast address in this cidr.

Sourceval hosts : ?usable:bool -> t -> addr Seq.t

hosts cidr is the sequence of host addresses in this cidr. By default, network and broadcast addresses are omitted. This can be changed by setting usable to false.

Sourceval subnets : int -> t -> t Seq.t

subnets n cidr is the sequence of subnets of cidr with a prefix length of n.

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

A total ordering function over the keys. This is a two-argument function f such that f e1 e2 is zero if the keys e1 and e2 are equal, f e1 e2 is strictly negative if e1 is smaller than e2, and f e1 e2 is strictly positive if e1 is greater than e2. Example: a suitable ordering function is the generic structural comparison function Stdlib.compare.

OCaml

Innovation. Community. Security.