NETCALC

NAME

netcalc-printf - display IP address information

SYNOPSIS

netcalc printf [OPTIONS] <fmt> <address> [ <address> [ ... <address> ] ]

netcalc-printf [OPTIONS] <fmt> <address> [ <address> [ ... <address> ] ]

netcalcprintf [OPTIONS] <fmt> <address> [ <address> [ ... <address> ] ]

neprintf [OPTIONS] <fmt> <address> [ <address> [ ... <address> ] ]

DESCRIPTION

The netcalc printf widget processes one or more addresses and prints them according to the format provided on the command line.

The fmt string may include format specifiers (substrings beginning with %) and format specifier modifers. A format specifier follows the syntqx:

%[flags][width]specifier

where:

flags

is one or more specifier modiers (see SPECIFIER MODIFIERS).

width

is the minumum number of characters to be printed by the specifier. If the specified value is shorter than the width, the result is padded with spaces. The value is not truncated if it is longer than width.

specifier

is character use to denote which value to insert into the string (see FORMAT SPECIFIERS).

OPTIONS

-4, --ipv4

The input address uses the format for the IPv4 address family. This option can be combined with --ipv6, --eui48, and --eui64. Addresses of other address families will generate an error.

-6, --ipv6

The input address uses the format for the IPv6 address family. This option can be combined with --ipv4, --eui48, and --eui64. Addresses of other address families will generate an error.

-C af, --family af

Convert input addresses to address family af. Where af may be ipv4, ipv6, eui48, or eui64. The prefix ::ffff:0:0 will be used when converting from IPv4 addresses to IPv6 addresses. The prefix fe80:: will be used when converting from EUI-48 and EUI-64 addresses to IPv6 addresses.

-E, --eui64

The input address uses the format for the EUI-64 address family. This option can be combined with --ipv4, --ipv6, and --eui48. Addresses of other address families will generate an error.

-e, --eui48, --mac

The input address uses the format for MAC addresses or EUI-48 address family. This option can be combined with --ipv4, --ipv6, and --eui64. Addresses of other address families will generate an error.

-h, --help

Print usage information and exit

-M

Display IPv6 addresses as IPv4-mapped IPv6 addresses.

-p net, --prefix net

Similar to the -C option, but the address family is determined by the address net

When converting to an IPv6 address from an IPv4 address, the first 96 bits of net will be used as the prefix for the resulting IPv6 address and the CIDR will be set to the CIDR which is the larger of the source and net addresses.

When converting to an IPv6 address from an EUI-48 address, the source address is converted to a modified EUI-64 address and treated as an EUI-64 address.

When converting to an IPv6 address from an EUI-64 address, the first 64 bits of net will be used as the prefix for the resulting IPv6 address and the CIDR from the net address will be used as the CIDR of the resulting address.

-q, --quiet, --silent

Suppress warnings and excess messages

-S

Display IPv4 and IPv6 addresses without zero suppression. For example the address 203.0.113.0 will be displayed as 203.000.113.000 and the address 2001:db8::1 will be displayed as 2001:0db8:0000:0000:0000:0000:0000:0001.

-V, --version

Print version number and exit

-v, --verbose

Print additional information about the addresses and the supernet of all the provided addresses.

-Z

Display IPv6 addresses without zero compression. For example the address 2001:db8::1 will be displayed as 2001:db8:0:0:0:0:0:1.

--colon

Display EUI-48 and EUI-64 addresses in blocks of two digits with colons as delimiters. 00:16:3e:9b:54:54 is an example with an EUI-48 address and 00:16:3e:71:9c:52:f0:d9 is an example with an EUI-64 address. This is the default format for EUI-48 addresses.

--dash

Display EUI-48 and EUI-64 addresses in blocks of two digits with dashes as delimiters. 00-16-3e-9b-54-54 is an example with an EUI-48 address and 00-16-3e-71-9c-52-f0-d9 is an example with an EUI-64 address.

--colon

Display EUI-48 and EUI-64 addresses in blocks of four digits with dots as delimiters. 0016.3e9b.5454 is an example with an EUI-48 address and 0016.3e71.9c52.f0d9 is an example with an EUI-64 address. This is the default format for EUI-64 addresses.

FORMAT SPECIFIERS

%

is replaced by ’%’.

A

is replaced by the input address using the address family’s default notation.

a

is replaced by the input address.

b

is replaced by the input address’s broadcast address.

C

is replaced by the input address’s CIDR without the delimiter.

c

is replaced by the input address’s CIDR with the delimiter if the CIDR is greater than a single address, otherwise is replaced with an empty string.

D

is replaced by the input address’s DNS arpa zone. This is the same as "%d" if the address is IPv4 with a CIDR of /32 or the address is IPv6 with a CIDR of /128.

d

is replaced by the input address’s DNS arpa host.

F

is replaced by the input address’s family (i.e. IPv4, IPv6, EUI48, or EUI64).

f

is replaced by the input address network’s first usable address.

I

is replaced by the input addresses’s interface name without a delimiter if the address is IPv6 with an interface scope, otherwise is replaced with an empty string.

i

is replaced by the input addresses’s interface name with a delimiter if the address is IPv6 with an interface scope, otherwise is replaced with an empty string.

l

is replaced by the input address network’s last usable address.

N

is replaced by the input address’s netmask.

n

is replaced by the input address’s network address.

P

is replaced by the input port number without a delimiter.

p

is replaced by the input port number with a delimiter if the port number is not zero, otherwise is replaced with an empty string.

W

is replaced by the input address’s wildcard address.

SPECIFIER MODIFIERS

-

justify padded fields to the left.

B

do not use delimiters (EUI48 and EUI64).

H

use dash delimiters (EUI48 and EUI64).

L

use colon delimiters (EUI48 and EUI64).

M

do not use IPv4-mapped IPv6 address notation with IPv6 addresses.

m

use IPv4-mapped IPv6 address notation with IPv6 addresses.

O

use dot delimiters (EUI48 and EUI64).

S

do not use zero suppression for IPv4 and IPv6 addresses.

s

use zero suppression for IPv4 and IPv6 addresses.

Z

do not use zero compression for IPv6 addresses.

z

use zero compression for IPv6 addresses.

ESCAPE SEQUENCES

\a

Alert (Beep, Bell)

\b

Backspace

\f

Formfeed Page Break

\n

Newline

\r

Carriage Return

\t

Horizontal Tab

\v

Vertical Tab

\\

Backslash

\’

Apostrophe or single quotation mark

\"

Double quotation mark

\?

Question mark

EXAMPLES

The following example will display the specified EUI-48 address using four different specifier modfiers.

Command:

netcalc printf "%Ba %Ha %La %Oa" 00:16:3e:9b:54:54

Result:

00163e9b5454 00-16-3e-9b-54-54 00:16:3e:9b:54:54 0016.3e9b.5454

The following example will display the specified IP addresses and their network addresses, broadcast addresses, netmasks, and CIDR.

Command:

netcalc printf "%-15a %-15b %-15n %SN %2C" \
10.0.0.0/8 \
172.16.0.0/12 \
192.168.0.0/16

Result:

10.0.0.0 10.255.255.255 10.0.0.0 255.000.000.000 8
172.16.0.0 172.31.255.255 172.16.0.0 255.240.000.000 12
192.168.0.0 192.168.255.255 192.168.0.0 255.255.000.000 16

SEE ALSO

netcalc(1), netcalc-info(1), netcalc-superblock(1), libnetcalc(3), netcalc_strfnet(3), netcalc-syntaxes(5)

AUTHOR

David M. Syzdek <david@syzdek.net>

ACKNOWLEDGEMENTS

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