Date: Fri, 04 May 2001 17:24:35 +0000 From: Gunther Schadow <gunther@aurora.regenstrief.org> To: freebsd-questions@freebsd.org Subject: I want to contribute a utility, how? Message-ID: <3AF2E5D3.3163FD74@aurora.regenstrief.org>
index | next in thread | raw e-mail
Hi,
in my project to produce VPN/firewall settop boxes, I have satisfied
a desperate need for some shell level IP adress calculator that would
help me genericise and simplify my configuration scripts. You probably
have that problem too, that some tools want netmasks, others want
a /prefix notation for networks, and you need to know low and high
host numbers, check whether an address is within a network and step
through host and network numbers etc. This is all handled now by the
following little tool. The man page is at the end.
My question is: how can I contribute this? I'd like it to go into the
distribution rather than just a port. I understand that I have to clean
up some things first, coding standards, and fix the first of the bugs
listed.
thanks,
-Gunther
IPAC(1) FreeBSD General Commands Manual IPAC(1)
NAME
ipac - IP address calculation and manipulation
SYNOPSIS
ipac [-x] [-abdehiIlmnpt] arguments ...
ipac [-x] -m prefix
ipac [-x] -p netmask
ipac [-x] -e address network prefix
ipac [-x] [-bhiIlnt] address prefix
DESCRIPTION
The ipac utility performs various IP address manipulations according to
the given operator and arguments. The arguments are of the following
types
address an arbirary IP address;
network an IP address representing a network, i.e., some of the
trailing bits should be clear;
netmask a netmask, i.e., an IP address beginning with a contiguous
sequence of set bits followed by and ending in a contiguous
sequence of cleared bits;
prefix a network prefix length, i.e. an integer number between 0
and 32.
All IP addresses can be represented in several forms, notably the dotted
decimal form, such as 123.45.67.89, or in hexadecimal form, such as
0x7b2d4359.
IP addresses are returned to standard output in dotted decimal form. If
the -x flag is present, the resulting address is printed in hexadecimal
form.
The ipac utility defines the following operators
-m prefix Converts a network prefix length (integer number between 0
and 32) into a netmask which is written to standard output.
-p netmask Converts a netmask into a network prefix length. The
netmask must be a contiguous series of set bits followed by
a contiguous series of clear bits. If the netmask argument
is not in the proper form, ipac will signal an error. The
prefix is is written to standard output in decimal form.
-e address network prefix
Returns true (0) if the address is in the network with the
given prefix.
-n address prefix
Writes the address of the network for the given (host)
address and prefix to standard output.
-b address prefix
Writes the broadcast address of the network for the given
(host) address and prefix to standard output.
-l address prefix
Writes the lowest host address number of the network for
the given (host) address and prefix to standard output.
-h address prefix
Writes the highest host address number of the network for
the given (host) address and prefix to standard output.
-i address prefix
Increases the given (host) address in the network given as
prefix by one and writes that address to standard output.
If the increase produces an overflow (i.e., if the argument
is a highest host in the network) ipac returns false (1)
and writes nothing.
-I address prefix
Increases the network number for the given (host) address
and prefix and writes the result to standard output. The
host number in the network is unchanged, e.g.,
ipac -I 192.168.16.2 24
returns "192.168.17.2".
-a address prefix n
Add the integer number n to the host address in the network
designated by prefix and write the result to standard out-
put. If this addition causes an overflow condition, ipac
returns 0 and outputs nothing.
-d address prefix n
Subtract the integer number n from the host address in the
network designated by prefix and write the result to stan-
dard output. If this addition causes an underflow condi-
tion, ipac returns 0 and outputs nothing.
RETURN VALUES
The ipac utility exits with one of the following values:
0 No error and expression evaluated to true.
1 Expression evaluated to false.
>1 An error occurred.
SEE ALSO
inet addr(3),
BUGS
The error and overflow conditions aren't properly checked yet. This man-
ual is partly a specification of how things should work.
Currently we handle only IPv4 addresses.
HISTORY
The ipac utility was written by Gunther Schadow <gschadow@regen-
strief.org>, Regenstrief Institute for Health Care.
BSD May 4, 2001 2
--
Gunther Schadow, M.D., Ph.D. gschadow@regenstrief.org
Medical Information Scientist Regenstrief Institute for Health Care
Adjunct Assistent Professor Indiana University School of Medicine
tel:1(317)630-7960 http://aurora.regenstrief.org
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-questions" in the body of the message
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?3AF2E5D3.3163FD74>
