The network-addresses Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The network-addresses Reference Manual

This is the network-addresses Reference Manual, generated automatically by Declt version 2.4 "Will Decker" on Wed Jun 20 12:19:32 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

network-addresses

Network addresses manipulation library.

This library lets you have an abstraction over IP addresses (ipv4 only for now) to manipulate them. Namely, there are 2 main abstractions:

An IP network consists of 2 things: a value and a subnet length, e.g. 192.168.0.0/16.

An IP address only consists of a value.

API

Class hierarchy

There exists 4 classes, best explained with their definitions:

(defclass network ()
  ((integer-value :initarg :integer-value :reader as-int)
   (subnet-length :initarg :subnet-length :reader subnet-length)
   (width :reader width :initform (error "Not implemented."))
   (max-value :reader max-value :initform (error "Not implemented."))))

(defclass ipv4-network (na:network)
  ((na:width :reader na:width :initform 32)
   (na:max-value :reader na:max-value :initform #xFFFFFFFF)))

(defclass address ()
  ((integer-value :initarg :integer-value :reader as-int)))

(defclass ipv4-address (na:address) ())

Packages

The network-addresses system provides 2 packages: network-addresses (nicknamed na) and network-addresses-ipv4 (nicknamed na4). The na package holds most of the public symbols, while na4 has the ipv4-specific functions.

network-addresses-ipv4 package
make-network-from-cidr

Takes a string representing a network in the CIDR notation, returns an ipv4-network.

Example:

CL-USER> (na4:make-network-from-cidr "192.168.0.0/16")
#<NETWORK-ADDRESSES-IPV4::IPV4-NETWORK 192.168.0.0/16>
network-addresses package
Conditions

This package can raise the na:invalid-format condition when an invalid IP address is provided to make-network-from-cidr.

network methods/functions

List of methods and functions that act on network objects. This list does not include the slot readers.

####### as-str

Returns the network value as a string.

Example:

CL-USER> (na:as-str (na4:make-network-from-cidr "192.168.0.0/16"))
"192.168.0.0/16"

####### netmask

Returns the netmask of the network as an address.

Example:

CL-USER> (na:netmask (na4:make-network-from-cidr "192.168.0.0/16"))
#<NETWORK-ADDRESSES-IPV4::IPV4-ADDRESS 255.255.0.0>

####### netmask-int

Returns the netmask of the network as an integer.

Example:

CL-USER> (na:netmask-int (na4:make-network-from-cidr "192.168.0.0/16"))
4294901760

####### hostmask

Returns the hostmask of the network as an address.

Example:

CL-USER> (na:hostmask (na4:make-network-from-cidr "192.168.0.0/16"))
#<NETWORK-ADDRESSES-IPV4::IPV4-ADDRESS 0.0.255.255>

####### hostmask-int

Returns the hostmask of the network as an integer.

Example:

CL-USER> (na:hostmask-int (na4:make-network-from-cidr "192.168.0.0/16"))
65535

####### broadcast

Returns the broadcast of the network as an address.

Example:

CL-USER> (na:broadcast (na4:make-network-from-cidr "192.168.0.0/16"))
#<NETWORK-ADDRESSES-IPV4::IPV4-ADDRESS 192.168.255.255>

####### broadcast-int

Returns the broadcast of the network as an integer.

Example:

CL-USER> (na:broadcast-int (na4:make-network-from-cidr "192.168.0.0/16"))
3232301055

####### addresses

Returns the list of IP addresses (excluding first and last) of the network as a list of address.

Example:

CL-USER> (na:addresses (na4:make-network-from-cidr "192.168.0.0/30"))
(#<NETWORK-ADDRESSES-IPV4::IPV4-ADDRESS 192.168.0.1>
 #<NETWORK-ADDRESSES-IPV4::IPV4-ADDRESS 192.168.0.2>)

####### addresses-int

Returns the list of IP addresses (excluding first and last) of the network as a list of integers.

Example:

CL-USER> (na:addresses-int (na4:make-network-from-cidr "192.168.0.0/30"))
(3232235521 3232235522)

####### first-address

Returns the first IP address of the network as an address.

Example:

CL-USER> (na:first-address (na4:make-network-from-cidr "192.168.0.0/30"))
#<NETWORK-ADDRESSES-IPV4::IPV4-ADDRESS 192.168.0.0>

####### first-address-int

Returns the first IP address of the network as an integer.

Example:

CL-USER> (na:first-address-int (na4:make-network-from-cidr "192.168.0.0/30"))
3232235520

####### last-address

Returns the last IP address of the network as an address.

Example:

CL-USER> (na:last-address (na4:make-network-from-cidr "192.168.0.0/30"))
#<NETWORK-ADDRESSES-IPV4::IPV4-ADDRESS 192.168.0.3>

####### last-address-int

Returns the last IP address of the network as an integer.

Example:

CL-USER> (na:last-address-int (na4:make-network-from-cidr "192.168.0.0/30"))
3232235523
address methods/functions

List of methods and functions that act on address objects. This list does not include the slot readers.

####### as-str

Returns the address value as a string.

Example:

CL-USER> (na:as-str (na:first-address (na4:make-network-from-cidr "192.168.0.0/16")))
"192.168.0.0"

License

This software is provided under the MIT license. Please see the LICENSE file.


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Previous: , Up: Systems   [Contents][Index]

2.1 network-addresses

Author

Florian Margaine <florian@margaine.com>

License

MIT

Description

A network addresses manipulation library.

Dependency

cl-ppcre

Source

network-addresses.asd (file)

Component

src (module)


Next: , Previous: , Up: Top   [Contents][Index]

3 Modules

Modules are listed depth-first from the system components tree.


Previous: , Up: Modules   [Contents][Index]

3.1 network-addresses/src

Parent

network-addresses (system)

Location

src/

Components

Next: , Previous: , Up: Top   [Contents][Index]

4 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

4.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.1 network-addresses.asd

Location

network-addresses.asd

Systems

network-addresses (system)


Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.2 network-addresses/src/package.lisp

Parent

src (module)

Location

src/package.lisp

Packages

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.3 network-addresses/src/generic.lisp

Dependency

package.lisp (file)

Parent

src (module)

Location

src/generic.lisp

Exported Definitions

as-str (generic function)


Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.4 network-addresses/src/conditions.lisp

Dependency

package.lisp (file)

Parent

src (module)

Location

src/conditions.lisp

Exported Definitions

invalid-format (condition)


Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.5 network-addresses/src/address.lisp

Dependency

package.lisp (file)

Parent

src (module)

Location

src/address.lisp

Exported Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

4.1.6 network-addresses/src/network.lisp

Dependencies
Parent

src (module)

Location

src/network.lisp

Exported Definitions
Internal Definitions

range (function)


Previous: , Up: Lisp files   [Contents][Index]

4.1.7 network-addresses/src/ipv4.lisp

Dependencies
Parent

src (module)

Location

src/ipv4.lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Top   [Contents][Index]

5 Packages

Packages are listed by definition order.


Next: , Previous: , Up: Packages   [Contents][Index]

5.1 network-addresses-ipv4

Source

package.lisp (file)

Nickname

na4

Use List

common-lisp

Exported Definitions

make-network-from-cidr (function)

Internal Definitions

Previous: , Up: Packages   [Contents][Index]

5.2 network-addresses

Source

package.lisp (file)

Nickname

na

Use List

common-lisp

Exported Definitions
Internal Definitions

range (function)


Next: , Previous: , Up: Top   [Contents][Index]

6 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

6.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.1 Functions

Function: addresses-int NETWORK

Returns the list of IP addresses of a network as integers.

Package

network-addresses

Source

network.lisp (file)

Function: broadcast-int NETWORK

Returns the broadcast as an integer.

Package

network-addresses

Source

network.lisp (file)

Function: first-address-int NETWORK

Returns the first address of this network.

Package

network-addresses

Source

network.lisp (file)

Function: hostmask-int NETWORK

Returns the hostmask as an integer.

Package

network-addresses

Source

network.lisp (file)

Function: last-address-int NETWORK

Returns the last address of this network.

Package

network-addresses

Source

network.lisp (file)

Function: make-network-from-cidr CIDR

Return a IPv4 network object based on the cidr.

Package

network-addresses-ipv4

Source

ipv4.lisp (file)

Function: netmask-int NETWORK

Returns the netmask as an integer.

Package

network-addresses

Source

network.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.2 Generic functions

Generic Function: addresses NETWORK

Returns the list of IP addresses of a network.

Package

network-addresses

Source

network.lisp (file)

Methods
Method: addresses (NETWORK ipv4-network)
Source

ipv4.lisp (file)

Generic Function: as-int OBJECT
Package

network-addresses

Methods
Method: as-int (NETWORK network)

automatically generated reader method

Source

network.lisp (file)

Method: as-int (ADDRESS address)

automatically generated reader method

Source

address.lisp (file)

Generic Function: as-str OBJECT

Returns the IP address/network in its string representation.

Package

network-addresses

Source

generic.lisp (file)

Methods
Method: as-str (NETWORK ipv4-network)
Source

ipv4.lisp (file)

Method: as-str (ADDRESS ipv4-address)
Source

ipv4.lisp (file)

Generic Function: broadcast NETWORK

Returns the broadcast as an IP address.

Package

network-addresses

Source

network.lisp (file)

Methods
Method: broadcast (NETWORK ipv4-network)
Source

ipv4.lisp (file)

Generic Function: first-address NETWORK

Returns the first IP address of this network.

Package

network-addresses

Source

network.lisp (file)

Methods
Method: first-address (NETWORK ipv4-network)
Source

ipv4.lisp (file)

Generic Function: hostmask NETWORK

Returns the hostmask as an IP address.

Package

network-addresses

Source

network.lisp (file)

Methods
Method: hostmask (NETWORK ipv4-network)
Source

ipv4.lisp (file)

Generic Function: last-address NETWORK

Returns the last IP address of this network.

Package

network-addresses

Source

network.lisp (file)

Methods
Method: last-address (NETWORK ipv4-network)
Source

ipv4.lisp (file)

Generic Function: max-value OBJECT
Package

network-addresses

Methods
Method: max-value (IPV4-NETWORK ipv4-network)

automatically generated reader method

Source

ipv4.lisp (file)

Method: max-value (NETWORK network)

automatically generated reader method

Source

network.lisp (file)

Generic Function: netmask NETWORK

Returns the netmask as an IP address.

Package

network-addresses

Source

network.lisp (file)

Methods
Method: netmask (NETWORK ipv4-network)
Source

ipv4.lisp (file)

Generic Function: subnet-length OBJECT
Package

network-addresses

Methods
Method: subnet-length (NETWORK network)

automatically generated reader method

Source

network.lisp (file)

Generic Function: width OBJECT
Package

network-addresses

Methods
Method: width (IPV4-NETWORK ipv4-network)

automatically generated reader method

Source

ipv4.lisp (file)

Method: width (NETWORK network)

automatically generated reader method

Source

network.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

6.1.3 Conditions

Condition: invalid-format ()
Package

network-addresses

Source

conditions.lisp (file)

Direct superclasses

error (condition)


Previous: , Up: Exported definitions   [Contents][Index]

6.1.4 Classes

Class: address ()
Package

network-addresses

Source

address.lisp (file)

Direct superclasses

standard-object (class)

Direct subclasses

ipv4-address (class)

Direct methods

as-int (method)

Direct slots
Slot: integer-value
Initargs

:integer-value

Readers

as-int (generic function)

Class: network ()
Package

network-addresses

Source

network.lisp (file)

Direct superclasses

standard-object (class)

Direct subclasses

ipv4-network (class)

Direct methods
Direct slots
Slot: integer-value
Initargs

:integer-value

Readers

as-int (generic function)

Slot: subnet-length
Initargs

:subnet-length

Readers

subnet-length (generic function)

Slot: width
Initform

(error "not implemented.")

Readers

width (generic function)

Slot: max-value
Initform

(error "not implemented.")

Readers

max-value (generic function)


Previous: , Up: Definitions   [Contents][Index]

6.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

6.2.1 Special variables

Special Variable: *ipv4-cidr-regex*
Package

network-addresses-ipv4

Source

ipv4.lisp (file)


Next: , Previous: , Up: Internal definitions   [Contents][Index]

6.2.2 Functions

Function: ipv4-integers-to-integer STRINGS

Transforms a list of integers in strings into a single integer, by having each integer going through its byte representation, then concatenating all the bytes, and returning the value of these bits. With math.

Package

network-addresses-ipv4

Source

ipv4.lisp (file)

Function: range START END
Package

network-addresses

Source

network.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

6.2.3 Classes

Class: ipv4-address ()
Package

network-addresses-ipv4

Source

ipv4.lisp (file)

Direct superclasses

address (class)

Direct methods
  • as-str (method)
  • print-object (method)
Class: ipv4-network ()
Package

network-addresses-ipv4

Source

ipv4.lisp (file)

Direct superclasses

network (class)

Direct methods
Direct slots
Slot: width
Initform

32

Readers

width (generic function)

Slot: max-value
Initform

4294967295

Readers

max-value (generic function)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   F   L   M   N  
Index Entry  Section

F
File, Lisp, network-addresses.asd: The network-addresses<dot>asd file
File, Lisp, network-addresses/src/address.lisp: The network-addresses/src/address<dot>lisp file
File, Lisp, network-addresses/src/conditions.lisp: The network-addresses/src/conditions<dot>lisp file
File, Lisp, network-addresses/src/generic.lisp: The network-addresses/src/generic<dot>lisp file
File, Lisp, network-addresses/src/ipv4.lisp: The network-addresses/src/ipv4<dot>lisp file
File, Lisp, network-addresses/src/network.lisp: The network-addresses/src/network<dot>lisp file
File, Lisp, network-addresses/src/package.lisp: The network-addresses/src/package<dot>lisp file

L
Lisp File, network-addresses.asd: The network-addresses<dot>asd file
Lisp File, network-addresses/src/address.lisp: The network-addresses/src/address<dot>lisp file
Lisp File, network-addresses/src/conditions.lisp: The network-addresses/src/conditions<dot>lisp file
Lisp File, network-addresses/src/generic.lisp: The network-addresses/src/generic<dot>lisp file
Lisp File, network-addresses/src/ipv4.lisp: The network-addresses/src/ipv4<dot>lisp file
Lisp File, network-addresses/src/network.lisp: The network-addresses/src/network<dot>lisp file
Lisp File, network-addresses/src/package.lisp: The network-addresses/src/package<dot>lisp file

M
Module, network-addresses/src: The network-addresses/src module

N
network-addresses.asd: The network-addresses<dot>asd file
network-addresses/src: The network-addresses/src module
network-addresses/src/address.lisp: The network-addresses/src/address<dot>lisp file
network-addresses/src/conditions.lisp: The network-addresses/src/conditions<dot>lisp file
network-addresses/src/generic.lisp: The network-addresses/src/generic<dot>lisp file
network-addresses/src/ipv4.lisp: The network-addresses/src/ipv4<dot>lisp file
network-addresses/src/network.lisp: The network-addresses/src/network<dot>lisp file
network-addresses/src/package.lisp: The network-addresses/src/package<dot>lisp file

Jump to:   F   L   M   N  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   A   B   F   G   H   I   L   M   N   R   S   W  
Index Entry  Section

A
addresses: Exported generic functions
addresses: Exported generic functions
addresses-int: Exported functions
as-int: Exported generic functions
as-int: Exported generic functions
as-int: Exported generic functions
as-str: Exported generic functions
as-str: Exported generic functions
as-str: Exported generic functions

B
broadcast: Exported generic functions
broadcast: Exported generic functions
broadcast-int: Exported functions

F
first-address: Exported generic functions
first-address: Exported generic functions
first-address-int: Exported functions
Function, addresses-int: Exported functions
Function, broadcast-int: Exported functions
Function, first-address-int: Exported functions
Function, hostmask-int: Exported functions
Function, ipv4-integers-to-integer: Internal functions
Function, last-address-int: Exported functions
Function, make-network-from-cidr: Exported functions
Function, netmask-int: Exported functions
Function, range: Internal functions

G
Generic Function, addresses: Exported generic functions
Generic Function, as-int: Exported generic functions
Generic Function, as-str: Exported generic functions
Generic Function, broadcast: Exported generic functions
Generic Function, first-address: Exported generic functions
Generic Function, hostmask: Exported generic functions
Generic Function, last-address: Exported generic functions
Generic Function, max-value: Exported generic functions
Generic Function, netmask: Exported generic functions
Generic Function, subnet-length: Exported generic functions
Generic Function, width: Exported generic functions

H
hostmask: Exported generic functions
hostmask: Exported generic functions
hostmask-int: Exported functions

I
ipv4-integers-to-integer: Internal functions

L
last-address: Exported generic functions
last-address: Exported generic functions
last-address-int: Exported functions

M
make-network-from-cidr: Exported functions
max-value: Exported generic functions
max-value: Exported generic functions
max-value: Exported generic functions
Method, addresses: Exported generic functions
Method, as-int: Exported generic functions
Method, as-int: Exported generic functions
Method, as-str: Exported generic functions
Method, as-str: Exported generic functions
Method, broadcast: Exported generic functions
Method, first-address: Exported generic functions
Method, hostmask: Exported generic functions
Method, last-address: Exported generic functions
Method, max-value: Exported generic functions
Method, max-value: Exported generic functions
Method, netmask: Exported generic functions
Method, subnet-length: Exported generic functions
Method, width: Exported generic functions
Method, width: Exported generic functions

N
netmask: Exported generic functions
netmask: Exported generic functions
netmask-int: Exported functions

R
range: Internal functions

S
subnet-length: Exported generic functions
subnet-length: Exported generic functions

W
width: Exported generic functions
width: Exported generic functions
width: Exported generic functions

Jump to:   A   B   F   G   H   I   L   M   N   R   S   W  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   *  
I   M   S   W  
Index Entry  Section

*
*ipv4-cidr-regex*: Internal special variables

I
integer-value: Exported classes
integer-value: Exported classes

M
max-value: Exported classes
max-value: Internal classes

S
Slot, integer-value: Exported classes
Slot, integer-value: Exported classes
Slot, max-value: Exported classes
Slot, max-value: Internal classes
Slot, subnet-length: Exported classes
Slot, width: Exported classes
Slot, width: Internal classes
Special Variable, *ipv4-cidr-regex*: Internal special variables
subnet-length: Exported classes

W
width: Exported classes
width: Internal classes

Jump to:   *  
I   M   S   W  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   A   C   I   N   P   S  
Index Entry  Section

A
address: Exported classes

C
Class, address: Exported classes
Class, ipv4-address: Internal classes
Class, ipv4-network: Internal classes
Class, network: Exported classes
Condition, invalid-format: Exported conditions

I
invalid-format: Exported conditions
ipv4-address: Internal classes
ipv4-network: Internal classes

N
network: Exported classes
network-addresses: The network-addresses system
network-addresses: The network-addresses package
network-addresses-ipv4: The network-addresses-ipv4 package

P
Package, network-addresses: The network-addresses package
Package, network-addresses-ipv4: The network-addresses-ipv4 package

S
System, network-addresses: The network-addresses system

Jump to:   A   C   I   N   P   S