pax_global_header00006660000000000000000000000064134246346430014523gustar00rootroot0000000000000052 comment=29a9c239bd1008363f5b34ffd6c2cef906f3660c netmask-2.4.4/000077500000000000000000000000001342463464300131745ustar00rootroot00000000000000netmask-2.4.4/.gitignore000066400000000000000000000003631342463464300151660ustar00rootroot00000000000000*.o .deps INSTALL Makefile Makefile.in autom4te.cache compile config.h config.h.in config.log config.status configure depcomp install-sh mdate-sh missing netmask.info stamp-h1 stamp-vti test-driver texinfo.tex version.texi netmask aclocal.m4 netmask-2.4.4/AUTHORS000066400000000000000000000002121342463464300142370ustar00rootroot00000000000000Primary code and documentation by Robert Stone Some algorithm design advice by Tom Lear netmask-2.4.4/COPYING000066400000000000000000000431271342463464300142360ustar00rootroot00000000000000 GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. netmask-2.4.4/ChangeLog000066400000000000000000000036261342463464300147550ustar00rootroot00000000000000netmask (2.4.4) unstable; urgency=low * harden error logging functions -- Robert Stone Thu, 31 Jan 2019 09:26:52 -0800 netmask (2.4.3) unstable; urgency=low * repair broken ":+" style range additions for #802884 * allow ranges listed from high to low * avoid configure warnings about missing NEWS file -- Robert Stone Sat, 31 Oct 2015 18:10:52 -0700 netmask (2.4.2) unstable; urgency=low * adds an "autogen" script to run the auto tools * tidy/update stale docs * clean up several spelling errors -- Robert Stone Mon, 28 Sep 2015 12:51:35 -0700 netmask (2.4.0) unstable; urgency=low * IPv6 support added. * Bugfix: Cisco style masks assumed more cautiously. * Perform dns lookups less aggressively. -- Robert Stone Tue, 19 Feb 2013 14:18:24 -0800 netmask (2.3.6) unstable; urgency=low * Debian policy compliance updates. -- Robert Stone Thu, 03 Apr 2003 13:43:14 -0800 netmask (2.3.5) unstable; urgency=low * Fixed typo in description (closes: #94632) * Add build-dependencies, including texinfo (closes: #111181). -- Robert Stone Thu, 14 Feb 2002 11:08:14 -0800 netmask (2.3.4) unstable; urgency=low * Bugfix: infodoc install cleanup. (closes: #69210) * Bugfix: circular list state hang. -- Robert Stone Wed, 30 Aug 2000 13:46:23 -0700 netmask (2.3.3) unstable frozen; urgency=low * Bugfix: dublicate entry addition segfault -- Robert Stone Wed, 1 Mar 2000 10:29:28 -0800 netmask (2.3.2) unstable; urgency=low * Debian packaging cleanup. -- Robert Stone Fri, 5 Nov 1999 11:18:23 -0800 netmask (2.3.1) unstable; urgency=low * Initial Release. -- Robert Stone Mon, 30 Aug 1999 20:36:48 -0700 Local variables: mode: debian-changelog End: netmask-2.4.4/Makefile.am000066400000000000000000000003261342463464300152310ustar00rootroot00000000000000 bin_PROGRAMS = netmask netmask_SOURCES = main.c netmask.c netmask.h errors.c errors.h info_TEXINFOS = netmask.texi netmask_TEXINFOS = gpl.texi man_MANS = netmask.1 EXTRA_DIST = $(man_MANS) TESTS = ./testscript netmask-2.4.4/README000066400000000000000000000010771342463464300140610ustar00rootroot00000000000000This is a handy tool for generating terse netmasks in several common formats. If you've ever maintained a firewall with more than a few rules in it, you might use netmask to clean up and generalize sloppy rules left by the netadmin before you. It will also convert netmasks from one format to another for the day you change your firewall software. See the file INSTALL for building and installation instructions. Please send all bug reports by electronic mail to: netmask-bug@trap.mtview.ca.us Netmask is free software. See the file COPYING for copying conditions. netmask-2.4.4/aclocal.m4000066400000000000000000001217071342463464300150440ustar00rootroot00000000000000# generated automatically by aclocal 1.14.1 -*- Autoconf -*- # Copyright (C) 1996-2013 Free Software Foundation, Inc. # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY, to the extent permitted by law; without # even the implied warranty of MERCHANTABILITY or FITNESS FOR A # PARTICULAR PURPOSE. m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])]) m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.69],, [m4_warning([this file was generated for autoconf 2.69. You have another version of autoconf. It may work, but is not guaranteed to. If you have problems, you may need to regenerate the build system entirely. To do so, use the procedure documented by the package, typically 'autoreconf'.])]) # Copyright (C) 2002-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_AUTOMAKE_VERSION(VERSION) # ---------------------------- # Automake X.Y traces this macro to ensure aclocal.m4 has been # generated from the m4 files accompanying Automake X.Y. # (This private macro should not be called outside this file.) AC_DEFUN([AM_AUTOMAKE_VERSION], [am__api_version='1.14' dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to dnl require some minimum version. Point them to the right macro. m4_if([$1], [1.14.1], [], [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl ]) # _AM_AUTOCONF_VERSION(VERSION) # ----------------------------- # aclocal traces this macro to find the Autoconf version. # This is a private macro too. Using m4_define simplifies # the logic in aclocal, which can simply ignore this definition. m4_define([_AM_AUTOCONF_VERSION], []) # AM_SET_CURRENT_AUTOMAKE_VERSION # ------------------------------- # Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced. # This function is AC_REQUIREd by AM_INIT_AUTOMAKE. AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION], [AM_AUTOMAKE_VERSION([1.14.1])dnl m4_ifndef([AC_AUTOCONF_VERSION], [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl _AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))]) # AM_AUX_DIR_EXPAND -*- Autoconf -*- # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets # $ac_aux_dir to '$srcdir/foo'. In other projects, it is set to # '$srcdir', '$srcdir/..', or '$srcdir/../..'. # # Of course, Automake must honor this variable whenever it calls a # tool from the auxiliary directory. The problem is that $srcdir (and # therefore $ac_aux_dir as well) can be either absolute or relative, # depending on how configure is run. This is pretty annoying, since # it makes $ac_aux_dir quite unusable in subdirectories: in the top # source directory, any form will work fine, but in subdirectories a # relative path needs to be adjusted first. # # $ac_aux_dir/missing # fails when called from a subdirectory if $ac_aux_dir is relative # $top_srcdir/$ac_aux_dir/missing # fails if $ac_aux_dir is absolute, # fails when called from a subdirectory in a VPATH build with # a relative $ac_aux_dir # # The reason of the latter failure is that $top_srcdir and $ac_aux_dir # are both prefixed by $srcdir. In an in-source build this is usually # harmless because $srcdir is '.', but things will broke when you # start a VPATH build or use an absolute $srcdir. # # So we could use something similar to $top_srcdir/$ac_aux_dir/missing, # iff we strip the leading $srcdir from $ac_aux_dir. That would be: # am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"` # and then we would define $MISSING as # MISSING="\${SHELL} $am_aux_dir/missing" # This will work as long as MISSING is not called from configure, because # unfortunately $(top_srcdir) has no meaning in configure. # However there are other variables, like CC, which are often used in # configure, and could therefore not use this "fixed" $ac_aux_dir. # # Another solution, used here, is to always expand $ac_aux_dir to an # absolute PATH. The drawback is that using absolute paths prevent a # configured tree to be moved without reconfiguration. AC_DEFUN([AM_AUX_DIR_EXPAND], [dnl Rely on autoconf to set up CDPATH properly. AC_PREREQ([2.50])dnl # expand $ac_aux_dir to an absolute path am_aux_dir=`cd $ac_aux_dir && pwd` ]) # AM_CONDITIONAL -*- Autoconf -*- # Copyright (C) 1997-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_CONDITIONAL(NAME, SHELL-CONDITION) # ------------------------------------- # Define a conditional. AC_DEFUN([AM_CONDITIONAL], [AC_PREREQ([2.52])dnl m4_if([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])], [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl AC_SUBST([$1_TRUE])dnl AC_SUBST([$1_FALSE])dnl _AM_SUBST_NOTMAKE([$1_TRUE])dnl _AM_SUBST_NOTMAKE([$1_FALSE])dnl m4_define([_AM_COND_VALUE_$1], [$2])dnl if $2; then $1_TRUE= $1_FALSE='#' else $1_TRUE='#' $1_FALSE= fi AC_CONFIG_COMMANDS_PRE( [if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then AC_MSG_ERROR([[conditional "$1" was never defined. Usually this means the macro was only invoked conditionally.]]) fi])]) # Copyright (C) 1999-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # There are a few dirty hacks below to avoid letting 'AC_PROG_CC' be # written in clear, in which case automake, when reading aclocal.m4, # will think it sees a *use*, and therefore will trigger all it's # C support machinery. Also note that it means that autoscan, seeing # CC etc. in the Makefile, will ask for an AC_PROG_CC use... # _AM_DEPENDENCIES(NAME) # ---------------------- # See how the compiler implements dependency checking. # NAME is "CC", "CXX", "OBJC", "OBJCXX", "UPC", or "GJC". # We try a few techniques and use that to set a single cache variable. # # We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was # modified to invoke _AM_DEPENDENCIES(CC); we would have a circular # dependency, and given that the user is not expected to run this macro, # just rely on AC_PROG_CC. AC_DEFUN([_AM_DEPENDENCIES], [AC_REQUIRE([AM_SET_DEPDIR])dnl AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl AC_REQUIRE([AM_MAKE_INCLUDE])dnl AC_REQUIRE([AM_DEP_TRACK])dnl m4_if([$1], [CC], [depcc="$CC" am_compiler_list=], [$1], [CXX], [depcc="$CXX" am_compiler_list=], [$1], [OBJC], [depcc="$OBJC" am_compiler_list='gcc3 gcc'], [$1], [OBJCXX], [depcc="$OBJCXX" am_compiler_list='gcc3 gcc'], [$1], [UPC], [depcc="$UPC" am_compiler_list=], [$1], [GCJ], [depcc="$GCJ" am_compiler_list='gcc3 gcc'], [depcc="$$1" am_compiler_list=]) AC_CACHE_CHECK([dependency style of $depcc], [am_cv_$1_dependencies_compiler_type], [if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then # We make a subdir and do the tests there. Otherwise we can end up # making bogus files that we don't know about and never remove. For # instance it was reported that on HP-UX the gcc test will end up # making a dummy file named 'D' -- because '-MD' means "put the output # in D". rm -rf conftest.dir mkdir conftest.dir # Copy depcomp to subdir because otherwise we won't find it if we're # using a relative directory. cp "$am_depcomp" conftest.dir cd conftest.dir # We will build objects and dependencies in a subdirectory because # it helps to detect inapplicable dependency modes. For instance # both Tru64's cc and ICC support -MD to output dependencies as a # side effect of compilation, but ICC will put the dependencies in # the current directory while Tru64 will put them in the object # directory. mkdir sub am_cv_$1_dependencies_compiler_type=none if test "$am_compiler_list" = ""; then am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp` fi am__universal=false m4_case([$1], [CC], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac], [CXX], [case " $depcc " in #( *\ -arch\ *\ -arch\ *) am__universal=true ;; esac]) for depmode in $am_compiler_list; do # Setup a source with many dependencies, because some compilers # like to wrap large dependency lists on column 80 (with \), and # we should not choose a depcomp mode which is confused by this. # # We need to recreate these files for each test, as the compiler may # overwrite some of them when testing with obscure command lines. # This happens at least with the AIX C compiler. : > sub/conftest.c for i in 1 2 3 4 5 6; do echo '#include "conftst'$i'.h"' >> sub/conftest.c # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with # Solaris 10 /bin/sh. echo '/* dummy */' > sub/conftst$i.h done echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf # We check with '-c' and '-o' for the sake of the "dashmstdout" # mode. It turns out that the SunPro C++ compiler does not properly # handle '-M -o', and we need to detect this. Also, some Intel # versions had trouble with output in subdirs. am__obj=sub/conftest.${OBJEXT-o} am__minus_obj="-o $am__obj" case $depmode in gcc) # This depmode causes a compiler race in universal mode. test "$am__universal" = false || continue ;; nosideeffect) # After this tag, mechanisms are not by side-effect, so they'll # only be used when explicitly requested. if test "x$enable_dependency_tracking" = xyes; then continue else break fi ;; msvc7 | msvc7msys | msvisualcpp | msvcmsys) # This compiler won't grok '-c -o', but also, the minuso test has # not run yet. These depmodes are late enough in the game, and # so weak that their functioning should not be impacted. am__obj=conftest.${OBJEXT-o} am__minus_obj= ;; none) break ;; esac if depmode=$depmode \ source=sub/conftest.c object=$am__obj \ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \ >/dev/null 2>conftest.err && grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 && grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 && grep $am__obj sub/conftest.Po > /dev/null 2>&1 && ${MAKE-make} -s -f confmf > /dev/null 2>&1; then # icc doesn't choke on unknown options, it will just issue warnings # or remarks (even with -Werror). So we grep stderr for any message # that says an option was ignored or not supported. # When given -MP, icc 7.0 and 7.1 complain thusly: # icc: Command line warning: ignoring option '-M'; no argument required # The diagnosis changed in icc 8.0: # icc: Command line remark: option '-MP' not supported if (grep 'ignoring option' conftest.err || grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else am_cv_$1_dependencies_compiler_type=$depmode break fi fi done cd .. rm -rf conftest.dir else am_cv_$1_dependencies_compiler_type=none fi ]) AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type]) AM_CONDITIONAL([am__fastdep$1], [ test "x$enable_dependency_tracking" != xno \ && test "$am_cv_$1_dependencies_compiler_type" = gcc3]) ]) # AM_SET_DEPDIR # ------------- # Choose a directory name for dependency files. # This macro is AC_REQUIREd in _AM_DEPENDENCIES. AC_DEFUN([AM_SET_DEPDIR], [AC_REQUIRE([AM_SET_LEADING_DOT])dnl AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl ]) # AM_DEP_TRACK # ------------ AC_DEFUN([AM_DEP_TRACK], [AC_ARG_ENABLE([dependency-tracking], [dnl AS_HELP_STRING( [--enable-dependency-tracking], [do not reject slow dependency extractors]) AS_HELP_STRING( [--disable-dependency-tracking], [speeds up one-time build])]) if test "x$enable_dependency_tracking" != xno; then am_depcomp="$ac_aux_dir/depcomp" AMDEPBACKSLASH='\' am__nodep='_no' fi AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno]) AC_SUBST([AMDEPBACKSLASH])dnl _AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl AC_SUBST([am__nodep])dnl _AM_SUBST_NOTMAKE([am__nodep])dnl ]) # Generate code to set up dependency tracking. -*- Autoconf -*- # Copyright (C) 1999-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_OUTPUT_DEPENDENCY_COMMANDS # ------------------------------ AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS], [{ # Older Autoconf quotes --file arguments for eval, but not when files # are listed without --file. Let's play safe and only enable the eval # if we detect the quoting. case $CONFIG_FILES in *\'*) eval set x "$CONFIG_FILES" ;; *) set x $CONFIG_FILES ;; esac shift for mf do # Strip MF so we end up with the name of the file. mf=`echo "$mf" | sed -e 's/:.*$//'` # Check whether this is an Automake generated Makefile or not. # We used to match only the files named 'Makefile.in', but # some people rename them; so instead we look at the file content. # Grep'ing the first line is not enough: some people post-process # each Makefile.in and add a new line on top of each file to say so. # Grep'ing the whole file is not good either: AIX grep has a line # limit of 2048, but all sed's we know have understand at least 4000. if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then dirpart=`AS_DIRNAME("$mf")` else continue fi # Extract the definition of DEPDIR, am__include, and am__quote # from the Makefile without running 'make'. DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"` test -z "$DEPDIR" && continue am__include=`sed -n 's/^am__include = //p' < "$mf"` test -z "$am__include" && continue am__quote=`sed -n 's/^am__quote = //p' < "$mf"` # Find all dependency output files, they are included files with # $(DEPDIR) in their names. We invoke sed twice because it is the # simplest approach to changing $(DEPDIR) to its actual value in the # expansion. for file in `sed -n " s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \ sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g'`; do # Make sure the directory exists. test -f "$dirpart/$file" && continue fdir=`AS_DIRNAME(["$file"])` AS_MKDIR_P([$dirpart/$fdir]) # echo "creating $dirpart/$file" echo '# dummy' > "$dirpart/$file" done done } ])# _AM_OUTPUT_DEPENDENCY_COMMANDS # AM_OUTPUT_DEPENDENCY_COMMANDS # ----------------------------- # This macro should only be invoked once -- use via AC_REQUIRE. # # This code is only required when automatic dependency tracking # is enabled. FIXME. This creates each '.P' file that we will # need in order to bootstrap the dependency handling code. AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS], [AC_CONFIG_COMMANDS([depfiles], [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS], [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"]) ]) # Do all the work for Automake. -*- Autoconf -*- # Copyright (C) 1996-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # This macro actually does too much. Some checks are only needed if # your package does certain things. But this isn't really a big deal. dnl Redefine AC_PROG_CC to automatically invoke _AM_PROG_CC_C_O. m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC]) [_AM_PROG_CC_C_O ]) # AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE]) # AM_INIT_AUTOMAKE([OPTIONS]) # ----------------------------------------------- # The call with PACKAGE and VERSION arguments is the old style # call (pre autoconf-2.50), which is being phased out. PACKAGE # and VERSION should now be passed to AC_INIT and removed from # the call to AM_INIT_AUTOMAKE. # We support both call styles for the transition. After # the next Automake release, Autoconf can make the AC_INIT # arguments mandatory, and then we can depend on a new Autoconf # release and drop the old call support. AC_DEFUN([AM_INIT_AUTOMAKE], [AC_PREREQ([2.65])dnl dnl Autoconf wants to disallow AM_ names. We explicitly allow dnl the ones we care about. m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl AC_REQUIRE([AC_PROG_INSTALL])dnl if test "`cd $srcdir && pwd`" != "`pwd`"; then # Use -I$(srcdir) only when $(srcdir) != ., so that make's output # is not polluted with repeated "-I." AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl # test to see if srcdir already configured if test -f $srcdir/config.status; then AC_MSG_ERROR([source directory already configured; run "make distclean" there first]) fi fi # test whether we have cygpath if test -z "$CYGPATH_W"; then if (cygpath --version) >/dev/null 2>/dev/null; then CYGPATH_W='cygpath -w' else CYGPATH_W=echo fi fi AC_SUBST([CYGPATH_W]) # Define the identity of the package. dnl Distinguish between old-style and new-style calls. m4_ifval([$2], [AC_DIAGNOSE([obsolete], [$0: two- and three-arguments forms are deprecated.]) m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl AC_SUBST([PACKAGE], [$1])dnl AC_SUBST([VERSION], [$2])], [_AM_SET_OPTIONS([$1])dnl dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT. m4_if( m4_ifdef([AC_PACKAGE_NAME], [ok]):m4_ifdef([AC_PACKAGE_VERSION], [ok]), [ok:ok],, [m4_fatal([AC_INIT should be called with package and version arguments])])dnl AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl _AM_IF_OPTION([no-define],, [AC_DEFINE_UNQUOTED([PACKAGE], ["$PACKAGE"], [Name of package]) AC_DEFINE_UNQUOTED([VERSION], ["$VERSION"], [Version number of package])])dnl # Some tools Automake needs. AC_REQUIRE([AM_SANITY_CHECK])dnl AC_REQUIRE([AC_ARG_PROGRAM])dnl AM_MISSING_PROG([ACLOCAL], [aclocal-${am__api_version}]) AM_MISSING_PROG([AUTOCONF], [autoconf]) AM_MISSING_PROG([AUTOMAKE], [automake-${am__api_version}]) AM_MISSING_PROG([AUTOHEADER], [autoheader]) AM_MISSING_PROG([MAKEINFO], [makeinfo]) AC_REQUIRE([AM_PROG_INSTALL_SH])dnl AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl AC_REQUIRE([AC_PROG_MKDIR_P])dnl # For better backward compatibility. To be removed once Automake 1.9.x # dies out for good. For more background, see: # # AC_SUBST([mkdir_p], ['$(MKDIR_P)']) # We need awk for the "check" target. The system "awk" is bad on # some platforms. AC_REQUIRE([AC_PROG_AWK])dnl AC_REQUIRE([AC_PROG_MAKE_SET])dnl AC_REQUIRE([AM_SET_LEADING_DOT])dnl _AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])], [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])], [_AM_PROG_TAR([v7])])]) _AM_IF_OPTION([no-dependencies],, [AC_PROVIDE_IFELSE([AC_PROG_CC], [_AM_DEPENDENCIES([CC])], [m4_define([AC_PROG_CC], m4_defn([AC_PROG_CC])[_AM_DEPENDENCIES([CC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_CXX], [_AM_DEPENDENCIES([CXX])], [m4_define([AC_PROG_CXX], m4_defn([AC_PROG_CXX])[_AM_DEPENDENCIES([CXX])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJC], [_AM_DEPENDENCIES([OBJC])], [m4_define([AC_PROG_OBJC], m4_defn([AC_PROG_OBJC])[_AM_DEPENDENCIES([OBJC])])])dnl AC_PROVIDE_IFELSE([AC_PROG_OBJCXX], [_AM_DEPENDENCIES([OBJCXX])], [m4_define([AC_PROG_OBJCXX], m4_defn([AC_PROG_OBJCXX])[_AM_DEPENDENCIES([OBJCXX])])])dnl ]) AC_REQUIRE([AM_SILENT_RULES])dnl dnl The testsuite driver may need to know about EXEEXT, so add the dnl 'am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This dnl macro is hooked onto _AC_COMPILER_EXEEXT early, see below. AC_CONFIG_COMMANDS_PRE(dnl [m4_provide_if([_AM_COMPILER_EXEEXT], [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl # POSIX will say in a future version that running "rm -f" with no argument # is OK; and we want to be able to make that assumption in our Makefile # recipes. So use an aggressive probe to check that the usage we want is # actually supported "in the wild" to an acceptable degree. # See automake bug#10828. # To make any issue more visible, cause the running configure to be aborted # by default if the 'rm' program in use doesn't match our expectations; the # user can still override this though. if rm -f && rm -fr && rm -rf; then : OK; else cat >&2 <<'END' Oops! Your 'rm' program seems unable to run without file operands specified on the command line, even when the '-f' option is present. This is contrary to the behaviour of most rm programs out there, and not conforming with the upcoming POSIX standard: Please tell bug-automake@gnu.org about your system, including the value of your $PATH and any error possibly output before this message. This can help us improve future automake versions. END if test x"$ACCEPT_INFERIOR_RM_PROGRAM" = x"yes"; then echo 'Configuration will proceed anyway, since you have set the' >&2 echo 'ACCEPT_INFERIOR_RM_PROGRAM variable to "yes"' >&2 echo >&2 else cat >&2 <<'END' Aborting the configuration process, to ensure you take notice of the issue. You can download and install GNU coreutils to get an 'rm' implementation that behaves properly: . If you want to complete the configuration process using your problematic 'rm' anyway, export the environment variable ACCEPT_INFERIOR_RM_PROGRAM to "yes", and re-run configure. END AC_MSG_ERROR([Your 'rm' program is bad, sorry.]) fi fi]) dnl Hook into '_AC_COMPILER_EXEEXT' early to learn its expansion. Do not dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further dnl mangled by Autoconf and run in a shell conditional statement. m4_define([_AC_COMPILER_EXEEXT], m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])]) # When config.status generates a header, we must update the stamp-h file. # This file resides in the same directory as the config header # that is generated. The stamp files are numbered to have different names. # Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the # loop where config.status creates the headers, so we can generate # our stamp files there. AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK], [# Compute $1's index in $config_headers. _am_arg=$1 _am_stamp_count=1 for _am_header in $config_headers :; do case $_am_header in $_am_arg | $_am_arg:* ) break ;; * ) _am_stamp_count=`expr $_am_stamp_count + 1` ;; esac done echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count]) # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_SH # ------------------ # Define $install_sh. AC_DEFUN([AM_PROG_INSTALL_SH], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl if test x"${install_sh}" != xset; then case $am_aux_dir in *\ * | *\ *) install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;; *) install_sh="\${SHELL} $am_aux_dir/install-sh" esac fi AC_SUBST([install_sh])]) # Copyright (C) 2003-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # Check whether the underlying file-system supports filenames # with a leading dot. For instance MS-DOS doesn't. AC_DEFUN([AM_SET_LEADING_DOT], [rm -rf .tst 2>/dev/null mkdir .tst 2>/dev/null if test -d .tst; then am__leading_dot=. else am__leading_dot=_ fi rmdir .tst 2>/dev/null AC_SUBST([am__leading_dot])]) # Check to see how 'make' treats includes. -*- Autoconf -*- # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MAKE_INCLUDE() # ----------------- # Check to see how make treats includes. AC_DEFUN([AM_MAKE_INCLUDE], [am_make=${MAKE-make} cat > confinc << 'END' am__doit: @echo this is the am__doit target .PHONY: am__doit END # If we don't find an include directive, just comment out the code. AC_MSG_CHECKING([for style of include used by $am_make]) am__include="#" am__quote= _am_result=none # First try GNU make style include. echo "include confinc" > confmf # Ignore all kinds of additional output from 'make'. case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=include am__quote= _am_result=GNU ;; esac # Now try BSD make style include. if test "$am__include" = "#"; then echo '.include "confinc"' > confmf case `$am_make -s -f confmf 2> /dev/null` in #( *the\ am__doit\ target*) am__include=.include am__quote="\"" _am_result=BSD ;; esac fi AC_SUBST([am__include]) AC_SUBST([am__quote]) AC_MSG_RESULT([$_am_result]) rm -f confinc confmf ]) # Fake the existence of programs that GNU maintainers use. -*- Autoconf -*- # Copyright (C) 1997-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_MISSING_PROG(NAME, PROGRAM) # ------------------------------ AC_DEFUN([AM_MISSING_PROG], [AC_REQUIRE([AM_MISSING_HAS_RUN]) $1=${$1-"${am_missing_run}$2"} AC_SUBST($1)]) # AM_MISSING_HAS_RUN # ------------------ # Define MISSING if not defined so far and test if it is modern enough. # If it is, set am_missing_run to use it, otherwise, to nothing. AC_DEFUN([AM_MISSING_HAS_RUN], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([missing])dnl if test x"${MISSING+set}" != xset; then case $am_aux_dir in *\ * | *\ *) MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;; *) MISSING="\${SHELL} $am_aux_dir/missing" ;; esac fi # Use eval to expand $SHELL if eval "$MISSING --is-lightweight"; then am_missing_run="$MISSING " else am_missing_run= AC_MSG_WARN(['missing' script is too old or missing]) fi ]) # Helper functions for option handling. -*- Autoconf -*- # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_MANGLE_OPTION(NAME) # ----------------------- AC_DEFUN([_AM_MANGLE_OPTION], [[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])]) # _AM_SET_OPTION(NAME) # -------------------- # Set option NAME. Presently that only means defining a flag for this option. AC_DEFUN([_AM_SET_OPTION], [m4_define(_AM_MANGLE_OPTION([$1]), [1])]) # _AM_SET_OPTIONS(OPTIONS) # ------------------------ # OPTIONS is a space-separated list of Automake options. AC_DEFUN([_AM_SET_OPTIONS], [m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])]) # _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET]) # ------------------------------------------- # Execute IF-SET if OPTION is set, IF-NOT-SET otherwise. AC_DEFUN([_AM_IF_OPTION], [m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])]) # Copyright (C) 1999-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_CC_C_O # --------------- # Like AC_PROG_CC_C_O, but changed for automake. We rewrite AC_PROG_CC # to automatically call this. AC_DEFUN([_AM_PROG_CC_C_O], [AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl AC_REQUIRE_AUX_FILE([compile])dnl AC_LANG_PUSH([C])dnl AC_CACHE_CHECK( [whether $CC understands -c and -o together], [am_cv_prog_cc_c_o], [AC_LANG_CONFTEST([AC_LANG_PROGRAM([])]) # Make sure it works both with $CC and with simple cc. # Following AC_PROG_CC_C_O, we do the test twice because some # compilers refuse to overwrite an existing .o file with -o, # though they will create one. am_cv_prog_cc_c_o=yes for am_i in 1 2; do if AM_RUN_LOG([$CC -c conftest.$ac_ext -o conftest2.$ac_objext]) \ && test -f conftest2.$ac_objext; then : OK else am_cv_prog_cc_c_o=no break fi done rm -f core conftest* unset am_i]) if test "$am_cv_prog_cc_c_o" != yes; then # Losing compiler, so override with the script. # FIXME: It is wrong to rewrite CC. # But if we don't then we get into trouble of one sort or another. # A longer-term fix would be to have automake use am__CC in this case, # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)" CC="$am_aux_dir/compile $CC" fi AC_LANG_POP([C])]) # For backward compatibility. AC_DEFUN_ONCE([AM_PROG_CC_C_O], [AC_REQUIRE([AC_PROG_CC])]) # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_RUN_LOG(COMMAND) # ------------------- # Run COMMAND, save the exit status in ac_status, and log it. # (This has been adapted from Autoconf's _AC_RUN_LOG macro.) AC_DEFUN([AM_RUN_LOG], [{ echo "$as_me:$LINENO: $1" >&AS_MESSAGE_LOG_FD ($1) >&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ac_status=$? echo "$as_me:$LINENO: \$? = $ac_status" >&AS_MESSAGE_LOG_FD (exit $ac_status); }]) # Check to make sure that the build environment is sane. -*- Autoconf -*- # Copyright (C) 1996-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SANITY_CHECK # --------------- AC_DEFUN([AM_SANITY_CHECK], [AC_MSG_CHECKING([whether build environment is sane]) # Reject unsafe characters in $srcdir or the absolute working directory # name. Accept space and tab only in the latter. am_lf=' ' case `pwd` in *[[\\\"\#\$\&\'\`$am_lf]]*) AC_MSG_ERROR([unsafe absolute working directory name]);; esac case $srcdir in *[[\\\"\#\$\&\'\`$am_lf\ \ ]]*) AC_MSG_ERROR([unsafe srcdir value: '$srcdir']);; esac # Do 'set' in a subshell so we don't clobber the current shell's # arguments. Must try -L first in case configure is actually a # symlink; some systems play weird games with the mod time of symlinks # (eg FreeBSD returns the mod time of the symlink's containing # directory). if ( am_has_slept=no for am_try in 1 2; do echo "timestamp, slept: $am_has_slept" > conftest.file set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null` if test "$[*]" = "X"; then # -L didn't work. set X `ls -t "$srcdir/configure" conftest.file` fi if test "$[*]" != "X $srcdir/configure conftest.file" \ && test "$[*]" != "X conftest.file $srcdir/configure"; then # If neither matched, then we have a broken ls. This can happen # if, for instance, CONFIG_SHELL is bash and it inherits a # broken ls alias from the environment. This has actually # happened. Such a system could not be considered "sane". AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken alias in your environment]) fi if test "$[2]" = conftest.file || test $am_try -eq 2; then break fi # Just in case. sleep 1 am_has_slept=yes done test "$[2]" = conftest.file ) then # Ok. : else AC_MSG_ERROR([newly created file is older than distributed files! Check your system clock]) fi AC_MSG_RESULT([yes]) # If we didn't sleep, we still need to ensure time stamps of config.status and # generated files are strictly newer. am_sleep_pid= if grep 'slept: no' conftest.file >/dev/null 2>&1; then ( sleep 1 ) & am_sleep_pid=$! fi AC_CONFIG_COMMANDS_PRE( [AC_MSG_CHECKING([that generated files are newer than configure]) if test -n "$am_sleep_pid"; then # Hide warnings about reused PIDs. wait $am_sleep_pid 2>/dev/null fi AC_MSG_RESULT([done])]) rm -f conftest.file ]) # Copyright (C) 2009-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_SILENT_RULES([DEFAULT]) # -------------------------- # Enable less verbose build rules; with the default set to DEFAULT # ("yes" being less verbose, "no" or empty being verbose). AC_DEFUN([AM_SILENT_RULES], [AC_ARG_ENABLE([silent-rules], [dnl AS_HELP_STRING( [--enable-silent-rules], [less verbose build output (undo: "make V=1")]) AS_HELP_STRING( [--disable-silent-rules], [verbose build output (undo: "make V=0")])dnl ]) case $enable_silent_rules in @%:@ ((( yes) AM_DEFAULT_VERBOSITY=0;; no) AM_DEFAULT_VERBOSITY=1;; *) AM_DEFAULT_VERBOSITY=m4_if([$1], [yes], [0], [1]);; esac dnl dnl A few 'make' implementations (e.g., NonStop OS and NextStep) dnl do not support nested variable expansions. dnl See automake bug#9928 and bug#10237. am_make=${MAKE-make} AC_CACHE_CHECK([whether $am_make supports nested variables], [am_cv_make_support_nested_variables], [if AS_ECHO([['TRUE=$(BAR$(V)) BAR0=false BAR1=true V=1 am__doit: @$(TRUE) .PHONY: am__doit']]) | $am_make -f - >/dev/null 2>&1; then am_cv_make_support_nested_variables=yes else am_cv_make_support_nested_variables=no fi]) if test $am_cv_make_support_nested_variables = yes; then dnl Using '$V' instead of '$(V)' breaks IRIX make. AM_V='$(V)' AM_DEFAULT_V='$(AM_DEFAULT_VERBOSITY)' else AM_V=$AM_DEFAULT_VERBOSITY AM_DEFAULT_V=$AM_DEFAULT_VERBOSITY fi AC_SUBST([AM_V])dnl AM_SUBST_NOTMAKE([AM_V])dnl AC_SUBST([AM_DEFAULT_V])dnl AM_SUBST_NOTMAKE([AM_DEFAULT_V])dnl AC_SUBST([AM_DEFAULT_VERBOSITY])dnl AM_BACKSLASH='\' AC_SUBST([AM_BACKSLASH])dnl _AM_SUBST_NOTMAKE([AM_BACKSLASH])dnl ]) # Copyright (C) 2001-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PROG_INSTALL_STRIP # --------------------- # One issue with vendor 'install' (even GNU) is that you can't # specify the program used to strip binaries. This is especially # annoying in cross-compiling environments, where the build's strip # is unlikely to handle the host's binaries. # Fortunately install-sh will honor a STRIPPROG variable, so we # always use install-sh in "make install-strip", and initialize # STRIPPROG with the value of the STRIP variable (set by the user). AC_DEFUN([AM_PROG_INSTALL_STRIP], [AC_REQUIRE([AM_PROG_INSTALL_SH])dnl # Installed binaries are usually stripped using 'strip' when the user # run "make install-strip". However 'strip' might not be the right # tool to use in cross-compilation environments, therefore Automake # will honor the 'STRIP' environment variable to overrule this program. dnl Don't test for $cross_compiling = yes, because it might be 'maybe'. if test "$cross_compiling" != no; then AC_CHECK_TOOL([STRIP], [strip], :) fi INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s" AC_SUBST([INSTALL_STRIP_PROGRAM])]) # Copyright (C) 2006-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_SUBST_NOTMAKE(VARIABLE) # --------------------------- # Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in. # This macro is traced by Automake. AC_DEFUN([_AM_SUBST_NOTMAKE]) # AM_SUBST_NOTMAKE(VARIABLE) # -------------------------- # Public sister of _AM_SUBST_NOTMAKE. AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)]) # Check how to create a tarball. -*- Autoconf -*- # Copyright (C) 2004-2013 Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # _AM_PROG_TAR(FORMAT) # -------------------- # Check how to create a tarball in format FORMAT. # FORMAT should be one of 'v7', 'ustar', or 'pax'. # # Substitute a variable $(am__tar) that is a command # writing to stdout a FORMAT-tarball containing the directory # $tardir. # tardir=directory && $(am__tar) > result.tar # # Substitute a variable $(am__untar) that extract such # a tarball read from stdin. # $(am__untar) < result.tar # AC_DEFUN([_AM_PROG_TAR], [# Always define AMTAR for backward compatibility. Yes, it's still used # in the wild :-( We should find a proper way to deprecate it ... AC_SUBST([AMTAR], ['$${TAR-tar}']) # We'll loop over all known methods to create a tar archive until one works. _am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none' m4_if([$1], [v7], [am__tar='$${TAR-tar} chof - "$$tardir"' am__untar='$${TAR-tar} xf -'], [m4_case([$1], [ustar], [# The POSIX 1988 'ustar' format is defined with fixed-size fields. # There is notably a 21 bits limit for the UID and the GID. In fact, # the 'pax' utility can hang on bigger UID/GID (see automake bug#8343 # and bug#13588). am_max_uid=2097151 # 2^21 - 1 am_max_gid=$am_max_uid # The $UID and $GID variables are not portable, so we need to resort # to the POSIX-mandated id(1) utility. Errors in the 'id' calls # below are definitely unexpected, so allow the users to see them # (that is, avoid stderr redirection). am_uid=`id -u || echo unknown` am_gid=`id -g || echo unknown` AC_MSG_CHECKING([whether UID '$am_uid' is supported by ustar format]) if test $am_uid -le $am_max_uid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi AC_MSG_CHECKING([whether GID '$am_gid' is supported by ustar format]) if test $am_gid -le $am_max_gid; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) _am_tools=none fi], [pax], [], [m4_fatal([Unknown tar format])]) AC_MSG_CHECKING([how to create a $1 tar archive]) # Go ahead even if we have the value already cached. We do so because we # need to set the values for the 'am__tar' and 'am__untar' variables. _am_tools=${am_cv_prog_tar_$1-$_am_tools} for _am_tool in $_am_tools; do case $_am_tool in gnutar) for _am_tar in tar gnutar gtar; do AM_RUN_LOG([$_am_tar --version]) && break done am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"' am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"' am__untar="$_am_tar -xf -" ;; plaintar) # Must skip GNU tar: if it does not support --format= it doesn't create # ustar tarball either. (tar --version) >/dev/null 2>&1 && continue am__tar='tar chf - "$$tardir"' am__tar_='tar chf - "$tardir"' am__untar='tar xf -' ;; pax) am__tar='pax -L -x $1 -w "$$tardir"' am__tar_='pax -L -x $1 -w "$tardir"' am__untar='pax -r' ;; cpio) am__tar='find "$$tardir" -print | cpio -o -H $1 -L' am__tar_='find "$tardir" -print | cpio -o -H $1 -L' am__untar='cpio -i -H $1 -d' ;; none) am__tar=false am__tar_=false am__untar=false ;; esac # If the value was cached, stop now. We just wanted to have am__tar # and am__untar set. test -n "${am_cv_prog_tar_$1}" && break # tar/untar a dummy directory, and stop if the command works. rm -rf conftest.dir mkdir conftest.dir echo GrepMe > conftest.dir/file AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar]) rm -rf conftest.dir if test -s conftest.tar; then AM_RUN_LOG([$am__untar /dev/null 2>&1 && break fi done rm -rf conftest.dir AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool]) AC_MSG_RESULT([$am_cv_prog_tar_$1])]) AC_SUBST([am__tar]) AC_SUBST([am__untar]) ]) # _AM_PROG_TAR netmask-2.4.4/autogen000077500000000000000000000001051342463464300145600ustar00rootroot00000000000000#! /bin/sh exec ${AUTORECONF-autoreconf} --install --symlink --force netmask-2.4.4/configure.ac000066400000000000000000000010711342463464300154610ustar00rootroot00000000000000dnl Process this file with autoconf to produce a configure script. AC_INIT([netmask], [2.4.4]) AC_CONFIG_SRCDIR([main.c]) AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE([foreign]) dnl Checks for programs. : ${CFLAGS='-Wall -g -O3'} AC_PROG_CC AC_PROG_AWK AC_PROG_INSTALL AC_PROG_LN_S dnl Checks for libraries. dnl Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS(syslog.h) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST dnl Checks for library functions. AC_FUNC_VPRINTF AC_CHECK_FUNCS(strerror strtoul) AC_OUTPUT(Makefile) netmask-2.4.4/debian/000077500000000000000000000000001342463464300144165ustar00rootroot00000000000000netmask-2.4.4/debian/changelog000066400000000000000000000037721342463464300163010ustar00rootroot00000000000000netmask (2.3.10) unstable; urgency=low * debian/rules - Correct debian-rules-ignores-make-clean-error lintian warning. * debian/control - Bump debian standards version to 3.7.3 (No changes) * debian/copyright - Rewrite the Copyright notice. -- Luis Uribe Sat, 05 Jul 2008 00:52:37 -0500 netmask (2.3.9) unstable; urgency=low * New maintainer (Closes: #389664) * debian/rules Remove commented dh_* commands -- Luis Uribe Fri, 23 Feb 2007 11:59:47 -0500 netmask (2.3.8) unstable; urgency=low * QA upload. * Set maintainer to QA Group; Orphaned: #389664 * Fix spelling mistake in description (Closes: #390063) * Fix override disparity (set Section: net) * Conforms with latest Standards Version 3.7.2 -- Michael Ablassmeier Tue, 10 Oct 2006 11:27:55 +0200 netmask (2.3.7) unstable; urgency=low * Repaired dotted quad broadcast and single mask (closes: #212674) -- Robert Stone Thu, 25 Sep 2003 14:01:55 -0700 netmask (2.3.6) unstable; urgency=low * Debian policy compliance updates. -- Robert Stone Thu, 3 Apr 2003 13:51:53 -0800 netmask (2.3.5) unstable; urgency=low * Fixed typo in description (closes: #94632) * Add build-dependencies, including texinfo (closes: #111181). -- Robert Stone Thu, 14 Feb 2002 11:08:14 -0800 netmask (2.3.4) unstable; urgency=low * Bugfix: infodoc install cleanup. (closes: #69210) * Bugfix: circular list state hang. -- Robert Stone Wed, 30 Aug 2000 13:46:23 -0700 netmask (2.3.3) unstable frozen; urgency=low * Bugfix: dublicate entry addition segfault -- Robert Stone Wed, 1 Mar 2000 10:29:28 -0800 netmask (2.3.2) unstable; urgency=low * Debian packaging cleanup. -- Robert Stone Fri, 5 Nov 1999 11:18:23 -0800 netmask (2.3.1) unstable; urgency=low * Initial Release. -- Robert Stone Mon, 30 Aug 1999 20:36:48 -0700 netmask-2.4.4/debian/compat000066400000000000000000000000021342463464300156140ustar00rootroot000000000000004 netmask-2.4.4/debian/control000066400000000000000000000010351342463464300160200ustar00rootroot00000000000000Source: netmask Section: net Priority: optional Maintainer: Luis Uribe Build-Depends: debhelper (>> 4.0.0) Standards-Version: 3.8.0 Package: netmask Architecture: any Depends: ${shlibs:Depends} Description: helps determine network masks This is a tiny program handy if you work with firewalls or routers occasionally (possibly using this as a helper for shell scripts). It can determine the smallest set of network masks to specify a range of hosts. It can also convert between common IP netmask and address formats. netmask-2.4.4/debian/copyright000066400000000000000000000013241342463464300163510ustar00rootroot00000000000000Netmask was written and debianized by Robert Stone . License: Copyright 1999 by Robert Stone This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. On Debian systems, the complete text of the GNU General Public License can be found in `/usr/share/common-licenses/GPL'. netmask-2.4.4/debian/docs000066400000000000000000000000071342463464300152660ustar00rootroot00000000000000README netmask-2.4.4/debian/rules000077500000000000000000000034371342463464300155050ustar00rootroot00000000000000#!/usr/bin/make -f # Sample debian/rules that uses debhelper. # GNU copyright 1997 to 1999 by Joey Hess. # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 # These are used for cross-compiling and for saving the configure script # from having to guess our platform (since we know it already) DEB_HOST_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE) DEB_BUILD_GNU_TYPE ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE) CFLAGS = -Wall -g ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) CFLAGS += -O0 else CFLAGS += -O2 endif ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS))) INSTALL_PROGRAM += -s endif config.status: configure dh_testdir ./configure --host=$(DEB_HOST_GNU_TYPE) --build=$(DEB_BUILD_GNU_TYPE) --prefix=/usr --mandir=\$${prefix}/share/man --infodir=\$${prefix}/share/info build: build-stamp build-stamp: config.status dh_testdir $(MAKE) touch build-stamp clean: dh_testdir dh_testroot rm -f build-stamp [ ! -f Makefile ] || $(MAKE) distclean ifneq "$(wildcard /usr/share/misc/config.sub)" "" cp -f /usr/share/misc/config.sub config.sub endif ifneq "$(wildcard /usr/share/misc/config.guess)" "" cp -f /usr/share/misc/config.guess config.guess endif dh_clean install: build dh_testdir dh_testroot dh_clean -k dh_installdirs $(MAKE) install DESTDIR=$(CURDIR)/debian/netmask # Build architecture-independent files here. binary-indep: build install # We have nothing to do by default. # Build architecture-dependent files here. binary-arch: build install dh_testdir dh_testroot dh_installchangelogs dh_installdocs dh_installman dh_link dh_strip dh_compress dh_fixperms dh_installdeb dh_shlibdeps dh_gencontrol dh_md5sums dh_builddeb binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary install netmask-2.4.4/errors.c000066400000000000000000000053521342463464300146610ustar00rootroot00000000000000/* errors.c -- error message handlers. Copyright (C) 1998 Robert Stone This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include #include "errors.h" #include "config.h" /* compatibility section */ #ifdef HAVE_SYSLOG_H # include #else /* HAVE_SYSLOG_H */ #warning no syslog facility? Errors will go to stderr. # define syslog(x,y,z) # define LOG_DEBUG 7 # define LOG_WARNING 4 # define LOG_ERR 3 #endif #ifndef HAVE_VPRINTF #error no vprintf? not ANSI C3.159-1989 (``ANSI C'') compliant? #endif #ifndef HAVE_STRERROR #define strerror(x) "system error" #endif /* end compatibility section */ static char *progname = NULL; static int show_status = 0; static int use_syslog = 0; static int message(int, const char *); int initerrors(char *pn, int type, int stat) { #ifdef HAVE_SYSLOG_H if(type == 0 || type == 1) use_syslog = type; #endif /* HAVE_SYSLOG_H */ if(pn != NULL) progname = pn; if(stat == 0 || stat == 1) show_status = stat; return(0); } int status(const char *fmt, ...) { static char buf[1024]; va_list args; if(!show_status) return(0); va_start(args, fmt); vsnprintf(buf, sizeof(buf), fmt, args); va_end(args); return(message(LOG_DEBUG, buf)); } int warn(const char *fmt, ...) { static char buf[1024]; va_list args; va_start(args, fmt); vsnprintf(buf, sizeof(buf), fmt, args); va_end(args); return(message(LOG_WARNING, buf)); } int panic(const char *fmt, ...) { static char buf[1024]; va_list args; va_start(args, fmt); vsnprintf(buf, sizeof(buf), fmt, args); va_end(args); message(LOG_ERR, buf); exit(1); } int message(int priority, const char *msg) { char buf[1024]; /* only handle errno if this is not an informational message */ if(errno && priority < 5) { snprintf(buf, sizeof(buf), "%s: %s", msg, strerror(errno)); errno = 0; } else strcpy(buf, msg); if(use_syslog) syslog(priority, "%s", buf); else fprintf(stderr, "%s: %s\n", progname, buf); return(0); } netmask-2.4.4/errors.h000066400000000000000000000031261342463464300146630ustar00rootroot00000000000000/* errors.h -- error message handlers. Copyright (C) 1998 Robert Stone This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #ifndef _HAVE_ERRORS_H #define _HAVE_ERRORS_H /* call initerrors before using these other functions * * these functions seem pretty straightforward to me, the messaging * functions take sprintf formatted strings and have a limit of * 1024 byte long error messages. * progname should be set to argv[0] * if progname is NULL, it is unchanged * type == 0 for stderr * type == 1 for syslog * otherwise type is unchanged * stat == 0 to skip status reporting * stat == 1 to print status messages * otherwise stat is unchanged * defaults: progname = NULL, type = 0, stat = 0 */ int initerrors(char *progname, int type, int stat); int status(const char *fmt, ...); /* print a status message */ int warn(const char *fmt, ...); /* print a warning message */ int panic(const char *fmt, ...); /* print an error and exit */ #endif netmask-2.4.4/getmask000077500000000000000000000013651342463464300145620ustar00rootroot00000000000000#!/usr/bin/perl #------------------------------------------------------------------------------- sub bitmask { local ($low,$high,$top)=(@_); return if($low>$high); # get highest bit needed for calculation if($top eq ""){ for($top=1;$top<$high;$top*=2){} } for(local $i=$top;$i>=1;$i/=2) { for(local $j=0;$j<=$top;$j+=$i) { if($j>=$low&&$j+$i-1<=$high) { return(&bitmask($low,$j-1,$top), "$j-". ( $j + ( $i - 1 ) ) ."/$i", &bitmask($j+$i,$high,$top)); } } } } for(@ARGV) { /^[0-9]+-[0-9]+$/ && do { @a=split("-",$_); if($a[0]>$a[1]) { warn "first number must be smaller in a sequence\n"; next; } print "[$a[0]-$a[1]]\n"; print " ".join("\n ",&bitmask(@a))."\n"; next; }; warn "\"$_\" not expected\n"; } netmask-2.4.4/gpl.texi000066400000000000000000000436511342463464300146620ustar00rootroot00000000000000@setfilename gpl.info @unnumbered GNU GENERAL PUBLIC LICENSE @center Version 2, June 1991 @display Copyright @copyright{} 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @end display @unnumberedsec Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software---to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. @iftex @unnumberedsec TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION @end iftex @ifinfo @center TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION @end ifinfo @enumerate @item This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The ``Program'', below, refers to any such program or work, and a ``work based on the Program'' means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term ``modification''.) Each licensee is addressed as ``you''. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. @item You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. @item You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: @enumerate a @item You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. @item You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. @item If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) @end enumerate These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. @item You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: @enumerate a @item Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, @item Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, @item Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) @end enumerate The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. @item You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. @item You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. @item Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. @item If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. @item If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. @item The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and ``any later version'', you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. @item If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. @iftex @heading NO WARRANTY @end iftex @ifinfo @center NO WARRANTY @end ifinfo @item BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM ``AS IS'' WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. @item IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. @end enumerate @iftex @heading END OF TERMS AND CONDITIONS @end iftex @ifinfo @center END OF TERMS AND CONDITIONS @end ifinfo @page @unnumberedsec How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the ``copyright'' line and a pointer to where the full notice is found. @smallexample @var{one line to give the program's name and an idea of what it does.} Copyright (C) 19@var{yy} @var{name of author} This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. @end smallexample Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: @smallexample Gnomovision version 69, Copyright (C) 19@var{yy} @var{name of author} Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. @end smallexample The hypothetical commands @samp{show w} and @samp{show c} should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than @samp{show w} and @samp{show c}; they could even be mouse-clicks or menu items---whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a ``copyright disclaimer'' for the program, if necessary. Here is a sample; alter the names: @smallexample @group Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. @var{signature of Ty Coon}, 1 April 1989 Ty Coon, President of Vice @end group @end smallexample This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. netmask-2.4.4/main.c000066400000000000000000000265511342463464300142750ustar00rootroot00000000000000/* main.c - a netmask generator * * Copyright (c) 2013 Robert Stone , * Tom Lear This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include #include #include #include #include #include #include #include #include "netmask.h" #include "errors.h" #include "config.h" struct addrmask { u_int32_t neta; u_int32_t mask; struct addrmask *next; struct addrmask *prev; }; struct option longopts[] = { { "version", 0, 0, 'v' }, { "help", 0, 0, 'h' }, { "debug", 0, 0, 'd' }, { "standard", 0, 0, 's' }, { "cidr", 0, 0, 'c' }, { "cisco", 0, 0, 'i' }, { "range", 0, 0, 'r' }, { "hex", 0, 0, 'x' }, { "octal", 0, 0, 'o' }, { "binary", 0, 0, 'b' }, { "nodns", 0, 0, 'n' }, { "files", 0, 0, 'f' }, // { "max", 1, 0, 'M' }, // { "min", 1, 0, 'm' }, { NULL, 0, 0, 0 } }; typedef enum { OUT_STD, OUT_CIDR, OUT_CISCO, OUT_RANGE, OUT_HEX, OUT_OCTAL, OUT_BINARY } output_t; char version[] = "netmask, version "VERSION; char vversion[] = __DATE__" "__TIME__; char usage[] = "Try `%s --help' for more information.\n"; char *progname = NULL; void disp_std(int domain, nm_addr *n, nm_addr *m) { char nb[INET6_ADDRSTRLEN + 1], mb[INET6_ADDRSTRLEN + 1]; inet_ntop(domain, n, nb, INET6_ADDRSTRLEN); inet_ntop(domain, m, mb, INET6_ADDRSTRLEN); printf("%15s/%-15s\n", nb, mb); } static void disp_cidr(int domain, nm_addr *n, nm_addr *m) { char nb[INET6_ADDRSTRLEN + 1]; int cidr = 0; inet_ntop(domain, n, nb, INET6_ADDRSTRLEN); if(domain == AF_INET) { uint32_t mask; for(mask = ntohl(m->s.s_addr); mask; mask <<= 1) cidr++; } else { uint8_t i, c; for(i = 0; i < 16; i++) for(c = m->s6.s6_addr[i]; c; c <<= 1) cidr++; } printf("%15s/%d\n", nb, cidr); } static void disp_cisco(int domain, nm_addr *n, nm_addr *m) { char nb[INET6_ADDRSTRLEN + 1], mb[INET6_ADDRSTRLEN + 1]; int i; if(domain == AF_INET6) for(i = 0; i < 16; i++) m->s6.s6_addr[i] = ~m->s6.s6_addr[i]; else m->s.s_addr = ~m->s.s_addr; inet_ntop(domain, n, nb, INET6_ADDRSTRLEN); inet_ntop(domain, m, mb, INET6_ADDRSTRLEN); printf("%15s %-15s\n", nb, mb); } static void range_num(char *dst, uint8_t *src) { /* roughly we must convert a 17 digit base 256 number * to a 39 digit base 10 number. */ char digits[41] = { 0 }; /* ceil(17 * log(256) / log(10)) == 41 */ int i, j, z, overflow; for(i = 0; i < 17; i++) { overflow = 0; for(j = sizeof(digits) - 1; j >= 0; j--) { int tmp = digits[j] * 256 + overflow; digits[j] = tmp % 10; overflow = tmp / 10; } overflow = src[i]; for(j = sizeof(digits) - 1; j >= 0; j--) { if(!overflow) break; int sum = digits[j] + overflow; digits[j] = sum % 10; overflow = sum / 10; } } /* convert to string */ z = 1; for(i = 0; i < sizeof(digits); i++) { if(z && digits[i] == 0) continue; z = 0; *dst++ = '0' + digits[i]; } /* special case for zero */ if(z) *dst++ = '0'; *dst++ = '\0'; } static void disp_range(int domain, nm_addr *n, nm_addr *m) { char nb[INET6_ADDRSTRLEN + 1], mb[INET6_ADDRSTRLEN + 1], ns[42]; uint64_t over = 1; uint8_t ra[17] = { 0 }; int i; if(domain == AF_INET6) { for(i = 15; i >= 0; i--) { m->s6.s6_addr[i] = ~m->s6.s6_addr[i]; over += m->s6.s6_addr[i]; m->s6.s6_addr[i] |= n->s6.s6_addr[i]; ra[i + 1] = over & 0xff; over >>= 8; } ra[0] = over; } else { over += htonl(~m->s.s_addr); for(i = 16; i > 11; i--) { ra[i] = over & 0xff; over >>= 8; } m->s.s_addr = n->s.s_addr | ~m->s.s_addr; } range_num(ns, ra); inet_ntop(domain, n, nb, INET6_ADDRSTRLEN); inet_ntop(domain, m, mb, INET6_ADDRSTRLEN); printf("%15s-%-15s (%s)\n", nb, mb, ns); } static void disp_hex(int domain, nm_addr *n, nm_addr *m) { if(domain == AF_INET) { printf("0x%08x/0x%08x\n", htonl(n->s.s_addr), htonl(m->s.s_addr)); } else { printf("0x%02x%02x%02x%02x%02x%02x%02x%02x" "%02x%02x%02x%02x%02x%02x%02x%02x/" "0x%02x%02x%02x%02x%02x%02x%02x%02x" "%02x%02x%02x%02x%02x%02x%02x%02x\n", n->s6.s6_addr[0], n->s6.s6_addr[1], n->s6.s6_addr[2], n->s6.s6_addr[3], n->s6.s6_addr[4], n->s6.s6_addr[5], n->s6.s6_addr[6], n->s6.s6_addr[7], n->s6.s6_addr[8], n->s6.s6_addr[9], n->s6.s6_addr[10], n->s6.s6_addr[11], n->s6.s6_addr[12], n->s6.s6_addr[13], n->s6.s6_addr[14], n->s6.s6_addr[15], m->s6.s6_addr[0], m->s6.s6_addr[1], m->s6.s6_addr[2], m->s6.s6_addr[3], m->s6.s6_addr[4], m->s6.s6_addr[5], m->s6.s6_addr[6], m->s6.s6_addr[7], m->s6.s6_addr[8], m->s6.s6_addr[9], m->s6.s6_addr[10], m->s6.s6_addr[11], m->s6.s6_addr[12], m->s6.s6_addr[13], m->s6.s6_addr[14], m->s6.s6_addr[15]); } } static void disp_octal(int domain, nm_addr *n, nm_addr *m) { if(domain == AF_INET) { printf("0%10o/0%10o\n", htonl(n->s.s_addr), htonl(m->s.s_addr)); } else { printf("0%03x%03x%03x%03x%03x%03x%03x%03x" "%03x%03x%03x%03x%03x%03x%03x%03x/" "0%03x%03x%03x%03x%03x%03x%03x%03x" "%03x%03x%03x%03x%03x%03x%03x%03x\n", n->s6.s6_addr[0], n->s6.s6_addr[1], n->s6.s6_addr[2], n->s6.s6_addr[3], n->s6.s6_addr[4], n->s6.s6_addr[5], n->s6.s6_addr[6], n->s6.s6_addr[7], n->s6.s6_addr[8], n->s6.s6_addr[9], n->s6.s6_addr[10], n->s6.s6_addr[11], n->s6.s6_addr[12], n->s6.s6_addr[13], n->s6.s6_addr[14], n->s6.s6_addr[15], m->s6.s6_addr[0], m->s6.s6_addr[1], m->s6.s6_addr[2], m->s6.s6_addr[3], m->s6.s6_addr[4], m->s6.s6_addr[5], m->s6.s6_addr[6], m->s6.s6_addr[7], m->s6.s6_addr[8], m->s6.s6_addr[9], m->s6.s6_addr[10], m->s6.s6_addr[11], m->s6.s6_addr[12], m->s6.s6_addr[13], m->s6.s6_addr[14], m->s6.s6_addr[15]); } } static void bin_str(char *dst, uint8_t *src, int len) { int i; int j; for(i = 0; i < len; i++) { for(j = 7; j >= 0; j--) { *dst++ = src[i] & (1 << j) ? '1' : '0'; } *dst++ = ' '; } /* replace the last space with a string terminator */ dst[-1] = '\0'; } static void disp_binary(int domain, nm_addr *n, nm_addr *m) { char ns[144], ms[144]; uint8_t bits[16]; if(domain == AF_INET) { unsigned long l; l = htonl(n->s.s_addr); bits[0] = 0xff & (l >> 24); bits[1] = 0xff & (l >> 16); bits[2] = 0xff & (l >> 8); bits[3] = 0xff & (l >> 0); bin_str(ns, bits, 4); l = htonl(m->s.s_addr); bits[0] = 0xff & (l >> 24); bits[1] = 0xff & (l >> 16); bits[2] = 0xff & (l >> 8); bits[3] = 0xff & (l >> 0); bin_str(ms, bits, 4); } else { bin_str(ns, n->s6.s6_addr, 16); bin_str(ms, m->s6.s6_addr, 16); } printf("%s / %s\n", ns, ms); } void display(NM nm, output_t style) { void (*disp)(int, nm_addr *, nm_addr *) = NULL; switch(style) { case OUT_STD: disp = &disp_std; break; case OUT_CIDR: disp = &disp_cidr; break; case OUT_CISCO: disp = &disp_cisco; break; case OUT_RANGE: disp = &disp_range; break; case OUT_HEX: disp = &disp_hex; break; case OUT_OCTAL: disp = &disp_octal; break; case OUT_BINARY: disp = &disp_binary; break; default: return; } nm_walk(nm, disp); } static inline void add_entry(NM *nm, const char *str, int dns) { NM new = nm_new_str(str, dns); if(new) *nm = nm_merge(*nm, new); else warn("parse error \"%s\"", str); } int main(int argc, char *argv[]) { int optc, h = 0, v = 0, f = 0, dns = NM_USE_DNS, lose = 0; // u_int32_t min = ~0, max = 0; output_t output = OUT_CIDR; progname = argv[0]; initerrors(progname, 0, 0); /* stderr, nostatus */ while((optc = getopt_long(argc, argv, "shoxdrvbincM:m:f", longopts, (int *) NULL)) != EOF) switch(optc) { case 'h': h = 1; break; case 'v': v++; break; case 'n': dns = 0; break; case 'f': f = 1; break; // case 'M': max = mspectou32(optarg); break; // case 'm': min = mspectou32(optarg); break; case 'd': initerrors(NULL, -1, 1); /* showstatus */ break; case 's': output = OUT_STD; break; case 'c': output = OUT_CIDR; break; case 'i': output = OUT_CISCO; break; case 'r': output = OUT_RANGE; break; case 'x': output = OUT_HEX; break; case 'o': output = OUT_OCTAL; break; case 'b': output = OUT_BINARY; break; default: lose = 1; break; } if(v) { if(v == 1) fprintf(stderr, "%s\n", version); else fprintf(stderr, "%s, %s\n", version, vversion); if(!h) exit(0); } if(h) { fprintf(stderr, "This is netmask, an address netmask generation utility\n" "Usage: %s spec [spec ...]\n" " -h, --help\t\t\tPrint a summary of the options\n" " -v, --version\t\t\tPrint the version number\n" " -d, --debug\t\t\tPrint status/progress information\n" " -s, --standard\t\tOutput address/netmask pairs\n" " -c, --cidr\t\t\tOutput CIDR format address lists\n" " -i, --cisco\t\t\tOutput Cisco style address lists\n" " -r, --range\t\t\tOutput ip address ranges\n" " -x, --hex\t\t\tOutput address/netmask pairs in hex\n" " -o, --octal\t\t\tOutput address/netmask pairs in octal\n" " -b, --binary\t\t\tOutput address/netmask pairs in binary\n" " -n, --nodns\t\t\tDisable DNS lookups for addresses\n" " -f, --files\t\t\tTreat arguments as input files\n" // " -M, --max mask\t\tLimit maximum mask size\n" // " -m, --min mask\t\tLimit minimum mask size (drop small ranges)\n" "Definitions:\n" " a spec can be any of:\n" " address\n" " address:address\n" " address:+address\n" " address/mask\n" " an address can be any of:\n" " N\t\tdecimal number\n" " 0N\t\toctal number\n" " 0xN\t\thex number\n" " N.N.N.N\tdotted quad\n" " hostname\tdns domain name\n" " a mask is the number of bits set to one from the left\n", progname); exit(0); } if(lose || optind == argc) { fprintf(stderr, usage, progname); exit(1); } NM nm = NULL; for(;optind < argc; optind++) { if(f) { char buf[1024]; FILE *fp = strncmp(argv[optind], "-", 2) ? fopen(argv[optind], "r") : stdin; if(!fp) { fprintf(stderr, "fopen: %s: %s\n", argv[optind], strerror(errno)); continue; } while(fscanf(fp, "%1023s", buf) != EOF) add_entry(&nm, buf, dns); } else add_entry(&nm, argv[optind], dns); } display(nm, output); return(0); } netmask-2.4.4/netmask.1000066400000000000000000000056061342463464300147270ustar00rootroot00000000000000.TH NETMASK 1 "15 May 1999" "Debian Project" "Debian Linux" .SH NAME netmask \- a netmask generation and conversion program .SH SYNOPSIS .B netmask .RI "[ " options " ] " spec " [ " spec " ... ]" .SH DESCRIPTION This program accepts and produces a variety of common network address and netmask formats. Not only can it convert address and netmask notations, but it will optimize the masks to generate the smallest list of rules. This is very handy if you've ever configured a firewall or router and some nasty network administrator before you decided that base 10 numbers were good places to start and end groups of machines. .SH OPTIONS .TP .BR "\-h" ", " "\-\-help" Print a summary of the options .TP .BR "\-v" ", " "\-\-version" Print the version number .TP .BR "\-d" ", " "\-\-debug" Print status/progress information .TP .BR "\-s" ", " "\-\-standard" Output address/netmask pairs .TP .BR "\-c" ", " "\-\-cidr" Output CIDR format address lists .TP .BR "\-i" ", " "\-\-cisco" Output Cisco style address lists .TP .BR "\-r" ", " "\-\-range" Output ip address ranges .TP .BR "\-x" ", " "\-\-hex" Output address/netmask pairs in hex .TP .BR "\-o" ", " "\-\-octal" Output address/netmask pairs in octal .TP .BR "\-b" ", " "\-\-binary" Output address/netmask pairs in binary .TP .BR "\-n" ", " "\-\-nodns" Disable DNS lookups for addresses .SH DEFINITIONS .RI "A " spec " is an address specification, it can look like:" .TP .I address One address. .TP .IR address1 : address2 .RI "All addresses from " address1 " to " address2 . .TP .IR address1 :+ address2 .RI "All addresses from " address1 " to " address1 + address2 . .TP .IR address / mask .RI "A group starting at " address " spanning " mask . .PP .RI "An " address " is an internet network address, it can look like:" .TP .I ftp.gnu.org An internet hostname. .TP .I 209.81.8.252 A standard dotted quad internet address notation. .TP .I 100 A decimal number (100 in this case). .TP .I 0100 An octal number preceded by "0" (64 in this case). .TP .I 0x100 A hexadecimal number preceded by "0x" (256 in this case). .PP .RI "A " mask " is a network mask, it can look like:" .TP .I 255.255.224.0 .RB "A dotted quad netmask (" netmask " will complain if it is not a" valid netmask). .TP .I 0.0.31.255 A Cisco style inverse netmask (with the same checks). .TP .I 8 The number of bits set to one from the left (CIDR notation). .TP .I 010 The number of bits set to one from the left in octal. .TP .I 0x10 The number of bits set to one from the left in hexadecimal. .SH AUTHOR .IR netmask " was written by Robert Stone. Some algorithm design and" optimization was provided by Tom Lear. This manual page was written by Robert Stone. .SH BUGS Let me know if you find any. This man page is a bit more simplistic than I'd like, but I've forgotten most of the groff I once knew. .SH SEE ALSO .BR ipchains (1), .BR ipfwadm (8), .BR netstat (8), .BR route (8), .BR routed (8), .BR gated (8), .BR tcpd (8) netmask-2.4.4/netmask.c000066400000000000000000000415601342463464300150100ustar00rootroot00000000000000/* netmask.c - a netmask generator * * Copyright (c) 2013 Robert Stone , * Tom Lear This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ #include #include #include #include "errors.h" #include "netmask.h" typedef struct { uint64_t h; uint64_t l; } u128_t; static inline u128_t u128_add(u128_t x, u128_t y, int *carry) { /* this relies on the sum being greater than both terms of the * addition, otherwise an overflow must have occurred. */ u128_t rv; rv.l = x.l + y.l; if(rv.l < x.l || rv.l < y.l) rv.h = 1; else rv.h = 0; rv.h += x.h + y.h; if(carry) { if(rv.h < x.h || rv.h < y.h) *carry = 1; else *carry = 0; } return rv; } static inline u128_t u128_and(u128_t x, u128_t y) { u128_t rv; rv.h = x.h & y.h; rv.l = x.l & y.l; return rv; } static inline u128_t u128_or(u128_t x, u128_t y) { u128_t rv; rv.h = x.h | y.h; rv.l = x.l | y.l; return rv; } static inline u128_t u128_xor(u128_t x, u128_t y) { u128_t rv; rv.h = x.h ^ y.h; rv.l = x.l ^ y.l; return rv; } static inline u128_t u128_neg(u128_t v) { u128_t rv; rv.h = ~v.h; rv.l = ~v.l; return rv; } static inline u128_t u128_lsh(u128_t v, uint8_t d) { u128_t rv; rv.h = v.h << 1 | v.l >> 63; rv.l = v.l << 1; return rv; } static inline int u128_cmp(u128_t x, u128_t y) { /* return -1, 0, 1 on sort order */ if(x.h < y.h) return -1; if(x.h > y.h) return 1; if(x.l < y.l) return -1; if(x.l > y.l) return 1; return 0; } static inline u128_t u128_of_s6(struct in6_addr *s6) { u128_t rv; rv.h = (((uint64_t)s6->s6_addr[0]) << 56) | (((uint64_t)s6->s6_addr[1]) << 48) | (((uint64_t)s6->s6_addr[2]) << 40) | (((uint64_t)s6->s6_addr[3]) << 32) | (((uint64_t)s6->s6_addr[4]) << 24) | (((uint64_t)s6->s6_addr[5]) << 16) | (((uint64_t)s6->s6_addr[6]) << 8) | (((uint64_t)s6->s6_addr[7]) << 0); rv.l = (((uint64_t)s6->s6_addr[8]) << 56) | (((uint64_t)s6->s6_addr[9]) << 48) | (((uint64_t)s6->s6_addr[10]) << 40) | (((uint64_t)s6->s6_addr[11]) << 32) | (((uint64_t)s6->s6_addr[12]) << 24) | (((uint64_t)s6->s6_addr[13]) << 16) | (((uint64_t)s6->s6_addr[14]) << 8) | (((uint64_t)s6->s6_addr[15]) << 0); return rv; } static inline struct in6_addr s6_of_u128(u128_t v) { struct in6_addr s6; s6.s6_addr[0] = 0xff & (v.h >> 56); s6.s6_addr[1] = 0xff & (v.h >> 48); s6.s6_addr[2] = 0xff & (v.h >> 40); s6.s6_addr[3] = 0xff & (v.h >> 32); s6.s6_addr[4] = 0xff & (v.h >> 24); s6.s6_addr[5] = 0xff & (v.h >> 16); s6.s6_addr[6] = 0xff & (v.h >> 8); s6.s6_addr[7] = 0xff & (v.h >> 0); s6.s6_addr[8] = 0xff & (v.l >> 56); s6.s6_addr[9] = 0xff & (v.l >> 48); s6.s6_addr[10] = 0xff & (v.l >> 40); s6.s6_addr[11] = 0xff & (v.l >> 32); s6.s6_addr[12] = 0xff & (v.l >> 24); s6.s6_addr[13] = 0xff & (v.l >> 16); s6.s6_addr[14] = 0xff & (v.l >> 8); s6.s6_addr[15] = 0xff & (v.l >> 0); return s6; } static inline u128_t u128_lit(uint64_t h, uint64_t l) { u128_t rv; rv.h = h; rv.l = l; return rv; } static inline u128_t u128_cidr(uint8_t n) { u128_t rv; if(n <= 0) { rv.h = 0; rv.l = 0; } else if(n <= 64) { rv.h = ~0ULL << (64 - n); rv.l = 0; } else if(n <= 128) { rv.h = ~0ULL; rv.l = ~0ULL << (128 - n); } else { rv.h = ~0ULL; rv.l = ~0ULL; } return rv; } static inline int cidr(u128_t u) { uint64_t v; int n = 0; for(v = u.l; v > 0; v <<= 1) n++; for(v = u.h; v > 0; v <<= 1) n++; return n; } static inline int chkmask(u128_t v) { /* this is sort of specialized */ int i; u128_t m = u128_lit(~0ULL, ~0ULL); for(i = 0; i < 129; i++) { if(u128_cmp(v, m) == 0) return 1; m = u128_lsh(m, 1); } return 0; } struct nm { u128_t neta; u128_t mask; int domain; NM next; }; NM nm_new_v4(struct in_addr *s) { NM self; union { struct in6_addr s6; uint32_t u32[4]; } v; v.u32[0] = 0; v.u32[1] = 0; v.u32[2] = htonl(0x0000ffff); v.u32[3] = s->s_addr; self = nm_new_v6(&v.s6); self->domain = AF_INET; return self; } NM nm_new_v6(struct in6_addr *s6) { NM self = (NM)malloc(sizeof(struct nm)); self->neta = u128_of_s6(s6); self->mask = u128_cidr(128); self->domain = AF_INET6; self->next = (NM)0; return self; } /* is "a" a subset of "b"? */ static inline int subset_of(NM a, NM b) { return( u128_cmp(a->mask, b->mask) >= 0 && u128_cmp(b->neta, u128_and(a->neta, b->mask)) == 0 ); } /* are "a" and "b" a joinable pair? */ static inline int joinable_pair(NM a, NM b) { return( /* nets have the same mask */ u128_cmp(a->mask, b->mask) == 0 && /* but are distinct */ u128_cmp(a->neta, b->neta) != 0 && /* and would both be subsets of the same mask << 1 */ u128_cmp(u128_lit(0, 0), u128_and( u128_xor(a->neta, b->neta), u128_lsh(a->mask, 1) )) == 0 ); } /* this is slightly complicated because an NM can outgrow it's initial * v4 state, but if it doesn't, we want to retain the fact that it * was and remained v4. */ static inline int is_v4(NM self) { struct nm v4map; v4map.neta = u128_lit(0, 0x0000ffff00000000ULL); v4map.mask = u128_cidr(96); return(self->domain == AF_INET && subset_of(self, &v4map)); } NM nm_new_ai(struct addrinfo *ai) { NM self = NULL; struct addrinfo *cur; for(cur = ai; cur; cur = cur->ai_next) { switch(cur->ai_family) { case AF_INET: self = nm_merge(self, nm_new_v4(&( (struct sockaddr_in *)cur->ai_addr )->sin_addr)); break; case AF_INET6: self = nm_merge(self, nm_new_v6(&( (struct sockaddr_in6 *)cur->ai_addr )->sin6_addr)); break; default: panic("unknown ai_family %d in struct addrinfo", cur->ai_family); } } return self; } static inline NM parse_addr(const char *str, int flags) { struct in6_addr s6; struct in_addr s; if(inet_pton(AF_INET6, str, &s6)) return nm_new_v6(&s6); if(inet_aton(str, &s)) return nm_new_v4(&s); if(NM_USE_DNS & flags) { struct addrinfo in, *out; memset(&in, 0, sizeof(struct addrinfo)); in.ai_family = AF_UNSPEC; if(getaddrinfo(str, NULL, &in, &out) == 0) { NM self = nm_new_ai(out); freeaddrinfo(out); return self; } } return NULL; } static inline int parse_mask(NM self, const char *str, int flags) { char *p; uint32_t v; struct in6_addr s6; struct in_addr s; v = strtoul(str, &p, 0); if(*p == '\0') { /* read it as a CIDR value */ if(is_v4(self)) { if(v > 32) return 0; v += 96; } else { if(v > 128) return 0; } self->mask = u128_cidr(v); } else if(inet_pton(AF_INET6, str, &s6)) { self->mask = u128_of_s6(&s6); /* flip cisco style masks */ if(u128_cmp( u128_lit(0, 0), u128_and( u128_lit(1ULL << 63, 1), u128_xor(u128_lit(0, 1), self->mask) ) ) == 0) { self->mask = u128_neg(self->mask); } self->domain = AF_INET6; } else if(self->domain == AF_INET && inet_aton(str, &s)) { v = htonl(s.s_addr); if(v & 1 && ~v >> 31) /* flip cisco style masks */ v = ~v; /* since mask is currently all 1s, mask ^ ~m will * set the low 32. */ self->mask = u128_xor(self->mask, u128_lit(0, ~v)); } else { return 0; } if(!chkmask(self->mask)) return 0; /* apply mask to neta */ self->neta = u128_and(self->neta, self->mask); return 1; } /* widen the mask as much as possible without including addresses below * neta or above max. return one if more ranges are needed to complete * the span or zero if this nm includes max. */ static inline int nm_widen(NM self, u128_t max, u128_t *last) { u128_t mask, neta, bcst; int cmp = u128_cmp(self->neta, max); while(cmp < 0) { /* attempt widening by one bit */ mask = u128_lsh(self->mask, 1); neta = u128_and(self->neta, mask); bcst = u128_or(self->neta, u128_neg(mask)); /* check ranges */ if(u128_cmp(neta, self->neta) < 0) break; cmp = u128_cmp(bcst, max); if(cmp > 0) break; /* successful attempt */ self->mask = mask; *last = bcst; status("widen %016llx %016llx/%d", self->neta.h, self->neta.l, cidr(self->mask)); if(cmp == 0) break; } return cmp; } static inline void nm_order(NM *low, NM *high) { if(u128_cmp((*low)->neta, (*high)->neta) > 0) { NM tmp = *low; *low = *high; *high = tmp; } } /* convert first and last into a list from first to last. (both these * should be single addresses, not lists.) */ static inline NM nm_seq(NM first, NM last) { /* if first is higher than last, swap them (legacy) */ nm_order(&first, &last); NM cur = first; u128_t pos = cur->neta; u128_t one = u128_lit(0, 1); u128_t max = last->neta; int domain = is_v4(first) && is_v4(last) ? AF_INET : AF_INET6; free(last); while(nm_widen(cur, max, &pos)) { cur->next = (NM)malloc(sizeof(struct nm)); cur = cur->next; cur->neta = u128_add(pos, one, NULL); cur->mask = u128_cidr(128); cur->domain = domain; cur->next = NULL; } return first; } NM nm_new_str(const char *str, int flags) { char *p, buf[2048]; NM self; if((p = strchr(str, '/'))) { /* mask separator */ strncpy(buf, str, p - str); buf[p - str] = '\0'; self = parse_addr(buf, flags); if(!self) return NULL; if(!parse_mask(self, p + 1, flags)) { free(self); return NULL; } return self; } else if((p = strchr(str, ','))) { /* new range character */ NM top; int add; strncpy(buf, str, p - str); buf[p - str] = '\0'; self = parse_addr(buf, flags); if(!self) return NULL; if(p[1] == '+') add = 1; else add = 0; top = parse_addr(p + add + 1, flags); if(!top) { free(self); return NULL; } if(add) { int carry; if(is_v4(top)) top->neta.l &= 0xffffffffULL; top->neta = u128_add(self->neta, top->neta, &carry); if(carry) { free(self); free(top); return NULL; } } return nm_seq(self, top); } else if((self = parse_addr(str, flags))) { return self; } else if((p = strchr(str, ':'))) { /* old range character (sloppy) */ NM top; int add; strncpy(buf, str, p - str); buf[p - str] = '\0'; self = parse_addr(buf, flags); if(!self) return NULL; if(p[1] == '+') { add = 1; if(p[2] == '-') { /* this is a pretty special reverse compatibility * situation. N:+-5" would actually emit the range from * N-5 to N because strtoul() hilariously accepts * negative numbers and the original code never detected * overflow and things just happened to work out. */ struct in_addr s; char *endp; uint32_t v = self->neta.l + strtoul(p + 2, &endp, 0); if(*endp == '\0') { s.s_addr = htonl(v); top = nm_new_v4(&s); if(!top) { free(self); return NULL; } return nm_seq(self, top); } } } else { add = 0; } top = parse_addr(p + add + 1, flags); if(!top) { free(self); return NULL; } if(add) { int carry; if(is_v4(top)) top->neta.l &= 0xffffffffULL; top->neta = u128_add(self->neta, top->neta, &carry); if(carry) { free(self); free(top); return NULL; } } return nm_seq(self, top); } else { return NULL; } } NM nm_merge(NM dst, NM src) { /* both lists are ordered and non-overlapping. Knit them into a * single ordered, non-overlapping list. */ NM tmp; NM *pos = &dst; /* double indirect pointer simplifies list insertion logic. */ while(src) { if(*pos == NULL) { /* remains of src go to tail of dst */ tmp = src; src = *pos; *pos = tmp; } else if(subset_of(src, *pos)) { status("found %016llx %016llx/%d a subset of %016llx %016llx/%d", src->neta.h, src->neta.l, cidr(src->mask), (*pos)->neta.h, (*pos)->neta.l, cidr((*pos)->mask)); /* drop src elt on the floor */ if(src->domain != AF_INET) /* may need to promote domain */ (*pos)->domain = src->domain; tmp = src; src = src->next; free(tmp); } else if(subset_of(*pos, src)) { /* src seems larger, merge the other direction instead */ tmp = src; src = *pos; *pos = tmp; } else if(joinable_pair(src, *pos)) { status("joinable %016llx %016llx/%d and %016llx %016llx/%d", src->neta.h, src->neta.l, cidr(src->mask), (*pos)->neta.h, (*pos)->neta.l, cidr((*pos)->mask)); /* pull the dst elt */ tmp = *pos; *pos = (*pos)->next; if(src->domain == AF_INET) src->domain = tmp->domain; free(tmp); /* widen the src elt */ src->mask = u128_lsh(src->mask, 1); src->neta = u128_and(src->neta, src->mask); /* and merge it back into the src tail */ tmp = src->next; src->next = NULL; src = nm_merge(src, tmp); /* now the dst scan needs to start over to find preceding * join candidates. */ pos = &dst; /* TODO: there should be a cheaper way to do this than an * effective double recursion, but the possibility of joins * cascading backwards makes this difficult */ } else if(u128_cmp(src->neta, (*pos)->neta) < 0) { /* src elt goes here in dst list. if top src elt were * spliced into dst, it may duplicate later elts in dst. * swap tails instead because src is well formed. */ tmp = src; src = *pos; *pos = tmp; } else { /* move down the dst list */ pos = &(*pos)->next; } } return dst; } void nm_walk(NM self, void (*cb)(int, nm_addr *, nm_addr *)) { int domain; nm_addr neta, mask; while(self) { neta.s6 = s6_of_u128(self->neta); mask.s6 = s6_of_u128(self->mask); if(is_v4(self)) { domain = AF_INET; neta.s.s_addr = htonl( neta.s6.s6_addr[12] << 24 | neta.s6.s6_addr[13] << 16 | neta.s6.s6_addr[14] << 8 | neta.s6.s6_addr[15] << 0); mask.s.s_addr = htonl( mask.s6.s6_addr[12] << 24 | mask.s6.s6_addr[13] << 16 | mask.s6.s6_addr[14] << 8 | mask.s6.s6_addr[15] << 0); } else { domain = AF_INET6; } cb(domain, &neta, &mask); self = self->next; } } netmask-2.4.4/netmask.h000066400000000000000000000006211342463464300150060ustar00rootroot00000000000000 #include #include typedef struct nm *NM; NM nm_new_v4(struct in_addr *); NM nm_new_v6(struct in6_addr *); NM nm_new_ai(struct addrinfo *); #define NM_USE_DNS 1 NM nm_new_str(const char *, int flags); NM nm_merge(NM, NM); typedef union { struct in6_addr s6; struct in_addr s; } nm_addr; void nm_walk(NM, void (*)(int domain, nm_addr *neta, nm_addr *mask)); netmask-2.4.4/netmask.texi000066400000000000000000000234631342463464300155410ustar00rootroot00000000000000\input texinfo @c -*-texinfo-*- @c %**start of header @setfilename netmask.info @settitle Generating Optimized Network Masks @finalout @setchapternewpage odd @c %**end of header @dircategory General Commands @include version.texi %@set EDITION 2.02 %@set VERSION 2.2 %@set UPDATED 26 May 1999 @ifinfo This file documents the @code{netmask} command for generating terse network masks. Manual adapted from GNU Hello Manual Adaptation Copyright (c) 1999 Robert Stone GNU Hello Manual Copyright (C) 1992, 1993 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. @ignore Permission is granted to process this file through TeX and print the results, provided the printed document carries copying permission notice identical to this one except for the removal of this paragraph (this paragraph not being relevant to the printed manual). @end ignore Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Foundation. @end ifinfo @titlepage @title Mask @subtitle The Network Mask Generation Program @subtitle Edition @value{EDITION}, for Hello Version @value{VERSION} @subtitle @value{UPDATED} @author by Robert Stone @page @vskip 0pt plus 1filll Manual adapted from GNU Hello Manual Adaptation Copyright (c) 1999 Robert Stone GNU Hello Manual Copyright @copyright{} 1992, 1993 Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute modified versions of this manual under the conditions for verbatim copying, provided that the entire resulting derived work is distributed under the terms of a permission notice identical to this one. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for modified versions, except that this permission notice may be stated in a translation approved by the Foundation. @end titlepage @node Top, , , (dir) @ifinfo This file documents the @code{netmask} command for generating terse network masks. @end ifinfo @menu * Instructions:: How to read this manual. * Copying:: How you can copy and share @code{netmask}. * Overview:: Preliminary information. * Sample:: Sample output from @code{netmask}. * Invoking netmask:: How to run @code{netmask}. * Problems:: Reporting bugs. * Concept Index:: Index of concepts. @end menu @node Instructions, Copying, , Top @chapter How to Read This Manual @cindex reading @cindex manual, how to read @cindex how to read To read this manual, begin at the beginning, reading from left to right and top to bottom, until you get to the end. Then stop. You may pause for a beer anywhere in the middle as well, if you wish. (Please note, however, that The King strongly advises against heavy use of prescription pharmaceuticals, based on his extensive personal and professional experience.) @node Copying, Overview, Instructions, Top @include gpl.texi @node Overview, Sample, Copying, Top @chapter Overview @cindex overview The `netmask' program accepts and produces a variety of common network address and netmask formats. Not only can it convert address and netmask notations, but it will optimize the masks to generate the smallest list of rules. This is very handy if you've ever configured a firewall or router and some nasty network administrator before you decided that base 10 numbers were good places to start and end groups of machines. Since I often have trouble even describing the process of generating optimal netmasks to fledgling network administrators, this seemed like a much better solution. I originally had a 32 line perl script to do this using nested for loops, but I found it too slow to deal with real internet addresses, so it only worked well with the last 8 bits. It couldn't merge ranges at all and it also only reported in one format... network address in decimal and the binary negation of the netmask plus one. Today netmask is written in C, and instead of for loops it does a slew of bit manipulation. It also accepts and reports common formats including CIDR, regular address and netmask pairs and Cisco style masks. It allows those netadmins who don't count on their hands in binary to come up with efficient firewalling and routing rules which would otherwise be unavailable to them making their router config files cluttered and their firewalls inefficient. Because it is protected by the GNU General Public License, users are free to share and change it. @code{netmask} was written by Robert Stone. Some algorithm design and optimization was provided by Tom Lear. @node Sample, Invoking netmask, Overview, Top @chapter Sample Output @cindex sample Here are some realistic examples of running @code{netmask}. This is the output of the command @samp{netmask 10.0.0.0,10.0.0.25}: @example 10.0.0.0/28 10.0.0.16/29 10.0.0.24/31 @end example This is the output of the command @samp{netmask 10.1.0.0/16 10.2.0.0/16 10.3.0.0/16}: @example 10.1.0.0/16 10.2.0.0/15 @end example This is the output of the command @samp{netmask --standard 10.0.0.0,+24}: @example 10.0.0.0/255.255.255.240 10.0.0.16/255.255.255.248 10.0.0.24/255.255.255.255 @end example @node Invoking netmask, Problems, Sample, Top @chapter Invoking @code{netmask} @cindex invoking @cindex version @cindex options @cindex usage @cindex help @cindex getting help The format for running the @code{netmask} program is: @example netmask @var{option} @var{spec} [@var{spec} @dots{}] @end example A @var{spec} is an address specification, it can look like: @cindex spec @table @samp @item @var{address} One address. @item @var{address1},@var{address2} All addresses from @var{address1} to @var{address2}. @item @var{address1},+@var{address2} All addresses from @var{address1} to @var{address1} + @var{address2}. @item @var{address}/@var{mask} A group starting at @var{address} spanning @var{mask} @end table An @var{address} is an internet network address, it can look like: @cindex address @table @samp @item ftp.gnu.org An internet hostname. @item 209.81.8.252 A standard dotted quad internet address notation. @item 2001:0db8:0000:0000:0000:ff00:0042:8329 An RFC5952 IPv6 internet address. @item 100 A decimal number (100 in this case). @item 0100 An octal number preceded by "0" (64 in this case). @item 0x100 A hexadecimal number preceded by "0x" (256 in this case). @end table A @var{mask} is a network mask, it can look like: @cindex mask @table @samp @item 255.255.224.0 A dotted quad netmask (@code{netmask} will complain if it is not a valid netmask) @item 0.0.31.255 A Cisco style inverse netmask (with the same checks). @item ffff:ffff:: An RFC5952 IPv6 internet address. (with the same checks) @item 8 CIDR notation (The number of bits set to one from the left). @item 010 Octal CIDR. @item 0x10 hexadecimal CIDR. @end table @code{netmask} supports the following options: @table @samp @item --help @itemx -h Print an informative help message describing the options and then exit. @item --version @itemx -v Print the version number of @code{netmask} on the standard error output and then exit. @item --debug @itemx -d @cindex debug Print status or progress information on stderr. Probably only useful to the author and subject to change at will. @item --standard @itemx -s @cindex standard Formats output as standard address and netmask pairs, such as: @example 10.1.8.128/255.255.255.224 @end example @item --cidr @itemx -c @cindex cidr @cindex CIDR Formats output in CIDR notation, such as: @example 10.1.8.128/27 @end example @item --cisco @itemx -i @cindex cisco Formats output in the style accepted by Cisco 2500 series router config files, such as: @example 10.1.8.128 0.0.0.31 @end example @item --range @itemx -r @cindex range Formats output as a set of ranges and the number of addresses contained in them, such as: @example 10.1.8.128-10.1.8.159 (32) @end example @item --hex @itemx -x @cindex hexadecimal Formats output as hexadecimal address and netmask pairs, such as: @example 0x0a010880/0xffffffe0 @end example @item --octal @itemx -o @cindex octal Formats output as octal addresses and netmask pairs, such as: @example 01200204200/037777777740 @end example @item --binary @itemx -b @cindex binary Formats output as binary addresses and netmask pairs, such as: @example 00001010 00000001 00001000 10000000 / 11111111 11111111 11111111 11100000 @end example @item --nodns @itemx -n @cindex DNS Disables dns lookups on input addresses. @item --files @itemx -f @cindex files Treat arguments as input files. @end table @node Problems, Concept Index, Invoking netmask, Top @chapter Reporting Bugs @cindex bugs @cindex problems If you find a bug in @code{netmask}, please send electronic mail to @w{@samp{netmask-bug@@trap.mtview.ca.us}}. Include the version number, which you can find by running @w{@samp{netmask --version}}. Also include in your message the output that the program produced and the output you expected.@refill If you have other questions, comments or suggestions about @code{netmask}, contact Talby via electronic mail to @w{@samp{talby@@trap.mtview.ca.us}}. Talby will try to help you out, although he may not have the resources to fix your problems. @node Concept Index, , Problems, Top @unnumbered Concept Index @cindex tail recursion @printindex cp @shortcontents @contents @bye netmask-2.4.4/tests/000077500000000000000000000000001342463464300143365ustar00rootroot00000000000000netmask-2.4.4/tests/bounds_dq1000066400000000000000000000000221342463464300163120ustar00rootroot00000000000000 0.0.0.0/0 netmask-2.4.4/tests/bounds_dq2000066400000000000000000000000221342463464300163130ustar00rootroot00000000000000 192.0.0.0/8 netmask-2.4.4/tests/bounds_dq3000066400000000000000000000000231342463464300163150ustar00rootroot00000000000000 192.168.0.0/16 netmask-2.4.4/tests/bounds_dq4000066400000000000000000000000231342463464300163160ustar00rootroot00000000000000 192.168.0.0/24 netmask-2.4.4/tests/bounds_dq5000066400000000000000000000000231342463464300163170ustar00rootroot00000000000000 192.168.0.1/32 netmask-2.4.4/tests/bounds_dq6000066400000000000000000000000221342463464300163170ustar00rootroot00000000000000 192.0.0.0/8 netmask-2.4.4/tests/inputs000066400000000000000000000001141342463464300155770ustar00rootroot00000000000000 0.0.0.0/32 0.0.0.2/32 0.0.0.4/32 0.0.0.6/32 netmask-2.4.4/tests/output_binary000066400000000000000000000010061342463464300171620ustar00rootroot0000000000000000000000 00000000 00000000 00000000 / 11111111 11111111 11111111 11111111 00000000 00000000 00000000 00000010 / 11111111 11111111 11111111 11111111 00000000 00000000 00000000 00000100 / 11111111 11111111 11111111 11111111 00000000 00000000 00000000 00000110 / 11111111 11111111 11111111 11111111 00000000 00000000 00000000 00001000 / 11111111 11111111 11111111 11111111 00000000 11111111 11111111 11111111 / 11111111 11111111 11111111 11111111 11111111 11111111 11111111 11111111 / 11111111 11111111 11111111 11111111 netmask-2.4.4/tests/output_cidr000066400000000000000000000002051342463464300166170ustar00rootroot00000000000000 0.0.0.0/32 0.0.0.2/32 0.0.0.4/32 0.0.0.6/32 0.0.0.8/32 0.255.255.255/32 255.255.255.255/32 netmask-2.4.4/tests/output_cisco000066400000000000000000000003401342463464300167760ustar00rootroot00000000000000 0.0.0.0 0.0.0.0 0.0.0.2 0.0.0.0 0.0.0.4 0.0.0.0 0.0.0.6 0.0.0.0 0.0.0.8 0.0.0.0 0.255.255.255 0.0.0.0 255.255.255.255 0.0.0.0 netmask-2.4.4/tests/output_hex000066400000000000000000000002321342463464300164620ustar00rootroot000000000000000x00000000/0xffffffff 0x00000002/0xffffffff 0x00000004/0xffffffff 0x00000006/0xffffffff 0x00000008/0xffffffff 0x00ffffff/0xffffffff 0xffffffff/0xffffffff netmask-2.4.4/tests/output_octal000066400000000000000000000002601342463464300170010ustar00rootroot000000000000000 0/037777777777 0 2/037777777777 0 4/037777777777 0 6/037777777777 0 10/037777777777 0 77777777/037777777777 037777777777/037777777777 netmask-2.4.4/tests/output_range000066400000000000000000000003741342463464300170010ustar00rootroot00000000000000 0.0.0.0-0.0.0.0 (1) 0.0.0.2-0.0.0.2 (1) 0.0.0.4-0.0.0.4 (1) 0.0.0.6-0.0.0.6 (1) 0.0.0.8-0.0.0.8 (1) 0.255.255.255-0.255.255.255 (1) 255.255.255.255-255.255.255.255 (1) netmask-2.4.4/tests/output_std000066400000000000000000000002401342463464300164670ustar00rootroot00000000000000 0.0.0.0/255.255.255.255 0.0.0.2/255.255.255.255 0.0.0.4/255.255.255.255 0.0.0.6/255.255.255.255 0.0.0.8/255.255.255.255 netmask-2.4.4/tests/range000066400000000000000000000001621342463464300153540ustar00rootroot00000000000000 0.0.0.100/30 0.0.0.104/29 0.0.0.112/28 0.0.0.128/26 0.0.0.192/29 0.0.0.200/32 netmask-2.4.4/tests/range_adds000066400000000000000000000002301342463464300163430ustar00rootroot00000000000000 10.0.0.1/32 10.0.0.2/31 10.0.0.4/31 10.0.0.6/32 172.16.29.1/32 172.16.29.2/31 172.16.29.4/30 172.16.29.8/32 netmask-2.4.4/tests/range_cidr000066400000000000000000000000231342463464300163510ustar00rootroot00000000000000 12.34.48.0/20 netmask-2.4.4/tests/range_join000066400000000000000000000000711342463464300163720ustar00rootroot00000000000000 10.1.0.0/16 10.2.0.0/15 10.4.0.0/16 netmask-2.4.4/tests/range_join2000066400000000000000000000000231342463464300164510ustar00rootroot00000000000000 10.0.0.0/14 netmask-2.4.4/tests/range_large000066400000000000000000000043141342463464300165310ustar00rootroot00000000000000 0.0.0.1/32 0.0.0.2/31 0.0.0.4/30 0.0.0.8/29 0.0.0.16/28 0.0.0.32/27 0.0.0.64/26 0.0.0.128/25 0.0.1.0/24 0.0.2.0/23 0.0.4.0/22 0.0.8.0/21 0.0.16.0/20 0.0.32.0/19 0.0.64.0/18 0.0.128.0/17 0.1.0.0/16 0.2.0.0/15 0.4.0.0/14 0.8.0.0/13 0.16.0.0/12 0.32.0.0/11 0.64.0.0/10 0.128.0.0/9 1.0.0.0/8 2.0.0.0/7 4.0.0.0/6 8.0.0.0/5 16.0.0.0/4 32.0.0.0/3 64.0.0.0/3 96.0.0.0/4 112.0.0.0/5 120.0.0.0/6 124.0.0.0/7 126.0.0.0/8 127.0.0.0/9 127.128.0.0/10 127.192.0.0/11 127.224.0.0/12 127.240.0.0/13 127.248.0.0/14 127.252.0.0/15 127.254.0.0/16 127.255.0.0/17 127.255.128.0/18 127.255.192.0/19 127.255.224.0/20 127.255.240.0/21 127.255.248.0/22 127.255.252.0/23 127.255.254.0/24 127.255.255.0/25 127.255.255.128/26 127.255.255.192/27 127.255.255.224/28 127.255.255.240/29 127.255.255.248/30 127.255.255.252/31 127.255.255.254/32 128.0.0.1/32 128.0.0.2/31 128.0.0.4/30 128.0.0.8/29 128.0.0.16/28 128.0.0.32/27 128.0.0.64/26 128.0.0.128/25 128.0.1.0/24 128.0.2.0/23 128.0.4.0/22 128.0.8.0/21 128.0.16.0/20 128.0.32.0/19 128.0.64.0/18 128.0.128.0/17 128.1.0.0/16 128.2.0.0/15 128.4.0.0/14 128.8.0.0/13 128.16.0.0/12 128.32.0.0/11 128.64.0.0/10 128.128.0.0/9 129.0.0.0/8 130.0.0.0/7 132.0.0.0/6 136.0.0.0/5 144.0.0.0/4 160.0.0.0/3 192.0.0.0/3 224.0.0.0/4 240.0.0.0/5 248.0.0.0/6 252.0.0.0/7 254.0.0.0/8 255.0.0.0/9 255.128.0.0/10 255.192.0.0/11 255.224.0.0/12 255.240.0.0/13 255.248.0.0/14 255.252.0.0/15 255.254.0.0/16 255.255.0.0/17 255.255.128.0/18 255.255.192.0/19 255.255.224.0/20 255.255.240.0/21 255.255.248.0/22 255.255.252.0/23 255.255.254.0/24 255.255.255.0/25 255.255.255.128/26 255.255.255.192/27 255.255.255.224/28 255.255.255.240/29 255.255.255.248/30 255.255.255.252/31 255.255.255.254/32 netmask-2.4.4/tests/range_order000066400000000000000000000001621342463464300165470ustar00rootroot00000000000000 0.0.0.100/30 0.0.0.104/29 0.0.0.112/28 0.0.0.128/26 0.0.0.192/29 0.0.0.200/32 netmask-2.4.4/tests/range_special000066400000000000000000000000461342463464300170550ustar00rootroot00000000000000 0.0.0.3/32 0.0.0.4/31 netmask-2.4.4/tests/simple000066400000000000000000000000231342463464300155450ustar00rootroot00000000000000 0.0.0.0/32 netmask-2.4.4/tests/simple2000066400000000000000000000001371342463464300156350ustar00rootroot00000000000000 0.0.0.0/32 0.0.0.2/32 0.0.0.4/32 0.0.0.6/32 0.0.0.8/32 netmask-2.4.4/tests/subset_clean000066400000000000000000000002301342463464300167230ustar00rootroot00000000000000 0.0.0.45/32 0.0.0.100/30 0.0.0.104/29 0.0.0.112/28 0.0.0.128/26 0.0.0.192/29 0.0.0.200/32 0.0.1.89/32 netmask-2.4.4/tests/subset_skip000066400000000000000000000002301342463464300166070ustar00rootroot00000000000000 0.0.0.45/32 0.0.0.100/30 0.0.0.104/29 0.0.0.112/28 0.0.0.128/26 0.0.0.192/29 0.0.0.200/32 0.0.1.89/32 netmask-2.4.4/testscript000077500000000000000000000052461342463464300153350ustar00rootroot00000000000000#!/bin/sh netmask="./netmask" RET=0 case "$1" in '') i=0 check () { i=$(expr $i + 1) eval $3 | diff -au $2 - if test $? -eq 0 then echo "ok $i - $1" else echo "not ok $i - $1" ; RET=1 fi } ;; update) check () { if test -e "$2" then echo "skip $2, file exists" else echo -n "make $2..." eval $3 > "$2" echo " done" fi } ;; *) echo "Usage: $0 [ update ]" ;; esac echo "1..23" check "simple one element" tests/simple \ "$netmask 0" check "simple multi element" tests/simple2 \ "$netmask 0 2 4 6 8" check "input formats" tests/inputs \ "$netmask 0 02 0x4 0.0.0.6" check "simple ranges" tests/range \ "$netmask 100:200" check "CIDR ranges" tests/range_cidr \ "$netmask 12.34.56.78/20" check "large ranges" tests/range_large \ "$netmask 1:0x7ffffffe 0x80000001:0xfffffffe" check "output format standard" tests/output_std \ "$netmask --standard 0 2 4 6 8" check "output format cidr" tests/output_cidr \ "$netmask --cidr 0 2 4 6 8 077777777 0xffffffff" check "output format cisco" tests/output_cisco \ "$netmask --cisco 0 2 4 6 8 077777777 0xffffffff" check "output format range" tests/output_range \ "$netmask --range 0 2 4 6 8 077777777 0xffffffff" check "output format hex" tests/output_hex \ "$netmask --hex 0 2 4 6 8 077777777 0xffffffff" check "output format octal" tests/output_octal \ "$netmask --octal 0 2 4 6 8 077777777 0xffffffff" check "output format binary" tests/output_binary \ "$netmask --binary 0 2 4 6 8 077777777 0xffffffff" check "subset skipping" tests/subset_skip \ "$netmask 345 100:200 105 45 200" check "subset clean" tests/subset_clean \ "$netmask 105 45 200 100:200 345" check "range joining" tests/range_join \ "$netmask 10.1.0.0/16 10.2.0.0/16 10.3.0.0/16 10.4.0.0/16" check "entire range joining" tests/range_join2 \ "$netmask 10.0.0.0/16 10.1.0.0/16 10.2.0.0/16 10.3.0.0/16" check "boundary dottedq 1" tests/bounds_dq1 \ "$netmask 192.168.0.1/0.0.0.0" check "boundary dottedq 1" tests/bounds_dq2 \ "$netmask 192.168.0.1/255.0.0.0" check "boundary dottedq 1" tests/bounds_dq3 \ "$netmask 192.168.0.1/255.255.0.0" check "boundary dottedq 1" tests/bounds_dq4 \ "$netmask 192.168.0.1/255.255.255.0" check "boundary dottedq 1" tests/bounds_dq5 \ "$netmask 192.168.0.1/255.255.255.255" check "boundary dottedq 1" tests/bounds_dq6 \ "$netmask 192.168.0.1/0.255.255.255" check "range adds" tests/range_adds \ "$netmask 10.0.0.1,+5 172.16.29.1:+7" check "range order" tests/range_order \ "$netmask 200:100" check "range special" tests/range_special \ "$netmask 0.0.0.5:+-2" exit $RET