package ipaddr
Install
    
    dune-project
 Dependency
Authors
Maintainers
Sources
sha256=9e30433fdb4ca437a6aa8ffb447baca5eba7615fb88e7b0cd8a4b416c3208133
    
    
  sha512=66a3bedfd91dacd6c1de9ba35abac3ef2ad3c2c8543f7b4e2a0cc6283a8d42138b48d02e904df0232ee9f320920e889bddbbda9a5148c5c6b72fd0164e0c6a34
    
    
  doc/ipaddr/Ipaddr/V4/index.html
Module Ipaddr.V4
A collection of functions for IPv4 addresses.
val make : int -> int -> int -> int -> tConverts the low bytes of four int values into an abstract V4.t.
Text string conversion
These manipulate human-readable IPv4 addresses (for example 192.168.1.2).
of_string s is the address t represented by the human-readable IPv4 address s. Returns a human-readable error string if parsing failed.
val of_string_exn : string -> tof_string_exn s is the address t represented as a human-readable IPv4 address s. Raises Parse_error if s is invalid or truncated.
of_string_raw s off acts as of_string_exn but takes as an extra argument the offset into the string for reading. off will be mutated to an unspecified value during the function call. s will a Parse_error exception if it is an invalid or truncated IP address.
with_port_of_string ~default s is the address t represented by the human-readble IPv4 address s with a possibly port :<port> (otherwise, we take the default value).
val to_string : t -> stringto_string ipv4 is the dotted decimal string representation of ipv4, i.e. XXX.XX.X.XXX.
to_buffer buf ipv4 writes the string representation of ipv4 into the buffer buf.
val pp : Format.formatter -> t -> unitpp f ipv4 outputs a human-readable representation of ipv4 to the formatter f.
Octets conversion
These manipulate IPv4 addresses represented as a sequence of four bytes. (e.g for example 0xc0a80102 will be the representation of the human-readable 192.168.1.2 address.
of_octets ?off s is the IPv4 address t represented by the octets in s starting from offset off within the string. Returns a human-readable error string if s is not at least off+4 bytes long. off defaults to 0.
val of_octets_exn : ?off:int -> string -> tof_octets_exn ipv4_octets is the IPv4 address represented by ipv4_octets starting from offset off. Raises Parse_error if ipv4_octets is not at least off+4 bytes long. off defaults to 0.
write_octets ?off ipv4 b writes the ipv4 as octets to b starting from offset off. b must be at least off+4 long or an error is returned.
val write_octets_exn : ?off:int -> t -> bytes -> unitwrite_octets_exn ?off ipv4 b writes the ipv4 as octets to b starting from offset off. b must be at least off+4 long or a Parse_error is raised.
val to_octets : t -> stringto_octets ipv4 returns the 4 bytes representing the ipv4 octets.
Int conversion
val of_int32 : int32 -> tof_int32 ipv4_packed is the address represented by ipv4_packed.
val to_int32 : t -> int32to_int32 ipv4 is the 32-bit packed encoding of ipv4.
val of_int16 : (int * int) -> tof_int16 ipv4_packed is the address represented by ipv4_packed.
val to_int16 : t -> int * intto_int16 ipv4 is the 16-bit packed encoding of ipv4.
MAC conversion
multicast_to_mac ipv4 is the MAC address corresponding to the multicast address ipv4. Described by RFC 1112.
Host conversion
val to_domain_name : t -> [ `host ] Domain_name.tto_domain_name ipv4 is the domain name label list for reverse lookups of ipv4. This includes the .in-addr.arpa suffix.
val of_domain_name : 'a Domain_name.t -> t optionof_domain_name name is Some t if the name has an .in-addr.arpa suffix, and an IPv4 address prefixed.
Utility functions
succ ipv4 is ip address next to ipv4. Returns a human-readable error string if it's already the highest address.
pred ipv4 is ip address before ipv4. Returns a human-readable error string if it's already the lowest address.
Common addresses
val any : tany is 0.0.0.0.
val unspecified : tunspecified is 0.0.0.0.
val broadcast : tbroadcast is 255.255.255.255.
val nodes : tnodes is 224.0.0.1.
val routers : trouters is 224.0.0.2.
val localhost : tlocalhost is 127.0.0.1.
module Prefix : sig ... endA module for manipulating IPv4 network prefixes (CIDR).
val is_global : t -> boolis_global ipv4 is a predicate indicating whether ipv4 globally addresses a node.
val is_multicast : t -> boolis_multicast ipv4 is a predicate indicating whether ipv4 is a multicast address.
val is_private : t -> boolis_private ipv4 is a predicate indicating whether ipv4 privately addresses a node.
include Map.OrderedType with type t := t
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.