NETMATH(8)

NAME
netmath - Perform arithmetic on a dotted IP address

SYNOPSIS
netmath -t operation IP.ADDRESS.1 [ IP.ADDRESS.2 ]

DESCRIPTION

The netmath program is used to perform some basic arithmetic on a dotted decimal IP address. The operations include and, or, and exclusive or.

With this program is is possible to generate the network IP domain given the base IP address of the device and its associated netmask. The program devinfo will obtain these two fields.

The primary focus for this program is as an aid to a shell script. It will write the answer to the request to the stdout file. The exit code is zero for success, one for a failure. The nature of the failure is written to the stderr file.

OPTIONS

-t operation
    Specify the type of operation to be performed. The operation may be one of the items listed in the OPERATIONS section.

IP.ADDR.1
This field contains the dotted decimal IP address to be used in the expression. This field is required.

IP.ADDR.2
This field contains the optional dotted decimal IP address to be used in the expression. If the address is not supplied, one is defaulted based upon the type of operation desired and the standard IP domain of the address given in IP.ADDR.1. There is further information in the DEFAULT IP.ADDR.2 section.

OPERATIONS

and Perform the logical conjunction of bits in the IP addresses. This is commonly called a 'logical and' operation. If only one address is given, the result will be the IP domain of the IP address.

or  Perform the logical injunction of the bits in the IP addresses. This is commonly called a 'logical or' operation. If only one address is given, the result will be the broadcast address (assuming a 1's broadcast address) for the given IP address in IP.ADDR.1.

xor Perform the logical exclusive or operation between the two addresses. Both IP addresses must be supplied if the operation is 'xor'.

DEFAULT IP.ADDR.2
If the second IP address is not supplied, it is defaulted according to the rules of an internet address.

0xFF000000 for a class-A address
0xFFFF0000 for a class-B address
0xFFFFFF00 for a class-C address
0xFFFFFFFF for a class-D address.

SECURITY
This program performs no network operations. It requires no special security issues.

SEE ALSO
devinfo will obtain the various parameters for a network device.

devinfo(8), gethost(8)

COPYRIGHT
The netmath program is in public domain. This is not the GNU public license.

WARRENTY
No warranty is expressed or implied. If it breaks then you get to keep both pieces.

AUTHOR
Al Longyear <longyear@netcom.com>