NETCALC-SYNTAXES

LIBRARY

Network Calculations Library (libnetcalc, -lnetcalc)

SYNOPSIS

#include <netcalc.h>

DESCRIPTION

The netcalc library supports multiple input formats for IPv4 addresses, IPv6 addresses, EUI-48 identifiers, and EUI-64 identifiers.

EUI-48 IDENTIFIERS

The following ABNF describes the syntax netcalc accepts for EUI-48 input.

eui48 = 5( 2HEXDIG ":" ) 2HEXDIG ; colon delimiter
eui48 =/ 5( 2HEXDIG "-" ) 2HEXDIG ; dash delimiter
eui48 =/ 2( 4HEXDIG "." ) 4HEXDIG ; dot delimiter
eui48 =/ 12HEXDIG ; no delimiter

The following are examples of the EUI-48 syntaxes supported by netcalc:

colon delimiter

01:23:45:67:89:ab

dash delimiter

01-23-45-67-89-ab

dot delimiter

0123.4567.89ab

no delimiter

0123456789ab

EUI-64 IDENTIFIERS

The following ABNF describes the syntax netcalc accepts for EUI-64 input.

eui64 = 7( 2HEXDIG ":" ) 2HEXDIG ; colon delimiter
eui64 =/ 7( 2HEXDIG "-" ) 2HEXDIG ; dash delimiter
eui64 =/ 3( 4HEXDIG "." ) 4HEXDIG ; dot delimiter
eui64 =/ 16HEXDIG ; no delimiter

The following are examples of the EUI-64 syntaxes supported by netcalc:

colon delimiter

01:23:45:67:89:ab:cd:ef

dash delimiter

01-23-45-67-89-ab-cd-ef

dot delimiter

0123.4567.89ab.cdef

no delimiter

0123456789abcdef

IPV4 ADDRESSES

The following ABNF describes the syntax netcalc accepts for IPv4 input.

ipv4 = ipv4addr [ "/" cidr4 / ":" port / "/" cidr4 ":" port ]

ipv4addr = 3( octet4 "." ) octet4

octet4 = 2DIGIT
octet4 =/ ( "0" / "1" ) 2DIGIT
octet4 =/ "2" ( "0" / "1" / "2" / "3" / "4" ) DIGIT
octet4 =/ "25" ( "0" / "1" / "2" / "3" / "4" / "5" )

cidr4 = DIGIT / ( "1" / "2" / "3" ) DIGIT

port = *1( "1" / "2" / "3" / "4" / "5" ) 4DIGIT
port =/ "6" ( "0" / "1" / "2" / "3" / "4" ) 3DIGIT
port =/ "65" ( "0" / "1" / "2" / "3" / "4" ) 2DIGIT
port =/ "655" ( "0" / "1" / "2" ) DIGIT
port =/ "6553" ( "0" / "1" / "2" / "3" / "4" / "5" )

The following are examples of the IPv4 syntaxes supported by netcalc:

address

203.0.113.42

with CIDR

203.0.113.42/29

with port

203.0.113.42:8080

with CIDR and port

203.0.113.42/29:8080

IPV6 ADDRESSES

The following ABNF describes the syntax netcalc accepts for IPv6 input.

ipv6 = ipv6addr
ipv6 =/ ipv6addr "" iface
ipv6 =/ ipv6addr "/" cidr6
ipv6 =/ "[" ipv6addr "]"
ipv6 =/ "[" ipv6addr "]/" cidr6
ipv6 =/ "[" ipv6addr "]:" port
ipv6 =/ "[" ipv6addr "]/" cidr6 ":" port
ipv6 =/ "[" ipv6addr "" iface "]"
ipv6 =/ "[" ipv6addr "" iface "]/" cidr6
ipv6 =/ "[" ipv6addr "" iface "]/" cidr6 ":" port

ipv6addr = 7( node6 ":" ) ( node6 / ":" )
ipv6addr =/ 1*7( node6 ":" ) ":"
ipv6addr =/ 1*6( node6 ":" ) ":" node6
ipv6addr =/ 1*5( node6 ":" ) 2( ":" node6 )
ipv6addr =/ 1*4( node6 ":" ) 3( ":" node6 )
ipv6addr =/ 1*3( node6 ":" ) 4( ":" node6 )
ipv6addr =/ 1*2( node6 ":" ) 5( ":" node6 )
ipv6addr =/ node6 ":" 6( ":" node6 )
ipv6addr =/ ":" 1*7( ":" node6 )
ipv6addr =/ "::"
ipv6addr = 6( node6 ":" ) ipv4addr
ipv6addr =/ 1*5( node6 ":" ) ":" ipv4addr
ipv6addr =/ 1*4( node6 ":" ) 1( ":" node6 ) ":" ipv4addr
ipv6addr =/ 1*3( node6 ":" ) 2( ":" node6 ) ":" ipv4addr
ipv6addr =/ 1*2( node6 ":" ) 3( ":" node6 ) ":" ipv4addr
ipv6addr =/ ( node6 ":" ) 4( ":" node6 ) ":" ipv4addr
ipv6addr =/ ":" *4( ":" node6 ) ":" ipv4addr

node6 = 1*4HEXDIG

cidr6 = 1*2DIGIT
cidr6 =/ "1" ( "0" / "1" ) DIGIT
cidr6 =/ "12" x30-38

port = *1( "1" / "2" / "3" / "4" / "5" ) *4DIGIT
port =/ "6" ( "0" / "1" / "2" / "3" / "4" ) 3DIGIT
port =/ "65" ( "0" / "1" / "2" / "3" / "4" ) 2DIGIT
port =/ "655" ( "0" / "1" / "2" ) DIGIT
port =/ "6553" ( "0" / "1" / "2" / "3" / "4" / "5" )

The following are examples of the IPv6 syntaxes supported by netcalc:

address

2001:0db8:000f:0300:0000:0000:cb00:712a

with 0 compression

2001:0db8:000f:0300::cb00:712a

with 0 suppression

2001:db8:f:300:0:0:cb00:712a

with both

2001:db8:f:300::cb00:712a

The following are examples of the IPv6 syntaxes with IPv4 mapped addresses supported by netcalc:

address

2001:0db8:000f:0300:0000:0000:203.000.113.042

with 0 compression

2001:0db8:000f:0300::203.000.113.042

with 0 suppression

2001:db8:f:300:0:0:203.0.113.42

with both

2001:db8:f:300::203.0.113.42

The following are examples of the IPv6 syntaxes with port, CIDR, and interface scope name using zero compression and zero suppression:

address

2001:db8:f:300::cb00:712a

address

[2001:db8:f:300::cb00:712a]

address

2001:db8:f:300::cb00:712aeth0

address

[2001:db8:f:300::cb00:712aeth0]

with CIDR

2001:db8:f:300::cb00:712a/64

with CIDR

[2001:db8:f:300::cb00:712a]/64

with CIDR

[2001:db8:f:300::cb00:712aeth0]/64

with port

[2001:db8:f:300::cb00:712a]:8080

with port

[2001:db8:f:300::cb00:712aeth0]:8080

with port and CIDR

[2001:db8:f:300::cb00:712a]/64:8080

with port and CIDR

[2001:db8:f:300::cb00:712aeth0]/64:8080

SEE ALSO

libnetcalc(3), netcalc(1)

AUTHOR

David M. Syzdek <david@syzdek.net>

ACKNOWLEDGEMENTS

Network Calculations Library is developed and maintained by David M. Syzdek <david@syzdek.net>.