From 0b51a024002cdb5875dff1d8fe8f9bf95180c3d8 Mon Sep 17 00:00:00 2001 From: Packit Date: Sep 16 2020 15:09:40 +0000 Subject: perl-NetAddr-IP-4.079 base --- diff --git a/About-NetAddr-IP.txt b/About-NetAddr-IP.txt new file mode 100644 index 0000000..52c8244 --- /dev/null +++ b/About-NetAddr-IP.txt @@ -0,0 +1,95 @@ +About NetAddr::IP + +At some point a user wrote and asked the difference between +NetAddr::IP and NetAddr::IP::Lite + +NetAddr::IP::Lite contains only "basic" IP address operations to create IP objects, +print or return their characteristics, do basic IP arithmetic, etc... a lot of +which is implemented in XS in its sub-classes, whereas NetAddr::IP contains complex +operations on nets, net ranges , etc... all implemented in perl. If you don't use +those, you don't need the overhead of loading them, the autoloader, etc... +Likewise, NetAddr::IP::Utilities and NetAddr::IP::InetBase exist to provide +"very basic" ipv4 and ipv6 utilities without the overhead of their superclasses +for module writers need to work with ipv4 & ipv6 "numbers" but do not need object +oriented overhead or functionality. + +Take a brief look at the SRC of each to see what is supported in each without +having to wade through the man pages to figure out where the overlap is. +Basically the modules are broken down into these functional areas that cover +various aspects of manipulating IP numbers. + +NetAddr::IP::InetBase mostly XS +net to text conversion routines + inet_aton + inet_ntoa + ipv6_aton + ipv6_ntoa + ipv6_n2x + ipv6_n2d + inet_any2n + inet_n2dx + inet_n2ad + inet_ntop + inet_pton + etc... + +NetAddr::IP::Util adds to above, mostly XS + above + ip arithmetic + addconst + add128 + sub128 + bin2bcd + bcd2bin + ipv4to6 + mask4to6 + ipanyto6 + maskanyto6 + ipv6to4 + bin2bcdn + bcdn2txt + bcdn2bin + comp128 + naip_gethostbyname (platform/socket independent) + etc... + +NetAddr::IP::Lite adds to above +mostly 1 or 2 line functions and/or calls to sub classes + all the "new" functions + all overload functions ( + - ++ -- = print eq ne == > >= < <= cmp) + "copy" (clone rather than reference) + return of IP parameters such as + broadcast + network + addr + mask + masklen + bits + version + cidr + aton + range + numeric + bigint + contains + within + first + last + nth + num + +NetAddr::IP adds to above + wildcard + short + full + full6 + splitref + split + rsplit + hostenum + compact + compactref + coalesce + re + re6 + +enjoy... diff --git a/Artistic b/Artistic new file mode 100644 index 0000000..5f22124 --- /dev/null +++ b/Artistic @@ -0,0 +1,131 @@ + + + + + The "Artistic License" + + Preamble + +The intent of this document is to state the conditions under which a +Package may be copied, such that the Copyright Holder maintains some +semblance of artistic control over the development of the package, +while giving the users of the package the right to use and distribute +the Package in a more-or-less customary fashion, plus the right to make +reasonable modifications. + +Definitions: + + "Package" refers to the collection of files distributed by the + Copyright Holder, and derivatives of that collection of files + created through textual modification. + + "Standard Version" refers to such a Package if it has not been + modified, or has been modified in accordance with the wishes + of the Copyright Holder as specified below. + + "Copyright Holder" is whoever is named in the copyright or + copyrights for the package. + + "You" is you, if you're thinking about copying or distributing + this Package. + + "Reasonable copying fee" is whatever you can justify on the + basis of media cost, duplication charges, time of people involved, + and so on. (You will not be required to justify it to the + Copyright Holder, but only to the computing community at large + as a market that must bear the fee.) + + "Freely Available" means that no fee is charged for the item + itself, though there may be fees involved in handling the item. + It also means that recipients of the item may redistribute it + under the same conditions they received it. + +1. You may make and give away verbatim copies of the source form of the +Standard Version of this Package without restriction, provided that you +duplicate all of the original copyright notices and associated disclaimers. + +2. You may apply bug fixes, portability fixes and other modifications +derived from the Public Domain or from the Copyright Holder. A Package +modified in such a way shall still be considered the Standard Version. + +3. You may otherwise modify your copy of this Package in any way, provided +that you insert a prominent notice in each changed file stating how and +when you changed that file, and provided that you do at least ONE of the +following: + + a) place your modifications in the Public Domain or otherwise make them + Freely Available, such as by posting said modifications to Usenet or + an equivalent medium, or placing the modifications on a major archive + site such as uunet.uu.net, or by allowing the Copyright Holder to include + your modifications in the Standard Version of the Package. + + b) use the modified Package only within your corporation or organization. + + c) rename any non-standard executables so the names do not conflict + with standard executables, which must also be provided, and provide + a separate manual page for each non-standard executable that clearly + documents how it differs from the Standard Version. + + d) make other distribution arrangements with the Copyright Holder. + +4. You may distribute the programs of this Package in object code or +executable form, provided that you do at least ONE of the following: + + a) distribute a Standard Version of the executables and library files, + together with instructions (in the manual page or equivalent) on where + to get the Standard Version. + + b) accompany the distribution with the machine-readable source of + the Package with your modifications. + + c) give non-standard executables non-standard names, and clearly + document the differences in manual pages (or equivalent), together + with instructions on where to get the Standard Version. + + d) make other distribution arrangements with the Copyright Holder. + +5. You may charge a reasonable copying fee for any distribution of this +Package. You may charge any fee you choose for support of this +Package. You may not charge a fee for this Package itself. However, +you may distribute this Package in aggregate with other (possibly +commercial) programs as part of a larger (possibly commercial) software +distribution provided that you do not advertise this Package as a +product of your own. You may embed this Package's interpreter within +an executable of yours (by linking); this shall be construed as a mere +form of aggregation, provided that the complete Standard Version of the +interpreter is so embedded. + +6. The scripts and library files supplied as input to or produced as +output from the programs of this Package do not automatically fall +under the copyright of this Package, but belong to whoever generated +them, and may be sold commercially, and may be aggregated with this +Package. If such scripts or library files are aggregated with this +Package via the so-called "undump" or "unexec" methods of producing a +binary executable image, then distribution of such an image shall +neither be construed as a distribution of this Package nor shall it +fall under the restrictions of Paragraphs 3 and 4, provided that you do +not represent such an executable image as a Standard Version of this +Package. + +7. C subroutines (or comparably compiled subroutines in other +languages) supplied by you and linked into this Package in order to +emulate subroutines and variables of the language defined by this +Package shall not be considered part of this Package, but are the +equivalent of input as in Paragraph 6, provided these subroutines do +not change the language in any way that would cause it to fail the +regression tests for the language. + +8. Aggregation of this Package with a commercial distribution is always +permitted provided that the use of this Package is embedded; that is, +when no overt attempt is made to make this Package's interfaces visible +to the end user of the commercial distribution. Such use shall not be +construed as a distribution of this Package. + +9. The name of the Copyright Holder may not be used to endorse or promote +products derived from this software without specific prior written permission. + +10. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR +IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED +WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + + The End diff --git a/Changes b/Changes new file mode 100644 index 0000000..3e50095 --- /dev/null +++ b/Changes @@ -0,0 +1,566 @@ +Revision history for Perl extension NetAddr::IP + +4.079 Fri Mar 25 16:18:26 PDT 2016 + correct non-suppression of leading zeros in certain instances of + new_no use. Thanks to "Mike Bartman (mbartman)" + for spotting the bug. + + put in missing code to propagate NetAddr::IP::Lite :nofqdn to IP.pm + +4.078 Mon Aug 17 15:35:28 PDT 2015 + fix typo in Util.pm 1.53 MakefilePL that cause compiler to not be + found at all + +4.077 Fri Aug 14 01:17:23 PDT 2015 + re-numbered because of CPAN upload issue + +4.076 Thu Aug 13 22:44:48 PDT 2015 + added method is_local() to Lite.pm + inspired by Xan Charbonne + + fix Util Makefile.PL to accomodate bug in Android's sh + + add method full6m() + inspired by abraxxa@cpan.org + + fix Util/Makefile.PL issue with clang compiler, bug 86831 + +4.075 Wed Jun 11 11:41:17 PDT 2014 + make CPAN happy with new rev number + +4.074 Wed Jun 11 09:36:10 PDT 2014 + In Lite.pm v1.54, + change input filter for resolvable hostnames + to allow the underscore character + Thanks to grankio [...] gmail.com for the heads up on this issue. + +4.073 Sat Apr 5 09:32:11 PDT 2014 + add documentation about FQDN conversion and + an option to disable + +4.072 Mon Jan 27 11:59:58 PST 2014 + modify Makefile.PL to bypass missing 'pod2text' + +4.071 Mon Sep 30 13:41:03 PDT 2013 + add method "canon" by request from + +4.070 Thu Sep 12 12:54:22 PDT 2013 + nth documention error fixed. thanks to Anton tobez@tobez.org + + Lite v1.51, add new6FFFF, RFC4291 compliant ipv4->ipV6 new + +4.069 Sat May 25 15:10:45 PDT 2013 + IN Lite.pm v1.50, add =encoding UTF-8 + In Util.pm v1.50 + changed Makefile.PL to check for config.h when building for XS + with 'gcc', try building with 'cc', and check again. + If config.h is not found, force Pure Perl mode. + + Kill XS in winduhs and Darwin, both of which misbehave when compiling XS code + +4.068 Wed Apr 3 10:52:24 PDT 2013 + update Makefile.PL in Util.pm v 1.49 to better detect 'winduhs' + +4.067 Sat Mar 30 12:57:20 PDT 2013 + Improved diagnostic message for "die" with bad mask for + hostenum, hostenumref, split, splitref, rsplit, rsplitref + Thanks to GENSYM@cpan.org for pointing out the need. + +4.066 Mon Oct 29 13:30:14 PDT 2012 + update Lite.pm v1.47 to support bracketed IPv6 URI notation + as described in RFC-3986 + Thanks to Quanah Gibson-Mount mishikal@yahoo.com + +4.065 Tue Oct 2 12:36:11 PDT 2012 + correct format for IPv6 embedded IPv4 addresses + in InetBase v0.8 + +4.064 Tue Sep 25 13:54:47 PDT 2012 + added support for rfc3021 /31 networks to hostenum + +4.063 Fri Aug 10 11:46:18 PDT 2012 + Updated GPL v2.0 text and address in all modules + +4.062 Wed Jun 6 12:34:48 PDT 2012 + documentation updates courtesy of + Ben Bullock + Thank you Ben. + +4.061 Tue May 8 16:24:03 PDT 2012 + fixed bug in Lite v1.44 that returned + $ip->num() = 2^128 for 0.0.0.0/0 + Thanks to Sebastian for spotting it. + +4.060 Fri Apr 6 16:00:02 PDT 2012 + In Lite.pm v1.43, + fix bug #75976, change in behavior introduced in v4.050 + where an empty string supplied to "new" previously returned + 'undef' and now returns 'default' for ipV4 or ipV6 + +4.059 Wed Mar 7 12:50:04 PST 2012 + add is_rfc1918 to Lite.pm v1.42 + + documentation updates + +4.058 Fri Nov 11 19:23:11 PST 2011 + up rev for documentation update + update documentation in InetBase v0.06 + +4.057 Fri Nov 11 15:04:20 PST 2011 + Lite.pm v1.40 + add call to InetBase::fillIPv4 to all uses of gethostbyname + + break out the code in InetBase v0.05 that expands short IPv4 + addresses into dotquad format to account for broken BSD + implementations of inet_aton and gethostbyname that do + not recognize the short format. EXPORT this as sub 'fillIPv4' + + in Util.pm v1.45, add 'fillIPv4' to calls to gethostbyname to + work around broken inet_aton and gethostbyname implementations + in certain BSD implementations + +4.056 Wed Nov 2 19:15:31 PDT 2011 + bump rev to incorporate + improved inet_aton in InetBase v0.04 to overcome broken + gethostbyname found in NetBSD and OpenBSD + +4.055 Fri Oct 28 11:41:22 PDT 2011 + in Lite.pm v1.38 + patch for bug 71869, issues with Math::BigInt varients + +4.054 Thu Oct 27 12:48:55 PDT 2011 + In Lite.pm v1.37, remove Calc.pm + add detection of early Math::Bigint object structure + fix bug 71869 - a failed test routine + +4.053 Wed Oct 26 08:52:34 PDT 2011 + In Lite.pm v1.36 + fix bug #71925. A a sub-varient of #62521 that showed up only for + short notation for IPv4. i.e. 127/n, 127.0/n, 127.0.0/n but + not 127.0.0.0/n + +4.052 Tue Oct 25 16:18:38 PDT 2011 + add test in Lite.pm v1.35 for api-version of Math::BigInt to + support versions earlier than 1.70, circa Dec 2003. + Thanks to Paul Howarth for spotting that bug. + +4.051 Mon Oct 24 14:44:53 PDT 2011 + fix bug 71869 + in Lite.pm v1.34 + use Math::BigInt::Calc for creating BigInt values and fall + back to NetAddr::IP::Calc if Math::BigInt is not present. + + remove reference to Config{osname} in InetBase.pm v0.03 + (Util 1.43) + + +4.050 Sat Oct 22 01:58:57 PDT 2011 + In Lite/Util/lib/NetAddr/IP/Lite/Util/InetBase.pm v0.02 + Socket6 prior to version 0.23 does not have AF_INET6 in the + EXPORT_OK array, modify InetBase.pm v0.2 to work around this. + + Add support for Math::BigInt to NetAddr::IP::Lite v1.33 + +4.049 Sat Oct 15 22:15:10 PDT 2011 + Updates to Lite.pm, Util.pm, new module InetBase.pm + + In Lite v1.32 + bug68723, add capability to parse input of the form + ->new6(12345,1). This should have been there but was + missing. Thanks to Andrei Benea for spotting this. + + In Util v1.41 + add inet_pton, inet_ntop, AF_INET, AF_INET6 + + modify inet_n2dx and inet_n2ad to + recognize the new 128 bit IPv4 format + ::FFFF:FFFF:0:0 + + replace isIPv4 with a pure perl version for portablity + + split the following into NetAddr::IP::InetBase v0.01 + to provide better long term support for IPv6 + inet_aton + inet_ntoa + ipv6_aton + ipv6_n2x + ipv6_n2d + inet_any2n + inet_n2dx + inet_n2ad + inet_ntop + inet_pton + packzeros + isIPv4 + isNewIPv4 + isAnyIPv4 + AF_INET + AF_INET6 + +4.048 Sat Oct 8 01:33:44 PDT 2011 + remove debug print statement from Util v1.40 + +4.047 Thu Oct 6 23:41:42 PDT 2011 + really correct missing reference in Util v1.39 + doc update only in Lite.pm v1.30 + +4.046 Thu Oct 6 20:20:33 PDT 2011 DEPRECATED + corrected missing reference to inet_4map6 in Util v1.38 + +4.045 Thu Oct 6 18:23:04 PDT 2011 DEPRECATED + updated NetAddr::IP::Util 1.37 + addid isAnyIPv4, isNewIPv4, inet_4map6 + revised naip_gethostbyname + to conform to Perl's gethostbyname output + +4.044 Wed May 18 14:47:34 PDT 2011 + added missing support for ->compactref(\@list) which is described + in the documentation but not implemented. + + Thanks to Rusty Bourland codebard@gmail.com for spotting this + and providing both a patch and test code + +4.043 Wed Apr 6 11:31:19 PDT 2011 + Update documentation on the use of "adding constants + to an IP address". + +4.042 Tue Mar 22 15:26:02 PDT 2011 + Update Lite.pm v1.27 to encompass treatment of /31 and /127 + point-to-point networks as described in RFC 3021 + + NOTE: for /31's and /127's + this changes the behavior of the following methods: + first returns the "network" address + last returns the "broadcast" address + nth index 0 returns "network" addr instead of undef + nth index 1 returns "broadcast" addr instead of undef + num returns 2 instead of 0 (zero) + + "old_nth" behavior is unchanged + + Thanks to Todd Caine todd.caine@gmail.com for pointing this out. + +4.041 Tue Mar 8 15:18:16 PST 2011 + Updated Lite.pm v1.26, "sub num" to support usable IP ranges + greater than 2**32 + + Thanks to Jan Ploski jan@plosquare.com for finding this bug + +4.040 Sat Feb 19 10:04:00 PST 2011 + correction to use of Util.pm package lexicals + + thanks to mishikal@yahoo.com for spotting the bug and to + Mark Martinec mark.martinec+ama...@ijs.si for the solution. + +4.039 Wed Feb 16 15:48:03 PST 2011 + Correct documentation for 'split' methods + +4.038 Fri Dec 17 17:47:47 PST 2010 + Modify subs "new" and "new6" in Lite.pm to accomodate + Cisco mask syntax that uses space instead of "/" for a separator + This eliminates the need for "new_cis" and "newcis6" which are now + deprecated. + + Modify LIte/t/v4-cnew.t and add Lite/t/v6-cnew.t to test the above + +4.037 Fri Nov 19 10:48:01 PST 2010 + add :upper and :lower to Lite.pm v1.23 + add comments about rfc5952 requirement for lowercase ipV6 notation + in Lite.pm v1.23 and IP.pm + add test for :lower in Lite.pm v1.23 + +4.036 Tue Nov 16 16:28:37 PST 2010 + In Util.pm v1.35, naip_gethostbyname modified to return undef + instead of 0 (zero) on failure + + thanks to Terry Cassidy enaudishaylee@tc17.com for the bug report + + In Util.pm v1.35, move sub's ipv6_n2d and ipv6_n2x to non-autosplit + portion of module to eliminate warnings during autosplit of "our" + variables + + thanks to Nicholas Bamber + Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=517361 + + In Lite.pm v1.22, update new6 to properly classify short ipv4 notation + i.e. 127/8 with test for ":" rather than match for \d.\d.\d.\d + + thanks to Steve Huff (SHUFF) * shuff@cpan.org for + spotting that bug. + + In Lite.pm v1.22, update t/v4-new.t for deprecated array syntax in + perl 5.13 + was: qw(...stuff...) + is: (qw(...stuff...)) + + thanks to Todd Rinaldo for reporting this + +4.035 Thu Oct 28 14:26:19 PDT 2010 + fix bug in Lite v1.21 where new6 improperly assigns the mask value + for and ipv4 address in 32 bit space instead of 128 bit space + + Thanks to Mark Martinec and Steve Huff (SHUFF) * shuff@cpan.org + for spotting and replicating that bug + + added new_cis and new_cis6 to Lite.pm v1.21 to accomodate + Cisco syntax that has IP and MASK separated by a space. + + Updated typo in documentation that left out example + print new6 stuff + +4.034 Mon Oct 25 16:22:01 PDT 2010 + Updated Lite::_xnew v1.20 to properly handle ipV6 notation of the form + xxxx:xxxx:xxxx:xxxx:xxxx:xxxx, DDD + + Thanks to Dusty Mabe for spotting this bug + +4.033 Wed Sep 29 10:32:50 PDT 2010 + Conditionalize import of AF_INET6 in Util.pm + NetAddr::IP::UtilPolluted + +4.032 Wed Sep 22 13:39:08 PDT 2010 + Added overload => 'ne' and '!=' to Lite.pm v1.18 + +4.031 Tue Sep 21 19:21:04 PDT 2010 + Pull Socket6 stuff out of Lite 1.17 and put into + NetAddr::IP::Util.pm 1.33 in its own namespace + +4.030 Tue Jul 20 15:32:23 PDT 2010 + Resolve named hosts in Lite.pm using gethostbyname, followed by + gethostbyname6 to determine whether to set ipV6 flag + + Thanks to Dusty Mabe for spotting this bug + +4.029 Thu Jul 8 18:17:38 PDT 2010 + In NetAddr::IP::Lite, + added support for the sub "new" to resolve host6 names + if the OPTIONAL perl Socket6 module is available + + Thanks to "Mabe, Dusty" for spotting + this and suggesting a fix. + +4.028 Wed May 12 14:18:20 PDT 2010 + In /Lite/Util/Util.xs v1.32, + changed netswap() to postincrement + *a++ = to *a and added increment after save to mollify some + picky compilers that return possible undefined behavior. + + changed type of _128x10 to 'void' + + Thanks to David Bolt for the above two patches + +4.027 Tue Jun 9 10:31:11 PDT 2009 + In NetAddr::IP::Util v1.31, + ferret out shell value for Makefile.PL when calling + ./configure for systems where the 'x' bit gets lost + due to bug in Archive::Tar + +4.026 Sat Mar 7 16:35:33 PST 2009 + make the compiler test check the environment for + CC before using Perl's default compiler + +4.025 Sat Mar 7 16:15:18 PST 2009 + revised compiler test in Makefile.PL for Util v1.29 + to accomodate picky Solaris "cc" + +4.024 Mon Jan 26 00:27:32 PST 2009 + documentation update + +4.023 Fri Jan 16 14:30:40 PST 2009 + added the capability to set the CASE of ipV6 text return + values to either upper or lower. Thanks to + Rob Riepel for developing + this improvement and providing a comprehensive patch + +4.022 Sat Dec 20 13:05:01 PST 2008 + In Util.xs 1.28 + set uninitialized "carry" in XS bin2bcd to zero + + This insidious bug only showed up on 64 bit hosts running perl 5.6.2 + Thanks to Oliver Paukstadt for taking the + time to do the testing for me on his s390 system. + +4.021 Wed Dec 10 11:09:36 PST 2008 + Removed test code that produces a warning about all perl versions, + OOPS!! instead of just the buggy 5.8.0 - 5.8.5 versions. + Thanks to paul@city-fan.org for reporting this. + +4.020 Tue Dec 9 16:25:46 PST 2008 + cleaned up various typo's with good patch from + Rob Riepel + thanks Rob. + + revised UtilPP v1.7 to work around perl 5.8.4 + failures with certain @_ operations of goto &sub... + see perl bug [ 23429]. Unfortunately, perl-5.8.4 is + the distribution of choice for many solaris boxes + +4.019 Sat Nov 29 15:15:30 PST 2008 + in Lite/Util, add pure perl testing to XS build + +4.018 Fri Nov 28 23:19:01 PST 2008 + revised XS code to be full re-entrant, thread safe in Util.xs v1.26 + removed all traces of mutex locks in Util.xs v1.26 + removed function 'threads' here an in UtilPP v1.6 + +4.017 Sun Nov 23 19:32:59 PST 2008 + Extended the capability of 'splitref' to allow splitting of + objects into multiple pieces with differing CIDR masks. + Returned object list can be split from bottom to top + or from top to bottom depending on which method is called + + split, rsplit, splitref, rsplitref + + Thanks to kashmish for the idea on + improving functionality of 'split'. + + Thanks to Rob Riepel + for a faster and more accurate _compV6 function. + + in UtitPP v1.5 + correct documentation error + add threads reporting (empty string) + + in Util v1.25 + add threads reporting that returns a comma separated + string of build headers. + + added what is hopefully thread safe operation via + serialization. Must be invoked by "--with-threads" + + in Lite v1.12 + corrected missing Zeros subroutine + Zeros and Zero both will work + + in Lite v1.12 + added minus (-) overloading to allow the subtraction + of two NetAddr::IP objects to get the difference between + the object->{addr}'s as a numeric value + Thanks to Rob Riepel + for the initial code and inspiration for this enhancement + +4.016 Wed Nov 5 18:13:20 PST 2008 + in Util/ version 1.24 + Clean up Makefile.PL to check actual required link + libraries against the perl build for consistency + +4.015 Sun Nov 2 10:10:38 PST 2008 + in Util v1.23 add missing headers in configure and localconf.h + for Solaris inet_xton + thanks to Karl Bunch for spotting the bug. + +4.014 Sat Nov 1 15:13:48 PST 2008 + in Lite.pm v1.11, add test for characters not allowed by + rfc952 before the call to gethostbyname in sub new() for those + people that insist on using deprecated functionality :aton + and OS's that fail to notice calls to gethostbyname with + binary arguments. + +4.013 Wed Oct 22 15:04:49 PDT 2008 + In Lite.pm v1.10, add new no octal method for + improperly formatted ipV4 addresses + + In Util.pm v1.22, eliminated dependence on PL_sawampersand + thanks to Mark Martinec + for spotting this and submitting a patch. + + In Util.pm v1.22, force -noxs mode for Win32 + + In Util.pm v1.22, use autoconf to configure 'C' build + +4.012 Thu Oct 16 19:35:33 PDT 2008 + clear build bug for Win32 in Util.pm v 1.21 + +4.011 released Oct 6 13:10 + +4.010 Sat Sep 27 17:00:28 PDT 2008 + in NetAddr::IP::Util v0.19 + updated test for ENDIANess in siteconf + + add test in inet_aton to detect overange IP dot quad values + missed by some broken Socket implementations + i.e. 256.1.1.1 would fail to return undef + +NOTE: Versions 4.008 and 4.009 had limited release to tester only + and were not uploaded to CPAN. All of the v4.008, 4.009 + changes are incorporated in v4.010 + +4.009 Tue Sep 2 19:09:57 PDT 2008 + In NetAddr::IP::Lite v1.07, + in the off chance that NetAddr::IP::Lite objects are created + and the caller later loads NetAddr::IP and expects to use + those objects, let the AUTOLOAD routine find and redirect + NetAddr::IP::Lite method and subroutine calls to NetAddr::IP. + + updated Lite/t/v4-wnew.t so that non-existent + domains are "really" not there + +4.008 Sat Jun 7 14:01:55 PDT 2008 + inherit method "new_from_aton" from NetAddr::IP::Lite + add related documentation + + Inherited methods from Lite.pm updated as follows: + + comparisons of the form <, >, <=, >= + 10.0.0.0/24 {operator} 10.0.0.0/16 + return now return the comparison of the cidr value + when the address portion is equal. +NOTE: this comparison returns the comparison of the NUMERIC + value of the CIDR. This produces the counter intuitive result + that /24 > /16. There is logic to this, really! For proper + operation of commands like "Compact" and "Coalesce", lists of + netaddr objects must sort in ascending order. However, this + conflicts with the requirement for larger netblocks to sort + FIRST so as to include smaller ones. This logic extends to + any requirement for a sort of netaddr objects. It should be + further noted that the mixing of netaddr objects with varying + IP addresses and CIDR allocations can lead to unexpected + results since the comparisons done first on the IP portion + and then on the CIDR portion. The documentation has been + updated appropriately. + Thanks to Peter DeVries for spotting this discrepancy + +4.007 Wed Jun 6 16:41:11 VET 2007 + Update copyright dates + +4.006 Wed Jun 6 15:58:04 VET 2007 + + A patch from Michael got rid of $& and $` as reported by Daryl + O'Shea and documented at + http://issues.apache.org/SpamAssassin/show_bug.cgi?id=5312 + +4.004 Wed Aug 16 16:01:54 PDT 2006 + update to include/exclude files in corrupted distro + +4.003 Sun Aug 6 10:48:25 PDT 2006 + correct SYNOPSIS documentation + add :old_nth + + update Lite.pm documentation + update Util.pm documentation + Imported into distribution CVS tree - Some revision number + mismatches are to be expected + Latin-1 is back + Fixed some angle brackets so that they show up in the docs + +4.002 Fri Aug 4 14:14:16 PDT 2006 + remove unused global variable $isV6 + + update Lite.pm to v1.02 + $isV6 global converted to a lexical variable within sub "_xnew" + $Class global removed and replaced by calls to UNIVERSAL::isa + Thanks to julian@mehnle.net for spotting problems related to + using the Lite.pm with mod_perl + +4.001 Thu Jul 6 14:09:01 PDT 2006 + various bug fixes courtesy of Luis Munoz: + changes to Lite.pm v1.01, Util.pm v0.17 see Changes in those distros. + update t/v6-re.t, addconst called as a scalar, should be called to + return the address value ()[1] + +4.000 Mon Jun 19 21:51:10 PDT 2006 + initial release of version 4.000 which includes + full support of ipV6 addresses and drops the requirement + for Math::BigInt and will run on older versions of Perl + at least back to 5.005_03 + diff --git a/Copying b/Copying new file mode 100644 index 0000000..839998f --- /dev/null +++ b/Copying @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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 Lesser 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) + + 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., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type how w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type how c' for details. + +The hypothetical commands how w' and how c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than how w' and how 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 + nomovision' (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 Lesser General +Public License instead of this License. diff --git a/IP.pm b/IP.pm new file mode 100644 index 0000000..4dbc582 --- /dev/null +++ b/IP.pm @@ -0,0 +1,1654 @@ +#!/usr/bin/perl -w + +package NetAddr::IP; + +use strict; +#use diagnostics; +use Carp; +use NetAddr::IP::Lite 1.57 qw(Zero Zeros Ones V4mask V4net); +use NetAddr::IP::Util 1.53 qw( + sub128 + inet_aton + inet_any2n + ipv6_aton + isIPv4 + ipv4to6 + mask4to6 + shiftleft + addconst + hasbits + notcontiguous +); + +use AutoLoader qw(AUTOLOAD); + +use vars qw( + @EXPORT_OK + @EXPORT_FAIL + @ISA + $VERSION + $_netlimit + $rfc3021 +); +require Exporter; + +@EXPORT_OK = qw(Compact Coalesce Zero Zeros Ones V4mask V4net netlimit); +@EXPORT_FAIL = qw($_netlimit); + +@ISA = qw(Exporter NetAddr::IP::Lite); + +$VERSION = do { sprintf " %d.%03d", (q$Revision: 4.79 $ =~ /\d+/g) }; + +$rfc3021 = 0; + +=pod + +=encoding UTF-8 + +=head1 NAME + +NetAddr::IP - Manages IPv4 and IPv6 addresses and subnets + +=head1 SYNOPSIS + + use NetAddr::IP qw( + Compact + Coalesce + Zeros + Ones + V4mask + V4net + netlimit + :aton DEPRECATED + :lower + :upper + :old_storable + :old_nth + :rfc3021 + :nofqdn + ); + + NOTE: NetAddr::IP::Util has a full complement of network address + utilities to convert back and forth between binary and text. + + inet_aton, inet_ntoa, ipv6_aton, ipv6_ntoa + ipv6_n2x, ipv6_n2d inet_any2d, inet_n2dx, + inet_n2ad, inetanyto6, ipv6to4 + +See L + + + my $ip = new NetAddr::IP '127.0.0.1'; + or if you prefer + my $ip = NetAddr::IP->new('127.0.0.1); + or from a packed IPv4 address + my $ip = new_from_aton NetAddr::IP (inet_aton('127.0.0.1')); + or from an octal filtered IPv4 address + my $ip = new_no NetAddr::IP '127.012.0.0'; + + print "The address is ", $ip->addr, " with mask ", $ip->mask, "\n" ; + + if ($ip->within(new NetAddr::IP "127.0.0.0", "255.0.0.0")) { + print "Is a loopback address\n"; + } + + # This prints 127.0.0.1/32 + print "You can also say $ip...\n"; + +* The following four functions return ipV6 representations of: + + :: = Zeros(); + FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF = Ones(); + FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:: = V4mask(); + ::FFFF:FFFF = V4net(); + + Will also return an ipV4 or ipV6 representation of a + resolvable Fully Qualified Domanin Name (FQDN). + +###### DEPRECATED, will be remove in version 5 ############ + + * To accept addresses in the format as returned by + inet_aton, invoke the module as: + + use NetAddr::IP qw(:aton); + +###### USE new_from_aton instead ########################## + +* To enable usage of legacy data files containing NetAddr::IP +objects stored using the L module. + + use NetAddr::IP qw(:old_storable); + +* To compact many smaller subnets (see: C<$me-Ecompact($addr1,$addr2,...)> + + @compacted_object_list = Compact(@object_list) + +* Return a reference to list of C subnets of +C<$masklen> mask length, when C<$number> or more addresses from +C<@list_of_subnets> are found to be contained in said subnet. + + $arrayref = Coalesce($masklen, $number, @list_of_subnets) + +* By default B functions and methods return string IPv6 +addresses in uppercase. To change that to lowercase: + +NOTE: the AUGUST 2010 RFC5952 states: + + 4.3. Lowercase + + The characters "a", "b", "c", "d", "e", and "f" in an IPv6 + address MUST be represented in lowercase. + +It is recommended that all NEW applications using NetAddr::IP be +invoked as shown on the next line. + + use NetAddr::IP qw(:lower); + +* To ensure the current IPv6 string case behavior even if the default changes: + + use NetAddr::IP qw(:upper); + +* To set a limit on the size of B processed or returned by NetAddr::IP. + +Set the maximum number of nets beyond which NetAddr::IP will return +an error as a power of 2 (default 16 or 65536 nets). Each 2**16 +consumes approximately 4 megs of memory. A 2**20 consumes 64 megs of +memory, A 2**24 consumes 1 gigabyte of memory. + + use NetAddr::IP qw(netlimit); + netlimit 20; + +The maximum B allowed is 2**24. Attempts to set limits below +the default of 16 or above the maximum of 24 are ignored. + +Returns true on success, otherwise C. + +=cut + +$_netlimit = 2 ** 16; # default + +sub netlimit($) { + return undef unless $_[0]; + return undef if $_[0] =~ /\D/; + return undef if $_[0] < 16; + return undef if $_[0] > 24; + $_netlimit = 2 ** $_[0]; +}; + +=head1 INSTALLATION + +Un-tar the distribution in an appropriate directory and type: + + perl Makefile.PL + make + make test + make install + +B depends on B which installs by +default with its primary functions compiled using Perl's XS extensions +to build a C library. If you do not have a C complier available or +would like the slower Pure Perl version for some other reason, then +type: + + perl Makefile.PL -noxs + make + make test + make install + +=head1 DESCRIPTION + +This module provides an object-oriented abstraction on top of IP +addresses or IP subnets that allows for easy manipulations. Version +4.xx of NetAddr::IP will work with older versions of Perl and is +compatible with Math::BigInt. + +The internal representation of all IP objects is in 128 bit IPv6 notation. +IPv4 and IPv6 objects may be freely mixed. + +=head2 Overloaded Operators + +Many operators have been overloaded, as described below: + +=cut + + ############################################# + # These are the overload methods, placed here + # for convenience. + ############################################# + +use overload + + '@{}' => sub { + return [ $_[0]->hostenum ]; + }; + +=pod + +=over + +=item B)> + +Has been optimized to copy one NetAddr::IP object to another very quickly. + +=item Bcopy()>> + +The B)> operation is only put in to operation when the +copied object is further mutated by another overloaded operation. See +L B for details. + +Bcopy()>> actually creates a new object when called. + +=item B + +An object can be used just as a string. For instance, the following code + + my $ip = new NetAddr::IP '192.168.1.123'; + print "$ip\n"; + +Will print the string 192.168.1.123/32. + +=item B + +You can test for equality with either C or C<==>. C allows +comparison with arbitrary strings as well as NetAddr::IP objects. The +following example: + + if (NetAddr::IP->new('127.0.0.1','255.0.0.0') eq '127.0.0.1/8') + { print "Yes\n"; } + +will print out "Yes". + +Comparison with C<==> requires both operands to be NetAddr::IP objects. + +In both cases, a true value is returned if the CIDR representation of +the operands is equal. + +=item B, E, E=, E=, E=E and C> + +Internally, all network objects are represented in 128 bit format. +The numeric representation of the network is compared through the +corresponding operation. Comparisons are tried first on the address portion +of the object and if that is equal then the NUMERIC cidr portion of the +masks are compared. This leads to the counterintuitive result that + + /24 > /16 + +Comparison should not be done on netaddr objects with different CIDR as +this may produce indeterminate - unexpected results, +rather the determination of which netblock is larger or smaller should be +done by comparing + + $ip1->masklen <=> $ip2->masklen + +=item B)> + +Add a 32 bit signed constant to the address part of a NetAddr object. +This operation changes the address part to point so many hosts above the +current objects start address. For instance, this code: + + print NetAddr::IP->new('127.0.0.1/8') + 5; + +will output 127.0.0.6/8. The address will wrap around at the broadcast +back to the network address. This code: + + print NetAddr::IP->new('10.0.0.1/24') + 255; + + outputs 10.0.0.0/24. + +Returns the the unchanged object when the constant is missing or out of +range. + + 2147483647 <= constant >= -2147483648 + +=item B)> + +The complement of the addition of a constant. + +=item B)> + +Returns the difference between the address parts of two NetAddr::IP +objects address parts as a 32 bit signed number. + +Returns B if the difference is out of range. + +(See range restrictions on Addition above) + +=item B + +Auto-incrementing a NetAddr::IP object causes the address part to be +adjusted to the next host address within the subnet. It will wrap at +the broadcast address and start again from the network address. + +=item B + +Auto-decrementing a NetAddr::IP object performs exactly the opposite +of auto-incrementing it, as you would expect. + +=cut + + ############################################# + # End of the overload methods. + ############################################# + + +# Preloaded methods go here. + +=pod + +=back + +=head2 Serializing and Deserializing + +This module defines hooks to collaborate with L for +serializing C objects, through compact and human readable +strings. You can revert to the old format by invoking this module as + + use NetAddr::IP ':old_storable'; + +You must do this if you have legacy data files containing NetAddr::IP +objects stored using the L module. + +=cut + +my $full_format = "%04X:%04X:%04X:%04X:%04X:%04X:%D.%D.%D.%D"; +my $full6_format = "%04X:%04X:%04X:%04X:%04X:%04X:%04X:%04X"; + +sub import +{ + if (grep { $_ eq ':old_storable' } @_) { + @_ = grep { $_ ne ':old_storable' } @_; + } else { + *{STORABLE_freeze} = sub + { + my $self = shift; + return $self->cidr(); # use stringification + }; + *{STORABLE_thaw} = sub + { + my $self = shift; + my $cloning = shift; # Not used + my $serial = shift; + + my $ip = new NetAddr::IP $serial; + $self->{addr} = $ip->{addr}; + $self->{mask} = $ip->{mask}; + $self->{isv6} = $ip->{isv6}; + return; + }; + } + + if (grep { $_ eq ':aton' } @_) + { + $NetAddr::IP::Lite::Accept_Binary_IP = 1; + @_ = grep { $_ ne ':aton' } @_; + } + if (grep { $_ eq ':old_nth' } @_) + { + $NetAddr::IP::Lite::Old_nth = 1; + @_ = grep { $_ ne ':old_nth' } @_; + } + if (grep { $_ eq ':nofqdn'} @_) + { + $NetAddr::IP::NetAddr::IP::Lite::NoFQDN = 1; + @_ = grep { $_ ne ':nofqdn' } @_; + } + if (grep { $_ eq ':lower' } @_) + { + $full_format = lc($full_format); + $full6_format = lc($full6_format); + NetAddr::IP::Util::lower(); + @_ = grep { $_ ne ':lower' } @_; + } + if (grep { $_ eq ':upper' } @_) + { + $full_format = uc($full_format); + $full6_format = uc($full6_format); + NetAddr::IP::Util::upper(); + @_ = grep { $_ ne ':upper' } @_; + } + if (grep { $_ eq ':rfc3021' } @_) + { + $rfc3021 = 1; + @_ = grep { $_ ne ':rfc3021' } @_; + } + NetAddr::IP->export_to_level(1, @_); +} + +sub compact { + return (ref $_[0] eq 'ARRAY') + ? compactref($_[0]) # Compact(\@list) + : @{compactref(\@_)}; # Compact(@list) or ->compact(@list) +} + +*Compact = \&compact; + +sub Coalesce { + return &coalesce; +} + +sub hostenumref($) { + my $r = _splitref(0,$_[0]); + unless ((notcontiguous($_[0]->{mask}))[1] == 128 || + ($rfc3021 && $_[0]->masklen == 31) ) { + splice(@$r, 0, 1); + splice(@$r, scalar @$r - 1, 1); + } + return $r; +} + +sub splitref { + unshift @_, 0; # mark as no reverse +# perl 5.8.4 fails with this operation. see perl bug [ 23429] +# goto &_splitref; + &_splitref; +} + +sub rsplitref { + unshift @_, 1; # mark as reversed +# perl 5.8.4 fails with this operation. see perl bug [ 23429] +# goto &_splitref; + &_splitref; +} + +sub split { + unshift @_, 0; # mark as no reverse + my $rv = &_splitref; + return $rv ? @$rv : (); +} + +sub rsplit { + unshift @_, 1; # mark as reversed + my $rv = &_splitref; + return $rv ? @$rv : (); +} + +sub full($) { + if (! $_[0]->{isv6} && isIPv4($_[0]->{addr})) { + my @hex = (unpack("n8",$_[0]->{addr})); + $hex[9] = $hex[7] & 0xff; + $hex[8] = $hex[7] >> 8; + $hex[7] = $hex[6] & 0xff; + $hex[6] >>= 8; + return sprintf($full_format,@hex); + } else { + &full6; + } +} + +sub full6($) { + my @hex = (unpack("n8",$_[0]->{addr})); + return sprintf($full6_format,@hex); +} + +sub full6m($) { + my @hex = (unpack("n8",$_[0]->{mask})); + return sprintf($full6_format,@hex); +} + +sub DESTROY {}; + +1; +__END__ + +sub do_prefix ($$$) { + my $mask = shift; + my $faddr = shift; + my $laddr = shift; + + if ($mask > 24) { + return "$faddr->[0].$faddr->[1].$faddr->[2].$faddr->[3]-$laddr->[3]"; + } + elsif ($mask == 24) { + return "$faddr->[0].$faddr->[1].$faddr->[2]."; + } + elsif ($mask > 16) { + return "$faddr->[0].$faddr->[1].$faddr->[2]-$laddr->[2]."; + } + elsif ($mask == 16) { + return "$faddr->[0].$faddr->[1]."; + } + elsif ($mask > 8) { + return "$faddr->[0].$faddr->[1]-$laddr->[1]."; + } + elsif ($mask == 8) { + return "$faddr->[0]."; + } + else { + return "$faddr->[0]-$laddr->[0]"; + } +} + +=pod + +=head2 Methods + +=over + +=item C<-Enew([$addr, [ $mask|IPv6 ]])> + +=item C<-Enew6([$addr, [ $mask]])> + +=item C<-Enew_no([$addr, [ $mask]])> + +=item C<-Enew_from_aton($netaddr)> + +=item new_cis and new_cis6 are DEPRECATED + +=item C<-Enew_cis("$addr $mask)> + +=item C<-Enew_cis6("$addr $mask)> + +The first two methods create a new address with the supplied address in +C<$addr> and an optional netmask C<$mask>, which can be omitted to get +a /32 or /128 netmask for IPv4 / IPv6 addresses respectively. + +The third method C is exclusively for IPv4 addresses and filters +improperly formatted +dot quad strings for leading 0's that would normally be interpreted as octal +format by NetAddr per the specifications for inet_aton. + +B takes a packed IPv4 address and assumes a /32 mask. This +function replaces the DEPRECATED :aton functionality which is fundamentally +broken. + +The last two methods B and B differ from B and +B only in that they except the common Cisco address notation for +address/mask pairs with a B as a separator instead of a slash (/) + +These methods are DEPRECATED because the functionality is now included +in the other "new" methods + + i.e. ->new_cis('1.2.3.0 24') + or + ->new_cis6('::1.2.3.0 120') + +C<-Enew6> and +C<-Enew_cis6> mark the address as being in ipV6 address space even +if the format would suggest otherwise. + + i.e. ->new6('1.2.3.4') will result in ::102:304 + + addresses submitted to ->new in ipV6 notation will + remain in that notation permanently. i.e. + ->new('::1.2.3.4') will result in ::102:304 + whereas new('1.2.3.4') would print out as 1.2.3.4 + + See "STRINGIFICATION" below. + +C<$addr> can be almost anything that can be resolved to an IP address +in all the notations I have seen over time. It can optionally contain +the mask in CIDR notation. + +B notation is understood, with the limitation that the range +specified by the prefix must match with a valid subnet. + +Addresses in the same format returned by C or +C can also be understood, although no mask can be +specified for them. The default is to not attempt to recognize this +format, as it seems to be seldom used. + +To accept addresses in that format, invoke the module as in + + use NetAddr::IP ':aton' + +If called with no arguments, 'default' is assumed. + +If called with an empty string as the argument, returns 'undef' + +C<$addr> can be any of the following and possibly more... + + n.n + n.n/mm + n.n.n + n.n.n/mm + n.n.n.n + n.n.n.n/mm 32 bit cidr notation + n.n.n.n/m.m.m.m + loopback, localhost, broadcast, any, default + x.x.x.x/host + 0xABCDEF, 0b111111000101011110, (a bcd number) + a netaddr as returned by 'inet_aton' + + +Any RFC1884 notation + + ::n.n.n.n + ::n.n.n.n/mmm 128 bit cidr notation + ::n.n.n.n/::m.m.m.m + ::x:x + ::x:x/mmm + x:x:x:x:x:x:x:x + x:x:x:x:x:x:x:x/mmm + x:x:x:x:x:x:x:x/m:m:m:m:m:m:m:m any RFC1884 notation + loopback, localhost, unspecified, any, default + ::x:x/host + 0xABCDEF, 0b111111000101011110 within the limits + of perl's number resolution + 123456789012 a 'big' bcd number (bigger than perl likes) + and Math::BigInt + +A Fully Qualified Domain Name which returns an ipV4 address or an ipV6 +address, embodied in that order. This previously undocumented feature +may be disabled with: + + use NetAddr::IP::Lite ':nofqdn'; + +If called with no arguments, 'default' is assumed. + +If called with an empty string as the argument, returns 'undef' + +=item C<-Ebroadcast()> + +Returns a new object referring to the broadcast address of a given +subnet. The broadcast address has all ones in all the bit positions +where the netmask has zero bits. This is normally used to address all +the hosts in a given subnet. + +=item C<-Enetwork()> + +Returns a new object referring to the network address of a given +subnet. A network address has all zero bits where the bits of the +netmask are zero. Normally this is used to refer to a subnet. + +=item C<-Eaddr()> + +Returns a scalar with the address part of the object as an IPv4 or IPv6 text +string as appropriate. This is useful for printing or for passing the +address part of the NetAddr::IP object to other components that expect an IP +address. If the object is an ipV6 address or was created using ->new6($ip) +it will be reported in ipV6 hex format otherwise it will be reported in dot +quad format only if it resides in ipV4 address space. + +=item C<-Emask()> + +Returns a scalar with the mask as an IPv4 or IPv6 text string as +described above. + +=item C<-Emasklen()> + +Returns a scalar the number of one bits in the mask. + +=item C<-Ebits()> + +Returns the width of the address in bits. Normally 32 for v4 and 128 for v6. + +=item C<-Eversion()> + +Returns the version of the address or subnet. Currently this can be +either 4 or 6. + +=item C<-Ecidr()> + +Returns a scalar with the address and mask in CIDR notation. A +NetAddr::IP object I to the result of this function. +(see comments about ->new6() and ->addr() for output formats) + +=item C<-Eaton()> + +Returns the address part of the NetAddr::IP object in the same format +as the C or C function respectively. If the object +was created using ->new6($ip), the address returned will always be in ipV6 +format, even for addresses in ipV4 address space. + +=item C<-Erange()> + +Returns a scalar with the base address and the broadcast address +separated by a dash and spaces. This is called range notation. + +=item C<-Eprefix()> + +Returns a scalar with the address and mask in ipV4 prefix +representation. This is useful for some programs, which expect its +input to be in this format. This method will include the broadcast +address in the encoding. + +=cut + +# only applicable to ipV4 +sub prefix($) { + return undef if $_[0]->{isv6}; + my $mask = (notcontiguous($_[0]->{mask}))[1]; + return $_[0]->addr if $mask == 128; + $mask -= 96; + my @faddr = split (/\./, $_[0]->first->addr); + my @laddr = split (/\./, $_[0]->broadcast->addr); + return do_prefix $mask, \@faddr, \@laddr; +} + +=item C<-Enprefix()> + +Just as C<-Eprefix()>, but does not include the broadcast address. + +=cut + +# only applicable to ipV4 +sub nprefix($) { + return undef if $_[0]->{isv6}; + my $mask = (notcontiguous($_[0]->{mask}))[1]; + return $_[0]->addr if $mask == 128; + $mask -= 96; + my @faddr = split (/\./, $_[0]->first->addr); + my @laddr = split (/\./, $_[0]->last->addr); + return do_prefix $mask, \@faddr, \@laddr; +} + +=pod + +=item C<-Enumeric()> + +When called in a scalar context, will return a numeric representation +of the address part of the IP address. When called in an array +contest, it returns a list of two elements. The first element is as +described, the second element is the numeric representation of the +netmask. + +This method is essential for serializing the representation of a +subnet. + +=item C<-Ebigint()> + +When called in scalar context, will return a Math::BigInt +representation of the address part of the IP address. When called in +an array context, it returns a list of two elements, The first +element is as described, the second element is the Math::BigInt +representation of the netmask. + +=item C<-Ewildcard()> + +When called in a scalar context, returns the wildcard bits +corresponding to the mask, in dotted-quad or ipV6 format as applicable. + +When called in an array context, returns a two-element array. The +first element, is the address part. The second element, is the +wildcard translation of the mask. + +=cut + +sub wildcard($) { + my $copy = $_[0]->copy; + $copy->{addr} = ~ $copy->{mask}; + $copy->{addr} &= V4net unless $copy->{isv6}; + if (wantarray) { + return ($_[0]->addr, $copy->addr); + } + return $copy->addr; +} + +=pod + +=item C<-Eshort()> + +Returns the address part in a short or compact notation. + + (ie, 127.0.0.1 becomes 127.1). + +Works with both, V4 and V6. + +=cut + +sub _compact_v6 ($) { + my $addr = shift; + + my @o = split /:/, $addr; + return $addr unless @o and grep { $_ =~ m/^0+$/ } @o; + + my @candidates = (); + my $start = undef; + + for my $i (0 .. $#o) + { + if (defined $start) + { + if ($o[$i] !~ m/^0+$/) + { + push @candidates, [ $start, $i - $start ]; + $start = undef; + } + } + else + { + $start = $i if $o[$i] =~ m/^0+$/; + } + } + + push @candidates, [$start, 8 - $start] if defined $start; + + my $l = (sort { $b->[1] <=> $a->[1] } @candidates)[0]; + + return $addr unless defined $l; + + $addr = $l->[0] == 0 ? '' : join ':', @o[0 .. $l->[0] - 1]; + $addr .= '::'; + $addr .= join ':', @o[$l->[0] + $l->[1] .. $#o]; + $addr =~ s/(^|:)0{1,3}/$1/g; + + return $addr; +} + + +#sub _old_compV6 { +# my @addr = split(':',shift); +# my $found = 0; +# my $v; +# foreach(0..$#addr) { +# ($v = $addr[$_]) =~ s/^0+//; +# $addr[$_] = $v || 0; +# } +# @_ = reverse(1..$#addr); +# foreach(@_) { +# if ($addr[$_] || $addr[$_ -1]) { +# last if $found; +# next; +# } +# $addr[$_] = $addr[$_ -1] = ''; +# $found = '1'; +# } +# (my $rv = join(':',@addr)) =~ s/:+:/::/; +# return $rv; +#} + +# thanks to Rob Riepel +# for this faster and more compact solution 11-17-08 +sub _compV6 ($) { + my $ip = shift; + return $ip unless my @candidates = $ip =~ /((?:^|:)0(?::0)+(?::|$))/g; + my $longest = (sort { length($b) <=> length($a) } @candidates)[0]; + $ip =~ s/$longest/::/; + return $ip; +} + +sub short($) { + my $addr = $_[0]->addr; + if (! $_[0]->{isv6} && isIPv4($_[0]->{addr})) { + my @o = split(/\./, $addr, 4); + splice(@o, 1, 2) if $o[1] == 0 and $o[2] == 0; + return join '.', @o; + } + return _compV6($addr); +} + +=item C<-Ecanon()> + +Returns the address part in canonical notation as a string. For +ipV4, this is dotted quad, and is the same as the return value from +"->addr()". For ipV6 it is as per RFC5952, and is the same as the LOWER CASE value +returned by "->short()". + +=cut + +sub canon($) { + my $addr = $_[0]->addr; + return $_[0]->{isv6} ? lc _compV6($addr) : $addr; +} + +=item C<-Efull()> + +Returns the address part in FULL notation for +ipV4 and ipV6 respectively. + + i.e. for ipV4 + 0000:0000:0000:0000:0000:0000:127.0.0.1 + + for ipV6 + 0000:0000:0000:0000:0000:0000:0000:0000 + +To force ipV4 addresses into full ipV6 format use: + +=item C<-Efull6()> + +Returns the address part in FULL ipV6 notation + +=item C<-Efull6m()> + +Returns the mask part in FULL ipV6 notation + +=item C<$me-Econtains($other)> + +Returns true when C<$me> completely contains C<$other>. False is +returned otherwise and C is returned if C<$me> and C<$other> +are not both C objects. + +=item C<$me-Ewithin($other)> + +The complement of C<-Econtains()>. Returns true when C<$me> is +completely contained within C<$other>. + +Note that C<$me> and C<$other> must be C objects. + +=item C-Eis_rfc1918()> + +Returns true when C<$me> is an RFC 1918 address. + + 10.0.0.0 - 10.255.255.255 (10/8 prefix) + 172.16.0.0 - 172.31.255.255 (172.16/12 prefix) + 192.168.0.0 - 192.168.255.255 (192.168/16 prefix) + +=item C<-Eis_local()> + +Returns true when C<$me> is a local network address. + + i.e. ipV4 127.0.0.0 - 127.255.255.255 + or ipV6 === ::1 + +=item C<-Esplitref($bits,[optional $bits1,$bits2,...])> + +Returns a reference to a list of objects, representing subnets of C mask +produced by splitting the original object, which is left +unchanged. Note that C<$bits> must be longer than the original +mask in order for it to be splittable. + +ERROR conditions: + + ->splitref will DIE with the message 'netlimit exceeded' + if the number of return objects exceeds 'netlimit'. + See function 'netlimit' above (default 2**16 or 65536 nets). + + ->splitref returns undef when C or the (bits list) + will not fit within the original object. + + ->splitref returns undef if a supplied ipV4, ipV6, or NetAddr + mask in inappropriately formatted, + +B may be a CIDR mask, a dot quad or ipV6 string or a NetAddr::IP object. +If C is missing, the object is split for into all available addresses +within the ipV4 or ipV6 object ( auto-mask of CIDR 32, 128 respectively ). + +With optional additional C list, the original object is split into +parts sized based on the list. NOTE: a short list will replicate the last +item. If the last item is too large to for what remains of the object after +splitting off the first parts of the list, a "best fits" list of remaining +objects will be returned based on an increasing sort of the CIDR values of +the C list. + + i.e. my $ip = new NetAddr::IP('192.168.0.0/24'); + my $objptr = $ip->split(28, 29, 28, 29, 26); + + has split plan 28 29 28 29 26 26 26 28 + and returns this list of objects + + 192.168.0.0/28 + 192.168.0.16/29 + 192.168.0.24/28 + 192.168.0.40/29 + 192.168.0.48/26 + 192.168.0.112/26 + 192.168.0.176/26 + 192.168.0.240/28 + +NOTE: that /26 replicates twice beyond the original request and /28 fills +the remaining return object requirement. + +=item C<-Ersplitref($bits,[optional $bits1,$bits2,...])> + +C<-Ersplitref> is the same as C<-Esplitref> above except that the split plan is +applied to the original object in reverse order. + + i.e. my $ip = new NetAddr::IP('192.168.0.0/24'); + my @objects = $ip->split(28, 29, 28, 29, 26); + + has split plan 28 26 26 26 29 28 29 28 + and returns this list of objects + + 192.168.0.0/28 + 192.168.0.16/26 + 192.168.0.80/26 + 192.168.0.144/26 + 192.168.0.208/29 + 192.168.0.216/28 + 192.168.0.232/29 + 192.168.0.240/28 + +=item C<-Esplit($bits,[optional $bits1,$bits2,...])> + +Similar to C<-Esplitref> above but returns the list rather than a list +reference. You may not want to use this if a large number of objects is +expected. + +=item C<-Ersplit($bits,[optional $bits1,$bits2,...])> + +Similar to C<-Ersplitref> above but returns the list rather than a list +reference. You may not want to use this if a large number of objects is +expected. + +=cut + +# input: $naip, +# @bits, list of masks for splits +# +# returns: empty array request will not fit in submitted net +# (\@bits,undef) if there is just one plan item i.e. return original net +# (\@bits,\%masks) for a real plan +# +sub _splitplan { + my($ip,@bits) = @_; + my $addr = $ip->addr(); + my $isV6 = $ip->{isv6}; + unless (@bits) { + $bits[0] = $isV6 ? 128 : 32; + } + my $basem = $ip->masklen(); + + my(%nets,$dif); + my $denom = 0; + + my($x,$maddr); + foreach(@bits) { + if (ref $_) { # is a NetAddr::IP + $x = $_->{isv6} ? $_->{addr} : $_->{addr} | V4mask; + ($x,$maddr) = notcontiguous($x); + return () if $x; # spurious bits + $_ = $isV6 ? $maddr : $maddr - 96; + } + elsif ( $_ =~ /^d+$/ ) { # is a negative number of the form -nnnn + ; + } + elsif ($_ = NetAddr::IP->new($addr,$_,$isV6)) { # will be undefined if bad mask and will fall into oops! + $_ = $_->masklen(); + } + else { + return (); # oops! + } + $dif = $_ - $basem; # for normalization + return () if $dif < 0; # overange nets not allowed + return (\@bits,undef) unless ($dif || $#bits); # return if original net = mask alone + $denom = $dif if $dif > $denom; + next if exists $nets{$_}; + $nets{$_} = $_ - $basem; # for normalization + } + +# $denom is the normalization denominator, since these are all exponents +# normalization can use add/subtract to accomplish normalization +# +# keys of %nets are the masks used by this split +# values of %nets are the normalized weighting for +# calculating when the split is "full" or complete +# %masks values contain the actual masks for each split subnet +# @bits contains the masks in the order the user actually wants them +# + my %masks; # calculate masks + my $maskbase = $isV6 ? 128 : 32; + foreach( keys %nets ) { + $nets{$_} = 2 ** ($denom - $nets{$_}); + $masks{$_} = shiftleft(Ones, $maskbase - $_); + } + + my @plan; + my $idx = 0; + $denom = 2 ** $denom; + PLAN: + while ($denom > 0) { # make a net plan + my $nexmask = ($idx < $#bits) ? $bits[$idx] : $bits[$#bits]; + ++$idx; + unless (($denom -= $nets{$nexmask}) < 0) { + return () if (push @plan, $nexmask) > $_netlimit; + next; + } +# a fractional net is needed that is not in the mask list or the replicant + $denom += $nets{$nexmask}; # restore mistake + TRY: + foreach (sort { $a <=> $b } keys %nets) { + next TRY if $nexmask > $_; + do { + next TRY if $denom - $nets{$_} < 0; + return () if (push @plan, $_) > $_netlimit; + $denom -= $nets{$_}; + } while $denom; + } + die 'ERROR: miscalculated weights' if $denom; + } + return () if $idx < @bits; # overrange original subnet request + return (\@plan,\%masks); +} + +# input: $rev, # t/f +# $naip, +# @bits # list of masks for split +# +sub _splitref { + my $rev = shift; + my($plan,$masks) = &_splitplan; +# bug report 82719 + croak("netmask error: overrange or spurious bits") unless defined $plan; +# return undef unless $plan; + my $net = $_[0]->network(); + return [$net] unless $masks; + my $addr = $net->{addr}; + my $isV6 = $net->{isv6}; + my @plan = $rev ? reverse @$plan : @$plan; +# print "plan @plan\n"; + +# create splits + my @ret; + while ($_ = shift @plan) { + my $mask = $masks->{$_}; + push @ret, $net->_new($addr,$mask,$isV6); + last unless @plan; + $addr = (sub128($addr,$mask))[1]; + } + return \@ret; +} + +=pod + +=item C<-Ehostenum()> + +Returns the list of hosts within a subnet. + +ERROR conditions: + + ->hostenum will DIE with the message 'netlimit exceeded' + if the number of return objects exceeds 'netlimit'. + See function 'netlimit' above (default 2**16 or 65536 nets). + +=cut + +sub hostenum ($) { + return @{$_[0]->hostenumref}; +} + +=pod + +=item C<-Ehostenumref()> + +Faster version of C<-Ehostenum()>, returning a reference to a list. + +NOTE: hostenum and hostenumref report zero (0) useable hosts in a /31 +network. This is the behavior expected prior to RFC 3021. To report 2 +useable hosts for use in point-to-point networks, use B<:rfc3021> tag. + + use NetAddr::IP qw(:rfc3021); + +This will cause hostenum and hostenumref to return two (2) useable hosts in +a /31 network. + +=item C<$me-Ecompact($addr1, $addr2, ...)> + +=item C<@compacted_object_list = Compact(@object_list)> + +Given a list of objects (including C<$me>), this method will compact +all the addresses and subnets into the largest (ie, least specific) +subnets possible that contain exactly all of the given objects. + +Note that in versions prior to 3.02, if fed with the same IP subnets +multiple times, these subnets would be returned. From 3.02 on, a more +"correct" approach has been adopted and only one address would be +returned. + +Note that C<$me> and all C<$addr>'s must be C objects. + +=item C<$me-Ecompactref(\@list)> + +=item C<$compacted_object_list = Compact(\@list)> + +As usual, a faster version of C<-Ecompact()> that returns a +reference to a list. Note that this method takes a reference to a list +instead. + +Note that C<$me> must be a C object. + +=cut + +sub compactref($) { +# my @r = sort { NetAddr::IP::Lite::comp_addr_mask($a,$b) } @{$_[0]} # use overload 'cmp' function +# or return []; +# return [] unless @r; + + my @r; + { + my $unr = []; + my $args = $_[0]; + + if (ref $_[0] eq __PACKAGE__ and ref $_[1] eq 'ARRAY') { + # ->compactref(\@list) + # + $unr = [$_[0], @{$_[1]}]; # keeping structures intact + } + else { + # Compact(@list) or ->compact(@list) or Compact(\@list) + # + $unr = $args; + } + + return [] unless @$unr; + + foreach(@$unr) { + $_->{addr} = $_->network->{addr}; + } + + @r = sort @$unr; + } + + my $changed; + do { + $changed = 0; + for(my $i=0; $i <= $#r -1;$i++) { + if ($r[$i]->contains($r[$i +1])) { + splice(@r,$i +1,1); + ++$changed; + --$i; + } + elsif ((notcontiguous($r[$i]->{mask}))[1] == (notcontiguous($r[$i +1]->{mask}))[1]) { # masks the same + if (hasbits($r[$i]->{addr} ^ $r[$i +1]->{addr})) { # if not the same netblock + my $upnet = $r[$i]->copy; + $upnet->{mask} = shiftleft($upnet->{mask},1); + if ($upnet->contains($r[$i +1])) { # adjacent nets in next net up + $r[$i] = $upnet; + splice(@r,$i +1,1); + ++$changed; + --$i; + } + } else { # identical nets + splice(@r,$i +1,1); + ++$changed; + --$i; + } + } + } + } while $changed; + return \@r; +} + +=pod + +=item C<$me-Ecoalesce($masklen, $number, @list_of_subnets)> + +=item C<$arrayref = Coalesce($masklen,$number,@list_of_subnets)> + +Will return a reference to list of C subnets of +C<$masklen> mask length, when C<$number> or more addresses from +C<@list_of_subnets> are found to be contained in said subnet. + +Subnets from C<@list_of_subnets> with a mask shorter than C<$masklen> +are passed "as is" to the return list. + +Subnets from C<@list_of_subnets> with a mask longer than C<$masklen> +will be counted (actually, the number of IP addresses is counted) +towards C<$number>. + +Called as a method, the array will include C<$me>. + +WARNING: the list of subnet must be the same type. i.e ipV4 or ipV6 + +=cut + +sub coalesce +{ + my $masklen = shift; + if (ref $masklen && ref $masklen eq __PACKAGE__ ) { # if called as a method + push @_,$masklen; + $masklen = shift; + } + + my $number = shift; + + # Addresses are at @_ + return [] unless @_; + my %ret = (); + my $type = $_[0]->{isv6}; + return [] unless defined $type; + + for my $ip (@_) + { + return [] unless $ip->{isv6} == $type; + $type = $ip->{isv6}; + my $n = NetAddr::IP->new($ip->addr . '/' . $masklen)->network; + if ($ip->masklen > $masklen) + { + $ret{$n} += $ip->num + $NetAddr::IP::Lite::Old_nth; + } + } + + my @ret = (); + + # Add to @ret any arguments with netmasks longer than our argument + for my $c (sort { $a->masklen <=> $b->masklen } + grep { $_->masklen <= $masklen } @_) + { + next if grep { $_->contains($c) } @ret; + push @ret, $c->network; + } + + # Now add to @ret all the subnets with more than $number hits + for my $c (map { new NetAddr::IP $_ } + grep { $ret{$_} >= $number } + keys %ret) + { + next if grep { $_->contains($c) } @ret; + push @ret, $c; + } + + return \@ret; +} + +=pod + +=item C<-Efirst()> + +Returns a new object representing the first usable IP address within +the subnet (ie, the first host address). + +=item C<-Elast()> + +Returns a new object representing the last usable IP address within +the subnet (ie, one less than the broadcast address). + +=item C<-Enth($index)> + +Returns a new object representing the I-th usable IP address within +the subnet (ie, the I-th host address). If no address is available +(for example, when the network is too small for C<$index> hosts), +C is returned. + +Version 4.00 of NetAddr::IP and version 1.00 of NetAddr::IP::Lite implements +C<-Enth($index)> and C<-Enum()> exactly as the documentation states. +Previous versions behaved slightly differently and not in a consistent +manner. See the README file for details. + +To use the old behavior for C<-Enth($index)> and C<-Enum()>: + + use NetAddr::IP::Lite qw(:old_nth); + + old behavior: + NetAddr::IP->new('10/32')->nth(0) == undef + NetAddr::IP->new('10/32')->nth(1) == undef + NetAddr::IP->new('10/31')->nth(0) == undef + NetAddr::IP->new('10/31')->nth(1) == 10.0.0.1/31 + NetAddr::IP->new('10/30')->nth(0) == undef + NetAddr::IP->new('10/30')->nth(1) == 10.0.0.1/30 + NetAddr::IP->new('10/30')->nth(2) == 10.0.0.2/30 + NetAddr::IP->new('10/30')->nth(3) == 10.0.0.3/30 + +Note that in each case, the broadcast address is represented in the +output set and that the 'zero'th index is alway undef except for +a point-to-point /31 or /127 network where there are exactly two +addresses in the network. + + new behavior: + NetAddr::IP->new('10/32')->nth(0) == 10.0.0.0/32 + NetAddr::IP->new('10.1/32'->nth(0) == 10.0.0.1/32 + NetAddr::IP->new('10/31')->nth(0) == 10.0.0.0/31 + NetAddr::IP->new('10/31')->nth(1) == 10.0.0.1/31 + NetAddr::IP->new('10/30')->nth(0) == 10.0.0.1/30 + NetAddr::IP->new('10/30')->nth(1) == 10.0.0.2/30 + NetAddr::IP->new('10/30')->nth(2) == undef + +Note that a /32 net always has 1 usable address while a /31 has exactly +two usable addresses for point-to-point addressing. The first +index (0) returns the address immediately following the network address +except for a /31 or /127 when it return the network address. + +=item C<-Enum()> + +As of version 4.42 of NetAddr::IP and version 1.27 of NetAddr::IP::Lite +a /31 and /127 with return a net B value of 2 instead of 0 (zero) +for point-to-point networks. + +Version 4.00 of NetAddr::IP and version 1.00 of NetAddr::IP::Lite +return the number of usable IP addresses within the subnet, +not counting the broadcast or network address. + +Previous versions worked only for ipV4 addresses, returned a +maximum span of 2**32 and returned the number of IP addresses +not counting the broadcast address. + (one greater than the new behavior) + +To use the old behavior for C<-Enth($index)> and C<-Enum()>: + + use NetAddr::IP::Lite qw(:old_nth); + +WARNING: + +NetAddr::IP will calculate and return a numeric string for network +ranges as large as 2**128. These values are TEXT strings and perl +can treat them as integers for numeric calculations. + +Perl on 32 bit platforms only handles integer numbers up to 2**32 +and on 64 bit platforms to 2**64. + +If you wish to manipulate numeric strings returned by NetAddr::IP +that are larger than 2**32 or 2**64, respectively, you must load +additional modules such as Math::BigInt, bignum or some similar +package to do the integer math. + +=item C<-Ere()> + +Returns a Perl regular expression that will match an IP address within +the given subnet. Defaults to ipV4 notation. Will return an ipV6 regex +if the address in not in ipV4 space. + +=cut + +sub re ($) +{ + return &re6 unless isIPv4($_[0]->{addr}); + my $self = shift->network; # Insure a "zero" host part + my ($addr, $mlen) = ($self->addr, $self->masklen); + my @o = split('\.', $addr, 4); + + my $octet= '(?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])'; + my @r = @o; + my $d; + +# for my $i (0 .. $#o) +# { +# warn "# $self: $r[$i] == $o[$i]\n"; +# } + + if ($mlen != 32) + { + if ($mlen > 24) + { + $d = 2 ** (32 - $mlen) - 1; + $r[3] = '(?:' . join('|', ($o[3]..$o[3] + $d)) . ')'; + } + else + { + $r[3] = $octet; + if ($mlen > 16) + { + $d = 2 ** (24 - $mlen) - 1; + $r[2] = '(?:' . join('|', ($o[2]..$o[2] + $d)) . ')'; + } + else + { + $r[2] = $octet; + if ($mlen > 8) + { + $d = 2 ** (16 - $mlen) - 1; + $r[1] = '(?:' . join('|', ($o[1]..$o[1] + $d)) . ')'; + } + else + { + $r[1] = $octet; + if ($mlen > 0) + { + $d = 2 ** (8 - $mlen) - 1; + $r[0] = '(?:' . join('|', ($o[0] .. $o[0] + $d)) . ')'; + } + else { $r[0] = $octet; } + } + } + } + } + + ### no digit before nor after (look-behind, look-ahead) + return "(?:(?re6()> + +Returns a Perl regular expression that will match an IP address within +the given subnet. Always returns an ipV6 regex. + +=cut + +sub re6($) { + my @net = split('',sprintf("%04X%04X%04X%04X%04X%04X%04X%04X",unpack('n8',$_[0]->network->{addr}))); + my @brd = split('',sprintf("%04X%04X%04X%04X%04X%04X%04X%04X",unpack('n8',$_[0]->broadcast->{addr}))); + + my @dig; + + foreach(0..$#net) { + my $n = $net[$_]; + my $b = $brd[$_]; + my $m; + if ($n.'' eq $b.'') { + if ($n =~ /\d/) { + push @dig, $n; + } else { + push @dig, '['.(lc $n).$n.']'; + } + } else { + my $n = $net[$_]; + my $b = $brd[$_]; + if ($n.'' eq 0 && $b =~ /F/) { + push @dig, 'x'; + } + elsif ($n =~ /\d/ && $b =~ /\d/) { + push @dig, '['.$n.'-'.$b.']'; + } + elsif ($n =~ /[A-F]/ && $b =~ /[A-F]/) { + $n .= '-'.$b; + push @dig, '['.(lc $n).$n.']'; + } + elsif ($n =~ /\d/ && $b =~ /[A-F]/) { + $m = ($n == 9) ? 9 : $n .'-9'; + if ($b =~ /A/) { + $m .= 'aA'; + } else { + $b = 'A-'. $b; + $m .= (lc $b). $b; + } + push @dig, '['.$m.']'; + } + elsif ($n =~ /[A-F]/ && $b =~ /\d/) { + if ($n =~ /A/) { + $m = 'aA'; + } else { + $n .= '-F'; + $m = (lc $n).$n; + } + if ($b == 9) { + $m .= 9; + } else { + $m .= $b .'-9'; + } + push @dig, '['.$m.']'; + } + } + } + my @grp; + do { + my $grp = join('',splice(@dig,0,4)); + if ($grp =~ /^(0+)/) { + my $l = length($1); + if ($l == 4) { + $grp = '0{1,4}'; + } else { + $grp =~ s/^${1}/0\{0,$l\}/; + } + } + if ($grp =~ /(x+)$/) { + my $l = length($1); + if ($l == 4) { + $grp = '[0-9a-fA-F]{1,4}'; + } else { + $grp =~ s/x+/\[0\-9a\-fA\-F\]\{$l\}/; + } + } + push @grp, $grp; + } while @dig > 0; + return '('. join(':',@grp) .')'; +} + +sub mod_version { + return $VERSION; + &Compact; # suppress warnings about these symbols + &Coalesce; + &STORABLE_freeze; + &STORABLE_thaw; +} + +=pod + +=back + +=head1 EXPORT_OK + + Compact + Coalesce + Zeros + Ones + V4mask + V4net + netlimit + +=head1 NOTES / BUGS ... FEATURES + +NetAddr::IP only runs in Pure Perl mode on Windows boxes because I don't +have the resources or know how to get the "configure" stuff working in the +Windows environment. Volunteers WELCOME to port the "C" portion of this +module to Windows. + +=head1 HISTORY + +=over 4 + +See the Changes file + +=back + +=head1 AUTHORS + +Luis E. Muñoz Eluismunoz@cpan.orgE, +Michael Robinton Emichael@bizsystems.comE + +=head1 WARRANTY + +This software comes with the same warranty as Perl itself (ie, none), +so by using it you accept any and all the liability. + +=head1 COPYRIGHT + +This software is (c) Luis E. Muñoz, 1999 - 2007, and (c) Michael +Robinton, 2006 - 2014. + +All rights reserved. + +This program is free software; you can redistribute it and/or modify +it under the terms of either: + + a) the GNU General Public License as published by the Free + Software Foundation; either version 2, or (at your option) any + later version, or + + b) the "Artistic License" which comes with this distribution. + +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 either +the GNU General Public License or the Artistic License for more details. + +You should have received a copy of the Artistic License with this +distribution, in the file named "Artistic". If not, I'll be glad to provide +one. + +You should also have received a copy of the GNU General Public License +along with this program in the file named "Copying". If not, write to the + + Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor + Boston, MA 02110-1301 USA. + +or visit their web page on the internet at: + + http://www.gnu.org/copyleft/gpl.html. + +=head1 SEE ALSO + + perl(1) L, L, +L + +=cut + +1; diff --git a/Lite/Changes b/Lite/Changes new file mode 100644 index 0000000..7104f43 --- /dev/null +++ b/Lite/Changes @@ -0,0 +1,444 @@ +Revision history for Perl extension NetAddr::IP::Lite + +1.57 Fri Mar 25 16:18:26 PDT 2016 + correct non-suppression of leading zeros in certain instances of + new_no use. Thanks to "Mike Bartman (mbartman)" + for spotting the bug. + +1.56 Mon Aug 17 15:35:28 PDT 2015 + fix typo in Util.pm 1.53 MakefilePL that cause compiler to not be found at all + +1.55 Thu Aug 13 22:44:48 PDT 2015 + added method is_local() + inspired by request from Xan Charbonne + + fix Util Makefile.PL to accomodate bug in Android's sh + + fix Util/Makefile.PL issue with clang compiler, bug 86831 + +1.54 Wed Jun 11 09:36:10 PDT 2014 + change input filter for resolvable hostnames + to allow the underscore character + Thanks to grankio [...] gmail.com for the heads up on this issue. + +1.53 Sat Apr 5 09:32:11 PDT 2014 + add documentation about FQDN conversion and + an option to disable + +1.52 Mon Jan 27 11:59:58 PST 2014 + modify Makefile.PL to bypass missing 'pod2text' + +1.51 Thu Sep 12 12:54:22 PDT 2013 + add new6FFFF, RFC4291 compliant ipv4->ipV6 new + +1.50 Sat May 25 15:10:45 PDT 2013 + add =encoding UTF-8 + +1.49 Tue Apr 9 12:02:34 PDT 2013 + In Util.pm v1.50 + changed Makefile.PL to check for config.h when building for XS + with 'gcc', try building with 'cc', and check again. + If config.h is not found, force Pure Perl mode. + + Kill XS in winduhs and Darwin, both of which misbehave when compiling XS code + +1.48 Wed Apr 3 10:52:24 PDT 2013 + Update Util.pm v1.49 to better detect 'winduhs' + +1.47 Mon Oct 29 13:30:14 PDT 2012 + update Lite.pm v1.47 to support bracketed IPv6 URI notation + as described in RFC-3986 + Thanks to Quanah Gibson-Mount mishikal@yahoo.com + +1.46 Tue Oct 2 12:36:11 PDT 2012 + correct incorrect format for IPv6 embedded IPv4 addresses + in InetBase v0.8 + +1.45 Fri Aug 10 11:46:18 PDT 2012 + --- + +1.44 Tue May 8 16:24:03 PDT 2012 + fixed bug that return $ip->num() = 2^128 for 0.0.0.0/0 + Thanks to Sebastian for spotting it. + +1.43 Fri Apr 6 13:19:48 PDT 2012 + fix bug #75976, change in behavior introduced in v4.050 + where an empty string supplied to "new" previously returned + 'undef' and now returns 'default' for ipV4 or ipV6 + +1.42 Wed Mar 7 12:50:04 PST 2012 + add "is_rfc1918" and tests + + correct typos in documentation + +1.41 Fri Nov 11 19:23:11 PST 2011 + up rev for documentation update + update documentation in InetBase v0.06 + +1.40 Fri Nov 11 13:20:32 PST 2011 + add call to InetBase::fillIPv4 to all uses of gethostbyname + + break out the code in InetBase v0.05 that expands short IPv4 + addresses into dotquad format to account for broken BSD + implementations of inet_aton and gethostbyname that do + not recognize the short format. EXPORT this as sub 'fillIPv4' + + in Util.pm v1.45, add 'fillIPv4' to calls to gethostbyname to + work around broken inet_aton and gethostbyname implementations + in certain BSD implementations + +1.39 Wed Nov 2 19:15:31 PDT 2011 + bump rev to incorporate + improved inet_aton in InetBase v0.04 to overcome broken + gethostbyname found in NetBSD and OpenBSD + +1.38 Fri Oct 28 11:41:22 PDT 2011 + patch for bug 71869, issues with Math::BigInt varients + +1.37 Thu Oct 27 12:48:55 PDT 2011 + add detection of early Math::Bigint 0.01 object structures + circa perl 5.6.1 + + remove Calc.pm as part of above + + fix bug 71869 - a failed test routine + +1.36 Wed Oct 26 08:52:34 PDT 2011 + fix bug #71925. A a sub-varient of #62521 that showed up only for + short notation for IPv4. i.e. 127/n, 127.0/n, 127.0.0/n but + not 127.0.0.0/n + +1.35 Tue Oct 25 16:18:38 PDT 2011 + add test for api-version of Math::BigInt to support versions + earlier than 1.70, circa Dec 2003. + Thanks to Paul Howarth for spotting that bug. + +1.34 Mon Oct 24 14:38:16 PDT 2011 + use Math::BigInt::Calc for creating BigInt values and fall + back to NetAddr::IP::Calc if Math::BigInt is not present. + Thanks to Paul Howarth for spotting that bug. + + remove reference to Config{osname} in InetBase.pm v0.03 + (Util 1.43) + +1.33 Sat Oct 22 01:47:42 PDT 2011 + In Lite/Util/lib/NetAddr/IP/Lite/Util/InetBase.pm v0.02 + Socket6 prior to version 0.23 does not have AF_INET6 in the + EXPORT_OK array, modify InetBase.pm v0.2 to work around this. + + Add support for Math::BigInt objects + +1.32 Sat Oct 15 22:05:23 PDT 2011 + bug68723, add capability to parse input of the form + ->new6(12345,1). This should have been there but was + missing. Thanks to Andrei Benea for spotting this. + + In Util v1.41 + add inet_pton, inet_ntop, AF_INET, AF_INET6 + + modify inet_n2dx and inet_n2ad to + recognize the new 128 bit IPv4 format + ::FFFF:FFFF:0:0 + + replace isIPv4 with a pure perl version for portablity + + split the following into NetAddr::IP::InetBase v0.01 + to provide better long term support for IPv6 + inet_aton + inet_ntoa + ipv6_aton + ipv6_n2x + ipv6_n2d + inet_any2n + inet_n2dx + inet_n2ad + inet_ntop + inet_pton + packzeros + isIPv4 + isNewIPv4 + isAnyIPv4 + AF_INET + AF_INET6 + +1.31 Sat Oct 8 01:33:44 PDT 2011 + remove debug print statement from Util.pm v1.40 + +1.30 Thu Oct 6 23:41:42 PDT 2011 + correct internal variable reference in Util.pm 1.39 + +1.29 Thu Oct 6 20:20:33 PDT 2011 + updated to UTIL 1.38 + +1.28 Wed Apr 6 11:31:19 PDT 2011 + Update documentation on the use of "adding constants + to an IP address". + +1.27 Tue Mar 22 15:26:02 PDT 2011 + Update Lite.pm to encompass treatment of /31 and /127 + point-to-point networks as described in RFC 3021 + + NOTE: for /31's and /127's + this changes the behavior of the following methods: + first returns the "network" address + last returns the "broadcast" address + nth index 0 returns "network" addr instead of undef + nth index 1 returns "broadcast" addr instead of undef + num returns 2 instead of 0 (zero) + + "old_nth" behavior is unchanged + + Thanks to Todd Caine todd.caine@gmail.com for pointing this out. + +1.26 Tue Mar 8 15:18:16 PST 2011 + Updated "sub num" to support usable IP ranges greater than 2**32 + + Thanks to Jan Ploski jan@plosquare.com for finding this bug + +1.25 Sat Feb 19 10:04:00 PST 2011 + correction to use of Util.pm package lexicals + + thanks to mishikal@yahoo.com for spotting the bug and to + Mark Martinec mark.martinec+ama...@ijs.si for the solution. + +1.24 Fri Dec 17 17:47:47 PST 2010 + Modify subs "new" and "new6" to accomodate + Cisco mask syntax that uses space instead of "/" for a separator + This eliminates the need for "new_cis" and "newcis6" which are now + deprecated. + + Modify t/v4-cnew.t and add t/v6-cnew.t to test the above + +1.23 Fri Nov 19 10:48:01 PST 2010 + add :upper and :lower to Lite.pm v1.23 + add comments about rfc5952 requirement for lowercase ipV6 notation + add test for :lower + +1.22 Tue Nov 16 16:28:37 PST 2010 + update new6 to properly classify short ipv4 notation + i.e. 127/8 with test for ":" rather than match for \d.\d.\d.\d + + thanks to Steve Huff (SHUFF) * shuff@cpan.org for + spotting that bug. + + update t/v4-new.t for deprecated array syntax in perl 5.13 + was: qw(...stuff...) + is: (qw(...stuff...)) + + thanks to Todd Rinaldo for reporting this + +1.21 Thu Oct 28 14:26:19 PDT 2010 + fix bug where new6 improperly assigns the mask value + for and ipv4 address in 32 bit space instead of 128 bit space + + Thanks to Mark Martinec and Steve Huff (SHUFF) * shuff@cpan.org + for spotting and replicating that bug + + added new_cis and new_cis6 to Lite.pm v1.21 to accomodate + Cisco syntax that has IP and MASK separated by a space. + + Updated typo in documentation that left out example + print new6 stuff + +1.20 Mon Oct 25 16:22:01 PDT 2010 + Updated _xnew to properly handle ipV6 notation of the form + xxxx:xxxx:xxxx:xxxx:xxxx:xxxx, DDD + + Thanks to Dusty Mabe for spotting this bug + +1.19 Wed Sep 29 10:32:50 PDT 2010 + Conditionalize import of AF_INET6 in Util.pm + NetAddr::IP::UtilPolluted + +1.18 Wed Sep 22 13:39:08 PDT 2010 + Added overload => 'ne' and '!=' to Lite.pm + +1.17 Tue Sep 21 17:50:50 PDT 2010 + Pull Socket6 stuff out of Lite and put into + NetAddr::IP::Util.pm in its own namespace + +1.16 Wed Aug 11 12:45:49 PDT 2010 + When using Socket6, pull in missing symbol PF_INET6, which may + or may not be present, from Socket. + +1.15 Tue Jul 20 15:32:23 PDT 2010 + Resolve named hosts using gethostbyname, followed by gethostbyname6 + to determine whether to set ipV6 flag + + Thanks to Dusty Mabe for spotting this bug + +1.14 Thu Jul 8 18:17:38 PDT 2010 + added support for the sub "new" to resolve host6 names + if the OPTIONAL perl Socket6 module is available + +1.13 Tue Dec 9 16:00:35 PST 2008 + added missing regexp to classify arguments as BCD numbers, + apparently this has been missing from NetAddr::IP::Lite + since the first release. + Thanks to Carlos Vicente cvicente@cpan.org for reporting this bug. + + revised UtilPP v1.7 to work around perl 5.8.4 + failures with certain @_ operations of goto &sub... + see perl bug [ 23429]. Unfortunately, perl-5.8.4 is + the distribution of choice for many solaris boxes + +1.12 Sun Nov 23 19:32:59 PST 2008 + repaired missing sub Zeros + + added minus (-) overloading to allow the subtraction + of two NetAddr::IP objects to get the difference between + the object->{addr}'s as a numeric value + Thanks to Rob Riepel + for the initial code and inspiration for this enhancement + +1.11 Sat Nov 1 15:13:48 PST 2008 + add test for characters not allowed by rfc952 before + the call to gethostbyname in sub new() for those people + that insist on using deprecated functionality :aton + and OS's that fail to notice calls to gethostbyname + with binary arguments + +1.10 Wed Oct 22 14:54:12 PDT 2008 + add new no octal method for improperly formatted ipV4 addresses + + In Util.pm v1.22, eliminated dependence on PL_sawampersand + thanks to Mark Martinec + for spotting this and submitting a patch. + + In Util.pm v1.22, force -noxs mode for Win32 + + In Util.pm v1.22, use autoconf to configure 'C' build + +1.09 Thu Oct 16 19:35:33 PDT 2008 + again... clear build bug for Win32 in Util.pm v 1.21 + +1.08 Sat Sep 27 12:27:28 PDT 2008 + in Util v0.19 + updated test for ENDIANess in siteconf + + add test in inet_aton to detect overange IP dot quad values + missed by some broken Socket implementations + i.e. 256.1.1.1 + +1.07 Tue Sep 2 19:09:57 PDT 2008 + in the off chance that NetAddr::IP::Lite objects are created + and the caller later loads NetAddr::IP and expects to use + those objects, let the AUTOLOAD routine find and redirect + NetAddr::IP::Lite method and subroutine calls to NetAddr::IP. + + updated t/v4-wnew.t so that non-existent + domains are "really" not there + +1.06 Sat Jun 7 12:57:18 PDT 2008 + add method "new_from_aton" and related documentation + + comparisons of the form <, >, <=, >= + 10.0.0.0/24 {operator} 10.0.0.0/16 + return now return the comparison of the cidr value + when the address portion is equal. +NOTE: this comparison returns the comparison of the NUMERIC + value of the CIDR. This produces the counter intuitive result + that /24 > /16. There is logic to this, really! For proper + operation of commands like "Compact" and "Coalesce", lists of + netaddr objects must sort in ascending order. However, this + conflicts with the requirement for larger netblocks to sort + FIRST so as to include smaller ones. This logic extends to + any requirement for a sort of netaddr objects. It should be + further noted that the mixing of netaddr objects with varying + IP addresses and CIDR allocations can lead to unexpected + results since the comparisons done first on the IP portion + and then on the CIDR portion. The documentation has been + updated appropriately. + Thanks to Peter DeVries for spotting this discrepancy + +1.05 undocumented +1.04 undocumented + +1.03 Sun Aug 6 10:48:25 PDT 2006 + update Util.pm v0.18 documentation + +1.02 Fri Aug 4 14:14:16 PDT 2006 + $isV6 global converted to a lexical variable within sub "_xnew" + $Class global removed and replaced by calls to UNIVERSAL::isa + Thanks to julian@mehnle.net for spotting problems related to + using the Lite.pm with mod_perl + +1.01 Thu Jul 6 10:46:48 PDT 2006 + update v4-wnew.t to warn user of possible long wait + update Util.pm v0.17 -- see Changes in that distro + +1.00 Mon Jun 26 13:34:00 PDT 2006 + changed behavior of ->nth and ->num + to 'exactly' conform to the documentation + + add :old_nth tag to preserve old behavior + and update tests to check both + +0.12 Sun Jun 25 16:13:00 PDT 2006 + imported missing 'bcd2bin' + + fixed Util->new() issues with long digit strings + ->new('::fffff') and non hex digits ->new('::foo'). + Thanks to Radoslaw Zielinski + for spotting these 3 bugs + +0.11 Wed Jun 14 14:53:21 PDT 2006 + add 'sub new6' and related functionality to methods + that print or return v4/6 information or text. + + add $self->{isv6} flag for hint to ipV6 status + + corrected bug in sub num that miscalculated the number + of IP's in a net for /31 /32 + +0.10 Tue Jun 13 14:07:46 PDT 2006 + bring 'sub new' into full compliance with NetAddr::IP, + correct compatibility with for ==,>,<,=>,>=,<=>,cmp + and update documentation to reflect actual implementation + + add 'copy' function that return a completely new object + + export (Zero Ones V4mask V4net) + + update Util.pm v0.15 so shiftleft returns original + argument when the shift count is zero or undefined + +0.09 Tue Jun 6 08:37:01 PDT 2006 + update Util/Makefile.PM to check for link libraries + that ExtUtils::MakeMaker does not find properly + + remove 'use warnings' from Lite.pm for backwards + compatibility with older perl versions + +0.08 Tue Jun 6 08:33:11 PDT 2006 + update Util.xs for build on windoze + +0.07 Tue Jun 6 08:21:12 PDT 2006 + update NetAddr::IP::Util to v0.12 + +0.06 Mon Jun 5 21:34:28 PDT 2006 + fix Sparc problems in Util v0.11 + 1) add workaround for OS's that do not have inet_aton + + 2) add workaround for compilers that do not understand + #if MACRO1 == MACRO2 + +0.05 Sun May 7 18:06:43 PDT 2006 + updated UtilPP.pm v0.06 to remove unnecessary pack(unpack) sequences + to speed up ipv6->4, ipv4->6 conversions + +0.04 Fri Apr 28 17:36:28 PDT 2006 + left Util/Makefile.pl out of the top level distro + +0.03 Fri Apr 28 17:26:51 PDT 2006 + oops! left prerequisite Util 0.08 in the Makefile + when it is include in this distro + +0.02 Fri Apr 28 16:11:00 PDT 2006 + update Lite.pm to accept ->new('addr/mask') + where addr and mask are both in IP address format + + add test for above t/netaddr.t + +0.01 Wed Apr 26 19:03:18 PDT 2006 + initial release diff --git a/Lite/Lite.pm b/Lite/Lite.pm new file mode 100644 index 0000000..b291e23 --- /dev/null +++ b/Lite/Lite.pm @@ -0,0 +1,1685 @@ +#!/usr/bin/perl + +package NetAddr::IP::Lite; + +use Carp; +use strict; +#use diagnostics; +#use warnings; +use NetAddr::IP::InetBase qw( + inet_any2n + isIPv4 + inet_n2dx + inet_aton + ipv6_aton + ipv6_n2x + fillIPv4 +); +use NetAddr::IP::Util qw( + addconst + sub128 + ipv6to4 + notcontiguous + shiftleft + hasbits + bin2bcd + bcd2bin + mask4to6 + ipv4to6 + naip_gethostbyname + havegethostbyname2 +); + +use vars qw(@ISA @EXPORT_OK $VERSION $Accept_Binary_IP $Old_nth $NoFQDN $AUTOLOAD *Zero); + +$VERSION = do { my @r = (q$Revision: 1.57 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; + +require Exporter; + +@ISA = qw(Exporter); + +@EXPORT_OK = qw(Zeros Zero Ones V4mask V4net); + +# Set to true, to enable recognizing of ipV4 && ipV6 binary notation IP +# addresses. Thanks to Steve Snodgrass for reporting. This can be done +# at the time of use-ing the module. See docs for details. + +$Accept_Binary_IP = 0; +$Old_nth = 0; +*Zero = \&Zeros; + +=pod + +=encoding UTF-8 + +=head1 NAME + +NetAddr::IP::Lite - Manages IPv4 and IPv6 addresses and subnets + +=head1 SYNOPSIS + + use NetAddr::IP::Lite qw( + Zeros + Ones + V4mask + V4net + :aton DEPRECATED ! + :old_nth + :upper + :lower + :nofqdn + ); + + my $ip = new NetAddr::IP::Lite '127.0.0.1'; + or if your prefer + my $ip = NetAddr::IP::Lite->new('127.0.0.1); + or from a packed IPv4 address + my $ip = new_from_aton NetAddr::IP::Lite (inet_aton('127.0.0.1')); + or from an octal filtered IPv4 address + my $ip = new_no NetAddr::IP::Lite '127.012.0.0'; + + print "The address is ", $ip->addr, " with mask ", $ip->mask, "\n" ; + + if ($ip->within(new NetAddr::IP::Lite "127.0.0.0", "255.0.0.0")) { + print "Is a loopback address\n"; + } + + # This prints 127.0.0.1/32 + print "You can also say $ip...\n"; + + The following four functions return ipV6 representations of: + + :: = Zeros(); + FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF = Ones(); + FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:: = V4mask(); + ::FFFF:FFFF = V4net(); + + Will also return an ipV4 or ipV6 representation of a + resolvable Fully Qualified Domanin Name (FQDN). + +=head1 INSTALLATION + +Un-tar the distribution in an appropriate directory and type: + + perl Makefile.PL + make + make test + make install + +B depends on B which installs by default with its primary functions compiled +using Perl's XS extensions to build a 'C' library. If you do not have a 'C' +complier available or would like the slower Pure Perl version for some other +reason, then type: + + perl Makefile.PL -noxs + make + make test + make install + +=head1 DESCRIPTION + +This module provides an object-oriented abstraction on top of IP +addresses or IP subnets, that allows for easy manipulations. Most of the +operations of NetAddr::IP are supported. This module will work with older +versions of Perl and is compatible with Math::BigInt. + +* By default B functions and methods return string IPv6 +addresses in uppercase. To change that to lowercase: + +NOTE: the AUGUST 2010 RFC5952 states: + + 4.3. Lowercase + + The characters "a", "b", "c", "d", "e", and "f" in an IPv6 + address MUST be represented in lowercase. + +It is recommended that all NEW applications using NetAddr::IP::Lite be +invoked as shown on the next line. + + use NetAddr::IP::Lite qw(:lower); + +* To ensure the current IPv6 string case behavior even if the default changes: + + use NetAddr::IP::Lite qw(:upper); + + +The internal representation of all IP objects is in 128 bit IPv6 notation. +IPv4 and IPv6 objects may be freely mixed. + +The supported operations are described below: + +=cut + +# in the off chance that NetAddr::IP::Lite objects are created +# and the caller later loads NetAddr::IP and expects to use +# those objects, let the AUTOLOAD routine find and redirect +# NetAddr::IP::Lite method and subroutine calls to NetAddr::IP. +# + +my $parent = 'NetAddr::IP'; + +# test function +# +# input: subroutine name in NetAddr::IP +# output: t/f if sub name exists in NetAddr::IP namespace +# +#sub sub_exists { +# my $other = $parent .'::'; +# return exists ${$other}{$_[0]}; +#} + +sub DESTROY {}; + +sub AUTOLOAD { + no strict; + my ($pkg,$func) = ($AUTOLOAD =~ /(.*)::([^:]+)$/); + my $other = $parent .'::'; + + if ($pkg =~ /^$other/o && exists ${$other}{$func}) { + $other .= $func; + goto &{$other}; + } + + my @stack = caller(0); + + if ( $pkg eq ref $_[0] ) { + $other = qq|Can't locate object method "$func" via|; + } + else { + $other = qq|Undefined subroutine \&$AUTOLOAD not found in|; + } + die $other . qq| package "$parent" or "$pkg" (did you forgot to load a module?) at $stack[1] line $stack[2].\n|; +} + +=head2 Overloaded Operators + +=cut + +# these really should be packed in Network Long order but since they are +# symmetrical, that extra internal processing can be skipped + +my $_v4zero = pack('L',0); +my $_zero = pack('L4',0,0,0,0); +my $_ones = ~$_zero; +my $_v4mask = pack('L4',0xffffffff,0xffffffff,0xffffffff,0); +my $_v4net = ~ $_v4mask; +my $_ipv4FFFF = pack('N4',0,0,0xffff,0); + +sub Zeros() { + return $_zero; +} +sub Ones() { + return $_ones; +} +sub V4mask() { + return $_v4mask; +} +sub V4net() { + return $_v4net; +} + + ############################################# + # These are the overload methods, placed here + # for convenience. + ############################################# + +use overload + + '+' => \&plus, + + '-' => \&minus, + + '++' => \&plusplus, + + '--' => \&minusminus, + + "=" => \©, + + '""' => sub { $_[0]->cidr(); }, + + 'eq' => sub { + my $a = (UNIVERSAL::isa($_[0],__PACKAGE__)) ? $_[0]->cidr : $_[0]; + my $b = (UNIVERSAL::isa($_[1],__PACKAGE__)) ? $_[1]->cidr : $_[1]; + $a eq $b; + }, + + 'ne' => sub { + my $a = (UNIVERSAL::isa($_[0],__PACKAGE__)) ? $_[0]->cidr : $_[0]; + my $b = (UNIVERSAL::isa($_[1],__PACKAGE__)) ? $_[1]->cidr : $_[1]; + $a ne $b; + }, + + '==' => sub { + return 0 unless UNIVERSAL::isa($_[0],__PACKAGE__) && UNIVERSAL::isa($_[1],__PACKAGE__); + $_[0]->cidr eq $_[1]->cidr; + }, + + '!=' => sub { + return 1 unless UNIVERSAL::isa($_[0],__PACKAGE__) && UNIVERSAL::isa($_[1],__PACKAGE__); + $_[0]->cidr ne $_[1]->cidr; + }, + + '>' => sub { + return &comp_addr_mask > 0 ? 1 : 0; + }, + + '<' => sub { + return &comp_addr_mask < 0 ? 1 : 0; + }, + + '>=' => sub { + return &comp_addr_mask < 0 ? 0 : 1; + }, + + '<=' => sub { + return &comp_addr_mask > 0 ? 0 : 1; + }, + + '<=>' => \&comp_addr_mask, + + 'cmp' => \&comp_addr_mask; + +sub comp_addr_mask { + my($c,$rv) = sub128($_[0]->{addr},$_[1]->{addr}); + return -1 unless $c; + return 1 if hasbits($rv); + ($c,$rv) = sub128($_[0]->{mask},$_[1]->{mask}); + return -1 unless $c; + return hasbits($rv) ? 1 : 0; +} + +#sub comp_addr { +# my($c,$rv) = sub128($_[0]->{addr},$_[1]->{addr}); +# return -1 unless $c; +# return hasbits($rv) ? 1 : 0; +#} + +=pod + +=over + +=item B)> + +Has been optimized to copy one NetAddr::IP::Lite object to another very quickly. + +=item Bcopy()>> + +The B)> operation is only put in to operation when the +copied object is further mutated by another overloaded operation. See +L B for details. + +Bcopy()>> actually creates a new object when called. + +=cut + +sub copy { + return _new($_[0],$_[0]->{addr}, $_[0]->{mask}); +} + +=item B + +An object can be used just as a string. For instance, the following code + + my $ip = new NetAddr::IP::Lite '192.168.1.123'; + print "$ip\n"; + +Will print the string 192.168.1.123/32. + + my $ip = new6 NetAddr::IP::Lite '192.168.1.123'; + print "$ip\n"; + +Will print the string 0:0:0:0:0:0:C0A8:17B/128 + +=item B + +You can test for equality with either C, C, C<==> or C. C, C allows the +comparison with arbitrary strings as well as NetAddr::IP::Lite objects. The +following example: + + if (NetAddr::IP::Lite->new('127.0.0.1','255.0.0.0') eq '127.0.0.1/8') + { print "Yes\n"; } + +Will print out "Yes". + +Comparison with C<==> and C requires both operands to be NetAddr::IP::Lite objects. + +=item B, E, E=, E=, E=E and C> + +Internally, all network objects are represented in 128 bit format. +The numeric representation of the network is compared through the +corresponding operation. Comparisons are tried first on the address portion +of the object and if that is equal then the NUMERIC cidr portion of the +masks are compared. This leads to the counterintuitive result that + + /24 > /16 + +Comparison should not be done on netaddr objects with different CIDR as +this may produce indeterminate - unexpected results, +rather the determination of which netblock is larger or smaller should be +done by comparing + + $ip1->masklen <=> $ip2->masklen + +=item B)> + +Add a 32 bit signed constant to the address part of a NetAddr object. +This operation changes the address part to point so many hosts above the +current objects start address. For instance, this code: + + print NetAddr::IP::Lite->new('127.0.0.1/8') + 5; + +will output 127.0.0.6/8. The address will wrap around at the broadcast +back to the network address. This code: + + print NetAddr::IP::Lite->new('10.0.0.1/24') + 255; + +outputs 10.0.0.0/24. + +Returns the the unchanged object when the constant is missing or out of range. + + 2147483647 <= constant >= -2147483648 + +=cut + +sub plus { + my $ip = shift; + my $const = shift; + + return $ip unless $const && + $const < 2147483648 && + $const > -2147483649; + + my $a = $ip->{addr}; + my $m = $ip->{mask}; + + my $lo = $a & ~$m; + my $hi = $a & $m; + + my $new = ((addconst($lo,$const))[1] & ~$m) | $hi; + + return _new($ip,$new,$m); +} + +=item B)> + +The complement of the addition of a constant. + +=item B)> + +Returns the difference between the address parts of two NetAddr::IP::Lite +objects address parts as a 32 bit signed number. + +Returns B if the difference is out of range. + +=cut + +my $_smsk = pack('L3N',0xffffffff,0xffffffff,0xffffffff,0x80000000); + +sub minus { + my $ip = shift; + my $arg = shift; + unless (ref $arg) { + return plus($ip, -$arg); + } + my($carry,$dif) = sub128($ip->{addr},$arg->{addr}); + if ($carry) { # value is positive + return undef if hasbits($dif & $_smsk); # all sign bits should be 0's + return (unpack('L3N',$dif))[3]; + } else { + return undef if hasbits(($dif & $_smsk) ^ $_smsk); # sign is 1's + return (unpack('L3N',$dif))[3] - 4294967296; + } +} + + # Auto-increment an object + +=item B + +Auto-incrementing a NetAddr::IP::Lite object causes the address part to be +adjusted to the next host address within the subnet. It will wrap at +the broadcast address and start again from the network address. + +=cut + +sub plusplus { + my $ip = shift; + + my $a = $ip->{addr}; + my $m = $ip->{mask}; + + my $lo = $a & ~ $m; + my $hi = $a & $m; + + $ip->{addr} = ((addconst($lo,1))[1] & ~ $m) | $hi; + return $ip; +} + +=item B + +Auto-decrementing a NetAddr::IP::Lite object performs exactly the opposite +of auto-incrementing it, as you would expect. + +=cut + +sub minusminus { + my $ip = shift; + + my $a = $ip->{addr}; + my $m = $ip->{mask}; + + my $lo = $a & ~$m; + my $hi = $a & $m; + + $ip->{addr} = ((addconst($lo,-1))[1] & ~$m) | $hi; + return $ip; +} + + ############################################# + # End of the overload methods. + ############################################# + +# Preloaded methods go here. + + # This is a variant to ->new() that + # creates and blesses a new object + # without the fancy parsing of + # IP formats and shorthands. + +# return a blessed IP object without parsing +# input: prototype, naddr, nmask +# returns: blessed IP object +# +sub _new ($$$) { + my $proto = shift; + my $class = ref($proto) || die "reference required"; + $proto = $proto->{isv6}; + my $self = { + addr => $_[0], + mask => $_[1], + isv6 => $proto, + }; + return bless $self, $class; +} + +=pod + +=back + +=head2 Methods + +=over + +=item C<-Enew([$addr, [ $mask|IPv6 ]])> + +=item C<-Enew6([$addr, [ $mask]])> + +=item C<-Enew6FFFF([$addr, [ $mask]])> + +=item C<-Enew_no([$addr, [ $mask]])> + +=item C<-Enew_from_aton($netaddr)> + +=item new_cis and new_cis6 are DEPRECATED + +=item C<-Enew_cis("$addr $mask)> + +=item C<-Enew_cis6("$addr $mask)> + +The first three methods create a new address with the supplied address in +C<$addr> and an optional netmask C<$mask>, which can be omitted to get +a /32 or /128 netmask for IPv4 / IPv6 addresses respectively. + +new6FFFF specifically returns an IPv4 address in IPv6 format according to RFC4291 + + new6 ::xxxx:xxxx + new6FFFF ::FFFF:xxxx:xxxx + +The third method C is exclusively for IPv4 addresses and filters +improperly formatted +dot quad strings for leading 0's that would normally be interpreted as octal +format by NetAddr per the specifications for inet_aton. + +B takes a packed IPv4 address and assumes a /32 mask. This +function replaces the DEPRECATED :aton functionality which is fundamentally +broken. + +The last two methods B and B differ from B and +B only in that they except the common Cisco address notation for +address/mask pairs with a B as a separator instead of a slash (/) + +These methods are DEPRECATED because the functionality is now included +in the other "new" methods + + i.e. ->new_cis('1.2.3.0 24') + or + ->new_cis6('::1.2.3.0 120') + +C<-Enew6> and +C<-Enew_cis6> mark the address as being in ipV6 address space even +if the format would suggest otherwise. + + i.e. ->new6('1.2.3.4') will result in ::102:304 + + addresses submitted to ->new in ipV6 notation will + remain in that notation permanently. i.e. + ->new('::1.2.3.4') will result in ::102:304 + whereas new('1.2.3.4') would print out as 1.2.3.4 + + See "STRINGIFICATION" below. + +C<$addr> can be almost anything that can be resolved to an IP address +in all the notations I have seen over time. It can optionally contain +the mask in CIDR notation. If the OPTIONAL perl module Socket6 is +available in the local library it will autoload and ipV6 host6 +names will be resolved as well as ipV4 hostnames. + +B notation is understood, with the limitation that the range +specified by the prefix must match with a valid subnet. + +Addresses in the same format returned by C or +C can also be understood, although no mask can be +specified for them. The default is to not attempt to recognize this +format, as it seems to be seldom used. + +###### DEPRECATED, will be remove in version 5 ############ +To accept addresses in that format, invoke the module as in + + use NetAddr::IP::Lite ':aton' + +###### USE new_from_aton instead ########################## + +If called with no arguments, 'default' is assumed. + +If called with an empty string as the argument, returns 'undef' + +C<$addr> can be any of the following and possibly more... + + n.n + n.n/mm + n.n mm + n.n.n + n.n.n/mm + n.n.n mm + n.n.n.n + n.n.n.n/mm 32 bit cidr notation + n.n.n.n mm + n.n.n.n/m.m.m.m + n.n.n.n m.m.m.m + loopback, localhost, broadcast, any, default + x.x.x.x/host + 0xABCDEF, 0b111111000101011110, (or a bcd number) + a netaddr as returned by 'inet_aton' + + +Any RFC1884 notation + + ::n.n.n.n + ::n.n.n.n/mmm 128 bit cidr notation + ::n.n.n.n/::m.m.m.m + ::x:x + ::x:x/mmm + x:x:x:x:x:x:x:x + x:x:x:x:x:x:x:x/mmm + x:x:x:x:x:x:x:x/m:m:m:m:m:m:m:m any RFC1884 notation + loopback, localhost, unspecified, any, default + ::x:x/host + 0xABCDEF, 0b111111000101011110 within the limits + of perl's number resolution + 123456789012 a 'big' bcd number (bigger than perl likes) + and Math::BigInt + +A Fully Qualified Domain Name which returns an ipV4 address or an ipV6 +address, embodied in that order. This previously undocumented feature +may be disabled with: + + use NetAddr::IP::Lite ':nofqdn'; + +If called with no arguments, 'default' is assumed. + +If called with and empty string as the argument, 'undef' is returned; + +=cut + +my $lbmask = inet_aton('255.0.0.0'); +my $_p4broad = inet_any2n('255.255.255.255'); +my $_p4loop = inet_any2n('127.0.0.1'); +my $_p4mloop = inet_aton('255.0.0.0'); + $_p4mloop = mask4to6($_p4mloop); +my $_p6loop = inet_any2n('::1'); + +my %fip4 = ( + default => Zeros, + any => Zeros, + broadcast => $_p4broad, + loopback => $_p4loop, + unspecified => undef, +); +my %fip4m = ( + default => Zeros, + any => Zeros, + broadcast => Ones, + loopback => $_p4mloop, + unspecified => undef, # not applicable for ipV4 + host => Ones, +); + +my %fip6 = ( + default => Zeros, + any => Zeros, + broadcast => undef, # not applicable for ipV6 + loopback => $_p6loop, + unspecified => Zeros, +); + +my %fip6m = ( + default => Zeros, + any => Zeros, + broadcast => undef, # not applicable for ipV6 + loopback => Ones, + unspecified => Ones, + host => Ones, +); + +my $ff000000 = pack('L3N',0xffffffff,0xffffffff,0xffffffff,0xFF000000); +my $ffff0000 = pack('L3N',0xffffffff,0xffffffff,0xffffffff,0xFFFF0000); +my $ffffff00 = pack('L3N',0xffffffff,0xffffffff,0xffffffff,0xFFFFFF00); + +sub _obits ($$) { + my($lo,$hi) = @_; + + return 0xFF if $lo == $hi; + return (~ ($hi ^ $lo)) & 0xFF; +} + +sub new_no($;$$) { + unshift @_, -1; + goto &_xnew; +} + +sub new($;$$) { + unshift @_, 0; + goto &_xnew; +} + +sub new_from_aton($$) { + my $proto = shift; + my $class = ref $proto || $proto || __PACKAGE__; + my $ip = shift; + return undef unless defined $ip; + my $addrlen = length($ip); + return undef unless $addrlen == 4; + my $self = { + addr => ipv4to6($ip), + mask => &Ones, + isv6 => 0, + }; + return bless $self, $class; +} + +sub new6($;$$) { + unshift @_, 1; + goto &_xnew; +} + +sub new6FFFF($;$$) { + my $ip = _xnew(1,@_); + $ip->{addr} |= $_ipv4FFFF; + return $ip; +} + +sub new_cis($;$$) { + my @in = @_; + if ( $in[1] && $in[1] =~ m!^(.+)\s+(.+)$! ) { + $in[1] = $1 .'/'. $2; + } + @_ = (0,@in); + goto &_xnew; +} + +sub new_cis6($;$$) { + my @in = @_; + if ( $in[1] && $in[1] =~ m!^(.+)\s+(.+)$! ) { + $in[1] = $1 .'/'. $2; + } + @_ = (1,@in); + goto &_xnew; +} + +sub _no_octal { +# $_[0] =~ m/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/; +# return sprintf("%d.%d.%d.%d",$1,$2,$3,$4); + (my $rv = $_[0]) =~ s#\b0*([1-9]\d*/?|0/?)#$1#g; # suppress leading zeros + $rv; +} + +sub _xnew($$;$$) { + my $noctal = 0; + my $isV6 = shift; + if ($isV6 < 0) { # flag for no octal? + $isV6 = 0; + $noctal = 1; + } + my $proto = shift; + my $class = ref $proto || $proto || __PACKAGE__; + my $ip = shift; + + if ($ip && $noctal && $ip !~ m|(?:[^\s0123456789/. -])|) { # octal suppression required if not an IPv4 address + $ip = _no_octal($ip); + } + +# fix for bug #75976 + return undef if defined $ip && $ip eq ''; + + $ip = 'default' unless defined $ip; + $ip = _retMBIstring($ip) # treat as big bcd string + if ref $ip && ref $ip eq 'Math::BigInt'; # can /CIDR notation + my $hasmask = 1; + my($mask,$tmp); + +# IP to lower case AFTER ref test for Math::BigInt. 'lc' strips blessing + + $ip = lc $ip; + + while (1) { +# process IP's with no CIDR or that have the CIDR as part of the IP argument string + unless (@_) { +# if ($ip =~ m!^(.+)/(.+)$!) { + if ($ip !~ /\D/) { # binary number notation + $ip = bcd2bin($ip); + $mask = Ones; + last; + } + elsif ($ip =~ m!^([a-z0-9.:-]+)(?:/|\s+)([a-z0-9.:-]+)$! || + $ip =~ m!^[\[]{1}([a-z0-9.:-]+)(?:/|\s+)([a-z0-9.:-]+)[\]]{1}$!) { + $ip = $1; + $mask = $2; + } elsif (grep($ip eq $_,(qw(default any broadcast loopback unspecified)))) { + $isV6 = 1 if $ip eq 'unspecified'; + if ($isV6) { + $mask = $fip6m{$ip}; + return undef unless defined ($ip = $fip6{$ip}); + } else { + $mask = $fip4m{$ip}; + return undef unless defined ($ip = $fip4{$ip}); + } + last; + } + } +# process "ipv6" token and default IP's + elsif (defined $_[0]) { + if ($_[0] =~ /ipv6/i || $isV6) { + if (grep($ip eq $_,(qw(default any loopback unspecified)))) { + $mask = $fip6m{$ip}; + $ip = $fip6{$ip}; + last; + } else { + return undef unless $isV6; +# add for ipv6 notation "12345, 1" + } +# $mask = lc $_[0]; +# } else { +# $mask = lc $_[0]; + } +# extract mask + $mask = $_[0]; + } +### +### process mask + unless (defined $mask) { + $hasmask = 0; + $mask = 'host'; + } + +# two kinds of IP's can turn on the isV6 flag +# 1) big digits that are over the IPv4 boundry +# 2) IPv6 IP syntax +# +# check these conditions and set isV6 as appropriate +# + my $try; + $isV6 = 1 if # check big bcd and IPv6 rfc1884 + ( $ip !~ /\D/ && # ip is all decimal + (length($ip) > 3 || $ip > 255) && # exclude a single digit in the range of zero to 255, could be funny IPv4 + ($try = bcd2bin($ip)) && ! isIPv4($try)) || # precedence so $try is not corrupted + (index($ip,':') >= 0 && ($try = ipv6_aton($ip))); # fails if not an rfc1884 address + +# if either of the above conditions is true, $try contains the NetAddr 128 bit address + +# checkfor Math::BigInt mask + $mask = _retMBIstring($mask) # treat as big bcd string + if ref $mask && ref $mask eq 'Math::BigInt'; + +# MASK to lower case AFTER ref test for Math::BigInt, 'lc' strips blessing + + $mask = lc $mask; + + if ($mask !~ /\D/) { # bcd or CIDR notation + my $isCIDR = length($mask) < 4 && $mask < 129; + if ($isV6) { + if ($isCIDR) { + my($dq1,$dq2,$dq3,$dq4); + if ($ip =~ /^(\d+)(?:|\.(\d+)(?:|\.(\d+)(?:|\.(\d+))))$/ && + do {$dq1 = $1; + $dq2 = $2 || 0; + $dq3 = $3 || 0; + $dq4 = $4 || 0; + 1; + } && + $dq1 >= 0 && $dq1 < 256 && + $dq2 >= 0 && $dq2 < 256 && + $dq3 >= 0 && $dq3 < 256 && + $dq4 >= 0 && $dq4 < 256 + ) { # corner condition of IPv4 with isV6 + $ip = join('.',$dq1,$dq2,$dq3,$dq4); + $try = ipv4to6(inet_aton($ip)); + if ($mask < 32) { + $mask = shiftleft(Ones,32 -$mask); + } + elsif ($mask == 32) { + $mask = Ones; + } else { + return undef; # undoubtably an error + } + } + elsif ($mask < 128) { + $mask = shiftleft(Ones,128 -$mask); # small cidr + } else { + $mask = Ones(); + } + } else { + $mask = bcd2bin($mask); + } + } + elsif ($isCIDR && $mask < 33) { # is V4 +# if ($ip && $noctal && $ip !~ m|(?:[^\s0123456789.])|) { # octal suppression required if not an IPv4 address +# $mask = _no_octal($mask); +# } + if ($mask < 32) { + $mask = shiftleft(Ones,32 -$mask); + } + elsif ( $mask == 32) { + $mask = Ones; + } else { + $mask = bcd2bin($mask); + $mask |= $_v4mask; # v4 always + } + } else { # also V4 + $mask = bcd2bin($mask); + $mask |= $_v4mask; + } + if ($try) { # is a big number + $ip = $try; + last; + } + } elsif ($mask =~ m/^\d+\.\d+\.\d+\.\d+$/) { # ipv4 form of mask + $mask = _no_octal($mask) if $noctal; # filter for octal + return undef unless defined ($mask = inet_aton($mask)); + $mask = mask4to6($mask); + } elsif (grep($mask eq $_,qw(default any broadcast loopback unspecified host))) { + if (index($ip,':') < 0 && ! $isV6) { + return undef unless defined ($mask = $fip4m{$mask}); + } else { + return undef unless defined ($mask = $fip6m{$mask}); + } + } else { + return undef unless defined ($mask = ipv6_aton($mask)); # try ipv6 form of mask + } + +# process remaining IP's + + if (index($ip,':') < 0) { # ipv4 address + if ($ip =~ m/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/) { + ; # the common case + } + elsif (grep($ip eq $_,(qw(default any broadcast loopback)))) { + return undef unless defined ($ip = $fip4{$ip}); + last; + } + elsif ($ip =~ m/^(\d+)\.(\d+)$/) { + $ip = ($hasmask) + ? "${1}.${2}.0.0" + : "${1}.0.0.${2}"; + } + elsif ($ip =~ m/^(\d+)\.(\d+)\.(\d+)$/) { + $ip = ($hasmask) + ? "${1}.${2}.${3}.0" + : "${1}.${2}.0.${3}"; + } + elsif ($ip =~ /^(\d+)$/ && $hasmask && $1 >= 0 and $1 < 256) { # pure numeric + $ip = sprintf("%d.0.0.0",$1); + } +# elsif ($ip =~ /^\d+$/ && !$hasmask) { # a big integer + elsif ($ip =~ /^\d+$/ ) { # a big integer + $ip = bcd2bin($ip); + last; + } +# these next three might be broken??? but they have been in the code a long time and no one has complained + elsif ($ip =~ /^0[xb]\d+$/ && $hasmask && + (($tmp = eval "$ip") || 1) && + $tmp >= 0 && $tmp < 256) { + $ip = sprintf("%d.0.0.0",$tmp); + } + elsif ($ip =~ /^-?\d+$/) { + $ip += 2 ** 32 if $ip < 0; + $ip = pack('L3N',0,0,0,$ip); + last; + } + elsif ($ip =~ /^-?0[xb]\d+$/) { + $ip = eval "$ip"; + $ip = pack('L3N',0,0,0,$ip); + last; + } + +# notations below include an implicit mask specification + + elsif ($ip =~ m/^(\d+)\.$/) { + $ip = "${1}.0.0.0"; + $mask = $ff000000; + } + elsif ($ip =~ m/^(\d+)\.(\d+)-(\d+)\.?$/ && $2 <= $3 && $3 < 256) { + $ip = "${1}.${2}.0.0"; + $mask = pack('L3C4',0xffffffff,0xffffffff,0xffffffff,255,_obits($2,$3),0,0); + } + elsif ($ip =~ m/^(\d+)-(\d+)\.?$/ and $1 <= $2 && $2 < 256) { + $ip = "${1}.0.0.0"; + $mask = pack('L3C4',0xffffffff,0xffffffff,0xffffffff,_obits($1,$2),0,0,0) + } + elsif ($ip =~ m/^(\d+)\.(\d+)\.$/) { + $ip = "${1}.${2}.0.0"; + $mask = $ffff0000; + } + elsif ($ip =~ m/^(\d+)\.(\d+)\.(\d+)-(\d+)\.?$/ && $3 <= $4 && $4 < 256) { + $ip = "${1}.${2}.${3}.0"; + $mask = pack('L3C4',0xffffffff,0xffffffff,0xffffffff,255,255,_obits($3,$4),0); + } + elsif ($ip =~ m/^(\d+)\.(\d+)\.(\d+)\.$/) { + $ip = "${1}.${2}.${3}.0"; + $mask = $ffffff00; + } + elsif ($ip =~ m/^(\d+)\.(\d+)\.(\d+)\.(\d+)-(\d+)$/ && $4 <= $5 && $5 < 256) { + $ip = "${1}.${2}.${3}.${4}"; + $mask = pack('L3C4',0xffffffff,0xffffffff,0xffffffff,255,255,255,_obits($4,$5)); + } + elsif ($ip =~ m/^(\d+\.\d+\.\d+\.\d+) + \s*-\s*(\d+\.\d+\.\d+\.\d+)$/x) { +# if ($noctal) { +# return undef unless ($ip = inet_aton(_no_octal($1))); +# return undef unless ($tmp = inet_aton(_no_octal($2))); +# } else { + return undef unless ($ip = inet_aton($1)); + return undef unless ($tmp = inet_aton($2)); +# } +# check for left side greater than right side +# save numeric difference in $mask + return undef if ($tmp = unpack('N',$tmp) - unpack('N',$ip)) < 0; + $ip = ipv4to6($ip); + $tmp = pack('L3N',0,0,0,$tmp); + $mask = ~$tmp; + return undef if notcontiguous($mask); +# check for non-aligned left side + return undef if hasbits($ip & $tmp); + last; + } +# check for resolvable IPv4 hosts + elsif (! $NoFQDN && $ip !~ /[^a-zA-Z0-9\._-]/ && ($tmp = gethostbyname(fillIPv4($ip))) && $tmp ne $_v4zero && $tmp ne $_zero ) { + $ip = ipv4to6($tmp); + last; + } +# check for resolvable IPv6 hosts + elsif (! $NoFQDN && $ip !~ /[^a-zA-Z0-9\._-]/ && havegethostbyname2() && ($tmp = naip_gethostbyname($ip))) { + $ip = $tmp; + $isV6 = 1; + last; + } + elsif ($Accept_Binary_IP && ! $hasmask) { + if (length($ip) == 4) { + $ip = ipv4to6($ip); + } elsif (length($ip) == 16) { + $isV6 = 1; + } else { + return undef; + } + last; + } else { + return undef; + } + return undef unless defined ($ip = inet_aton($ip)); + $ip = ipv4to6($ip); + last; + } +########## continuing + else { # ipv6 address + $isV6 = 1; + $ip = $1 if $ip =~ /\[([^\]]+)\]/; # transform URI notation + if (defined ($tmp = ipv6_aton($ip))) { + $ip = $tmp; + last; + } + last if grep($ip eq $_,(qw(default any loopback unspecified))) && + defined ($ip = $fip6{$ip}); + return undef; + } + } # end while (1) + return undef if notcontiguous($mask); # invalid if not contiguous + + my $self = { + addr => $ip, + mask => $mask, + isv6 => $isV6, + }; + return bless $self, $class; +} + +=item C<-Ebroadcast()> + +Returns a new object referring to the broadcast address of a given +subnet. The broadcast address has all ones in all the bit positions +where the netmask has zero bits. This is normally used to address all +the hosts in a given subnet. + +=cut + +sub broadcast ($) { + my $ip = _new($_[0],$_[0]->{addr} | ~$_[0]->{mask},$_[0]->{mask}); + $ip->{addr} &= V4net unless $ip->{isv6}; + return $ip; +} + +=item C<-Enetwork()> + +Returns a new object referring to the network address of a given +subnet. A network address has all zero bits where the bits of the +netmask are zero. Normally this is used to refer to a subnet. + +=cut + +sub network ($) { + return _new($_[0],$_[0]->{addr} & $_[0]->{mask},$_[0]->{mask}); +} + +=item C<-Eaddr()> + +Returns a scalar with the address part of the object as an IPv4 or IPv6 text +string as appropriate. This is useful for printing or for passing the address +part of the NetAddr::IP::Lite object to other components that expect an IP +address. If the object is an ipV6 address or was created using ->new6($ip) +it will be reported in ipV6 hex format otherwise it will be reported in dot +quad format only if it resides in ipV4 address space. + +=cut + +sub addr ($) { + return ($_[0]->{isv6}) + ? ipv6_n2x($_[0]->{addr}) + : inet_n2dx($_[0]->{addr}); +} + +=item C<-Emask()> + +Returns a scalar with the mask as an IPv4 or IPv6 text string as +described above. + +=cut + +sub mask ($) { + return ipv6_n2x($_[0]->{mask}) if $_[0]->{isv6}; + my $mask = isIPv4($_[0]->{addr}) + ? $_[0]->{mask} & V4net + : $_[0]->{mask}; + return inet_n2dx($mask); +} + +=item C<-Emasklen()> + +Returns a scalar the number of one bits in the mask. + +=cut + +sub masklen ($) { + my $len = (notcontiguous($_[0]->{mask}))[1]; + return 0 unless $len; + return $len if $_[0]->{isv6}; + return isIPv4($_[0]->{addr}) + ? $len -96 + : $len; +} + +=item C<-Ebits()> + +Returns the width of the address in bits. Normally 32 for v4 and 128 for v6. + +=cut + +sub bits { + return $_[0]->{isv6} ? 128 : 32; +} + +=item C<-Eversion()> + +Returns the version of the address or subnet. Currently this can be +either 4 or 6. + +=cut + +sub version { + my $self = shift; + return $self->{isv6} ? 6 : 4; +} + +=item C<-Ecidr()> + +Returns a scalar with the address and mask in CIDR notation. A +NetAddr::IP::Lite object I to the result of this function. +(see comments about ->new6() and ->addr() for output formats) + +=cut + +sub cidr ($) { + return $_[0]->addr . '/' . $_[0]->masklen; +} + +=item C<-Eaton()> + +Returns the address part of the NetAddr::IP::Lite object in the same format +as the C or C function respectively. If the object +was created using ->new6($ip), the address returned will always be in ipV6 +format, even for addresses in ipV4 address space. + +=cut + +sub aton { + return $_[0]->{addr} if $_[0]->{isv6}; + return isIPv4($_[0]->{addr}) + ? ipv6to4($_[0]->{addr}) + : $_[0]->{addr}; +} + +=item C<-Erange()> + +Returns a scalar with the base address and the broadcast address +separated by a dash and spaces. This is called range notation. + +=cut + +sub range ($) { + return $_[0]->network->addr . ' - ' . $_[0]->broadcast->addr; +} + +=item C<-Enumeric()> + +When called in a scalar context, will return a numeric representation +of the address part of the IP address. When called in an array +context, it returns a list of two elements. The first element is as +described, the second element is the numeric representation of the +netmask. + +This method is essential for serializing the representation of a +subnet. + +=cut + +sub numeric ($) { + if (wantarray) { + if (! $_[0]->{isv6} && isIPv4($_[0]->{addr})) { + return ( sprintf("%u",unpack('N',ipv6to4($_[0]->{addr}))), + sprintf("%u",unpack('N',ipv6to4($_[0]->{mask})))); + } + else { + return ( bin2bcd($_[0]->{addr}), + bin2bcd($_[0]->{mask})); + } + } + return (! $_[0]->{isv6} && isIPv4($_[0]->{addr})) + ? sprintf("%u",unpack('N',ipv6to4($_[0]->{addr}))) + : bin2bcd($_[0]->{addr}); +} + +=item C<-Ebigint()> + +When called in a scalar context, will return a Math::BigInt representation +of the address part of the IP address. When called in an array +contest, it returns a list of two elements. The first element is as +described, the second element is the Math::BigInt representation of the +netmask. + +=cut + +my $biloaded; +my $bi2strng; +my $no_mbi_emu = 1; + +# function to force into test development mode +# +sub _force_bi_emu { + undef $biloaded; + undef $bi2strng; + $no_mbi_emu = 0; + print STDERR "\n\n\tWARNING: test development mode, this +\tmessage SHOULD NEVER BE SEEN IN PRODUCTION! +set my \$no_mbi_emu = 1 in t/bigint.t to remove this warning\n\n"; +} + +# function to stringify various flavors of Math::BigInt objects +# tests to see if the object is a hash or a signed scalar + +sub _bi_stfy { + "$_[0]" =~ /(\d+)/; # stringify and remove '+' if present + $1; +} + +sub _fakebi2strg { + ${$_[0]} =~ /(\d+)/; + $1; +} + +# fake new from bi string Math::BigInt 0.01 +# +sub _bi_fake { + bless \('+'. $_[1]), 'Math::BigInt'; +} + +# as of this writing there are three known flavors of Math::BigInt +# v0.01 MBI::new returns a scalar ref +# v1.?? - 1.69 CALC::_new takes a reference to a scalar, returns an array, MBI returns a hash ref +# v1.70 and up CALC::_new takes a scalar, returns and array, MBI returns a hash ref + +sub _loadMBI { # load Math::BigInt on demand + if (eval {$no_mbi_emu && require Math::BigInt}) { # any version should work, three known + import Math::BigInt; + $biloaded = \&Math::BigInt::new; + $bi2strng = \&_bi_stfy; + } else { + $biloaded = \&_bi_fake; + $bi2strng = \&_fakebi2strg; + } +} + +sub _retMBIstring { + _loadMBI unless $biloaded; # load Math::BigInt on demand + $bi2strng->(@_); +} + +sub _biRef { + _loadMBI unless $biloaded; # load Math::BigInt on demand + $biloaded->('Math::BigInt',$_[0]); +} + +sub bigint($) { + my($addr,$mask); + if (wantarray) { + if (! $_[0]->{isv6} && isIPv4($_[0]->{addr})) { + $addr = $_[0]->{addr} + ? sprintf("%u",unpack('N',ipv6to4($_[0]->{addr}))) + : 0; + $mask = $_[0]->{mask} + ? sprintf("%u",unpack('N',ipv6to4($_[0]->{mask}))) + : 0; + } + else { + $addr = $_[0]->{addr} + ? bin2bcd($_[0]->{addr}) + : 0; + $mask = $_[0]->{mask} + ? bin2bcd($_[0]->{mask}) + : 0; + } + (_biRef($addr),_biRef($mask)); + + } else { # not wantarray + + if (! $_[0]->{isv6} && isIPv4($_[0]->{addr})) { + $addr = $_[0]->{addr} + ? sprintf("%u",unpack('N',ipv6to4($_[0]->{addr}))) + : 0; + } else { + $addr = $_[0]->{addr} + ? bin2bcd($_[0]->{addr}) + : 0; + } + _biRef($addr); + } +} + +=item C<$me-Econtains($other)> + +Returns true when C<$me> completely contains C<$other>. False is +returned otherwise and C is returned if C<$me> and C<$other> +are not both C objects. + +=cut + +sub contains ($$) { + return within(@_[1,0]); +} + +=item C<$me-Ewithin($other)> + +The complement of C<-Econtains()>. Returns true when C<$me> is +completely contained within C<$other>, undef if C<$me> and C<$other> +are not both C objects. + +=cut + +sub within ($$) { + return 1 unless hasbits($_[1]->{mask}); # 0x0 contains everything + my $netme = $_[0]->{addr} & $_[0]->{mask}; + my $brdme = $_[0]->{addr} | ~ $_[0]->{mask}; + my $neto = $_[1]->{addr} & $_[1]->{mask}; + my $brdo = $_[1]->{addr} | ~ $_[1]->{mask}; + return (sub128($netme,$neto) && sub128($brdo,$brdme)) + ? 1 : 0; +} + +=item C-Eis_rfc1918()> + +Returns true when C<$me> is an RFC 1918 address. + + 10.0.0.0 - 10.255.255.255 (10/8 prefix) + 172.16.0.0 - 172.31.255.255 (172.16/12 prefix) + 192.168.0.0 - 192.168.255.255 (192.168/16 prefix) + +=cut + +my $ip_10 = NetAddr::IP::Lite->new('10.0.0.0/8'); +my $ip_10n = $ip_10->{addr}; # already the right value +my $ip_10b = $ip_10n | ~ $ip_10->{mask}; + +my $ip_172 = NetAddr::IP::Lite->new('172.16.0.0/12'); +my $ip_172n = $ip_172->{addr}; # already the right value +my $ip_172b = $ip_172n | ~ $ip_172->{mask}; + +my $ip_192 = NetAddr::IP::Lite->new('192.168.0.0/16'); +my $ip_192n = $ip_192->{addr}; # already the right value +my $ip_192b = $ip_192n | ~ $ip_192->{mask}; + +sub is_rfc1918 ($) { + my $netme = $_[0]->{addr} & $_[0]->{mask}; + my $brdme = $_[0]->{addr} | ~ $_[0]->{mask}; + return 1 if (sub128($netme,$ip_10n) && sub128($ip_10b,$brdme)); + return 1 if (sub128($netme,$ip_192n) && sub128($ip_192b,$brdme)); + return (sub128($netme,$ip_172n) && sub128($ip_172b,$brdme)) + ? 1 : 0; +} + +=item C<-Eis_local()> + +Returns true when C<$me> is a local network address. + + i.e. ipV4 127.0.0.0 - 127.255.255.255 + or ipV6 === ::1 + +=cut + +my $_lclhost6 = NetAddr::IP::Lite->new('::1'); +my $_lclnet = NetAddr::IP::Lite->new('127/8'); + +sub is_local ($) { + return ($_[0]->{isv6}) + ? $_[0] == $_lclhost6 + : $_[0]->within($_lclnet); +} + +=item C<-Efirst()> + +Returns a new object representing the first usable IP address within +the subnet (ie, the first host address). + +=cut + +my $_cidr127 = pack('N4',0xffffffff,0xffffffff,0xffffffff,0xfffffffe); + +sub first ($) { + if (hasbits($_[0]->{mask} ^ $_cidr127)) { + return $_[0]->network + 1; + } else { + return $_[0]->network; + } +# return $_[0]->network + 1; +} + +=item C<-Elast()> + +Returns a new object representing the last usable IP address within +the subnet (ie, one less than the broadcast address). + +=cut + +sub last ($) { + if (hasbits($_[0]->{mask} ^ $_cidr127)) { + return $_[0]->broadcast - 1; + } else { + return $_[0]->broadcast; + } +# return $_[0]->broadcast - 1; +} + +=item C<-Enth($index)> + +Returns a new object representing the I-th usable IP address within +the subnet (ie, the I-th host address). If no address is available +(for example, when the network is too small for C<$index> hosts), +C is returned. + +Version 4.00 of NetAddr::IP and version 1.00 of NetAddr::IP::Lite implements +C<-Enth($index)> and C<-Enum()> exactly as the documentation states. +Previous versions behaved slightly differently and not in a consistent +manner. + +To use the old behavior for C<-Enth($index)> and C<-Enum()>: + + use NetAddr::IP::Lite qw(:old_nth); + + old behavior: + NetAddr::IP->new('10/32')->nth(0) == undef + NetAddr::IP->new('10/32')->nth(1) == undef + NetAddr::IP->new('10/31')->nth(0) == undef + NetAddr::IP->new('10/31')->nth(1) == 10.0.0.1/31 + NetAddr::IP->new('10/30')->nth(0) == undef + NetAddr::IP->new('10/30')->nth(1) == 10.0.0.1/30 + NetAddr::IP->new('10/30')->nth(2) == 10.0.0.2/30 + NetAddr::IP->new('10/30')->nth(3) == 10.0.0.3/30 + +Note that in each case, the broadcast address is represented in the +output set and that the 'zero'th index is alway undef except for +a point-to-point /31 or /127 network where there are exactly two +addresses in the network. + + new behavior: + NetAddr::IP->new('10/32')->nth(0) == 10.0.0.0/32 + NetAddr::IP->new('10.1/32'->nth(0) == 10.0.0.1/32 + NetAddr::IP->new('10/31')->nth(0) == 10.0.0.0/32 + NetAddr::IP->new('10/31')->nth(1) == 10.0.0.1/32 + NetAddr::IP->new('10/30')->nth(0) == 10.0.0.1/30 + NetAddr::IP->new('10/30')->nth(1) == 10.0.0.2/30 + NetAddr::IP->new('10/30')->nth(2) == undef + +Note that a /32 net always has 1 usable address while a /31 has exactly +two usable addresses for point-to-point addressing. The first +index (0) returns the address immediately following the network address +except for a /31 or /127 when it return the network address. + +=cut + +sub nth ($$) { + my $self = shift; + my $count = shift; + + my $slash31 = ! hasbits($self->{mask} ^ $_cidr127); + if ($Old_nth) { + return undef if $slash31 && $count != 1; + return undef if ($count < 1 or $count > $self->num ()); + } + elsif ($slash31) { + return undef if ($count && $count != 1); # only index 0, 1 allowed for /31 + } else { + ++$count; + return undef if ($count < 1 or $count > $self->num ()); + } + return $self->network + $count; +} + +=item C<-Enum()> + +As of version 4.42 of NetAddr::IP and version 1.27 of NetAddr::IP::Lite +a /31 and /127 with return a net B value of 2 instead of 0 (zero) +for point-to-point networks. + +Version 4.00 of NetAddr::IP and version 1.00 of NetAddr::IP::Lite +return the number of usable IP addresses within the subnet, +not counting the broadcast or network address. + +Previous versions worked only for ipV4 addresses, returned a +maximum span of 2**32 and returned the number of IP addresses +not counting the broadcast address. + (one greater than the new behavior) + +To use the old behavior for C<-Enth($index)> and C<-Enum()>: + + use NetAddr::IP::Lite qw(:old_nth); + +WARNING: + +NetAddr::IP will calculate and return a numeric string for network +ranges as large as 2**128. These values are TEXT strings and perl +can treat them as integers for numeric calculations. + +Perl on 32 bit platforms only handles integer numbers up to 2**32 +and on 64 bit platforms to 2**64. + +If you wish to manipulate numeric strings returned by NetAddr::IP +that are larger than 2**32 or 2**64, respectively, you must load +additional modules such as Math::BigInt, bignum or some similar +package to do the integer math. + +=cut + +sub num ($) { + if ($Old_nth) { + my @net = unpack('L3N',$_[0]->{mask} ^ Ones); +# number of ip's less broadcast + return 0xfffffffe if $net[0] || $net[1] || $net[2]; # 2**32 -1 + return $net[3] if $net[3]; + } else { # returns 1 for /32 /128, 2 for /31 /127 else n-2 up to 2**32 + (undef, my $net) = addconst($_[0]->{mask},1); + return 1 unless hasbits($net); # ipV4/32 or ipV6/128 + $net = $net ^ Ones; + return 2 unless hasbits($net); # ipV4/31 or ipV6/127 + $net &= $_v4net unless $_[0]->{isv6}; + return bin2bcd($net); + } +} + +# deprecated +#sub num ($) { +# my @net = unpack('L3N',$_[0]->{mask} ^ Ones); +# if ($Old_nth) { +## number of ip's less broadcast +# return 0xfffffffe if $net[0] || $net[1] || $net[2]; # 2**32 -1 +# return $net[3] if $net[3]; +# } else { # returns 1 for /32 /128, 0 for /31 /127 else n-2 up to 2**32 +## number of usable IP's === number of ip's less broadcast & network addys +# return 0xfffffffd if $net[0] || $net[1] || $net[2]; # 2**32 -2 +# return 1 unless $net[3]; +# $net[3]--; +# } +# return $net[3]; +#} + +=pod + +=back + +=cut + +sub import { + if (grep { $_ eq ':aton' } @_) { + $Accept_Binary_IP = 1; + @_ = grep { $_ ne ':aton' } @_; + } + if (grep { $_ eq ':old_nth' } @_) { + $Old_nth = 1; + @_ = grep { $_ ne ':old_nth' } @_; + } + if (grep { $_ eq ':lower' } @_) + { + NetAddr::IP::Util::lower(); + @_ = grep { $_ ne ':lower' } @_; + } + if (grep { $_ eq ':upper' } @_) + { + NetAddr::IP::Util::upper(); + @_ = grep { $_ ne ':upper' } @_; + } + if (grep { $_ eq ':nofqdn' } @_) + { + $NoFQDN = 1; + @_ = grep { $_ ne ':nofqdn' } @_; + } + NetAddr::IP::Lite->export_to_level(1, @_); +} + +=head1 EXPORT_OK + + Zeros + Ones + V4mask + V4net + :aton DEPRECATED + :old_nth + :upper + :lower + :nofqdn + +=head1 AUTHORS + +Luis E. Muñoz Eluismunoz@cpan.orgE, +Michael Robinton Emichael@bizsystems.comE + +=head1 WARRANTY + +This software comes with the same warranty as perl itself (ie, none), +so by using it you accept any and all the liability. + +=head1 COPYRIGHT + + This software is (c) Luis E. Muñoz, 1999 - 2005 + and (c) Michael Robinton, 2006 - 2014. + +All rights reserved. + +This program is free software; you can redistribute it and/or modify +it under the terms of either: + + a) the GNU General Public License as published by the Free + Software Foundation; either version 2, or (at your option) any + later version, or + + b) the "Artistic License" which comes with this distribution. + +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 either +the GNU General Public License or the Artistic License for more details. + +You should have received a copy of the Artistic License with this +distribution, in the file named "Artistic". If not, I'll be glad to provide +one. + +You should also have received a copy of the GNU General Public License +along with this program in the file named "Copying". If not, write to the + + Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor + Boston, MA 02110-1301 USA + +or visit their web page on the internet at: + + http://www.gnu.org/copyleft/gpl.html. + +=head1 SEE ALSO + +NetAddr::IP(3), NetAddr::IP::Util(3), NetAddr::IP::InetBase(3) + +=cut + +1; diff --git a/Lite/MANIFEST b/Lite/MANIFEST new file mode 100644 index 0000000..62cbd3b --- /dev/null +++ b/Lite/MANIFEST @@ -0,0 +1,135 @@ +MANIFEST +MANIFEST.SKIP +Changes +Lite.pm +Makefile.PL +README +bug2742981 +t/addr.t +t/aton.t +t/bigint.t +t/bignums.t +t/bin_ips.t +t/bits.t +t/broadcast.t +t/bug62521.t +t/bug75976.t +t/cidr.t +t/constants.t +t/contains.t +t/copy.t +t/firstlast.t +t/is_local.t +t/ipv4FFFF.t +t/lemasklen.t +t/loops.t +t/lower.t +t/mask.t +t/masklen.t +t/netaddr.t +t/network.t +t/new-nth.t +t/new-num.t +t/nofqdn.t +t/numeric.t +t/old-nth.t +t/old-num.t +t/over-qq.t +t/over_comp.t +t/over_copy.t +t/over_equal.t +t/over_math.t +t/overminus.t +t/pathological.t +t/range.t +t/relops.t +t/rfc_1918.t +t/v4-aton.t +t/v4-badnm.t +t/v4-base.t +t/v4-basem.t +t/v4-cidr.t +t/v4-cnew.t +t/v4-contains.t +t/v4-last.t +t/v4-new-first.t +t/v4-new_from_aton.t +t/v4-new.t +t/v4_new_cis.t +t/v4-no_octal.t +t/v4-num.t +t/v4-numeric.t +t/v4-old-first.t +t/v4-range.t +t/v4-snew.t +t/v4-wnew.t +t/v6-cnew.t +t/v6-contains.t +t/v6-inc.t +t/v6-new_cis6_base.t +t/v6-new_cis_base.t +t/v6-new-base.t +t/v6-num.t +t/v6-numeric.t +t/v6-old-base.t +t/version.t +t/within.t +t/v6-cnew-uri.t +t/v6-new-base-uri.t +t/v6-numeric-uri.t +t/v6-old-base-uri.t +Util/MANIFEST +Util/MANIFEST.SKIP +Util/Changes +Util/configure.cc +Util/configure.gcc +Util/configure.ac +Util/config.h.in +Util/lib/NetAddr/IP/UtilPP.pm +Util/tlib/NetAddr/IP/Util_IS.pm +Util/localconf.h +Util/Makefile.PL +Util/README +Util/t/4to6.t +Util/t/add128.t +Util/t/addconst.t +Util/t/af_inet6.t +Util/t/anyto6.t +Util/t/badd.t +Util/t/bcd2bin.t +Util/t/bcdn2bin.t +Util/t/bin.t +Util/t/comp128.t +Util/t/croak.t +Util/t/hasbits.t +Util/t/inet_4map6.t +Util/t/inet_n2ad.t +Util/t/inet_n2dx.t +Util/t/ipv4_inet.t +Util/t/ipv6_any2n.t +Util/t/ipv6func.t +Util/t/ipv6to4.t +Util/t/isIPv4.t +Util/t/leftshift.t +Util/t/mode.t +Util/t/notcontiguous.t +Util/t/simple_pack.t +Util/t/sub128.t +Util/typemap +Util/Util.pm +Util/Util.xs +Util/lib/NetAddr/IP/InetBase.pm +Util/t/binet_n2ad.t +Util/t/binet_n2dx.t +Util/t/binet_pton.t +Util/t/bipv4_inet.t +Util/t/bipv6_any2n.t +Util/t/bipv6func.t +Util/t/bisIPv4.t +Util/t/bpackzeros.t +Util/t/inet_pton.t +Util/t/packzeros.t +Util/t/binet_ntoa.t +Util/t/ipv6_ntoa.t +Util/t/naip_gethostbyname.t +Util/t/no6_naip_gethostbyname.t diff --git a/Lite/MANIFEST.SKIP b/Lite/MANIFEST.SKIP new file mode 100644 index 0000000..1afffee --- /dev/null +++ b/Lite/MANIFEST.SKIP @@ -0,0 +1,31 @@ +^Build$ +^_build/ +^blib/ +^blibdirs +Makefile$ +Makefile\.[a-z]+$ +pm_to_blib +CVS/.* +\.cvs +,v$ +^tmp/ +\.old$ +\.bak$ +\.tmp$ +\.xsc$ +~$ +^# +\.shar$ +\.tar$ +\.tgz$ +\.tar\.gz$ +\.zip$ +_uu$ +Util_IS\.pm$ +Util\.(bs|[co])$ +localStuff\.h$ +config\.log$ +config\.h$ +config\.status +localperl\.h +META.yml diff --git a/Lite/Makefile.PL b/Lite/Makefile.PL new file mode 100644 index 0000000..643899d --- /dev/null +++ b/Lite/Makefile.PL @@ -0,0 +1,48 @@ +use ExtUtils::MakeMaker; +use Config; + +my $pkg = 'NetAddr::IP::Lite'; +$pkg =~ /[^:]+$/; +my $module = $& .'.pm'; + +# See lib/ExtUtils/MakeMaker.pm for details of how to influence +# the contents of the Makefile that is written. + +my %makeparms = ( + 'NAME' => $pkg, + 'VERSION_FROM' => $module, # finds $VERSION + 'PREREQ_PM' => {Test::More => 0, + }, + 'clean' => { FILES => "*~ tmp* META.yml"}, + 'dist' => {COMPRESS=>'gzip', SUFFIX=>'gz'} +); + +sub MY::top_targets { + package MY; + my $inherited = shift->SUPER::top_targets(@_); + $inherited =~ s/(pure_all\s+::.+)/$1 README/; + $inherited; +} + +sub MY::post_constants { + my $post_constants = $Config{scriptdirexp} .'/pod2text'; + if (-e $post_constants) { + $post_constants = q| +MY_POD2TEXT = |. $post_constants .q| +|; + } else { + $post_constants = q| +MY_POD2TEXT = echo "perl distro missing 'pod2text' to convert " |; + } +} + +sub MY::postamble { + package MY; + my $postamble = q| +README : |. $module .q| + @$(MY_POD2TEXT) |. $module .q| > README + +|; +} + +WriteMakefile(%makeparms); diff --git a/Lite/README b/Lite/README new file mode 100644 index 0000000..b719cb5 --- /dev/null +++ b/Lite/README @@ -0,0 +1,547 @@ +NAME + NetAddr::IP::Lite - Manages IPv4 and IPv6 addresses and subnets + +SYNOPSIS + use NetAddr::IP::Lite qw( + Zeros + Ones + V4mask + V4net + :aton DEPRECATED ! + :old_nth + :upper + :lower + :nofqdn + ); + + my $ip = new NetAddr::IP::Lite '127.0.0.1'; + or if your prefer + my $ip = NetAddr::IP::Lite->new('127.0.0.1); + or from a packed IPv4 address + my $ip = new_from_aton NetAddr::IP::Lite (inet_aton('127.0.0.1')); + or from an octal filtered IPv4 address + my $ip = new_no NetAddr::IP::Lite '127.012.0.0'; + + print "The address is ", $ip->addr, " with mask ", $ip->mask, "\n" ; + + if ($ip->within(new NetAddr::IP::Lite "127.0.0.0", "255.0.0.0")) { + print "Is a loopback address\n"; + } + + # This prints 127.0.0.1/32 + print "You can also say $ip...\n"; + + The following four functions return ipV6 representations of: + + :: = Zeros(); + FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF = Ones(); + FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:: = V4mask(); + ::FFFF:FFFF = V4net(); + + Will also return an ipV4 or ipV6 representation of a + resolvable Fully Qualified Domanin Name (FQDN). + +INSTALLATION + Un-tar the distribution in an appropriate directory and type: + + perl Makefile.PL + make + make test + make install + + NetAddr::IP::Lite depends on NetAddr::IP::Util which installs by default + with its primary functions compiled using Perl's XS extensions to build + a 'C' library. If you do not have a 'C' complier available or would like + the slower Pure Perl version for some other reason, then type: + + perl Makefile.PL -noxs + make + make test + make install + +DESCRIPTION + This module provides an object-oriented abstraction on top of IP + addresses or IP subnets, that allows for easy manipulations. Most of the + operations of NetAddr::IP are supported. This module will work with + older versions of Perl and is compatible with Math::BigInt. + + * By default NetAddr::IP functions and methods return string IPv6 + addresses in uppercase. To change that to lowercase: + + NOTE: the AUGUST 2010 RFC5952 states: + + 4.3. Lowercase + + The characters "a", "b", "c", "d", "e", and "f" in an IPv6 + address MUST be represented in lowercase. + + It is recommended that all NEW applications using NetAddr::IP::Lite be + invoked as shown on the next line. + + use NetAddr::IP::Lite qw(:lower); + + * To ensure the current IPv6 string case behavior even if the default + changes: + + use NetAddr::IP::Lite qw(:upper); + + The internal representation of all IP objects is in 128 bit IPv6 + notation. IPv4 and IPv6 objects may be freely mixed. + + The supported operations are described below: + + Overloaded Operators + + Assignment ("=") + Has been optimized to copy one NetAddr::IP::Lite object to another + very quickly. + + "->copy()" + The assignment ("=") operation is only put in to operation when the + copied object is further mutated by another overloaded operation. + See the overload manpage SPECIAL SYMBOLS FOR "use overload" for + details. + + "->copy()" actually creates a new object when called. + + Stringification + An object can be used just as a string. For instance, the following + code + + my $ip = new NetAddr::IP::Lite '192.168.1.123'; + print "$ip\n"; + + Will print the string 192.168.1.123/32. + + my $ip = new6 NetAddr::IP::Lite '192.168.1.123'; + print "$ip\n"; + + Will print the string 0:0:0:0:0:0:C0A8:17B/128 + + Equality + You can test for equality with either "eq", "ne", "==" or "!=". + "eq", "ne" allows the comparison with arbitrary strings as well as + NetAddr::IP::Lite objects. The following example: + + if (NetAddr::IP::Lite->new('127.0.0.1','255.0.0.0') eq '127.0.0.1/8') + { print "Yes\n"; } + + Will print out "Yes". + + Comparison with "==" and "!=" requires both operands to be + NetAddr::IP::Lite objects. + + Comparison via >, <, >=, <=, <=> and "cmp" + Internally, all network objects are represented in 128 bit format. + The numeric representation of the network is compared through the + corresponding operation. Comparisons are tried first on the address + portion of the object and if that is equal then the NUMERIC cidr + portion of the masks are compared. This leads to the + counterintuitive result that + + /24 > /16 + + Comparison should not be done on netaddr objects with different CIDR + as this may produce indeterminate - unexpected results, rather the + determination of which netblock is larger or smaller should be done + by comparing + + $ip1->masklen <=> $ip2->masklen + + Addition of a constant ("+") + Add a 32 bit signed constant to the address part of a NetAddr + object. This operation changes the address part to point so many + hosts above the current objects start address. For instance, this + code: + + print NetAddr::IP::Lite->new('127.0.0.1/8') + 5; + + will output 127.0.0.6/8. The address will wrap around at the + broadcast back to the network address. This code: + + print NetAddr::IP::Lite->new('10.0.0.1/24') + 255; + + outputs 10.0.0.0/24. + + Returns the the unchanged object when the constant is missing or out + of range. + + 2147483647 <= constant >= -2147483648 + + Subtraction of a constant ("-") + The complement of the addition of a constant. + + Difference ("-") + Returns the difference between the address parts of two + NetAddr::IP::Lite objects address parts as a 32 bit signed number. + + Returns undef if the difference is out of range. + + Auto-increment + Auto-incrementing a NetAddr::IP::Lite object causes the address part + to be adjusted to the next host address within the subnet. It will + wrap at the broadcast address and start again from the network + address. + + Auto-decrement + Auto-decrementing a NetAddr::IP::Lite object performs exactly the + opposite of auto-incrementing it, as you would expect. + + Methods + + "->new([$addr, [ $mask|IPv6 ]])" + "->new6([$addr, [ $mask]])" + "->new6FFFF([$addr, [ $mask]])" + "->new_no([$addr, [ $mask]])" + "->new_from_aton($netaddr)" + new_cis and new_cis6 are DEPRECATED + "->new_cis("$addr $mask)" + "->new_cis6("$addr $mask)" + The first three methods create a new address with the supplied + address in "$addr" and an optional netmask "$mask", which can be + omitted to get a /32 or /128 netmask for IPv4 / IPv6 addresses + respectively. + + new6FFFF specifically returns an IPv4 address in IPv6 format + according to RFC4291 + + new6 ::xxxx:xxxx + new6FFFF ::FFFF:xxxx:xxxx + + The third method "new_no" is exclusively for IPv4 addresses and + filters improperly formatted dot quad strings for leading 0's that + would normally be interpreted as octal format by NetAddr per the + specifications for inet_aton. + + new_from_aton takes a packed IPv4 address and assumes a /32 mask. + This function replaces the DEPRECATED :aton functionality which is + fundamentally broken. + + The last two methods new_cis and new_cis6 differ from new and new6 + only in that they except the common Cisco address notation for + address/mask pairs with a space as a separator instead of a slash + (/) + + These methods are DEPRECATED because the functionality is now + included in the other "new" methods + + i.e. ->new_cis('1.2.3.0 24') + or + ->new_cis6('::1.2.3.0 120') + + "->new6" and "->new_cis6" mark the address as being in ipV6 address + space even if the format would suggest otherwise. + + i.e. ->new6('1.2.3.4') will result in ::102:304 + + addresses submitted to ->new in ipV6 notation will + remain in that notation permanently. i.e. + ->new('::1.2.3.4') will result in ::102:304 + whereas new('1.2.3.4') would print out as 1.2.3.4 + + See "STRINGIFICATION" below. + + "$addr" can be almost anything that can be resolved to an IP address + in all the notations I have seen over time. It can optionally + contain the mask in CIDR notation. If the OPTIONAL perl module + Socket6 is available in the local library it will autoload and ipV6 + host6 names will be resolved as well as ipV4 hostnames. + + prefix notation is understood, with the limitation that the range + specified by the prefix must match with a valid subnet. + + Addresses in the same format returned by "inet_aton" or + "gethostbyname" can also be understood, although no mask can be + specified for them. The default is to not attempt to recognize this + format, as it seems to be seldom used. + + ###### DEPRECATED, will be remove in version 5 ############ To + accept addresses in that format, invoke the module as in + + use NetAddr::IP::Lite ':aton' + + ###### USE new_from_aton instead ########################## + + If called with no arguments, 'default' is assumed. + + If called with an empty string as the argument, returns 'undef' + + "$addr" can be any of the following and possibly more... + + n.n + n.n/mm + n.n mm + n.n.n + n.n.n/mm + n.n.n mm + n.n.n.n + n.n.n.n/mm 32 bit cidr notation + n.n.n.n mm + n.n.n.n/m.m.m.m + n.n.n.n m.m.m.m + loopback, localhost, broadcast, any, default + x.x.x.x/host + 0xABCDEF, 0b111111000101011110, (or a bcd number) + a netaddr as returned by 'inet_aton' + + Any RFC1884 notation + + ::n.n.n.n + ::n.n.n.n/mmm 128 bit cidr notation + ::n.n.n.n/::m.m.m.m + ::x:x + ::x:x/mmm + x:x:x:x:x:x:x:x + x:x:x:x:x:x:x:x/mmm + x:x:x:x:x:x:x:x/m:m:m:m:m:m:m:m any RFC1884 notation + loopback, localhost, unspecified, any, default + ::x:x/host + 0xABCDEF, 0b111111000101011110 within the limits + of perl's number resolution + 123456789012 a 'big' bcd number (bigger than perl likes) + and Math::BigInt + + A Fully Qualified Domain Name which returns an ipV4 address or an + ipV6 address, embodied in that order. This previously undocumented + feature may be disabled with: + + use NetAddr::IP::Lite ':nofqdn'; + + If called with no arguments, 'default' is assumed. + + If called with and empty string as the argument, 'undef' is + returned; + + "->broadcast()" + Returns a new object referring to the broadcast address of a given + subnet. The broadcast address has all ones in all the bit positions + where the netmask has zero bits. This is normally used to address + all the hosts in a given subnet. + + "->network()" + Returns a new object referring to the network address of a given + subnet. A network address has all zero bits where the bits of the + netmask are zero. Normally this is used to refer to a subnet. + + "->addr()" + Returns a scalar with the address part of the object as an IPv4 or + IPv6 text string as appropriate. This is useful for printing or for + passing the address part of the NetAddr::IP::Lite object to other + components that expect an IP address. If the object is an ipV6 + address or was created using ->new6($ip) it will be reported in ipV6 + hex format otherwise it will be reported in dot quad format only if + it resides in ipV4 address space. + + "->mask()" + Returns a scalar with the mask as an IPv4 or IPv6 text string as + described above. + + "->masklen()" + Returns a scalar the number of one bits in the mask. + + "->bits()" + Returns the width of the address in bits. Normally 32 for v4 and 128 + for v6. + + "->version()" + Returns the version of the address or subnet. Currently this can be + either 4 or 6. + + "->cidr()" + Returns a scalar with the address and mask in CIDR notation. A + NetAddr::IP::Lite object *stringifies* to the result of this + function. (see comments about ->new6() and ->addr() for output + formats) + + "->aton()" + Returns the address part of the NetAddr::IP::Lite object in the same + format as the "inet_aton()" or "ipv6_aton" function respectively. If + the object was created using ->new6($ip), the address returned will + always be in ipV6 format, even for addresses in ipV4 address space. + + "->range()" + Returns a scalar with the base address and the broadcast address + separated by a dash and spaces. This is called range notation. + + "->numeric()" + When called in a scalar context, will return a numeric + representation of the address part of the IP address. When called in + an array context, it returns a list of two elements. The first + element is as described, the second element is the numeric + representation of the netmask. + + This method is essential for serializing the representation of a + subnet. + + "->bigint()" + When called in a scalar context, will return a Math::BigInt + representation of the address part of the IP address. When called in + an array contest, it returns a list of two elements. The first + element is as described, the second element is the Math::BigInt + representation of the netmask. + + "$me->contains($other)" + Returns true when "$me" completely contains "$other". False is + returned otherwise and "undef" is returned if "$me" and "$other" are + not both "NetAddr::IP::Lite" objects. + + "$me->within($other)" + The complement of "->contains()". Returns true when "$me" is + completely contained within "$other", undef if "$me" and "$other" + are not both "NetAddr::IP::Lite" objects. + + C->is_rfc1918()> + Returns true when "$me" is an RFC 1918 address. + + 10.0.0.0 - 10.255.255.255 (10/8 prefix) + 172.16.0.0 - 172.31.255.255 (172.16/12 prefix) + 192.168.0.0 - 192.168.255.255 (192.168/16 prefix) + + "->is_local()" + Returns true when "$me" is a local network address. + + i.e. ipV4 127.0.0.0 - 127.255.255.255 + or ipV6 === ::1 + + "->first()" + Returns a new object representing the first usable IP address within + the subnet (ie, the first host address). + + "->last()" + Returns a new object representing the last usable IP address within + the subnet (ie, one less than the broadcast address). + + "->nth($index)" + Returns a new object representing the *n*-th usable IP address + within the subnet (ie, the *n*-th host address). If no address is + available (for example, when the network is too small for "$index" + hosts), "undef" is returned. + + Version 4.00 of NetAddr::IP and version 1.00 of NetAddr::IP::Lite + implements "->nth($index)" and "->num()" exactly as the + documentation states. Previous versions behaved slightly differently + and not in a consistent manner. + + To use the old behavior for "->nth($index)" and "->num()": + + use NetAddr::IP::Lite qw(:old_nth); + + old behavior: + NetAddr::IP->new('10/32')->nth(0) == undef + NetAddr::IP->new('10/32')->nth(1) == undef + NetAddr::IP->new('10/31')->nth(0) == undef + NetAddr::IP->new('10/31')->nth(1) == 10.0.0.1/31 + NetAddr::IP->new('10/30')->nth(0) == undef + NetAddr::IP->new('10/30')->nth(1) == 10.0.0.1/30 + NetAddr::IP->new('10/30')->nth(2) == 10.0.0.2/30 + NetAddr::IP->new('10/30')->nth(3) == 10.0.0.3/30 + + Note that in each case, the broadcast address is represented in the + output set and that the 'zero'th index is alway undef except for a + point-to-point /31 or /127 network where there are exactly two + addresses in the network. + + new behavior: + NetAddr::IP->new('10/32')->nth(0) == 10.0.0.0/32 + NetAddr::IP->new('10.1/32'->nth(0) == 10.0.0.1/32 + NetAddr::IP->new('10/31')->nth(0) == 10.0.0.0/32 + NetAddr::IP->new('10/31')->nth(1) == 10.0.0.1/32 + NetAddr::IP->new('10/30')->nth(0) == 10.0.0.1/30 + NetAddr::IP->new('10/30')->nth(1) == 10.0.0.2/30 + NetAddr::IP->new('10/30')->nth(2) == undef + + Note that a /32 net always has 1 usable address while a /31 has + exactly two usable addresses for point-to-point addressing. The + first index (0) returns the address immediately following the + network address except for a /31 or /127 when it return the network + address. + + "->num()" + As of version 4.42 of NetAddr::IP and version 1.27 of + NetAddr::IP::Lite a /31 and /127 with return a net num value of 2 + instead of 0 (zero) for point-to-point networks. + + Version 4.00 of NetAddr::IP and version 1.00 of NetAddr::IP::Lite + return the number of usable IP addresses within the subnet, not + counting the broadcast or network address. + + Previous versions worked only for ipV4 addresses, returned a maximum + span of 2**32 and returned the number of IP addresses not counting + the broadcast address. (one greater than the new behavior) + + To use the old behavior for "->nth($index)" and "->num()": + + use NetAddr::IP::Lite qw(:old_nth); + + WARNING: + + NetAddr::IP will calculate and return a numeric string for network + ranges as large as 2**128. These values are TEXT strings and perl + can treat them as integers for numeric calculations. + + Perl on 32 bit platforms only handles integer numbers up to 2**32 + and on 64 bit platforms to 2**64. + + If you wish to manipulate numeric strings returned by NetAddr::IP + that are larger than 2**32 or 2**64, respectively, you must load + additional modules such as Math::BigInt, bignum or some similar + package to do the integer math. + +EXPORT_OK + Zeros + Ones + V4mask + V4net + :aton DEPRECATED + :old_nth + :upper + :lower + :nofqdn + +AUTHORS + Luis E. Muñoz , Michael Robinton + + +WARRANTY + This software comes with the same warranty as perl itself (ie, none), so + by using it you accept any and all the liability. + +COPYRIGHT + This software is (c) Luis E. Muñoz, 1999 - 2005 + and (c) Michael Robinton, 2006 - 2014. + + All rights reserved. + + This program is free software; you can redistribute it and/or modify it + under the terms of either: + + a) the GNU General Public License as published by the Free + Software Foundation; either version 2, or (at your option) any + later version, or + + b) the "Artistic License" which comes with this distribution. + + 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 either the GNU + General Public License or the Artistic License for more details. + + You should have received a copy of the Artistic License with this + distribution, in the file named "Artistic". If not, I'll be glad to + provide one. + + You should also have received a copy of the GNU General Public License + along with this program in the file named "Copying". If not, write to + the + + Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor + Boston, MA 02110-1301 USA + + or visit their web page on the internet at: + + http://www.gnu.org/copyleft/gpl.html. + +SEE ALSO + NetAddr::IP(3), NetAddr::IP::Util(3), NetAddr::IP::InetBase(3) + diff --git a/Lite/Util/Changes b/Lite/Util/Changes new file mode 100644 index 0000000..35fb8b8 --- /dev/null +++ b/Lite/Util/Changes @@ -0,0 +1,287 @@ + +1.53 Mon Aug 17 15:35:28 PDT 2015 + fix typo in MakefilePL that cause compiler to not be found at all + +1.52 Thu Aug 13 22:44:48 PDT 2015 + fix Makefile.PL to accomodate bug in Android's sh + + fix Makefile.PL issue with clang compiler, bug 86831 + +1.51 Mon Jan 27 11:59:58 PST 2014 + modify Makefile.PL to bypass missing 'pod2text' + +1.50 Tue Apr 9 12:02:34 PDT 2013 + changed Makefile.PL to check for config.h when building for XS + with 'gcc', try building with 'cc', and check again. + If config.h is not found, force Pure Perl mode. + + Kill XS in winduhs and Darwin, both of which misbehave when compiling XS code + +1.49 Wed Apr 3 10:52:24 PDT 2013 + modify Makefile.PL to better detect 'winduhs' + +1.48 Tue Oct 2 12:36:11 PDT 2012 + correct incorrect format for IPv6 embedded IPv4 addresses + in InetBase v0.8 + +1.47 Fri Aug 10 11:46:18 PDT 2012 + correct typo in documentation POD + Thanks to Gregor Herrmann, Debian Perl Group + + Updated GPL text and address + +1.46 Fri Nov 11 19:23:11 PST 2011 + update documentation in InetBase v0.06 + +1.45 Fri Nov 11 13:20:32 PST 2011 + break out the code in InetBase v0.05 that expands short IPv4 + addresses into dotquad format to account for broken BSD + implementations of inet_aton and gethostbyname that do + not recognize the short format. EXPORT this as sub 'fillIPv4' + + in Util.pm, add 'fillIPv4' to calls to gethostbyname to + work around broken inet_aton and gethostbyname implementations + in certain BSD implementations + +1.44 Wed Nov 2 19:15:31 PDT 2011 + improve inet_aton in InetBase v0.04 to overcome broken + gethostbyname found in NetBSD and OpenBSD + +1.43 Mon Oct 24 13:25:09 PDT 2011 + remove reference to Config{osname} in InetBase.pm v0.03 + +1.42 Fri Oct 21 10:34:46 PDT 2011 + Socket6 prior to version 0.23 does not have AF_INET6 in the + EXPORT_OK array, modify InetBase.pm v0.02 to work around this. + +1.41 Sat Oct 15 17:26:21 PDT 2011 + add inet_pton, inet_ntop, AF_INET, AF_INET6 + + modify inet_n2dx and inet_n2ad to + recognize the new 128 bit IPv4 format + ::FFFF:FFFF:0:0 + + replace isIPv4 with a pure perl version for portablity + + split the following into NetAddr::IP::InetBase v0.01 + to provide better long term support for IPv6 + inet_aton + inet_ntoa + ipv6_aton + ipv6_n2x + ipv6_n2d + inet_any2n + inet_n2dx + inet_n2ad + inet_ntop + inet_pton + packzeros + isIPv4 + isNewIPv4 + isAnyIPv4 + AF_INET + AF_INET6 + +1.40 Sat Oct 8 01:33:44 PDT 2011 + remove debug print statement from Util.pm + +1.39 Thu Oct 6 23:41:42 PDT 2011 + really correct missing internal reference + +1.38 Thu Oct 6 20:20:33 PDT 2011 + corrected missing internal reference to inet_4map6 + +1.37 Thu Oct 6 18:23:04 PDT 2011 + addid isAnyIPv4, isNewIPv4, inet_4map6 + revised naip_gethostbyname + to conform to Perl's gethostbyname output + +1.36 Sat Feb 19 10:04:00 PST 2011 + correction to use of package lexicals + + thanks to mishikal@yahoo.com for spotting the bug and to + Mark Martinec mark.martinec+ama...@ijs.si for the solution. + +1.35 Tue Nov 16 16:28:37 PST 2010 + naip_gethostbyname modified to return undef instead of + 0 (zero) on failure + + thanks to Terry Cassidy enaudishaylee@tc17.com for the bug report + + move sub's ipv6_n2d and ipv6_n2x to non-autosplit portion + of module to eliminate warnings during autosplit of "our" variables + + thanks to Nicholas Bamber + Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=517361 + +1.34 Wed Sep 29 10:32:50 PDT 2010 + Conditionalize import of AF_INET6 in Util.pm + NetAddr::IP::UtilPolluted + +1.33 Tue Sep 21 17:50:50 PDT 2010 + Add UtilPolluted namespace to contain name space pollution + created by "use Socket" when invoking Socket6. + +1.32 Wed May 12 14:18:20 PDT 2010 + In Util.xs, + changed netswap() to postincrement + *a++ = to *a and added increment after save to mollify some + picky compilers that return possible undefined behavior. + + changed type of _128x10 to 'void' + +1.31 Tue Jun 9 10:31:11 PDT 2009 + ferret out shell value for Makefile.PL when calling + ./configure for systems where the 'x' bit gets lost + due to bug in Archive::Tar + +1.30 Sat Mar 7 16:35:33 PST 2009 + make the compiler test check the environment for + CC before using Perl's default compiler + +1.29 Sat Mar 7 16:15:18 PST 2009 + revised compiler test in Makefile.PL for Util v1.29 + to accomodate picky Solaris "cc" + +1.28 Wed Dec 17 14:14:06 PST 2008 + set uninitialized "carry" in XS bin2bcd to zero + +1.27 Tue Dec 9 12:00:08 PST 2008 + revised UtilPP v1.7 to work around perl 5.8.4 + failures with certain @_ operations of goto &sub... + see perl bug [ 23429]. Unfortunately, perl-5.8.4 is + the distribution of choice for many solaris boxes + +1.26 Fri Nov 28 23:19:01 PST 2008 + revised XS code to be full re-entrant... thread safe. + removed all traces of mutex locks + removed function 'threads' here an in UtilPP v1.6 + +1.25 Tue Nov 18 19:08:56 PST 2008 + correct documentation error in Util_PP v1.5 + + add threads reporting to Util.xs and UtilPP + + added what is hopefully thread safe operation via + serialization. Must be invoked by "--with-threads" + +1.24 Wed Nov 5 18:13:20 PST 2008 + Clean up Makefile.PL to check actual required link + libraries against the perl build for consistency + +1.23 Sun Nov 2 10:10:38 PST 2008 + add missing headers in configure and localconf.h for Solaris inet_xton + thanks to Karl Bunch for spotting the bug. + +1.22 Wed Oct 22 14:54:12 PDT 2008 + eliminated dependence on PL_sawampersand + thanks to Mark Martinec + for spotting this and submitting a patch. + + force -noxs mode for Win32 + + use autoconf to configure 'C' build + +1.21 Thu Oct 16 19:35:33 PDT 2008 + again... clear build bug for Win32 + and lets get the version number right since it appears + that it was up-rev'd at some point to 1.xx + +0.20 Mon Oct 6 13:07:34 PDT 2008 + clear build bug for Win32 + +0.19 Sat Sep 27 13:36:58 PDT 2008 + updated test for ENDIANess in siteconf + + add test in inet_aton to detect overange IP dot quad values + missed by some broken Socket implementations + i.e. 256.1.1.1 + +0.18 Sun Aug 6 10:48:25 PDT 2006 + correct shiftleft documentation + correct mask4to6 documentation + +0.17 Thu Jul 6 10:46:48 PDT 2006 + update 'siteconf line 1608' to fix empty variable in inet_aton test + update 'siteconf line 1636' to fix empty variable in inet_pton test + add missing colon at t/notcontiguous.t line 66 + +0.16 Sun Jun 25 16:13:00 PDT 2006 + fixed ->new() issues with long digit strings ->new('::fffff') + and non hex digits ->new('::foo'). + Thanks to Radoslaw Zielinski + for spotting those bugs + +0.15 Tue Jun 13 14:42:34 PDT 2006 + UtilPP.pm v0.07 & Util.xs 'shiftleft' so that the original + argument is returned when the shift count is '0' or missing + +0.14 Tue Jun 6 08:37:01 PDT 2006 + add logic to check LIBS => [-lfiles] + individually. ExtUtils::xxx does a bad job and + leaves libs that do not exist in the list + which causes 'siteconf' to blow up on missing libs + on perl 5.053 (and probably others) + +0.13 Tue Jun 6 08:33:11 PDT 2006 + added to xs file, 'hopefully' to allow build on windoze platforms + +0.12 Tue Jun 6 08:21:12 PDT 2006 + add logic to makefile so 'siteconfig' and C libs + are not used in PurePerl mode + +0.11 Mon Jun 5 14:45:09 PDT 2006 + fix Sparc problems + 1) add workaround for OS's that do not have inet_aton + + 2) add workaround for compilers that do not understand + #if MACRO1 == MACRO2 + +0.10 Sat Jun 3 19:07:51 PDT 2006 + add site configuration to supply u_intxx_t vars + for Sun OS and others that don't have them + +0.09 Sun May 7 18:06:43 PDT 2006 + UtilPP.pm v0.06, removed unnecessary pack(unpack) sequences + to speed up ipv4->6, ipv6->4 conversions + +0.08 Wed Apr 26 18:33:12 PDT 2006 + correct documentation error + add ipv6to4 + +0.07 Sun Apr 23 16:11:56 PDT 2006 + correct reporting error in UtilPP v0.04 for + incorrect argument length in ipv4 -> 6 conversions + + add conditional netaddr conversion functions + ipanyto6, maskanyto6 to Util.xs and UtilPP v0.05 + +0.06 Tue Apr 18 16:50:53 PDT 2006 + add ipv4to6, mask4to6 to Util.pm and UtilPP.pm v0.03 + +0.05 Sat Apr 15 15:48:17 PDT 2006 + Fixed some typo's in Makefile.PL that + failed to update README during build + +0.04 Wed Apr 12 15:43:33 PDT 2006 + add Util_IS.pm to guarantee that the XS lib is not + loaded if a previous incarnation of the same version + has previously been installed on the system and the + module is built with -noxs + +0.03 Tue Apr 4 21:55:35 PDT 2006 + update minisocket to perl-5.9.3, add header + file for backwards compatibility + + add function 'notcontiguous' to return cidr size + and check for spurious bits in the network mask + +0.02 Fri Mar 31 12:44:15 PST 2006 + added test for illegal characters to ipv6_aton + + added UtilPP for Pure Perl functionality for the + WinTel folks that don't have gcc on their systems + +0.01 Tue Mar 28 16:42:44 PST 2006 + initial release + diff --git a/Lite/Util/MANIFEST b/Lite/Util/MANIFEST new file mode 100644 index 0000000..9e4e21d --- /dev/null +++ b/Lite/Util/MANIFEST @@ -0,0 +1,54 @@ +Changes +MANIFEST This list of files +MANIFEST.SKIP +Makefile.PL +README +Util.pm +Util.xs +config.h.in +configure.cc +configure.gcc +configure.ac +lib/NetAddr/IP/InetBase.pm +lib/NetAddr/IP/UtilPP.pm +localconf.h +t/4to6.t +t/add128.t +t/addconst.t +t/af_inet6.t +t/anyto6.t +t/badd.t +t/bcd2bin.t +t/bcdn2bin.t +t/bin.t +t/binet_n2ad.t +t/binet_n2dx.t +t/binet_pton.t +t/bipv4_inet.t +t/binet_ntoa.t +t/bipv6_any2n.t +t/bipv6func.t +t/bisIPv4.t +t/bpackzeros.t +t/comp128.t +t/croak.t +t/hasbits.t +t/inet_4map6.t +t/inet_n2ad.t +t/inet_n2dx.t +t/inet_pton.t +t/ipv4_inet.t +t/ipv6_ntoa.t +t/ipv6_any2n.t +t/ipv6func.t +t/ipv6to4.t +t/isIPv4.t +t/leftshift.t +t/mode.t +t/notcontiguous.t +t/packzeros.t +t/simple_pack.t +t/sub128.t +t/naip_gethostbyname.t +t/no6_naip_gethostbyname.t +typemap diff --git a/Lite/Util/MANIFEST.SKIP b/Lite/Util/MANIFEST.SKIP new file mode 100644 index 0000000..122be32 --- /dev/null +++ b/Lite/Util/MANIFEST.SKIP @@ -0,0 +1,32 @@ +^Build$ +^_build/ +^blib/ +^blibdirs +Makefile$ +Makefile\.[a-z]+$ +pm_to_blib +CVS/.* +\.cvs +,v$ +^tmp/ +\.old$ +\.bak$ +\.tmp$ +\.xsc$ +~$ +^# +\.shar$ +\.tar$ +\.tgz$ +\.tar\.gz$ +\.zip$ +_uu$ +Util\.(bs|[co])$ +localStuff\.h$ +config\.log$ +config\.h$ +config\.status +localperl\.h +tlib/NetAddr/IP/Util_IS.pm +Util_IS.pm +META.yml diff --git a/Lite/Util/Makefile.PL b/Lite/Util/Makefile.PL new file mode 100644 index 0000000..77d9eb7 --- /dev/null +++ b/Lite/Util/Makefile.PL @@ -0,0 +1,268 @@ +use ExtUtils::MakeMaker qw( + WriteMakefile + prompt +); +use Config; +use Cwd; +# fix for bug in Android's sh +use File::Spec; +use Getopt::Long qw( + GetOptions +); + +my $pwd = getcwd(); + +unlink 'Makefile'; # remove Makefile to stabilize CC test + +# +# get any command line arguments +# +my($useXS); +GetOptions( + 'xs!' => \$useXS, + 'pm' => sub { + warn "\n\t".'WARNING: Use of "--pm" is deprecated, use "-noxs" instead'."\n\n"; + $useXS = 0; + }, +); + +print STDERR "building for $^O\n"; + +#if ($Config{osname} =~ /MSWin32/i || $Config{osname} eq 'dos') { +# kill windows and Darwin, both of which misbahave when building XS code +if ($Config{osname} =~ /win/i || $Config{osname} eq 'dos') { + $useXS = 0; # force NOXS mode for windows +} + +my $pkg = 'NetAddr::IP::Util'; +$pkg =~ /[^:]+$/; +my $module = $& .'.pm'; +my $cfile = $& .'.c'; + +my %makeparms = ( + NAME => $pkg, + VERSION_FROM => $module, # finds $VERSION +# depend => {$cfile => q[xs_include/miniSocket.inc localconf.h config.h localperl.h], + depend => {$cfile => q[ localconf.h config.h localperl.h ], + }, +# PREREQ_PM => { Socket6 => 0.23, can't do this +# }, + LIBS => [], + XS => {}, + C => [], + clean => { FILES => "*.bs *.o *.c *~ tmp* Util_IS.pm localperl.h auto*"}, + realclean => { FILES => "config.h config.log config.status"}, + dist => {COMPRESS=>'gzip', SUFFIX=>'gz'} + +); + +# +# Check if we have a C compiler + +unless (defined $useXS) { + my $compiler = test_cc(); + if ($compiler) { + $ENV{CC} = $compiler; + print "You have a working compiler.\n"; + $useXS = 1; +# $makeparms{'MYEXTLIB'} = 'netdns$(LIB_EXT)', + + } else { + $useXS = 0; + print <tmpdir() if $^O eq 'android'; + + unless (-e './config.h') { + system $Config{sh}, 'configure.gcc'; + } + my @LIBS; + unless (open(F,'config.h')) { + warn "Cannot read config.h built by 'gcc', trying 'cc'.\n"; +# try to build with cc + system $Config(sh), 'configure.cc'; + unless (open(F,'config.h')) { + warn "Cannot read config.h built by 'cc', using 'pure Perl'.\n"; + $useXS = 0; + last; + } + } + + foreach() { + if ($_ =~ /^#define LIBS([ a-zA-Z-]+)/) { + @LIBS = ($1 =~ /[a-zA-Z0-9-]+/g); + + $makeparms{LIBS} = [$1]; + last; + } + } + close F; + my $link = ''; + foreach(@libs) { + if ($Config{libs} =~ /$_\b/) { + $link .= $_ .' '; + } + } + chop $link; + $makeparms{LIBS} = [$link]; + + open(F,'>localperl.h') or die "could not open localperl.h for write\n"; + print F q| +/* Written by Makefile.PL + * + * Do not modify this file, modify Makefile.PL instead + * + */ +|; + close F; + + $begin = q| +config :: config.h + @$(NOOP) + +config.h : + $(SHELL) configure +|; + last; +} + +open(F,'>Util_IS.pm'); +print F q|#!/usr/bin/perl +# +# DO NOT ALTER THIS FILE +# IT IS WRITTEN BY Makefile.PL +# EDIT THAT INSTEAD +# +package NetAddr::IP::Util_IS; +use vars qw($VERSION); +$VERSION = 1.00; + + +sub pure { + return |, (($useXS) ? 0 : 1), q|; +} +sub not_pure { + return |, (($useXS) ? 1 : 0), q|; +} +1; +__END__ + +=head1 NAME + +NetAddr::IP::Util_IS - Tell about Pure Perl + +=head1 SYNOPSIS + + use NetAddr::IP::Util_IS; + + $rv = NetAddr::IP::Util_IS->pure; + $rv = NetAddr::IP::Util_IS->not_pure; + +=head1 DESCRIPTION + +Util_IS indicates whether or not B was compiled in Pure +Perl mode. + +=over 4 + +=item * $rv = NetAddr::IP::Util_IS->pure; + +Returns true if PurePerl mode, else false. + +=item * $rv = NetAddr::IP::Util_IS->not_pure; + +Returns true if NOT PurePerl mode, else false + +=back + +=cut + +1; +|; + +sub test_cc { + # + # The perl/C check borrowed and modified from + # Graham Barr's Scalar-List-Utils distribution. + # + print "Testing if you have a C compiler and the needed header files....\n"; + + unless (open(F, ">compile.c")) { + warn "Cannot write compile.c, skipping test compilation and installing pure Perl version.\n"; + return 0; + } + + my $CC; + foreach $CC (($ENV{CC},$Config{cc},$Config{ccname})) { + next unless $CC; + my $command = qq|$CC compile.c -o compile.output|; + + print F <<'EOF'; +int main() { return 0; } +EOF + + close(F) or return 0; + + print STDERR $command,"\n"; + + my $rv = system($command); + + foreach my $file (glob('compile*')) { + unlink($file) || warn "Could not delete $file: $!\n"; + } + if ($rv == 0) { + return $CC; + } + } + return undef; +} + +sub MY::top_targets { + package MY; + my $inherited = shift->SUPER::top_targets(@_); + $inherited =~ s/(pure_all\s+::.+)/$1 README/; + $begin . $inherited; +} + +sub MY::post_constants { + my $post_constants = $Config{scriptdirexp} .'/pod2text'; + if (-e $post_constants) { + $post_constants = q| +MY_POD2TEXT = |. $post_constants .q| +|; + } else { + $post_constants = q| +MY_POD2TEXT = echo "perl distro missing 'pod2text' to convert " |; + } +} + +sub MY::postamble { + package MY; + my $postamble = q| +README : |. $module .q| + @$(MY_POD2TEXT) |. $module .q| > README + +|; +} + +WriteMakefile(%makeparms); diff --git a/Lite/Util/README b/Lite/Util/README new file mode 100644 index 0000000..fdc3f17 --- /dev/null +++ b/Lite/Util/README @@ -0,0 +1,605 @@ +NAME + NetAddr::IP::Util -- IPv4/6 and 128 bit number utilities + +SYNOPSIS + use NetAddr::IP::Util qw( + inet_aton + inet_ntoa + ipv6_aton + ipv6_ntoa + ipv6_n2x + ipv6_n2d + inet_any2n + hasbits + isIPv4 + isNewIPv4 + isAnyIPv4 + inet_n2dx + inet_n2ad + inet_pton + inet_ntop + inet_4map6 + ipv4to6 + mask4to6 + ipanyto6 + maskanyto6 + ipv6to4 + packzeros + shiftleft + addconst + add128 + sub128 + notcontiguous + bin2bcd + bcd2bin + mode + AF_INET + AF_INET6 + naip_gethostbyname + ); + + use NetAddr::IP::Util qw(:all :inet :ipv4 :ipv6 :math) + + :inet => inet_aton, inet_ntoa, ipv6_aton + ipv6_ntoa, ipv6_n2x, ipv6_n2d, + inet_any2n, inet_n2dx, inet_n2ad, + inet_pton, inet_ntop, inet_4map6, + ipv4to6, mask4to6, ipanyto6, packzeros + maskanyto6, ipv6to4, naip_gethostbyname + + :ipv4 => inet_aton, inet_ntoa + + :ipv6 => ipv6_aton, ipv6_ntoa, ipv6_n2x, + ipv6_n2d, inet_any2n, inet_n2dx, + inet_n2ad, inet_pton, inet_ntop, + inet_4map6, ipv4to6, mask4to6, + ipanyto6, maskanyto6, ipv6to4, + packzeros, naip_gethostbyname + + :math => hasbits, isIPv4, isNewIPv4, isAnyIPv4, + addconst, add128, sub128, notcontiguous, + bin2bcd, bcd2bin, shiftleft + + $dotquad = inet_ntoa($netaddr); + $netaddr = inet_aton($dotquad); + $ipv6naddr = ipv6_aton($ipv6_text); + $ipv6_text = ipvt_ntoa($ipv6naddr); + $hex_text = ipv6_n2x($ipv6naddr); + $dec_text = ipv6_n2d($ipv6naddr); + $hex_text = packzeros($hex_text); + $ipv6naddr = inet_any2n($dotquad or $ipv6_text); + $ipv6naddr = inet_4map6($netaddr or $ipv6naddr); + $rv = hasbits($bits128); + $rv = isIPv4($bits128); + $rv = isNewIPv4($bits128); + $rv = isAnyIPv4($bits128); + $dotquad or $hex_text = inet_n2dx($ipv6naddr); + $dotquad or $dec_text = inet_n2ad($ipv6naddr); + $netaddr = inet_pton($AF_family,$hex_text); + $hex_text = inet_ntop($AF_family,$netaddr); + $ipv6naddr = ipv4to6($netaddr); + $ipv6naddr = mask4to6($netaddr); + $ipv6naddr = ipanyto6($netaddr); + $ipv6naddr = maskanyto6($netaddr); + $netaddr = ipv6to4($pv6naddr); + $bitsX2 = shiftleft($bits128,$n); + $carry = addconst($ipv6naddr,$signed_32con); + ($carry,$ipv6naddr)=addconst($ipv6naddr,$signed_32con); + $carry = add128($ipv6naddr1,$ipv6naddr2); + ($carry,$ipv6naddr)=add128($ipv6naddr1,$ipv6naddr2); + $carry = sub128($ipv6naddr1,$ipv6naddr2); + ($carry,$ipv6naddr)=sub128($ipv6naddr1,$ipv6naddr2); + ($spurious,$cidr) = notcontiguous($mask128); + $bcdtext = bin2bcd($bits128); + $bits128 = bcd2bin($bcdtxt); + $modetext = mode; + ($name,$aliases,$addrtype,$length,@addrs)=naip_gethostbyname(NAME); + $trueif = havegethostbyname2(); + + NetAddr::IP::Util::lower(); + NetAddr::IP::Util::upper(); + +INSTALLATION + Un-tar the distribution in an appropriate directory and type: + + perl Makefile.PL + make + make test + make install + + NetAddr::IP::Util installs by default with its primary functions + compiled using Perl's XS extensions to build a 'C' library. If you do + not have a 'C' complier available or would like the slower Pure Perl + version for some other reason, then type: + + perl Makefile.PL -noxs + make + make test + make install + +DESCRIPTION + NetAddr::IP::Util provides a suite of tools for manipulating and + converting IPv4 and IPv6 addresses into 128 bit string context and back + to text. The strings can be manipulated with Perl's logical operators: + + and & + or | + xor ^ + ~ compliment + + in the same manner as 'vec' strings. + + The IPv6 functions support all rfc1884 formats. + + i.e. x:x:x:x:x:x:x:x:x + x:x:x:x:x:x:x:d.d.d.d + ::x:x:x + ::x:d.d.d.d + and so on... + + * $dotquad = inet_ntoa($netaddr); + Convert a packed IPv4 network address to a dot-quad IP address. + + input: packed network address + returns: IP address i.e. 10.4.12.123 + + * $netaddr = inet_aton($dotquad); + Convert a dot-quad IP address into an IPv4 packed network address. + + input: IP address i.e. 192.5.16.32 + returns: packed network address + + * $ipv6addr = ipv6_aton($ipv6_text); + Takes an IPv6 address of the form described in rfc1884 and returns a + 128 bit binary RDATA string. + + input: ipv6 text + returns: 128 bit RDATA string + + * $ipv6_text = ipv6_ntoa($ipv6naddr); + Convert a 128 bit binary IPv6 address to compressed rfc 1884 text + representation. + + input: 128 bit RDATA string + returns: ipv6 text + + * $hex_text = ipv6_n2x($ipv6addr); + Takes an IPv6 RDATA string and returns an 8 segment IPv6 hex address + + input: 128 bit RDATA string + returns: x:x:x:x:x:x:x:x + + * $dec_text = ipv6_n2d($ipv6addr); + Takes an IPv6 RDATA string and returns a mixed hex - decimal IPv6 + address with the 6 uppermost chunks in hex and the lower 32 bits in + dot-quad representation. + + input: 128 bit RDATA string + returns: x:x:x:x:x:x:d.d.d.d + + * $ipv6naddr = inet_any2n($dotquad or $ipv6_text); + This function converts a text IPv4 or IPv6 address in text format in + any standard notation into a 128 bit IPv6 string address. It + prefixes any dot-quad address (if found) with '::' and passes it to + ipv6_aton. + + input: dot-quad or rfc1844 address + returns: 128 bit IPv6 string + + * $rv = hasbits($bits128); + This function returns true if there are one's present in the 128 bit + string and false if all the bits are zero. + + i.e. if (hasbits($bits128)) { + &do_something; + } + + or if (hasbits($bits128 & $mask128) { + &do_something; + } + + This allows the implementation of logical functions of the form of: + + if ($bits128 & $mask128) { + ... + + input: 128 bit IPv6 string + returns: true if any bits are present + + * $ipv6naddr = inet_4map6($netaddr or $ipv6naddr + This function returns an ipV6 network address with the first 80 bits + set to zero and the next 16 bits set to one, while the last 32 bits + are filled with the ipV4 address. + + input: ipV4 netaddr + or ipV6 netaddr + returns: ipV6 netaddr + + returns: undef on error + + An ipV6 network address must be in one of the two compatible ipV4 + mapped address spaces. i.e. + + ::ffff::d.d.d.d or ::d.d.d.d + + * $rv = isIPv4($bits128); + This function returns true if there are no on bits present in the + IPv6 portion of the 128 bit string and false otherwise. + + i.e. the address must be of the form - ::d.d.d.d + + Note: this is an old and deprecated ipV4 compatible ipV6 address + + * $rv = isNewIPv4($bits128); + This function return true if the IPv6 128 bit string is of the form + + ::ffff::d.d.d.d + + * $rv = isAnyIPv4($bits128); + This function return true if the IPv6 bit string is of the form + + ::d.d.d.d or ::ffff::d.d.d.d + + * $dotquad or $hex_text = inet_n2dx($ipv6naddr); + This function does the right thing and returns the text for either a + dot-quad IPv4 or a hex notation IPv6 address. + + input: 128 bit IPv6 string + returns: ddd.ddd.ddd.ddd + or x:x:x:x:x:x:x:x + + * $dotquad or $dec_text = inet_n2ad($ipv6naddr); + This function does the right thing and returns the text for either a + dot-quad IPv4 or a hex::decimal notation IPv6 address. + + input: 128 bit IPv6 string + returns: ddd.ddd.ddd.ddd + or x:x:x:x:x:x:ddd.ddd.ddd.dd + + * $netaddr = inet_pton($AF_family,$hex_text); + This function takes an IP address in IPv4 or IPv6 text format and + converts it into binary format. The type of IP address conversion is + controlled by the FAMILY argument. + + * $hex_text = inet_ntop($AF_family,$netaddr); + This function takes and IP address in binary format and converts it + into text format. The type of IP address conversion is controlled by + the FAMILY argument. + + NOTE: inet_ntop ALWAYS returns lowercase characters. + + * $hex_text = packzeros($hex_text); + This function optimizes and rfc 1884 IPv6 hex address to reduce the + number of long strings of zero bits as specified in rfc 1884, 2.2 + (2) by substituting :: for the first occurence of the longest string + of zeros in the address. + + * $ipv6naddr = ipv4to6($netaddr); + Convert an ipv4 network address into an IPv6 network address. + + input: 32 bit network address + returns: 128 bit network address + + * $ipv6naddr = mask4to6($netaddr); + Convert an ipv4 network address/mask into an ipv6 network mask. + + input: 32 bit network/mask address + returns: 128 bit network/mask address + + NOTE: returns the high 96 bits as one's + + * $ipv6naddr = ipanyto6($netaddr); + Similar to ipv4to6 except that this function takes either an IPv4 or + IPv6 input and always returns a 128 bit IPv6 network address. + + input: 32 or 128 bit network address + returns: 128 bit network address + + * $ipv6naddr = maskanyto6($netaddr); + Similar to mask4to6 except that this function takes either an IPv4 + or IPv6 netmask and always returns a 128 bit IPv6 netmask. + + input: 32 or 128 bit network mask + returns: 128 bit network mask + + * $netaddr = ipv6to4($pv6naddr); + Truncate the upper 96 bits of a 128 bit address and return the lower + 32 bits. Returns an IPv4 address as returned by inet_aton. + + input: 128 bit network address + returns: 32 bit inet_aton network address + + * $bitsXn = shiftleft($bits128,$n); + input: 128 bit string variable, + number of shifts [optional] + returns: bits X n shifts + + NOTE: a single shift is performed + if $n is not specified + + * addconst($ipv6naddr,$signed_32con); + Add a signed constant to a 128 bit string variable. + + input: 128 bit IPv6 string, + signed 32 bit integer + returns: scalar carry + array (carry, result) + + * add128($ipv6naddr1,$ipv6naddr2); + Add two 128 bit string variables. + + input: 128 bit string var1, + 128 bit string var2 + returns: scalar carry + array (carry, result) + + * sub128($ipv6naddr1,$ipv6naddr2); + Subtract two 128 bit string variables. + + input: 128 bit string var1, + 128 bit string var2 + returns: scalar carry + array (carry, result) + + Note: The carry from this operation is the result of adding the + one's complement of ARG2 +1 to the ARG1. It is logically NOT borrow. + + i.e. if ARG1 >= ARG2 then carry = 1 + or if ARG1 < ARG2 then carry = 0 + + * ($spurious,$cidr) = notcontiguous($mask128); + This function counts the bit positions remaining in the mask when + the rightmost '0's are removed. + + input: 128 bit netmask + returns true if there are spurious + zero bits remaining in the + mask, false if the mask is + contiguous one's, + 128 bit cidr number + + * $bcdtext = bin2bcd($bits128); + Convert a 128 bit binary string into binary coded decimal text + digits. + + input: 128 bit string variable + returns: string of bcd text digits + + * $bits128 = bcd2bin($bcdtxt); + Convert a bcd text string to 128 bit string variable + + input: string of bcd text digits + returns: 128 bit string variable + + * $modetext = mode; + Returns the operating mode of this module. + + input: none + returns: "Pure Perl" + or "CC XS" + + * ($name,$aliases,$addrtype,$length,@addrs)=naip_gethostbyname(NAME); + Replacement for Perl's gethostbyname if Socket6 is available + + In ARRAY context, returns a list of five elements, the hostname or + NAME, a space separated list of C_NAMES, AF family, length of the + address structure, and an array of one or more netaddr's + + In SCALAR context, returns the first netaddr. + + This function ALWAYS returns an IPv6 address, even on IPv4 only + systems. IPv4 addresses are mapped into IPv6 space in the form: + + ::FFFF:FFFF:d.d.d.d + + This is NOT the expected result from Perl's gethostbyname2. It is + instead equivalent to: + + On an IPv4 only system: + $ipv6naddr = ipv4to6 scalar ( gethostbyname( name )); + + On a system with Socket6 and a working gethostbyname2: + $ipv6naddr = gethostbyname2( name, AF_INET6 ); + and if that fails, the IPv4 conversion above. + + For a gethostbyname2 emulator that behave like Socket6, see: the + Net::DNS::Dig manpage + + * $trueif = havegethostbyname2(); + This function returns TRUE if Socket6 has a functioning + gethostbyname2, otherwise it returns FALSE. See the comments above + about the behavior of naip_gethostbyname. + + * NetAddr::IP::Util::lower(); + Return IPv6 strings in lowercase. + + * NetAddr::IP::Util::upper(); + Return IPv6 strings in uppercase. This is the default. + +EXAMPLES + # convert any textual IP address into a 128 bit vector + # + sub text2vec { + my($anyIP,$anyMask) = @_; + + # not IPv4 bit mask + my $notiv4 = ipv6_aton('FFFF:FFFF:FFFF:FFFF:FFFF:FFFF::'); + + my $vecip = inet_any2n($anyIP); + my $mask = inet_any2n($anyMask); + + # extend mask bits for IPv4 + my $bits = 128; # default + unless (hasbits($mask & $notiv4)) { + $mask |= $notiv4; + $bits = 32; + } + return ($vecip, $mask, $bits); + } + + ... alternate implementation, a little faster + + sub text2vec { + my($anyIP,$anyMask) = @_; + + # not IPv4 bit mask + my $notiv4 = ipv6_aton('FFFF:FFFF:FFFF:FFFF:FFFF:FFFF::'); + + my $vecip = inet_any2n($anyIP); + my $mask = inet_any2n($anyMask); + + # extend mask bits for IPv4 + my $bits = 128; # default + if (isIPv4($mask)) { + $mask |= $notiv4; + $bits = 32; + } + return ($vecip, $mask, $bits); + } + + ... elsewhere + $nip = { + addr => $vecip, + mask => $mask, + bits => $bits, + }; + + # return network and broadcast addresses from IP and Mask + # + sub netbroad { + my($nip) = shift; + my $notmask = ~ $nip->{mask}; + my $bcast = $nip->{addr} | $notmask; + my $network = $nip->{addr} & $nip->{mask}; + return ($network, $broadcast); + } + + # check if address is within a network + # + sub within { + my($nip,$net) = @_; + my $addr = $nip->{addr} + my($nw,$bc) = netbroad($net); + # arg1 >= arg2, sub128 returns true + return (sub128($addr,$nw) && sub128($bc,$addr)) + ? 1 : 0; + } + + # truely hard way to do $ip++ + # add a constant, wrapping at netblock boundaries + # to subtract the constant, negate it before calling + # 'addwrap' since 'addconst' will extend the sign bits + # + sub addwrap { + my($nip,$const) = @_; + my $addr = $nip->{addr}; + my $mask = $nip->{mask}; + my $bits = $nip->{bits}; + my $notmask = ~ $mask; + my $hibits = $addr & $mask; + $addr = addconst($addr,$const); + my $wraponly = $addr & $notmask; + my $newip = { + addr => $hibits | $wraponly, + mask => $mask, + bits => $bits, + }; + # bless $newip as appropriate + return $newip; + } + + # something more useful + # increment a /24 net to the NEXT net at the boundry + + my $nextnet = 256; # for /24 + LOOP: + while (...continuing) { + your code.... + ... + my $lastip = $ip-copy(); + $ip++; + if ($ip < $lastip) { # host part wrapped? + # discard carry + (undef, $ip->{addr} = addconst($ip->{addr}, $nextnet); + } + next LOOP; + } + +EXPORT_OK + inet_aton + inet_ntoa + ipv6_aton + ipv6_ntoa + ipv6_n2x + ipv6_n2d + inet_any2n + hasbits + isIPv4 + isNewIPv4 + isAnyIPv4 + inet_n2dx + inet_n2ad + inet_pton + inet_ntop + inet_4map6 + ipv4to6 + mask4to6 + ipanyto6 + maskanyto6 + ipv6to4 + packzeros + shiftleft + addconst + add128 + sub128 + notcontiguous + bin2bcd + bcd2bin + mode + naip_gethostbyname + havegethostbyname2 + +AUTHOR + Michael Robinton + +COPYRIGHT + Copyright 2003 - 2014, Michael Robinton + + All rights reserved. + + This program is free software; you can redistribute it and/or modify it + under the terms of either: + + a) the GNU General Public License as published by the Free + Software Foundation; either version 2, or (at your option) any + later version, or + + b) the "Artistic License" which comes with this distribution. + + 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 either the GNU + General Public License or the Artistic License for more details. + + You should have received a copy of the Artistic License with this + distribution, in the file named "Artistic". If not, I'll be glad to + provide one. + + You should also have received a copy of the GNU General Public License + along with this program in the file named "Copying". If not, write to + the + + Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor + Boston, MA 02110-1301 USA. + + or visit their web page on the internet at: + + http://www.gnu.org/copyleft/gpl.html. + +AUTHOR + Michael Robinton + +SEE ALSO + NetAddr::IP(3), NetAddr::IP::Lite(3), NetAddr::IP::InetBase(3) + diff --git a/Lite/Util/Util.pm b/Lite/Util/Util.pm new file mode 100644 index 0000000..51db1e9 --- /dev/null +++ b/Lite/Util/Util.pm @@ -0,0 +1,968 @@ +#!/usr/bin/perl +package NetAddr::IP::Util; + +use strict; +#use diagnostics; +#use lib qw(blib/lib); + +use vars qw($VERSION @EXPORT_OK @ISA %EXPORT_TAGS $Mode); +use AutoLoader qw(AUTOLOAD); +use NetAddr::IP::Util_IS; +use NetAddr::IP::InetBase qw( + :upper + :all +); + +*NetAddr::IP::Util::upper = \&NetAddr::IP::InetBase::upper; +*NetAddr::IP::Util::lower = \&NetAddr::IP::InetBase::lower; + +require DynaLoader; +require Exporter; + +@ISA = qw(Exporter DynaLoader); + +$VERSION = do { my @r = (q$Revision: 1.53 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; + +@EXPORT_OK = qw( + inet_aton + inet_ntoa + ipv6_aton + ipv6_ntoa + ipv6_n2x + ipv6_n2d + inet_any2n + hasbits + isIPv4 + isNewIPv4 + isAnyIPv4 + inet_n2dx + inet_n2ad + inet_pton + inet_ntop + inet_4map6 + shiftleft + addconst + add128 + sub128 + notcontiguous + bin2bcd + bcd2bin + mode + ipv4to6 + mask4to6 + ipanyto6 + maskanyto6 + ipv6to4 + bin2bcdn + bcdn2txt + bcdn2bin + simple_pack + comp128 + packzeros + AF_INET + AF_INET6 + naip_gethostbyname + havegethostbyname2 +); + +%EXPORT_TAGS = ( + all => [@EXPORT_OK], + inet => [qw( + inet_aton + inet_ntoa + ipv6_aton + ipv6_ntoa + ipv6_n2x + ipv6_n2d + inet_any2n + inet_n2dx + inet_n2ad + inet_pton + inet_ntop + inet_4map6 + ipv4to6 + mask4to6 + ipanyto6 + maskanyto6 + ipv6to4 + packzeros + naip_gethostbyname + )], + math => [qw( + shiftleft + hasbits + isIPv4 + isNewIPv4 + isAnyIPv4 + addconst + add128 + sub128 + notcontiguous + bin2bcd + bcd2bin + )], + ipv4 => [qw( + inet_aton + inet_ntoa + )], + ipv6 => [qw( + ipv6_aton + ipv6_ntoa + ipv6_n2x + ipv6_n2d + inet_any2n + inet_n2dx + inet_n2ad + inet_pton + inet_ntop + inet_4map6 + ipv4to6 + mask4to6 + ipanyto6 + maskanyto6 + ipv6to4 + packzeros + naip_gethostbyname + )], +); + +if (NetAddr::IP::Util_IS->not_pure) { + eval { ## attempt to load 'C' version of utilities + bootstrap NetAddr::IP::Util $VERSION; + }; +} +if (NetAddr::IP::Util_IS->pure || $@) { ## load the pure perl version if 'C' lib missing + require NetAddr::IP::UtilPP; + import NetAddr::IP::UtilPP qw( :all ); +# require Socket; +# import Socket qw(inet_ntoa); +# *yinet_aton = \&Socket::inet_aton; + $Mode = 'Pure Perl'; +} +else { + $Mode = 'CC XS'; +} + +# if Socket lib is broken in some way, check for overange values +# +#my $overange = yinet_aton('256.1') ? 1:0; +#my $overange = gethostbyname('256.1') ? 1:0; + +sub mode() { $Mode }; + +my $_newV4compat = pack('N4',0,0,0xffff,0); + +sub inet_4map6 { + my $naddr = shift; + if (length($naddr) == 4) { + $naddr = ipv4to6($naddr); + } + elsif (length($naddr) == 16) { + ; # is OK + return undef unless isAnyIPv4($naddr); + } else { + return undef; + } + $naddr |= $_newV4compat; + return $naddr; +} + +sub DESTROY {}; + +my $havegethostbyname2 = 0; + +my $mygethostbyname; + +my $_Sock6ok = 1; # for testing gethostbyname + +sub havegethostbyname2 { + return $_Sock6ok + ? $havegethostbyname2 + : 0; +} + +sub import { + if (grep { $_ eq ':noSock6' } @_) { + $_Sock6ok = 0; + @_ = grep { $_ ne ':noSock6' } @_; + } + NetAddr::IP::Util->export_to_level(1,@_); +} + +package NetAddr::IP::UtilPolluted; + +# Socket pollutes the name space with all of its symbols. Since +# we don't want them all, confine them to this name space. + +use strict; +use Socket; + +my $_v4zero = pack('L',0); +my $_zero = pack('L4',0,0,0,0); + +# invoke replacement subroutine for Perl's "gethostbyname" +# if Socket6 is available. +# +# NOTE: in certain BSD implementations, Perl's gethostbyname is broken +# we will use our own InetBase::inet_aton instead + +sub _end_gethostbyname { +# my ($name,$aliases,$addrtype,$length,@addrs) = @_; + my @rv = @_; +# first ip address = rv[4] + my $tip = $rv[4]; + unless ($tip && $tip ne $_v4zero && $tip ne $_zero) { + @rv = (); + } +# length = rv[3] + elsif ($rv[3] && $rv[3] == 4) { + foreach (4..$#rv) { + $rv[$_] = NetAddr::IP::Util::inet_4map6(NetAddr::IP::Util::ipv4to6($rv[$_])); + } + $rv[3] = 16; # unconditionally set length to 16 + } + elsif ($rv[3] == 16) { + ; # is ok + } else { + @rv = (); + } + return @rv; +} + +unless ( eval { require Socket6 }) { + $mygethostbyname = sub { +# SEE NOTE above about broken BSD + my @tip = gethostbyname(NetAddr::IP::InetBase::fillIPv4($_[0])); + return &_end_gethostbyname(@tip); + }; +} else { + import Socket6 qw( gethostbyname2 getipnodebyname ); + my $try = eval { my @try = gethostbyname2('127.0.0.1',NetAddr::IP::Util::AF_INET()); $try[4] }; + if (! $@ && $try && $try eq INADDR_LOOPBACK()) { + *_ghbn2 = \&Socket6::gethostbyname2; + $havegethostbyname2 = 1; + } else { + *_ghbn2 = sub { return () }; # use failure branch below + } + + $mygethostbyname = sub { + my @tip; + unless ($_Sock6ok && (@tip = _ghbn2($_[0],NetAddr::IP::Util::AF_INET6())) && @tip > 1) { +# SEE NOTE above about broken BSD + @tip = gethostbyname(NetAddr::IP::InetBase::fillIPv4($_[0])); + } + return &_end_gethostbyname(@tip); + }; +} + +package NetAddr::IP::Util; + +sub naip_gethostbyname { +# turn off complaint from Socket6 about missing numeric argument + undef local $^W; + my @rv = &$mygethostbyname($_[0]); + return wantarray + ? @rv + : $rv[4]; +} + +1; + +__END__ + +=head1 NAME + +NetAddr::IP::Util -- IPv4/6 and 128 bit number utilities + +=head1 SYNOPSIS + + use NetAddr::IP::Util qw( + inet_aton + inet_ntoa + ipv6_aton + ipv6_ntoa + ipv6_n2x + ipv6_n2d + inet_any2n + hasbits + isIPv4 + isNewIPv4 + isAnyIPv4 + inet_n2dx + inet_n2ad + inet_pton + inet_ntop + inet_4map6 + ipv4to6 + mask4to6 + ipanyto6 + maskanyto6 + ipv6to4 + packzeros + shiftleft + addconst + add128 + sub128 + notcontiguous + bin2bcd + bcd2bin + mode + AF_INET + AF_INET6 + naip_gethostbyname + ); + + use NetAddr::IP::Util qw(:all :inet :ipv4 :ipv6 :math) + + :inet => inet_aton, inet_ntoa, ipv6_aton + ipv6_ntoa, ipv6_n2x, ipv6_n2d, + inet_any2n, inet_n2dx, inet_n2ad, + inet_pton, inet_ntop, inet_4map6, + ipv4to6, mask4to6, ipanyto6, packzeros + maskanyto6, ipv6to4, naip_gethostbyname + + :ipv4 => inet_aton, inet_ntoa + + :ipv6 => ipv6_aton, ipv6_ntoa, ipv6_n2x, + ipv6_n2d, inet_any2n, inet_n2dx, + inet_n2ad, inet_pton, inet_ntop, + inet_4map6, ipv4to6, mask4to6, + ipanyto6, maskanyto6, ipv6to4, + packzeros, naip_gethostbyname + + :math => hasbits, isIPv4, isNewIPv4, isAnyIPv4, + addconst, add128, sub128, notcontiguous, + bin2bcd, bcd2bin, shiftleft + + $dotquad = inet_ntoa($netaddr); + $netaddr = inet_aton($dotquad); + $ipv6naddr = ipv6_aton($ipv6_text); + $ipv6_text = ipvt_ntoa($ipv6naddr); + $hex_text = ipv6_n2x($ipv6naddr); + $dec_text = ipv6_n2d($ipv6naddr); + $hex_text = packzeros($hex_text); + $ipv6naddr = inet_any2n($dotquad or $ipv6_text); + $ipv6naddr = inet_4map6($netaddr or $ipv6naddr); + $rv = hasbits($bits128); + $rv = isIPv4($bits128); + $rv = isNewIPv4($bits128); + $rv = isAnyIPv4($bits128); + $dotquad or $hex_text = inet_n2dx($ipv6naddr); + $dotquad or $dec_text = inet_n2ad($ipv6naddr); + $netaddr = inet_pton($AF_family,$hex_text); + $hex_text = inet_ntop($AF_family,$netaddr); + $ipv6naddr = ipv4to6($netaddr); + $ipv6naddr = mask4to6($netaddr); + $ipv6naddr = ipanyto6($netaddr); + $ipv6naddr = maskanyto6($netaddr); + $netaddr = ipv6to4($pv6naddr); + $bitsX2 = shiftleft($bits128,$n); + $carry = addconst($ipv6naddr,$signed_32con); + ($carry,$ipv6naddr)=addconst($ipv6naddr,$signed_32con); + $carry = add128($ipv6naddr1,$ipv6naddr2); + ($carry,$ipv6naddr)=add128($ipv6naddr1,$ipv6naddr2); + $carry = sub128($ipv6naddr1,$ipv6naddr2); + ($carry,$ipv6naddr)=sub128($ipv6naddr1,$ipv6naddr2); + ($spurious,$cidr) = notcontiguous($mask128); + $bcdtext = bin2bcd($bits128); + $bits128 = bcd2bin($bcdtxt); + $modetext = mode; + ($name,$aliases,$addrtype,$length,@addrs)=naip_gethostbyname(NAME); + $trueif = havegethostbyname2(); + + NetAddr::IP::Util::lower(); + NetAddr::IP::Util::upper(); + +=head1 INSTALLATION + +Un-tar the distribution in an appropriate directory and type: + + perl Makefile.PL + make + make test + make install + +B installs by default with its primary functions compiled +using Perl's XS extensions to build a 'C' library. If you do not have a 'C' +complier available or would like the slower Pure Perl version for some other +reason, then type: + + perl Makefile.PL -noxs + make + make test + make install + +=head1 DESCRIPTION + +B provides a suite of tools for manipulating and +converting IPv4 and IPv6 addresses into 128 bit string context and back to +text. The strings can be manipulated with Perl's logical operators: + + and & + or | + xor ^ + ~ compliment + +in the same manner as 'vec' strings. + +The IPv6 functions support all rfc1884 formats. + + i.e. x:x:x:x:x:x:x:x:x + x:x:x:x:x:x:x:d.d.d.d + ::x:x:x + ::x:d.d.d.d + and so on... + +=over 4 + +=item * $dotquad = inet_ntoa($netaddr); + +Convert a packed IPv4 network address to a dot-quad IP address. + + input: packed network address + returns: IP address i.e. 10.4.12.123 + +=item * $netaddr = inet_aton($dotquad); + +Convert a dot-quad IP address into an IPv4 packed network address. + + input: IP address i.e. 192.5.16.32 + returns: packed network address + +=item * $ipv6addr = ipv6_aton($ipv6_text); + +Takes an IPv6 address of the form described in rfc1884 +and returns a 128 bit binary RDATA string. + + input: ipv6 text + returns: 128 bit RDATA string + +=item * $ipv6_text = ipv6_ntoa($ipv6naddr); + +Convert a 128 bit binary IPv6 address to compressed rfc 1884 +text representation. + + input: 128 bit RDATA string + returns: ipv6 text + +=item * $hex_text = ipv6_n2x($ipv6addr); + +Takes an IPv6 RDATA string and returns an 8 segment IPv6 hex address + + input: 128 bit RDATA string + returns: x:x:x:x:x:x:x:x + +=item * $dec_text = ipv6_n2d($ipv6addr); + +Takes an IPv6 RDATA string and returns a mixed hex - decimal IPv6 address +with the 6 uppermost chunks in hex and the lower 32 bits in dot-quad +representation. + + input: 128 bit RDATA string + returns: x:x:x:x:x:x:d.d.d.d + +=item * $ipv6naddr = inet_any2n($dotquad or $ipv6_text); + +This function converts a text IPv4 or IPv6 address in text format in any +standard notation into a 128 bit IPv6 string address. It prefixes any +dot-quad address (if found) with '::' and passes it to B. + + input: dot-quad or rfc1844 address + returns: 128 bit IPv6 string + +=item * $rv = hasbits($bits128); + +This function returns true if there are one's present in the 128 bit string +and false if all the bits are zero. + + i.e. if (hasbits($bits128)) { + &do_something; + } + + or if (hasbits($bits128 & $mask128) { + &do_something; + } + +This allows the implementation of logical functions of the form of: + + if ($bits128 & $mask128) { + ... + + input: 128 bit IPv6 string + returns: true if any bits are present + +=item * $ipv6naddr = inet_4map6($netaddr or $ipv6naddr + +This function returns an ipV6 network address with the first 80 bits +set to zero and the next 16 bits set to one, while the last 32 bits +are filled with the ipV4 address. + + input: ipV4 netaddr + or ipV6 netaddr + returns: ipV6 netaddr + + returns: undef on error + +An ipV6 network address must be in one of the two compatible ipV4 +mapped address spaces. i.e. + + ::ffff::d.d.d.d or ::d.d.d.d + +=item * $rv = isIPv4($bits128); + +This function returns true if there are no on bits present in the IPv6 +portion of the 128 bit string and false otherwise. + + i.e. the address must be of the form - ::d.d.d.d + +Note: this is an old and deprecated ipV4 compatible ipV6 address + +=item * $rv = isNewIPv4($bits128); + +This function return true if the IPv6 128 bit string is of the form + + ::ffff::d.d.d.d + +=item * $rv = isAnyIPv4($bits128); + +This function return true if the IPv6 bit string is of the form + + ::d.d.d.d or ::ffff::d.d.d.d + +=item * $dotquad or $hex_text = inet_n2dx($ipv6naddr); + +This function B and returns the text for either a +dot-quad IPv4 or a hex notation IPv6 address. + + input: 128 bit IPv6 string + returns: ddd.ddd.ddd.ddd + or x:x:x:x:x:x:x:x + +=item * $dotquad or $dec_text = inet_n2ad($ipv6naddr); + +This function B and returns the text for either a +dot-quad IPv4 or a hex::decimal notation IPv6 address. + + input: 128 bit IPv6 string + returns: ddd.ddd.ddd.ddd + or x:x:x:x:x:x:ddd.ddd.ddd.dd + +=item * $netaddr = inet_pton($AF_family,$hex_text); + +This function takes an IP address in IPv4 or IPv6 text format and converts it into +binary format. The type of IP address conversion is controlled by the FAMILY +argument. + +=item * $hex_text = inet_ntop($AF_family,$netaddr); + +This function takes and IP address in binary format and converts it into +text format. The type of IP address conversion is controlled by the FAMILY +argument. + +NOTE: inet_ntop ALWAYS returns lowercase characters. + +=item * $hex_text = packzeros($hex_text); + +This function optimizes and rfc 1884 IPv6 hex address to reduce the number of +long strings of zero bits as specified in rfc 1884, 2.2 (2) by substituting +B<::> for the first occurence of the longest string of zeros in the address. + +=item * $ipv6naddr = ipv4to6($netaddr); + +Convert an ipv4 network address into an IPv6 network address. + + input: 32 bit network address + returns: 128 bit network address + +=item * $ipv6naddr = mask4to6($netaddr); + +Convert an ipv4 network address/mask into an ipv6 network mask. + + input: 32 bit network/mask address + returns: 128 bit network/mask address + +NOTE: returns the high 96 bits as one's + +=item * $ipv6naddr = ipanyto6($netaddr); + +Similar to ipv4to6 except that this function takes either an IPv4 or IPv6 +input and always returns a 128 bit IPv6 network address. + + input: 32 or 128 bit network address + returns: 128 bit network address + +=item * $ipv6naddr = maskanyto6($netaddr); + +Similar to mask4to6 except that this function takes either an IPv4 or IPv6 +netmask and always returns a 128 bit IPv6 netmask. + + input: 32 or 128 bit network mask + returns: 128 bit network mask + +=item * $netaddr = ipv6to4($pv6naddr); + +Truncate the upper 96 bits of a 128 bit address and return the lower +32 bits. Returns an IPv4 address as returned by inet_aton. + + input: 128 bit network address + returns: 32 bit inet_aton network address + +=item * $bitsXn = shiftleft($bits128,$n); + + input: 128 bit string variable, + number of shifts [optional] + returns: bits X n shifts + + NOTE: a single shift is performed + if $n is not specified + +=item * addconst($ipv6naddr,$signed_32con); + +Add a signed constant to a 128 bit string variable. + + input: 128 bit IPv6 string, + signed 32 bit integer + returns: scalar carry + array (carry, result) + +=item * add128($ipv6naddr1,$ipv6naddr2); + +Add two 128 bit string variables. + + input: 128 bit string var1, + 128 bit string var2 + returns: scalar carry + array (carry, result) + +=item * sub128($ipv6naddr1,$ipv6naddr2); + +Subtract two 128 bit string variables. + + input: 128 bit string var1, + 128 bit string var2 + returns: scalar carry + array (carry, result) + +Note: The carry from this operation is the result of adding the one's +complement of ARG2 +1 to the ARG1. It is logically +B. + + i.e. if ARG1 >= ARG2 then carry = 1 + or if ARG1 < ARG2 then carry = 0 + + +=item * ($spurious,$cidr) = notcontiguous($mask128); + +This function counts the bit positions remaining in the mask when the +rightmost '0's are removed. + + input: 128 bit netmask + returns true if there are spurious + zero bits remaining in the + mask, false if the mask is + contiguous one's, + 128 bit cidr number + +=item * $bcdtext = bin2bcd($bits128); + +Convert a 128 bit binary string into binary coded decimal text digits. + + input: 128 bit string variable + returns: string of bcd text digits + +=item * $bits128 = bcd2bin($bcdtxt); + +Convert a bcd text string to 128 bit string variable + + input: string of bcd text digits + returns: 128 bit string variable + +=cut + +#=item * $onescomp=NetAddr::IP::Util::comp128($ipv6addr); +# +#This function is not exported because it is more efficient to use perl " ~ " +#on the bit string directly. This interface to the B routine is published for +#module testing purposes because it is used internally in the B routine. The +#function is very fast, but calling if from perl directly is very slow. It is almost +#33% faster to use B than to do a 1's comp with perl and then call +#B. +# +#=item * $bcdpacked = NetAddr::IP::Util::bin2bcdn($bits128); +# +#Convert a 128 bit binary string into binary coded decimal digits. +#This function is not exported. +# +# input: 128 bit string variable +# returns: string of packed decimal digits +# +# i.e. text = unpack("H*", $bcd); +# +#=item * $bcdtext = NetAddr::IP::Util::bcdn2txt($bcdpacked); +# +#Convert a packed bcd string into text digits, suppress the leading zeros. +#This function is not exported. +# +# input: string of packed decimal digits +# returns: hexadecimal digits +# +#Similar to unpack("H*", $bcd); +# +#=item * $bcdpacked = NetAddr::IP::Util::simple_pack($bcdtext); +# +#Convert a numeric string into a packed bcd string, left fill with zeros +# +# input: string of decimal digits +# returns: string of packed decimal digits +# +#Similar to pack("H*", $bcdtext); + +=item * $modetext = mode; + +Returns the operating mode of this module. + + input: none + returns: "Pure Perl" + or "CC XS" + +=item * ($name,$aliases,$addrtype,$length,@addrs)=naip_gethostbyname(NAME); + +Replacement for Perl's gethostbyname if Socket6 is available + +In ARRAY context, returns a list of five elements, the hostname or NAME, +a space separated list of C_NAMES, AF family, length of the address +structure, and an array of one or more netaddr's + +In SCALAR context, returns the first netaddr. + +This function ALWAYS returns an IPv6 address, even on IPv4 only systems. +IPv4 addresses are mapped into IPv6 space in the form: + + ::FFFF:FFFF:d.d.d.d + +This is NOT the expected result from Perl's gethostbyname2. It is instead equivalent to: + + On an IPv4 only system: + $ipv6naddr = ipv4to6 scalar ( gethostbyname( name )); + + On a system with Socket6 and a working gethostbyname2: + $ipv6naddr = gethostbyname2( name, AF_INET6 ); + and if that fails, the IPv4 conversion above. + +For a gethostbyname2 emulator that behave like Socket6, see: +L + +=item * $trueif = havegethostbyname2(); + +This function returns TRUE if Socket6 has a functioning B, +otherwise it returns FALSE. See the comments above about the behavior of +B. + +=item * NetAddr::IP::Util::lower(); + +Return IPv6 strings in lowercase. + +=item * NetAddr::IP::Util::upper(); + +Return IPv6 strings in uppercase. This is the default. + +=back + +=head1 EXAMPLES + + + # convert any textual IP address into a 128 bit vector + # + sub text2vec { + my($anyIP,$anyMask) = @_; + + # not IPv4 bit mask + my $notiv4 = ipv6_aton('FFFF:FFFF:FFFF:FFFF:FFFF:FFFF::'); + + my $vecip = inet_any2n($anyIP); + my $mask = inet_any2n($anyMask); + + # extend mask bits for IPv4 + my $bits = 128; # default + unless (hasbits($mask & $notiv4)) { + $mask |= $notiv4; + $bits = 32; + } + return ($vecip, $mask, $bits); + } + + ... alternate implementation, a little faster + + sub text2vec { + my($anyIP,$anyMask) = @_; + + # not IPv4 bit mask + my $notiv4 = ipv6_aton('FFFF:FFFF:FFFF:FFFF:FFFF:FFFF::'); + + my $vecip = inet_any2n($anyIP); + my $mask = inet_any2n($anyMask); + + # extend mask bits for IPv4 + my $bits = 128; # default + if (isIPv4($mask)) { + $mask |= $notiv4; + $bits = 32; + } + return ($vecip, $mask, $bits); + } + + + ... elsewhere + $nip = { + addr => $vecip, + mask => $mask, + bits => $bits, + }; + + # return network and broadcast addresses from IP and Mask + # + sub netbroad { + my($nip) = shift; + my $notmask = ~ $nip->{mask}; + my $bcast = $nip->{addr} | $notmask; + my $network = $nip->{addr} & $nip->{mask}; + return ($network, $broadcast); + } + + # check if address is within a network + # + sub within { + my($nip,$net) = @_; + my $addr = $nip->{addr} + my($nw,$bc) = netbroad($net); + # arg1 >= arg2, sub128 returns true + return (sub128($addr,$nw) && sub128($bc,$addr)) + ? 1 : 0; + } + + # truely hard way to do $ip++ + # add a constant, wrapping at netblock boundaries + # to subtract the constant, negate it before calling + # 'addwrap' since 'addconst' will extend the sign bits + # + sub addwrap { + my($nip,$const) = @_; + my $addr = $nip->{addr}; + my $mask = $nip->{mask}; + my $bits = $nip->{bits}; + my $notmask = ~ $mask; + my $hibits = $addr & $mask; + $addr = addconst($addr,$const); + my $wraponly = $addr & $notmask; + my $newip = { + addr => $hibits | $wraponly, + mask => $mask, + bits => $bits, + }; + # bless $newip as appropriate + return $newip; + } + + # something more useful + # increment a /24 net to the NEXT net at the boundry + + my $nextnet = 256; # for /24 + LOOP: + while (...continuing) { + your code.... + ... + my $lastip = $ip-copy(); + $ip++; + if ($ip < $lastip) { # host part wrapped? + # discard carry + (undef, $ip->{addr} = addconst($ip->{addr}, $nextnet); + } + next LOOP; + } + + +=head1 EXPORT_OK + + inet_aton + inet_ntoa + ipv6_aton + ipv6_ntoa + ipv6_n2x + ipv6_n2d + inet_any2n + hasbits + isIPv4 + isNewIPv4 + isAnyIPv4 + inet_n2dx + inet_n2ad + inet_pton + inet_ntop + inet_4map6 + ipv4to6 + mask4to6 + ipanyto6 + maskanyto6 + ipv6to4 + packzeros + shiftleft + addconst + add128 + sub128 + notcontiguous + bin2bcd + bcd2bin + mode + naip_gethostbyname + havegethostbyname2 + +=head1 AUTHOR + +Michael Robinton + +=head1 COPYRIGHT + +Copyright 2003 - 2014, Michael Robinton Emichael@bizsystems.comE + +All rights reserved. + +This program is free software; you can redistribute it and/or modify +it under the terms of either: + + a) the GNU General Public License as published by the Free + Software Foundation; either version 2, or (at your option) any + later version, or + + b) the "Artistic License" which comes with this distribution. + +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 either +the GNU General Public License or the Artistic License for more details. + +You should have received a copy of the Artistic License with this +distribution, in the file named "Artistic". If not, I'll be glad to provide +one. + +You should also have received a copy of the GNU General Public License +along with this program in the file named "Copying". If not, write to the + + Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor + Boston, MA 02110-1301 USA. + +or visit their web page on the internet at: + + http://www.gnu.org/copyleft/gpl.html. + +=head1 AUTHOR + +Michael Robinton + +=head1 SEE ALSO + +NetAddr::IP(3), NetAddr::IP::Lite(3), NetAddr::IP::InetBase(3) + +=cut + +1; diff --git a/Lite/Util/Util.xs b/Lite/Util/Util.xs new file mode 100644 index 0000000..42de991 --- /dev/null +++ b/Lite/Util/Util.xs @@ -0,0 +1,801 @@ + +/* + * Copyright 2006 - 2012, Michael Robinton + * + * 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., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _CYGWIN +#include +#endif + +#include "EXTERN.h" +#include "perl.h" +#include "XSUB.h" + +/* needed for testing with 'printf' +#include + */ + +#ifdef _CYGWIN +#include +#endif + +#include "localconf.h" + +#ifdef __cplusplus +} +#endif + +/* workaround for OS's without inet_aton */ +/* #include "xs_include/inet_aton.c" removed 10-12-11 */ + +typedef union +{ + u_int32_t u[4]; + unsigned char c[16]; +} n128; + +char * is_ipv6to4 = "ipv6to4", * is_shiftleft = "shiftleft", * is_comp128 = "comp128"; +char * is_sub128 = "sub128", * is_add128 = "add128"; +char * is_hasbits = "hasbits"; +/* , * is_isIPv4 = "isIPv4"; */ +char * is_bcd2bin = "bcd2bin", * is_simple_pack = "simple_pack", * is_bcdn2bin = "bcdn2bin"; +char * is_mask4to6 = "mask4to6", * is_ipv4to6 = "ipv4to6"; +char * is_maskanyto6 = "maskanyto6", * is_ipanyto6 = "ipanyto6"; + +typedef struct bcdstuff +{ /* character array of 40 bytes */ + char txt[21]; /* 20 bytes + string terminator */ + u_int32_t bcd[5]; /* 20 bytes, 40 digits */ +} BCD; + +#define zero ('0' & 0x7f) + +/* useful for debug, prints the 128 bits of 8, 16 bit registers */ +void +printb128(char * b) +{ + int c; + for(c=0;c<16;c++) { + if (b[c] &0x80) + printf("1"); + else + printf("0"); + if (b[c] &0x40) + printf("1"); + else + printf("0"); + if (b[c] &0x20) + printf("1"); + else + printf("0"); + if (b[c] &0x10) + printf("1"); + else + printf("0"); + if (b[c] &0x8) + printf("1"); + else + printf("0"); + if (b[c] &0x4) + printf("1"); + else + printf("0"); + if (b[c] &0x2) + printf("1"); + else + printf("0"); + if (b[c] &0x1) + printf("1"); + else + printf("0"); + if (c == 3 || c == 7 || c == 11) + printf("\n"); + } + printf("\n\n"); +} + +void +extendipv4(void * aa, void * ux) +{ + register u_int32_t * a = ux; + *a++ = 0; + *a++ = 0; + *a++ = 0; + *a = *((u_int32_t *)aa); +} + +void +extendmask4(void * aa, void * ux) +{ + register u_int32_t * a = ux; + *a++ = 0xffffffff; + *a++ = 0xffffffff; + *a++ = 0xffffffff; + *a = *((u_int32_t *)aa); +} + +void +fastcomp128(void * aa) +{ + register u_int32_t * a = aa; + + *a++ ^= 0xffffffff; + *a++ ^= 0xffffffff; + *a++ ^= 0xffffffff; + *a++ ^= 0xffffffff; +} + +/* add two 128 bit numbers + return the carry + */ + +int +adder128(void * aa, void * bb, n128 * ap128, int carry) +{ + int i; + register u_int32_t a, b, r; + + for (i=3; i >= 0; i--) { + a = *((u_int32_t *)aa + i); + b = *((u_int32_t *)bb + i); + r = a + b; + a = 0; /* ripple carry forward */ + if ( r < a || r < b) /* if overflow */ + a = 1; + + b = r + carry; /* carry propagate in */ + if (b < r) /* ripple carry forward */ + carry = 1; /* if overflow */ + else + carry = a; + + *((u_int32_t *)(ap128->u) + i) = b; + } + return carry; +} + +int +addercon(void * aa, u_int32_t * bb, n128 * ap128, int32_t con) +{ + register u_int32_t tmp = 0x80000000; + + if (con & tmp) + tmp = 0xffffffff; + else + tmp = 0; + + bb[0] = tmp; + bb[1] = tmp; + bb[2] = tmp; + bb[3] = (u_int32_t)con; + return adder128(aa,bb,ap128,0); +} + +int +have128(void * bp) +{ + register u_int32_t * p = bp; + + if (*p++ || *p++ || *p++ || *p++) + return 1; + return 0; +} + +int +_isipv4(void * bp) +{ + register u_int32_t * p = bp; + + if (*p++ || *p++ || *p++) + return 0; + return 1; +} + +/* network byte swap and copy */ +void +netswap_copy(void * dest, void * src, int len) +{ + register u_int32_t * d = dest, * s = src; + + for (/* -- */;len>0;len--) { +#ifdef host_is_LITTLE_ENDIAN + *d++ = (((*s & 0xff000000) >> 24) | ((*s & 0x00ff0000) >> 8) | \ + ((*s & 0x0000ff00) << 8) | ((*s & 0x000000ff) << 24)); +#else +# ifdef host_is_BIG_ENDIAN + *d++ = *s; +# else +# error ENDIANness not defined +# endif +#endif + s++; + } +} + +/* do ntohl / htonl changes as necessary for this OS + */ +void +netswap(void * ap, int len) +{ +#ifdef host_is_LITTLE_ENDIAN + register u_int32_t * a = ap; + for (/* -- */;len >0;len--) { + *a = (((*a & 0xff000000) >> 24) | ((*a & 0x00ff0000) >> 8) | \ + ((*a & 0x0000ff00) << 8) | ((*a & 0x000000ff) << 24)); + a++; + } +#endif +} + +/* shift right to purge '0's, + return mask bit count and remainder value, + left fill with ones + */ +unsigned char +_countbits(void *ap) +{ + register u_int32_t * p0 = (u_int32_t *)ap, * p1 = p0 +1, * p2 = p1 +1, * p3 = p2 +1; + unsigned char count = 128; + + fastcomp128(ap); + + do { + if (!(*p3 & 1)) + break; + count--; + *p3 >>= 1; + if (*p2 & 1) + *p3 |= 0x80000000; + *p2 >>= 1; + if (*p1 & 1) + *p2 |= 0x80000000; + *p1 >>= 1; + if (*p0 & 1) + *p1 |= 0x80000000; + *p0 >>= 1; + } while (count > 0); + return count; +} + +/* multiply 128 bit number x 2 + */ +void +_128x2(u_int32_t * ap) +{ + register u_int32_t * p = ap +3, tmpc, carry = 0; + + do { + tmpc = *p & 0x80000000; /* propagate hi bit to next word */ + *p <<= 1; + if (carry) + *p += 1; + carry = tmpc; + } while (p-- > ap); +/* printf("2o %04X:%04X:%04X:%04X\n",*(ap),*(ap +1),*(ap +2),*(ap +3)); */ +} + +/* multiply 128 bit number X10 + */ +void +_128x10(n128 * ap128, n128 * tp128) +{ + register u_int32_t * ap = ap128->u, * tp = tp128->u; + _128x2(ap); /* multiply by two */ + *tp = *ap; /* temp save */ + *(tp +1) = *(ap +1); + *(tp +2) = *(ap +2); + *(tp +3) = *(ap +3); + _128x2(ap); + _128x2(ap); /* times 8 */ + (void) adder128(ap,tp,ap128,0); +/* printf("x %04X:%04X:%04X:%04X\n",*((u_int32_t *)ap),*((u_int32_t *)ap +1),*((u_int32_t *)ap +2),*((u_int32_t *)ap +3)); */ +} + +/* multiply 128 bit number by 10, add bcd digit to result + */ +void +_128x10plusbcd(n128 * ap128, n128 * tp128, char digit) +{ + register u_int32_t * ap = ap128->u, * tp = tp128->u; +/* printf("digit %X + %X = ",digit,*(ap +3)); */ + _128x10(ap128,tp128); + *tp = 0; + *(tp + 1) = 0; + *(tp + 2) = 0; + *(tp + 3) = digit; + (void) adder128(ap,tp,ap128,0); +/* printf("%d %04X:%04X:%04X:%04X\n",digit,*((u_int32_t *)ap),*((u_int32_t *)ap +1),*((u_int32_t *)ap +2),*((u_int32_t *)ap +3)); */ +} + +char +_simple_pack(void * str,int len, BCD * n) +{ + int i = len -1, j=19, lo=1; + register unsigned char c, * bcdn = (unsigned char *)(n->bcd), * sp = (unsigned char *) str; + + if (len > 40) + return '*'; /* error, input string too long */ + + memset (bcdn, 0, 20); + + do { + c = *(sp + i) & 0x7f; + if (c < zero || c > (zero + 9)) + return c; /* error, out of range */ + + if (lo) { /* lo byte ? */ + *(bcdn + j) = c & 0xF; + lo = 0; + } + else { + c <<= 4; + *(bcdn + j) |= c; + lo = 1; /* lo byte next */ + j--; + } + } while (i-- > 0); + return 0; +} + +/* convert a packed bcd string to 128 bit binary string + */ +void +_bcdn2bin(void * bp, n128 * ap128, n128 * cp128, int len) +{ + int i = 0, hasdigits = 0, lo; + register unsigned char c, * cp = (unsigned char *)bp; + + memset(ap128->c, 0, 16); + memset(cp128->c, 0, 16); + + while (i < len ) { + c = *cp++; + for (lo=0;lo<2;lo+=1) { + if (lo) { + if (hasdigits) /* suppress leading zero multiplications */ + _128x10plusbcd(ap128, cp128, c & 0xF); + else { + if (c & 0xF) { + hasdigits = 1; + ap128->u[3] = c & 0xF; + } + } + } + else { + if (hasdigits) /* suppress leading zero multiplications */ + _128x10plusbcd(ap128, cp128, c >> 4); + else { + if (c & 0XF0) { + hasdigits = 1; + ap128->u[3] = c >> 4; + } + } + } + i++; + if (i >= len) + break; + } + } +} + +/* convert a 128 bit number string to a bcd number string + returns the length of the bcd string === 20 + */ +int +_bin2bcd (unsigned char * binary, BCD * n) +{ + register u_int32_t tmp, add3, msk8, bcd8, carry = 0; + u_int32_t word; + unsigned char binmsk = 0; + int c = 0,i, j, p; + + memset (n->bcd, 0, 20); + + for (p=0;p<128;p++) { /* bit pointer */ + if (! binmsk) { + word = *((unsigned char *)binary + c); + binmsk = 0x80; + c++; + } + carry = word & binmsk; /* bit to convert */ + binmsk >>= 1; + for (i=4;i>=0;i--) { + bcd8 = n->bcd[i]; + if (carry | bcd8) { /* if something to do */ + add3 = 3; + msk8 = 8; + + for (j=0;j<8;j++) { /* prep bcd digits for X2 */ + tmp = bcd8 + add3; + if (tmp & msk8) + bcd8 = tmp; + add3 <<= 4; + msk8 <<= 4; + } + tmp = bcd8 & 0x80000000; /* propagated carry */ + bcd8 <<= 1; /* x 2 */ + if (carry) + bcd8 += 1; + n->bcd[i] = bcd8; + carry = tmp; + } + } + } + netswap(n->bcd,5); + return 20; +} + +/* convert a bcd number string to a bcd text string + returns the number of digits + */ +int +_bcd2txt(unsigned char * bcd2p, BCD * n) +{ + register unsigned char bcd, dchar; + int i, j = 0; + + for (i=0;i<20;i++) { + dchar = *(bcd2p + i); + bcd = dchar >> 4; + if (j || bcd) { + n->txt[j] = bcd + zero; + j++; + } + bcd = dchar & 0xF; + if (j || bcd || i == 19) { /* must be at least one digit */ + n->txt[j] = bcd + zero; + j++; + } + } + n->txt[j] = 0; /* string terminator */ + return j; +} + +/* INCLUDE: xs_include/miniSocket.inc removed 10-12-11 */ + + + +MODULE = NetAddr::IP::Util PACKAGE = NetAddr::IP::Util + +PROTOTYPES: ENABLE + +void +comp128(s,...) + SV * s +ALIAS: + NetAddr::IP::Util::ipv6to4 = 2 + NetAddr::IP::Util::shiftleft = 1 +PREINIT: + unsigned char * ap; + char * subname; + u_int32_t wa[4]; + STRLEN len; + int i; +PPCODE: + ap = (unsigned char *) SvPV(s,len); + if (len != 16) { + if (ix == 2) + subname = is_ipv6to4; + else if (ix == 1) + subname = is_shiftleft; + else + subname = is_comp128; + croak("Bad arg length for %s%s, length is %d, should be %d", + "NetAddr::IP::Util::",subname,len *8,128); + } + if (ix == 2) { + XPUSHs(sv_2mortal(newSVpvn((char *)(ap +12),4))); + XSRETURN(1); + } + else if (ix == 1) { + if (items < 2) { + memcpy(wa,ap,16); + } + else if ((i = SvIV(ST(1))) == 0) { + memcpy(wa,ap,16); + } + else if (i < 0 || i > 128) { + croak("Bad arg value for %s, is %d, should be 0 thru 128", + "NetAddr::IP::Util::shiftleft",i); + } + else { + netswap_copy(wa,ap,4); + do { + _128x2(wa); + i--; + } while (i > 0); + netswap(wa,4); + } + } + else { + memcpy(wa,ap,16); + fastcomp128(wa); + } + XPUSHs(sv_2mortal(newSVpvn((char *)wa,16))); + XSRETURN(1); + +void +add128(as,bs) + SV * as + SV * bs +ALIAS: + NetAddr::IP::Util::sub128 = 1 +PREINIT: + unsigned char * ap, *bp; + char * subname; + u_int32_t wa[4], wb[4]; + n128 a128; + STRLEN len; +PPCODE: + ap = (unsigned char *) SvPV(as,len); + if (len != 16) { + Bail: + if (ix == 1) + subname = is_sub128; + else + subname = is_add128; + croak("Bad arg length for %s%s, length is %d, should be %d", + "NetAddr::IP::Util::",subname,len *8,128); + } + + bp = (unsigned char *) SvPV(bs,len); + if (len != 16) { + goto Bail; + } + netswap_copy(wa,ap,4); + netswap_copy(wb,bp,4); + if (ix == 1) { + fastcomp128(wb); + XPUSHs(sv_2mortal(newSViv((I32)adder128(wa,wb,&a128,1)))); + } + else { + XPUSHs(sv_2mortal(newSViv((I32)adder128(wa,wb,&a128,0)))); + } + if (GIMME_V == G_ARRAY) { + netswap(a128.u,4); + XPUSHs(sv_2mortal(newSVpvn((char *)a128.c,16))); + XSRETURN(2); + } + XSRETURN(1); + +void +addconst(s,cnst) + SV * s + I32 cnst +PREINIT: + n128 a128; + unsigned char * ap; + u_int32_t wa[4], wb[4]; + STRLEN len; +PPCODE: + ap = (unsigned char *) SvPV(s,len); + if (len != 16) { + croak("Bad arg length for %s, length is %d, should be %d", + "NetAddr::IP::Util::addconst",len *8,128); + } + netswap_copy(wa,ap,4); + XPUSHs(sv_2mortal(newSViv((I32)addercon(wa,wb,&a128,cnst)))); + if (GIMME_V == G_ARRAY) { + netswap(a128.u,4); + XPUSHs(sv_2mortal(newSVpvn((char *)a128.c,16))); + XSRETURN(2); + } + XSRETURN(1); + + +int +hasbits(s) + SV * s +PREINIT: + unsigned char * bp; + char * subname; + STRLEN len; +CODE: + bp = (unsigned char *) SvPV(s,len); + if (len != 16) { + subname = is_hasbits; + croak("Bad arg length for %s%s, length is %d, should be %d", + "NetAddr::IP::Util::",subname,len *8,128); + } + RETVAL = have128(bp); +OUTPUT: + RETVAL + +void +bin2bcd(s) + SV * s +ALIAS: + NetAddr::IP::Util::bcdn2txt = 2 + NetAddr::IP::Util::bin2bcdn = 1 +PREINIT: + BCD n; + unsigned char * cp; + STRLEN len; +PPCODE: + cp = (unsigned char *) SvPV(s,len); + if (ix == 0) { + if (len != 16) { + croak("Bad arg length for %s, length is %d, should be %d", + "NetAddr::IP::Util::bin2bcd",len *8,128); + } + (void) _bin2bcd(cp,&n); + XPUSHs(sv_2mortal(newSVpvn((char *)n.txt,_bcd2txt((unsigned char *)n.bcd,&n)))); + } + else if (ix == 1) { + if (len != 16) { + croak("Bad arg length for %s, length is %d, should be %d", + "NetAddr::IP::Util::bin2bcdn",len *8,128); + } + XPUSHs(sv_2mortal(newSVpvn((char *)n.bcd,_bin2bcd(cp,&n)))); + } + else { + if (len > 20) { + croak("Bad arg length for %s, length is %d, should %d digits or less", + "NetAddr::IP::Util::bcdn2txt",len *2,40); + } + XPUSHs(sv_2mortal(newSVpvn((char *)n.txt,_bcd2txt(cp,&n)))); + } + XSRETURN(1); + +#* +#* the second argument 'len' is the number of bcd digits for +#* the bcdn2bin conversion. Pack looses track of the number +#* digits so this is needed to do the "right thing". +#* NOTE: that simple_pack always returns 40 digits +#* +void +bcd2bin(s,...) + SV * s +ALIAS: + NetAddr::IP::Util::bcdn2bin = 2 + NetAddr::IP::Util::simple_pack = 1 +PREINIT: + BCD n; + n128 c128, a128; + unsigned char * cp, badc; + char * subname; + STRLEN len; +PPCODE: + cp = (unsigned char *) SvPV(s,len); + if (len > 40) { + if (ix == 0) + subname = is_bcd2bin; + else if (ix ==1) + subname = is_simple_pack; + Badigits: + croak("Bad arg length for %s%s, length is %d, should be %d digits or less", + "NetAddr::IP::Util::",subname,len,40); + } + if (ix == 2) { + if (len > 20) { + len <<= 1; /* times 2 */ + subname = is_bcdn2bin; + goto Badigits; + } + if (items < 2) { + croak("Bad usage, should have %s('packedbcd,length)", + "NetAddr::IP::Util::bcdn2bin"); + } + len = SvIV(ST(1)); + _bcdn2bin(cp,&a128,&c128,(int)len); + netswap(a128.u,4); + XPUSHs(sv_2mortal(newSVpvn((char *)a128.c,16))); + XSRETURN(1); + } + badc = _simple_pack(cp,(int)len, &n); + if (badc) { + if (ix == 1) + subname = is_simple_pack; + else + subname = is_bcd2bin; + croak("Bad char in string for %s%s, character is '%c', allowed are 0-9", + "NetAddr::IP::Util::",subname,badc); + } + if (ix == 0) { + _bcdn2bin((void *)n.bcd,&a128,&c128,40); + netswap(a128.u,4); + XPUSHs(sv_2mortal(newSVpvn((char *)a128.c,16))); + } + else { /* ix == 1 */ + XPUSHs(sv_2mortal(newSVpvn((char *)n.bcd,20))); + } + XSRETURN(1); + +void +notcontiguous(s) + SV * s +PREINIT: + unsigned char * ap, count; + u_int32_t wa[4]; + STRLEN len; +PPCODE: + ap = (unsigned char *) SvPV(s,len); + if (len != 16) { + croak("Bad arg length for %s, length is %d, should be %d", + "NetAddr::IP::Util::countbits",len *8,128); + } + netswap_copy(wa,ap,4); + count = _countbits(wa); + XPUSHs(sv_2mortal(newSViv((I32)have128(wa)))); + if (GIMME_V == G_ARRAY) { + XPUSHs(sv_2mortal(newSViv((I32)count))); + XSRETURN(2); + } + XSRETURN(1); + +void +ipv4to6(s) + SV * s +ALIAS: + NetAddr::IP::Util::mask4to6 = 1 +PREINIT: + unsigned char * ip; + char * subname; + u_int32_t wa[4]; + STRLEN len; +PPCODE: + ip = (unsigned char *) SvPV(s,len); + if (len != 4) { + if (ix == 1) + subname = is_mask4to6; + else + subname = is_ipv4to6; + croak("Bad arg length for %s%s, length is %d, should be 32", + "NetAddr::IP::Util::",subname,len *8); + } + if (ix == 0) + extendipv4(ip, wa); + else + extendmask4(ip, wa); + XPUSHs(sv_2mortal(newSVpvn((char *)wa,16))); + XSRETURN(1); + +void +ipanyto6(s) + SV * s +ALIAS: + NetAddr::IP::Util::maskanyto6 = 1 +PREINIT: + unsigned char * ip; + char * subname; + u_int32_t wa[4]; + STRLEN len; +PPCODE: + ip = (unsigned char *) SvPV(s,len); + if (len == 16) /* if already 128 bits, return input */ + XPUSHs(sv_2mortal(newSVpvn((char *)ip,16))); + else if (len == 4) { + if (ix == 0) + extendipv4(ip, wa); + else + extendmask4(ip, wa); + XPUSHs(sv_2mortal(newSVpvn((char *)wa,16))); + } + else { + if (ix == 1) + subname = is_maskanyto6; + else + subname = is_ipanyto6; + croak("Bad arg length for %s%s, length is %d, should be 32 or 128", + "NetAddr::IP::Util::",subname,len *8); + } + XSRETURN(1); + diff --git a/Lite/Util/config.h.in b/Lite/Util/config.h.in new file mode 100644 index 0000000..3292a42 --- /dev/null +++ b/Lite/Util/config.h.in @@ -0,0 +1,127 @@ +/* config.h.in. Generated from configure.ac by autoheader. */ + +/* Define to 1 if you have the header file. */ +#undef HAVE_ARPA_INET_H + +/* Define to 1 if function 'gethostbyname' is present */ +#undef HAVE_GETHOSTBYNAME + +/* Define to 1 if function 'inet_addr' is present */ +#undef HAVE_INET_ADDR + +/* Define to 1 if function 'inet_aton' is present */ +#undef HAVE_INET_ATON + +/* Define to 1 if function 'inet_pton' is present */ +#undef HAVE_INET_PTON + +/* Define to 1 if you have the header file. */ +#undef HAVE_INTTYPES_H + +/* Define if library library 'nsl' is present */ +#undef HAVE_LIBNSL + +/* Define to 1 if you have the header file. */ +#undef HAVE_MEMORY_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NETDB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_NETINET_IN_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDINT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STDLIB_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRINGS_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_STRING_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_SOCKET_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_STAT_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_SYS_TYPES_H + +/* Define to 1 if you have the header file. */ +#undef HAVE_UNISTD_H + +/* Extra libraries */ +#undef LIBS + +/* Define to the address where bug reports for this package should be sent. */ +#undef PACKAGE_BUGREPORT + +/* Define to the full name of this package. */ +#undef PACKAGE_NAME + +/* Define to the full name and version of this package. */ +#undef PACKAGE_STRING + +/* Define to the one symbol short name of this package. */ +#undef PACKAGE_TARNAME + +/* Define to the version of this package. */ +#undef PACKAGE_VERSION + +/* The size of `uint16_t', as computed by sizeof. */ +#undef SIZEOF_UINT16_T + +/* The size of `uint32_t', as computed by sizeof. */ +#undef SIZEOF_UINT32_T + +/* The size of `uint8_t', as computed by sizeof. */ +#undef SIZEOF_UINT8_T + +/* The size of `u_int16_t', as computed by sizeof. */ +#undef SIZEOF_U_INT16_T + +/* The size of `u_int32_t', as computed by sizeof. */ +#undef SIZEOF_U_INT32_T + +/* The size of `u_int8_t', as computed by sizeof. */ +#undef SIZEOF_U_INT8_T + +/* Define to 1 if you have the ANSI C header files. */ +#undef STDC_HEADERS + +/* Define to 1 if your processor stores words with the most significant byte + first (like Motorola and SPARC, unlike Intel and VAX). */ +#undef WORDS_BIGENDIAN + +/* Define for Solaris 2.5.1 so the uint32_t typedef from , + , or is not used. If the typedef was allowed, the + #define below would cause a syntax error. */ +#undef _UINT32_T + +/* Define for Solaris 2.5.1 so the uint8_t typedef from , + , or is not used. If the typedef was allowed, the + #define below would cause a syntax error. */ +#undef _UINT8_T + +/* Define to empty if `const' does not conform to ANSI C. */ +#undef const + +/* Define to the type of a signed integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +#undef int32_t + +/* Define to the type of an unsigned integer type of width exactly 16 bits if + such a type exists and the standard includes do not define it. */ +#undef uint16_t + +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +#undef uint32_t + +/* Define to the type of an unsigned integer type of width exactly 8 bits if + such a type exists and the standard includes do not define it. */ +#undef uint8_t diff --git a/Lite/Util/configure.ac b/Lite/Util/configure.ac new file mode 100644 index 0000000..72862c4 --- /dev/null +++ b/Lite/Util/configure.ac @@ -0,0 +1,54 @@ +# Process this file with autoconf to produce a configure script. +AC_INIT() +AC_CONFIG_HEADER([config.h]) + +# Checks for programs. +AC_PROG_CC + +# Checks for header files. +AC_HEADER_STDC +AC_CHECK_HEADERS([sys/socket.h netinet/in.h arpa/inet.h netdb.h]) + +# Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +AC_TYPE_INT32_T +AC_TYPE_UINT16_T +AC_TYPE_UINT32_T +AC_TYPE_UINT8_T + +# Checks for library functions. +AC_PROG_GCC_TRADITIONAL +AH_TEMPLATE([LIBS],[Extra libraries needed for this build]) +AH_TEMPLATE([HAVE_LIBNSL],[Define if library library 'nsl' is present]) + +AH_TEMPLATE([HAVE_GETHOSTBYNAME],[Define to 1 if function 'gethostbyname' is present]) +AC_SEARCH_LIBS([gethostbyname],[nsl],[ + AC_DEFINE([HAVE_GETHOSTBYNAME])]) + +AH_TEMPLATE([HAVE_INET_ATON],[Define to 1 if function 'inet_aton' is present]) +AC_SEARCH_LIBS([inet_aton],[socket],[ + AC_DEFINE([HAVE_INET_ATON])]) + +AH_TEMPLATE([HAVE_INET_PTON],[Define to 1 if function 'inet_pton' is present]) +AC_SEARCH_LIBS([inet_pton],[socket],[ + AC_DEFINE([HAVE_INET_PTON])]) + +AH_TEMPLATE([HAVE_INET_ADDR],[Define to 1 if function 'inet_addr' is present]) +AC_SEARCH_LIBS([inet_addr],[socket],[ + AC_DEFINE([HAVE_INET_ADDR])]) + +AC_C_BIGENDIAN +AC_CHECK_SIZEOF([uint8_t]) +AC_CHECK_SIZEOF([uint16_t]) +AC_CHECK_SIZEOF([uint32_t]) +AC_CHECK_SIZEOF([u_int8_t]) +AC_CHECK_SIZEOF([u_int16_t]) +AC_CHECK_SIZEOF([u_int32_t]) + +AC_CONFIG_COMMANDS_PRE([ + if test "$LIBS" != ""; then + AC_DEFINE_UNQUOTED([LIBS],[$LIBS],[Extra libraries]) + fi +]) + +AC_OUTPUT diff --git a/Lite/Util/configure.cc b/Lite/Util/configure.cc new file mode 100644 index 0000000..b9a0080 --- /dev/null +++ b/Lite/Util/configure.cc @@ -0,0 +1,5401 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.69. +# +# +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. +# +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + +# Use a proper internal environment variable to ensure we don't fall + # into an infinite loop, continuously re-executing ourselves. + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then + _as_can_reexec=no; export _as_can_reexec; + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +as_fn_exit 255 + fi + # We don't want this to propagate to other subprocesses. + { _as_can_reexec=; unset _as_can_reexec;} +if test "x$CONFIG_SHELL" = x; then + as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which + # is contrary to our usage. Disable this feature. + alias -g '\${1+\"\$@\"}'='\"\$@\"' + setopt NO_GLOB_SUBST +else + case \`(set -o) 2>/dev/null\` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi +" + as_required="as_fn_return () { (exit \$1); } +as_fn_success () { as_fn_return 0; } +as_fn_failure () { as_fn_return 1; } +as_fn_ret_success () { return 0; } +as_fn_ret_failure () { return 1; } + +exitcode=0 +as_fn_success || { exitcode=1; echo as_fn_success failed.; } +as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; } +as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; } +as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; } +if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : + +else + exitcode=1; echo positional parameters were not saved. +fi +test x\$exitcode = x0 || exit 1 +test -x / || exit 1" + as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO + as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO + eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && + test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1 +test \$(( 1 + 1 )) = 2 || exit 1" + if (eval "$as_required") 2>/dev/null; then : + as_have_required=yes +else + as_have_required=no +fi + if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then : + +else + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +as_found=false +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + as_found=: + case $as_dir in #( + /*) + for as_base in sh bash ksh sh5; do + # Try only shells that exist, to save several forks. + as_shell=$as_dir/$as_base + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then : + CONFIG_SHELL=$as_shell as_have_required=yes + if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then : + break 2 +fi +fi + done;; + esac + as_found=false +done +$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } && + { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then : + CONFIG_SHELL=$SHELL as_have_required=yes +fi; } +IFS=$as_save_IFS + + + if test "x$CONFIG_SHELL" != x; then : + export CONFIG_SHELL + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 +fi + + if test x$as_have_required = xno; then : + $as_echo "$0: This script requires a shell more modern than all" + $as_echo "$0: the shells that I found on your system." + if test x${ZSH_VERSION+set} = xset ; then + $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should" + $as_echo "$0: be upgraded to zsh 4.3.4 or later." + else + $as_echo "$0: Please tell bug-autoconf@gnu.org about your system, +$0: including any error possibly output before this +$0: message. Then install a modern shell, or manually run +$0: the script under such a shell if you do have one." + fi + exit 1 +fi +fi +fi +SHELL=${CONFIG_SHELL-/bin/sh} +export SHELL +# Unset more variables known to interfere with behavior of common tools. +CLICOLOR_FORCE= GREP_OPTIONS= +unset CLICOLOR_FORCE GREP_OPTIONS + +## --------------------- ## +## M4sh Shell Functions. ## +## --------------------- ## +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + + + as_lineno_1=$LINENO as_lineno_1a=$LINENO + as_lineno_2=$LINENO as_lineno_2a=$LINENO + eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" && + test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || { + # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have + # already done that, so ensure we don't try to do so again and fall + # in an infinite loop. This has already happened in practice. + _as_can_reexec=no; export _as_can_reexec + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +test -n "$DJDIR" || exec 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= + +# Identity of this package. +PACKAGE_NAME= +PACKAGE_TARNAME= +PACKAGE_VERSION= +PACKAGE_STRING= +PACKAGE_BUGREPORT= +PACKAGE_URL= + +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='LTLIBOBJS +LIBOBJS +EGREP +GREP +CPP +OBJEXT +EXEEXT +ac_ct_CC +CPPFLAGS +LDFLAGS +CFLAGS +CC +target_alias +host_alias +build_alias +LIBS +ECHO_T +ECHO_N +ECHO_C +DEFS +mandir +localedir +libdir +psdir +pdfdir +dvidir +htmldir +infodir +docdir +oldincludedir +includedir +localstatedir +sharedstatedir +sysconfdir +datadir +datarootdir +libexecdir +sbindir +bindir +program_transform_name +prefix +exec_prefix +PACKAGE_URL +PACKAGE_BUGREPORT +PACKAGE_STRING +PACKAGE_VERSION +PACKAGE_TARNAME +PACKAGE_NAME +PATH_SEPARATOR +SHELL' +ac_subst_files='' +ac_user_opts=' +enable_option_checking +' + ac_precious_vars='build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CPP' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +ac_unrecognized_opts= +ac_unrecognized_sep= +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid feature name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"enable_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval enable_$ac_useropt=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=\$ac_optarg ;; + + -without-* | --without-*) + ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && + as_fn_error $? "invalid package name: $ac_useropt" + ac_useropt_orig=$ac_useropt + ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` + case $ac_user_opts in + *" +"with_$ac_useropt" +"*) ;; + *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig" + ac_unrecognized_sep=', ';; + esac + eval with_$ac_useropt=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + case $ac_envvar in #( + '' | [0-9]* | *[!_$as_cr_alnum]* ) + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; + esac + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + as_fn_error $? "missing argument to $ac_option" +fi + +if test -n "$ac_unrecognized_opts"; then + case $enable_option_checking in + no) ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; + *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; + esac +fi + +# Check all directory arguments for consistency. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir +do + eval ac_val=\$$ac_var + # Remove trailing slashes. + case $ac_val in + */ ) + ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'` + eval $ac_var=\$ac_val;; + esac + # Be sure to have absolute directory names. + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + as_fn_error $? "working directory cannot be determined" +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + as_fn_error $? "pwd does not report name of working directory" + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$as_myself" || +$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_myself" : 'X\(//\)[^/]' \| \ + X"$as_myself" : 'X\(//\)$' \| \ + X"$as_myself" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_myself" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures this package to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking ...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF +_ACEOF +fi + +if test -n "$ac_init_help"; then + + cat <<\_ACEOF + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + CPP C preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +Report bugs to the package provider. +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || + { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } || + continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +configure +generated by GNU Autoconf 2.69 + +Copyright (C) 2012 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi + +## ------------------------ ## +## Autoconf initialization. ## +## ------------------------ ## + +# ac_fn_c_try_compile LINENO +# -------------------------- +# Try to compile conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext + if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_compile + +# ac_fn_c_try_cpp LINENO +# ---------------------- +# Try to preprocess conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_cpp () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } > conftest.i && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_cpp + +# ac_fn_c_try_run LINENO +# ---------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes +# that executables *can* be run. +ac_fn_c_try_run () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { ac_try='./conftest$ac_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then : + ac_retval=0 +else + $as_echo "$as_me: program exited with status $ac_status" >&5 + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=$ac_status +fi + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_run + +# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists, giving a warning if it cannot be compiled using +# the include files in INCLUDES and setting the cache variable VAR +# accordingly. +ac_fn_c_check_header_mongrel () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if eval \${$3+:} false; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +else + # Is the header compilable? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5 +$as_echo_n "checking $2 usability... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_header_compiler=yes +else + ac_header_compiler=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5 +$as_echo "$ac_header_compiler" >&6; } + +# Is the header present? +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5 +$as_echo_n "checking $2 presence... " >&6; } +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <$2> +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + ac_header_preproc=yes +else + ac_header_preproc=no +fi +rm -f conftest.err conftest.i conftest.$ac_ext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 +$as_echo "$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #(( + yes:no: ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5 +$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; + no:yes:* ) + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5 +$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: check for missing prerequisite headers?" >&5 +$as_echo "$as_me: WARNING: $2: check for missing prerequisite headers?" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5 +$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&5 +$as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 +$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} + ;; +esac + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=\$ac_header_compiler" +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } +fi + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_mongrel + +# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES +# ------------------------------------------------------- +# Tests whether HEADER exists and can be compiled using the include files in +# INCLUDES, setting the cache variable VAR accordingly. +ac_fn_c_check_header_compile () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 +$as_echo_n "checking for $2... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +#include <$2> +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + eval "$3=yes" +else + eval "$3=no" +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_check_header_compile + +# ac_fn_c_find_intX_t LINENO BITS VAR +# ----------------------------------- +# Finds a signed integer type with width BITS, setting cache variable VAR +# accordingly. +ac_fn_c_find_intX_t () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for int$2_t" >&5 +$as_echo_n "checking for int$2_t... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=no" + # Order is important - never check a type that is potentially smaller + # than half of the expected target width. + for ac_type in int$2_t 'int' 'long int' \ + 'long long int' 'short int' 'signed char'; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default + enum { N = $2 / 2 - 1 }; +int +main () +{ +static int test_array [1 - 2 * !(0 < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1))]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default + enum { N = $2 / 2 - 1 }; +int +main () +{ +static int test_array [1 - 2 * !(($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1) + < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 2))]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + case $ac_type in #( + int$2_t) : + eval "$3=yes" ;; #( + *) : + eval "$3=\$ac_type" ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + if eval test \"x\$"$3"\" = x"no"; then : + +else + break +fi + done +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_find_intX_t + +# ac_fn_c_find_uintX_t LINENO BITS VAR +# ------------------------------------ +# Finds an unsigned integer type with width BITS, setting cache variable VAR +# accordingly. +ac_fn_c_find_uintX_t () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5 +$as_echo_n "checking for uint$2_t... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=no" + # Order is important - never check a type that is potentially smaller + # than half of the expected target width. + for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \ + 'unsigned long long int' 'unsigned short int' 'unsigned char'; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + case $ac_type in #( + uint$2_t) : + eval "$3=yes" ;; #( + *) : + eval "$3=\$ac_type" ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + if eval test \"x\$"$3"\" = x"no"; then : + +else + break +fi + done +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_find_uintX_t + +# ac_fn_c_try_link LINENO +# ----------------------- +# Try to link conftest.$ac_ext, and return whether this succeeded. +ac_fn_c_try_link () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + rm -f conftest.$ac_objext conftest$ac_exeext + if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + grep -v '^ *+' conftest.err >conftest.er1 + cat conftest.er1 >&5 + mv -f conftest.er1 conftest.err + fi + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && { + test "$cross_compiling" = yes || + test -x conftest$ac_exeext + }; then : + ac_retval=0 +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_retval=1 +fi + # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information + # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would + # interfere with the next link command; also delete a directory that is + # left behind by Apple's compiler. We do this before executing the actions. + rm -rf conftest.dSYM conftest_ipa8_conftest.oo + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval + +} # ac_fn_c_try_link + +# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES +# -------------------------------------------- +# Tries to find the compile-time value of EXPR in a program that includes +# INCLUDES, setting VAR accordingly. Returns whether the value could be +# computed +ac_fn_c_compute_int () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) >= 0)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_lo=0 ac_mid=0 + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=$ac_mid; break +else + as_fn_arith $ac_mid + 1 && ac_lo=$as_val + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) < 0)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=-1 ac_mid=-1 + while :; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) >= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_lo=$ac_mid; break +else + as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + ac_lo= ac_hi= +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +int +main () +{ +static int test_array [1 - 2 * !(($2) <= $ac_mid)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_hi=$ac_mid +else + as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in #(( +?*) eval "$3=\$ac_lo"; ac_retval=0 ;; +'') ac_retval=1 ;; +esac + else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$4 +static long int longval () { return $2; } +static unsigned long int ulongval () { return $2; } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + return 1; + if (($2) < 0) + { + long int i = longval (); + if (i != ($2)) + return 1; + fprintf (f, "%ld", i); + } + else + { + unsigned long int i = ulongval (); + if (i != ($2)) + return 1; + fprintf (f, "%lu", i); + } + /* Do not output a trailing newline, as this causes \r\n confusion + on some platforms. */ + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + echo >>conftest.val; read $3 config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by $as_me, which was +generated by GNU Autoconf 2.69. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + $as_echo "PATH: $as_dir" + done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;; + 2) + as_fn_append ac_configure_args1 " '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + as_fn_append ac_configure_args " '$ac_arg'" + ;; + esac + done +done +{ ac_configure_args0=; unset ac_configure_args0;} +{ ac_configure_args1=; unset ac_configure_args1;} + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + $as_echo "## ---------------- ## +## Cache variables. ## +## ---------------- ##" + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + $as_echo "## ----------------- ## +## Output variables. ## +## ----------------- ##" + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + $as_echo "## ------------------- ## +## File substitutions. ## +## ------------------- ##" + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + $as_echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + $as_echo "## ----------- ## +## confdefs.h. ## +## ----------- ##" + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + $as_echo "$as_me: caught signal $ac_signal" + $as_echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +$as_echo "/* confdefs.h */" > confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_URL "$PACKAGE_URL" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer an explicitly selected file to automatically selected ones. +ac_site_file1=NONE +ac_site_file2=NONE +if test -n "$CONFIG_SITE"; then + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac +elif test "x$prefix" != xNONE; then + ac_site_file1=$prefix/share/config.site + ac_site_file2=$prefix/etc/config.site +else + ac_site_file1=$ac_default_prefix/share/config.site + ac_site_file2=$ac_default_prefix/etc/config.site +fi +for ac_site_file in "$ac_site_file1" "$ac_site_file2" +do + test "x$ac_site_file" = xNONE && continue + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 +$as_echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" \ + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5; } + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special files + # actually), so we avoid doing that. DJGPP emulates it as a regular file. + if test /dev/null != "$cache_file" && test -f "$cache_file"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 +$as_echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5 +$as_echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5 +$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + # differences in whitespace do not lead to failure. + ac_old_val_w=`echo x $ac_old_val` + ac_new_val_w=`echo x $ac_new_val` + if test "$ac_old_val_w" != "$ac_new_val_w"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5 +$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + ac_cache_corrupted=: + else + { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5 +$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;} + eval $ac_var=\$ac_old_val + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: former value: \`$ac_old_val'" >&5 +$as_echo "$as_me: former value: \`$ac_old_val'" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: current value: \`$ac_new_val'" >&5 +$as_echo "$as_me: current value: \`$ac_new_val'" >&2;} + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) as_fn_append ac_configure_args " '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} + { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 +$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 +fi +## -------------------- ## +## Main body of script. ## +## -------------------- ## + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +ac_config_headers="$ac_config_headers config.h" + + +# Checks for programs. +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="gcc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5 +$as_echo "$CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_prog_ac_ct_CC+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_prog_ac_ct_CC="$ac_prog" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5 +$as_echo "$ac_ct_CC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5 +$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } + +# Provide some information about the compiler. +$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 +set X $ac_compile +ac_compiler=$2 +for ac_option in --version -v -V -qversion; do + { { ac_try="$ac_compiler $ac_option >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compiler $ac_option >&5") 2>conftest.err + ac_status=$? + if test -s conftest.err; then + sed '10a\ +... rest of stderr output deleted ... + 10q' conftest.err >conftest.er1 + cat conftest.er1 >&5 + fi + rm -f conftest.er1 conftest.err + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } +done + +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } +ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` + +# The possible output files: +ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*" + +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { { ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi +if test -z "$ac_file"; then : + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "C compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } +ac_exeext=$ac_cv_exeext + +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 +$as_echo_n "checking for suffix of executables... " >&6; } +if { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest conftest$ac_cv_exeext +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 +$as_echo "$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details" "$LINENO" 5; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 +$as_echo_n "checking for suffix of object files... " >&6; } +if ${ac_cv_objext+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { { ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; then : + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + $as_echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5; } +fi +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5 +$as_echo "$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 +$as_echo_n "checking whether we are using the GNU C compiler... " >&6; } +if ${ac_cv_c_compiler_gnu+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_compiler_gnu=yes +else + ac_compiler_gnu=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5 +$as_echo "$ac_cv_c_compiler_gnu" >&6; } +if test $ac_compiler_gnu = yes; then + GCC=yes +else + GCC= +fi +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 +$as_echo_n "checking whether $CC accepts -g... " >&6; } +if ${ac_cv_prog_cc_g+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +else + CFLAGS="" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + +else + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_g=yes +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5 +$as_echo "$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 +$as_echo_n "checking for $CC option to accept ISO C89... " >&6; } +if ${ac_cv_prog_cc_c89+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +struct stat; +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_prog_cc_c89=$ac_arg +fi +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5 +$as_echo "none needed" >&6; } ;; + xno) + { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5 +$as_echo "unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5 +$as_echo "$ac_cv_prog_cc_c89" >&6; } ;; +esac +if test "x$ac_cv_prog_cc_c89" != xno; then : + +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +# Checks for header files. + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5 +$as_echo_n "checking how to run the C preprocessor... " >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if ${ac_cv_prog_CPP+:} false; then : + $as_echo_n "(cached) " >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5 +$as_echo "$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + +else + # Broken: fails on valid input. +continue +fi +rm -f conftest.err conftest.i conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +_ACEOF +if ac_fn_c_try_cpp "$LINENO"; then : + # Broken: success on invalid input. +continue +else + # Passes both tests. +ac_preproc_ok=: +break +fi +rm -f conftest.err conftest.i conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.i conftest.err conftest.$ac_ext +if $ac_preproc_ok; then : + +else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 +$as_echo_n "checking for grep that handles long lines and -e... " >&6; } +if ${ac_cv_path_GREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if test -z "$GREP"; then + ac_path_GREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_GREP" || continue +# Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_GREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_GREP"; then + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_GREP=$GREP +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5 +$as_echo "$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 +$as_echo_n "checking for egrep... " >&6; } +if ${ac_cv_path_EGREP+:} false; then : + $as_echo_n "(cached) " >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + if test -z "$EGREP"; then + ac_path_EGREP_found=false + # Loop through the user's path and test for each of PROGNAME-LIST + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + as_fn_executable_p "$ac_path_EGREP" || continue +# Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + $as_echo_n 0123456789 >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + $as_echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + as_fn_arith $ac_count + 1 && ac_count=$as_val + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + $ac_path_EGREP_found && break 3 + done + done + done +IFS=$as_save_IFS + if test -z "$ac_cv_path_EGREP"; then + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + fi +else + ac_cv_path_EGREP=$EGREP +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5 +$as_echo "$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 +$as_echo_n "checking for ANSI C header files... " >&6; } +if ${ac_cv_header_stdc+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_header_stdc=yes +else + ac_cv_header_stdc=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then : + +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then : + : +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + +else + ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + +fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5 +$as_echo "$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +$as_echo "#define STDC_HEADERS 1" >>confdefs.h + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default +" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +for ac_header in sys/socket.h netinet/in.h arpa/inet.h netdb.h +do : + as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` +ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : + cat >>confdefs.h <<_ACEOF +#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +# Checks for typedefs, structures, and compiler characteristics. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 +$as_echo_n "checking for an ANSI C-conforming const... " >&6; } +if ${ac_cv_c_const+:} false; then : + $as_echo_n "(cached) " >&6 +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +int +main () +{ + +#ifndef __cplusplus + /* Ultrix mips cc rejects this sort of thing. */ + typedef int charset[2]; + const charset cs = { 0, 0 }; + /* SunOS 4.1.1 cc rejects this. */ + char const *const *pcpcc; + char **ppc; + /* NEC SVR4.0.2 mips cc rejects this. */ + struct point {int x, y;}; + static struct point const zero = {0,0}; + /* AIX XL C 1.02.0.0 rejects this. + It does not let you subtract one const X* pointer from another in + an arm of an if-expression whose if-part is not a constant + expression */ + const char *g = "string"; + pcpcc = &g + (g ? g-g : 0); + /* HPUX 7.0 cc rejects these. */ + ++pcpcc; + ppc = (char**) pcpcc; + pcpcc = (char const *const *) ppc; + { /* SCO 3.2v4 cc rejects this sort of thing. */ + char tx; + char *t = &tx; + char const *s = 0 ? (char *) 0 : (char const *) 0; + + *t++ = 0; + if (s) return 0; + } + { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ + int x[] = {25, 17}; + const int *foo = &x[0]; + ++foo; + } + { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ + typedef const int *iptr; + iptr p = 0; + ++p; + } + { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying + "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ + struct s { int j; const int *ap[3]; } bx; + struct s *b = &bx; b->j = 5; + } + { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; + if (!foo) return 0; + } + return !cs[0] && !zero.x; +#endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_const=yes +else + ac_cv_c_const=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5 +$as_echo "$ac_cv_c_const" >&6; } +if test $ac_cv_c_const = no; then + +$as_echo "#define const /**/" >>confdefs.h + +fi + +ac_fn_c_find_intX_t "$LINENO" "32" "ac_cv_c_int32_t" +case $ac_cv_c_int32_t in #( + no|yes) ;; #( + *) + +cat >>confdefs.h <<_ACEOF +#define int32_t $ac_cv_c_int32_t +_ACEOF +;; +esac + +ac_fn_c_find_uintX_t "$LINENO" "16" "ac_cv_c_uint16_t" +case $ac_cv_c_uint16_t in #( + no|yes) ;; #( + *) + + +cat >>confdefs.h <<_ACEOF +#define uint16_t $ac_cv_c_uint16_t +_ACEOF +;; + esac + +ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t" +case $ac_cv_c_uint32_t in #( + no|yes) ;; #( + *) + +$as_echo "#define _UINT32_T 1" >>confdefs.h + + +cat >>confdefs.h <<_ACEOF +#define uint32_t $ac_cv_c_uint32_t +_ACEOF +;; + esac + +ac_fn_c_find_uintX_t "$LINENO" "8" "ac_cv_c_uint8_t" +case $ac_cv_c_uint8_t in #( + no|yes) ;; #( + *) + +$as_echo "#define _UINT8_T 1" >>confdefs.h + + +cat >>confdefs.h <<_ACEOF +#define uint8_t $ac_cv_c_uint8_t +_ACEOF +;; + esac + + +# Checks for library functions. +if test $ac_cv_c_compiler_gnu = yes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC needs -traditional" >&5 +$as_echo_n "checking whether $CC needs -traditional... " >&6; } +if ${ac_cv_prog_gcc_traditional+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_pattern="Autoconf.*'x'" + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +Autoconf TIOCGETP +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "$ac_pattern" >/dev/null 2>&1; then : + ac_cv_prog_gcc_traditional=yes +else + ac_cv_prog_gcc_traditional=no +fi +rm -f conftest* + + + if test $ac_cv_prog_gcc_traditional = no; then + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include +Autoconf TCGETA +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "$ac_pattern" >/dev/null 2>&1; then : + ac_cv_prog_gcc_traditional=yes +fi +rm -f conftest* + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_gcc_traditional" >&5 +$as_echo "$ac_cv_prog_gcc_traditional" >&6; } + if test $ac_cv_prog_gcc_traditional = yes; then + CC="$CC -traditional" + fi +fi + + + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostbyname" >&5 +$as_echo_n "checking for library containing gethostbyname... " >&6; } +if ${ac_cv_search_gethostbyname+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char gethostbyname (); +int +main () +{ +return gethostbyname (); + ; + return 0; +} +_ACEOF +for ac_lib in '' nsl; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_gethostbyname=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_gethostbyname+:} false; then : + break +fi +done +if ${ac_cv_search_gethostbyname+:} false; then : + +else + ac_cv_search_gethostbyname=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_gethostbyname" >&5 +$as_echo "$ac_cv_search_gethostbyname" >&6; } +ac_res=$ac_cv_search_gethostbyname +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + + $as_echo "#define HAVE_GETHOSTBYNAME 1" >>confdefs.h + +fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing inet_aton" >&5 +$as_echo_n "checking for library containing inet_aton... " >&6; } +if ${ac_cv_search_inet_aton+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char inet_aton (); +int +main () +{ +return inet_aton (); + ; + return 0; +} +_ACEOF +for ac_lib in '' socket; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_inet_aton=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_inet_aton+:} false; then : + break +fi +done +if ${ac_cv_search_inet_aton+:} false; then : + +else + ac_cv_search_inet_aton=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_inet_aton" >&5 +$as_echo "$ac_cv_search_inet_aton" >&6; } +ac_res=$ac_cv_search_inet_aton +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + + $as_echo "#define HAVE_INET_ATON 1" >>confdefs.h + +fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing inet_pton" >&5 +$as_echo_n "checking for library containing inet_pton... " >&6; } +if ${ac_cv_search_inet_pton+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char inet_pton (); +int +main () +{ +return inet_pton (); + ; + return 0; +} +_ACEOF +for ac_lib in '' socket; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_inet_pton=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_inet_pton+:} false; then : + break +fi +done +if ${ac_cv_search_inet_pton+:} false; then : + +else + ac_cv_search_inet_pton=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_inet_pton" >&5 +$as_echo "$ac_cv_search_inet_pton" >&6; } +ac_res=$ac_cv_search_inet_pton +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + + $as_echo "#define HAVE_INET_PTON 1" >>confdefs.h + +fi + + + +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing inet_addr" >&5 +$as_echo_n "checking for library containing inet_addr... " >&6; } +if ${ac_cv_search_inet_addr+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_func_search_save_LIBS=$LIBS +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char inet_addr (); +int +main () +{ +return inet_addr (); + ; + return 0; +} +_ACEOF +for ac_lib in '' socket; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + if ac_fn_c_try_link "$LINENO"; then : + ac_cv_search_inet_addr=$ac_res +fi +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext + if ${ac_cv_search_inet_addr+:} false; then : + break +fi +done +if ${ac_cv_search_inet_addr+:} false; then : + +else + ac_cv_search_inet_addr=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_inet_addr" >&5 +$as_echo "$ac_cv_search_inet_addr" >&6; } +ac_res=$ac_cv_search_inet_addr +if test "$ac_res" != no; then : + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + + $as_echo "#define HAVE_INET_ADDR 1" >>confdefs.h + +fi + + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 +$as_echo_n "checking whether byte ordering is bigendian... " >&6; } +if ${ac_cv_c_bigendian+:} false; then : + $as_echo_n "(cached) " >&6 +else + ac_cv_c_bigendian=unknown + # See if we're dealing with a universal compiler. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#ifndef __APPLE_CC__ + not a universal capable compiler + #endif + typedef int dummy; + +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + + # Check for potential -arch flags. It is not universal unless + # there are at least two -arch flags with different values. + ac_arch= + ac_prev= + for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do + if test -n "$ac_prev"; then + case $ac_word in + i?86 | x86_64 | ppc | ppc64) + if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then + ac_arch=$ac_word + else + ac_cv_c_bigendian=universal + break + fi + ;; + esac + ac_prev= + elif test "x$ac_word" = "x-arch"; then + ac_prev=arch + fi + done +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + if test $ac_cv_c_bigendian = unknown; then + # See if sys/param.h defines the BYTE_ORDER macro. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include + +int +main () +{ +#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \ + && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \ + && LITTLE_ENDIAN) + bogus endian macros + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + # It does; now see whether it defined to BIG_ENDIAN or not. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + #include + +int +main () +{ +#if BYTE_ORDER != BIG_ENDIAN + not big endian + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_bigendian=yes +else + ac_cv_c_bigendian=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi + if test $ac_cv_c_bigendian = unknown; then + # See if defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris). + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN) + bogus endian macros + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + # It does; now see whether it defined to _BIG_ENDIAN or not. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include + +int +main () +{ +#ifndef _BIG_ENDIAN + not big endian + #endif + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + ac_cv_c_bigendian=yes +else + ac_cv_c_bigendian=no +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + fi + if test $ac_cv_c_bigendian = unknown; then + # Compile a test program. + if test "$cross_compiling" = yes; then : + # Try to guess by grepping values from an object file. + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +short int ascii_mm[] = + { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; + short int ascii_ii[] = + { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; + int use_ascii (int i) { + return ascii_mm[i] + ascii_ii[i]; + } + short int ebcdic_ii[] = + { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; + short int ebcdic_mm[] = + { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; + int use_ebcdic (int i) { + return ebcdic_mm[i] + ebcdic_ii[i]; + } + extern int foo; + +int +main () +{ +return use_ascii (foo) == use_ebcdic (foo); + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then + ac_cv_c_bigendian=yes + fi + if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then + if test "$ac_cv_c_bigendian" = unknown; then + ac_cv_c_bigendian=no + else + # finding both strings is unlikely to happen, but who knows? + ac_cv_c_bigendian=unknown + fi + fi +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +else + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ + + /* Are we little or big endian? From Harbison&Steele. */ + union + { + long int l; + char c[sizeof (long int)]; + } u; + u.l = 1; + return u.c[sizeof (long int) - 1] == 1; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_run "$LINENO"; then : + ac_cv_c_bigendian=no +else + ac_cv_c_bigendian=yes +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \ + conftest.$ac_objext conftest.beam conftest.$ac_ext +fi + + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5 +$as_echo "$ac_cv_c_bigendian" >&6; } + case $ac_cv_c_bigendian in #( + yes) + $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h +;; #( + no) + ;; #( + universal) + +$as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h + + ;; #( + *) + as_fn_error $? "unknown endianness + presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; + esac + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of uint8_t" >&5 +$as_echo_n "checking size of uint8_t... " >&6; } +if ${ac_cv_sizeof_uint8_t+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (uint8_t))" "ac_cv_sizeof_uint8_t" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_uint8_t" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (uint8_t) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_uint8_t=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_uint8_t" >&5 +$as_echo "$ac_cv_sizeof_uint8_t" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_UINT8_T $ac_cv_sizeof_uint8_t +_ACEOF + + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of uint16_t" >&5 +$as_echo_n "checking size of uint16_t... " >&6; } +if ${ac_cv_sizeof_uint16_t+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (uint16_t))" "ac_cv_sizeof_uint16_t" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_uint16_t" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (uint16_t) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_uint16_t=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_uint16_t" >&5 +$as_echo "$ac_cv_sizeof_uint16_t" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_UINT16_T $ac_cv_sizeof_uint16_t +_ACEOF + + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of uint32_t" >&5 +$as_echo_n "checking size of uint32_t... " >&6; } +if ${ac_cv_sizeof_uint32_t+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (uint32_t))" "ac_cv_sizeof_uint32_t" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_uint32_t" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (uint32_t) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_uint32_t=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_uint32_t" >&5 +$as_echo "$ac_cv_sizeof_uint32_t" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_UINT32_T $ac_cv_sizeof_uint32_t +_ACEOF + + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of u_int8_t" >&5 +$as_echo_n "checking size of u_int8_t... " >&6; } +if ${ac_cv_sizeof_u_int8_t+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (u_int8_t))" "ac_cv_sizeof_u_int8_t" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_u_int8_t" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (u_int8_t) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_u_int8_t=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_u_int8_t" >&5 +$as_echo "$ac_cv_sizeof_u_int8_t" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_U_INT8_T $ac_cv_sizeof_u_int8_t +_ACEOF + + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of u_int16_t" >&5 +$as_echo_n "checking size of u_int16_t... " >&6; } +if ${ac_cv_sizeof_u_int16_t+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (u_int16_t))" "ac_cv_sizeof_u_int16_t" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_u_int16_t" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (u_int16_t) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_u_int16_t=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_u_int16_t" >&5 +$as_echo "$ac_cv_sizeof_u_int16_t" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_U_INT16_T $ac_cv_sizeof_u_int16_t +_ACEOF + + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of u_int32_t" >&5 +$as_echo_n "checking size of u_int32_t... " >&6; } +if ${ac_cv_sizeof_u_int32_t+:} false; then : + $as_echo_n "(cached) " >&6 +else + if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (u_int32_t))" "ac_cv_sizeof_u_int32_t" "$ac_includes_default"; then : + +else + if test "$ac_cv_type_u_int32_t" = yes; then + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error 77 "cannot compute sizeof (u_int32_t) +See \`config.log' for more details" "$LINENO" 5; } + else + ac_cv_sizeof_u_int32_t=0 + fi +fi + +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_u_int32_t" >&5 +$as_echo "$ac_cv_sizeof_u_int32_t" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_U_INT32_T $ac_cv_sizeof_u_int32_t +_ACEOF + + + + + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5 +$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #( + *) { eval $ac_var=; unset $ac_var;} ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes: double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \. + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + if test "x$cache_file" != "x/dev/null"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 +$as_echo "$as_me: updating cache $cache_file" >&6;} + if test ! -f "$cache_file" || test -h "$cache_file"; then + cat confcache >"$cache_file" + else + case $cache_file in #( + */* | ?:*) + mv -f confcache "$cache_file"$$ && + mv -f "$cache_file"$$ "$cache_file" ;; #( + *) + mv -f confcache "$cache_file" ;; + esac + fi + fi + else + { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 +$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +U= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`$as_echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext" + as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + + + + if test "$LIBS" != ""; then + +cat >>confdefs.h <<_ACEOF +#define LIBS $LIBS +_ACEOF + + fi + + +: "${CONFIG_STATUS=./config.status}" +ac_write_fail=0 +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5 +$as_echo "$as_me: creating $CONFIG_STATUS" >&6;} +as_write_fail=0 +cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1 +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false + +SHELL=\${CONFIG_SHELL-$SHELL} +export SHELL +_ASEOF +cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1 +## -------------------- ## +## M4sh Initialization. ## +## -------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : + emulate sh + NULLCMD=: + # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in #( + *posix*) : + set -o posix ;; #( + *) : + ;; +esac +fi + + +as_nl=' +' +export as_nl +# Printing a long string crashes Solaris 7 /usr/bin/printf. +as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\' +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo +as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo +# Prefer a ksh shell builtin over an external printf program on Solaris, +# but without wasting forks for bash or zsh. +if test -z "$BASH_VERSION$ZSH_VERSION" \ + && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='print -r --' + as_echo_n='print -rn --' +elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then + as_echo='printf %s\n' + as_echo_n='printf %s' +else + if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then + as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"' + as_echo_n='/usr/ucb/echo -n' + else + as_echo_body='eval expr "X$1" : "X\\(.*\\)"' + as_echo_n_body='eval + arg=$1; + case $arg in #( + *"$as_nl"*) + expr "X$arg" : "X\\(.*\\)$as_nl"; + arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;; + esac; + expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl" + ' + export as_echo_n_body + as_echo_n='sh -c $as_echo_n_body as_echo' + fi + export as_echo_body + as_echo='sh -c $as_echo_body as_echo' +fi + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + PATH_SEPARATOR=: + (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { + (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || + PATH_SEPARATOR=';' + } +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +as_myself= +case $0 in #(( + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break + done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + exit 1 +fi + +# Unset variables that we do not need and which cause bugs (e.g. in +# pre-3.0 UWIN ksh). But do not cause bugs in bash 2.01; the "|| exit 1" +# suppresses any "Segmentation fault" message there. '((' could +# trigger a bug in pdksh 5.2.14. +for as_var in BASH_ENV ENV MAIL MAILPATH +do eval test x\${$as_var+set} = xset \ + && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || : +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +LC_ALL=C +export LC_ALL +LANGUAGE=C +export LANGUAGE + +# CDPATH. +(unset CDPATH) >/dev/null 2>&1 && unset CDPATH + + +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- +# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are +# provided, also output the error to LOG_FD, referencing LINENO. Then exit the +# script with STATUS, using 1 if that was 0. +as_fn_error () +{ + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 + fi + $as_echo "$as_me: error: $2" >&2 + as_fn_exit $as_status +} # as_fn_error + + +# as_fn_set_status STATUS +# ----------------------- +# Set $? to STATUS, without forking. +as_fn_set_status () +{ + return $1 +} # as_fn_set_status + +# as_fn_exit STATUS +# ----------------- +# Exit the shell with STATUS, even in a "trap 0" or "set -e" context. +as_fn_exit () +{ + set +e + as_fn_set_status $1 + exit $1 +} # as_fn_exit + +# as_fn_unset VAR +# --------------- +# Portably unset VAR. +as_fn_unset () +{ + { eval $1=; unset $1;} +} +as_unset=as_fn_unset +# as_fn_append VAR VALUE +# ---------------------- +# Append the text in VALUE to the end of the definition contained in VAR. Take +# advantage of any shell optimizations that allow amortized linear growth over +# repeated appends, instead of the typical quadratic growth present in naive +# implementations. +if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then : + eval 'as_fn_append () + { + eval $1+=\$2 + }' +else + as_fn_append () + { + eval $1=\$$1\$2 + } +fi # as_fn_append + +# as_fn_arith ARG... +# ------------------ +# Perform arithmetic evaluation on the ARGs, and store the result in the +# global $as_val. Take advantage of shells that can avoid forks. The arguments +# must be portable across $(()) and expr. +if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then : + eval 'as_fn_arith () + { + as_val=$(( $* )) + }' +else + as_fn_arith () + { + as_val=`expr "$@" || test $? -eq 1` + } +fi # as_fn_arith + + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in #((((( +-n*) + case `echo 'xy\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + xy) ECHO_C='\c';; + *) echo `echo ksh88 bug on AIX 6.1` > /dev/null + ECHO_T=' ';; + esac;; +*) + ECHO_N='-n';; +esac + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir 2>/dev/null +fi +if (echo >conf$$.file) 2>/dev/null; then + if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -pR'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -pR' + elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln + else + as_ln_s='cp -pR' + fi +else + as_ln_s='cp -pR' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + + +# as_fn_mkdir_p +# ------------- +# Create "$as_dir" as a directory, including parents if necessary. +as_fn_mkdir_p () +{ + + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || eval $as_mkdir_p || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" + + +} # as_fn_mkdir_p +if mkdir -p . 2>/dev/null; then + as_mkdir_p='mkdir -p "$as_dir"' +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 +## ----------------------------------- ## +## Main body of $CONFIG_STATUS script. ## +## ----------------------------------- ## +_ASEOF +test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# Save the log message, to keep $0 and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by $as_me, which was +generated by GNU Autoconf 2.69. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + + +case $ac_config_headers in *" +"*) set x $ac_config_headers; shift; ac_config_headers=$*;; +esac + + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +# Files that config.status was made for. +config_headers="$ac_config_headers" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +ac_cs_usage="\ +\`$as_me' instantiates files and other configuration actions +from templates according to the current configuration. Unless the files +and actions are specified as TAGs, all are instantiated by default. + +Usage: $0 [OPTION]... [TAG]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + --config print configuration, then exit + -q, --quiet, --silent + do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration headers: +$config_headers + +Report bugs to the package provider." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" +ac_cs_version="\\ +config.status +configured by $0, generated by GNU Autoconf 2.69, + with options \\"\$ac_cs_config\\" + +Copyright (C) 2012 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +test -n "\$AWK" || AWK=awk +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +# The default lists apply if the user does not specify any file. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=?*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --header | --heade | --head | --hea ) + $ac_shift + case $ac_optarg in + *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + as_fn_append CONFIG_HEADERS " '$ac_optarg'" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + as_fn_error $? "ambiguous option: \`$1' +Try \`$0 --help' for more information.";; + --help | --hel | -h ) + $as_echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) as_fn_error $? "unrecognized option: \`$1' +Try \`$0 --help' for more information." ;; + + *) as_fn_append ac_config_targets " $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +if \$ac_cs_recheck; then + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + shift + \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 + CONFIG_SHELL='$SHELL' + export CONFIG_SHELL + exec "\$@" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + $as_echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= ac_tmp= + trap 'exit_status=$? + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status +' 0 + trap 'as_fn_exit 1' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp + +# Set up the scripts for CONFIG_HEADERS section. +# No need to generate them if there are no CONFIG_HEADERS. +# This happens for instance with `./config.status Makefile'. +if test -n "$CONFIG_HEADERS"; then +cat >"$ac_tmp/defines.awk" <<\_ACAWK || +BEGIN { +_ACEOF + +# Transform confdefs.h into an awk script `defines.awk', embedded as +# here-document in config.status, that substitutes the proper values into +# config.h.in to produce config.h. + +# Create a delimiter string that does not exist in confdefs.h, to ease +# handling of long lines. +ac_delim='%!_!# ' +for ac_last_try in false false :; do + ac_tt=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_tt"; then + break + elif $ac_last_try; then + as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 + else + ac_delim="$ac_delim!$ac_delim _$ac_delim!! " + fi +done + +# For the awk script, D is an array of macro values keyed by name, +# likewise P contains macro parameters if any. Preserve backslash +# newline sequences. + +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +sed -n ' +s/.\{148\}/&'"$ac_delim"'/g +t rset +:rset +s/^[ ]*#[ ]*define[ ][ ]*/ / +t def +d +:def +s/\\$// +t bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3"/p +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p +d +:bsnl +s/["\\]/\\&/g +s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\ +D["\1"]=" \3\\\\\\n"\\/p +t cont +s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p +t cont +d +:cont +n +s/.\{148\}/&'"$ac_delim"'/g +t clear +:clear +s/\\$// +t bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/"/p +d +:bsnlc +s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p +b cont +' >$CONFIG_STATUS || ac_write_fail=1 + +cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 + for (key in D) D_is_set[key] = 1 + FS = "" +} +/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ { + line = \$ 0 + split(line, arg, " ") + if (arg[1] == "#") { + defundef = arg[2] + mac1 = arg[3] + } else { + defundef = substr(arg[1], 2) + mac1 = arg[2] + } + split(mac1, mac2, "(") #) + macro = mac2[1] + prefix = substr(line, 1, index(line, defundef) - 1) + if (D_is_set[macro]) { + # Preserve the white space surrounding the "#". + print prefix "define", macro P[macro] D[macro] + next + } else { + # Replace #undef with comments. This is necessary, for example, + # in the case of _POSIX_SOURCE, which is predefined and required + # on some systems where configure will not decide to define it. + if (defundef == "undef") { + print "/*", prefix defundef, macro, "*/" + next + } + } +} +{ print } +_ACAWK +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 +fi # test -n "$CONFIG_HEADERS" + + +eval set X " :H $CONFIG_HEADERS " +shift +for ac_tag +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$ac_tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; + esac + case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac + as_fn_append ac_file_inputs " '$ac_f'" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input='Generated from '` + $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g' + `' by configure.' + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5 +$as_echo "$as_me: creating $ac_file" >&6;} + fi + # Neutralize special characters interpreted by sed in replacement strings. + case $configure_input in #( + *\&* | *\|* | *\\* ) + ac_sed_conf_input=`$as_echo "$configure_input" | + sed 's/[\\\\&|]/\\\\&/g'`;; #( + *) ac_sed_conf_input=$configure_input;; + esac + + case $ac_tag in + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +$as_echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + as_dir="$ac_dir"; as_fn_mkdir_p + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + + :H) + # + # CONFIG_HEADER + # + if test x"$ac_file" != x-; then + { + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" + } >"$ac_tmp/config.h" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then + { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 +$as_echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f "$ac_file" + mv "$ac_tmp/config.h" "$ac_file" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + fi + else + $as_echo "/* $configure_input */" \ + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error $? "could not create -" "$LINENO" 5 + fi + ;; + + + esac + +done # for ac_tag + + +as_fn_exit 0 +_ACEOF +ac_clean_files=$ac_clean_files_save + +test $ac_write_fail = 0 || + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || as_fn_exit 1 +fi +if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 +$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} +fi + + diff --git a/Lite/Util/configure.gcc b/Lite/Util/configure.gcc new file mode 100644 index 0000000..4843d9f --- /dev/null +++ b/Lite/Util/configure.gcc @@ -0,0 +1,7799 @@ +#! /bin/sh +# Guess values for system-dependent variables and create Makefiles. +# Generated by GNU Autoconf 2.61. +# +# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +# 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + + + +# PATH needs CR +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +as_nl=' +' +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + +# Work around bugs in pre-3.0 UWIN ksh. +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# CDPATH. +$as_unset CDPATH + + +if test "x$CONFIG_SHELL" = x; then + if (eval ":") 2>/dev/null; then + as_have_required=yes +else + as_have_required=no +fi + + if test $as_have_required = yes && (eval ": +(as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=\$LINENO + as_lineno_2=\$LINENO + test \"x\$as_lineno_1\" != \"x\$as_lineno_2\" && + test \"x\`expr \$as_lineno_1 + 1\`\" = \"x\$as_lineno_2\") || { (exit 1); exit 1; } +") 2> /dev/null; then + : +else + as_candidate_shells= + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + case $as_dir in + /*) + for as_base in sh bash ksh sh5; do + as_candidate_shells="$as_candidate_shells $as_dir/$as_base" + done;; + esac +done +IFS=$as_save_IFS + + + for as_shell in $as_candidate_shells $SHELL; do + # Try only shells that exist, to save several forks. + if { test -f "$as_shell" || test -f "$as_shell.exe"; } && + { ("$as_shell") 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + +: +_ASEOF +}; then + CONFIG_SHELL=$as_shell + as_have_required=yes + if { "$as_shell" 2> /dev/null <<\_ASEOF +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + +: +(as_func_return () { + (exit $1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = "$1" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test $exitcode = 0) || { (exit 1); exit 1; } + +( + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2") || { (exit 1); exit 1; } + +_ASEOF +}; then + break +fi + +fi + + done + + if test "x$CONFIG_SHELL" != x; then + for as_var in BASH_ENV ENV + do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + done + export CONFIG_SHELL + exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} +fi + + + if test $as_have_required = no; then + echo This script requires a shell more modern than all the + echo shells that I found on your system. Please install a + echo modern shell, or manually run the script under such a + echo shell if you do have one. + { (exit 1); exit 1; } +fi + + +fi + +fi + + + +(eval "as_func_return () { + (exit \$1) +} +as_func_success () { + as_func_return 0 +} +as_func_failure () { + as_func_return 1 +} +as_func_ret_success () { + return 0 +} +as_func_ret_failure () { + return 1 +} + +exitcode=0 +if as_func_success; then + : +else + exitcode=1 + echo as_func_success failed. +fi + +if as_func_failure; then + exitcode=1 + echo as_func_failure succeeded. +fi + +if as_func_ret_success; then + : +else + exitcode=1 + echo as_func_ret_success failed. +fi + +if as_func_ret_failure; then + exitcode=1 + echo as_func_ret_failure succeeded. +fi + +if ( set x; as_func_ret_success y && test x = \"\$1\" ); then + : +else + exitcode=1 + echo positional parameters were not saved. +fi + +test \$exitcode = 0") || { + echo No shell found that supports shell functions. + echo Please tell autoconf@gnu.org about your system, + echo including any error possibly output before this + echo message +} + + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # scripts with optimization help from Paolo Bonzini. Blame Lee + # E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; +esac + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir +fi +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + + +exec 7<&0 &1 + +# Name of the host. +# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# so uname gets run too. +ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` + +# +# Initializations. +# +ac_default_prefix=/usr/local +ac_clean_files= +ac_config_libobj_dir=. +LIBOBJS= +cross_compiling=no +subdirs= +MFLAGS= +MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} + +# Identity of this package. +PACKAGE_NAME= +PACKAGE_TARNAME= +PACKAGE_VERSION= +PACKAGE_STRING= +PACKAGE_BUGREPORT= + +# Factoring default headers for most tests. +ac_includes_default="\ +#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif" + +ac_subst_vars='SHELL +PATH_SEPARATOR +PACKAGE_NAME +PACKAGE_TARNAME +PACKAGE_VERSION +PACKAGE_STRING +PACKAGE_BUGREPORT +exec_prefix +prefix +program_transform_name +bindir +sbindir +libexecdir +datarootdir +datadir +sysconfdir +sharedstatedir +localstatedir +includedir +oldincludedir +docdir +infodir +htmldir +dvidir +pdfdir +psdir +libdir +localedir +mandir +DEFS +ECHO_C +ECHO_N +ECHO_T +LIBS +build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +CPPFLAGS +ac_ct_CC +EXEEXT +OBJEXT +CPP +GREP +EGREP +LIBOBJS +LTLIBOBJS' +ac_subst_files='' + ac_precious_vars='build_alias +host_alias +target_alias +CC +CFLAGS +LDFLAGS +LIBS +CPPFLAGS +CPP' + + +# Initialize some variables set by options. +ac_init_help= +ac_init_version=false +# The variables have the same names as the options, with +# dashes changed to underlines. +cache_file=/dev/null +exec_prefix=NONE +no_create= +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +verbose= +x_includes=NONE +x_libraries=NONE + +# Installation directory options. +# These are left unexpanded so users can "make install exec_prefix=/foo" +# and all the variables that are supposed to be based on exec_prefix +# by default will actually change. +# Use braces instead of parens because sh, perl, etc. also accept them. +# (The list follows the same order as the GNU Coding Standards.) +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datarootdir='${prefix}/share' +datadir='${datarootdir}' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +includedir='${prefix}/include' +oldincludedir='/usr/include' +docdir='${datarootdir}/doc/${PACKAGE}' +infodir='${datarootdir}/info' +htmldir='${docdir}' +dvidir='${docdir}' +pdfdir='${docdir}' +psdir='${docdir}' +libdir='${exec_prefix}/lib' +localedir='${datarootdir}/locale' +mandir='${datarootdir}/man' + +ac_prev= +ac_dashdash= +for ac_option +do + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval $ac_prev=\$ac_option + ac_prev= + continue + fi + + case $ac_option in + *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *) ac_optarg=yes ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case $ac_dashdash$ac_option in + --) + ac_dashdash=yes ;; + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir=$ac_optarg ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build_alias ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build_alias=$ac_optarg ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file=$ac_optarg ;; + + --config-cache | -C) + cache_file=config.cache ;; + + -datadir | --datadir | --datadi | --datad) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=*) + datadir=$ac_optarg ;; + + -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \ + | --dataroo | --dataro | --datar) + ac_prev=datarootdir ;; + -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \ + | --dataroot=* | --dataroo=* | --dataro=* | --datar=*) + datarootdir=$ac_optarg ;; + + -disable-* | --disable-*) + ac_feature=`expr "x$ac_option" : 'x-*disable-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` + eval enable_$ac_feature=no ;; + + -docdir | --docdir | --docdi | --doc | --do) + ac_prev=docdir ;; + -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*) + docdir=$ac_optarg ;; + + -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv) + ac_prev=dvidir ;; + -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*) + dvidir=$ac_optarg ;; + + -enable-* | --enable-*) + ac_feature=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_feature" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid feature name: $ac_feature" >&2 + { (exit 1); exit 1; }; } + ac_feature=`echo $ac_feature | sed 's/[-.]/_/g'` + eval enable_$ac_feature=\$ac_optarg ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix=$ac_optarg ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he | -h) + ac_init_help=long ;; + -help=r* | --help=r* | --hel=r* | --he=r* | -hr*) + ac_init_help=recursive ;; + -help=s* | --help=s* | --hel=s* | --he=s* | -hs*) + ac_init_help=short ;; + + -host | --host | --hos | --ho) + ac_prev=host_alias ;; + -host=* | --host=* | --hos=* | --ho=*) + host_alias=$ac_optarg ;; + + -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht) + ac_prev=htmldir ;; + -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \ + | --ht=*) + htmldir=$ac_optarg ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir=$ac_optarg ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir=$ac_optarg ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir=$ac_optarg ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir=$ac_optarg ;; + + -localedir | --localedir | --localedi | --localed | --locale) + ac_prev=localedir ;; + -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*) + localedir=$ac_optarg ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst | --locals) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*) + localstatedir=$ac_optarg ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir=$ac_optarg ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c | -n) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir=$ac_optarg ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix=$ac_optarg ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix=$ac_optarg ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix=$ac_optarg ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name=$ac_optarg ;; + + -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd) + ac_prev=pdfdir ;; + -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*) + pdfdir=$ac_optarg ;; + + -psdir | --psdir | --psdi | --psd | --ps) + ac_prev=psdir ;; + -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*) + psdir=$ac_optarg ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir=$ac_optarg ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir=$ac_optarg ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site=$ac_optarg ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir=$ac_optarg ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir=$ac_optarg ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target_alias ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target_alias=$ac_optarg ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers | -V) + ac_init_version=: ;; + + -with-* | --with-*) + ac_package=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/[-.]/_/g'` + eval with_$ac_package=\$ac_optarg ;; + + -without-* | --without-*) + ac_package=`expr "x$ac_option" : 'x-*without-\(.*\)'` + # Reject names that are not valid shell variable names. + expr "x$ac_package" : ".*[^-._$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid package name: $ac_package" >&2 + { (exit 1); exit 1; }; } + ac_package=`echo $ac_package | sed 's/[-.]/_/g'` + eval with_$ac_package=no ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes=$ac_optarg ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries=$ac_optarg ;; + + -*) { echo "$as_me: error: unrecognized option: $ac_option +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } + ;; + + *=*) + ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='` + # Reject names that are not valid shell variable names. + expr "x$ac_envvar" : ".*[^_$as_cr_alnum]" >/dev/null && + { echo "$as_me: error: invalid variable name: $ac_envvar" >&2 + { (exit 1); exit 1; }; } + eval $ac_envvar=\$ac_optarg + export $ac_envvar ;; + + *) + # FIXME: should be removed in autoconf 3.0. + echo "$as_me: WARNING: you should use --build, --host, --target" >&2 + expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && + echo "$as_me: WARNING: invalid host type: $ac_option" >&2 + : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + ;; + + esac +done + +if test -n "$ac_prev"; then + ac_option=--`echo $ac_prev | sed 's/_/-/g'` + { echo "$as_me: error: missing argument to $ac_option" >&2 + { (exit 1); exit 1; }; } +fi + +# Be sure to have absolute directory names. +for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \ + datadir sysconfdir sharedstatedir localstatedir includedir \ + oldincludedir docdir infodir htmldir dvidir pdfdir psdir \ + libdir localedir mandir +do + eval ac_val=\$$ac_var + case $ac_val in + [\\/$]* | ?:[\\/]* ) continue;; + NONE | '' ) case $ac_var in *prefix ) continue;; esac;; + esac + { echo "$as_me: error: expected an absolute directory name for --$ac_var: $ac_val" >&2 + { (exit 1); exit 1; }; } +done + +# There might be people who depend on the old broken behavior: `$host' +# used to hold the argument of --host etc. +# FIXME: To remove some day. +build=$build_alias +host=$host_alias +target=$target_alias + +# FIXME: To remove some day. +if test "x$host_alias" != x; then + if test "x$build_alias" = x; then + cross_compiling=maybe + echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. + If a cross compiler is detected then cross compile mode will be used." >&2 + elif test "x$build_alias" != "x$host_alias"; then + cross_compiling=yes + fi +fi + +ac_tool_prefix= +test -n "$host_alias" && ac_tool_prefix=$host_alias- + +test "$silent" = yes && exec 6>/dev/null + + +ac_pwd=`pwd` && test -n "$ac_pwd" && +ac_ls_di=`ls -di .` && +ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || + { echo "$as_me: error: Working directory cannot be determined" >&2 + { (exit 1); exit 1; }; } +test "X$ac_ls_di" = "X$ac_pwd_ls_di" || + { echo "$as_me: error: pwd does not report name of working directory" >&2 + { (exit 1); exit 1; }; } + + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then the parent directory. + ac_confdir=`$as_dirname -- "$0" || +$as_expr X"$0" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$0" : 'X\(//\)[^/]' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +echo X"$0" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + srcdir=$ac_confdir + if test ! -r "$srcdir/$ac_unique_file"; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r "$srcdir/$ac_unique_file"; then + test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." + { echo "$as_me: error: cannot find sources ($ac_unique_file) in $srcdir" >&2 + { (exit 1); exit 1; }; } +fi +ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" +ac_abs_confdir=`( + cd "$srcdir" && test -r "./$ac_unique_file" || { echo "$as_me: error: $ac_msg" >&2 + { (exit 1); exit 1; }; } + pwd)` +# When building in place, set srcdir=. +if test "$ac_abs_confdir" = "$ac_pwd"; then + srcdir=. +fi +# Remove unnecessary trailing slashes from srcdir. +# Double slashes in file names in object file debugging info +# mess up M-x gdb in Emacs. +case $srcdir in +*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;; +esac +for ac_var in $ac_precious_vars; do + eval ac_env_${ac_var}_set=\${${ac_var}+set} + eval ac_env_${ac_var}_value=\$${ac_var} + eval ac_cv_env_${ac_var}_set=\${${ac_var}+set} + eval ac_cv_env_${ac_var}_value=\$${ac_var} +done + +# +# Report the --help message. +# +if test "$ac_init_help" = "long"; then + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat <<_ACEOF +\`configure' configures this package to adapt to many kinds of systems. + +Usage: $0 [OPTION]... [VAR=VALUE]... + +To assign environment variables (e.g., CC, CFLAGS...), specify them as +VAR=VALUE. See below for descriptions of some of the useful variables. + +Defaults for the options are specified in brackets. + +Configuration: + -h, --help display this help and exit + --help=short display options specific to this package + --help=recursive display the short help of all the included packages + -V, --version display version information and exit + -q, --quiet, --silent do not print \`checking...' messages + --cache-file=FILE cache test results in FILE [disabled] + -C, --config-cache alias for \`--cache-file=config.cache' + -n, --no-create do not create output files + --srcdir=DIR find the sources in DIR [configure dir or \`..'] + +Installation directories: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [PREFIX] + +By default, \`make install' will install all the files in +\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc. You can specify +an installation prefix other than \`$ac_default_prefix' using \`--prefix', +for instance \`--prefix=\$HOME'. + +For better control, use the options below. + +Fine tuning of the installation directories: + --bindir=DIR user executables [EPREFIX/bin] + --sbindir=DIR system admin executables [EPREFIX/sbin] + --libexecdir=DIR program executables [EPREFIX/libexec] + --sysconfdir=DIR read-only single-machine data [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com] + --localstatedir=DIR modifiable single-machine data [PREFIX/var] + --libdir=DIR object code libraries [EPREFIX/lib] + --includedir=DIR C header files [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc [/usr/include] + --datarootdir=DIR read-only arch.-independent data root [PREFIX/share] + --datadir=DIR read-only architecture-independent data [DATAROOTDIR] + --infodir=DIR info documentation [DATAROOTDIR/info] + --localedir=DIR locale-dependent data [DATAROOTDIR/locale] + --mandir=DIR man documentation [DATAROOTDIR/man] + --docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE] + --htmldir=DIR html documentation [DOCDIR] + --dvidir=DIR dvi documentation [DOCDIR] + --pdfdir=DIR pdf documentation [DOCDIR] + --psdir=DIR ps documentation [DOCDIR] +_ACEOF + + cat <<\_ACEOF +_ACEOF +fi + +if test -n "$ac_init_help"; then + + cat <<\_ACEOF + +Some influential environment variables: + CC C compiler command + CFLAGS C compiler flags + LDFLAGS linker flags, e.g. -L if you have libraries in a + nonstandard directory + LIBS libraries to pass to the linker, e.g. -l + CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I if + you have headers in a nonstandard directory + CPP C preprocessor + +Use these variables to override the choices made by `configure' or to help +it to find libraries and programs with nonstandard names/locations. + +_ACEOF +ac_status=$? +fi + +if test "$ac_init_help" = "recursive"; then + # If there are subdirs, report their specific --help. + for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue + test -d "$ac_dir" || continue + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + cd "$ac_dir" || { ac_status=$?; continue; } + # Check for guested configure. + if test -f "$ac_srcdir/configure.gnu"; then + echo && + $SHELL "$ac_srcdir/configure.gnu" --help=recursive + elif test -f "$ac_srcdir/configure"; then + echo && + $SHELL "$ac_srcdir/configure" --help=recursive + else + echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2 + fi || ac_status=$? + cd "$ac_pwd" || { ac_status=$?; break; } + done +fi + +test -n "$ac_init_help" && exit $ac_status +if $ac_init_version; then + cat <<\_ACEOF +configure +generated by GNU Autoconf 2.61 + +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, +2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. +This configure script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it. +_ACEOF + exit +fi +cat >config.log <<_ACEOF +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. + +It was created by $as_me, which was +generated by GNU Autoconf 2.61. Invocation command line was + + $ $0 $@ + +_ACEOF +exec 5>>config.log +{ +cat <<_ASUNAME +## --------- ## +## Platform. ## +## --------- ## + +hostname = `(hostname || uname -n) 2>/dev/null | sed 1q` +uname -m = `(uname -m) 2>/dev/null || echo unknown` +uname -r = `(uname -r) 2>/dev/null || echo unknown` +uname -s = `(uname -s) 2>/dev/null || echo unknown` +uname -v = `(uname -v) 2>/dev/null || echo unknown` + +/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown` +/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown` + +/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown` +/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown` +/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown` +/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown` +/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown` +/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown` +/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown` + +_ASUNAME + +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + echo "PATH: $as_dir" +done +IFS=$as_save_IFS + +} >&5 + +cat >&5 <<_ACEOF + + +## ----------- ## +## Core tests. ## +## ----------- ## + +_ACEOF + + +# Keep a trace of the command line. +# Strip out --no-create and --no-recursion so they do not pile up. +# Strip out --silent because we don't want to record it for future runs. +# Also quote any args containing shell meta-characters. +# Make two passes to allow for proper duplicate-argument suppression. +ac_configure_args= +ac_configure_args0= +ac_configure_args1= +ac_must_keep_next=false +for ac_pass in 1 2 +do + for ac_arg + do + case $ac_arg in + -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + continue ;; + *\'*) + ac_arg=`echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;; + esac + case $ac_pass in + 1) ac_configure_args0="$ac_configure_args0 '$ac_arg'" ;; + 2) + ac_configure_args1="$ac_configure_args1 '$ac_arg'" + if test $ac_must_keep_next = true; then + ac_must_keep_next=false # Got value, back to normal. + else + case $ac_arg in + *=* | --config-cache | -C | -disable-* | --disable-* \ + | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \ + | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \ + | -with-* | --with-* | -without-* | --without-* | --x) + case "$ac_configure_args0 " in + "$ac_configure_args1"*" '$ac_arg' "* ) continue ;; + esac + ;; + -* ) ac_must_keep_next=true ;; + esac + fi + ac_configure_args="$ac_configure_args '$ac_arg'" + ;; + esac + done +done +$as_unset ac_configure_args0 || test "${ac_configure_args0+set}" != set || { ac_configure_args0=; export ac_configure_args0; } +$as_unset ac_configure_args1 || test "${ac_configure_args1+set}" != set || { ac_configure_args1=; export ac_configure_args1; } + +# When interrupted or exit'd, cleanup temporary files, and complete +# config.log. We remove comments because anyway the quotes in there +# would cause problems or look ugly. +# WARNING: Use '\'' to represent an apostrophe within the trap. +# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug. +trap 'exit_status=$? + # Save into config.log some information that might help in debugging. + { + echo + + cat <<\_ASBOX +## ---------------- ## +## Cache variables. ## +## ---------------- ## +_ASBOX + echo + # The following way of writing the cache mishandles newlines in values, +( + for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 +echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + *) $as_unset $ac_var ;; + esac ;; + esac + done + (set) 2>&1 | + case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + sed -n \ + "s/'\''/'\''\\\\'\'''\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p" + ;; #( + *) + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) + echo + + cat <<\_ASBOX +## ----------------- ## +## Output variables. ## +## ----------------- ## +_ASBOX + echo + for ac_var in $ac_subst_vars + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + echo "$ac_var='\''$ac_val'\''" + done | sort + echo + + if test -n "$ac_subst_files"; then + cat <<\_ASBOX +## ------------------- ## +## File substitutions. ## +## ------------------- ## +_ASBOX + echo + for ac_var in $ac_subst_files + do + eval ac_val=\$$ac_var + case $ac_val in + *\'\''*) ac_val=`echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;; + esac + echo "$ac_var='\''$ac_val'\''" + done | sort + echo + fi + + if test -s confdefs.h; then + cat <<\_ASBOX +## ----------- ## +## confdefs.h. ## +## ----------- ## +_ASBOX + echo + cat confdefs.h + echo + fi + test "$ac_signal" != 0 && + echo "$as_me: caught signal $ac_signal" + echo "$as_me: exit $exit_status" + } >&5 + rm -f core *.core core.conftest.* && + rm -f -r conftest* confdefs* conf$$* $ac_clean_files && + exit $exit_status +' 0 +for ac_signal in 1 2 13 15; do + trap 'ac_signal='$ac_signal'; { (exit 1); exit 1; }' $ac_signal +done +ac_signal=0 + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -f -r conftest* confdefs.h + +# Predefined preprocessor variables. + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_NAME "$PACKAGE_NAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_TARNAME "$PACKAGE_TARNAME" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_VERSION "$PACKAGE_VERSION" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_STRING "$PACKAGE_STRING" +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT" +_ACEOF + + +# Let the site file select an alternate cache file if it wants to. +# Prefer explicitly selected file to automatically selected ones. +if test -n "$CONFIG_SITE"; then + set x "$CONFIG_SITE" +elif test "x$prefix" != xNONE; then + set x "$prefix/share/config.site" "$prefix/etc/config.site" +else + set x "$ac_default_prefix/share/config.site" \ + "$ac_default_prefix/etc/config.site" +fi +shift +for ac_site_file +do + if test -r "$ac_site_file"; then + { echo "$as_me:$LINENO: loading site script $ac_site_file" >&5 +echo "$as_me: loading site script $ac_site_file" >&6;} + sed 's/^/| /' "$ac_site_file" >&5 + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special + # files actually), so we avoid doing that. + if test -f "$cache_file"; then + { echo "$as_me:$LINENO: loading cache $cache_file" >&5 +echo "$as_me: loading cache $cache_file" >&6;} + case $cache_file in + [\\/]* | ?:[\\/]* ) . "$cache_file";; + *) . "./$cache_file";; + esac + fi +else + { echo "$as_me:$LINENO: creating cache $cache_file" >&5 +echo "$as_me: creating cache $cache_file" >&6;} + >$cache_file +fi + +# Check that the precious variables saved in the cache have kept the same +# value. +ac_cache_corrupted=false +for ac_var in $ac_precious_vars; do + eval ac_old_set=\$ac_cv_env_${ac_var}_set + eval ac_new_set=\$ac_env_${ac_var}_set + eval ac_old_val=\$ac_cv_env_${ac_var}_value + eval ac_new_val=\$ac_env_${ac_var}_value + case $ac_old_set,$ac_new_set in + set,) + { echo "$as_me:$LINENO: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,set) + { echo "$as_me:$LINENO: error: \`$ac_var' was not set in the previous run" >&5 +echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;} + ac_cache_corrupted=: ;; + ,);; + *) + if test "x$ac_old_val" != "x$ac_new_val"; then + { echo "$as_me:$LINENO: error: \`$ac_var' has changed since the previous run:" >&5 +echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;} + { echo "$as_me:$LINENO: former value: $ac_old_val" >&5 +echo "$as_me: former value: $ac_old_val" >&2;} + { echo "$as_me:$LINENO: current value: $ac_new_val" >&5 +echo "$as_me: current value: $ac_new_val" >&2;} + ac_cache_corrupted=: + fi;; + esac + # Pass precious variables to config.status. + if test "$ac_new_set" = set; then + case $ac_new_val in + *\'*) ac_arg=$ac_var=`echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;; + *) ac_arg=$ac_var=$ac_new_val ;; + esac + case " $ac_configure_args " in + *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy. + *) ac_configure_args="$ac_configure_args '$ac_arg'" ;; + esac + fi +done +if $ac_cache_corrupted; then + { echo "$as_me:$LINENO: error: changes in the environment can compromise the build" >&5 +echo "$as_me: error: changes in the environment can compromise the build" >&2;} + { { echo "$as_me:$LINENO: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&5 +echo "$as_me: error: run \`make distclean' and/or \`rm $cache_file' and start over" >&2;} + { (exit 1); exit 1; }; } +fi + + + + + + + + + + + + + + + + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +ac_config_headers="$ac_config_headers config.h" + + +# Checks for programs. +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$ac_cv_prog_CC"; then + ac_ct_CC=$CC + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="gcc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +else + CC="$ac_cv_prog_CC" +fi + +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args. +set dummy ${ac_tool_prefix}cc; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="${ac_tool_prefix}cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + fi +fi +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + ac_prog_rejected=no +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# != 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@" + fi +fi +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + +fi +if test -z "$CC"; then + if test -n "$ac_tool_prefix"; then + for ac_prog in cl.exe + do + # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args. +set dummy $ac_tool_prefix$ac_prog; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_CC="$ac_tool_prefix$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +CC=$ac_cv_prog_CC +if test -n "$CC"; then + { echo "$as_me:$LINENO: result: $CC" >&5 +echo "${ECHO_T}$CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + test -n "$CC" && break + done +fi +if test -z "$CC"; then + ac_ct_CC=$CC + for ac_prog in cl.exe +do + # Extract the first word of "$ac_prog", so it can be a program name with args. +set dummy $ac_prog; ac_word=$2 +{ echo "$as_me:$LINENO: checking for $ac_word" >&5 +echo $ECHO_N "checking for $ac_word... $ECHO_C" >&6; } +if test "${ac_cv_prog_ac_ct_CC+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test -n "$ac_ct_CC"; then + ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test. +else +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + ac_cv_prog_ac_ct_CC="$ac_prog" + echo "$as_me:$LINENO: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done +done +IFS=$as_save_IFS + +fi +fi +ac_ct_CC=$ac_cv_prog_ac_ct_CC +if test -n "$ac_ct_CC"; then + { echo "$as_me:$LINENO: result: $ac_ct_CC" >&5 +echo "${ECHO_T}$ac_ct_CC" >&6; } +else + { echo "$as_me:$LINENO: result: no" >&5 +echo "${ECHO_T}no" >&6; } +fi + + + test -n "$ac_ct_CC" && break +done + + if test "x$ac_ct_CC" = x; then + CC="" + else + case $cross_compiling:$ac_tool_warned in +yes:) +{ echo "$as_me:$LINENO: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&5 +echo "$as_me: WARNING: In the future, Autoconf will not detect cross-tools +whose name does not start with the host triplet. If you think this +configuration is useful to you, please write to autoconf@gnu.org." >&2;} +ac_tool_warned=yes ;; +esac + CC=$ac_ct_CC + fi +fi + +fi + + +test -z "$CC" && { { echo "$as_me:$LINENO: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&5 +echo "$as_me: error: no acceptable C compiler found in \$PATH +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + +# Provide some information about the compiler. +echo "$as_me:$LINENO: checking for C compiler version" >&5 +ac_compiler=`set X $ac_compile; echo $2` +{ (ac_try="$ac_compiler --version >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler --version >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -v >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -v >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } +{ (ac_try="$ac_compiler -V >&5" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compiler -V >&5") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } + +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files a.out a.exe b.out" +# Try to create an executable without -o first, disregard a.out. +# It will help us diagnose broken compilers, and finding out an intuition +# of exeext. +{ echo "$as_me:$LINENO: checking for C compiler default output file name" >&5 +echo $ECHO_N "checking for C compiler default output file name... $ECHO_C" >&6; } +ac_link_default=`echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` +# +# List of possible output files, starting from the most likely. +# The algorithm is not robust to junk in `.', hence go to wildcards (a.*) +# only as a last resort. b.out is created by i960 compilers. +ac_files='a_out.exe a.exe conftest.exe a.out conftest a.* conftest.* b.out' +# +# The IRIX 6 linker writes into existing files which may not be +# executable, retaining their permissions. Remove them first so a +# subsequent execution test works. +ac_rmfiles= +for ac_file in $ac_files +do + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; + * ) ac_rmfiles="$ac_rmfiles $ac_file";; + esac +done +rm -f $ac_rmfiles + +if { (ac_try="$ac_link_default" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link_default") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # Autoconf-2.13 could set the ac_cv_exeext variable to `no'. +# So ignore a value of `no', otherwise this would lead to `EXEEXT = no' +# in a Makefile. We should not override ac_cv_exeext if it was cached, +# so that the user can short-circuit this test for compilers unknown to +# Autoconf. +for ac_file in $ac_files '' +do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) + ;; + [ab].out ) + # We found the default executable, but exeext='' is most + # certainly right. + break;; + *.* ) + if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no; + then :; else + ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + fi + # We set ac_cv_exeext here because the later test for it is not + # safe: cross compilers may not add the suffix if given an `-o' + # argument, so we may need to know it at that point already. + # Even if this section looks crufty: it has the advantage of + # actually working. + break;; + * ) + break;; + esac +done +test "$ac_cv_exeext" = no && ac_cv_exeext= + +else + ac_file='' +fi + +{ echo "$as_me:$LINENO: result: $ac_file" >&5 +echo "${ECHO_T}$ac_file" >&6; } +if test -z "$ac_file"; then + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: C compiler cannot create executables +See \`config.log' for more details." >&5 +echo "$as_me: error: C compiler cannot create executables +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } +fi + +ac_exeext=$ac_cv_exeext + +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ echo "$as_me:$LINENO: checking whether the C compiler works" >&5 +echo $ECHO_N "checking whether the C compiler works... $ECHO_C" >&6; } +# FIXME: These cross compiler hacks should be removed for Autoconf 3.0 +# If not cross compiling, check that we can run a simple program. +if test "$cross_compiling" != yes; then + if { ac_try='./$ac_file' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { echo "$as_me:$LINENO: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } + fi + fi +fi +{ echo "$as_me:$LINENO: result: yes" >&5 +echo "${ECHO_T}yes" >&6; } + +rm -f a.out a.exe conftest$ac_cv_exeext b.out +ac_clean_files=$ac_clean_files_save +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ echo "$as_me:$LINENO: checking whether we are cross compiling" >&5 +echo $ECHO_N "checking whether we are cross compiling... $ECHO_C" >&6; } +{ echo "$as_me:$LINENO: result: $cross_compiling" >&5 +echo "${ECHO_T}$cross_compiling" >&6; } + +{ echo "$as_me:$LINENO: checking for suffix of executables" >&5 +echo $ECHO_N "checking for suffix of executables... $ECHO_C" >&6; } +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + # If both `conftest.exe' and `conftest' are `present' (well, observable) +# catch `conftest.exe'. For instance with Cygwin, `ls conftest' will +# work properly (i.e., refer to `conftest.exe'), while it won't with +# `rm'. +for ac_file in conftest.exe conftest conftest.*; do + test -f "$ac_file" || continue + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.o | *.obj ) ;; + *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'` + break;; + * ) break;; + esac +done +else + { { echo "$as_me:$LINENO: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest$ac_cv_exeext +{ echo "$as_me:$LINENO: result: $ac_cv_exeext" >&5 +echo "${ECHO_T}$ac_cv_exeext" >&6; } + +rm -f conftest.$ac_ext +EXEEXT=$ac_cv_exeext +ac_exeext=$EXEEXT +{ echo "$as_me:$LINENO: checking for suffix of object files" >&5 +echo $ECHO_N "checking for suffix of object files... $ECHO_C" >&6; } +if test "${ac_cv_objext+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.o conftest.obj +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; then + for ac_file in conftest.o conftest.obj conftest.*; do + test -f "$ac_file" || continue; + case $ac_file in + *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf ) ;; + *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'` + break;; + esac +done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +{ { echo "$as_me:$LINENO: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute suffix of object files: cannot compile +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +rm -f conftest.$ac_cv_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_objext" >&5 +echo "${ECHO_T}$ac_cv_objext" >&6; } +OBJEXT=$ac_cv_objext +ac_objext=$OBJEXT +{ echo "$as_me:$LINENO: checking whether we are using the GNU C compiler" >&5 +echo $ECHO_N "checking whether we are using the GNU C compiler... $ECHO_C" >&6; } +if test "${ac_cv_c_compiler_gnu+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +#ifndef __GNUC__ + choke me +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_compiler_gnu=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_compiler_gnu=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +ac_cv_c_compiler_gnu=$ac_compiler_gnu + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_c_compiler_gnu" >&5 +echo "${ECHO_T}$ac_cv_c_compiler_gnu" >&6; } +GCC=`test $ac_compiler_gnu = yes && echo yes` +ac_test_CFLAGS=${CFLAGS+set} +ac_save_CFLAGS=$CFLAGS +{ echo "$as_me:$LINENO: checking whether $CC accepts -g" >&5 +echo $ECHO_N "checking whether $CC accepts -g... $ECHO_C" >&6; } +if test "${ac_cv_prog_cc_g+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_save_c_werror_flag=$ac_c_werror_flag + ac_c_werror_flag=yes + ac_cv_prog_cc_g=no + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + CFLAGS="" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_c_werror_flag=$ac_save_c_werror_flag + CFLAGS="-g" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_g=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag=$ac_save_c_werror_flag +fi +{ echo "$as_me:$LINENO: result: $ac_cv_prog_cc_g" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_g" >&6; } +if test "$ac_test_CFLAGS" = set; then + CFLAGS=$ac_save_CFLAGS +elif test $ac_cv_prog_cc_g = yes; then + if test "$GCC" = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-g" + fi +else + if test "$GCC" = yes; then + CFLAGS="-O2" + else + CFLAGS= + fi +fi +{ echo "$as_me:$LINENO: checking for $CC option to accept ISO C89" >&5 +echo $ECHO_N "checking for $CC option to accept ISO C89... $ECHO_C" >&6; } +if test "${ac_cv_prog_cc_c89+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_prog_cc_c89=no +ac_save_CC=$CC +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include +/* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ +struct buf { int x; }; +FILE * (*rcsopen) (struct buf *, struct stat *, int); +static char *e (p, i) + char **p; + int i; +{ + return p[i]; +} +static char *f (char * (*g) (char **, int), char **p, ...) +{ + char *s; + va_list v; + va_start (v,p); + s = g (p, va_arg (v,int)); + va_end (v); + return s; +} + +/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has + function prototypes and stuff, but not '\xHH' hex character constants. + These don't provoke an error unfortunately, instead are silently treated + as 'x'. The following induces an error, until -std is added to get + proper ANSI mode. Curiously '\x00'!='x' always comes out true, for an + array size at least. It's necessary to write '\x00'==0 to get something + that's true only with -std. */ +int osf4_cc_array ['\x00' == 0 ? 1 : -1]; + +/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters + inside strings and character constants. */ +#define FOO(x) 'x' +int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1]; + +int test (int i, double x); +struct s1 {int (*f) (int a);}; +struct s2 {int (*f) (double a);}; +int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int); +int argc; +char **argv; +int +main () +{ +return f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]; + ; + return 0; +} +_ACEOF +for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \ + -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__" +do + CC="$ac_save_CC $ac_arg" + rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_prog_cc_c89=$ac_arg +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext + test "x$ac_cv_prog_cc_c89" != "xno" && break +done +rm -f conftest.$ac_ext +CC=$ac_save_CC + +fi +# AC_CACHE_VAL +case "x$ac_cv_prog_cc_c89" in + x) + { echo "$as_me:$LINENO: result: none needed" >&5 +echo "${ECHO_T}none needed" >&6; } ;; + xno) + { echo "$as_me:$LINENO: result: unsupported" >&5 +echo "${ECHO_T}unsupported" >&6; } ;; + *) + CC="$CC $ac_cv_prog_cc_c89" + { echo "$as_me:$LINENO: result: $ac_cv_prog_cc_c89" >&5 +echo "${ECHO_T}$ac_cv_prog_cc_c89" >&6; } ;; +esac + + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +# Checks for header files. + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu +{ echo "$as_me:$LINENO: checking how to run the C preprocessor" >&5 +echo $ECHO_N "checking how to run the C preprocessor... $ECHO_C" >&6; } +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then + if test "${ac_cv_prog_CPP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Double quotes because CPP needs to be expanded + for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp" + do + ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi + +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi + +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + break +fi + + done + ac_cv_prog_CPP=$CPP + +fi + CPP=$ac_cv_prog_CPP +else + ac_cv_prog_CPP=$CPP +fi +{ echo "$as_me:$LINENO: result: $CPP" >&5 +echo "${ECHO_T}$CPP" >&6; } +ac_preproc_ok=false +for ac_c_preproc_warn_flag in '' yes +do + # Use a header file that comes with gcc, so configuring glibc + # with a fresh cross-compiler works. + # Prefer to if __STDC__ is defined, since + # exists even on freestanding compilers. + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. "Syntax error" is here to catch this case. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#ifdef __STDC__ +# include +#else +# include +#endif + Syntax error +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Broken: fails on valid input. +continue +fi + +rm -f conftest.err conftest.$ac_ext + + # OK, works on sane cases. Now check whether nonexistent headers + # can be detected and how. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + # Broken: success on invalid input. +continue +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # Passes both tests. +ac_preproc_ok=: +break +fi + +rm -f conftest.err conftest.$ac_ext + +done +# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. +rm -f conftest.err conftest.$ac_ext +if $ac_preproc_ok; then + : +else + { { echo "$as_me:$LINENO: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&5 +echo "$as_me: error: C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details." >&2;} + { (exit 1); exit 1; }; } +fi + +ac_ext=c +ac_cpp='$CPP $CPPFLAGS' +ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' +ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5' +ac_compiler_gnu=$ac_cv_c_compiler_gnu + + +{ echo "$as_me:$LINENO: checking for grep that handles long lines and -e" >&5 +echo $ECHO_N "checking for grep that handles long lines and -e... $ECHO_C" >&6; } +if test "${ac_cv_path_GREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # Extract the first word of "grep ggrep" to use in msg output +if test -z "$GREP"; then +set dummy grep ggrep; ac_prog_name=$2 +if test "${ac_cv_path_GREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_path_GREP_found=false +# Loop through the user's path and test for each of PROGNAME-LIST +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in grep ggrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue + # Check for GNU ac_path_GREP and select it if it is found. + # Check for GNU $ac_path_GREP +case `"$ac_path_GREP" --version 2>&1` in +*GNU*) + ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;; +*) + ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + echo 'GREP' >> "conftest.nl" + "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + ac_count=`expr $ac_count + 1` + if test $ac_count -gt ${ac_path_GREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_GREP="$ac_path_GREP" + ac_path_GREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + + $ac_path_GREP_found && break 3 + done +done + +done +IFS=$as_save_IFS + + +fi + +GREP="$ac_cv_path_GREP" +if test -z "$GREP"; then + { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } +fi + +else + ac_cv_path_GREP=$GREP +fi + + +fi +{ echo "$as_me:$LINENO: result: $ac_cv_path_GREP" >&5 +echo "${ECHO_T}$ac_cv_path_GREP" >&6; } + GREP="$ac_cv_path_GREP" + + +{ echo "$as_me:$LINENO: checking for egrep" >&5 +echo $ECHO_N "checking for egrep... $ECHO_C" >&6; } +if test "${ac_cv_path_EGREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 + then ac_cv_path_EGREP="$GREP -E" + else + # Extract the first word of "egrep" to use in msg output +if test -z "$EGREP"; then +set dummy egrep; ac_prog_name=$2 +if test "${ac_cv_path_EGREP+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_path_EGREP_found=false +# Loop through the user's path and test for each of PROGNAME-LIST +as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_prog in egrep; do + for ac_exec_ext in '' $ac_executable_extensions; do + ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" + { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue + # Check for GNU ac_path_EGREP and select it if it is found. + # Check for GNU $ac_path_EGREP +case `"$ac_path_EGREP" --version 2>&1` in +*GNU*) + ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;; +*) + ac_count=0 + echo $ECHO_N "0123456789$ECHO_C" >"conftest.in" + while : + do + cat "conftest.in" "conftest.in" >"conftest.tmp" + mv "conftest.tmp" "conftest.in" + cp "conftest.in" "conftest.nl" + echo 'EGREP' >> "conftest.nl" + "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break + diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break + ac_count=`expr $ac_count + 1` + if test $ac_count -gt ${ac_path_EGREP_max-0}; then + # Best one so far, save it but keep looking for a better one + ac_cv_path_EGREP="$ac_path_EGREP" + ac_path_EGREP_max=$ac_count + fi + # 10*(2^10) chars as input seems more than enough + test $ac_count -gt 10 && break + done + rm -f conftest.in conftest.tmp conftest.nl conftest.out;; +esac + + + $ac_path_EGREP_found && break 3 + done +done + +done +IFS=$as_save_IFS + + +fi + +EGREP="$ac_cv_path_EGREP" +if test -z "$EGREP"; then + { { echo "$as_me:$LINENO: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&5 +echo "$as_me: error: no acceptable $ac_prog_name could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" >&2;} + { (exit 1); exit 1; }; } +fi + +else + ac_cv_path_EGREP=$EGREP +fi + + + fi +fi +{ echo "$as_me:$LINENO: result: $ac_cv_path_EGREP" >&5 +echo "${ECHO_T}$ac_cv_path_EGREP" >&6; } + EGREP="$ac_cv_path_EGREP" + + +{ echo "$as_me:$LINENO: checking for ANSI C header files" >&5 +echo $ECHO_N "checking for ANSI C header files... $ECHO_C" >&6; } +if test "${ac_cv_header_stdc+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#include +#include + +int +main () +{ + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_header_stdc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_header_stdc=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "memchr" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include + +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "free" >/dev/null 2>&1; then + : +else + ac_cv_header_stdc=no +fi +rm -f conftest* + +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. + if test "$cross_compiling" = yes; then + : +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include +#if ((' ' & 0x0FF) == 0x020) +# define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#else +# define ISLOWER(c) \ + (('a' <= (c) && (c) <= 'i') \ + || ('j' <= (c) && (c) <= 'r') \ + || ('s' <= (c) && (c) <= 'z')) +# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c)) +#endif + +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int +main () +{ + int i; + for (i = 0; i < 256; i++) + if (XOR (islower (i), ISLOWER (i)) + || toupper (i) != TOUPPER (i)) + return 2; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + : +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_header_stdc=no +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi +fi +{ echo "$as_me:$LINENO: result: $ac_cv_header_stdc" >&5 +echo "${ECHO_T}$ac_cv_header_stdc" >&6; } +if test $ac_cv_header_stdc = yes; then + +cat >>confdefs.h <<\_ACEOF +#define STDC_HEADERS 1 +_ACEOF + +fi + +# On IRIX 5.3, sys/types and inttypes.h are conflicting. + + + + + + + + + +for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \ + inttypes.h stdint.h unistd.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + eval "$as_ac_Header=yes" +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + eval "$as_ac_Header=no" +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + + + + + +for ac_header in sys/socket.h netinet/in.h arpa/inet.h netdb.h +do +as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh` +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + { echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } +else + # Is the header compilable? +{ echo "$as_me:$LINENO: checking $ac_header usability" >&5 +echo $ECHO_N "checking $ac_header usability... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +#include <$ac_header> +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_header_compiler=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_compiler=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5 +echo "${ECHO_T}$ac_header_compiler" >&6; } + +# Is the header present? +{ echo "$as_me:$LINENO: checking $ac_header presence" >&5 +echo $ECHO_N "checking $ac_header presence... $ECHO_C" >&6; } +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include <$ac_header> +_ACEOF +if { (ac_try="$ac_cpp conftest.$ac_ext" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } >/dev/null && { + test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || + test ! -s conftest.err + }; then + ac_header_preproc=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_header_preproc=no +fi + +rm -f conftest.err conftest.$ac_ext +{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5 +echo "${ECHO_T}$ac_header_preproc" >&6; } + +# So? What about this header? +case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in + yes:no: ) + { echo "$as_me:$LINENO: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&5 +echo "$as_me: WARNING: $ac_header: accepted by the compiler, rejected by the preprocessor!" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the compiler's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the compiler's result" >&2;} + ac_header_preproc=yes + ;; + no:yes:* ) + { echo "$as_me:$LINENO: WARNING: $ac_header: present but cannot be compiled" >&5 +echo "$as_me: WARNING: $ac_header: present but cannot be compiled" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: check for missing prerequisite headers?" >&5 +echo "$as_me: WARNING: $ac_header: check for missing prerequisite headers?" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: see the Autoconf documentation" >&5 +echo "$as_me: WARNING: $ac_header: see the Autoconf documentation" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&5 +echo "$as_me: WARNING: $ac_header: section \"Present But Cannot Be Compiled\"" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: proceeding with the preprocessor's result" >&5 +echo "$as_me: WARNING: $ac_header: proceeding with the preprocessor's result" >&2;} + { echo "$as_me:$LINENO: WARNING: $ac_header: in the future, the compiler will take precedence" >&5 +echo "$as_me: WARNING: $ac_header: in the future, the compiler will take precedence" >&2;} + + ;; +esac +{ echo "$as_me:$LINENO: checking for $ac_header" >&5 +echo $ECHO_N "checking for $ac_header... $ECHO_C" >&6; } +if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + eval "$as_ac_Header=\$ac_header_preproc" +fi +ac_res=`eval echo '${'$as_ac_Header'}'` + { echo "$as_me:$LINENO: result: $ac_res" >&5 +echo "${ECHO_T}$ac_res" >&6; } + +fi +if test `eval echo '${'$as_ac_Header'}'` = yes; then + cat >>confdefs.h <<_ACEOF +#define `echo "HAVE_$ac_header" | $as_tr_cpp` 1 +_ACEOF + +fi + +done + + +# Checks for typedefs, structures, and compiler characteristics. +{ echo "$as_me:$LINENO: checking for an ANSI C-conforming const" >&5 +echo $ECHO_N "checking for an ANSI C-conforming const... $ECHO_C" >&6; } +if test "${ac_cv_c_const+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +int +main () +{ +/* FIXME: Include the comments suggested by Paul. */ +#ifndef __cplusplus + /* Ultrix mips cc rejects this. */ + typedef int charset[2]; + const charset cs; + /* SunOS 4.1.1 cc rejects this. */ + char const *const *pcpcc; + char **ppc; + /* NEC SVR4.0.2 mips cc rejects this. */ + struct point {int x, y;}; + static struct point const zero = {0,0}; + /* AIX XL C 1.02.0.0 rejects this. + It does not let you subtract one const X* pointer from another in + an arm of an if-expression whose if-part is not a constant + expression */ + const char *g = "string"; + pcpcc = &g + (g ? g-g : 0); + /* HPUX 7.0 cc rejects these. */ + ++pcpcc; + ppc = (char**) pcpcc; + pcpcc = (char const *const *) ppc; + { /* SCO 3.2v4 cc rejects this. */ + char *t; + char const *s = 0 ? (char *) 0 : (char const *) 0; + + *t++ = 0; + if (s) return 0; + } + { /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ + int x[] = {25, 17}; + const int *foo = &x[0]; + ++foo; + } + { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ + typedef const int *iptr; + iptr p = 0; + ++p; + } + { /* AIX XL C 1.02.0.0 rejects this saying + "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ + struct s { int j; const int *ap[3]; }; + struct s *b; b->j = 5; + } + { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; + if (!foo) return 0; + } + return !cs[0] && !zero.x; +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_c_const=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_c_const=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_c_const" >&5 +echo "${ECHO_T}$ac_cv_c_const" >&6; } +if test $ac_cv_c_const = no; then + +cat >>confdefs.h <<\_ACEOF +#define const +_ACEOF + +fi + + + { echo "$as_me:$LINENO: checking for int32_t" >&5 +echo $ECHO_N "checking for int32_t... $ECHO_C" >&6; } +if test "${ac_cv_c_int32_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_c_int32_t=no + for ac_type in 'int32_t' 'int' 'long int' \ + 'long long int' 'short int' 'signed char'; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(0 < ($ac_type) (((($ac_type) 1 << (32 - 2)) - 1) * 2 + 1))]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(($ac_type) (((($ac_type) 1 << (32 - 2)) - 1) * 2 + 1) + < ($ac_type) (((($ac_type) 1 << (32 - 2)) - 1) * 2 + 2))]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + : +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + case $ac_type in + int32_t) ac_cv_c_int32_t=yes ;; + *) ac_cv_c_int32_t=$ac_type ;; +esac + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + test "$ac_cv_c_int32_t" != no && break + done +fi +{ echo "$as_me:$LINENO: result: $ac_cv_c_int32_t" >&5 +echo "${ECHO_T}$ac_cv_c_int32_t" >&6; } + case $ac_cv_c_int32_t in #( + no|yes) ;; #( + *) + +cat >>confdefs.h <<_ACEOF +#define int32_t $ac_cv_c_int32_t +_ACEOF +;; + esac + + + { echo "$as_me:$LINENO: checking for uint16_t" >&5 +echo $ECHO_N "checking for uint16_t... $ECHO_C" >&6; } +if test "${ac_cv_c_uint16_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_c_uint16_t=no + for ac_type in 'uint16_t' 'unsigned int' 'unsigned long int' \ + 'unsigned long long int' 'unsigned short int' 'unsigned char'; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(($ac_type) -1 >> (16 - 1) == 1)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + case $ac_type in + uint16_t) ac_cv_c_uint16_t=yes ;; + *) ac_cv_c_uint16_t=$ac_type ;; +esac + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + test "$ac_cv_c_uint16_t" != no && break + done +fi +{ echo "$as_me:$LINENO: result: $ac_cv_c_uint16_t" >&5 +echo "${ECHO_T}$ac_cv_c_uint16_t" >&6; } + case $ac_cv_c_uint16_t in #( + no|yes) ;; #( + *) + + +cat >>confdefs.h <<_ACEOF +#define uint16_t $ac_cv_c_uint16_t +_ACEOF +;; + esac + + + { echo "$as_me:$LINENO: checking for uint32_t" >&5 +echo $ECHO_N "checking for uint32_t... $ECHO_C" >&6; } +if test "${ac_cv_c_uint32_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_c_uint32_t=no + for ac_type in 'uint32_t' 'unsigned int' 'unsigned long int' \ + 'unsigned long long int' 'unsigned short int' 'unsigned char'; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(($ac_type) -1 >> (32 - 1) == 1)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + case $ac_type in + uint32_t) ac_cv_c_uint32_t=yes ;; + *) ac_cv_c_uint32_t=$ac_type ;; +esac + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + test "$ac_cv_c_uint32_t" != no && break + done +fi +{ echo "$as_me:$LINENO: result: $ac_cv_c_uint32_t" >&5 +echo "${ECHO_T}$ac_cv_c_uint32_t" >&6; } + case $ac_cv_c_uint32_t in #( + no|yes) ;; #( + *) + +cat >>confdefs.h <<\_ACEOF +#define _UINT32_T 1 +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define uint32_t $ac_cv_c_uint32_t +_ACEOF +;; + esac + + + { echo "$as_me:$LINENO: checking for uint8_t" >&5 +echo $ECHO_N "checking for uint8_t... $ECHO_C" >&6; } +if test "${ac_cv_c_uint8_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_cv_c_uint8_t=no + for ac_type in 'uint8_t' 'unsigned int' 'unsigned long int' \ + 'unsigned long long int' 'unsigned short int' 'unsigned char'; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !(($ac_type) -1 >> (8 - 1) == 1)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + case $ac_type in + uint8_t) ac_cv_c_uint8_t=yes ;; + *) ac_cv_c_uint8_t=$ac_type ;; +esac + +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + test "$ac_cv_c_uint8_t" != no && break + done +fi +{ echo "$as_me:$LINENO: result: $ac_cv_c_uint8_t" >&5 +echo "${ECHO_T}$ac_cv_c_uint8_t" >&6; } + case $ac_cv_c_uint8_t in #( + no|yes) ;; #( + *) + +cat >>confdefs.h <<\_ACEOF +#define _UINT8_T 1 +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define uint8_t $ac_cv_c_uint8_t +_ACEOF +;; + esac + + +# Checks for library functions. +if test $ac_cv_c_compiler_gnu = yes; then + { echo "$as_me:$LINENO: checking whether $CC needs -traditional" >&5 +echo $ECHO_N "checking whether $CC needs -traditional... $ECHO_C" >&6; } +if test "${ac_cv_prog_gcc_traditional+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_pattern="Autoconf.*'x'" + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +Autoconf TIOCGETP +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "$ac_pattern" >/dev/null 2>&1; then + ac_cv_prog_gcc_traditional=yes +else + ac_cv_prog_gcc_traditional=no +fi +rm -f conftest* + + + if test $ac_cv_prog_gcc_traditional = no; then + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +Autoconf TCGETA +_ACEOF +if (eval "$ac_cpp conftest.$ac_ext") 2>&5 | + $EGREP "$ac_pattern" >/dev/null 2>&1; then + ac_cv_prog_gcc_traditional=yes +fi +rm -f conftest* + + fi +fi +{ echo "$as_me:$LINENO: result: $ac_cv_prog_gcc_traditional" >&5 +echo "${ECHO_T}$ac_cv_prog_gcc_traditional" >&6; } + if test $ac_cv_prog_gcc_traditional = yes; then + CC="$CC -traditional" + fi +fi + + + + + + + + +{ echo "$as_me:$LINENO: checking for library containing gethostbyname" >&5 +echo $ECHO_N "checking for library containing gethostbyname... $ECHO_C" >&6; } +if test "${ac_cv_search_gethostbyname+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$LIBS +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char gethostbyname (); +int +main () +{ +return gethostbyname (); + ; + return 0; +} +_ACEOF +for ac_lib in '' nsl; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_search_gethostbyname=$ac_res +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext + if test "${ac_cv_search_gethostbyname+set}" = set; then + break +fi +done +if test "${ac_cv_search_gethostbyname+set}" = set; then + : +else + ac_cv_search_gethostbyname=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_search_gethostbyname" >&5 +echo "${ECHO_T}$ac_cv_search_gethostbyname" >&6; } +ac_res=$ac_cv_search_gethostbyname +if test "$ac_res" != no; then + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + + cat >>confdefs.h <<\_ACEOF +#define HAVE_GETHOSTBYNAME 1 +_ACEOF + +fi + + + + +{ echo "$as_me:$LINENO: checking for library containing inet_aton" >&5 +echo $ECHO_N "checking for library containing inet_aton... $ECHO_C" >&6; } +if test "${ac_cv_search_inet_aton+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$LIBS +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char inet_aton (); +int +main () +{ +return inet_aton (); + ; + return 0; +} +_ACEOF +for ac_lib in '' socket; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_search_inet_aton=$ac_res +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext + if test "${ac_cv_search_inet_aton+set}" = set; then + break +fi +done +if test "${ac_cv_search_inet_aton+set}" = set; then + : +else + ac_cv_search_inet_aton=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_search_inet_aton" >&5 +echo "${ECHO_T}$ac_cv_search_inet_aton" >&6; } +ac_res=$ac_cv_search_inet_aton +if test "$ac_res" != no; then + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + + cat >>confdefs.h <<\_ACEOF +#define HAVE_INET_ATON 1 +_ACEOF + +fi + + + + +{ echo "$as_me:$LINENO: checking for library containing inet_pton" >&5 +echo $ECHO_N "checking for library containing inet_pton... $ECHO_C" >&6; } +if test "${ac_cv_search_inet_pton+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$LIBS +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char inet_pton (); +int +main () +{ +return inet_pton (); + ; + return 0; +} +_ACEOF +for ac_lib in '' socket; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_search_inet_pton=$ac_res +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext + if test "${ac_cv_search_inet_pton+set}" = set; then + break +fi +done +if test "${ac_cv_search_inet_pton+set}" = set; then + : +else + ac_cv_search_inet_pton=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_search_inet_pton" >&5 +echo "${ECHO_T}$ac_cv_search_inet_pton" >&6; } +ac_res=$ac_cv_search_inet_pton +if test "$ac_res" != no; then + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + + cat >>confdefs.h <<\_ACEOF +#define HAVE_INET_PTON 1 +_ACEOF + +fi + + + + +{ echo "$as_me:$LINENO: checking for library containing inet_addr" >&5 +echo $ECHO_N "checking for library containing inet_addr... $ECHO_C" >&6; } +if test "${ac_cv_search_inet_addr+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + ac_func_search_save_LIBS=$LIBS +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ + +/* Override any GCC internal prototype to avoid an error. + Use char because int might match the return type of a GCC + builtin and then its argument prototype would still apply. */ +#ifdef __cplusplus +extern "C" +#endif +char inet_addr (); +int +main () +{ +return inet_addr (); + ; + return 0; +} +_ACEOF +for ac_lib in '' socket; do + if test -z "$ac_lib"; then + ac_res="none required" + else + ac_res=-l$ac_lib + LIBS="-l$ac_lib $ac_func_search_save_LIBS" + fi + rm -f conftest.$ac_objext conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest$ac_exeext && + $as_test_x conftest$ac_exeext; then + ac_cv_search_inet_addr=$ac_res +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \ + conftest$ac_exeext + if test "${ac_cv_search_inet_addr+set}" = set; then + break +fi +done +if test "${ac_cv_search_inet_addr+set}" = set; then + : +else + ac_cv_search_inet_addr=no +fi +rm conftest.$ac_ext +LIBS=$ac_func_search_save_LIBS +fi +{ echo "$as_me:$LINENO: result: $ac_cv_search_inet_addr" >&5 +echo "${ECHO_T}$ac_cv_search_inet_addr" >&6; } +ac_res=$ac_cv_search_inet_addr +if test "$ac_res" != no; then + test "$ac_res" = "none required" || LIBS="$ac_res $LIBS" + + cat >>confdefs.h <<\_ACEOF +#define HAVE_INET_ADDR 1 +_ACEOF + +fi + + +{ echo "$as_me:$LINENO: checking whether byte ordering is bigendian" >&5 +echo $ECHO_N "checking whether byte ordering is bigendian... $ECHO_C" >&6; } +if test "${ac_cv_c_bigendian+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + # See if sys/param.h defines the BYTE_ORDER macro. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include + +int +main () +{ +#if ! (defined BYTE_ORDER && defined BIG_ENDIAN && defined LITTLE_ENDIAN \ + && BYTE_ORDER && BIG_ENDIAN && LITTLE_ENDIAN) + bogus endian macros +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + # It does; now see whether it defined to BIG_ENDIAN or not. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +#include +#include + +int +main () +{ +#if BYTE_ORDER != BIG_ENDIAN + not big endian +#endif + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_c_bigendian=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_c_bigendian=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + # It does not; compile a test program. +if test "$cross_compiling" = yes; then + # try to guess the endianness by grepping values into an object file + ac_cv_c_bigendian=unknown + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; +short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; +void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; } +short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; +short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; +void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; } +int +main () +{ + _ascii (); _ebcdic (); + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then + ac_cv_c_bigendian=yes +fi +if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then + if test "$ac_cv_c_bigendian" = unknown; then + ac_cv_c_bigendian=no + else + # finding both strings is unlikely to happen, but who knows? + ac_cv_c_bigendian=unknown + fi +fi +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ + + /* Are we little or big endian? From Harbison&Steele. */ + union + { + long int l; + char c[sizeof (long int)]; + } u; + u.l = 1; + return u.c[sizeof (long int) - 1] == 1; + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_c_bigendian=no +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +ac_cv_c_bigendian=yes +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi + + +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_c_bigendian" >&5 +echo "${ECHO_T}$ac_cv_c_bigendian" >&6; } +case $ac_cv_c_bigendian in + yes) + +cat >>confdefs.h <<\_ACEOF +#define WORDS_BIGENDIAN 1 +_ACEOF + ;; + no) + ;; + *) + { { echo "$as_me:$LINENO: error: unknown endianness +presetting ac_cv_c_bigendian=no (or yes) will help" >&5 +echo "$as_me: error: unknown endianness +presetting ac_cv_c_bigendian=no (or yes) will help" >&2;} + { (exit 1); exit 1; }; } ;; +esac + +{ echo "$as_me:$LINENO: checking for uint8_t" >&5 +echo $ECHO_N "checking for uint8_t... $ECHO_C" >&6; } +if test "${ac_cv_type_uint8_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +typedef uint8_t ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_uint8_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_uint8_t=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_uint8_t" >&5 +echo "${ECHO_T}$ac_cv_type_uint8_t" >&6; } + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ echo "$as_me:$LINENO: checking size of uint8_t" >&5 +echo $ECHO_N "checking size of uint8_t... $ECHO_C" >&6; } +if test "${ac_cv_sizeof_uint8_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef uint8_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef uint8_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef uint8_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef uint8_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_lo=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo= ac_hi= +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef uint8_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo=`expr '(' $ac_mid ')' + 1` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_uint8_t=$ac_lo;; +'') if test "$ac_cv_type_uint8_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (uint8_t) +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (uint8_t) +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_uint8_t=0 + fi ;; +esac +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef uint8_t ac__type_sizeof_; +static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } +static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + return 1; + if (((long int) (sizeof (ac__type_sizeof_))) < 0) + { + long int i = longval (); + if (i != ((long int) (sizeof (ac__type_sizeof_)))) + return 1; + fprintf (f, "%ld\n", i); + } + else + { + unsigned long int i = ulongval (); + if (i != ((long int) (sizeof (ac__type_sizeof_)))) + return 1; + fprintf (f, "%lu\n", i); + } + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_uint8_t=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +if test "$ac_cv_type_uint8_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (uint8_t) +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (uint8_t) +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_uint8_t=0 + fi +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.val +fi +{ echo "$as_me:$LINENO: result: $ac_cv_sizeof_uint8_t" >&5 +echo "${ECHO_T}$ac_cv_sizeof_uint8_t" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_UINT8_T $ac_cv_sizeof_uint8_t +_ACEOF + + +{ echo "$as_me:$LINENO: checking for uint16_t" >&5 +echo $ECHO_N "checking for uint16_t... $ECHO_C" >&6; } +if test "${ac_cv_type_uint16_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +typedef uint16_t ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_uint16_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_uint16_t=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_uint16_t" >&5 +echo "${ECHO_T}$ac_cv_type_uint16_t" >&6; } + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ echo "$as_me:$LINENO: checking size of uint16_t" >&5 +echo $ECHO_N "checking size of uint16_t... $ECHO_C" >&6; } +if test "${ac_cv_sizeof_uint16_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef uint16_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef uint16_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef uint16_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef uint16_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_lo=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo= ac_hi= +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef uint16_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo=`expr '(' $ac_mid ')' + 1` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_uint16_t=$ac_lo;; +'') if test "$ac_cv_type_uint16_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (uint16_t) +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (uint16_t) +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_uint16_t=0 + fi ;; +esac +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef uint16_t ac__type_sizeof_; +static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } +static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + return 1; + if (((long int) (sizeof (ac__type_sizeof_))) < 0) + { + long int i = longval (); + if (i != ((long int) (sizeof (ac__type_sizeof_)))) + return 1; + fprintf (f, "%ld\n", i); + } + else + { + unsigned long int i = ulongval (); + if (i != ((long int) (sizeof (ac__type_sizeof_)))) + return 1; + fprintf (f, "%lu\n", i); + } + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_uint16_t=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +if test "$ac_cv_type_uint16_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (uint16_t) +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (uint16_t) +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_uint16_t=0 + fi +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.val +fi +{ echo "$as_me:$LINENO: result: $ac_cv_sizeof_uint16_t" >&5 +echo "${ECHO_T}$ac_cv_sizeof_uint16_t" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_UINT16_T $ac_cv_sizeof_uint16_t +_ACEOF + + +{ echo "$as_me:$LINENO: checking for uint32_t" >&5 +echo $ECHO_N "checking for uint32_t... $ECHO_C" >&6; } +if test "${ac_cv_type_uint32_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +typedef uint32_t ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_uint32_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_uint32_t=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_uint32_t" >&5 +echo "${ECHO_T}$ac_cv_type_uint32_t" >&6; } + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ echo "$as_me:$LINENO: checking size of uint32_t" >&5 +echo $ECHO_N "checking size of uint32_t... $ECHO_C" >&6; } +if test "${ac_cv_sizeof_uint32_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef uint32_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef uint32_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef uint32_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef uint32_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_lo=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo= ac_hi= +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef uint32_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo=`expr '(' $ac_mid ')' + 1` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_uint32_t=$ac_lo;; +'') if test "$ac_cv_type_uint32_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (uint32_t) +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (uint32_t) +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_uint32_t=0 + fi ;; +esac +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef uint32_t ac__type_sizeof_; +static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } +static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + return 1; + if (((long int) (sizeof (ac__type_sizeof_))) < 0) + { + long int i = longval (); + if (i != ((long int) (sizeof (ac__type_sizeof_)))) + return 1; + fprintf (f, "%ld\n", i); + } + else + { + unsigned long int i = ulongval (); + if (i != ((long int) (sizeof (ac__type_sizeof_)))) + return 1; + fprintf (f, "%lu\n", i); + } + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_uint32_t=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +if test "$ac_cv_type_uint32_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (uint32_t) +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (uint32_t) +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_uint32_t=0 + fi +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.val +fi +{ echo "$as_me:$LINENO: result: $ac_cv_sizeof_uint32_t" >&5 +echo "${ECHO_T}$ac_cv_sizeof_uint32_t" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_UINT32_T $ac_cv_sizeof_uint32_t +_ACEOF + + +{ echo "$as_me:$LINENO: checking for u_int8_t" >&5 +echo $ECHO_N "checking for u_int8_t... $ECHO_C" >&6; } +if test "${ac_cv_type_u_int8_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +typedef u_int8_t ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_u_int8_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_u_int8_t=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_u_int8_t" >&5 +echo "${ECHO_T}$ac_cv_type_u_int8_t" >&6; } + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ echo "$as_me:$LINENO: checking size of u_int8_t" >&5 +echo $ECHO_N "checking size of u_int8_t... $ECHO_C" >&6; } +if test "${ac_cv_sizeof_u_int8_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef u_int8_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef u_int8_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef u_int8_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef u_int8_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_lo=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo= ac_hi= +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef u_int8_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo=`expr '(' $ac_mid ')' + 1` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_u_int8_t=$ac_lo;; +'') if test "$ac_cv_type_u_int8_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (u_int8_t) +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (u_int8_t) +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_u_int8_t=0 + fi ;; +esac +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef u_int8_t ac__type_sizeof_; +static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } +static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + return 1; + if (((long int) (sizeof (ac__type_sizeof_))) < 0) + { + long int i = longval (); + if (i != ((long int) (sizeof (ac__type_sizeof_)))) + return 1; + fprintf (f, "%ld\n", i); + } + else + { + unsigned long int i = ulongval (); + if (i != ((long int) (sizeof (ac__type_sizeof_)))) + return 1; + fprintf (f, "%lu\n", i); + } + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_u_int8_t=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +if test "$ac_cv_type_u_int8_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (u_int8_t) +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (u_int8_t) +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_u_int8_t=0 + fi +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.val +fi +{ echo "$as_me:$LINENO: result: $ac_cv_sizeof_u_int8_t" >&5 +echo "${ECHO_T}$ac_cv_sizeof_u_int8_t" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_U_INT8_T $ac_cv_sizeof_u_int8_t +_ACEOF + + +{ echo "$as_me:$LINENO: checking for u_int16_t" >&5 +echo $ECHO_N "checking for u_int16_t... $ECHO_C" >&6; } +if test "${ac_cv_type_u_int16_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +typedef u_int16_t ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_u_int16_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_u_int16_t=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_u_int16_t" >&5 +echo "${ECHO_T}$ac_cv_type_u_int16_t" >&6; } + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ echo "$as_me:$LINENO: checking size of u_int16_t" >&5 +echo $ECHO_N "checking size of u_int16_t... $ECHO_C" >&6; } +if test "${ac_cv_sizeof_u_int16_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef u_int16_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef u_int16_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef u_int16_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef u_int16_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_lo=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo= ac_hi= +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef u_int16_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo=`expr '(' $ac_mid ')' + 1` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_u_int16_t=$ac_lo;; +'') if test "$ac_cv_type_u_int16_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (u_int16_t) +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (u_int16_t) +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_u_int16_t=0 + fi ;; +esac +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef u_int16_t ac__type_sizeof_; +static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } +static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + return 1; + if (((long int) (sizeof (ac__type_sizeof_))) < 0) + { + long int i = longval (); + if (i != ((long int) (sizeof (ac__type_sizeof_)))) + return 1; + fprintf (f, "%ld\n", i); + } + else + { + unsigned long int i = ulongval (); + if (i != ((long int) (sizeof (ac__type_sizeof_)))) + return 1; + fprintf (f, "%lu\n", i); + } + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_u_int16_t=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +if test "$ac_cv_type_u_int16_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (u_int16_t) +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (u_int16_t) +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_u_int16_t=0 + fi +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.val +fi +{ echo "$as_me:$LINENO: result: $ac_cv_sizeof_u_int16_t" >&5 +echo "${ECHO_T}$ac_cv_sizeof_u_int16_t" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_U_INT16_T $ac_cv_sizeof_u_int16_t +_ACEOF + + +{ echo "$as_me:$LINENO: checking for u_int32_t" >&5 +echo $ECHO_N "checking for u_int32_t... $ECHO_C" >&6; } +if test "${ac_cv_type_u_int32_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default +typedef u_int32_t ac__type_new_; +int +main () +{ +if ((ac__type_new_ *) 0) + return 0; +if (sizeof (ac__type_new_)) + return 0; + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_cv_type_u_int32_t=yes +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_cv_type_u_int32_t=no +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi +{ echo "$as_me:$LINENO: result: $ac_cv_type_u_int32_t" >&5 +echo "${ECHO_T}$ac_cv_type_u_int32_t" >&6; } + +# The cast to long int works around a bug in the HP C Compiler +# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects +# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'. +# This bug is HP SR number 8606223364. +{ echo "$as_me:$LINENO: checking size of u_int32_t" >&5 +echo $ECHO_N "checking size of u_int32_t... $ECHO_C" >&6; } +if test "${ac_cv_sizeof_u_int32_t+set}" = set; then + echo $ECHO_N "(cached) $ECHO_C" >&6 +else + if test "$cross_compiling" = yes; then + # Depending upon the size, compute the lo and hi bounds. +cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef u_int32_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_lo=0 ac_mid=0 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef u_int32_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo=`expr $ac_mid + 1` + if test $ac_lo -le $ac_mid; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid + 1` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef u_int32_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) < 0)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=-1 ac_mid=-1 + while :; do + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef u_int32_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) >= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_lo=$ac_mid; break +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_hi=`expr '(' $ac_mid ')' - 1` + if test $ac_mid -le $ac_hi; then + ac_lo= ac_hi= + break + fi + ac_mid=`expr 2 '*' $ac_mid` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + done +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo= ac_hi= +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +# Binary search between lo and hi bounds. +while test "x$ac_lo" != "x$ac_hi"; do + ac_mid=`expr '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo` + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef u_int32_t ac__type_sizeof_; +int +main () +{ +static int test_array [1 - 2 * !(((long int) (sizeof (ac__type_sizeof_))) <= $ac_mid)]; +test_array [0] = 0 + + ; + return 0; +} +_ACEOF +rm -f conftest.$ac_objext +if { (ac_try="$ac_compile" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_compile") 2>conftest.er1 + ac_status=$? + grep -v '^ *+' conftest.er1 >conftest.err + rm -f conftest.er1 + cat conftest.err >&5 + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { + test -z "$ac_c_werror_flag" || + test ! -s conftest.err + } && test -s conftest.$ac_objext; then + ac_hi=$ac_mid +else + echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + + ac_lo=`expr '(' $ac_mid ')' + 1` +fi + +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +done +case $ac_lo in +?*) ac_cv_sizeof_u_int32_t=$ac_lo;; +'') if test "$ac_cv_type_u_int32_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (u_int32_t) +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (u_int32_t) +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_u_int32_t=0 + fi ;; +esac +else + cat >conftest.$ac_ext <<_ACEOF +/* confdefs.h. */ +_ACEOF +cat confdefs.h >>conftest.$ac_ext +cat >>conftest.$ac_ext <<_ACEOF +/* end confdefs.h. */ +$ac_includes_default + typedef u_int32_t ac__type_sizeof_; +static long int longval () { return (long int) (sizeof (ac__type_sizeof_)); } +static unsigned long int ulongval () { return (long int) (sizeof (ac__type_sizeof_)); } +#include +#include +int +main () +{ + + FILE *f = fopen ("conftest.val", "w"); + if (! f) + return 1; + if (((long int) (sizeof (ac__type_sizeof_))) < 0) + { + long int i = longval (); + if (i != ((long int) (sizeof (ac__type_sizeof_)))) + return 1; + fprintf (f, "%ld\n", i); + } + else + { + unsigned long int i = ulongval (); + if (i != ((long int) (sizeof (ac__type_sizeof_)))) + return 1; + fprintf (f, "%lu\n", i); + } + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +rm -f conftest$ac_exeext +if { (ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); } && { ac_try='./conftest$ac_exeext' + { (case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + echo "$as_me:$LINENO: \$? = $ac_status" >&5 + (exit $ac_status); }; }; then + ac_cv_sizeof_u_int32_t=`cat conftest.val` +else + echo "$as_me: program exited with status $ac_status" >&5 +echo "$as_me: failed program was:" >&5 +sed 's/^/| /' conftest.$ac_ext >&5 + +( exit $ac_status ) +if test "$ac_cv_type_u_int32_t" = yes; then + { { echo "$as_me:$LINENO: error: cannot compute sizeof (u_int32_t) +See \`config.log' for more details." >&5 +echo "$as_me: error: cannot compute sizeof (u_int32_t) +See \`config.log' for more details." >&2;} + { (exit 77); exit 77; }; } + else + ac_cv_sizeof_u_int32_t=0 + fi +fi +rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext conftest.$ac_objext conftest.$ac_ext +fi +rm -f conftest.val +fi +{ echo "$as_me:$LINENO: result: $ac_cv_sizeof_u_int32_t" >&5 +echo "${ECHO_T}$ac_cv_sizeof_u_int32_t" >&6; } + + + +cat >>confdefs.h <<_ACEOF +#define SIZEOF_U_INT32_T $ac_cv_sizeof_u_int32_t +_ACEOF + + + + + +cat >confcache <<\_ACEOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs, see configure's option --config-cache. +# It is not useful on other systems. If it contains results you don't +# want to keep, you may remove or edit it. +# +# config.status only pays attention to the cache file if you give it +# the --recheck option to rerun configure. +# +# `ac_cv_env_foo' variables (set or unset) will be overridden when +# loading this file, other *unset* `ac_cv_foo' will be assigned the +# following values. + +_ACEOF + +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, we kill variables containing newlines. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +( + for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do + eval ac_val=\$$ac_var + case $ac_val in #( + *${as_nl}*) + case $ac_var in #( + *_cv_*) { echo "$as_me:$LINENO: WARNING: Cache variable $ac_var contains a newline." >&5 +echo "$as_me: WARNING: Cache variable $ac_var contains a newline." >&2;} ;; + esac + case $ac_var in #( + _ | IFS | as_nl) ;; #( + *) $as_unset $ac_var ;; + esac ;; + esac + done + + (set) 2>&1 | + case $as_nl`(ac_space=' '; set) 2>&1` in #( + *${as_nl}ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote + # substitution turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + "s/'/'\\\\''/g; + s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p" + ;; #( + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p" + ;; + esac | + sort +) | + sed ' + /^ac_cv_env_/b end + t clear + :clear + s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/ + t end + s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/ + :end' >>confcache +if diff "$cache_file" confcache >/dev/null 2>&1; then :; else + if test -w "$cache_file"; then + test "x$cache_file" != "x/dev/null" && + { echo "$as_me:$LINENO: updating cache $cache_file" >&5 +echo "$as_me: updating cache $cache_file" >&6;} + cat confcache >$cache_file + else + { echo "$as_me:$LINENO: not updating unwritable cache $cache_file" >&5 +echo "$as_me: not updating unwritable cache $cache_file" >&6;} + fi +fi +rm -f confcache + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +DEFS=-DHAVE_CONFIG_H + +ac_libobjs= +ac_ltlibobjs= +for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue + # 1. Remove the extension, and $U if already installed. + ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' + ac_i=`echo "$ac_i" | sed "$ac_script"` + # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR + # will be set to the directory where LIBOBJS objects are built. + ac_libobjs="$ac_libobjs \${LIBOBJDIR}$ac_i\$U.$ac_objext" + ac_ltlibobjs="$ac_ltlibobjs \${LIBOBJDIR}$ac_i"'$U.lo' +done +LIBOBJS=$ac_libobjs + +LTLIBOBJS=$ac_ltlibobjs + + + + if test "$LIBS" != ""; then + +cat >>confdefs.h <<_ACEOF +#define LIBS $LIBS +_ACEOF + + fi + + +: ${CONFIG_STATUS=./config.status} +ac_clean_files_save=$ac_clean_files +ac_clean_files="$ac_clean_files $CONFIG_STATUS" +{ echo "$as_me:$LINENO: creating $CONFIG_STATUS" >&5 +echo "$as_me: creating $CONFIG_STATUS" >&6;} +cat >$CONFIG_STATUS <<_ACEOF +#! $SHELL +# Generated by $as_me. +# Run this file to recreate the current configuration. +# Compiler output produced by configure, useful for debugging +# configure, is in config.log if it exists. + +debug=false +ac_cs_recheck=false +ac_cs_silent=false +SHELL=\${CONFIG_SHELL-$SHELL} +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +## --------------------- ## +## M4sh Initialization. ## +## --------------------- ## + +# Be more Bourne compatible +DUALCASE=1; export DUALCASE # for MKS sh +if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then + emulate sh + NULLCMD=: + # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which + # is contrary to our usage. Disable this feature. + alias -g '${1+"$@"}'='"$@"' + setopt NO_GLOB_SUBST +else + case `(set -o) 2>/dev/null` in + *posix*) set -o posix ;; +esac + +fi + + + + +# PATH needs CR +# Avoid depending upon Character Ranges. +as_cr_letters='abcdefghijklmnopqrstuvwxyz' +as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ' +as_cr_Letters=$as_cr_letters$as_cr_LETTERS +as_cr_digits='0123456789' +as_cr_alnum=$as_cr_Letters$as_cr_digits + +# The user is always right. +if test "${PATH_SEPARATOR+set}" != set; then + echo "#! /bin/sh" >conf$$.sh + echo "exit 0" >>conf$$.sh + chmod +x conf$$.sh + if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then + PATH_SEPARATOR=';' + else + PATH_SEPARATOR=: + fi + rm -f conf$$.sh +fi + +# Support unset when possible. +if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then + as_unset=unset +else + as_unset=false +fi + + +# IFS +# We need space, tab and new line, in precisely that order. Quoting is +# there to prevent editors from complaining about space-tab. +# (If _AS_PATH_WALK were called with IFS unset, it would disable word +# splitting by setting IFS to empty value.) +as_nl=' +' +IFS=" "" $as_nl" + +# Find who we are. Look in the path if we contain no directory separator. +case $0 in + *[\\/]* ) as_myself=$0 ;; + *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break +done +IFS=$as_save_IFS + + ;; +esac +# We did not find ourselves, most probably we were run as `sh COMMAND' +# in which case we are not to be found in the path. +if test "x$as_myself" = x; then + as_myself=$0 +fi +if test ! -f "$as_myself"; then + echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2 + { (exit 1); exit 1; } +fi + +# Work around bugs in pre-3.0 UWIN ksh. +for as_var in ENV MAIL MAILPATH +do ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var +done +PS1='$ ' +PS2='> ' +PS4='+ ' + +# NLS nuisances. +for as_var in \ + LANG LANGUAGE LC_ADDRESS LC_ALL LC_COLLATE LC_CTYPE LC_IDENTIFICATION \ + LC_MEASUREMENT LC_MESSAGES LC_MONETARY LC_NAME LC_NUMERIC LC_PAPER \ + LC_TELEPHONE LC_TIME +do + if (set +x; test -z "`(eval $as_var=C; export $as_var) 2>&1`"); then + eval $as_var=C; export $as_var + else + ($as_unset $as_var) >/dev/null 2>&1 && $as_unset $as_var + fi +done + +# Required to use basename. +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then + as_basename=basename +else + as_basename=false +fi + + +# Name of the executable. +as_me=`$as_basename -- "$0" || +$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \ + X"$0" : 'X\(//\)$' \| \ + X"$0" : 'X\(/\)' \| . 2>/dev/null || +echo X/"$0" | + sed '/^.*\/\([^/][^/]*\)\/*$/{ + s//\1/ + q + } + /^X\/\(\/\/\)$/{ + s//\1/ + q + } + /^X\/\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + +# CDPATH. +$as_unset CDPATH + + + + as_lineno_1=$LINENO + as_lineno_2=$LINENO + test "x$as_lineno_1" != "x$as_lineno_2" && + test "x`expr $as_lineno_1 + 1`" = "x$as_lineno_2" || { + + # Create $as_me.lineno as a copy of $as_myself, but with $LINENO + # uniformly replaced by the line number. The first 'sed' inserts a + # line-number line after each line using $LINENO; the second 'sed' + # does the real work. The second script uses 'N' to pair each + # line-number line with the line containing $LINENO, and appends + # trailing '-' during substitution so that $LINENO is not a special + # case at line end. + # (Raja R Harinath suggested sed '=', and Paul Eggert wrote the + # scripts with optimization help from Paolo Bonzini. Blame Lee + # E. McMahon (1931-1989) for sed's syntax. :-) + sed -n ' + p + /[$]LINENO/= + ' <$as_myself | + sed ' + s/[$]LINENO.*/&-/ + t lineno + b + :lineno + N + :loop + s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/ + t loop + s/-\n.*// + ' >$as_me.lineno && + chmod +x "$as_me.lineno" || + { echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2 + { (exit 1); exit 1; }; } + + # Don't try to exec as it changes $[0], causing all sort of problems + # (the dirname of $[0] is not the place where we might find the + # original and so on. Autoconf is especially sensitive to this). + . "./$as_me.lineno" + # Exit status is that of the last command. + exit +} + + +if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then + as_dirname=dirname +else + as_dirname=false +fi + +ECHO_C= ECHO_N= ECHO_T= +case `echo -n x` in +-n*) + case `echo 'x\c'` in + *c*) ECHO_T=' ';; # ECHO_T is single tab character. + *) ECHO_C='\c';; + esac;; +*) + ECHO_N='-n';; +esac + +if expr a : '\(a\)' >/dev/null 2>&1 && + test "X`expr 00001 : '.*\(...\)'`" = X001; then + as_expr=expr +else + as_expr=false +fi + +rm -f conf$$ conf$$.exe conf$$.file +if test -d conf$$.dir; then + rm -f conf$$.dir/conf$$.file +else + rm -f conf$$.dir + mkdir conf$$.dir +fi +echo >conf$$.file +if ln -s conf$$.file conf$$ 2>/dev/null; then + as_ln_s='ln -s' + # ... but there are two gotchas: + # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. + # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. + # In both cases, we have to default to `cp -p'. + ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || + as_ln_s='cp -p' +elif ln conf$$.file conf$$ 2>/dev/null; then + as_ln_s=ln +else + as_ln_s='cp -p' +fi +rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file +rmdir conf$$.dir 2>/dev/null + +if mkdir -p . 2>/dev/null; then + as_mkdir_p=: +else + test -d ./-p && rmdir ./-p + as_mkdir_p=false +fi + +if test -x / >/dev/null 2>&1; then + as_test_x='test -x' +else + if ls -dL / >/dev/null 2>&1; then + as_ls_L_option=L + else + as_ls_L_option= + fi + as_test_x=' + eval sh -c '\'' + if test -d "$1"; then + test -d "$1/."; + else + case $1 in + -*)set "./$1";; + esac; + case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in + ???[sx]*):;;*)false;;esac;fi + '\'' sh + ' +fi +as_executable_p=$as_test_x + +# Sed expression to map a string onto a valid CPP name. +as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" + +# Sed expression to map a string onto a valid variable name. +as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" + + +exec 6>&1 + +# Save the log message, to keep $[0] and so on meaningful, and to +# report actual input values of CONFIG_FILES etc. instead of their +# values after options handling. +ac_log=" +This file was extended by $as_me, which was +generated by GNU Autoconf 2.61. Invocation command line was + + CONFIG_FILES = $CONFIG_FILES + CONFIG_HEADERS = $CONFIG_HEADERS + CONFIG_LINKS = $CONFIG_LINKS + CONFIG_COMMANDS = $CONFIG_COMMANDS + $ $0 $@ + +on `(hostname || uname -n) 2>/dev/null | sed 1q` +" + +_ACEOF + +cat >>$CONFIG_STATUS <<_ACEOF +# Files that config.status was made for. +config_headers="$ac_config_headers" + +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +ac_cs_usage="\ +\`$as_me' instantiates files from templates according to the +current configuration. + +Usage: $0 [OPTIONS] [FILE]... + + -h, --help print this help, then exit + -V, --version print version number and configuration settings, then exit + -q, --quiet do not print progress messages + -d, --debug don't remove temporary files + --recheck update $as_me by reconfiguring in the same conditions + --header=FILE[:TEMPLATE] + instantiate the configuration header FILE + +Configuration headers: +$config_headers + +Report bugs to ." + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +ac_cs_version="\\ +config.status +configured by $0, generated by GNU Autoconf 2.61, + with options \\"`echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" + +Copyright (C) 2006 Free Software Foundation, Inc. +This config.status script is free software; the Free Software Foundation +gives unlimited permission to copy, distribute and modify it." + +ac_pwd='$ac_pwd' +srcdir='$srcdir' +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF +# If no file are specified by the user, then we need to provide default +# value. By we need to know if files were specified by the user. +ac_need_defaults=: +while test $# != 0 +do + case $1 in + --*=*) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` + ac_shift=: + ;; + *) + ac_option=$1 + ac_optarg=$2 + ac_shift=shift + ;; + esac + + case $ac_option in + # Handling of the options. + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + ac_cs_recheck=: ;; + --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) + echo "$ac_cs_version"; exit ;; + --debug | --debu | --deb | --de | --d | -d ) + debug=: ;; + --header | --heade | --head | --hea ) + $ac_shift + CONFIG_HEADERS="$CONFIG_HEADERS $ac_optarg" + ac_need_defaults=false;; + --he | --h) + # Conflict between --help and --header + { echo "$as_me: error: ambiguous option: $1 +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; };; + --help | --hel | -h ) + echo "$ac_cs_usage"; exit ;; + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil | --si | --s) + ac_cs_silent=: ;; + + # This is an error. + -*) { echo "$as_me: error: unrecognized option: $1 +Try \`$0 --help' for more information." >&2 + { (exit 1); exit 1; }; } ;; + + *) ac_config_targets="$ac_config_targets $1" + ac_need_defaults=false ;; + + esac + shift +done + +ac_configure_extra_args= + +if $ac_cs_silent; then + exec 6>/dev/null + ac_configure_extra_args="$ac_configure_extra_args --silent" +fi + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +if \$ac_cs_recheck; then + echo "running CONFIG_SHELL=$SHELL $SHELL $0 "$ac_configure_args \$ac_configure_extra_args " --no-create --no-recursion" >&6 + CONFIG_SHELL=$SHELL + export CONFIG_SHELL + exec $SHELL "$0"$ac_configure_args \$ac_configure_extra_args --no-create --no-recursion +fi + +_ACEOF +cat >>$CONFIG_STATUS <<\_ACEOF +exec 5>>config.log +{ + echo + sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX +## Running $as_me. ## +_ASBOX + echo "$ac_log" +} >&5 + +_ACEOF +cat >>$CONFIG_STATUS <<_ACEOF +_ACEOF + +cat >>$CONFIG_STATUS <<\_ACEOF + +# Handling of arguments. +for ac_config_target in $ac_config_targets +do + case $ac_config_target in + "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; + + *) { { echo "$as_me:$LINENO: error: invalid argument: $ac_config_target" >&5 +echo "$as_me: error: invalid argument: $ac_config_target" >&2;} + { (exit 1); exit 1; }; };; + esac +done + + +# If the user did not use the arguments to specify the items to instantiate, +# then the envvar interface is used. Set only those that are not. +# We use the long form for the default assignment because of an extremely +# bizarre bug on SunOS 4.1.3. +if $ac_need_defaults; then + test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers +fi + +# Have a temporary directory for convenience. Make it in the build tree +# simply because there is no reason against having it here, and in addition, +# creating and moving files from /tmp can sometimes cause problems. +# Hook for its removal unless debugging. +# Note that there is a small window in which the directory will not be cleaned: +# after its creation but before its name has been assigned to `$tmp'. +$debug || +{ + tmp= + trap 'exit_status=$? + { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status +' 0 + trap '{ (exit 1); exit 1; }' 1 2 13 15 +} +# Create a (secure) tmp directory for tmp files. + +{ + tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && + test -n "$tmp" && test -d "$tmp" +} || +{ + tmp=./conf$$-$RANDOM + (umask 077 && mkdir "$tmp") +} || +{ + echo "$me: cannot create a temporary directory in ." >&2 + { (exit 1); exit 1; } +} + + +for ac_tag in :H $CONFIG_HEADERS +do + case $ac_tag in + :[FHLC]) ac_mode=$ac_tag; continue;; + esac + case $ac_mode$ac_tag in + :[FHL]*:*);; + :L* | :C*:*) { { echo "$as_me:$LINENO: error: Invalid tag $ac_tag." >&5 +echo "$as_me: error: Invalid tag $ac_tag." >&2;} + { (exit 1); exit 1; }; };; + :[FH]-) ac_tag=-:-;; + :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; + esac + ac_save_IFS=$IFS + IFS=: + set x $ac_tag + IFS=$ac_save_IFS + shift + ac_file=$1 + shift + + case $ac_mode in + :L) ac_source=$1;; + :[FH]) + ac_file_inputs= + for ac_f + do + case $ac_f in + -) ac_f="$tmp/stdin";; + *) # Look for the file first in the build tree, then in the source tree + # (if the path is not absolute). The absolute path cannot be DOS-style, + # because $ac_f cannot contain `:'. + test -f "$ac_f" || + case $ac_f in + [\\/$]*) false;; + *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; + esac || + { { echo "$as_me:$LINENO: error: cannot find input file: $ac_f" >&5 +echo "$as_me: error: cannot find input file: $ac_f" >&2;} + { (exit 1); exit 1; }; };; + esac + ac_file_inputs="$ac_file_inputs $ac_f" + done + + # Let's still pretend it is `configure' which instantiates (i.e., don't + # use $as_me), people would be surprised to read: + # /* config.h. Generated by config.status. */ + configure_input="Generated from "`IFS=: + echo $* | sed 's|^[^:]*/||;s|:[^:]*/|, |g'`" by configure." + if test x"$ac_file" != x-; then + configure_input="$ac_file. $configure_input" + { echo "$as_me:$LINENO: creating $ac_file" >&5 +echo "$as_me: creating $ac_file" >&6;} + fi + + case $ac_tag in + *:-:* | *:-) cat >"$tmp/stdin";; + esac + ;; + esac + + ac_dir=`$as_dirname -- "$ac_file" || +$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$ac_file" : 'X\(//\)[^/]' \| \ + X"$ac_file" : 'X\(//\)$' \| \ + X"$ac_file" : 'X\(/\)' \| . 2>/dev/null || +echo X"$ac_file" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + { as_dir="$ac_dir" + case $as_dir in #( + -*) as_dir=./$as_dir;; + esac + test -d "$as_dir" || { $as_mkdir_p && mkdir -p "$as_dir"; } || { + as_dirs= + while :; do + case $as_dir in #( + *\'*) as_qdir=`echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #( + *) as_qdir=$as_dir;; + esac + as_dirs="'$as_qdir' $as_dirs" + as_dir=`$as_dirname -- "$as_dir" || +$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \ + X"$as_dir" : 'X\(//\)[^/]' \| \ + X"$as_dir" : 'X\(//\)$' \| \ + X"$as_dir" : 'X\(/\)' \| . 2>/dev/null || +echo X"$as_dir" | + sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{ + s//\1/ + q + } + /^X\(\/\/\)[^/].*/{ + s//\1/ + q + } + /^X\(\/\/\)$/{ + s//\1/ + q + } + /^X\(\/\).*/{ + s//\1/ + q + } + s/.*/./; q'` + test -d "$as_dir" && break + done + test -z "$as_dirs" || eval "mkdir $as_dirs" + } || test -d "$as_dir" || { { echo "$as_me:$LINENO: error: cannot create directory $as_dir" >&5 +echo "$as_me: error: cannot create directory $as_dir" >&2;} + { (exit 1); exit 1; }; }; } + ac_builddir=. + +case "$ac_dir" in +.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;; +*) + ac_dir_suffix=/`echo "$ac_dir" | sed 's,^\.[\\/],,'` + # A ".." for each directory in $ac_dir_suffix. + ac_top_builddir_sub=`echo "$ac_dir_suffix" | sed 's,/[^\\/]*,/..,g;s,/,,'` + case $ac_top_builddir_sub in + "") ac_top_builddir_sub=. ac_top_build_prefix= ;; + *) ac_top_build_prefix=$ac_top_builddir_sub/ ;; + esac ;; +esac +ac_abs_top_builddir=$ac_pwd +ac_abs_builddir=$ac_pwd$ac_dir_suffix +# for backward compatibility: +ac_top_builddir=$ac_top_build_prefix + +case $srcdir in + .) # We are building in place. + ac_srcdir=. + ac_top_srcdir=$ac_top_builddir_sub + ac_abs_top_srcdir=$ac_pwd ;; + [\\/]* | ?:[\\/]* ) # Absolute name. + ac_srcdir=$srcdir$ac_dir_suffix; + ac_top_srcdir=$srcdir + ac_abs_top_srcdir=$srcdir ;; + *) # Relative name. + ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix + ac_top_srcdir=$ac_top_build_prefix$srcdir + ac_abs_top_srcdir=$ac_pwd/$srcdir ;; +esac +ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix + + + case $ac_mode in + + :H) + # + # CONFIG_HEADER + # +_ACEOF + +# Transform confdefs.h into a sed script `conftest.defines', that +# substitutes the proper values into config.h.in to produce config.h. +rm -f conftest.defines conftest.tail +# First, append a space to every undef/define line, to ease matching. +echo 's/$/ /' >conftest.defines +# Then, protect against being on the right side of a sed subst, or in +# an unquoted here document, in config.status. If some macros were +# called several times there might be several #defines for the same +# symbol, which is useless. But do not sort them, since the last +# AC_DEFINE must be honored. +ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]* +# These sed commands are passed to sed as "A NAME B PARAMS C VALUE D", where +# NAME is the cpp macro being defined, VALUE is the value it is being given. +# PARAMS is the parameter list in the macro definition--in most cases, it's +# just an empty string. +ac_dA='s,^\\([ #]*\\)[^ ]*\\([ ]*' +ac_dB='\\)[ (].*,\\1define\\2' +ac_dC=' ' +ac_dD=' ,' + +uniq confdefs.h | + sed -n ' + t rset + :rset + s/^[ ]*#[ ]*define[ ][ ]*// + t ok + d + :ok + s/[\\&,]/\\&/g + s/^\('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/ '"$ac_dA"'\1'"$ac_dB"'\2'"${ac_dC}"'\3'"$ac_dD"'/p + s/^\('"$ac_word_re"'\)[ ]*\(.*\)/'"$ac_dA"'\1'"$ac_dB$ac_dC"'\2'"$ac_dD"'/p + ' >>conftest.defines + +# Remove the space that was appended to ease matching. +# Then replace #undef with comments. This is necessary, for +# example, in the case of _POSIX_SOURCE, which is predefined and required +# on some systems where configure will not decide to define it. +# (The regexp can be short, since the line contains either #define or #undef.) +echo 's/ $// +s,^[ #]*u.*,/* & */,' >>conftest.defines + +# Break up conftest.defines: +ac_max_sed_lines=50 + +# First sed command is: sed -f defines.sed $ac_file_inputs >"$tmp/out1" +# Second one is: sed -f defines.sed "$tmp/out1" >"$tmp/out2" +# Third one will be: sed -f defines.sed "$tmp/out2" >"$tmp/out1" +# et cetera. +ac_in='$ac_file_inputs' +ac_out='"$tmp/out1"' +ac_nxt='"$tmp/out2"' + +while : +do + # Write a here document: + cat >>$CONFIG_STATUS <<_ACEOF + # First, check the format of the line: + cat >"\$tmp/defines.sed" <<\\CEOF +/^[ ]*#[ ]*undef[ ][ ]*$ac_word_re[ ]*\$/b def +/^[ ]*#[ ]*define[ ][ ]*$ac_word_re[( ]/b def +b +:def +_ACEOF + sed ${ac_max_sed_lines}q conftest.defines >>$CONFIG_STATUS + echo 'CEOF + sed -f "$tmp/defines.sed"' "$ac_in >$ac_out" >>$CONFIG_STATUS + ac_in=$ac_out; ac_out=$ac_nxt; ac_nxt=$ac_in + sed 1,${ac_max_sed_lines}d conftest.defines >conftest.tail + grep . conftest.tail >/dev/null || break + rm -f conftest.defines + mv conftest.tail conftest.defines +done +rm -f conftest.defines conftest.tail + +echo "ac_result=$ac_in" >>$CONFIG_STATUS +cat >>$CONFIG_STATUS <<\_ACEOF + if test x"$ac_file" != x-; then + echo "/* $configure_input */" >"$tmp/config.h" + cat "$ac_result" >>"$tmp/config.h" + if diff $ac_file "$tmp/config.h" >/dev/null 2>&1; then + { echo "$as_me:$LINENO: $ac_file is unchanged" >&5 +echo "$as_me: $ac_file is unchanged" >&6;} + else + rm -f $ac_file + mv "$tmp/config.h" $ac_file + fi + else + echo "/* $configure_input */" + cat "$ac_result" + fi + rm -f "$tmp/out12" + ;; + + + esac + +done # for ac_tag + + +{ (exit 0); exit 0; } +_ACEOF +chmod +x $CONFIG_STATUS +ac_clean_files=$ac_clean_files_save + + +# configure is writing to config.log, and then calls config.status. +# config.status does its own redirection, appending to config.log. +# Unfortunately, on DOS this fails, as config.log is still kept open +# by configure, so config.status won't be able to write to it; its +# output is simply discarded. So we exec the FD to /dev/null, +# effectively closing config.log, so it can be properly (re)opened and +# appended to by config.status. When coming back to configure, we +# need to make the FD available again. +if test "$no_create" != yes; then + ac_cs_success=: + ac_config_status_args= + test "$silent" = yes && + ac_config_status_args="$ac_config_status_args --quiet" + exec 5>/dev/null + $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false + exec 5>>config.log + # Use ||, not &&, to avoid exiting from the if with $? = 1, which + # would make configure fail if this is the last instruction. + $ac_cs_success || { (exit 1); exit 1; } +fi + diff --git a/Lite/Util/lib/NetAddr/IP/InetBase.pm b/Lite/Util/lib/NetAddr/IP/InetBase.pm new file mode 100644 index 0000000..3589b4d --- /dev/null +++ b/Lite/Util/lib/NetAddr/IP/InetBase.pm @@ -0,0 +1,791 @@ +#!/usr/bin/perl +package NetAddr::IP::InetBase; + +use strict; +#use diagnostics; +#use lib qw(blib lib); + +use vars qw($VERSION @EXPORT_OK @ISA %EXPORT_TAGS $Mode); +use AutoLoader qw(AUTOLOAD); +require Exporter; + +@ISA = qw(Exporter); + +$VERSION = do { my @r = (q$Revision: 0.08 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; + +@EXPORT_OK = qw( + inet_aton + inet_ntoa + ipv6_aton + ipv6_ntoa + ipv6_n2x + ipv6_n2d + inet_any2n + inet_n2dx + inet_n2ad + inet_ntop + inet_pton + packzeros + isIPv4 + isNewIPv4 + isAnyIPv4 + AF_INET + AF_INET6 + fake_AF_INET6 + fillIPv4 +); + +%EXPORT_TAGS = ( + all => [@EXPORT_OK], + ipv4 => [qw( + inet_aton + inet_ntoa + fillIPv4 + )], + ipv6 => [qw( + ipv6_aton + ipv6_ntoa + ipv6_n2x + ipv6_n2d + inet_any2n + inet_n2dx + inet_n2ad + inet_pton + inet_ntop + packzeros + )], +); + +# prototypes +sub inet_ntoa; +sub ipv6_aton; +sub ipv6_ntoa; +sub inet_any2n($); +sub inet_n2dx($); +sub inet_n2ad($); +sub _inet_ntop; +sub _inet_pton; + +my $emulateAF_INET6 = 0; + +{ no warnings 'once'; + +*packzeros = \&_packzeros; + +## dynamic configuraton for IPv6 + +require Socket; + +*AF_INET = \&Socket::AF_INET; + +if (eval { AF_INET6() } ) { + *AF_INET6 = \&Socket::AF_INET6; + $emulateAF_INET6 = -1; # have it, remind below +} +if (eval{ require Socket6 } ) { + import Socket6 qw( + inet_pton + inet_ntop + ); + unless ($emulateAF_INET6) { + *AF_INET6 = \&Socket6::AF_INET6; + } + $emulateAF_INET6 = 0; # clear, have it from elsewhere or here +} else { + unless ($emulateAF_INET6) { # unlikely at this point + if ($^O =~ /(?:free|dragon.+)bsd/i) { # FreeBSD, DragonFlyBSD + $emulateAF_INET6 = 28; + } elsif ($^O =~ /bsd/i) { # other BSD flavors like NetBDS, OpenBSD, BSD + $emulateAF_INET6 = 24; + } elsif ($^O =~ /(?:darwin|mac)/i) { # Mac OS X + $emulateAF_INET6 = 30; + } elsif ($^O =~ /win/i) { # Windows + $emulateAF_INET6 = 23; + } elsif ($^O =~ /(?:solaris|sun)/i) { # Sun box + $emulateAF_INET6 = 26; + } else { # use linux default + $emulateAF_INET6 = 10; + } + *AF_INET6 = sub { $emulateAF_INET6; }; + } else { + $emulateAF_INET6 = 0; # clear, have it from elsewhere + } + *inet_pton = \&_inet_pton; + *inet_ntop = \&_inet_ntop; +} + +} # end no warnings 'once' + +sub fake_AF_INET6 { + return $emulateAF_INET6; +} + +# allow user to choose upper or lower case +BEGIN { + use vars qw($n2x_format $n2d_format); + $n2x_format = "%x:%x:%x:%x:%x:%x:%x:%x"; + $n2d_format = "%x:%x:%x:%x:%x:%x:%d.%d.%d.%d"; +} + +my $case = 0; # default lower case + +sub upper { $n2x_format = uc($n2x_format); $n2d_format = uc($n2d_format); $case = 1; } +sub lower { $n2x_format = lc($n2x_format); $n2d_format = lc($n2d_format); $case = 0; } + +sub ipv6_n2x { + die "Bad arg length for 'ipv6_n2x', length is ". length($_[0]) ." should be 16" + unless length($_[0]) == 16; + return sprintf($n2x_format,unpack("n8",$_[0])); +} + +sub ipv6_n2d { + die "Bad arg length for 'ipv6_n2d', length is ". length($_[0]) ." should be 16" + unless length($_[0]) == 16; + my @hex = (unpack("n8",$_[0])); + $hex[9] = $hex[7] & 0xff; + $hex[8] = $hex[7] >> 8; + $hex[7] = $hex[6] & 0xff; + $hex[6] >>= 8; + return sprintf($n2d_format,@hex); +} + +# if Socket lib is broken in some way, check for overange values +# +#my $overange = yinet_aton('256.1') ? 1:0; +#my $overange = gethostbyname('256.1') ? 1:0; + +#sub inet_aton { +# unless (! $overange || $_[0] =~ /[^0-9\.]/) { # hostname +# my @dq = split(/\./,$_[0]); +# foreach (@dq) { +# return undef if $_ > 255; +# } +# } +# scalar gethostbyname($_[0]); +#} + +sub fillIPv4 { + my $host = $_[0]; + return undef unless defined $host; + if ($host =~ /^(\d+)(?:|\.(\d+)(?:|\.(\d+)(?:|\.(\d+))))$/) { + if (defined $4) { + return undef unless + $1 >= 0 && $1 < 256 && + $2 >= 0 && $2 < 256 && + $3 >= 0 && $3 < 256 && + $4 >= 0 && $4 < 256; + $host = $1.'.'.$2.'.'.$3.'.'.$4; +# return pack('C4',$1,$2,$3,$4); +# $host = ($1 << 24) + ($2 << 16) + ($3 << 8) + $4; + } elsif (defined $3) { + return undef unless + $1 >= 0 && $1 < 256 && + $2 >= 0 && $2 < 256 && + $3 >= 0 && $3 < 256; + $host = $1.'.'.$2.'.0.'.$3 +# return pack('C4',$1,$2,0,$3); +# $host = ($1 << 24) + ($2 << 16) + $3; + } elsif (defined $2) { + return undef unless + $1 >= 0 && $1 < 256 && + $2 >= 0 && $2 < 256; + $host = $1.'.0.0.'.$2; +# return pack('C4',$1,0,0,$2); +# $host = ($1 << 24) + $2; + } else { + $host = '0.0.0.'.$1; +# return pack('C4',0,0,0,$1); +# $host = $1; + } +# return pack('N',$host); + } + $host; +} + +sub inet_aton { + my $host = fillIPv4($_[0]); + return $host ? scalar gethostbyname($host) : undef; +} + +#sub inet_aton { +# my $host = $_[0]; +# return undef unless defined $host; +# if ($host =~ /^(\d+)(?:|\.(\d+)(?:|\.(\d+)(?:|\.(\d+))))$/) { +# if (defined $4) { +# return undef unless +# $1 >= 0 && $1 < 256 && +# $2 >= 0 && $2 < 256 && +# $3 >= 0 && $3 < 256 && +# $4 >= 0 && $4 < 256; +# return pack('C4',$1,$2,$3,$4); +## $host = ($1 << 24) + ($2 << 16) + ($3 << 8) + $4; +# } elsif (defined $3) { +# return undef unless +# $1 >= 0 && $1 < 256 && +# $2 >= 0 && $2 < 256 && +# $3 >= 0 && $3 < 256; +# return pack('C4',$1,$2,0,$3); +## $host = ($1 << 24) + ($2 << 16) + $3; +# } elsif (defined $2) { +# return undef unless +# $1 >= 0 && $1 < 256 && +# $2 >= 0 && $2 < 256; +# return pack('C4',$1,0,0,$2); +## $host = ($1 << 24) + $2; +# } else { +# return pack('C4',0,0,0,$1); +## $host = $1; +# } +## return pack('N',$host); +# } +# scalar gethostbyname($host); +#} + +my $_zero = pack('L4',0,0,0,0); +my $_ipv4mask = pack('L4',0xffffffff,0xffffffff,0xffffffff,0); + +sub isIPv4 { + if (length($_[0]) != 16) { + my $sub = (caller(1))[3] || (caller(0))[3]; + die "Bad arg length for $sub, length is ". (length($_[0]) *8) .", should be 128"; + } + return ($_[0] & $_ipv4mask) eq $_zero + ? 1 : 0; +} + +my $_newV4compat = pack('N4',0,0,0xffff,0); + +sub isNewIPv4 { + my $naddr = $_[0] ^ $_newV4compat; + return isIPv4($naddr); +} + +sub isAnyIPv4 { + my $naddr = $_[0]; + my $rv = isIPv4($_[0]); + return $rv if $rv; + return isNewIPv4($naddr); +} + +sub DESTROY {}; + +sub import { + if (grep { $_ eq ':upper' } @_) { + upper(); + @_ = grep { $_ ne ':upper' } @_; + } + NetAddr::IP::InetBase->export_to_level(1,@_); +} + +1; + +__END__ + +=head1 NAME + +NetAddr::IP::InetBase -- IPv4 and IPV6 utilities + +=head1 SYNOPSIS + + use NetAddr::IP::Base qw( + :upper + inet_aton + inet_ntoa + ipv6_aton + ipv6_ntoa + ipv6_n2x + ipv6_n2d + inet_any2n + inet_n2dx + inet_n2ad + inet_pton + inet_ntop + packzeros + isIPv4 + isNewIPv4 + isAnyIPv4 + AF_INET + AF_INET6 + fake_AF_INET6 + fillIPv4 + ); + + use NetAddr::IP::Util qw(:all :inet :ipv4 :ipv6 :math) + + :ipv4 => inet_aton, inet_ntoa, fillIPv4 + + :ipv6 => ipv6_aton, ipv6_ntoa,ipv6_n2x, ipv6_n2d, + inet_any2n, inet_n2dx, inet_n2ad + inet_pton, inet_ntop, packzeros + + $dotquad = inet_ntoa($netaddr); + $netaddr = inet_aton($dotquad); + $ipv6naddr = ipv6_aton($ipv6_text); + $ipv6_text = ipv6_ntoa($ipv6naddr); + $hex_text = ipv6_n2x($ipv6naddr); + $dec_text = ipv6_n2d($ipv6naddr); + $ipv6naddr = inet_any2n($dotquad or $ipv6_text); + $dotquad or $hex_text = inet_n2dx($ipv6naddr); + $dotquad or $dec_text = inet_n2ad($ipv6naddr); + $netaddr = inet_pton($AF_family,$text_addr); + $text_addr = inet_ntop($AF_family,$netaddr); + $hex_text = packzeros($hex_text); + $rv = isIPv4($bits128); + $rv = isNewIPv4($bits128); + $rv = isAnyIPv4($bits128); + $constant = AF_INET(); + $constant = AF_INET6(); + $trueif = fake_AF_INET6(); + $ip_filled = fillIPv4($shortIP); + + NetAddr::IP::InetBase::lower(); + NetAddr::IP::InetBase::upper(); + +=head1 INSTALLATION + +Un-tar the distribution in an appropriate directory and type: + + perl Makefile.PL + make + make test + make install + +=head1 DESCRIPTION + +B provides a suite network of conversion functions +written in pure Perl for converting both IPv4 and IPv6 addresses to +and from network address format and text format. + +The IPv6 functions support all rfc1884 formats. + + i.e. x:x:x:x:x:x:x:x:x + x:x:x:x:x:x:x:d.d.d.d + ::x:x:x + ::x:d.d.d.d + and so on... + +=over 4 + +=item * $dotquad = inet_ntoa($netaddr); + +Convert a packed IPv4 network address to a dot-quad IP address. + + input: packed network address + returns: IP address i.e. 10.4.12.123 + +=cut + +sub inet_ntoa { + die 'Bad arg length for '. __PACKAGE__ ."::inet_ntoa, length is ". length($_[0]) ." should be 4" + unless length($_[0]) == 4; + my @hex = (unpack("n2",$_[0])); + $hex[3] = $hex[1] & 0xff; + $hex[2] = $hex[1] >> 8; + $hex[1] = $hex[0] & 0xff; + $hex[0] >>= 8; + return sprintf("%d.%d.%d.%d",@hex); +} + +=item * $netaddr = inet_aton($dotquad); + +Convert a dot-quad IP address into an IPv4 packed network address. + + input: IP address i.e. 192.5.16.32 + returns: packed network address + +=item * $ipv6addr = ipv6_aton($ipv6_text); + +Takes an IPv6 address of the form described in rfc1884 +and returns a 128 bit binary RDATA string. + + input: ipv6 text + returns: 128 bit RDATA string + +=cut + +sub ipv6_aton { + my($ipv6) = @_; + return undef unless $ipv6; + local($1,$2,$3,$4,$5); + if ($ipv6 =~ /^(.*:)(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/) { # mixed hex, dot-quad + return undef if $2 > 255 || $3 > 255 || $4 > 255 || $5 > 255; + $ipv6 = sprintf("%s%X%02X:%X%02X",$1,$2,$3,$4,$5); # convert to pure hex + } + my $c; + return undef if + $ipv6 =~ /[^:0-9a-fA-F]/ || # non-hex character + (($c = $ipv6) =~ s/::/x/ && $c =~ /(?:x|:):/) || # double :: ::? + $ipv6 =~ /[0-9a-fA-F]{5,}/; # more than 4 digits + $c = $ipv6 =~ tr/:/:/; # count the colons + return undef if $c < 7 && $ipv6 !~ /::/; + if ($c > 7) { # strip leading or trailing :: + return undef unless + $ipv6 =~ s/^::/:/ || + $ipv6 =~ s/::$/:/; + return undef if --$c > 7; + } + while ($c++ < 7) { # expand compressed fields + $ipv6 =~ s/::/:::/; + } + $ipv6 .= 0 if $ipv6 =~ /:$/; + my @hex = split(/:/,$ipv6); + foreach(0..$#hex) { + $hex[$_] = hex($hex[$_] || 0); + } + pack("n8",@hex); +} + +=item * $ipv6text = ipv6_ntoa($ipv6naddr); + +Convert a 128 bit binary IPv6 address to compressed rfc 1884 +text representation. + + input: 128 bit RDATA string + returns: ipv6 text + +=cut + +sub ipv6_ntoa { + return inet_ntop(AF_INET6(),$_[0]); +} + +=item * $hex_text = ipv6_n2x($ipv6addr); + +Takes an IPv6 RDATA string and returns an 8 segment IPv6 hex address + + input: 128 bit RDATA string + returns: x:x:x:x:x:x:x:x + + Note: this function does NOT compress adjacent + strings of 0:0:0:0 into the :: format + +=item * $dec_text = ipv6_n2d($ipv6addr); + +Takes an IPv6 RDATA string and returns a mixed hex - decimal IPv6 address +with the 6 uppermost chunks in hex and the lower 32 bits in dot-quad +representation. + + input: 128 bit RDATA string + returns: x:x:x:x:x:x:d.d.d.d + + Note: this function does NOT compress adjacent + strings of 0:0:0:0 into the :: format + +=item * $ipv6naddr = inet_any2n($dotquad or $ipv6_text); + +This function converts a text IPv4 or IPv6 address in text format in any +standard notation into a 128 bit IPv6 string address. It prefixes any +dot-quad address (if found) with '::' and passes it to B. + + input: dot-quad or rfc1844 address + returns: 128 bit IPv6 string + +=cut + +sub inet_any2n($) { + my($addr) = @_; + $addr = '' unless $addr; + $addr = '::' . $addr + unless $addr =~ /:/; + return ipv6_aton($addr); +} + +=item * $dotquad or $hex_text = inet_n2dx($ipv6naddr); + +This function B and returns the text for either a +dot-quad IPv4 or a hex notation IPv6 address. + + input: 128 bit IPv6 string + returns: ddd.ddd.ddd.ddd + or x:x:x:x:x:x:x:x + + Note: this function does NOT compress adjacent + strings of 0:0:0:0 into the :: format + +=cut + +sub inet_n2dx($) { + my($nadr) = @_; + if (isAnyIPv4($nadr)) { + local $1; + ipv6_n2d($nadr) =~ /([^:]+)$/; + return $1; + } + return ipv6_n2x($nadr); +} + +=item * $dotquad or $dec_text = inet_n2ad($ipv6naddr); + +This function B and returns the text for either a +dot-quad IPv4 or a hex::decimal notation IPv6 address. + + input: 128 bit IPv6 string + returns: ddd.ddd.ddd.ddd + or x:x:x:x:x:x:ddd.ddd.ddd.dd + + Note: this function does NOT compress adjacent + strings of 0:0:0:0 into the :: format + +=cut + +sub inet_n2ad($) { + my($nadr) = @_; + my $addr = ipv6_n2d($nadr); + return $addr unless isAnyIPv4($nadr); + local $1; + $addr =~ /([^:]+)$/; + return $1; +} + +=item * $netaddr = inet_pton($AF_family,$text_addr); + +This function takes an IP address in IPv4 or IPv6 text format and converts it into +binary format. The type of IP address conversion is controlled by the FAMILY +argument. + +NOTE: inet_pton, inet_ntop and AF_INET6 come from the Socket6 library if it +is present on this host. + +=cut + +sub _inet_pton { + my($af,$ip) = @_; + die 'Bad address family for '. __PACKAGE__ ."::inet_pton, got $af" + unless $af == AF_INET6() || $af == AF_INET(); + if ($af == AF_INET()) { + inet_aton($ip); + } else { + ipv6_aton($ip); + } +} + +=item * $text_addr = inet_ntop($AF_family,$netaddr); + +This function takes and IP address in binary format and converts it into +text format. The type of IP address conversion is controlled by the FAMILY +argument. + +NOTE: inet_ntop ALWAYS returns lowercase characters. + +NOTE: inet_pton, inet_ntop and AF_INET6 come from the Socket6 library if it +is present on this host. + +=cut + +sub _inet_ntop { + my($af,$naddr) = @_; + die 'Unsupported address family for '. __PACKAGE__ ."::inet_ntop, af is $af" + unless $af == AF_INET6() || $af == AF_INET(); + if ($af == AF_INET()) { + inet_ntoa($naddr); + } else { + return ($case) + ? lc packzeros(ipv6_n2x($naddr)) + : _packzeros(ipv6_n2x($naddr)); + } +} + +=item * $hex_text = packzeros($hex_text); + +This function optimizes and rfc 1884 IPv6 hex address to reduce the number of +long strings of zero bits as specified in rfc 1884, 2.2 (2) by substituting +B<::> for the first occurence of the longest string of zeros in the address. + +=cut + +sub _packzeros { + my $x6 = shift; + if ($x6 =~ /\:\:/) { # already contains :: +# then re-optimize + $x6 = ($x6 =~ /\:\d+\.\d+\.\d+\.\d+/) # ipv4 notation ? + ? ipv6_n2d(ipv6_aton($x6)) + : ipv6_n2x(ipv6_aton($x6)); + } + $x6 = ':'. lc $x6; # prefix : & always lower case + my $d = ''; + if ($x6 =~ /(.+\:)(\d+\.\d+\.\d+\.\d+)/) { # if contains dot quad + $x6 = $1; # save hex piece + $d = $2; # and dot quad piece + } + $x6 .= ':'; # suffix : + $x6 =~ s/\:0+/\:0/g; # compress strings of 0's to single '0' + $x6 =~ s/\:0([1-9a-f]+)/\:$1/g; # eliminate leading 0's in hex strings + my @x = $x6 =~ /(?:\:0)*/g; # split only strings of :0:0..." + + my $m = 0; + my $i = 0; + + for (0..$#x) { # find next longest pattern :0:0:0... + my $len = length($x[$_]); + next unless $len > $m; + $m = $len; + $i = $_; # index to first longest pattern + } + + if ($m > 2) { # there was a string of 2 or more zeros + $x6 =~ s/$x[$i]/\:/; # replace first longest :0:0:0... with "::" + unless ($i) { # if it is the first match, $i = 0 + $x6 = substr($x6,0,-1); # keep the leading ::, remove trailing ':' + } else { + $x6 = substr($x6,1,-1); # else remove leading & trailing ':' + } + $x6 .= ':' unless $x6 =~ /\:\:/; # restore ':' if match and we can't see it, implies trailing '::' + } else { # there was no match + $x6 = substr($x6,1,-1); # remove leading & trailing ':' + } + $x6 .= $d; # append digits if any + return $case + ? uc $x6 + : $x6; +} + +=item * $ipv6naddr = ipv4to6($netaddr); + +Convert an ipv4 network address into an ipv6 network address. + + input: 32 bit network address + returns: 128 bit network address + +=item * $rv = isIPv4($bits128); + +This function returns true if there are no on bits present in the IPv6 +portion of the 128 bit string and false otherwise. + + i.e. the address must be of the form - ::d.d.d.d + +Note: this is an old and deprecated ipV4 compatible ipV6 address + +=item * $rv = isNewIPv4($bits128); + +This function return true if the IPv6 128 bit string is of the form + + ::ffff:d.d.d.d + +=item * $rv = isAnyIPv4($bits128); + +This function return true if the IPv6 bit string is of the form + + ::d.d.d.d or ::ffff:d.d.d.d + +=item * NetAddr::IP::InetBase::lower(); + +Return IPv6 strings in lowercase. This is the default. + +=item * NetAddr::IP::InetBase::upper(); + +Return IPv6 strings in uppercase. + +The default may be set to uppercase when the module is loaded by invoking +the TAG :upper. i.e. + + use NetAddr::IP::InetBase qw( :upper ); + +=item * $constant = AF_INET; + +This function returns the system value for AF_INET. + +=item * $constant = AF_INET6; + +AF_INET6 is sometimes present in the Socket library and always present in the Socket6 library. When the Socket +library does not contain AF_INET6 and when Socket6 is not present, a place holder value is C based on +the underlying host operating system. See B below. + +NOTE: inet_pton, inet_ntop and AF_INET6 come from the Socket6 library if it +is present on this host. + +=item * $trueif = fake_AF_INET6; + +This function return FALSE if AF_INET6 is provided by Socket or Socket6. Otherwise, it returns the best guess +value based on name of the host operating system. + +=item * $ip_filled = fillIPv4($shortIP); + +This function converts IPv4 addresses of the form 127.1 to the long form +127.0.0.1 + +If the function is passed an argument that does not match the form of an IP +address, the original argument is returned. i.e. pass it a hostname or a +short IP and it will return a hostname or a filled IP. + +=back + +=head1 EXPORT_OK + + :upper + inet_aton + inet_ntoa + ipv6_aton + ipv6_ntoa + ipv6_n2x + ipv6_n2d + inet_any2n + inet_n2dx + inet_n2ad + inet_pton + inet_ntop + packzeros + isIPv4 + isNewIPv4 + isAnyIPv4 + AF_INET + AF_INET6 + fake_AF_INET6 + fillIPv4 + +=head1 %EXPORT_TAGS + + :all + :ipv4 + :ipv6 + :upper + +=head1 AUTHOR + +Michael Robinton + +=head1 COPYRIGHT + +Copyright 2003 - 2012, Michael Robinton Emichael@bizsystems.comE + +All rights reserved. + +This program is free software; you can redistribute it and/or modify +it under the terms of either: + + a) the GNU General Public License as published by the Free + Software Foundation; either version 2, or (at your option) any + later version, or + + b) the "Artistic License" which comes with this distribution. + +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 either +the GNU General Public License or the Artistic License for more details. + +You should have received a copy of the Artistic License with this +distribution, in the file named "Artistic". If not, I'll be glad to provide +one. + +You should also have received a copy of the GNU General Public License +along with this program in the file named "Copying". If not, write to the + + Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor + Boston, MA 02110-1301 USA + +or visit their web page on the internet at: + + http://www.gnu.org/copyleft/gpl.html. + +=head1 AUTHOR + +Michael Robinton + +=head1 SEE ALSO + +NetAddr::IP(3), NetAddr::IP::Lite(3), NetAddr::IP::Util(3) + +=cut + +1; diff --git a/Lite/Util/lib/NetAddr/IP/UtilPP.pm b/Lite/Util/lib/NetAddr/IP/UtilPP.pm new file mode 100644 index 0000000..39330c5 --- /dev/null +++ b/Lite/Util/lib/NetAddr/IP/UtilPP.pm @@ -0,0 +1,722 @@ +#!/usr/bin/perl +package NetAddr::IP::UtilPP; + +use strict; +#use diagnostics; +#use lib qw(blib lib); + +use AutoLoader qw(AUTOLOAD); +use vars qw($VERSION @EXPORT_OK @ISA %EXPORT_TAGS); +require Exporter; + + +@ISA = qw(Exporter); + +$VERSION = do { my @r = (q$Revision: 1.9 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r }; + +@EXPORT_OK = qw( + hasbits + shiftleft + addconst + add128 + sub128 + notcontiguous + ipv4to6 + mask4to6 + ipanyto6 + maskanyto6 + ipv6to4 + bin2bcd + bcd2bin + comp128 + bin2bcdn + bcdn2txt + bcdn2bin + simple_pack +); + +%EXPORT_TAGS = ( + all => [@EXPORT_OK], +); + +sub DESTROY {}; + +1; +__END__ + +=head1 NAME + +NetAddr::IP::UtilPP -- pure Perl functions for NetAddr::IP::Util + +=head1 SYNOPSIS + + use NetAddr::IP::UtilPP qw( + hasbits + shiftleft + addconst + add128 + sub128 + notcontiguous + ipv4to6 + mask4to6 + ipanyto6 + maskanyto6 + ipv6to4 + bin2bcd + bcd2bin + ); + + use NetAddr::IP::UtilPP qw(:all) + + $rv = hasbits($bits128); + $bitsX2 = shiftleft($bits128,$n); + $carry = addconst($ipv6naddr,$signed_32con); + ($carry,$ipv6naddr)=addconst($ipv6naddr,$signed_32con); + $carry = add128($ipv6naddr1,$ipv6naddr2); + ($carry,$ipv6naddr)=add128($ipv6naddr1,$ipv6naddr2); + $carry = sub128($ipv6naddr1,$ipv6naddr2); + ($spurious,$cidr) = notcontiguous($mask128); + ($carry,$ipv6naddr)=sub128($ipv6naddr1,$ipv6naddr2); + $ipv6naddr = ipv4to6($netaddr); + $ipv6naddr = mask4to6($netaddr); + $ipv6naddr = ipanyto6($netaddr); + $ipv6naddr = maskanyto6($netaddr); + $netaddr = ipv6to4($pv6naddr); + $bcdtext = bin2bcd($bits128); + $bits128 = bcd2bin($bcdtxt); + +=head1 DESCRIPTION + +B provides pure Perl functions for B + +=over 4 + +=item * $rv = hasbits($bits128); + +This function returns true if there are one's present in the 128 bit string +and false if all the bits are zero. + + i.e. if (hasbits($bits128)) { + &do_something; + } + + or if (hasbits($bits128 & $mask128) { + &do_something; + } + +This allows the implementation of logical functions of the form of: + + if ($bits128 & $mask128) { + ... + + input: 128 bit IPv6 string + returns: true if any bits are present + +=cut + +sub _deadlen { + my($len,$should) = @_; + $len *= 8; + $should = 128 unless $should; + my $sub = (caller(1))[3]; + die "Bad argument length for $sub, is $len, should be $should"; +} + +sub hasbits { + _deadlen(length($_[0])) + if length($_[0]) != 16; + return 1 if vec($_[0],0,32); + return 1 if vec($_[0],1,32); + return 1 if vec($_[0],2,32); + return 1 if vec($_[0],3,32); + return 0; +} + +#=item * $rv = isIPv4($bits128); +# +#This function returns true if there are no on bits present in the IPv6 +#portion of the 128 bit string and false otherwise. +# +#=cut +# +#sub xisIPv4 { +# _deadlen(length($_[0])) +# if length($_[0]) != 16; +# return 0 if vec($_[0],0,32); +# return 0 if vec($_[0],1,32); +# return 0 if vec($_[0],2,32); +# return 1; +#} + +=item * $bitsXn = shiftleft($bits128,$n); + + input: 128 bit string variable, + number of shifts [optional] + returns: bits X n shifts + + NOTE: input bits are returned + if $n is not specified + +=cut + +# multiply x 2 +# +sub _128x2 { + my $inp = shift; + $$inp[0] = ($$inp[0] << 1 & 0xffffffff) + (($$inp[1] & 0x80000000) ? 1:0); + $$inp[1] = ($$inp[1] << 1 & 0xffffffff) + (($$inp[2] & 0x80000000) ? 1:0); + $$inp[2] = ($$inp[2] << 1 & 0xffffffff) + (($$inp[3] & 0x80000000) ? 1:0); + $$inp[3] = $$inp[3] << 1 & 0xffffffff; +} + +# multiply x 10 +# +sub _128x10 { + my($a128p) = @_; + _128x2($a128p); # x2 + my @x2 = @$a128p; # save the x2 value + _128x2($a128p); + _128x2($a128p); # x8 + _sa128($a128p,\@x2,0); # add for x10 +} + +sub shiftleft { + _deadlen(length($_[0])) + if length($_[0]) != 16; + my($bits,$shifts) = @_; + return $bits unless $shifts; + die "Bad arg value for ".__PACKAGE__.":shiftleft, length should be 0 thru 128" + if $shifts < 0 || $shifts > 128; + my @uint32t = unpack('N4',$bits); + do { + $bits = _128x2(\@uint32t); + $shifts-- + } while $shifts > 0; + pack('N4',@uint32t); +} + +sub slowadd128 { + my @ua = unpack('N4',$_[0]); + my @ub = unpack('N4',$_[1]); + my $carry = _sa128(\@ua,\@ub,$_[2]); + return ($carry,pack('N4',@ua)) + if wantarray; + return $carry; +} + +sub _sa128 { + my($uap,$ubp,$carry) = @_; + if (($$uap[3] += $$ubp[3] + $carry) > 0xffffffff) { + $$uap[3] -= 4294967296; # 0x1_00000000 + $carry = 1; + } else { + $carry = 0; + } + + if (($$uap[2] += $$ubp[2] + $carry) > 0xffffffff) { + $$uap[2] -= 4294967296; + $carry = 1; + } else { + $carry = 0; + } + + if (($$uap[1] += $$ubp[1] + $carry) > 0xffffffff) { + $$uap[1] -= 4294967296; + $carry = 1; + } else { + $carry = 0; + } + + if (($$uap[0] += $$ubp[0] + $carry) > 0xffffffff) { + $$uap[0] -= 4294967296; + $carry = 1; + } else { + $carry = 0; + } + $carry; +} + +=item * addconst($ipv6naddr,$signed_32con); + +Add a signed constant to a 128 bit string variable. + + input: 128 bit IPv6 string, + signed 32 bit integer + returns: scalar carry + array (carry, result) + +=cut + +sub addconst { + my($a128,$const) = @_; + _deadlen(length($a128)) + if length($a128) != 16; + unless ($const) { + return (wantarray) ? ($const,$a128) : $const; + } + my $sign = ($const < 0) ? 0xffffffff : 0; + my $b128 = pack('N4',$sign,$sign,$sign,$const); + @_ = ($a128,$b128,0); +# perl 5.8.4 fails with this operation. see perl bug [ 23429] +# goto &slowadd128; + slowadd128(@_); +} + +=item * add128($ipv6naddr1,$ipv6naddr2); + +Add two 128 bit string variables. + + input: 128 bit string var1, + 128 bit string var2 + returns: scalar carry + array (carry, result) + +=cut + +sub add128 { + my($a128,$b128) = @_; + _deadlen(length($a128)) + if length($a128) != 16; + _deadlen(length($b128)) + if length($b128) != 16; + @_ = ($a128,$b128,0); +# perl 5.8.4 fails with this operation. see perl bug [ 23429] +# goto &slowadd128; + slowadd128(@_); +} + +=item * sub128($ipv6naddr1,$ipv6naddr2); + +Subtract two 128 bit string variables. + + input: 128 bit string var1, + 128 bit string var2 + returns: scalar carry + array (carry, result) + +Note: The carry from this operation is the result of adding the one's +complement of ARG2 +1 to the ARG1. It is logically +B. + + i.e. if ARG1 >= ARG2 then carry = 1 + or if ARG1 < ARG2 then carry = 0 + +=cut + +sub sub128 { + _deadlen(length($_[0])) + if length($_[0]) != 16; + _deadlen(length($_[1])) + if length($_[1]) != 16; + my $a128 = $_[0]; + my $b128 = ~$_[1]; + @_ = ($a128,$b128,1); +# perl 5.8.4 fails with this operation. see perl bug [ 23429] +# goto &slowadd128; + slowadd128(@_); +} + +=item * ($spurious,$cidr) = notcontiguous($mask128); + +This function counts the bit positions remaining in the mask when the +rightmost '0's are removed. + + input: 128 bit netmask + returns true if there are spurious + zero bits remaining in the + mask, false if the mask is + contiguous one's, + 128 bit cidr + +=cut + +sub notcontiguous { + _deadlen(length($_[0])) + if length($_[0]) != 16; + my @ua = unpack('N4', ~$_[0]); + my $count; + for ($count = 128;$count > 0; $count--) { + last unless $ua[3] & 1; + $ua[3] >>= 1; + $ua[3] |= 0x80000000 if $ua[2] & 1; + $ua[2] >>= 1; + $ua[2] |= 0x80000000 if $ua[1] & 1; + $ua[1] >>= 1; + $ua[1] |= 0x80000000 if $ua[0] & 1; + $ua[0] >>= 1; + } + + my $spurious = $ua[0] | $ua[1] | $ua[2] | $ua[3]; + return $spurious unless wantarray; + return ($spurious,$count); +} + +=item * $ipv6naddr = ipv4to6($netaddr); + +Convert an ipv4 network address into an ipv6 network address. + + input: 32 bit network address + returns: 128 bit network address + +=cut + +sub ipv4to6 { + _deadlen(length($_[0]),32) + if length($_[0]) != 4; +# return pack('L3H8',0,0,0,unpack('H8',$_[0])); + return pack('L3a4',0,0,0,$_[0]); +} + +=item * $ipv6naddr = mask4to6($netaddr); + +Convert an ipv4 netowrk address into an ipv6 network mask. + + input: 32 bit network/mask address + returns: 128 bit network/mask address + +NOTE: returns the high 96 bits as one's + +=cut + +sub mask4to6 { + _deadlen(length($_[0]),32) + if length($_[0]) != 4; +# return pack('L3H8',0xffffffff,0xffffffff,0xffffffff,unpack('H8',$_[0])); + return pack('L3a4',0xffffffff,0xffffffff,0xffffffff,$_[0]); +} + +=item * $ipv6naddr = ipanyto6($netaddr); + +Similar to ipv4to6 except that this function takes either an IPv4 or IPv6 +input and always returns a 128 bit IPv6 network address. + + input: 32 or 128 bit network address + returns: 128 bit network address + +=cut + +sub ipanyto6 { + my $naddr = shift; + my $len = length($naddr); + return $naddr if $len == 16; +# return pack('L3H8',0,0,0,unpack('H8',$naddr)) + return pack('L3a4',0,0,0,$naddr) + if $len == 4; + _deadlen($len,'32 or 128'); +} + +=item * $ipv6naddr = maskanyto6($netaddr); + +Similar to mask4to6 except that this function takes either an IPv4 or IPv6 +netmask and always returns a 128 bit IPv6 netmask. + + input: 32 or 128 bit network mask + returns: 128 bit network mask + +=cut + +sub maskanyto6 { + my $naddr = shift; + my $len = length($naddr); + return $naddr if $len == 16; +# return pack('L3H8',0xffffffff,0xffffffff,0xffffffff,unpack('H8',$naddr)) + return pack('L3a4',0xffffffff,0xffffffff,0xffffffff,$naddr) + if $len == 4; + _deadlen($len,'32 or 128'); +} + +=item * $netaddr = ipv6to4($pv6naddr); + +Truncate the upper 96 bits of a 128 bit address and return the lower +32 bits. Returns an IPv4 address as returned by inet_aton. + + input: 128 bit network address + returns: 32 bit inet_aton network address + +=cut + +sub ipv6to4 { + my $naddr = shift; +_deadlen(length($naddr)) + if length($naddr) != 16; + @_ = unpack('L3H8',$naddr); + return pack('H8',@{_}[3..10]); +} + +=item * $bcdtext = bin2bcd($bits128); + +Convert a 128 bit binary string into binary coded decimal text digits. + + input: 128 bit string variable + returns: string of bcd text digits + +=cut + +sub bin2bcd { + _deadlen(length($_[0])) + if length($_[0]) != 16; + unpack("H40",&_bin2bcdn) =~ /^0*(.+)/; + $1; +} + +=item * $bits128 = bcd2bin($bcdtxt); + +Convert a bcd text string to 128 bit string variable + + input: string of bcd text digits + returns: 128 bit string variable + +=cut + +sub bcd2bin { + &_bcdcheck; +# perl 5.8.4 fails with this operation. see perl bug [ 23429] +# goto &_bcd2bin; + &_bcd2bin; +} + +=pod + +=back + +=cut + +#=item * $onescomp = comp128($ipv6addr); +# +#This function is for testing, it is more efficient to use perl " ~ " +#on the bit string directly. This interface to the B routine is published for +#module testing purposes because it is used internally in the B routine. The +#function is very fast, but calling if from perl directly is very slow. It is almost +#33% faster to use B than to do a 1's comp with perl and then call +#B. In the PurePerl version, it is a call to +# +# sub {return ~ $_[0]}; +# +#=cut + +sub comp128 { + _deadlen(length($_[0])) + if length($_[0]) != 16; + return ~ $_[0]; +} + +#=item * $bcdpacked = bin2bcdn($bits128); +# +#Convert a 128 bit binary string into binary coded decimal digits. +#This function is for testing only. +# +# input: 128 bit string variable +# returns: string of packed decimal digits +# +# i.e. text = unpack("H*", $bcd); +# +#=cut + +sub bin2bcdn { + _deadlen(length($_[0])) + if length($_[0]) != 16; +# perl 5.8.4 fails with this operation. see perl bug [ 23429] +# goto &_bin2bcdn; + &_bin2bcdn; +} + +sub _bin2bcdn { + my($b128) = @_; + my @binary = unpack('N4',$b128); + my @nbcd = (0,0,0,0,0); # 5 - 32 bit registers + my ($add3, $msk8, $bcd8, $carry, $tmp); + my $j = 0; + my $k = -1; + my $binmsk = 0; + foreach(0..127) { + unless ($binmsk) { + $binmsk = 0x80000000; + $k++; + } + $carry = $binary[$k] & $binmsk; + $binmsk >>= 1; + next unless $carry || $j; # skip leading zeros + foreach(4,3,2,1,0) { + $bcd8 = $nbcd[$_]; + $add3 = 3; + $msk8 = 8; + + $j = 0; + while ($j < 8) { + $tmp = $bcd8 + $add3; + if ($tmp & $msk8) { + $bcd8 = $tmp; + } + $add3 <<= 4; + $msk8 <<= 4; + $j++; + } + $tmp = $bcd8 & 0x80000000; # propagate carry + $bcd8 <<= 1; # x2 + if ($carry) { + $bcd8 += 1; + } + $nbcd[$_] = $bcd8; + $carry = $tmp; + } + } + pack('N5',@nbcd); +} + +#=item * $bcdtext = bcdn2txt($bcdpacked); +# +#Convert a packed bcd string into text digits, suppress the leading zeros. +#This function is for testing only. +# +# input: string of packed decimal digits +# consisting of exactly 40 digits +# returns: hexdecimal digits +# +#Similar to unpack("H*", $bcd); +# +#=cut + +sub bcdn2txt { + die "Bad argument length for ".__PACKAGE__.":bcdn2txt, is ".(2 * length($_[0])).", should be exactly 40 digits" + if length($_[0]) != 20; + (unpack('H40',$_[0])) =~ /^0*(.+)/; + $1; +} + +#=item * $bits128 = bcdn2bin($bcdpacked,$ndigits); +# +# Convert a packed bcd string into a 128 bit string variable +# +# input: packed bcd string +# number of digits in string +# returns: 128 bit string variable +# + +sub bcdn2bin { + my($bcd,$dc) = @_; + $dc = 0 unless $dc; + die "Bad argument length for ".__PACKAGE__.":bcdn2txt, is ".(2 * length($bcd)).", should be 1 to 40 digits" + if length($bcd) > 20; + die "Bad digit count for ".__PACKAGE__.":bcdn2bin, is $dc, should be 1 to 40 digits" + if $dc < 1 || $dc > 40; + return _bcd2bin(unpack("H$dc",$bcd)); +} + +sub _bcd2bin { + my @bcd = split('',$_[0]); + my @hbits = (0,0,0,0); + my @digit = (0,0,0,0); + my $found = 0; + foreach(@bcd) { + my $bcd = $_ & 0xf; # just the nibble + unless ($found) { + next unless $bcd; # skip leading zeros + $found = 1; + $hbits[3] = $bcd; # set the first digit, no x10 necessary + next; + } + _128x10(\@hbits); + $digit[3] = $bcd; + _sa128(\@hbits,\@digit,0); + } + return pack('N4',@hbits); +} + +#=item * $bcdpacked = simple_pack($bcdtext); +# +#Convert a numeric string into a packed bcd string, left fill with zeros +#This function is for testing only. +# +# input: string of decimal digits +# returns: string of packed decimal digits +# +#Similar to pack("H*", $bcdtext); +# +sub _bcdcheck { + my($bcd) = @_;; + my $sub = (caller(1))[3]; + my $len = length($bcd); + die "Bad bcd number length $_ ".__PACKAGE__.":simple_pack, should be 1 to 40 digits" + if $len > 40 || $len < 1; + die "Bad character in decimal input string '$1' for ".__PACKAGE__.":simple_pack" + if $bcd =~ /(\D)/; +} + +sub simple_pack { + &_bcdcheck; + my($bcd) = @_; + while (length($bcd) < 40) { + $bcd = '0'. $bcd; + } + return pack('H40',$bcd); +} + + +=head1 EXPORT_OK + + hasbits + shiftleft + addconst + add128 + sub128 + notcontiguous + ipv4to6 + mask4to6 + ipanyto6 + maskanyto6 + ipv6to4 + bin2bcd + bcd2bin + comp128 + bin2bcdn + bcdn2txt + bcdn2bin + simple_pack + threads + +=head1 AUTHOR + +Michael Robinton Emichael@bizsystems.comE + +=head1 COPYRIGHT + +Copyright 2003 - 2012, Michael Robinton Emichael@bizsystems.comE + +All rights reserved. + +This program is free software; you can redistribute it and/or modify +it under the terms of either: + + a) the GNU General Public License as published by the Free + Software Foundation; either version 2, or (at your option) any + later version, or + + b) the "Artistic License" which comes with this distribution. + +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 either +the GNU General Public License or the Artistic License for more details. + +You should have received a copy of the Artistic License with this +distribution, in the file named "Artistic". If not, I'll be glad to provide +one. + +You should also have received a copy of the GNU General Public License +along with this program in the file named "Copying". If not, write to the + + Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor + Boston, MA 02110-1301 USA + +or visit their web page on the internet at: + + http://www.gnu.org/copyleft/gpl.html. + +=head1 AUTHOR + +Michael Robinton + +=cut + +1; diff --git a/Lite/Util/localconf.h b/Lite/Util/localconf.h new file mode 100644 index 0000000..0a1a524 --- /dev/null +++ b/Lite/Util/localconf.h @@ -0,0 +1,80 @@ +/* + * localconf.h + * + */ + +#include "config.h" + +#ifdef WORDS_BIGENDIAN +#define host_is_BIG_ENDIAN 1 +#else +#define host_is_LITTLE_ENDIAN 1 +#endif + +#include +#ifdef HAVE_SYS_TYPES_H +# include +#endif +#ifdef HAVE_SYS_STAT_H +# include +#endif +#ifdef STDC_HEADERS +# include +# include +#else +# ifdef HAVE_STDLIB_H +# include +# endif +#endif +#ifdef HAVE_STRING_H +# if !defined STDC_HEADERS && defined HAVE_MEMORY_H +# include +# endif +# include +#endif +#ifdef HAVE_STRINGS_H +# include +#endif +#ifdef HAVE_INTTYPES_H +# include +#endif +#ifdef HAVE_STDINT_H +# include +#endif +#ifdef HAVE_UNISTD_H +# include +#endif + +#ifdef HAVE_SYS_SOCKET_H +# include +#endif +#ifdef HAVE_NET_INET_H +# include +#endif +#ifdef HAVE_ARPA_INET_H +# include +#endif +#ifdef HAVE_NETDB_H +# include +#endif + +#if SIZEOF_U_INT8_T == 0 +#undef SIZEOF_U_INT8_T +#define SIZEOF_U_INT8_T SIZEOF_UINT8_T +typedef uint8_t u_int8_t; +#endif + +#if SIZEOF_U_INT16_T == 0 +#undef SIZEOF_U_INT16_T +#define SIZEOF_U_INT16_T SIZEOF_UINT16_T +typedef uint16_t u_int16_t; +#endif + +#if SIZEOF_U_INT32_T == 0 +#undef SIZEOF_U_INT32_T +#define SIZEOF_U_INT32_T SIZEOF_UINT32_T +typedef uint32_t u_int32_t; +#endif + +#include "localperl.h" + diff --git a/Lite/Util/t/4to6.t b/Lite/Util/t/4to6.t new file mode 100644 index 0000000..307be86 --- /dev/null +++ b/Lite/Util/t/4to6.t @@ -0,0 +1,69 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..5\n"; } +END {print "not ok 1\n" unless $loaded;} + +use NetAddr::IP::Util qw( + inet_aton + ipv6_n2d + ipv6_aton + ipv4to6 + mask4to6 +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +my $nip = inet_aton('1.2.3.4'); +my $exp = '0:0:0:0:0:0:1.2.3.4'; + +## test 2 check 4->6 conversion +my $nipv6 = ipv4to6($nip); +my $ipv6 = ipv6_n2d($nipv6); +print "got: $ipv6\nexp: $exp\nnot " + unless $ipv6 eq $exp; +&ok; + + +## test 3 check mask4->6 extension +$exp = 'FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:1.2.3.4'; +$nipv6 = mask4to6($nip); +$ipv6 = ipv6_n2d($nipv6); +print "got: $ipv6\nexp: $exp\nnot " + unless $ipv6 eq $exp; +&ok; + +## test 4 check bad length +$nip = pack("H9",0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09); +eval { + ipv4to6($nip); +}; +print "ipv4to6 accepted bad argument length\nnot " + unless $@ && $@ =~ /Bad arg.+ipv4to6/; +&ok; + +## test 5 check bad length +eval { + mask4to6($nip); +}; +print "mask4to6 accepted bad argument length\nnot " + unless $@ && $@ =~ /Bad arg.+mask4to6/; +&ok; + diff --git a/Lite/Util/t/add128.t b/Lite/Util/t/add128.t new file mode 100644 index 0000000..1e8e7c0 --- /dev/null +++ b/Lite/Util/t/add128.t @@ -0,0 +1,92 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..57\n"; } +END {print "not ok 1\n" unless $loaded;} + +use NetAddr::IP::Util qw( + add128 + sub128 + ipv6_aton + ipv6_n2x + comp128 +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +my @num = # number plus carry exp +qw( + FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFE ::1 0 FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF + ::1 FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFE 0 FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF + ::2 FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFE 1 0:0:0:0:0:0:0:0 + FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFE ::2 1 0:0:0:0:0:0:0:0 + FFFF:FFFF:FFFF:FFFF:FFFF:8FFF:FFFF:FFFE ::7000:0:2 1 0:0:0:0:0:0:0:0 + FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFE ::3 1 0:0:0:0:0:0:0:1 + ::1 ::2 0 0:0:0:0:0:0:0:3 + ::FFFF ::FFFF 0 0:0:0:0:0:0:1:FFFE + ::FFFF:FFFF ::FFFF:FFFF 0 0:0:0:0:0:1:FFFF:FFFE + ::FFFF:FFFF:FFFF ::FFFF:FFFF:FFFF 0 0:0:0:0:1:FFFF:FFFF:FFFE + ::FFFF:FFFF:FFFF:FFFF ::FFFF:FFFF:FFFF:FFFF 0 0:0:0:1:FFFF:FFFF:FFFF:FFFE + ::FFFF:FFFF:FFFF:FFFF:FFFF ::FFFF:FFFF:FFFF:FFFF:FFFF 0 0:0:1:FFFF:FFFF:FFFF:FFFF:FFFE + ::FFFF:FFFF:FFFF:FFFF:FFFF:FFFF ::FFFF:FFFF:FFFF:FFFF:FFFF:FFFF 0 0:1:FFFF:FFFF:FFFF:FFFF:FFFF:FFFE + ::FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF ::FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF 0 1:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFE +); + +## test 2 - 15 check carry +for (my $i=0; $i<@num; $i+=4) { + my $num = ipv6_aton($num[$i]); + my $plus = ipv6_aton($num[$i +1]); + my $rv = add128($num,$plus); + print "got: $rv, exp: $num[$i +2]\nnot " + unless $rv == $num[$i +2]; + &ok; +} +## test 16 - 43 check carry + result +for (my $i=0; $i<@num; $i+=4) { + my $num = ipv6_aton($num[$i]); + my $plus = ipv6_aton($num[$i +1]); + my($rv,$result) = add128($num,$plus); + print "got: $rv, exp: $num[$i +2]\nnot " + unless $rv == $num[$i +2]; + &ok; + $result = ipv6_n2x($result); + print "got: $result\nexp: $num[$i +3]\nnot " + unless $result eq $num[$i +3]; + &ok; +} + +## test 44 - 57 the subtraction of the comp of the 'plus' category +## should invert the carry and add 1 to 'exp' +## start test at first 'number' that starts with '::FFFF' +for (my $i=0; $i<@num; $i+=4) { + next unless $num[$i] =~ /^::FFFF/; + my $num = ipv6_aton($num[$i]); + my $plus = ipv6_aton($num[$i +1]); + my $minus = comp128($plus); + my($rv,$result) = sub128($num,$minus); + print "got: $rv, exp: $num[$i +2]\nnot " + unless $rv == $num[$i +2]; + &ok; + $num[$i +3] =~ s/FFFE$/FFFF/; + $result = ipv6_n2x($result); + print "got: $result\nexp: $num[$i +3]\nnot " + unless $result eq $num[$i +3]; + &ok; +} diff --git a/Lite/Util/t/addconst.t b/Lite/Util/t/addconst.t new file mode 100644 index 0000000..dd28349 --- /dev/null +++ b/Lite/Util/t/addconst.t @@ -0,0 +1,77 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..20\n"; } +END {print "not ok 1\n" unless $loaded;} + +use NetAddr::IP::Util qw( + ipv6_aton + ipv6_n2x + inet_any2n + addconst +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +my @num = qw # input expected +( + :: 0:0:0:0:0:0:0:0 + :: 0:0:0:0:0:0:0:2 + ::FFFF 0:0:0:0:0:0:1:3 + ::FFFF:FFFF 0:0:0:0:0:1:0:5 + ::FFFF:FFFF:FFFF 0:0:0:0:1:0:0:7 + ::FFFF:FFFF:FFFF:ffff 0:0:0:1:0:0:0:9 + ::FFFF:FFFF:FFFF:ffff:ffff 0:0:1:0:0:0:0:B + ::FFFF:FFFF:FFFF:ffff:ffff:ffff 0:1:0:0:0:0:0:D + 0:FFFF:FFFF:FFFF:ffff:ffff:ffff:ffff 1:0:0:0:0:0:0:F + FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF 0:0:0:0:0:0:0:11 +); + +for (my $i=0; $i <@num; $i+=2) { + my $bnum = ipv6_aton($num[$i]); + my($carry,$rv) = addconst($bnum,$i); + $rv = ipv6_n2x($rv); + print "got: $rv\nexp: $num[$i +1]\nnot " + unless $rv eq $num[$i +1]; + &ok; +} + +@num = qw # input expected +( + FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF + :: FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFE + FFFF:: FFFE:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFC + FFFF:FFFF:: FFFF:FFFE:FFFF:FFFF:FFFF:FFFF:FFFF:FFFA + FFFF:FFFF:FFFF:: FFFF:FFFF:FFFE:FFFF:FFFF:FFFF:FFFF:FFF8 + ffff:ffff:ffff:ffff:: FFFF:FFFF:FFFF:FFFE:FFFF:FFFF:FFFF:FFF6 + ffff:ffff:ffff:ffff:ffff:: FFFF:FFFF:FFFF:FFFF:FFFE:FFFF:FFFF:FFF4 + ffff:ffff:ffff:ffff:ffff:ffff:: FFFF:FFFF:FFFF:FFFF:FFFF:FFFE:FFFF:FFF2 + FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:0 FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFE:FFF0 +); + +for (my $i=0; $i <@num; $i+=2) { + my $bnum = ipv6_aton($num[$i]); + my($carry,$rv) = addconst($bnum,-$i); + $rv = ipv6_n2x($rv); + print "got: $rv\nexp: $num[$i +1]\nnot " + unless $rv eq $num[$i +1]; + &ok; +} + diff --git a/Lite/Util/t/af_inet6.t b/Lite/Util/t/af_inet6.t new file mode 100644 index 0000000..e07b7a0 --- /dev/null +++ b/Lite/Util/t/af_inet6.t @@ -0,0 +1,46 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..3\n"; } +END {print "not ok 1\n" unless $loaded;} + +#use diagnostics; +use Config; +use NetAddr::IP::InetBase qw( + AF_INET + AF_INET6 + fake_AF_INET6 +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +## test 2 - 13 add stuff to buffer +my $af; +print "AF_INET = 2 not found in the Socket library\nnot " + unless ($af = AF_INET()) && $af == 2; +&ok; + +my $fake = fake_AF_INET6(); +my $af_inet6 = AF_INET6(); +my $txt = $fake + ? "\n\tSocket does not have AF_INET6, Socket6 not present\n\tguessed AF_INET6 for '$Config{osname}' = $fake\n" + : "\n\tAF_INET6 = $af_inet6 derived from Socket or Socket6\n"; +print STDERR $txt; +&ok; diff --git a/Lite/Util/t/anyto6.t b/Lite/Util/t/anyto6.t new file mode 100644 index 0000000..a4149ea --- /dev/null +++ b/Lite/Util/t/anyto6.t @@ -0,0 +1,86 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..7\n"; } +END {print "not ok 1\n" unless $loaded;} + +use NetAddr::IP::Util qw( + inet_aton + ipv6_n2d + ipv6_aton + ipanyto6 + maskanyto6 +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +my $nip = inet_aton('1.2.3.4'); +my $exp = '0:0:0:0:0:0:1.2.3.4'; + +## test 2 check 4->6 conversion +my $nipv6 = ipanyto6($nip); +my $ipv6 = ipv6_n2d($nipv6); +print "got: $ipv6\nexp: $exp\nnot " + unless $ipv6 eq $exp; +&ok; + + +## test 3 check mask4->6 extension +$exp = 'FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:1.2.3.4'; +$nipv6 = maskanyto6($nip); +$ipv6 = ipv6_n2d($nipv6); +print "got: $ipv6\nexp: $exp\nnot " + unless $ipv6 eq $exp && +&ok; + +## test 4 check bad length +$nip = pack("H9",0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09); +eval { + ipanyto6($nip); +}; +print "ipanyto6 accepted bad argument length\nnot " + unless $@ && $@ =~ /Bad arg.+ipanyto6/; +&ok; + +## test 5 check bad length +eval { + maskanyto6($nip); +}; +print "maskanyto6 accepted bad argument length\nnot " + unless $@ && $@ =~ /Bad arg.+maskanyto6/; +&ok; + +## test 6 check pass of ipv6 addrs +$nip = ipv6_aton('::1:2.3.4.5'); +$exp = '0:0:0:0:0:1:2.3.4.5'; +$nipv6 = ipanyto6($nip); +$ipv6 = ipv6_n2d($nipv6); +print "got: $ipv6\nexp: $exp\nnot " + unless $ipv6 eq $exp; +&ok; + +## test 7 check pass of ipv6 addrs +$nip = ipv6_aton('FFF::1:2.3.4.5'); +$exp = 'FFF:0:0:0:0:1:2.3.4.5'; +$nipv6 = maskanyto6($nip); +$ipv6 = ipv6_n2d($nipv6); +print "got: $ipv6\nexp: $exp\nnot " + unless $ipv6 eq $exp; +&ok; diff --git a/Lite/Util/t/badd.t b/Lite/Util/t/badd.t new file mode 100644 index 0000000..f13a473 --- /dev/null +++ b/Lite/Util/t/badd.t @@ -0,0 +1,69 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) +$| = 1; +END {print "1..1\nnot ok 1\n" unless $test;} + +use NetAddr::IP::Util qw( + ipv6_aton + ipv6_n2x +); + +$test = 1; + +sub ok { + print "ok $test\n"; + ++$test; +} + +my @addr = +qw( :: 0:0:0:0:0:0:0:0 + ::: undef + foo undef + ::foo undef + foo:: undef + abc::def::9 undef + abcd1:: undef + abcd:: abcd:0:0:0:0:0:0:0 + ::abcde undef + :a:b:c:d:1:2:3:4 undef + :a:b:c:d undef + a:b:c:d:1:2:3:4: undef + a:b:c:d:1:2:3:4:: undef + ::a:b:c:d:1:2:3:4 undef + ::a:b:c:d:1:2:3 0:a:b:c:d:1:2:3 + ::a:b:c:d:1:2:3: undef + :a:b:c:d:1:2:3:: undef + a:b:c:d:1:2:3:: a:b:c:d:1:2:3:0 +); + +my $x = @addr/2; + +# notify TEST about number of tests +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +print '1..',$x,"\n"; + +for ($x = 0;$x <= $#addr; $x+=2) { + my $bstr = ipv6_aton($addr[$x]); + if ($addr[$x +1] =~ /undef/) { + print "unexpected return value for $addr[$x]: $_\nnot " + if ($_ = ipv6_aton && (ipv6_n2x($_) || 'not defined')); + } else { + my $rv = ipv6_aton($addr[$x]); + unless ($rv) { + print "got undefined value for $addr[$x]\nnot "; + } + else { + $rv = ipv6_n2x($rv) || 'not defined'; + print "got: $rv, exp: $addr[$x +1]\nnot " + unless $rv eq uc $addr[$x +1]; + } + } + &ok; +} diff --git a/Lite/Util/t/bcd2bin.t b/Lite/Util/t/bcd2bin.t new file mode 100644 index 0000000..f089736 --- /dev/null +++ b/Lite/Util/t/bcd2bin.t @@ -0,0 +1,68 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..25\n"; } +END {print "not ok 1\n" unless $loaded;} + +use NetAddr::IP::Util qw( + bcd2bin + ipv6_n2x +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +my @num = # input expected +qw( + 0 0:0:0:0:0:0:0:0 + 2147483648 0:0:0:0:0:0:8000:0 + 4294967296 0:0:0:0:0:1:0:0 + 8589934592 0:0:0:0:0:2:0:0 + 10000000000 0:0:0:0:0:2:540B:E400 + 17179869184 0:0:0:0:0:4:0:0 + 34359738368 0:0:0:0:0:8:0:0 + 68719476736 0:0:0:0:0:10:0:0 + 137438953472 0:0:0:0:0:20:0:0 + 274877906944 0:0:0:0:0:40:0:0 + 549755813888 0:0:0:0:0:80:0:0 + 1099511627776 0:0:0:0:0:100:0:0 + 2199023255552 0:0:0:0:0:200:0:0 + 4398046511104 0:0:0:0:0:400:0:0 + 8796093022208 0:0:0:0:0:800:0:0 + 17592186044416 0:0:0:0:0:1000:0:0 + 35184372088832 0:0:0:0:0:2000:0:0 + 70368744177664 0:0:0:0:0:4000:0:0 + 140737488355328 0:0:0:0:0:8000:0:0 + 9223372036854775808 0:0:0:0:8000:0:0:0 + 604462909807314587353088 0:0:0:8000:0:0:0:0 + 39614081257132168796771975168 0:0:8000:0:0:0:0:0 + 2596148429267413814265248164610048 0:8000:0:0:0:0:0:0 + 170141183460469231731687303715884105728 8000:0:0:0:0:0:0:0 +); + +## tests 2 - 9 check pack correct + +for (my $i=0;$i<@num;$i+=2) { +print $num[$i],"\n"; + my $bits = bcd2bin($num[$i]); + my $ip = ipv6_n2x($bits); + print "got: $ip\nexp: $num[$i +1]\nnot " + unless $ip eq $num[$i +1]; + &ok; +} diff --git a/Lite/Util/t/bcdn2bin.t b/Lite/Util/t/bcdn2bin.t new file mode 100644 index 0000000..baf1723 --- /dev/null +++ b/Lite/Util/t/bcdn2bin.t @@ -0,0 +1,73 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..25\n"; } +END {print "not ok 1\n" unless $loaded;} + +use NetAddr::IP::Util qw( + ipv6_n2x + bcdn2bin +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +my @num = # input expected +qw( + 0 0:0:0:0:0:0:0:0 + 2147483648 0:0:0:0:0:0:8000:0 + 4294967296 0:0:0:0:0:1:0:0 + 8589934592 0:0:0:0:0:2:0:0 + 10000000000 0:0:0:0:0:2:540B:E400 + 17179869184 0:0:0:0:0:4:0:0 + 34359738368 0:0:0:0:0:8:0:0 + 68719476736 0:0:0:0:0:10:0:0 + 137438953472 0:0:0:0:0:20:0:0 + 274877906944 0:0:0:0:0:40:0:0 + 549755813888 0:0:0:0:0:80:0:0 + 1099511627776 0:0:0:0:0:100:0:0 + 2199023255552 0:0:0:0:0:200:0:0 + 4398046511104 0:0:0:0:0:400:0:0 + 8796093022208 0:0:0:0:0:800:0:0 + 17592186044416 0:0:0:0:0:1000:0:0 + 35184372088832 0:0:0:0:0:2000:0:0 + 70368744177664 0:0:0:0:0:4000:0:0 + 140737488355328 0:0:0:0:0:8000:0:0 + 9223372036854775808 0:0:0:0:8000:0:0:0 + 604462909807314587353088 0:0:0:8000:0:0:0:0 + 39614081257132168796771975168 0:0:8000:0:0:0:0:0 + 2596148429267413814265248164610048 0:8000:0:0:0:0:0:0 + 170141183460469231731687303715884105728 8000:0:0:0:0:0:0:0 +); + +## tests 2 - 9 check pack correct + +#use Devel::Peek 'Dump'; + +for (my $i=0;$i<@num;$i+=2) { +print $num[$i],"\n"; + my $pkd = pack("H*",$num[$i]); + my $len = length($num[$i]); +#Dump($pkd); + my $bits = bcdn2bin($pkd,$len); + my $ip = ipv6_n2x($bits); + print "got: $ip\nexp: $num[$i +1]\nnot " + unless $ip eq $num[$i +1]; + &ok; +} diff --git a/Lite/Util/t/bin.t b/Lite/Util/t/bin.t new file mode 100644 index 0000000..49c3a60 --- /dev/null +++ b/Lite/Util/t/bin.t @@ -0,0 +1,111 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..25\n"; } +END {print "not ok 1\n" unless $loaded;} + +use NetAddr::IP::Util qw( + ipv6_aton + bin2bcd + bin2bcdn + bcdn2txt +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +# input: array ref, value ref, number ref +# +sub val { + my $bcd = shift; + my $rv = unpack("H*",$bcd); + $rv =~ s/^0+(\d)/$1/g; + return $rv; +} + +sub numnum { + my($ar,$i) = @_; + return sprintf("%.0f",$ar->[$i +1]); +} + +sub numstr { + my($ar,$i) = @_; + return $ar->[$i+1]; +} + +sub dotest { + my($ar,$vr,$nr) = @_; + for(my $i=0;$i<@$ar;$i+=2) { + my $bstr = ipv6_aton($ar->[$i]); + my $bcd = bin2bcdn($bstr); + my $val = $vr->($bcd); + my $exp = $nr->($ar,$i); + print "\t\t$val\n"; + print "got: $val\nexp: $exp\nnot " + unless $val eq $exp; + &ok; + } +} + +# setup only, can't depend on float to do it right on all systems +#my @num1 = # input expected +#( +# '::' => 0, +# '::8000:0' => 2**(15+16), +# '::8000:0:0' => 2**(15+(16*2)), +# '::8000:0:0:0' => 2**(15+(16*3)), +# '::8000:0:0:0:0' => 2**(15+(16*4)), +# '::8000:0:0:0:0:0' => 2**(15+(16*5)), +# '::8000:0:0:0:0:0:0' => 2**(15+(16*6)), +# '8000:0:0:0:0:0:0:0' => 2**(15+(16*7)), +#); + +my @num2 = qw( + :: 0 + ::8000:0 2147483648 + ::8000:0:0 140737488355328 + ::8000:0:0:0 9223372036854775808 + ::8000:0:0:0:0 604462909807314587353088 + ::8000:0:0:0:0:0 39614081257132168796771975168 + ::8000:0:0:0:0:0:0 2596148429267413814265248164610048 + 8000:0:0:0:0:0:0:0 170141183460469231731687303715884105728 +); + +## tests 2 - 9 bin2bcdn numeric unpack +#dotest(\@num1,\&val,\&numnum); + +## tests 10 - 17 bin2bcdn string unpack TEST 2 - 9 +dotest(\@num2,\&val,\&numstr); + +## tests 18 - 25 bin2bcdn numeric bcdn2txt +#dotest(\@num1,\&bcdn2txt,\&numnum); + +## tests 26 - 33 bin2bcdn string bcdn2txt TEST 10 - 17 +dotest(\@num2,\&bcdn2txt,\&numstr); + +## tests 34 - 41 bin2bcd TEST 18 - 25 +for(my $i=0;$i<@num2;$i+=2) { + my $bstr = ipv6_aton($num2[$i]); + my $bcd = bin2bcd($bstr); + my $exp = $num2[$i +1]; + print "\t\t$bcd\n"; + print "got: $bcd\nexp: $exp\nnot " + unless $bcd eq $exp; + &ok; +} diff --git a/Lite/Util/t/binet_n2ad.t b/Lite/Util/t/binet_n2ad.t new file mode 100644 index 0000000..1d575e0 --- /dev/null +++ b/Lite/Util/t/binet_n2ad.t @@ -0,0 +1,49 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..4\n"; } +END {print "not ok 1\n" unless $loaded;} + +use NetAddr::IP::InetBase qw( + :upper + ipv6_aton + ipv6_n2x + inet_any2n + inet_n2ad +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +my @num = qw # input expected +( a1b2:c3d4:e5d6:f7e8:08f9:190a:2a1b:3b4c A1B2:C3D4:E5D6:F7E8:8F9:190A:42.27.59.76 + 1.2.3.4 1.2.3.4 + 190A::102:304 190A:0:0:0:0:0:1.2.3.4 +); + +my $ff = ipv6_aton($num[1]); +for(my $i=0;$i<@num;$i+=2) { + my $num = $num[$i]; + my $bstr = inet_any2n($num); + my $rv = inet_n2ad($bstr); + my $exp = $num[$i +1]; + print "got: $rv\nexp: $exp\nnot " + unless $rv eq $exp; + &ok; +} diff --git a/Lite/Util/t/binet_n2dx.t b/Lite/Util/t/binet_n2dx.t new file mode 100644 index 0000000..8f99333 --- /dev/null +++ b/Lite/Util/t/binet_n2dx.t @@ -0,0 +1,50 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..6\n"; } +END {print "not ok 1\n" unless $loaded;} + +use NetAddr::IP::InetBase qw( + :upper + ipv6_aton + inet_any2n + inet_n2dx +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +my @num = qw # input expected +( a1b2:c3d4:e5d6:f7e8:08f9:190a:2a1b:3b4c A1B2:C3D4:E5D6:F7E8:8F9:190A:2A1B:3B4C + 1.2.3.4 1.2.3.4 + A1B2:C3D4:E5D6:F7E8:08F9:190A:1.2.3.4 A1B2:C3D4:E5D6:F7E8:8F9:190A:102:304 + ::1.2.3.4 1.2.3.4 + ::FFFF:1.2.3.4 1.2.3.4 +); + +my $ff = ipv6_aton($num[1]); +for(my $i=0;$i<@num;$i+=2) { + my $num = $num[$i]; + my $bstr = inet_any2n($num); + my $rv = inet_n2dx($bstr); + my $exp = $num[$i +1]; + print "got: $rv\nexp: $exp\nnot " + unless $rv eq $exp; + &ok; +} diff --git a/Lite/Util/t/binet_ntoa.t b/Lite/Util/t/binet_ntoa.t new file mode 100644 index 0000000..5be3763 --- /dev/null +++ b/Lite/Util/t/binet_ntoa.t @@ -0,0 +1,66 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..20\n"; } +END {print "not ok 1\n" unless $loaded;} + +#use diagnostics; +use NetAddr::IP::InetBase qw( + ipv6_ntoa + inet_pton + AF_INET6 +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +## test 2 - 19 add stuff to buffer +my @num = # in exphex +qw( + :: :: + 43:: 43:: + ::21 ::21 + ::1:2:3:4:5:6:7 0:1:2:3:4:5:6:7 + 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:0 + 1::8 1::8 + FF00::FFFF ff00::ffff + FFFF::FFFF:FFFF ffff::ffff:ffff + A1B2:C3D4:E5D6:F7E8:08F9:190A:1.2.3.4 a1b2:c3d4:e5d6:f7e8:8f9:190a:102:304 +); + +for (my $i=0;$i<@num;$i+=2) { + my $bits = inet_pton(AF_INET6(),$num[$i]); + my $len = length($bits); + print "bad len = $len, exp: 16\nnot " + unless $len == 16; # 16 bytes x 8 bits + &ok; + my $ipv6x = ipv6_ntoa($bits); + print "got: $ipv6x\nexp: $num[$i +1]\nnot " + unless $ipv6x eq $num[$i +1]; + &ok; +} + +## test 32 check bad length ntop +my $try = '1234'; +my $notempty = eval { + ipv6_ntoa($try); +}; +print "failed bad argument length test for ipv6_ntoa\nnot " + unless $@ && $@ =~ /Bad arg/; +&ok; diff --git a/Lite/Util/t/binet_pton.t b/Lite/Util/t/binet_pton.t new file mode 100644 index 0000000..cd37372 --- /dev/null +++ b/Lite/Util/t/binet_pton.t @@ -0,0 +1,96 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..32\n"; } +END {print "not ok 1\n" unless $loaded;} + +#use diagnostics; +use NetAddr::IP::InetBase qw( + :upper + :ipv6 + AF_INET + AF_INET6 +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +## test 2 - 13 add stuff to buffer +my @num = # addr +qw( + 0.0.0.0 + 255.255.255.255 + 1.2.3.4 + 10.253.230.9 +); + +foreach (@num) { + my @digs = split(/\./,$_); + my $pkd = pack('C4',@digs); + my $naddr = inet_pton(AF_INET(),$_); + my $addr = join('.',unpack('C4',$naddr)); + my $num = inet_ntop(AF_INET(),$pkd); + + print "bits do not match\nnot " + unless $naddr eq $pkd; + &ok; + + print "inet_pton: $addr, exp: $_\nnot " + unless $addr eq $_; + &ok; + + print "inet_ntop: $num, exp: $_\nnot " + unless $num eq $_; + &ok; +} + +## test 14 - 31 +@num = # in exphex +qw( + :: :: + 43:: 43:: + ::21 ::21 + ::1:2:3:4:5:6:7 0:1:2:3:4:5:6:7 + 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:0 + 1::8 1::8 + FF00::FFFF ff00::ffff + FFFF::FFFF:FFFF ffff::ffff:ffff + A1B2:C3D4:E5D6:F7E8:08F9:190A:1.2.3.4 a1b2:c3d4:e5d6:f7e8:8f9:190a:102:304 +); + +for (my $i=0;$i<@num;$i+=2) { + my $bits = inet_pton(AF_INET6(),$num[$i]); + my $len = length($bits); + print "bad len = $len, exp: 16\nnot " + unless $len == 16; # 16 bytes x 8 bits + &ok; + my $ipv6x = inet_ntop(AF_INET6(),$bits); + print "got: $ipv6x\nexp: $num[$i +1]\nnot " + unless $ipv6x eq $num[$i +1]; + &ok; +} + +## test 32 check bad length ntop +my $try = '1234'; +my $notempty = eval { + inet_ntop(AF_INET6(),$try); +}; +print "failed bad argument length test for inet_ntop\nnot " + unless $@ && $@ =~ /Bad arg/; +&ok; diff --git a/Lite/Util/t/bipv4_inet.t b/Lite/Util/t/bipv4_inet.t new file mode 100644 index 0000000..1a32ca3 --- /dev/null +++ b/Lite/Util/t/bipv4_inet.t @@ -0,0 +1,59 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..13\n"; } +END {print "not ok 1\n" unless $loaded;} + +#use diagnostics; +use NetAddr::IP::InetBase qw( + inet_ntoa + inet_aton +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +## test 2 add stuff to buffer +my @num = # addr +qw( + 0.0.0.0 + 255.255.255.255 + 1.2.3.4 + 10.253.230.9 +); + +foreach (@num) { + my @digs = split(/\./,$_); + my $pkd = pack('C4',@digs); + my $naddr = inet_aton($_); + my $addr = join('.',unpack('C4',$naddr)); + my $num = inet_ntoa($pkd); + + print "bits do not match\nnot " + unless $naddr eq $pkd; + &ok; + + print "inet_aton: $addr, exp: $_\nnot " + unless $addr eq $_; + &ok; + + print "inet_ntoa: $num, exp: $_\nnot " + unless $num eq $_; + &ok; +} diff --git a/Lite/Util/t/bipv6_any2n.t b/Lite/Util/t/bipv6_any2n.t new file mode 100644 index 0000000..bfdba4a --- /dev/null +++ b/Lite/Util/t/bipv6_any2n.t @@ -0,0 +1,48 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..4\n"; } +END {print "not ok 1\n" unless $loaded;} + +use NetAddr::IP::InetBase qw( + :upper + ipv6_aton + ipv6_n2x + inet_any2n +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +my @num = qw # input expected +( a1b2:c3d4:e5d6:f7e8:08f9:190a:2a1b:3b4c A1B2:C3D4:E5D6:F7E8:8F9:190A:2A1B:3B4C + 1.2.3.4 0:0:0:0:0:0:102:304 + A1B2:C3D4:E5D6:F7E8:08F9:190A:1.2.3.4 A1B2:C3D4:E5D6:F7E8:8F9:190A:102:304 +); + +my $ff = ipv6_aton($num[1]); +for(my $i=0;$i<@num;$i+=2) { + my $num = $num[$i]; + my $bstr = inet_any2n($num); + my $rv = ipv6_n2x($bstr); + my $exp = $num[$i +1]; + print "got: $rv\nexp: $exp\nnot " + unless $rv eq $exp; + &ok; +} diff --git a/Lite/Util/t/bipv6func.t b/Lite/Util/t/bipv6func.t new file mode 100644 index 0000000..2cff0d9 --- /dev/null +++ b/Lite/Util/t/bipv6func.t @@ -0,0 +1,76 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..27\n"; } +END {print "not ok 1\n" unless $loaded;} + +use NetAddr::IP::InetBase qw( + :upper + ipv6_aton + ipv6_n2x + ipv6_n2d +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +my @num = # in exphex expd +qw( + :: 0:0:0:0:0:0:0:0 0:0:0:0:0:0:0.0.0.0 + 43:: 43:0:0:0:0:0:0:0 43:0:0:0:0:0:0.0.0.0 + ::21 0:0:0:0:0:0:0:21 0:0:0:0:0:0:0.0.0.33 + ::1:2:3:4:5:6:7 0:1:2:3:4:5:6:7 0:1:2:3:4:5:0.6.0.7 + 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:0 1:2:3:4:5:6:0.7.0.0 + 1::8 1:0:0:0:0:0:0:8 1:0:0:0:0:0:0.0.0.8 + FF00::FFFF FF00:0:0:0:0:0:0:FFFF FF00:0:0:0:0:0:0.0.255.255 + FFFF::FFFF:FFFF FFFF:0:0:0:0:0:FFFF:FFFF FFFF:0:0:0:0:0:255.255.255.255 +); + +for (my $i=0;$i<@num;$i+=3) { + my $bits = ipv6_aton($num[$i]); + my $len = length($bits); + print "bad len = $len, exp: 16\nnot " + unless $len == 16; # 16 bytes x 8 bits + &ok; + my $ipv6x = ipv6_n2x($bits); + print "got: $ipv6x\nexp: $num[$i +1]\nnot " + unless $ipv6x eq $num[$i +1]; + &ok; + my $ipv6d = ipv6_n2d($bits); + print "got: $ipv6d\nexp: $num[$i +2]\nnot " + unless $ipv6d eq $num[$i +2]; + &ok; +} + +## test 26 check bad length n2x +my $try = '1234'; +my $notempty = eval { + ipv6_n2x($try); +}; +print "failed bad argument length test for ipv6_n2x\nnot " + unless $@ && $@ =~ /Bad arg/; +&ok; + +## test 27 check bad length n2d +$notempty = eval { + ipv6_n2d($try); +}; +print "failed bad argument length test for ipv6_n2d\nnot " + unless $@ && $@ =~ /Bad arg/; +&ok; diff --git a/Lite/Util/t/bisIPv4.t b/Lite/Util/t/bisIPv4.t new file mode 100644 index 0000000..57c6893 --- /dev/null +++ b/Lite/Util/t/bisIPv4.t @@ -0,0 +1,186 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..421\n"; } +END {print "not ok 1\n" unless $loaded;} + +use NetAddr::IP::InetBase qw( + :upper + ipv6_aton + ipv6_n2x + isIPv4 + isNewIPv4 + isAnyIPv4 +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +my @num = qw # input +( + :: + 8000:: + 4000:: + 2000:: + 1000:: + 800:: + 400:: + 200:: + 100:: + 80:: + 40:: + 20:: + 10:: + 1:: + 0:8000:: + 0:4000:: + 0:2000:: + 0:1000:: + 0:800:: + 0:400:: + 0:200:: + 0:100:: + 0:80:: + 0:40:: + 0:20:: + 0:10:: + 0:1:: + 0:0:8000:: + 0:0:4000:: + 0:0:2000:: + 0:0:1000:: + 0:0:800:: + 0:0:400:: + 0:0:200:: + 0:0:100:: + 0:0:80:: + 0:0:40:: + 0:0:20:: + 0:0:10:: + 0:0:1:: + 0:0:0:8000:: + 0:0:0:4000:: + 0:0:0:2000:: + 0:0:0:1000:: + 0:0:0:800:: + 0:0:0:400:: + 0:0:0:200:: + 0:0:0:100:: + 0:0:0:80:: + 0:0:0:40:: + 0:0:0:20:: + 0:0:0:10:: + 0:0:0:1:: + 0:0:0:0:8000:: + 0:0:0:0:4000:: + 0:0:0:0:2000:: + 0:0:0:0:1000:: + 0:0:0:0:800:: + 0:0:0:0:400:: + 0:0:0:0:200:: + 0:0:0:0:100:: + 0:0:0:0:80:: + 0:0:0:0:40:: + 0:0:0:0:20:: + 0:0:0:0:10:: + 0:0:0:0:1:: + 0:0:0:0:0:8000:: + 0:0:0:0:0:4000:: + 0:0:0:0:0:2000:: + 0:0:0:0:0:1000:: + 0:0:0:0:0:800:: + 0:0:0:0:0:400:: + 0:0:0:0:0:200:: + 0:0:0:0:0:100:: + 0:0:0:0:0:80:: + 0:0:0:0:0:40:: + 0:0:0:0:0:20:: + 0:0:0:0:0:10:: + 0:0:0:0:0:1:: + ::8000:0 + ::4000:0 + ::2000:0 + ::1000:0 + ::800:0 + ::400:0 + ::200:0 + ::100:0 + ::80:0 + ::40:0 + ::20:0 + ::10:0 + ::1:0 + ::8000 + ::4000 + ::2000 + ::1000 + ::800 + ::400 + ::200 + ::100 + ::80 + ::40 + ::20 + ::10 + ::1 +); + +# check isIPv4 + +foreach (@num) { + my $bstr = ipv6_aton($_); + my $rv = isIPv4($bstr); + my $exp = ($_ =~ /\d::$/) ? 0:1; + print "got: $rv, exp: $exp for ", ipv6_n2x($bstr), "\nnot " + unless $rv eq $exp; + &ok; +} + +# check isAnyIPv4 +foreach (@num) { + my $bstr = ipv6_aton($_); + my $rv = isAnyIPv4($bstr); + my $exp = ($_ =~ /\d::$/) ? 0:1; + print "got: $rv, exp: $exp for ", ipv6_n2x($bstr), "\nnot " + unless $rv eq $exp; + &ok; +} + +my $compat = ipv6_aton('::FFFF:0:0'); + +# check isAnyIPv4 with compatible high bits +foreach (@num) { + my $bstr = ipv6_aton($_); + $bstr ^= $compat; + my $rv = isAnyIPv4($bstr); + my $exp = ($_ =~ /\d::$/) ? 0:1; + print "got: $rv, exp: $exp for ", ipv6_n2x($bstr), "\nnot " + unless $rv eq $exp; + &ok; +} +# check isNewIPv4 with compatible high bits +foreach (@num) { + my $bstr = ipv6_aton($_); + $bstr ^= $compat; + my $rv = isNewIPv4($bstr); + my $exp = ($_ =~ /\d::$/) ? 0:1; + print "got: $rv, exp: $exp for ", ipv6_n2x($bstr), "\nnot " + unless $rv eq $exp; + &ok; +} diff --git a/Lite/Util/t/bpackzeros.t b/Lite/Util/t/bpackzeros.t new file mode 100644 index 0000000..7afdd0d --- /dev/null +++ b/Lite/Util/t/bpackzeros.t @@ -0,0 +1,52 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..13\n"; } +END {print "not ok 1\n" unless $loaded;} + +use NetAddr::IP::InetBase qw( + packzeros +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +my @addr = qw # input expected +( D0:00:0000:0000:000:b00:0000:000 d0::b00:0:0 + 0d0:00:0000:0000:000:0b00:: d0::b00:0:0 + ::c3D4:E5d6:0:0:0:0 0:0:c3d4:e5d6:: + 0:0000:c3D4:e5d6:0:0:0:0 0:0:c3d4:e5d6:: + 0:0:0:0:0:0:0:0 :: + 0:0:: :: + ::0:000:0 :: + 0:0::1.2.3.4 ::1.2.3.4 + ::1.2.3.4 ::1.2.3.4 + ::01b2:c3D4:0:0:0:1.2.3.4 0:1b2:c3d4::1.2.3.4 + 0:0:0:0:a1B2:c3d4:: ::a1b2:c3d4:0:0 + 12:0:0:0:34:0:00:000 12::34:0:0:0 +); + +for(my $i=0;$i<@addr;$i+=2) { + my $addr = $addr[$i]; + my $rv = packzeros($addr); + my $exp = $addr[$i +1]; + print "got: $rv\nexp: $exp\nnot " + unless $rv eq $exp; + &ok; +} diff --git a/Lite/Util/t/comp128.t b/Lite/Util/t/comp128.t new file mode 100644 index 0000000..808af2b --- /dev/null +++ b/Lite/Util/t/comp128.t @@ -0,0 +1,48 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..4\n"; } +END {print "not ok 1\n" unless $loaded;} + +use NetAddr::IP::Util qw( + ipv6_aton + ipv6_n2x + comp128 +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +my @num = qw # input expected +( :: FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF + FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF 0:0:0:0:0:0:0:0 + A1B2:C3D4:E5D6:F7E8:08F9:190A:2A1B:3B4C 5E4D:3C2B:1A29:817:F706:E6F5:D5E4:C4B3 +); + +my $ff = ipv6_aton($num[1]); +for(my $i=0;$i<@num;$i+=2) { + my $num = $num[$i]; + my $bstr = ipv6_aton($num); + my $cnum = comp128($bstr); + my $rv = ipv6_n2x($cnum); + my $exp = $num[$i +1]; + print "got: $rv\nexp: $exp\nnot " + unless $rv eq $exp; + &ok; +} diff --git a/Lite/Util/t/croak.t b/Lite/Util/t/croak.t new file mode 100644 index 0000000..b939458 --- /dev/null +++ b/Lite/Util/t/croak.t @@ -0,0 +1,168 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..31\n"; } +END {print "not ok 1\n" unless $loaded;} + +use NetAddr::IP::Util qw( + bcd2bin + bin2bcd + hasbits + isIPv4 + add128 + sub128 + shiftleft + comp128 + bcdn2txt + bin2bcdn + bcdn2bin + simple_pack +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +## tests 2 - 9 simple_pack + +foreach( + '1234/', + '1234:', + 'a1234', + '&1234', +) { + my $rv; + eval { $rv = simple_pack($_) }; + if (defined $rv) { + $rv = unpack("H40",$rv); + print "got: $rv, exp: 'die'\nnot "; + } + &ok; + + print "expected a die from bad character input\nnot " + unless $@ && $@ =~ /Bad/; + &ok; +} + +## tests 10 - 17 bcd2bin + +foreach( + '1234/', + '1234:', + 'a1234', + '&1234', +) { + my $rv; + eval { $rv = bcd2bin($_) }; + if (defined $rv) { + $rv = unpack("H40",$rv); + print "got: $rv, exp: 'die'\nnot "; + } + &ok; + + print "expected a die from bad character input\nnot " + unless $@ && $@ =~ /Bad/; + &ok; +} + +## test 18 bcdn2bin +eval { bcdn2bin('123456789012345678901') }; +print "expected a die from bad vector string length\nnot " + unless $@ && $@ =~ /Bad/; +&ok; + +## test 19 bcdn2bin +eval { bcdn2bin('12345678901234567890') }; +print "expected a die from missing length specifier\nnot " + unless $@ && $@ =~ /Bad/; +&ok; + +## test 20 bin2bcd +eval { bin2bcd('123') }; +print "expected a die from bad vector string length\nnot " + unless $@ && $@ =~ /Bad/; +&ok; + +## test 21 bin2bcdn +eval { bin2bcdn('123') }; +print "expected a die from bad vector string length\nnot " + unless $@ && $@ =~ /Bad/; +&ok; + +## test 22 bcdn2txt +eval { bcdn2txt('123456789012345678901') }; +print "expected a die from bad vector string length\nnot " + unless $@ && $@ =~ /Bad/; +&ok; + +## test 23 bcdn2txt +my $rv; +my $exp = '3132333435363738393031323334353637383930'; +$rv = bcdn2txt('12345678901234567890'); +print "got: $rv\nexp: $exp\nnot " + unless $rv eq $exp; +&ok; + +## test 24 hasbits +eval { hasbits('123') }; +print "expected a die from bad vector string length\nnot " + unless $@ && $@ =~ /Bad/; +&ok; + +## test 25 isIPv4 +eval { isIPv4('12345678901234567') }; +print "expected a die from bad vector string length\nnot " + unless $@ && $@ =~ /Bad/; +&ok; + +## test 26 add128 +eval { add128('123','1234567890123456') }; +print "expected a die from bad vector string length\nnot " + unless $@ && $@ =~ /Bad/; +&ok; + +## test 27 sub128 +eval { sub128('1234567890123456','12345678901234567') }; +print "expected a die from bad vector string length\nnot " + unless $@ && $@ =~ /Bad/; +&ok; + +## test 28 comp128 +eval { comp128('123') }; +print "expected a die from bad vector string length\nnot " + unless $@ && $@ =~ /Bad/; +&ok; + +## test 29 shiftleft +eval { shiftleft ('12345678901234567') }; +print "expected a die from bad vector string length\nnot " + unless $@ && $@ =~ /Bad/; +&ok; + +## test 30 shiftleft +eval { shiftleft ('1234567890123456',-1) }; +print "expected a die from bad shift count specifier\nnot " + unless $@ && $@ =~ /Bad/; +&ok; + +## test 31 shiftleft +eval { shiftleft ('1234567890123456',129) }; +print "expected a die from bad shift count specifier\nnot " + unless $@ && $@ =~ /Bad/; +&ok; + diff --git a/Lite/Util/t/hasbits.t b/Lite/Util/t/hasbits.t new file mode 100644 index 0000000..780cc3a --- /dev/null +++ b/Lite/Util/t/hasbits.t @@ -0,0 +1,147 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) +$| = 1; +END {print "1..1\nnot ok 1\n" unless $test;} + +use NetAddr::IP::Util qw( + ipv6_aton + ipv6_n2x + hasbits +); + +$test = 1; + +sub ok { + print "ok $test\n"; + ++$test; +} + +my @num = qw # input +( + :: + 8000:: + 4000:: + 2000:: + 1000:: + 800:: + 400:: + 200:: + 100:: + 80:: + 40:: + 20:: + 10:: + 1:: + 0:8000:: + 0:4000:: + 0:2000:: + 0:1000:: + 0:800:: + 0:400:: + 0:200:: + 0:100:: + 0:80:: + 0:40:: + 0:20:: + 0:10:: + 0:1:: + 0:0:8000:: + 0:0:4000:: + 0:0:2000:: + 0:0:1000:: + 0:0:800:: + 0:0:400:: + 0:0:200:: + 0:0:100:: + 0:0:80:: + 0:0:40:: + 0:0:20:: + 0:0:10:: + 0:0:1:: + 0:0:0:8000:: + 0:0:0:4000:: + 0:0:0:2000:: + 0:0:0:1000:: + 0:0:0:800:: + 0:0:0:400:: + 0:0:0:200:: + 0:0:0:100:: + 0:0:0:80:: + 0:0:0:40:: + 0:0:0:20:: + 0:0:0:10:: + 0:0:0:1:: + ::8000:0:0:0 + ::4000:0:0:0 + ::2000:0:0:0 + ::1000:0:0:0 + ::800:0:0:0 + ::400:0:0:0 + ::200:0:0:0 + ::100:0:0:0 + ::80:0:0:0 + ::40:0:0:0 + ::20:0:0:0 + ::10:0:0:0 + ::1:0:0:0 + ::8000:0:0 + ::4000:0:0 + ::2000:0:0 + ::1000:0:0 + ::800:0:0 + ::400:0:0 + ::200:0:0 + ::100:0:0 + ::80:0:0 + ::40:0:0 + ::20:0:0 + ::10:0:0 + ::1:0:0 + ::8000:0 + ::4000:0 + ::2000:0 + ::1000:0 + ::800:0 + ::400:0 + ::200:0 + ::100:0 + ::80:0 + ::40:0 + ::20:0 + ::10:0 + ::1:0 + ::8000 + ::4000 + ::2000 + ::1000 + ::800 + ::400 + ::200 + ::100 + ::80 + ::40 + ::20 + ::10 + ::1 + ::8000:0:0:0:0 + ::8000:0:0:0:0:0 + ::8000:0:0:0:0:0:0 + 8000:0:0:0:0:0:0:0 +); +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): +print '1..',(scalar @num), "\n"; + +foreach (@num) { + my $bstr = ipv6_aton($_); + my $rv = hasbits($bstr); + my $exp = ($_ eq '::') ? 0:1; + print "got: $rv, exp: $exp for ", ipv6_n2x($bstr), "\nnot " + unless $rv eq $exp; + &ok; +} diff --git a/Lite/Util/t/inet_4map6.t b/Lite/Util/t/inet_4map6.t new file mode 100644 index 0000000..edb06a8 --- /dev/null +++ b/Lite/Util/t/inet_4map6.t @@ -0,0 +1,70 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) +$| = 1; +END {print "1..1\nnot ok 1\n" unless $test;} + +#use diagnostics; +use NetAddr::IP::Util qw( + ipv6_n2d + inet_aton + ipv6_aton + inet_4map6 +); + +$test = 1; + +sub ok { + print "ok $test\n"; + ++$test; +} + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): +print "1..6\n"; + +my @stuff = qw( + 192.168.1.1 + 1.2.3.4 + ::3.4.5.6 + ::FFFF:4.5.6.7 + ::1:5.4.3.2 + ::FEFF:4.3.2.1 +); + + my $p4 = '0:0:0:0:0:FFFF:'; + my $p6 = '0:0:0:0:0:'; + + foreach(0..$#stuff) { + my $pass = 1; + my $result; + my $bstr; + $pass = 0 if $_ > 3; + if ($stuff[$_] =~ /\:/) { + $bstr = ipv6_aton($stuff[$_]); + my $prefix = ($stuff[$_] =~ /^\:\:F/) + ? $p6 : $p4; + ($result = $stuff[$_]) =~ s/\:\:/$prefix/; + } + else { + $bstr = inet_aton($stuff[$_]); + $result = $p4 . $stuff[$_]; + } + my $rv = inet_4map6($bstr); + if ($pass && ! $rv) { + print "failed to return valid address\nnot "; + } + elsif ($pass) { + $rv = ipv6_n2d($rv); + print "got: $rv, exp: $result\nnot " unless $rv eq $result; + } + else { + print 'unknown return ', ipv6_n2d($rv), "\nnot " if $rv; + } + &ok; + } + diff --git a/Lite/Util/t/inet_n2ad.t b/Lite/Util/t/inet_n2ad.t new file mode 100644 index 0000000..63846b4 --- /dev/null +++ b/Lite/Util/t/inet_n2ad.t @@ -0,0 +1,48 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..4\n"; } +END {print "not ok 1\n" unless $loaded;} + +use NetAddr::IP::Util qw( + ipv6_aton + ipv6_n2x + inet_any2n + inet_n2ad +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +my @num = qw # input expected +( a1b2:c3d4:e5d6:f7e8:08f9:190a:2a1b:3b4c A1B2:C3D4:E5D6:F7E8:8F9:190A:42.27.59.76 + 1.2.3.4 1.2.3.4 + 190A::102:304 190A:0:0:0:0:0:1.2.3.4 +); + +my $ff = ipv6_aton($num[1]); +for(my $i=0;$i<@num;$i+=2) { + my $num = $num[$i]; + my $bstr = inet_any2n($num); + my $rv = inet_n2ad($bstr); + my $exp = $num[$i +1]; + print "got: $rv\nexp: $exp\nnot " + unless $rv eq $exp; + &ok; +} diff --git a/Lite/Util/t/inet_n2dx.t b/Lite/Util/t/inet_n2dx.t new file mode 100644 index 0000000..93e5db5 --- /dev/null +++ b/Lite/Util/t/inet_n2dx.t @@ -0,0 +1,50 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..6\n"; } +END {print "not ok 1\n" unless $loaded;} + +use NetAddr::IP::Util qw( + ipv6_aton + ipv6_n2x + inet_any2n + inet_n2dx +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +my @num = qw # input expected +( a1b2:c3d4:e5d6:f7e8:08f9:190a:2a1b:3b4c A1B2:C3D4:E5D6:F7E8:8F9:190A:2A1B:3B4C + 1.2.3.4 1.2.3.4 + A1B2:C3D4:E5D6:F7E8:08F9:190A:1.2.3.4 A1B2:C3D4:E5D6:F7E8:8F9:190A:102:304 + ::1.2.3.4 1.2.3.4 + ::FFFF:1.2.3.4 1.2.3.4 +); + +my $ff = ipv6_aton($num[1]); +for(my $i=0;$i<@num;$i+=2) { + my $num = $num[$i]; + my $bstr = inet_any2n($num); + my $rv = inet_n2dx($bstr); + my $exp = $num[$i +1]; + print "got: $rv\nexp: $exp\nnot " + unless $rv eq $exp; + &ok; +} diff --git a/Lite/Util/t/inet_pton.t b/Lite/Util/t/inet_pton.t new file mode 100644 index 0000000..2058063 --- /dev/null +++ b/Lite/Util/t/inet_pton.t @@ -0,0 +1,96 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..32\n"; } +END {print "not ok 1\n" unless $loaded;} + +#use diagnostics; +use NetAddr::IP::Util qw( + inet_ntop + inet_pton + AF_INET + AF_INET6 +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +## test 2 - 13 add stuff to buffer +my @num = # addr +qw( + 0.0.0.0 + 255.255.255.255 + 1.2.3.4 + 10.253.230.9 +); + +foreach (@num) { + my @digs = split(/\./,$_); + my $pkd = pack('C4',@digs); + my $naddr = inet_pton(AF_INET(),$_); + my $addr = join('.',unpack('C4',$naddr)); + my $num = inet_ntop(AF_INET(),$pkd); + + print "bits do not match\nnot " + unless $naddr eq $pkd; + &ok; + + print "inet_pton: $addr, exp: $_\nnot " + unless $addr eq $_; + &ok; + + print "inet_ntop: $num, exp: $_\nnot " + unless $num eq $_; + &ok; +} + +## test 14 - 31 +@num = # in exphex +qw( + :: :: + 43:: 43:: + ::21 ::21 + ::1:2:3:4:5:6:7 0:1:2:3:4:5:6:7 + 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:0 + 1::8 1::8 + FF00::FFFF ff00::ffff + FFFF::FFFF:FFFF ffff::ffff:ffff + A1B2:C3D4:E5D6:F7E8:08F9:190A:1.2.3.4 a1b2:c3d4:e5d6:f7e8:8f9:190a:102:304 +); + +for (my $i=0;$i<@num;$i+=2) { + my $bits = inet_pton(AF_INET6(),$num[$i]); + my $len = length($bits); + print "bad len = $len, exp: 16\nnot " + unless $len == 16; # 16 bytes x 8 bits + &ok; + my $ipv6x = inet_ntop(AF_INET6(),$bits); + print "got: $ipv6x\nexp: $num[$i +1]\nnot " + unless $ipv6x eq $num[$i +1]; + &ok; +} + +## test 32 check bad length ntop +my $try = '1234'; +my $notempty = eval { + inet_ntop(AF_INET6(),$try); +}; +print "failed bad argument length test for inet_ntop\nnot " + unless $@ && $@ =~ /Bad arg/; +&ok; diff --git a/Lite/Util/t/ipv4_inet.t b/Lite/Util/t/ipv4_inet.t new file mode 100644 index 0000000..6c44e68 --- /dev/null +++ b/Lite/Util/t/ipv4_inet.t @@ -0,0 +1,59 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..13\n"; } +END {print "not ok 1\n" unless $loaded;} + +#use diagnostics; +use NetAddr::IP::Util qw( + inet_ntoa + inet_aton +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +## test 2 add stuff to buffer +my @num = # addr +qw( + 0.0.0.0 + 255.255.255.255 + 1.2.3.4 + 10.253.230.9 +); + +foreach (@num) { + my @digs = split(/\./,$_); + my $pkd = pack('C4',@digs); + my $naddr = inet_aton($_); + my $addr = join('.',unpack('C4',$naddr)); + my $num = inet_ntoa($pkd); + + print "bits do not match\nnot " + unless $naddr eq $pkd; + &ok; + + print "inet_aton: $addr, exp: $_\nnot " + unless $addr eq $_; + &ok; + + print "inet_ntoa: $num, exp: $_\nnot " + unless $num eq $_; + &ok; +} diff --git a/Lite/Util/t/ipv6_any2n.t b/Lite/Util/t/ipv6_any2n.t new file mode 100644 index 0000000..3564508 --- /dev/null +++ b/Lite/Util/t/ipv6_any2n.t @@ -0,0 +1,47 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..4\n"; } +END {print "not ok 1\n" unless $loaded;} + +use NetAddr::IP::Util qw( + ipv6_aton + ipv6_n2x + inet_any2n +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +my @num = qw # input expected +( a1b2:c3d4:e5d6:f7e8:08f9:190a:2a1b:3b4c A1B2:C3D4:E5D6:F7E8:8F9:190A:2A1B:3B4C + 1.2.3.4 0:0:0:0:0:0:102:304 + A1B2:C3D4:E5D6:F7E8:08F9:190A:1.2.3.4 A1B2:C3D4:E5D6:F7E8:8F9:190A:102:304 +); + +my $ff = ipv6_aton($num[1]); +for(my $i=0;$i<@num;$i+=2) { + my $num = $num[$i]; + my $bstr = inet_any2n($num); + my $rv = ipv6_n2x($bstr); + my $exp = $num[$i +1]; + print "got: $rv\nexp: $exp\nnot " + unless $rv eq $exp; + &ok; +} diff --git a/Lite/Util/t/ipv6_ntoa.t b/Lite/Util/t/ipv6_ntoa.t new file mode 100644 index 0000000..67cf2b1 --- /dev/null +++ b/Lite/Util/t/ipv6_ntoa.t @@ -0,0 +1,66 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..20\n"; } +END {print "not ok 1\n" unless $loaded;} + +#use diagnostics; +use NetAddr::IP::Util qw( + ipv6_ntoa + inet_pton + AF_INET6 +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +## test 2 - 19 add stuff to buffer +my @num = # in exphex +qw( + :: :: + 43:: 43:: + ::21 ::21 + ::1:2:3:4:5:6:7 0:1:2:3:4:5:6:7 + 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:0 + 1::8 1::8 + FF00::FFFF ff00::ffff + FFFF::FFFF:FFFF ffff::ffff:ffff + A1B2:C3D4:E5D6:F7E8:08F9:190A:1.2.3.4 a1b2:c3d4:e5d6:f7e8:8f9:190a:102:304 +); + +for (my $i=0;$i<@num;$i+=2) { + my $bits = inet_pton(AF_INET6(),$num[$i]); + my $len = length($bits); + print "bad len = $len, exp: 16\nnot " + unless $len == 16; # 16 bytes x 8 bits + &ok; + my $ipv6x = ipv6_ntoa($bits); + print "got: $ipv6x\nexp: $num[$i +1]\nnot " + unless $ipv6x eq $num[$i +1]; + &ok; +} + +## test 32 check bad length ntop +my $try = '1234'; +my $notempty = eval { + ipv6_ntoa($try); +}; +print "failed bad argument length test for ipv6_ntoa\nnot " + unless $@ && $@ =~ /Bad arg/; +&ok; diff --git a/Lite/Util/t/ipv6func.t b/Lite/Util/t/ipv6func.t new file mode 100644 index 0000000..4ef0d9c --- /dev/null +++ b/Lite/Util/t/ipv6func.t @@ -0,0 +1,75 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..27\n"; } +END {print "not ok 1\n" unless $loaded;} + +use NetAddr::IP::Util qw( + ipv6_aton + ipv6_n2x + ipv6_n2d +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +my @num = # in exphex expd +qw( + :: 0:0:0:0:0:0:0:0 0:0:0:0:0:0:0.0.0.0 + 43:: 43:0:0:0:0:0:0:0 43:0:0:0:0:0:0.0.0.0 + ::21 0:0:0:0:0:0:0:21 0:0:0:0:0:0:0.0.0.33 + ::1:2:3:4:5:6:7 0:1:2:3:4:5:6:7 0:1:2:3:4:5:0.6.0.7 + 1:2:3:4:5:6:7:: 1:2:3:4:5:6:7:0 1:2:3:4:5:6:0.7.0.0 + 1::8 1:0:0:0:0:0:0:8 1:0:0:0:0:0:0.0.0.8 + FF00::FFFF FF00:0:0:0:0:0:0:FFFF FF00:0:0:0:0:0:0.0.255.255 + FFFF::FFFF:FFFF FFFF:0:0:0:0:0:FFFF:FFFF FFFF:0:0:0:0:0:255.255.255.255 +); + +for (my $i=0;$i<@num;$i+=3) { + my $bits = ipv6_aton($num[$i]); + my $len = length($bits); + print "bad len = $len, exp: 16\nnot " + unless $len == 16; # 16 bytes x 8 bits + &ok; + my $ipv6x = ipv6_n2x($bits); + print "got: $ipv6x\nexp: $num[$i +1]\nnot " + unless $ipv6x eq $num[$i +1]; + &ok; + my $ipv6d = ipv6_n2d($bits); + print "got: $ipv6d\nexp: $num[$i +2]\nnot " + unless $ipv6d eq $num[$i +2]; + &ok; +} + +## test 26 check bad length n2x +my $try = '1234'; +my $notempty = eval { + ipv6_n2x($try); +}; +print "failed bad argument length test for ipv6_n2x\nnot " + unless $@ && $@ =~ /Bad arg/; +&ok; + +## test 27 check bad length n2d +$notempty = eval { + ipv6_n2d($try); +}; +print "failed bad argument length test for ipv6_n2d\nnot " + unless $@ && $@ =~ /Bad arg/; +&ok; diff --git a/Lite/Util/t/ipv6to4.t b/Lite/Util/t/ipv6to4.t new file mode 100644 index 0000000..9500b07 --- /dev/null +++ b/Lite/Util/t/ipv6to4.t @@ -0,0 +1,55 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..4\n"; } +END {print "not ok 1\n" unless $loaded;} + +use NetAddr::IP::Util qw( + inet_ntoa + inet_any2n + ipv6_n2d + ipv6to4 +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +my $nip = inet_any2n('1.2.3.4'); +my $exp = '0:0:0:0:0:0:1.2.3.4'; + +## test 2 check that we have an ipv6 netaddr +my $ipv6 = ipv6_n2d($nip); +print "got: $ipv6\nexp: $exp\nnot " + unless $ipv6 eq $exp; +&ok; + +## test 3 check conversion back to ipv4 +$exp = '1.2.3.4'; +print "got: $_, exp: $exp\nnot " + unless inet_ntoa(ipv6to4($nip)) eq $exp; +&ok; + +## test 4 check bad length +$nip = pack("H9",0x00,0x01,0x02,0x03,0x04,0x05,0x06,0x07,0x08,0x09); +eval { + ipv6to4($nip); +}; +print "ipv6to4 accepted bad argument length\nnot " + unless $@ && $@ =~ /Bad arg.+ipv6to4/; +&ok; diff --git a/Lite/Util/t/isIPv4.t b/Lite/Util/t/isIPv4.t new file mode 100644 index 0000000..0c74dba --- /dev/null +++ b/Lite/Util/t/isIPv4.t @@ -0,0 +1,186 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..421\n"; } +END {print "not ok 1\n" unless $loaded;} + +use NetAddr::IP::Util qw( + ipv6_aton + ipv6_n2x + isIPv4 + isNewIPv4 + isAnyIPv4 +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +my @num = qw # input +( + :: + 8000:: + 4000:: + 2000:: + 1000:: + 800:: + 400:: + 200:: + 100:: + 80:: + 40:: + 20:: + 10:: + 1:: + 0:8000:: + 0:4000:: + 0:2000:: + 0:1000:: + 0:800:: + 0:400:: + 0:200:: + 0:100:: + 0:80:: + 0:40:: + 0:20:: + 0:10:: + 0:1:: + 0:0:8000:: + 0:0:4000:: + 0:0:2000:: + 0:0:1000:: + 0:0:800:: + 0:0:400:: + 0:0:200:: + 0:0:100:: + 0:0:80:: + 0:0:40:: + 0:0:20:: + 0:0:10:: + 0:0:1:: + 0:0:0:8000:: + 0:0:0:4000:: + 0:0:0:2000:: + 0:0:0:1000:: + 0:0:0:800:: + 0:0:0:400:: + 0:0:0:200:: + 0:0:0:100:: + 0:0:0:80:: + 0:0:0:40:: + 0:0:0:20:: + 0:0:0:10:: + 0:0:0:1:: + 0:0:0:0:8000:: + 0:0:0:0:4000:: + 0:0:0:0:2000:: + 0:0:0:0:1000:: + 0:0:0:0:800:: + 0:0:0:0:400:: + 0:0:0:0:200:: + 0:0:0:0:100:: + 0:0:0:0:80:: + 0:0:0:0:40:: + 0:0:0:0:20:: + 0:0:0:0:10:: + 0:0:0:0:1:: + 0:0:0:0:0:8000:: + 0:0:0:0:0:4000:: + 0:0:0:0:0:2000:: + 0:0:0:0:0:1000:: + 0:0:0:0:0:800:: + 0:0:0:0:0:400:: + 0:0:0:0:0:200:: + 0:0:0:0:0:100:: + 0:0:0:0:0:80:: + 0:0:0:0:0:40:: + 0:0:0:0:0:20:: + 0:0:0:0:0:10:: + 0:0:0:0:0:1:: + ::8000:0 + ::4000:0 + ::2000:0 + ::1000:0 + ::800:0 + ::400:0 + ::200:0 + ::100:0 + ::80:0 + ::40:0 + ::20:0 + ::10:0 + ::1:0 + ::8000 + ::4000 + ::2000 + ::1000 + ::800 + ::400 + ::200 + ::100 + ::80 + ::40 + ::20 + ::10 + ::1 +); + +# check isIPv4 + +foreach (@num) { + my $bstr = ipv6_aton($_); + my $rv = isIPv4($bstr); + my $exp = ($_ =~ /\d::$/) ? 0:1; + print "got: $rv, exp: $exp for ", ipv6_n2x($bstr), "\nnot " + unless $rv eq $exp; + &ok; +} + +# check isAnyIPv4 +foreach (@num) { + my $bstr = ipv6_aton($_); + my $rv = isAnyIPv4($bstr); + my $exp = ($_ =~ /\d::$/) ? 0:1; + print "got: $rv, exp: $exp for ", ipv6_n2x($bstr), "\nnot " + unless $rv eq $exp; + &ok; +} + +my $compat = ipv6_aton('::FFFF:0:0'); + +# check isAnyIPv4 with compatible high bits +foreach (@num) { + my $bstr = ipv6_aton($_); + $bstr ^= $compat; + my $rv = isAnyIPv4($bstr); + my $exp = ($_ =~ /\d::$/) ? 0:1; + print "got: $rv, exp: $exp for ", ipv6_n2x($bstr), "\nnot " + unless $rv eq $exp; + &ok; +} + +# check isNewIPv4 with compatible high bits +foreach (@num) { + my $bstr = ipv6_aton($_); + $bstr ^= $compat; + my $rv = isNewIPv4($bstr); + my $exp = ($_ =~ /\d::$/) ? 0:1; + print "got: $rv, exp: $exp for ", ipv6_n2x($bstr), "\nnot " + unless $rv eq $exp; + &ok; +} diff --git a/Lite/Util/t/leftshift.t b/Lite/Util/t/leftshift.t new file mode 100644 index 0000000..abe622c --- /dev/null +++ b/Lite/Util/t/leftshift.t @@ -0,0 +1,58 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..9\n"; } +END {print "not ok 1\n" unless $loaded;} + +use NetAddr::IP::Util qw( + ipv6_aton + ipv6_n2x + shiftleft +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +my @num = # input shift expected +qw( + 1::1 none 1:0:0:0:0:0:0:1 + 1::1 0 1:0:0:0:0:0:0:1 + 1::1 1 2:0:0:0:0:0:0:2 + 1::1 2 4:0:0:0:0:0:0:4 + 1::1 3 8:0:0:0:0:0:0:8 + 1::1 15 8000:0:0:0:0:0:0:8000 + 1::1 16 0:0:0:0:0:0:1:0 + 1::1 128 0:0:0:0:0:0:0:0 +); + +for (my $i=0;$i < @num;$i+=3) { + my $bstr = ipv6_aton($num[$i]); + my $rv; + if ($num[$i +1] =~ /\D/) { + $rv = shiftleft($bstr); + } + else { + $rv = shiftleft($bstr,$num[$i +1]); + } + my $exp = $num[$i+2]; + my $got = ipv6_n2x($rv); + print "got: $got, exp: $exp\nnot " + unless $got eq $exp; + &ok; +} diff --git a/Lite/Util/t/mode.t b/Lite/Util/t/mode.t new file mode 100644 index 0000000..66d3136 --- /dev/null +++ b/Lite/Util/t/mode.t @@ -0,0 +1,26 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..2\n"; } +END {print "not ok 1\n" unless $loaded;} + +use NetAddr::IP::Util qw( + mode +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +my $mode = mode(); +my $txt = "\tmode $mode"; +print STDERR $txt,"\n"; +print "ok 2\n"; diff --git a/Lite/Util/t/naip_gethostbyname.t b/Lite/Util/t/naip_gethostbyname.t new file mode 100644 index 0000000..6da9b18 --- /dev/null +++ b/Lite/Util/t/naip_gethostbyname.t @@ -0,0 +1,59 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..3\n"; } +END {print "not ok 1\n" unless $loaded;} + +#use diagnostics; +use NetAddr::IP::Util qw( + naip_gethostbyname + havegethostbyname2 + ipv6_n2x + inet_aton +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +my $exp = '0:0:0:0:0:FFFF:7F00:1'; +my $host = '127.1'; +my $got = ipv6_n2x( scalar naip_gethostbyname($host)); +print "got: $got\nexp: $exp\nnot " + unless $got eq $exp; +&ok; + +$exp = '0:0:0:0:0:0:0:1'; +$host = $exp; + +if (havegethostbyname2()) { + $got = ipv6_n2x(scalar naip_gethostbyname($host)); + print "got: $got\nexp: $exp\nnot " + unless $got eq $exp; +} else { +print STDERR "\n\tgethostbyname2 missing from Socket6\n" + if eval{ require Socket6 }; + $got = scalar naip_gethostbyname($host); + if ($got) { + $got = eval{ inet_ntoa($got) } || + eval{ ipv6_n2x($got) }; + } + print "unexpected return value got: $got\nnot " + if $got; +} +&ok; diff --git a/Lite/Util/t/no6_naip_gethostbyname.t b/Lite/Util/t/no6_naip_gethostbyname.t new file mode 100644 index 0000000..1f02421 --- /dev/null +++ b/Lite/Util/t/no6_naip_gethostbyname.t @@ -0,0 +1,58 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..3\n"; } +END {print "not ok 1\n" unless $loaded;} + +#use diagnostics; +use NetAddr::IP::Util qw( + :noSock6 + naip_gethostbyname + havegethostbyname2 + ipv6_n2x + inet_aton +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +my $exp = '0:0:0:0:0:FFFF:7F00:1'; +my $host = '127.1'; +my $got = ipv6_n2x( scalar naip_gethostbyname($host)); +print "got: $got\nexp: $exp\nnot " + unless $got eq $exp; +&ok; + +$exp = '0:0:0:0:0:0:0:1'; +$host = $exp; + +if (havegethostbyname2()) { + $got = ipv6_n2x(scalar naip_gethostbyname($host)); + print "got: $got\nexp: $exp\nnot " + unless $got eq $exp; +} else { + $got = scalar naip_gethostbyname($host); + if ($got) { + $got = eval{ inet_ntoa($got) } || + eval{ ipv6_n2x($got) }; + } + print "unexpected return value got: $got\nnot " + if $got; +} +&ok; diff --git a/Lite/Util/t/notcontiguous.t b/Lite/Util/t/notcontiguous.t new file mode 100644 index 0000000..0724d85 --- /dev/null +++ b/Lite/Util/t/notcontiguous.t @@ -0,0 +1,72 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..49\n"; } +END {print "not ok 1\n" unless $loaded;} + +use NetAddr::IP::Util qw( + inet_any2n + notcontiguous +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +my @num = # input expected spur +qw( + FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF 128 0 + FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFE 127 0 + FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFC 126 0 + FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFF8 125 0 + FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFF0 124 0 + FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFE0 123 0 + FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFC0 122 0 + FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FF80 121 0 + FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FF00 120 0 + FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:0 112 0 + FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFF0:0 108 0 + FFeF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF 128 1 + FFFF:FFeF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFE 127 1 + FFFF:FFFF:FeFF:FFFF:FFFF:FFFF:FFFF:FFFC 126 1 + FFFF:FFFF:FFFF:eFFF:FFFF:FFFF:FFFF:FFF8 125 1 + FFFF:FFFF:FFFF:FFFF:FFFe:FFFF:FFFF:FFF0 124 1 + FFFF:FFFF:FFF:FFFF:FFFF:FFFF:FFFF:FFE0 123 1 + FFFF:FFFF:FFFF:FFFF:FFFF:FFeF:FFFF:FFC0 122 1 + FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FeFF:FF80 121 1 + FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:eF00 120 1 + eFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:0 112 1 + FFFF:FeFF:FFFF:FFFF:FFFF:FFFF:FFF0:0 108 1 + F000:: 4 0 + A000:: 3 1 +); + +for (my $i=0;$i < @num;$i+=3) { + my $bstr = inet_any2n($num[$i]); + my $rv; + my $xcidr = $num[$i+1]; + my $xspur = $num[$i+2]; + my($spur,$cidr) = notcontiguous($bstr); + print "cidr: $cidr, exp: $xcidr\nnot " + unless $cidr == $xcidr; + &ok; + $spur = 1 if $spur; + print "spur: $spur, exp: $xspur\nnot " + unless $spur == $xspur; + &ok; +} diff --git a/Lite/Util/t/packzeros.t b/Lite/Util/t/packzeros.t new file mode 100644 index 0000000..6c89542 --- /dev/null +++ b/Lite/Util/t/packzeros.t @@ -0,0 +1,53 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..13\n"; } +END {print "not ok 1\n" unless $loaded;} + +use NetAddr::IP::Util qw( + + packzeros +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +my @addr = qw # input expected +( D0:00:0000:0000:000:b00:0000:000 d0::b00:0:0 + 0d0:00:0000:0000:000:0B00:: d0::b00:0:0 + ::c3D4:e5d6:0:0:0:0 0:0:c3d4:e5d6:: + 0:0000:c3D4:e5d6:0:0:0:0 0:0:c3d4:e5d6:: + 0:0:0:0:0:0:0:0 :: + 0:0:: :: + ::0:000:0 :: + 0:0::1.2.3.4 ::1.2.3.4 + ::1.2.3.4 ::1.2.3.4 + ::01b2:C3d4:0:0:0:1.2.3.4 0:1b2:c3d4::1.2.3.4 + 0:0:0:0:a1b2:c3D4:: ::a1b2:c3d4:0:0 + 12:0:0:0:34:0:00:000 12::34:0:0:0 +); + +for(my $i=0;$i<@addr;$i+=2) { + my $addr = $addr[$i]; + my $rv = packzeros($addr); + my $exp = lc $addr[$i +1]; + print "got: $rv\nexp: $exp\nnot " + unless $rv eq $exp; + &ok; +} diff --git a/Lite/Util/t/simple_pack.t b/Lite/Util/t/simple_pack.t new file mode 100644 index 0000000..901521c --- /dev/null +++ b/Lite/Util/t/simple_pack.t @@ -0,0 +1,51 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..9\n"; } +END {print "not ok 1\n" unless $loaded;} + +use NetAddr::IP::Util qw( + simple_pack +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +my @num2 = qw( + 0 + 2147483648 + 140737488355328 + 9223372036854775808 + 604462909807314587353088 + 39614081257132168796771975168 + 2596148429267413814265248164610048 + 170141183460469231731687303715884105728 +); + +## tests 2 - 9 check pack correct + +for (my $i=0;$i<@num2;$i++) { + my $len = length($num2[$i]); + my $pkd = simple_pack($num2[$i]); + my $rv = unpack("H40",$pkd); + $rv =~ s/^0+(\d)/$1/g; + print "got: $rv\nexp: $num2[$i]\nnot " + unless $rv eq $num2[$i]; + &ok; +} diff --git a/Lite/Util/t/sub128.t b/Lite/Util/t/sub128.t new file mode 100644 index 0000000..7ed31a3 --- /dev/null +++ b/Lite/Util/t/sub128.t @@ -0,0 +1,68 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..34\n"; } +END {print "not ok 1\n" unless $loaded;} + +use NetAddr::IP::Util qw( + sub128 + ipv6_aton + ipv6_n2x +); + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} +my @num = # number minus carry (not borrow) exp +qw( + ::f712:fff:fffe ::f712:fff:fffc 1 0:0:0:0:0:0:0:2 + ::712:fff:fffe ::712:fff:fffc 1 0:0:0:0:0:0:0:2 + ::712:ffff:fffe ::712:ffff:fffc 1 0:0:0:0:0:0:0:2 + ::f712:ffff:fffa ::f712:ffff:fffc 0 FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFE + ::f712:fff:fffa ::f712:fff:fffc 0 FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFE + ::712:fff:fffa ::712:fff:fffc 0 FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFE + ::712:ffff:fffa ::712:ffff:fffc 0 FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFE + ::2 ::1 1 0:0:0:0:0:0:0:1 + ::f712:ffff:fffe ::f712:ffff:fffc 1 0:0:0:0:0:0:0:2 + ::1 ::3 0 FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFE + ::1234 ::1234 1 0:0:0:0:0:0:0:0 +); +## test 2 check comp of zero + +for (my $i=0; $i<@num; $i+=4) { + my $num = ipv6_aton($num[$i]); + my $minus = ipv6_aton($num[$i +1]); + my $rv = sub128($num,$minus); + print "got: $rv, exp: $num[$i +2]\nnot " + unless $rv == $num[$i +2]; + &ok; +} + +for (my $i=0; $i<@num; $i+=4) { + my $num = ipv6_aton($num[$i]); + my $minus = ipv6_aton($num[$i +1]); + my($rv,$dif) = sub128($num,$minus); + print "got: $rv, exp: $num[$i +2]\nnot " + unless $rv == $num[$i +2]; + &ok; + $dif = ipv6_n2x($dif); + print "got: $dif\nexp: $num[$i +3]\nnot " + unless $dif eq $num[$i +3]; + &ok; +} + diff --git a/Lite/Util/tlib/NetAddr/IP/Util_IS.pm b/Lite/Util/tlib/NetAddr/IP/Util_IS.pm new file mode 100644 index 0000000..5d58917 --- /dev/null +++ b/Lite/Util/tlib/NetAddr/IP/Util_IS.pm @@ -0,0 +1,51 @@ +#!/usr/bin/perl +# +# DO NOT ALTER THIS FILE +# IT IS WRITTEN BY Makefile.PL +# EDIT THAT INSTEAD +# +package NetAddr::IP::Util_IS; +use vars qw($VERSION); +$VERSION = 1.00; + + +sub pure { + return 1; +} +sub not_pure { + return 0; +} +1; +__END__ + +=head1 NAME + +NetAddr::IP::Util_IS - Tell about Pure Perl + +=head1 SYNOPSIS + + use NetAddr::IP::Util_IS; + + $rv = NetAddr::IP::Util_IS->pure; + $rv = NetAddr::IP::Util_IS->not_pure; + +=head1 DESCRIPTION + +Util_IS indicates whether or not B was compiled in Pure +Perl mode. + +=over 4 + +=item * $rv = NetAddr::IP::Util_IS->pure; + +Returns true if PurePerl mode, else false. + +=item * $rv = NetAddr::IP::Util_IS->not_pure; + +Returns true if NOT PurePerl mode, else false + +=back + +=cut + +1; diff --git a/Lite/Util/typemap b/Lite/Util/typemap new file mode 100644 index 0000000..b85166a --- /dev/null +++ b/Lite/Util/typemap @@ -0,0 +1,28 @@ +# +# Map C types to Perl types +# + +struct in_addr * T_PTROBJ + +# +# Input conversions +# + +INPUT + +T_PTROBJ + if (sv_derived_from($arg, \"${ntype}\")) { + IV tmp = SvIV((SV*)SvRV($arg)); + $var = ($type) tmp; + } + else + croak(\"$var is not of type ${ntype}\") + +# +# Output conversions +# + +OUTPUT + +T_PTROBJ + sv_setref_pv($arg, \"${ntype}\", (void*)$var); diff --git a/Lite/bug2742981 b/Lite/bug2742981 new file mode 100755 index 0000000..fa420b8 --- /dev/null +++ b/Lite/bug2742981 @@ -0,0 +1,96 @@ +#!/usr/bin/perl +use Math::BigInt; +use NetAddr::IP::Util qw( + bcd2bin + ipv6_n2x +); + +my $data = q| + got: '340282366920938963520000944000010176000' +# expected: '340282366920938463463374607431768211455' + +# Failed test 'cafe:cafe::/64 Scalar numeric ok' +# at t/v6-numeric.t line 57. +# got: '269827015721314205120005577600083392000' +# expected: '269827015721314068804783158349174669312' + +# Failed test 'cafe:cafe::/64 Array numeric ok for network' +# at t/v6-numeric.t line 58. +# got: '269827015721314205120005577600083392000' +# expected: '269827015721314068804783158349174669312' + +# Failed test 'cafe:cafe::/64 Array numeric ok for mask' +# at t/v6-numeric.t line 59. +# got: '340282366920938963520000944000010176000' +# expected: '340282366920938463444927863358058659840' + +# Failed test 'cafe:cafe::1/64 Scalar numeric ok' +# at t/v6-numeric.t line 57. +# got: '269827015721314205120005577600083392000' +# expected: '269827015721314068804783158349174669313' + +# Failed test 'cafe:cafe::1/64 Array numeric ok for network' +# at t/v6-numeric.t line 58. +# got: '269827015721314205120005577600083392000' +# expected: '269827015721314068804783158349174669313' + +# Failed test 'cafe:cafe::1/64 Array numeric ok for mask' +# at t/v6-numeric.t line 59. +# got: '340282366920938963520000944000010176000' +# expected: '340282366920938463444927863358058659840' + +# Failed test 'dead:beef::/100 Scalar numeric ok' +# at t/v6-numeric.t line 57. +# got: '295990755014136299520006003200014752000' +# expected: '295990755014133383690938178081940045824' + +# Failed test 'dead:beef::/100 Array numeric ok for network' +# at t/v6-numeric.t line 58. +# got: '295990755014136299520006003200014752000' +# expected: '295990755014133383690938178081940045824' + +# Failed test 'dead:beef::/100 Array numeric ok for mask' +# at t/v6-numeric.t line 59. +# got: '340282366920938963520000944000010176000' +# expected: '340282366920938463463374607431499776000' + +# Failed test 'dead:beef::1/100 Scalar numeric ok' +# at t/v6-numeric.t line 57. +# got: '295990755014136299520006003200014752000' +# expected: '295990755014133383690938178081940045825' + +# Failed test 'dead:beef::1/100 Array numeric ok for network' +# at t/v6-numeric.t line 58. +# got: '295990755014136299520006003200014752000' +# expected: '295990755014133383690938178081940045825' + +# Failed test 'dead:beef::1/100 Array numeric ok for mask' +# at t/v6-numeric.t line 59. +# got: '340282366920938963520000944000010176000' +# expected: '340282366920938463463374607431499776000' +|; + +my @trial = split("\n",$data); +my @data; +foreach(@trial) { + if ($_ =~ /(?:got|expected)\:\s+\'(\d+)/) { + push @data,$1; + } +} + +#for(my $i=0;$i <= $#data;$i +=2) { +# print $data[$i]," -\n"; +# print $data[$i +1]," =\n"; +# my $x = Math::BigInt->new($data[$i]); +# my $y = Math::BigInt->new($data[$i +1]); +# $x->bsub($y); +# print $x,"\n\n"; +#} + +for(my $i=0;$i <= $#data;$i +=2) { + my $x = ipv6_n2x(bcd2bin($data[$i])); + print $data[$i],"\t=> $x\n"; + my $y = ipv6_n2x(bcd2bin($data[$i +1])); + print $data[$i +1],"\t=> $y\n"; +} + diff --git a/Lite/t/addr.t b/Lite/t/addr.t new file mode 100644 index 0000000..2daeb95 --- /dev/null +++ b/Lite/t/addr.t @@ -0,0 +1,36 @@ + +#use diagnostics; +use NetAddr::IP::Lite; + +$| = 1; + +print "1..3\n"; + +my $test = 1; +sub ok() { + print 'ok ',$test++,"\n"; +} + +my $loip = new NetAddr::IP::Lite('::1.2.3.4/120'); # same as 1.2.3.4/24 +my $hiip = new NetAddr::IP::Lite('FF00::1:4/120'); + +## test '""' just for the heck of it +my $exp = 'FF00:0:0:0:0:0:1:4/120'; +my $txt = sprintf("%s",$hiip); +print 'got: ',$txt," exp: $exp\nnot " + unless $txt eq $exp; +&ok; + +## test addr lo +$exp = '0:0:0:0:0:0:102:304'; +my $addr = $loip->addr; +print "got: $addr, exp: $exp\nnot " + unless $addr eq $exp && ! ref $addr; +&ok; + +## test addr hi +$exp = 'FF00:0:0:0:0:0:1:4'; +$addr = $hiip->addr; +print "got: $addr, exp: $exp\nnot " + unless $addr eq $exp && ! ref $addr; +&ok; diff --git a/Lite/t/aton.t b/Lite/t/aton.t new file mode 100644 index 0000000..4be40f1 --- /dev/null +++ b/Lite/t/aton.t @@ -0,0 +1,33 @@ + +#use diagnostics; +use NetAddr::IP::Util qw( + inet_n2dx +); +use NetAddr::IP::Lite; + +$| = 1; + +print "1..2\n"; + +my $test = 1; +sub ok() { + print 'ok ',$test++,"\n"; +} + +my $loip = new NetAddr::IP::Lite('::1.2.3.4/120'); # same as 1.2.3.4/24 +my $hiip = new NetAddr::IP::Lite('FF00::4/120'); + +## test aton + +my $exp = 'FF00:0:0:0:0:0:0:4'; +my $txt = inet_n2dx($hiip->aton); +print "got: $txt, exp: $exp\nnot " + unless $txt eq $exp; +&ok; + +$exp = '1.2.3.4'; +$txt = inet_n2dx($loip->aton); +print "got: $txt, exp: $exp\nnot " + unless $txt eq $exp; +&ok; + diff --git a/Lite/t/bigint.t b/Lite/t/bigint.t new file mode 100644 index 0000000..b854558 --- /dev/null +++ b/Lite/t/bigint.t @@ -0,0 +1,170 @@ + +use strict; +#use diagnostics; +use Test::More; + +use NetAddr::IP::Lite; +use NetAddr::IP::Util qw( + bcd2bin + bin2bcd + addconst + shiftleft +); + +use Data::Dumper; + +sub badd { # function to add a small int to bignum string + my($n,$i) = @_; + my $v = bcd2bin($n); + (undef,$v) = addconst($v,$i); + bin2bcd($v); +} + +sub xpo2 { # function to do a n^2 multiplication + my($n,$x) = @_; + my $v = bcd2bin($n); + my $c = 0; + while ($x >>= 1) {$c++} + $v = shiftleft($v,$c); + bin2bcd($v); +} + +my $no_mbi_emu = 1; # set this to "1" for normal, "0" for development + +unless (eval{ $no_mbi_emu && require Math::BigInt }) { + if ($no_mbi_emu) { + print "1..1\nok 1 # skipped all, Math::BigInt not found\n"; + exit; + } + + &NetAddr::IP::Lite::_force_bi_emu; + + package Math::BigInt; + my $badd = \&main::badd; + require overload; + import overload + '""' => sub { + ${$_[0]} =~ /(\d+)/; + return $1; + }, + '+' => sub { + ${$_[0]} =~ /(\d+)/; + $b = '+'. main::badd($1,$_[1]); + bless \$b; + }; + *new = \&NetAddr::IP::Lite::_bi_fake; +} + +my @exp = (qw( + 255.255.255.253/32 4294967293 4294967295 + 255.255.255.254/32 4294967294 4294967295 + 255.255.255.255/32 4294967295 4294967295 + 0:0:0:0:0:1:0:0/128 4294967296 4294967295 + 0:0:0:0:0:1:0:1/128 4294967297 4294967295 + 0:0:0:0:0:1:0:2/128 4294967298 4294967295 + FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFD/128 340282366920938463463374607431768211453 340282366920938463463374607431768211455 + FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFE/128 340282366920938463463374607431768211454 340282366920938463463374607431768211455 + FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF/128 340282366920938463463374607431768211455 340282366920938463463374607431768211455 + 0.0.0.0/32 0 4294967295 + 0.0.0.1/32 1 4294967295 + 0.0.0.2/32 2 4294967295 + 123.45.67.89/32 2066563929 4294967295 + 123.45.67.89/28 2066563929 4294967280 + 123.45.67.89/24 2066563929 4294967040 + 123.45.67.89/20 2066563929 4294963200 + 123.45.67.89/16 2066563929 4294901760 + 123.45.67.89/12 2066563929 4293918720 + 123.45.67.89/8 2066563929 4278190080 + 123.45.67.89/4 2066563929 4026531840 + 123.45.67.89/0 2066563929 0 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/128 170145699920964442595609400891477785294 340282366920938463463374607431768211455 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/124 170145699920964442595609400891477785294 340282366920938463463374607431768211440 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/120 170145699920964442595609400891477785294 340282366920938463463374607431768211200 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/116 170145699920964442595609400891477785294 340282366920938463463374607431768207360 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/112 170145699920964442595609400891477785294 340282366920938463463374607431768145920 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/108 170145699920964442595609400891477785294 340282366920938463463374607431767162880 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/104 170145699920964442595609400891477785294 340282366920938463463374607431751434240 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/100 170145699920964442595609400891477785294 340282366920938463463374607431499776000 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/96 170145699920964442595609400891477785294 340282366920938463463374607427473244160 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/92 170145699920964442595609400891477785294 340282366920938463463374607363048734720 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/88 170145699920964442595609400891477785294 340282366920938463463374606332256583680 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/84 170145699920964442595609400891477785294 340282366920938463463374589839582167040 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/80 170145699920964442595609400891477785294 340282366920938463463374325956791500800 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/76 170145699920964442595609400891477785294 340282366920938463463370103832140840960 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/72 170145699920964442595609400891477785294 340282366920938463463302549837730283520 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/68 170145699920964442595609400891477785294 340282366920938463462221685927161364480 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/64 170145699920964442595609400891477785294 340282366920938463444927863358058659840 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/60 170145699920964442595609400891477785294 340282366920938463168226702252415385600 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/56 170145699920964442595609400891477785294 340282366920938458741008124562122997760 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/52 170145699920964442595609400891477785294 340282366920938387905510881517444792320 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/48 170145699920964442595609400891477785294 340282366920937254537554992802593505280 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/44 170145699920964442595609400891477785294 340282366920919120650260773364972912640 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/40 170145699920964442595609400891477785294 340282366920628978453553262363043430400 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/36 170145699920964442595609400891477785294 340282366915986703306233086332171714560 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/32 170145699920964442595609400891477785294 340282366841710300949110269838224261120 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/28 170145699920964442595609400891477785294 340282365653287863235145205935065006080 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/24 170145699920964442595609400891477785294 340282346638528859811704183484516925440 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/20 170145699920964442595609400891477785294 340282042402384805036647824275747635200 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/16 170145699920964442595609400891477785294 340277174624079928635746076935438991360 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/12 170145699920964442595609400891477785294 340199290171201906221318119490500689920 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/8 170145699920964442595609400891477785294 338953138925153547590470800371487866880 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/4 170145699920964442595609400891477785294 319014718988379809496913694467282698240 + 8000:DEAD:BEEF:4:CAFE:BAD:2:FACE/0 170145699920964442595609400891477785294 0 +)); + +my $ptr = 0; +my $max = @exp -11; +plan tests => $max || 1; + +sub run { + foreach(1..5) { + my $ip = new NetAddr::IP::Lite($exp[$ptr]); + my $mbi = $ip->bigint(); + $mbi = $mbi + 1; +#print $ip,"\n"; +#print Dumper $mbi; +#print $exp[$ptr+1],"\n"; + like($mbi, qr/(?:0|$exp[$ptr+4])/); + $ip = new NetAddr::IP::Lite($mbi); + is($ip, $exp[$ptr+3]); + pass(); # ignore mask for these tests + $ptr += 3; + } +} + +run(); +$ptr += 3; +run(); + +$ptr += 3; + +sub mrun { + my $n = shift; + foreach(1..$n) { + my $ip = new NetAddr::IP::Lite($exp[$ptr]); + my ($mbia,$mbim) = $ip->bigint(); + my($ary,$msk,$eip) = @exp[$ptr+1,$ptr+2,$ptr+3]; + $ptr += 3; +#print $msk,"\n"; +#print Dumper $mbia; +#print Dumper $mbim; + like($mbia, qr/$ary/); + like($mbim, qr/$msk/); + my $len = $ip->masklen(); + last unless $len; + last if $ptr > $max + 200; # loop stop, just in case +#print Dumper $mbim; + $mbim = new Math::BigInt($exp[$ptr+2]); +#print Dumper $mbim; +#print Dumper $mbia; + $ip = new NetAddr::IP::Lite($mbia,$mbim); + is($ip, $eip); +#print '|',$ip,"|\n"; + } +} + +mrun(9); + +$ptr += 3; + +mrun(32); diff --git a/Lite/t/bignums.t b/Lite/t/bignums.t new file mode 100644 index 0000000..186c872 --- /dev/null +++ b/Lite/t/bignums.t @@ -0,0 +1,130 @@ + +use strict; +use Test::More; + +use NetAddr::IP::Lite; +#use NetAddr::IP::Util qw( +# bcd2bin +# ipv6_n2x +# bin2bcd +#); +#use Data::Dumper; + +my @num = qw( + 2001:468:D01:3C:0:0:80DF:3C1B/128 42540577535367674011024906890208295963 + 73.150.6.197/32 1234568901 + 128.0.0.0/32 2147483648 + 0:0:0:0:0:1:0:0/128 4294967296 + 0:0:0:0:0:2:0:0/128 8589934592 + 0:0:0:0:0:2:540B:E400/128 10000000000 + 0:0:0:0:0:4:0:0/128 17179869184 + 0:0:0:0:0:8:0:0/128 34359738368 + 0:0:0:0:0:10:0:0/128 68719476736 + 0:0:0:0:0:20:0:0/128 137438953472 + 0:0:0:0:0:40:0:0/128 274877906944 + 0:0:0:0:0:80:0:0/128 549755813888 + 0:0:0:0:0:100:0:0/128 1099511627776 + 0:0:0:0:0:200:0:0/128 2199023255552 + 0:0:0:0:0:400:0:0/128 4398046511104 + 0:0:0:0:0:800:0:0/128 8796093022208 + 0:0:0:0:0:1000:0:0/128 17592186044416 + 0:0:0:0:0:2000:0:0/128 35184372088832 + 0:0:0:0:0:4000:0:0/128 70368744177664 + 0:0:0:0:0:8000:0:0/128 140737488355328 + 0:0:0:0:8000:0:0:0/128 9223372036854775808 + 0:0:0:8000:0:0:0:0/128 604462909807314587353088 + 0:0:8000:0:0:0:0:0/128 39614081257132168796771975168 + 0:8000:0:0:0:0:0:0/128 2596148429267413814265248164610048 + 8000:0:0:0:0:0:0:0/128 170141183460469231731687303715884105728 + 255.255.255.255/32 4294967295 + 1.2.3.4/32 16909060 + 10.253.230.9/32 184411657 +); + +plan tests => scalar @num; + +#diag ("\ntesting SCALARS\n\n"); + +for(my $i = 0;$i <= $#num;$i += 2) { + my $n = $num[$i +1]; + my $ip = new NetAddr::IP::Lite($n); + ok($ip eq $num[$i],"$n\t=> got: $ip\texp: ". $num[$i]); +} + +#diag ("\ntesting Math::BigInt's\n\n"); + +for(my $i = 0;$i <= $#num;$i += 2) { + my $n = new Math::BigInt($num[$i +1]); + my $ip = new NetAddr::IP::Lite($num[$i +1]); + ok($ip eq $num[$i],"$n\t=> got: $ip\texp: ". $num[$i]); +} + + + + +# simulate the use of Math::BigInt + +package Math::BigInt; +use strict; + +use overload +'""' => sub { $_[0]->_str(); }; + +sub BASE_LEN () { 7 }; + +sub _str { # adapted from Math::BigInt::Calc::_str + # (ref to BINT) return num_str + # Convert number from internal base 100000 format to string format. + # internal format is always normalized (no leading zeros, "-0" => "+0") + my $ar = $_[0]->{value}; + + my $l = scalar @$ar; # number of parts + my $ret = ""; + # handle first one different to strip leading zeros from it (there are no + # leading zero parts in internal representation) + $l --; $ret .= int($ar->[$l]); $l--; + # Interestingly, the pre-padd method uses more time + # the old grep variant takes longer (14 vs. 10 sec) + my $z = '0' x (BASE_LEN -1); + while ($l >= 0) + { + $ret .= substr($z.$ar->[$l],- BASE_LEN); # fastest way I could think of + $l--; + } + $ret; +} + +sub new { # adapted from Math::BigInt::new + my ($class,$wanted) = @_; + my $self = bless {}, $class; + + die "oops, not a good Math::BigInt number" + unless ((!ref $wanted) && ($wanted =~ /^([+-]?)[1-9][0-9]*\z/)); + $self->{sign} = $1 || '+'; + + if ($wanted =~ /^[+-]/) { +# remove sign without touching wanted to make it work with constants + my $t = $wanted; $t =~ s/^[+-]//; + $self->{value} = _new($t); + } + else { + $self->{value} = _new($wanted); + } + return $self; +} + +sub _new { # adapted from Math::BigInt::Calc::_new + my $wanted = $_[0]; + # (ref to string) return ref to num_array + # Convert a number from string format (without sign) to internal base + # 1ex format. Assumes normalized value as input. + my $il = length($wanted)-1; + + # < BASE_LEN due len-1 above + return [ int($wanted) ] if $il < BASE_LEN; # shortcut for short numbers + + my $base_len = BASE_LEN; + # this leaves '00000' instead of int 0 and will be corrected after any op + [ reverse(unpack("a" . ($il % BASE_LEN +1) + . ("a$base_len" x ($il / BASE_LEN)), $wanted)) ]; +} diff --git a/Lite/t/bin_ips.t b/Lite/t/bin_ips.t new file mode 100644 index 0000000..884b2d4 --- /dev/null +++ b/Lite/t/bin_ips.t @@ -0,0 +1,102 @@ + +#use diagnostics; +use NetAddr::IP::Lite; + +$| = 1; + +sub ok() { + print 'ok ',$test++,"\n"; +} + +print "1..10\n"; + +$test = 1; + +############## test new6 + +my $exp = '0:0:0:0:0:0:0:3039/1'; + +my $ip = NetAddr::IP::Lite->new6(12345,1); +my $got = $ip->cidr(); +print "got: $got\nexp: $exp\nnot " + unless $got eq $exp; +&ok; + +$ip = NetAddr::IP::Lite->new6('12345',1); +$got = $ip->cidr(); +print "got: $got\nexp: $exp\nnot " + unless $got eq $exp; +&ok; + +$ip = NetAddr::IP::Lite->new6('12345/1'); +$got = $ip->cidr(); +print "got: $got\nexp: $exp\nnot " + unless $got eq $exp; +&ok; + + +# 2^127 170141183460469231731687303715884105728 + +$exp = '8000:0:0:0:0:0:0:0/1'; + +$ip = NetAddr::IP::Lite->new6('170141183460469231731687303715884105728/1'); +$got = $ip->cidr(); +print "got: $got\nexp: $exp\nnot " + unless $got eq $exp; +&ok; + +# 2^128 340282366920938463463374607431768211456 +# minus one + +$exp = 'FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF/1'; + +$ip = NetAddr::IP::Lite->new6('340282366920938463463374607431768211455/1'); +$got = $ip->cidr(); +print "got: $got\nexp: $exp\nnot " + unless $got eq $exp; +&ok; + +############# test new + +$exp = '0.0.48.57/1'; + +$ip = NetAddr::IP::Lite->new(12345,1); +$got = $ip->cidr(); +print "got: $got\nexp: $exp\nnot " + unless $got eq $exp; +&ok; + +$ip = NetAddr::IP::Lite->new('12345',1); +$got = $ip->cidr(); +print "got: $got\nexp: $exp\nnot " + unless $got eq $exp; +&ok; + +$ip = NetAddr::IP::Lite->new('12345/1'); +$got = $ip->cidr(); +print "got: $got\nexp: $exp\nnot " + unless $got eq $exp; +&ok; + + +# 2^127 170141183460469231731687303715884105728 + +$exp = '8000:0:0:0:0:0:0:0/1'; + +$ip = NetAddr::IP::Lite->new('170141183460469231731687303715884105728/1'); +$got = $ip->cidr(); +print "got: $got\nexp: $exp\nnot " + unless $got eq $exp; +&ok; + +# 2^128 340282366920938463463374607431768211456 +# minus one + +$exp = 'FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF/1'; + +$ip = NetAddr::IP::Lite->new('340282366920938463463374607431768211455/1'); +$got = $ip->cidr(); +print "got: $got\nexp: $exp\nnot " + unless $got eq $exp; +&ok; + diff --git a/Lite/t/bits.t b/Lite/t/bits.t new file mode 100644 index 0000000..476b9df --- /dev/null +++ b/Lite/t/bits.t @@ -0,0 +1,37 @@ + +#use diagnostics; +use NetAddr::IP::Lite; + +$| = 1; + +print "1..3\n"; + +my $test = 1; +sub ok() { + print 'ok ',$test++,"\n"; +} + +my $loip = new NetAddr::IP::Lite('::1.2.3.4/120'); # same as 1.2.3.4/24 +my $hiip = new NetAddr::IP::Lite('FF00::1:4/120'); +my $dqip = new NetAddr::IP::Lite('1.2.3.4/24'); + +## test bits lo +$exp = 128; +my $bits = $loip->bits; +print "got: $bits, exp: $exp\nnot " + unless $bits == $exp; +&ok; + +## test bits hi +$exp = 128; +$bits = $hiip->bits; +print "got: $bits, exp: $exp\nnot " + unless $bits == $exp; +&ok; + +## test dotquad bits +$exp = 32; +$bits = $dqip->bits; +print "got: $bits, exp: $exp\nnot " + unless $bits == $exp; +&ok; diff --git a/Lite/t/broadcast.t b/Lite/t/broadcast.t new file mode 100644 index 0000000..fea884f --- /dev/null +++ b/Lite/t/broadcast.t @@ -0,0 +1,37 @@ + +#use diagnostics; +use NetAddr::IP::Lite; + +$| = 1; + +print "1..3\n"; + +my $test = 1; +sub ok() { + print 'ok ',$test++,"\n"; +} + +my $loip = new NetAddr::IP::Lite('::1.2.3.4/120'); # same as 1.2.3.4/24 +my $hiip = new NetAddr::IP::Lite('FF00::4/120'); + +## test '""' just for the heck of it +my $exp = 'FF00:0:0:0:0:0:0:4/120'; +my $txt = sprintf("%s",$hiip); +print 'got: ',$txt," exp: $exp\nnot " + unless $txt eq $exp; +&ok; + +## test broadcast lo +$exp = '0:0:0:0:0:0:102:3FF/120'; +my $broad = $loip->broadcast; +print 'got: ',$broad, " exp: $exp\nnot " + unless $broad eq $exp; +&ok; + +## test broadcast hi +$exp = 'FF00:0:0:0:0:0:0:FF/120'; +$broad = $hiip->broadcast; +print 'got: ',$broad, " exp: $exp\nnot " + unless $broad eq $exp; +&ok; + diff --git a/Lite/t/bug62521.t b/Lite/t/bug62521.t new file mode 100644 index 0000000..0fdfc06 --- /dev/null +++ b/Lite/t/bug62521.t @@ -0,0 +1,28 @@ + +BEGIN { $| = 1; print "1..3\n"; } +END {print "not ok 1\n" unless $loaded;} + +$loaded = 1; +print "ok 1\n"; + +#use diagnostics; +use NetAddr::IP::Lite; + +$| = 1; + +my $test = 2; + +sub ok() { + print 'ok ',$test++,"\n"; +} + +$exp = '0:0:0:0:0:0:7F00:0/104'; +my $ip = new6 NetAddr::IP::Lite('127.0.0.0/8'); +print "exp $exp\ngot ", $ip, "\nnot " + unless $ip eq $exp; +&ok; + +$ip = new6 NetAddr::IP::Lite('127/8'); +print "exp $exp\ngot ", $ip, "\nnot " + unless $ip eq $exp; +&ok; diff --git a/Lite/t/bug75976.t b/Lite/t/bug75976.t new file mode 100644 index 0000000..9cfe498 --- /dev/null +++ b/Lite/t/bug75976.t @@ -0,0 +1,41 @@ + +BEGIN { $| = 1; print "1..7\n"; } +END {print "not ok 1\n" unless $loaded;} + +$loaded = 1; +print "ok 1\n"; + +#use diagnostics; +use NetAddr::IP::Lite; + +$| = 1; + +my $test = 2; + +sub ok() { + print 'ok ',$test++,"\n"; +} + +my $ud = undef; +my @bugtest = ( + 0 => '0.0.0.0/32', '0:0:0:0:0:0:0:0/128', + $ud => '0.0.0.0/0', '0:0:0:0:0:0:0:0/0', + "" => 'undef', 'undef', +); + + +for (my $i=0;$i <= $#bugtest;$i+=3) { + my $ip6 = sprintf("%s", NetAddr::IP::Lite->new6($bugtest[$i]) || 'undef'); + my $ip = sprintf ("%s", NetAddr::IP::Lite->new($bugtest[$i]) || 'undef'); + my $expip = $bugtest[$i+1]; + my $expip6 = $bugtest[$i+2]; + + print "got: $ip\nexp: $expip\nnot " + unless $ip eq $expip; + &ok; + + print "got: $ip6\nexp: $expip6\nnot " + unless $ip6 eq $expip6; + &ok; + +} diff --git a/Lite/t/cidr.t b/Lite/t/cidr.t new file mode 100644 index 0000000..292521a --- /dev/null +++ b/Lite/t/cidr.t @@ -0,0 +1,36 @@ + +#use diagnostics; +use NetAddr::IP::Lite; + +$| = 1; + +print "1..3\n"; + +my $test = 1; +sub ok() { + print 'ok ',$test++,"\n"; +} + +my $loip = new NetAddr::IP::Lite('::1.2.3.4/120'); # same as 1.2.3.4/24 +my $hiip = new NetAddr::IP::Lite('FF00::4/120'); +my $dqip = new NetAddr::IP::Lite('1.2.3.4/24'); + +## test cidr + +my $exp = 'FF00:0:0:0:0:0:0:4/120'; +my $txt = $hiip->cidr; +print "got: $txt, exp: $exp\nnot " + unless $txt eq $exp; +&ok; + +$exp = '0:0:0:0:0:0:102:304/120'; +$txt = $loip->cidr; +print "got: $txt, exp: $exp\nnot " + unless $txt eq $exp; +&ok; + +$exp = '1.2.3.4/24'; +$txt = $dqip->cidr; +print "got: $txt, exp: $exp\nnot " + unless $txt eq $exp; +&ok; diff --git a/Lite/t/constants.t b/Lite/t/constants.t new file mode 100644 index 0000000..fd1602d --- /dev/null +++ b/Lite/t/constants.t @@ -0,0 +1,19 @@ + +#use diagnostics; +use Test::More tests => 15; +use NetAddr::IP::Lite qw(Zeros Zero Ones V4mask V4net); + +my %const = ( + '0::' => Zeros, + '::' => Zero, + 'FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF' => Ones, + 'FFFF:FFFF:FFFF:FFFF:FFFF:FFFF::' => V4mask, + '::FFFF:FFFF' => V4net, +); + +my($ip,$rv); +foreach (sort keys %const) { + ok(($ip = new NetAddr::IP::Lite($_)),"netaddr $_"); + ok($ip->{addr} eq $const{$_},"match $_"); + ok(($rv = length($const{$_})) == 16, "length $_ is $rv"); +} diff --git a/Lite/t/contains.t b/Lite/t/contains.t new file mode 100644 index 0000000..c192658 --- /dev/null +++ b/Lite/t/contains.t @@ -0,0 +1,40 @@ + +#use diagnostics; +use NetAddr::IP::Lite; + +$| = 1; + +print "1..12\n"; + +my $test = 1; +sub ok() { + print 'ok ',$test++,"\n"; +} + +my $net4 = NetAddr::IP::Lite->new('1.2.3.5/30'); +my $net6 = NetAddr::IP::Lite->new('FF::85/126'); +my @try = qw( + 1.2.3.3 0 + 1.2.3.4 1 + 1.2.3.5 1 + 1.2.3.6 1 + 1.2.3.7 1 + 1.2.3.8 0 + FF::83 0 + FF::84 1 + FF::85 1 + FF::86 1 + FF::87 1 + FF::88 0 +); + +for (my $i=0;$i<@try;$i+=2) { + my $ip = NetAddr::IP::Lite->new($try[$i]); + my $rv = ($try[$i] =~ /:/) + ? $net6->contains($ip) + : $net4->contains($ip); + print "got: $rv, exp: $try[$i+1]\nnot " + unless $rv == $try[$i+1]; + &ok; +} + diff --git a/Lite/t/copy.t b/Lite/t/copy.t new file mode 100644 index 0000000..a21fdf2 --- /dev/null +++ b/Lite/t/copy.t @@ -0,0 +1,52 @@ + +#use diagnostics; +use NetAddr::IP::Lite 0.10; +*Ones = \&NetAddr::IP::Lite::Ones; +use NetAddr::IP::Util qw( + ipv6_aton + shiftleft +); +$| = 1; + +print "1..4\n"; + +my $test = 1; +sub ok() { + print 'ok ',$test++,"\n"; +} + +my $ip24 = '1.2.3.4/24'; +my $o = new NetAddr::IP::Lite($ip24); +my $c = $o->copy; + +## test 1 validate original +my $txto = sprintf("%s",$o); +my $txtc = sprintf("%s",$c); +print "orig... got: $txto, exp: $ip24\nnot " + unless $txto eq $ip24; +&ok; + +## test 2 +print "copy... got: $txtc, exp: $ip24\nnot " + unless $txtc eq $ip24; +&ok; + +my $ip28 = '1.2.3.4/28'; +my $mask = shiftleft(Ones(),32 - 28); + +$c->{mask} = $mask; +$txto = sprintf("%s",$o); +$txtc = sprintf("%s",$c); + +## test 3 validate original +$txto = sprintf("%s",$o); +$txtc = sprintf("%s",$c); +print "orig... got: $txto, exp: $ip24\nnot " + unless $txto eq $ip24; +&ok; + +## test 4 +print "copy... got: $txtc, exp: $ip28\nnot " + unless $txtc eq $ip28; +&ok; + diff --git a/Lite/t/firstlast.t b/Lite/t/firstlast.t new file mode 100644 index 0000000..edb9f3c --- /dev/null +++ b/Lite/t/firstlast.t @@ -0,0 +1,66 @@ + +#use diagnostics; +use NetAddr::IP::Lite; + +$| = 1; + +print "1..8\n"; + +my $test = 1; +sub ok() { + print 'ok ',$test++,"\n"; +} + +my $ip4 = NetAddr::IP::Lite->new('1.2.3.11/29'); +my $ip6 = NetAddr::IP::Lite->new('FF::8B/125'); + +my $exp = '1.2.3.9'; +my $rv = $ip4->first->addr; +print "got: $rv, exp: $exp\nnot " + unless $rv eq $exp; +&ok; + +$exp = '1.2.3.14'; +$rv = $ip4->last->addr; +print "got: $rv, exp: $exp\nnot " + unless $rv eq $exp; +&ok; + +$exp = 'FF:0:0:0:0:0:0:89'; +$rv = $ip6->first->addr; +print "got: $rv, exp: $exp\nnot " + unless $rv eq $exp; +&ok; + +$exp = 'FF:0:0:0:0:0:0:8E'; +$rv = $ip6->last->addr; +print "got: $rv, exp: $exp\nnot " + unless $rv eq $exp; +&ok; + +$ip4 = NetAddr::IP::Lite->new('1.2.3.11/31'); +$ip6 = NetAddr::IP::Lite->new('FF::8B/127'); + +$exp = '1.2.3.10'; +$rv = $ip4->first->addr; +print "got: $rv, exp: $exp\nnot " + unless $rv eq $exp; +&ok; + +$exp = '1.2.3.11'; +$rv = $ip4->last->addr; +print "got: $rv, exp: $exp\nnot " + unless $rv eq $exp; +&ok; + +$exp = 'FF:0:0:0:0:0:0:8A'; +$rv = $ip6->first->addr; +print "got: $rv, exp: $exp\nnot " + unless $rv eq $exp; +&ok; + +$exp = 'FF:0:0:0:0:0:0:8B'; +$rv = $ip6->last->addr; +print "got: $rv, exp: $exp\nnot " + unless $rv eq $exp; +&ok; diff --git a/Lite/t/ipv4FFFF.t b/Lite/t/ipv4FFFF.t new file mode 100644 index 0000000..bbea1a0 --- /dev/null +++ b/Lite/t/ipv4FFFF.t @@ -0,0 +1,18 @@ + +#use diagnostics; +use NetAddr::IP::Lite; + +$| = 1; + +print "1..1\n"; + +my $test = 1; +sub ok() { + print 'ok ',$test++,"\n"; +} + +my $ip = new6FFFF NetAddr::IP::Lite('127.0.0.1'); +my $exp = '0:0:0:0:0:FFFF:7F00:1/128'; +print "got: $ip\nexp: $exp\nnot " + unless "$ip" eq $exp; +&ok; diff --git a/Lite/t/is_local.t b/Lite/t/is_local.t new file mode 100644 index 0000000..8d3545c --- /dev/null +++ b/Lite/t/is_local.t @@ -0,0 +1,36 @@ + +#use diagnostics; +use NetAddr::IP::Lite; + +$| = 1; + +print "1..9\n"; + +my $test = 1; +sub ok() { + print 'ok ',$test++,"\n"; +} + +my @ips = qw( + 126.255.255.255 0 + 127.0.0.0 1 + 127.0.0.1 1 + 127.255.255.254 1 + 127.255.255.255 1 + 128.0.0.0 0 + ::0 0 + ::1 1 + ::2 0 + +); + + +for (my $i=0;$i<=$#ips;$i+=2) { + my $ip = new NetAddr::IP::Lite($ips[$i]); + my $got = $ip->is_local(); + my $exp = $ips[$i+1]; + print $ip," got: $got, exp: $exp\nnot " + unless $got == $exp; + &ok; +} + diff --git a/Lite/t/lemasklen.t b/Lite/t/lemasklen.t new file mode 100644 index 0000000..b79e558 --- /dev/null +++ b/Lite/t/lemasklen.t @@ -0,0 +1,19 @@ +use NetAddr::IP::Lite; + +my @masks = 0 .. 32; + +$| = 1; + +print '1..', scalar @masks, "\n"; + +my $count = 1; + +for my $m (@masks) { + my $ip = new NetAddr::IP::Lite '10.0.0.1', $m; + if ($ip->masklen == $m) { + print "ok ", $count ++, "\n"; + } + else { + print "not ok ", $count ++, "\n"; + } +} diff --git a/Lite/t/loops.t b/Lite/t/loops.t new file mode 100644 index 0000000..8f90ade --- /dev/null +++ b/Lite/t/loops.t @@ -0,0 +1,51 @@ +use NetAddr::IP::Lite; + +$| = 1; + +my @deltas = (0, 1, 2, 3, 255); + +print "1..", 15 + @deltas, "\n"; + +my $count = 1; + +for (my $ip = new NetAddr::IP::Lite '10.0.0.1/28'; + $ip < $ip->broadcast; + $ip ++) +{ + my $o = $ip->addr; + + $o =~ s/^.+\.(\d+)$/$1/; + + if ($o == $count) { + print "ok $count\n"; + } + else { + print "not ok $count\n"; + } + + ++ $count; +} + +my $ip = new NetAddr::IP::Lite '10.0.0.255/24'; +$ip ++; + +if ($ip eq '10.0.0.0/24') { + print "ok $count\n"; +} +else { + print "not ok $count\n"; +} + +++$count; + +$ip = new NetAddr::IP::Lite '10.0.0.0/24'; + +for my $v (@deltas) { + if ($ip + $v eq '10.0.0.' . $v . '/24') { + print "ok $count\n"; + } + else { + print "not ok $count\n"; + } + ++ $count; +} diff --git a/Lite/t/lower.t b/Lite/t/lower.t new file mode 100644 index 0000000..f4fe92e --- /dev/null +++ b/Lite/t/lower.t @@ -0,0 +1,11 @@ + +#use diagnostics; +use Test::More tests => 2; + +use_ok ('NetAddr::IP::Lite', qw(:lower)); + +my $exp = 'ff:0:0:0:0:0:0:eeaa/128'; +my $ip = new NetAddr::IP::Lite('FF::eeAA'); +my $got = sprintf $ip; +ok ($got eq $exp,"lower case $got"); + diff --git a/Lite/t/mask.t b/Lite/t/mask.t new file mode 100644 index 0000000..2709383 --- /dev/null +++ b/Lite/t/mask.t @@ -0,0 +1,44 @@ + +#use diagnostics; +use NetAddr::IP::Lite; + +$| = 1; + +print "1..4\n"; + +my $test = 1; +sub ok() { + print 'ok ',$test++,"\n"; +} + +my $loip = new NetAddr::IP::Lite('::1.2.3.4/120'); # same as 1.2.3.4/24 +my $hiip = new NetAddr::IP::Lite('FF00::1:4/120'); +my $dqip = new NetAddr::IP::Lite('1.2.3.4/24'); + +## test '""' just for the heck of it +my $exp = 'FF00:0:0:0:0:0:1:4/120'; +my $txt = sprintf("%s",$hiip); +print 'got: ',$txt," exp: $exp\nnot " + unless $txt eq $exp; +&ok; + +## test lo ip +$exp = 'FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FF00'; +my $mask = $loip->mask; +print "got: $mask, exp: $exp\nnot " + unless $mask eq $exp && ! ref $mask; +&ok; + +## test mask hi +$exp = 'FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FF00'; +$mask = $hiip->mask; +print "got: $mask, exp: $exp\nnot " + unless $mask eq $exp && ! ref $mask; +&ok; + +## test mask dot quad +$exp = '255.255.255.0'; +$mask = $dqip->mask; +print "got: $mask, exp: $exp\nnot " + unless $mask eq $exp && ! ref $mask; +&ok; diff --git a/Lite/t/masklen.t b/Lite/t/masklen.t new file mode 100644 index 0000000..409b282 --- /dev/null +++ b/Lite/t/masklen.t @@ -0,0 +1,37 @@ + +#use diagnostics; +use NetAddr::IP::Lite; + +$| = 1; + +print "1..3\n"; + +my $test = 1; +sub ok() { + print 'ok ',$test++,"\n"; +} + +my $loip = new NetAddr::IP::Lite('::1.2.3.4/120'); # same as 1.2.3.4/24 +my $hiip = new NetAddr::IP::Lite('FF00::1:4/120'); +my $dqip = new NetAddr::IP::Lite('1.2.3.4/24'); + +## test masklen lo +$exp = 120; +my $masklen = $loip->masklen; +print "got: $masklen, exp: $exp\nnot " + unless $masklen == $exp; +&ok; + +## test masklen hi +$exp = 120; +$masklen = $hiip->masklen; +print "got: $masklen, exp: $exp\nnot " + unless $masklen == $exp; +&ok; + +## test masklen dq +$exp = 24; +$masklen = $dqip->masklen; +print "got: $masklen, exp: $exp\nnot " + unless $masklen == $exp; +&ok; diff --git a/Lite/t/netaddr.t b/Lite/t/netaddr.t new file mode 100644 index 0000000..9eec7db --- /dev/null +++ b/Lite/t/netaddr.t @@ -0,0 +1,208 @@ +# Before `make install' is performed this script should be runnable with +# `make test'. After `make install' it should work as `perl test.pl' + +######################### We start with some black magic to print on failure. +# Change 1..1 below to 1..last_test_to_print . +# (It may become useful if the test is moved to ./t subdirectory.) + +BEGIN { $| = 1; print "1..35\n"; } +END {print "not ok 1\n" unless $loaded;} + +#use diagnostics; +use Data::Dumper; +use NetAddr::IP::Lite; + +$loaded = 1; +print "ok 1\n"; +######################### End of black magic. + +# Insert your test code below (better if it prints "ok 13" +# (correspondingly "not ok 13") depending on the success of chunk 13 +# of the test code): + +=pod + +$rv=list2NetAddr(\@inlist,\@NAobject); + +Build of NetAddr object structure from a list of IPv4 addresses or address +ranges. This object is passed to B to check if a given IP +address is contained in the list. + + input: array reference pointer + to a list of addresses + + i.e. 11.22.33.44 + 11.22.33.0/24 + 11.22.33.0/255.255.255.0 + 11.22.33.20-11.22.33.46 + 11.22.33.20 - 11.22.33.46 + + output: Number of objects created + or undef on error + +The NAobject array is filled with NetAddr::IP::Lite object references. + +=cut + +sub list2NetAddr { + my($inref,$outref) = @_; + return undef + unless ref $inref eq 'ARRAY' + && ref $outref eq 'ARRAY'; + unless ($SKIP_NetAddrIP) { + require NetAddr::IP::Lite; + $SKIP_NetAddrIP = 1; + } + @$outref = (); + my $IP; + no strict; + foreach $IP (@$inref) { + $IP =~ s/\s//g; + # 11.22.33.44 + if ($IP =~ /^\d+\.\d+\.\d+\.\d+$/o) { + push @$outref, NetAddr::IP::Lite->new($IP), 0; + } + # 11.22.33.44 - 11.22.33.49 + elsif ($IP =~ /^(\d+\.\d+\.\d+\.\d+)\s*\-\s*(\d+\.\d+\.\d+\.\d+)$/o) { + push @$outref, NetAddr::IP::Lite->new($1), NetAddr::IP::Lite->new($2); + } + # 11.22.33.44/63 + elsif ($IP =~ m|^\d+\.\d+\.\d+\.\d+/\d+$|) { + push @$outref, NetAddr::IP::Lite->new($IP), 0; + } + # 11.22.33.44/255.255.255.224 + elsif ($IP =~ m|^\d+\.\d+\.\d+\.\d+/\d+\.\d+\.\d+\.\d+$|o) { + push @$outref, NetAddr::IP::Lite->new($IP), 0; + } +# ignore un-matched IP patterns + } + return (scalar @$outref)/2; +} + +=pod + +$rv = matchNetAddr($ip,\@NAobject); + +Check if an IP address appears in a list of NetAddr objects. + + input: dot quad IP address, + reference to NetAddr objects + output: true if match else false + +=cut + +sub matchNetAddr { + my($ip,$naref) = @_; + return 0 unless $ip && $ip =~ /\d+\.\d+\.\d+\.\d+/; + $ip =~ s/\s//g; + $ip = new NetAddr::IP::Lite($ip); + my $i; + for($i=0; $i <= $#{$naref}; $i += 2) { + my $beg = $naref->[$i]; + my $end = $naref->[$i+1]; + if ($end) { + return 1 if $ip >= $beg && $ip <= $end; + } else { + return 1 if $ip->within($beg); + } + } + return 0; +} + + + +$test = 2; + +sub ok { + print "ok $test\n"; + ++$test; +} + +## test 2 instantiate netaddr array +# +# A multi-formated array of IP address that will never be tarpitted. +# +# WARNING: if you are using a private network, then you should include the +# address description for the net/subnets that you are using or you might +# find your DMZ or internal mail servers blocked since many DNSBLS list the +# private network addresses as BLACKLISTED +# +# 127./8, 10./8, 172.16/12, 192.168/16 +# +# class A xxx.0.0.0/8 +# class B xxx.xxx.0.0/16 +# class C xxx.xxx.xxx.0/24 0 +# 128 subnet xxx.xxx.xxx.xxx/25 128 +# 64 subnet xxx.xxx.xxx.xxx/26 192 +# 32 subnet xxx.xxx.xxx.xxx/27 224 +# 16 subnet xxx.xxx.xxx.xxx/28 240 +# 8 subnet xxx.xxx.xxx.xxx/29 248 +# 4 subnet xxx.xxx.xxx.xxx/30 252 +# 2 subnet xxx.xxx.xxx.xxx/31 254 +# single address xxx.xxx.xxx.xxx/32 255 +# +@tstrng = ( + # a single address + '11.22.33.44', + # a range of ip's, ONLY VALID WITHIN THE SAME CLASS 'C' + '22.33.44.55 - 22.33.44.65', + '45.67.89.10-45.67.89.32', + # a CIDR range + '5.6.7.16/28', + # a range specified with a netmask + '7.8.9.128/255.255.255.240', + # this should ALWAYS be here + '127.0.0.0/8', # ignore all test entries and localhost +); +my @NAobject; +my $rv = list2NetAddr(\@tstrng,\@NAobject); +print "wrong number of NA objects\ngot: $rv, exp: 6\nnot " + unless $rv == 6; +&ok; + +## test 3 check disallowed terms +print "accepted null parameter\nnot " + if matchNetAddr(); +&ok; + +## test 4 check disallowed parm +print "accepted non-numeric parameter\nnot " + if matchNetAddr('junk'); +&ok; + +##test 5 check non-ip short +print "accepted short ip segment\nnot " + if matchNetAddr('1.2.3'); +&ok; + +# yeah, it will accept a long one, but that's tough! + +## test 6-35 bracket NA objects +# +my @chkary = # 5 x 6 tests + # out left in left middle in right out right +qw( 11.22.33.43 11.22.33.44 11.22.33.44 11.22.33.44 11.22.33.45 + 22.33.44.54 22.33.44.55 22.33.44.60 22.33.44.65 22.33.44.66 + 45.67.89.9 45.67.89.10 45.67.89.20 45.67.89.32 45.67.89.33 + 5.6.7.15 5.6.7.16 5.6.7.20 5.6.7.31 5.6.7.32 + 7.8.9.127 7.8.9.128 7.8.9.138 7.8.9.143 7.8.9.144 + 126.255.255.255 127.0.0.0 127.128.128.128 127.255.255.255 128.0.0.0 +); + +for(my $i=0;$i <= $#chkary; $i+=5) { + print "accepted outside left bound $chkary[$i]\nnot " + if matchNetAddr($chkary[$i],\@NAobject); + &ok; + print "rejected inside left bound $chkary[$i+1]\nnot " + unless matchNetAddr($chkary[$i+1],\@NAobject); + &ok; + print "rejected inside middle bound $chkary[$i+2]\nnot " + unless matchNetAddr($chkary[$i+2],\@NAobject); + &ok; + print "rejected inside right bound $chkary[$i+3]\nnot " + unless matchNetAddr($chkary[$i+3],\@NAobject); + &ok; + print "accepted outside right bound $chkary[$i+4]\nnot " + if matchNetAddr($chkary[$i+4],\@NAobject); + &ok; +} diff --git a/Lite/t/network.t b/Lite/t/network.t new file mode 100644 index 0000000..c000940 --- /dev/null +++ b/Lite/t/network.t @@ -0,0 +1,44 @@ + +#use diagnostics; +use NetAddr::IP::Lite; + +$| = 1; + +print "1..4\n"; + +my $test = 1; +sub ok() { + print 'ok ',$test++,"\n"; +} + +my $loip = new NetAddr::IP::Lite('::1.2.3.4/120'); # same as 1.2.3.4/24 +my $hiip = new NetAddr::IP::Lite('FF00::1:4/120'); +my $dqip = new NetAddr::IP::Lite('1.2.3.4/24'); + +## test '""' just for the heck of it +my $exp = 'FF00:0:0:0:0:0:1:4/120'; +my $txt = sprintf("%s",$hiip); +print 'got: ',$txt," exp: $exp\nnot " + unless $txt eq $exp; +&ok; + +## test network dq +$exp = '1.2.3.0/24'; +my $net = $dqip->network; +print 'got: ',$net, " exp: $exp\nnot " + unless $net eq $exp; +&ok; + +## test network hi +$exp = 'FF00:0:0:0:0:0:1:0/120'; +$net = $hiip->network; +print 'got: ',$net, " exp: $exp\nnot " + unless $net eq $exp; +&ok; + +## test network lo +$exp = '0:0:0:0:0:0:102:300/120'; +$net = $loip->network; +print 'got: ',$net, " exp: $exp\nnot " + unless $net eq $exp; +&ok; diff --git a/Lite/t/new-nth.t b/Lite/t/new-nth.t new file mode 100644 index 0000000..adcd77a --- /dev/null +++ b/Lite/t/new-nth.t @@ -0,0 +1,44 @@ + +#use diagnostics; +use NetAddr::IP::Lite; + +$| = 1; + +sub ok() { + print 'ok ',$test++,"\n"; +} + +my $ip4 = NetAddr::IP::Lite->new('1.2.3.11/29'); + +my @try = qw( + 0 1.2.3.9 + 1 1.2.3.10 + 2 1.2.3.11 + 3 1.2.3.12 + 4 1.2.3.13 + 5 1.2.3.14 + 6 undef +); + +print '1..', (@try/2) +2, "\n"; + +$test = 1; + +for (my $i=0;$i<@try;$i+=2) { + my $rv = $ip4->nth($try[$i]); + $rv = defined $rv + ? $rv->addr + : 'undef'; + print "got: $rv, exp: $try[$i+1]\nnot " + unless $rv eq $try[$i+1]; + &ok; +} + +print "got: $_, exp: 1\nnot " + unless ($_ = NetAddr::IP::Lite->new('1.2.3.4/32')->num()) && $_ == 1; +&ok; + +print "got: $_, exp: 0\nnot " + unless defined ($_ = NetAddr::IP::Lite->new('1.2.3.4/31')->num()) && $_ == 2; +&ok; + diff --git a/Lite/t/new-num.t b/Lite/t/new-num.t new file mode 100644 index 0000000..76b6510 --- /dev/null +++ b/Lite/t/new-num.t @@ -0,0 +1,33 @@ + +#use diagnostics; +use NetAddr::IP::Lite; + +$| = 1; + +sub ok() { + print 'ok ',$test++,"\n"; +} + +my @try = qw( + 10/32 1 + 10/31 2 + 10/30 2 + ::1/128 1 + ::1/127 2 + ::1/126 2 + 1.2.3.11/29 6 + FF::8B/125 6 +); + +print '1..',(@try/2),"\n"; + +$test = 1; + +foreach(my $i = 0;$i <=$#try;$i+= 2) { + my $ip = NetAddr::IP::Lite->new($try[$i]); + my $exp = $try[$i +1]; + + print "got: $_, exp: $exp\nnot " + unless ($_ = $ip->num) == $exp; + &ok; +} diff --git a/Lite/t/nofqdn.t b/Lite/t/nofqdn.t new file mode 100644 index 0000000..91ab975 --- /dev/null +++ b/Lite/t/nofqdn.t @@ -0,0 +1,29 @@ + + +use NetAddr::IP::Lite + +$| = 1; + +print "1..2\n"; + +my $test = 1; +sub ok() { + print 'ok ',$test++,"\n"; +} + + +my $ip = new NetAddr::IP::Lite('arin.net'); +if (defined $ip) { + print "ok $test # Skipped, resolved $ip\n"; + $test++; +} else { + print "ok $test # Skipped, resolver not working\n"; + $test++; +} + +import NetAddr::IP::Lite qw(:nofqdn); + +$ip = new NetAddr::IP::Lite('arin.net'); +print "unexpected response with :nofqdn\nnot " + if defined $ip; +&ok; diff --git a/Lite/t/numeric.t b/Lite/t/numeric.t new file mode 100644 index 0000000..2ac72f4 --- /dev/null +++ b/Lite/t/numeric.t @@ -0,0 +1,36 @@ + +#use diagnostics; +use NetAddr::IP::Lite; + +$| = 1; + +print "1..6\n"; + +my $test = 1; +sub ok() { + print 'ok ',$test++,"\n"; +} + +my @tval = qw # IP bcd mask bcd +( 8000:0:0:0:0:0:0:1/112 170141183460469231731687303715884105729 340282366920938463463374607431768145920 + 1.2.3.4/24 16909060 4294967040 +); + +for (my $i=0;$i < @tval;$i+=3) { + my $nip = NetAddr::IP::Lite->new($tval[$i]); +## test scalar return + my $sclr = $nip->numeric; + print "got: $sclr\nexp: $tval[$i+1]\nnot " + unless $sclr .'x' eq $tval[$i+1] .'x'; + &ok; + +## test array return + my($addr,$mask) = $nip->numeric; + print "got: $addr\nexp: $tval[$i+1]\nnot " + unless $addr .'x' eq $tval[$i+1] .'x'; + &ok; + + print "got: $mask\nexp: $tval[$i+2]\nnot " + unless $mask .'x' eq $tval[$i+2] .'x'; + &ok; +} diff --git a/Lite/t/old-nth.t b/Lite/t/old-nth.t new file mode 100644 index 0000000..b63cf75 --- /dev/null +++ b/Lite/t/old-nth.t @@ -0,0 +1,36 @@ + +#use diagnostics; +use NetAddr::IP::Lite qw(:old_nth); + +$| = 1; + +print "1..9\n"; + +my $test = 1; +sub ok() { + print 'ok ',$test++,"\n"; +} + +my $ip4 = NetAddr::IP::Lite->new('1.2.3.11/29'); + +my @try = qw( + 0 undef + 1 1.2.3.9 + 2 1.2.3.10 + 3 1.2.3.11 + 4 1.2.3.12 + 5 1.2.3.13 + 6 1.2.3.14 + 7 1.2.3.15 + 8 undef +); + +for (my $i=0;$i<@try;$i+=2) { + my $rv = $ip4->nth($try[$i]); + $rv = defined $rv + ? $rv->addr + : 'undef'; + print "got: $rv, exp: $try[$i+1]\nnot " + unless $rv eq $try[$i+1]; + &ok; +} diff --git a/Lite/t/old-num.t b/Lite/t/old-num.t new file mode 100644 index 0000000..f550054 --- /dev/null +++ b/Lite/t/old-num.t @@ -0,0 +1,33 @@ + +#use diagnostics; +use NetAddr::IP::Lite qw(:old_nth); + +$| = 1; + +sub ok() { + print 'ok ',$test++,"\n"; +} + +my @try = qw( + 10/32 0 + 10/31 1 + 10/30 3 + ::1/128 0 + ::1/127 1 + ::1/126 3 + 1.2.3.11/29 7 + FF::8B/125 7 +); + +print '1..',(@try/2),"\n"; + +$test = 1; + +foreach(my $i = 0;$i <=$#try;$i+= 2) { + my $ip = NetAddr::IP::Lite->new($try[$i]); + my $exp = $try[$i +1]; + + print "got: $_, exp: $exp\nnot " + unless ($_ = $ip->num) == $exp; + &ok; +} diff --git a/Lite/t/over-qq.t b/Lite/t/over-qq.t new file mode 100644 index 0000000..7571156 --- /dev/null +++ b/Lite/t/over-qq.t @@ -0,0 +1,53 @@ +use NetAddr::IP::Lite; + +my @addr = ('10.0.0.0/8', '192.168.0.0/16', '127.0.0.1/32'); + +$| = 1; + +print "1..", 5 * scalar @addr, "\n"; + +my $count = 1; + +for my $a (@addr) { + my $ip = new NetAddr::IP::Lite $a; + if ($a eq "$ip") { + print "ok $count\n"; + } + else { + print "not ok $count\n"; + } + ++ $count; + + if ($a eq $ip) { + print "ok $count\n"; + } + else { + print "not ok $count\n"; + } + ++ $count; + + if ($ip eq $a) { + print "ok $count\n"; + } + else { + print "not ok $count\n"; + } + ++ $count; + + if ($ip eq $ip) { + print "ok $count\n"; + } + else { + print "not ok $count\n"; + } + ++ $count; + + if ($ip == $ip) { + print "ok $count\n"; + } + else { + print "not ok $count\n"; + } + ++ $count; + +} diff --git a/Lite/t/over_comp.t b/Lite/t/over_comp.t new file mode 100644 index 0000000..16a0480 --- /dev/null +++ b/Lite/t/over_comp.t @@ -0,0 +1,66 @@ + +#use diagnostics; +use NetAddr::IP::Lite; + +$| = 1; + +print "1..21\n"; + +my $test = 1; +sub ok() { + print 'ok ',$test++,"\n"; +} + +my $four = new NetAddr::IP::Lite('::4'); +$four->{val} = 4; +my $five = new NetAddr::IP::Lite('::5'); +$five->{val} = 5; +my @t = ( +# arg1 arg2 < <= == >= > <=> cmp + $four, $four, 0, 1, 1, 1, 0, 0, 0, + $four, $five, 1, 1, 0, 0, 0, -1, -1, + $five, $four, 0, 0, 0, 1, 1, 1, 1, +); + +for (my $i = 0; $i< @t; $i+=9) { +## test '=' overloaded here + my $arg1 = $t[$i]; + my $arg2 = $t[$i+1]; + my ($lt,$le,$eq,$ge,$gt,$nc,$cmp) = @t[$i+2,$i+3,$i+4,$i+5,$i+6,$i+7,$i+8]; + +## test '<' + print "failed $arg1->{val} < $arg2->{val}, got: $_, exp: $lt\nnot " + unless ($_ = ($arg1 < $arg2)) == $lt; + &ok; + +## test '<=' + print "failed $arg1->{val} <= $arg2->{val}, got: $_, exp: $le\nnot " + unless ($_ = ($arg1 <= $arg2)) == $le; + &ok; + +## test '==' + print "failed $arg1->{val} == $arg2->{val}, got: $_, exp: $eq\nnot " + unless ($_ = ($arg1 == $arg2)) == $eq; + &ok; + +## test '>=' + print "failed $arg1->{val} >= $arg2->{val}, got: $_, exp: $ge\nnot " + unless ($_ = ($arg1 >= $arg2)) == $ge; + &ok; + +## test '>' + print "failed $arg1->{val} > $arg2->{val}, got: $_, exp: $gt\nnot " + unless ($_ = ($arg1 > $arg2)) == $gt; + &ok; + +## test '<=>' + print "failed $arg1->{val} <=> $arg2->{val}, got: $_, exp: $nc\nnot " + unless ($_ = ($arg1 <=> $arg2)) == $nc; + &ok; + +## test 'cmp' + print "failed $arg1->{val} cmp $arg2->{val}, got: $_, exp: $cmp\nnot " + unless ($_ = ($arg1 cmp $arg2)) == $cmp; + &ok; +} + diff --git a/Lite/t/over_copy.t b/Lite/t/over_copy.t new file mode 100644 index 0000000..7b9aba6 --- /dev/null +++ b/Lite/t/over_copy.t @@ -0,0 +1,85 @@ + +#use diagnostics; +use NetAddr::IP::Lite 0.10; +*Ones = \&NetAddr::IP::Lite::Ones; +use NetAddr::IP::Util qw( + ipv6_aton + shiftleft +); +$| = 1; + +print "1..8\n"; + +my $test = 1; +sub ok() { + print 'ok ',$test++,"\n"; +} + +my $ip24 = '1.2.3.4/24'; +my $o = new NetAddr::IP::Lite($ip24); +my $c = $o; + +## test 1 validate original +my $txto = sprintf("%s",$o); +my $txtc = sprintf("%s",$c); +print "orig... got: $txto, exp: $ip24\nnot " + unless $txto eq $ip24; +&ok; + +## test 2 +print "copy... got: $txtc, exp: $ip24\nnot " + unless $txtc eq $ip24; +&ok; + +my $ip28 = '1.2.3.4/28'; +my $mask = shiftleft(Ones(),32 - 28); + +$c->{mask} = $mask; +$txto = sprintf("%s",$o); +$txtc = sprintf("%s",$c); + +## overload does not unlink originals in this case +## test 3 validate original +$txto = sprintf("%s",$o); +$txtc = sprintf("%s",$c); +print "orig... got: $txto, exp: $ip28\nnot " + unless $txto eq $ip28; +&ok; + +## test 4 +print "copy... got: $txtc, exp: $ip28\nnot " + unless $txtc eq $ip28; +&ok; + +my $ip265 = '1.2.3.5/26'; +my $ip285 = '1.2.3.5/28'; +$mask = shiftleft(Ones(),32 - 26); + +## test 5 overload seperates variables +$c++; +## validate original +$txto = sprintf("%s",$o); +$txtc = sprintf("%s",$c); +print "orig... got: $txto, exp: $ip28\nnot " + unless $txto eq $ip28; +&ok; + +## test 6 check mutated copy +print "copy... got: $txtc, exp: $ip285\nnot " + unless $txtc eq $ip285; +&ok; + +## test 7 check seperation +$c->{mask} = $mask; +## validate original +$txto = sprintf("%s",$o); +$txtc = sprintf("%s",$c); +print "orig... got: $txto, exp: $ip28\nnot " + unless $txto eq $ip28; +&ok; + +## test 8 check mutated copy +print "copy... got: $txtc, exp: $ip265\nnot " + unless $txtc eq $ip265; +&ok; + diff --git a/Lite/t/over_equal.t b/Lite/t/over_equal.t new file mode 100644 index 0000000..9b1ff18 --- /dev/null +++ b/Lite/t/over_equal.t @@ -0,0 +1,122 @@ + +#use diagnostics; +use NetAddr::IP::Lite; + +$| = 1; + +print "1..14\n"; + +my $test = 1; +sub ok() { + print 'ok ',$test++,"\n"; +} + +my $four = new NetAddr::IP::Lite('0.0.0.4'); # same as 0.0.0.4/32 +my $four120 = new NetAddr::IP::Lite('::4/120'); # same as 0.0.0.4/24 + +my $t432 = '0.0.0.4/32'; +my $t4120 = '0:0:0:0:0:0:0:4/120'; + +my $five = new NetAddr::IP::Lite('0.0.0.5'); +my $t532 = '0.0.0.5/32'; + + +# 1 +## test '""' overload +my $txt = sprintf ("%s",$four120); + +print "got: $txt, exp: $t4120\nnot " + unless $txt eq $t4120; +&ok; + +# 2 +## test '""' again +$txt = sprintf ("%s",$four); + +print "got: $txt, exp: $t432\nnot " + unless $txt eq $t432; +&ok; + +# 3 +## test 'eq' to scalar +print 'failed ',$four," eq $t432\nnot " + unless $four eq $t432; +&ok; + +# 4 +## test scalar 'eq' to +print "failed $t432 eq ",$four,"\nnot " + unless $t432 eq $four; +&ok; + +# 5 +## test 'eq' to self +print 'failed ',$four,' eq ', $four,"\nnot " + unless $four eq $four; +&ok; + +# 6 +## test 'eq' cidr != +print 'failed ',$four,' should not eq ',$four120,"\nnot " + if $four eq $four120; +&ok; + +# 7 +## test '==' not for scalars +print "failed scalar $t432 should not == ",$four,"\nnot " + if $t432 == $four; +&ok; + +# 8 +## test '== not for scalar, reversed args +print 'failed scalar ',$four," should not == $t432\nnot " + if $four == $t432; +&ok; + +# ========================================== +# +# test "ne" and "!=" +# +# 9 +## test 'ne' to scalar +print 'failed ',$four120," ne $t432\nnot " + unless $four120 ne $t432; +&ok; + +# 10 +## test scalar 'ne' to +print "failed $t432 ne ",$four120,"\nnot " + unless $t432 ne $four120; +&ok; + +# 11 +## test 'ne' to cidr +print 'failed ',$four,' ne ', $four120,"\nnot " + unless $four ne $four120; +&ok; + +# 12 +## test '!=' not for scalar, reversed args +$rv = $five != $four ? 1 : 0; +#print "rv=$rv\n"; +print "failed scalar $five != $four\nnot " + unless $rv; +&ok; + +# unblessed scalars not welcome +undef local $^W; +# 13 +## test '!=' not for scalars +my $rv = $t432 != $five ? 1 : 0; +#print "rv=$rv\n"; +print "failed scalar $t432 != ",$five,"\nnot " + unless $rv; +&ok; + +# 14 +# since both of these are string scalars, the != should fail +$rv = $t532 != $t432 ? 1 : 0; +#print "rv = $rv\n"; +print "failed scalar $t532 != $t432\nnot " + if $rv; +&ok; diff --git a/Lite/t/over_math.t b/Lite/t/over_math.t new file mode 100644 index 0000000..a912ef7 --- /dev/null +++ b/Lite/t/over_math.t @@ -0,0 +1,64 @@ + +#use diagnostics; +use NetAddr::IP::Lite; + +$| = 1; + +print "1..7\n"; + +my $test = 1; +sub ok() { + print 'ok ',$test++,"\n"; +} + +my $ip = new NetAddr::IP::Lite('0.0.0.4/24'); + +## test '+' +my $exp = '0.0.0.132/24'; +my $nip = $ip + 128; +print 'got: ',$nip," exp: $exp\nnot " + unless $nip eq $exp; +&ok; + +## test '+' wrap around +$nip = $ip + 257; +$exp = '0.0.0.5/24'; +print 'got: ',$nip," exp: $exp\nnot " + unless $nip eq $exp; +&ok; + +## test '-' and wrap +$nip = $ip - 10; +$exp = '0.0.0.250/24'; +print 'got: ',$nip," exp: $exp\nnot " + unless $nip eq $exp; +&ok; + +## test '++' post +$nip++; +$exp = '0.0.0.251/24'; +print 'got: ',$nip," exp: $exp\nnot " + unless $nip eq $exp; +&ok; + +## test '++' pre +++$nip; +$exp = '0.0.0.252/24'; +print 'got: ',$nip," exp: $exp\nnot " + unless $nip eq $exp; +&ok; + +## test '--' post +$ip--; +$exp = '0.0.0.3/24'; +print 'got: ',$ip," exp: $exp\nnot " + unless $ip eq $exp; +&ok; + +## test '--' pre +--$ip; +$exp = '0.0.0.2/24'; +print 'got: ',$ip," exp: $exp\nnot " + unless $ip eq $exp; +&ok; + diff --git a/Lite/t/overminus.t b/Lite/t/overminus.t new file mode 100644 index 0000000..50254cd --- /dev/null +++ b/Lite/t/overminus.t @@ -0,0 +1,45 @@ + +#use diagnostics; +use Test::More tests => 32; +use NetAddr::IP::Lite; + +my $ip80 = new NetAddr::IP::Lite('::1:8000:0/80'); +my $ip7f = $ip80 - 1; +my $maxplus = 2147483647; +my $maxminus = 2147483648; + +my $rv; + +my $ipmax = $ip80 + $maxplus; +ok(($rv = sprintf("%s",$ipmax)) eq '0:0:0:0:0:1:FFFF:FFFF/80',"ip80 maxplus eq $rv eq 0:0:0:0:0:1:FFFF:FFFF/80"); + +my $ipmin = $ip80 - $maxminus; +ok(($rv = sprintf("%s",$ipmin)) eq '0:0:0:0:0:1:0:0/80',"ip80 maxminus� eq $rv eq 0:0:0:0:0:1:0:0/80"); + +my $over = $maxplus +1; +ok(($rv = sprintf("%s",$ip80 + $over)) eq '0:0:0:0:0:1:8000:0/80',"ip80 +overange unchanged, $rv"); + +$over = $maxminus +1; +ok(($rv = sprintf("%s",$ip80 - $over)) eq '0:0:0:0:0:1:8000:0/80',"ip80 -overange unchanged, $rv"); + + +ok(($rv = sprintf("%s",$ip80)) eq '0:0:0:0:0:1:8000:0/80',"ip80 eq $rv eq 0:0:0:0:0:1:8000:0/80"); +ok(($rv = sprintf("%s",$ip7f)) eq '0:0:0:0:0:1:7FFF:FFFF/80',"ip7f eq $rv eq 0:0:0:0:0:1:7FFF:FFFF/80"); + +ok(($rv = $ip80 - $ip7f) == 1,"ip80 - ip7f = $rv"); +ok(($rv = $ip7f - $ip80) == -1,"ip7f - ip80 = $rv"); + +ok(($rv = $ipmax - $ip80) == $maxplus,"ipmax - ip80 = $rv should be $maxplus"); +ok(($rv = $ipmin - $ip80) == -$maxminus,"ipmin - ip80 = $rv should be \-$maxminus"); + +++$ipmax; +--$ipmin; +ok(! defined($ipmax - $ip80),'undefined $ipmax - $ip80 is overange'); +ok(! defined($ipmin - $ip80),'undefined $ipmin - $ip80 is -overange'); + +my $ipx = $ip80->copy + 256; +foreach (1..10) { + ok(($rv = $ipx - $ip80) == $_ * 256,"$ipx - $ip80 = ". $_*256 ." should be $rv"); + ok(($rv = $ip80 - $ipx) == - $_ * 256,"$ip80 - $ipx = ". -$_*256 ." should be $rv"); + $ipx += 256; +} diff --git a/Lite/t/pathological.t b/Lite/t/pathological.t new file mode 100644 index 0000000..deaafc6 --- /dev/null +++ b/Lite/t/pathological.t @@ -0,0 +1,27 @@ + +#use diagnostics; +use NetAddr::IP::Lite; + +END {print "1..1\nnot ok 1\n" unless $test}; + +$| = 1; + +$test = 1; +sub ok() { + print 'ok ',$test++,"\n"; +} + +my @addrs = # pathological cases should fail +qw( ::foo + ::f00/129 + ::f00/150 +); + +print '1..',(scalar @addrs),"\n"; + +my $ip; +foreach(@addrs) { + print "expected undef, got: $ip\nnot " + if ($ip = new NetAddr::IP::Lite($_)); + &ok; +} diff --git a/Lite/t/range.t b/Lite/t/range.t new file mode 100644 index 0000000..cd43053 --- /dev/null +++ b/Lite/t/range.t @@ -0,0 +1,34 @@ + +#use diagnostics; +use NetAddr::IP::Util qw( + inet_ntoa + ipv6_n2x +); +use NetAddr::IP::Lite; + +$| = 1; + +print "1..2\n"; + +my $test = 1; +sub ok() { + print 'ok ',$test++,"\n"; +} + +my $loip = new NetAddr::IP::Lite('1.2.3.4/24'); +my $hiip = new NetAddr::IP::Lite('FF00::4/120'); + +## test range + +my $exp = 'FF00:0:0:0:0:0:0:0 - FF00:0:0:0:0:0:0:FF'; +my $txt = $hiip->range; +print "got: $txt, exp: $exp\nnot " + unless $txt eq $exp; +&ok; + +$exp = '1.2.3.0 - 1.2.3.255'; +$txt = $loip->range; +print "got: $txt, exp: $exp\nnot " + unless $txt eq $exp; +&ok; + diff --git a/Lite/t/relops.t b/Lite/t/relops.t new file mode 100644 index 0000000..0c09a50 --- /dev/null +++ b/Lite/t/relops.t @@ -0,0 +1,59 @@ +use NetAddr::IP::Lite; + +BEGIN { +@gt = ( + [ '255.255.255.255/32', '0.0.0.0/0' ], + [ 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff', '::/0' ], + [ '10.0.1.0/16', '10.0.0.1/24' ], + [ '10.0.0.1/24', '10.0.0.0/24' ], + [ 'deaf:beef::1/64', 'dead:beef::/64' ], + ); + +@ngt = ( + [ '0.0.0.0/0', '255.255.255.255/32' ], + [ '::/0', 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff' ], + [ '10.0.0.0/24', '10.0.0.0/24' ], + [ 'dead:beef::/60', 'dead:beef::/60' ], + ); + +@cmp = ( + [ '0.0.0.0/0', '255.255.255.255/32', -1 ], + [ '::/0', 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff', -1 ], + [ '10.0.0.0/16', '10.0.0.0/8', 1 ], + [ 'dead:beef::/60', 'dead:beef::/40', 1 ], + [ '10.0.0.0/24', '10.0.0.0/8', 1 ], + [ '255.255.255.255/32', '0.0.0.0/0', 1 ], + [ 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff', '::/0', 1 ], + [ '142.52.5.87', '142.52.2.88', 1 ], + [ '10.0.0.0/24', '10.0.0.0/24', 0 ], + [ 'default', 'default', 0 ], + [ 'broadcast', 'broadcast', 0], + [ 'loopback', 'loopback', 0], + ); + +}; + +use Test::More tests => @gt + @ngt + (2 * @cmp); + +for my $a (@gt) { + $a_ip = new NetAddr::IP::Lite $a->[0]; + $b_ip = new NetAddr::IP::Lite $a->[1]; + + ok($a_ip > $b_ip, "$a_ip > $b_ip"); +} + +for my $a (@ngt) { + $a_ip = new NetAddr::IP::Lite $a->[0]; + $b_ip = new NetAddr::IP::Lite $a->[1]; + + ok(!($a_ip > $b_ip), "$a_ip !> $b_ip"); +} + +for $a (@cmp) { + $a_ip = new NetAddr::IP::Lite $a->[0]; + $b_ip = new NetAddr::IP::Lite $a->[1]; + + is($a_ip <=> $b_ip, $a->[2], "$a_ip <=> $b_ip is $a->[2]"); + is($a_ip cmp $b_ip, $a->[2], "$a_ip cmp $b_ip is $a->[2]"); +} + diff --git a/Lite/t/rfc_1918.t b/Lite/t/rfc_1918.t new file mode 100644 index 0000000..850de21 --- /dev/null +++ b/Lite/t/rfc_1918.t @@ -0,0 +1,38 @@ + +#use diagnostics; +use NetAddr::IP::Lite; + +$| = 1; + +print "1..12\n"; + +my $test = 1; +sub ok() { + print 'ok ',$test++,"\n"; +} + +my @ips = qw( + 9.255.255.255 0 + 10.0.0.0 1 + 10.255.255.255 1 + 11.0.0.0 0 + 172.15.255.255 0 + 172.16.0.0 1 + 172.31.255.255 1 + 172.32.0.0 0 + 192.167.255.255 0 + 192.168.0.0 1 + 192.168.255.255 1 + 192.169.0.0 0 +); + + +for (my $i=0;$i<=$#ips;$i+=2) { + my $ip = new NetAddr::IP::Lite($ips[$i]); + my $got = $ip->is_rfc1918(); + my $exp = $ips[$i+1]; + print $ip," got: $got, exp: $exp\nnot " + unless $got == $exp; + &ok; +} + diff --git a/Lite/t/v4-aton.t b/Lite/t/v4-aton.t new file mode 100644 index 0000000..3ffe37b --- /dev/null +++ b/Lite/t/v4-aton.t @@ -0,0 +1,59 @@ +use Test::More tests => 19; + +my @addr = ( + [ 'localhost', '127.0.0.1' ], + [ 'broadcast', '255.255.255.255' ], + [ '254.254.0.1', '254.254.0.1' ], + [ 'default', '0.0.0.0' ], + [ '10.0.0.1', '10.0.0.1' ], + +); +my %addr = ( + localhost => pack('N',0x7f000001), + broadcast => pack('N',0xffffffff), + '254.254.0.1' => pack('N',0xfefe0001), + default => pack('N',0), + '10.0.0.1' => pack('N',0x0a000001), + '127.0.0.1' => pack('N',0x7f000001), + '255.255.255.255' => pack('N',0xffffffff), + '0.0.0.0' => pack('N',0), +); + +# local inet_aton, don't use perl's Socket + +sub l_inet_aton { + my $rv = (exists $addr{$_[0]}) ? $addr{$_[0]} : undef; +} + + +# Verify that Accept_Binary_IP works... + +my $x; + +SKIP: +{ + skip "Failed to load NetAddr::IP::Lite", 17 + unless use_ok('NetAddr::IP::Lite'); + + ok(! defined NetAddr::IP::Lite->new("\1\1\1\1"), + "binary unrecognized by default ". ($x ? $x->addr :'')); + + # This mimicks the actual use with :aton + NetAddr::IP::Lite::import(':aton'); + + ok(defined ($x = NetAddr::IP::Lite->new("\1\1\1\1")), + "...but can be recognized ". $x->addr); + + ok(!defined ($x = NetAddr::IP::Lite->new('bad rfc-952 characters')), + "bad rfc-952 characters ". ($x ? $x->addr :'')); + + is(NetAddr::IP::Lite->new($_->[0])->aton, l_inet_aton($_->[1]), "->aton($_->[0])") + for @addr; + + ok(defined NetAddr::IP::Lite->new(l_inet_aton($_->[1])), "->new aton($_->[1])") + for @addr; + + is(NetAddr::IP::Lite->new(l_inet_aton($_->[1]))->addr, $_->[1], + "->new aton($_->[1])") + for @addr; +}; diff --git a/Lite/t/v4-badnm.t b/Lite/t/v4-badnm.t new file mode 100644 index 0000000..4d6b264 --- /dev/null +++ b/Lite/t/v4-badnm.t @@ -0,0 +1,42 @@ +# I know this does not look like -*- perl -*-, but I swear it is... + +use strict; +use Test::More; + +$| = 1; + +my @badnets = ( + '10.10.10.10/255.255.0.255', + '10.10.10.10/255.0.255.255', + '10.10.10.10/0.255.255.255', + '10.10.10.10/128.255.0.255', + '10.10.10.10/255.128.0.255', + '10.10.10.10/255.255.255.129', + '10.10.10.10/255.255.129.0', + '10.10.10.10/255.255.255.130', + '10.10.10.10/255.255.130.0', + '10.10.10.10/255.0.0.1', + '10.10.10.10/255.129.0.1', + '10.10.10.10/0.255.0.255', + '58.26.0.0-58.27.127.255', # Taken from APNIC's WHOIS case +); + +my @goodnets = (); + +push @goodnets, "10.0.0.1/$_" for (0 .. 32); +push @goodnets, "10.0.0.1/255.255.255.255"; + +plan tests => 1 + @badnets + @goodnets; + +die "# Cannot continue without NetAddr::IP::Lite\n" + unless use_ok('NetAddr::IP::Lite'); + +my $count = 1; + +ok(! defined NetAddr::IP::Lite->new($_), "new $_ should fail") + for @badnets; + +ok(defined NetAddr::IP::Lite->new($_), "new $_ should work") + for @goodnets; + + diff --git a/Lite/t/v4-base.t b/Lite/t/v4-base.t new file mode 100644 index 0000000..b8e81bc --- /dev/null +++ b/Lite/t/v4-base.t @@ -0,0 +1,19 @@ +use NetAddr::IP::Lite; + +my @addr = (qw( 127.0.0.1 10.0.0.1 )); +my @mask = (qw( 255.0.0.0 255.255.0.0 255.255.255.0 255.255.255.255 )); + +$| = 1; +print "1..", (2 * scalar @addr * scalar @mask), "\n"; + +my $count = 1; + +for my $a (@addr) { + for my $m (@mask) { + my $ip = new NetAddr::IP::Lite $a, $m; + print (($ip->addr ne $a ? 'not ' : ''), "ok ", $count++, "\n"); + print (($ip->mask ne $m ? 'not ' : ''), "ok ", $count++, "\n"); + } +} + + diff --git a/Lite/t/v4-basem.t b/Lite/t/v4-basem.t new file mode 100644 index 0000000..461a371 --- /dev/null +++ b/Lite/t/v4-basem.t @@ -0,0 +1,24 @@ +use NetAddr::IP::Lite; + +my $nets = { + '10.0.0.16' => [ 24, '10.0.0.255', '10.0.0.0' ], + '127.0.0.1' => [ 8, '127.255.255.255', '127.0.0.0' ], + '192.168.0.10' => [ 17, '192.168.127.255', '192.168.0.0' ], +}; + +$| = 1; +print "1..", (2 * scalar keys %$nets), "\n"; + +my $count = 1; + +for my $a (keys %$nets) { + my $ip = new NetAddr::IP::Lite $a, $nets->{$a}->[0]; + print '', (($ip->broadcast->addr ne $nets->{$a}->[1] ? + 'not ' : ''), + "ok ", $count++, "\n"); + print '', (($ip->network->addr ne $nets->{$a}->[2] ? + 'not ' : ''), + "ok ", $count++, "\n"); +} + + diff --git a/Lite/t/v4-cidr.t b/Lite/t/v4-cidr.t new file mode 100644 index 0000000..b96f38f --- /dev/null +++ b/Lite/t/v4-cidr.t @@ -0,0 +1,28 @@ +use NetAddr::IP::Lite; + +$| = 1; + +my @addr = (qw( + 0.0.0.0/0 + 1.0.0.0/1 + 2.0.0.0/2 + 10.0.0.0/8 + 10.0.120.0/24 + 161.196.66.0/25 + 255.255.255.255/32 + )); + +print '1..', scalar @addr, "\n"; + +my $count = 1; + +for my $a (@addr) { + my $ip = new NetAddr::IP::Lite $a; + if ($ip->cidr eq $a) { + print "ok ", $count ++, "\n"; + } + else { + print "not ok ", $count ++, "\n"; + print "$a -> ", $ip->cidr, " [", $ip->mask, "]\n"; + } +} diff --git a/Lite/t/v4-cnew.t b/Lite/t/v4-cnew.t new file mode 100644 index 0000000..9cb2d7c --- /dev/null +++ b/Lite/t/v4-cnew.t @@ -0,0 +1,30 @@ +use NetAddr::IP::Lite; + +my @subnets = ( + [ '127.1', '127.0.0.1/32' ], + [ '127.1/16', '127.1.0.0/16' ], + [ '10.10.10', '10.10.0.10/32' ], + [ '10.10.10/24', '10.10.10.0/24' ], +# include test for cisco syntax using space instead of '/' + [ '127.1 16', '127.1.0.0/16' ], + [ '10.10.10 24', '10.10.10.0/24' ], + [ '10.10.10 255.255.255.0', '10.10.10.0/24' ], + ); + +$| = 1; + +print '1..', (scalar @subnets) , "\n"; + +my $count = 1; + +for my $n (@subnets) { + my $ip = new NetAddr::IP::Lite $n->[0]; + if ($ip eq $n->[1]) { + print "ok $count\n"; + } + else { + print "not ok $count\n"; + } + + ++ $count; +} diff --git a/Lite/t/v4-contains.t b/Lite/t/v4-contains.t new file mode 100644 index 0000000..62234b7 --- /dev/null +++ b/Lite/t/v4-contains.t @@ -0,0 +1,60 @@ +use NetAddr::IP::Lite; + +my @yes_pairs = ( + [ [ '127.0.0.0', '255.0.0.0' ], + [ '127.0.0.1', '255.255.255.255'] ], + [ [ '10.0.0.0', '255.255.255.0' ], + [ '10.0.0.128', '255.255.255.128' ] ], + [ [ '10.0.0.0', '255.0.0.0' ], + [ '10.0.0.0', '255.0.0.0' ]], + [ [ '10.0.0.0', '255.0.0.0' ], + [ '10.0.0.1', '255.0.0.0' ]], + [ [ '10.0.0.0', '255.255.255.254' ], + [ '10.0.0.1', '255.255.255.254' ]], + [ [ '10.0.0.0', '255.255.255.254' ], + [ '10.0.0.1', '255.255.255.255' ]], + [ [ '10.0.0.1', '255.0.0.0' ], + [ '10.0.0.1', '255.255.255.255' ]], + [ [ 'default', 'default' ], + [ '10.0.0.1', '255.255.255.254' ]], + [ [ 'default', 'default' ], + [ 'broadcast', undef ]], + [ [ 'loopback', '255.0.0.0' ], + [ '127.0.0.0', '255.0.0.0' ] ], + ); + +my @no_pairs = ( + [ [ '127.0.0.1', '255.255.255.255' ], + [ '127.0.0.0', '255.0.0.0' ] ], + [ [ '10.0.0.0', '255.0.0.0' ], + [ '11.0.0.0', '255.0.0.0' ] ], + [ [ '10.0.1.0', '255.255.255.0' ], + [ '10.0.2.0', '255.255.255.0' ] ], + [ [ '10.0.0.1', '255.255.255.254' ], + [ 'default', '0' ] ], + ); + +$| = 1; +print "1..", 2 * (scalar @yes_pairs + scalar @no_pairs), "\n"; + +my $count = 1; + +for my $p (@yes_pairs) { + my $ip_a = new NetAddr::IP::Lite $p->[0]->[0], $p->[0]->[1]; + my $ip_b = new NetAddr::IP::Lite $p->[1]->[0], $p->[1]->[1]; + print (($ip_a->contains($ip_b) ? '' : 'not '), 'ok ', $count++, "\n"); + print (($ip_b->within($ip_a) ? '' : 'not '), 'ok ', $count++, "\n"); + +# print "a = ", $ip_a->addr, "/", $ip_a->mask, "\n"; +# print "b = ", $ip_b->addr, "/", $ip_b->mask, "\n"; + +} + +for my $p (@no_pairs) { + my $ip_a = new NetAddr::IP::Lite $p->[0]->[0], $p->[0]->[1]; + my $ip_b = new NetAddr::IP::Lite $p->[1]->[0], $p->[1]->[1]; + print (($ip_a->contains($ip_b) ? 'not ' : ''), 'ok ', $count++, "\n"); + print (($ip_b->within($ip_a) ? 'not ' : ''), 'ok ', $count++, "\n"); +} + + diff --git a/Lite/t/v4-last.t b/Lite/t/v4-last.t new file mode 100644 index 0000000..9e374f9 --- /dev/null +++ b/Lite/t/v4-last.t @@ -0,0 +1,32 @@ +use NetAddr::IP::Lite; + +my %w = ('default' => [ '255.255.255.254', '0.0.0.0' ], + 'loopback' => [ '127.255.255.254', '255.0.0.0' ], + '127.0.0.1/8' => [ '127.255.255.254', '255.0.0.0' ], + '10.' => [ '10.255.255.254', '255.0.0.0' ], + '10.10.10/24' => [ '10.10.10.254', '255.255.255.0' ], + ); + +$| = 1; + +print '1..', (2 * scalar keys %w), "\n"; + +my $count = 1; + +for my $a (keys %w) { + my $ip = NetAddr::IP::Lite->new($a)->last; + + if ($ip->addr eq $w{$a}->[0]) { + print "ok ", $count++, "\n"; + } + else { + print "not ok ", $count++, "\n"; + } + + if ($ip->mask eq $w{$a}->[1]) { + print "ok ", $count++, "\n"; + } + else { + print "not ok ", $count++, "\n"; + } +} diff --git a/Lite/t/v4-new-first.t b/Lite/t/v4-new-first.t new file mode 100644 index 0000000..31d1a57 --- /dev/null +++ b/Lite/t/v4-new-first.t @@ -0,0 +1,30 @@ +use NetAddr::IP::Lite; + +my $nets = { + '10.0.0.16' => [ 24, '10.0.0.1', '10.0.0.254', '10.0.0.11'], + '10.0.0.5' => [ 30, '10.0.0.5', '10.0.0.6', 'undef' ], + '10.128.0.1' => [ 8, '10.0.0.1', '10.255.255.254', '10.0.0.11'], + '10.128.0.1' => [ 24, '10.128.0.1', '10.128.0.254', '10.128.0.11'], +}; + +$| = 1; +print "1..", (3 * scalar keys %$nets), "\n"; + +my $count = 1; + +for my $a (keys %$nets) { + my $ip = new NetAddr::IP::Lite $a, $nets->{$a}->[0]; + print '', (($ip->first->addr ne $nets->{$a}->[1] ? + 'not ' : ''), + "ok ", $count++, "\n"); + print '', (($ip->last->addr ne $nets->{$a}->[2] ? + 'not ' : ''), + "ok ", $count++, "\n"); + + my $new = $ip->nth(10); + print '', (((defined $new ? $new->addr : 'undef') ne $nets->{$a}->[3] ? + 'not ' : ''), + "ok ", $count++, "\n"); +} + + diff --git a/Lite/t/v4-new.t b/Lite/t/v4-new.t new file mode 100644 index 0000000..dd952b9 --- /dev/null +++ b/Lite/t/v4-new.t @@ -0,0 +1,67 @@ +use NetAddr::IP::Lite; + +use Test::More; + +my $binword; +{ + local $SIG{__WARN__} = sub {}; + $binword = eval "0b11111111111111110000000000000000"; +} +if ($@) { + $binword = 0xffff0000; + print STDERR "\t\tskipped! 0b11111111111111110000000000000000\n\t\tbinary bit strings unsupported in Perl version $]\n"; +} + +@a = ( + [ 'localhost', '127.0.0.1' ], + [ 0x01010101, '1.1.1.1' ], + [ 1, '1.0.0.0' ], # Because it will have a mask. 0.0.0.1 ow + [ 'default', '0.0.0.0' ], + [ 'any', '0.0.0.0' ], + [-809041407, '207.199.2.1'], + [3485925889, '207.199.2.1'], +); + +@m = ( + [ 0, '0.0.0.0' ], + [ 1, '128.0.0.0' ], + [ 2, '192.0.0.0' ], + [ 4, '240.0.0.0' ], + [ 8, '255.0.0.0' ], + [ 16, '255.255.0.0' ], + [ 17, '255.255.128.0' ], + [ 24, '255.255.255.0' ], + [ 'default', '0.0.0.0' ], + [ 32, '255.255.255.255' ], + [ 'host', '255.255.255.255' ], + [ 0xffffff00, '255.255.255.0' ], + [ '255.255.255.240', '255.255.255.240' ], + [ '255.255.128.0', '255.255.128.0' ], + [ $binword, '255.255.0.0' ], +); + +plan tests => (4 * scalar @a * scalar @m) + 4; + +foreach my $invalid (qw( + 256.1.1.1 + 256.256.1.1 + 256.256.256.1 + 256.256.256.256 +)) { + ok (! defined NetAddr::IP::Lite->new($invalid), "Invalid IP $invalid returns undef"); +} + +for my $a (@a) { + for my $m (@m) { + my $ip = new NetAddr::IP::Lite $a->[0], $m->[0]; + SKIP: + { + skip "Failed to make an object for $a->[0]/$m->[0]", 4 + unless defined $ip; + is($ip->addr, $a->[1], "$a->[0] / $m->[0] is $a->[1]"); + is($ip->mask, $m->[1], "$a->[0] / $m->[0] is $m->[1]"); + is($ip->bits, 32, "$a->[0] / $m->[0] is 32 bits wide"); + is($ip->version, 4, "$a->[0] / $m->[0] is version 4"); + }; + } +} diff --git a/Lite/t/v4-new_from_aton.t b/Lite/t/v4-new_from_aton.t new file mode 100644 index 0000000..2a26c36 --- /dev/null +++ b/Lite/t/v4-new_from_aton.t @@ -0,0 +1,27 @@ +use NetAddr::IP::Util qw( + inet_aton + ipv6_n2x +); +use NetAddr::IP::Lite; +use Test::More; +#use diagnostics; + +plan tests => 12 + 3; + +ok(! defined NetAddr::IP::Lite->new_from_aton(''), "blank netaddr returns undef"); +ok(! defined NetAddr::IP::Lite->new_from_aton(undef), "undefined netaddr returns undef"); +ok(! defined NetAddr::IP::Lite->new_from_aton('1.2.3.4'), "Dot Quad IP returns undef"); + +foreach (qw( + 0.0.0.0 + 127.0.0.1 + 255.255.255.255 +)) { + my $naddr = inet_aton($_); + my $ip = new_from_aton NetAddr::IP::Lite($naddr); + ok(defined $ip, "$_ is defined"); + ok($ip->bits == 32, "$_ is 32 bits wide"); + ok($ip->mask eq '255.255.255.255', "mask is all ones"); + ok($ip->version == 4, "version is IPv4"); +} + diff --git a/Lite/t/v4-no_octal.t b/Lite/t/v4-no_octal.t new file mode 100644 index 0000000..a56706f --- /dev/null +++ b/Lite/t/v4-no_octal.t @@ -0,0 +1,50 @@ +use NetAddr::IP::Lite; +*_no_octal = \&NetAddr::IP::Lite::_no_octal; + +use Test::More; + +my @ranges = ( + [ '10.0.0.0/8', '10.0.0.0', '10.255.255.255' ], + [ '192.68.0.0/16', '192.068.0.0', '192.068.255.255' ], + ); + +my @weird = ( + [ '128.111.12.0', '128.111.12.129' ], + ); + +plan tests => 6 * @ranges + 2 * @weird + 28; + +for my $r (@ranges) { + my $r1 = new_no NetAddr::IP::Lite $r->[1] . '-' . $r->[2]; + isa_ok($r1, 'NetAddr::IP::Lite'); + is($r1, $r->[0], "Correct interpretation (with space)"); + + $r1 = new_no NetAddr::IP::Lite $r->[1] . ' - ' . $r->[2]; + isa_ok($r1, 'NetAddr::IP::Lite'); + is($r1, $r->[0], "Correct interpretation (w/o space)"); + + $r1 = new_no NetAddr::IP::Lite $r->[0]; + isa_ok($r1, 'NetAddr::IP::Lite'); + my @rev = (undef,_no_octal($r->[1]),_no_octal($r->[2])); + is($r1->range, $rev[1] . ' - ' . $rev[2], "Correct reverse"); +} + +for my $r (@weird) +{ + my $r1 = new_no NetAddr::IP::Lite $r->[0] . '-' . $r->[1]; + ok(! defined $r1, "Weird range w/o space produces undef"); + $r1 = new_no NetAddr::IP::Lite $r->[0] . ' - ' . $r->[1]; + ok(! defined $r1, "Weird range with space produces undef"); +} + +for my $o (254, 252, 248, 240, 224, 192, 128) +{ + my $r1 = new_no NetAddr::IP::Lite '0.0.0.0 - ' . $o . '.0.0.0'; + ok(! defined $r1, "Weird $o range, first octet"); + $r1 = new_no NetAddr::IP::Lite '0.0.0.0 - 0.' . $o . '.0.0'; + ok(! defined $r1, "Weird $o range, second octet"); + $r1 = new_no NetAddr::IP::Lite '0.0.0.0 - 0.0.' . $o . '.0'; + ok(! defined $r1, "Weird $o range, third octet"); + $r1 = new_no NetAddr::IP::Lite '0.0.0.0 - 0.0.0.' . $o; + ok(! defined $r1, "Weird $o range, fourth octet"); +} diff --git a/Lite/t/v4-num.t b/Lite/t/v4-num.t new file mode 100644 index 0000000..8e766b6 --- /dev/null +++ b/Lite/t/v4-num.t @@ -0,0 +1,37 @@ +use NetAddr::IP::Lite; + +my $nets = { + '10.1.2.3' => [ 32, 0 ], + '10.2.3.4' => [ 31, 1 ], + '10.0.0.16' => [ 24, 255 ], + '10.128.0.1' => [ 8, 2 ** 24 - 1 ], + '10.0.0.5' => [ 30, 3 ], + '0.0.0.0' => [ 0, 2 ** 32 -1 ], +}; + +my $new = 1; # flag for old vs new numeric returns + +$| = 1; + +$test = keys %$nets; +$test *= 2; +print "1..", $test, "\n"; + +$test = 1; +sub tst { + for my $a (keys %$nets) { + my $nc = $nets->{$a}->[1] - $new; # net count + $nc = 1 if $nc < 0; + $nc = 2 if $new && $nets->{$a}->[0] == 31; # special case for /31, /127 + my $ip = new NetAddr::IP::Lite $a, $nets->{$a}->[0]; + print "got: $_, exp: $nc\nnot " + unless ($_ = $ip->num) == $nc; + print "ok ", $test++, "\n"; + } +} + +tst(); + +import NetAddr::IP::Lite qw(:old_nth); +$new = 0; +tst(); diff --git a/Lite/t/v4-numeric.t b/Lite/t/v4-numeric.t new file mode 100644 index 0000000..a2bf009 --- /dev/null +++ b/Lite/t/v4-numeric.t @@ -0,0 +1,36 @@ +use NetAddr::IP::Lite; + +my $nets = { + '10.0.0.0/20' => [ 167772160, 4294963200 ], + '10.0.15.0/24' => [ 167776000, 4294967040 ], + '192.168.0.0/24' => [ 3232235520, 4294967040], + 'broadcast' => [ 4294967295, 4294967295], + 'default' => [ 0, 0 ], +}; + +$| = 1; +print "1..", 4 * (scalar keys %$nets), "\n"; + +my $count = 1; + +for my $a (keys %$nets) { + my $ip = new NetAddr::IP::Lite $a; + my ($addr, $mask) = $ip->numeric; + + my $nip = new NetAddr::IP::Lite $addr, $mask; + + print '', ($nip ? '' : 'not '), 'ok ', $count++, "\n"; + + print '', ($nip and $nip->cidr eq $ip->cidr) ? '' : 'not ', + 'ok ', $count ++, "\n"; + + print '', (($addr != $nets->{$a}->[0] ? 'not ' : ''), + "ok ", $count++, "\n"); + + print '', (($mask != $nets->{$a}->[1] ? 'not ' : ''), + "ok ", $count++, "\n"); + + +} + + diff --git a/Lite/t/v4-old-first.t b/Lite/t/v4-old-first.t new file mode 100644 index 0000000..89fef7f --- /dev/null +++ b/Lite/t/v4-old-first.t @@ -0,0 +1,30 @@ +use NetAddr::IP::Lite qw(:old_nth); + +my $nets = { + '10.0.0.16' => [ 24, '10.0.0.1', '10.0.0.254', '10.0.0.10'], + '10.0.0.5' => [ 30, '10.0.0.5', '10.0.0.6', 'undef' ], + '10.128.0.1' => [ 8, '10.0.0.1', '10.255.255.254', '10.0.0.10'], + '10.128.0.1' => [ 24, '10.128.0.1', '10.128.0.254', '10.128.0.10'], +}; + +$| = 1; +print "1..", (3 * scalar keys %$nets), "\n"; + +my $count = 1; + +for my $a (keys %$nets) { + my $ip = new NetAddr::IP::Lite $a, $nets->{$a}->[0]; + print '', (($ip->first->addr ne $nets->{$a}->[1] ? + 'not ' : ''), + "ok ", $count++, "\n"); + print '', (($ip->last->addr ne $nets->{$a}->[2] ? + 'not ' : ''), + "ok ", $count++, "\n"); + + my $new = $ip->nth(10); + print '', (((defined $new ? $new->addr : 'undef') ne $nets->{$a}->[3] ? + 'not ' : ''), + "ok ", $count++, "\n"); +} + + diff --git a/Lite/t/v4-range.t b/Lite/t/v4-range.t new file mode 100644 index 0000000..2a96ef5 --- /dev/null +++ b/Lite/t/v4-range.t @@ -0,0 +1,48 @@ +use NetAddr::IP::Lite; + +use Test::More; + +my @ranges = ( + [ '10.0.0.0/8', '10.0.0.0', '10.255.255.255' ], + [ '192.168.0.0/16', '192.168.0.0', '192.168.255.255' ], + ); + +my @weird = ( + [ '128.111.12.0', '128.111.12.129' ], + ); + +plan tests => 6 * @ranges + 2 * @weird + 28; + +for my $r (@ranges) { + my $r1 = new NetAddr::IP::Lite $r->[1] . '-' . $r->[2]; + isa_ok($r1, 'NetAddr::IP::Lite'); + is($r1, $r->[0], "Correct interpretation (with space)"); + + $r1 = new NetAddr::IP::Lite $r->[1] . ' - ' . $r->[2]; + isa_ok($r1, 'NetAddr::IP::Lite'); + is($r1, $r->[0], "Correct interpretation (w/o space)"); + + $r1 = new NetAddr::IP::Lite $r->[0]; + isa_ok($r1, 'NetAddr::IP::Lite'); + is($r1->range, $r->[1] . ' - ' . $r->[2], "Correct reverse"); +} + +for my $r (@weird) +{ + my $r1 = new NetAddr::IP::Lite $r->[0] . '-' . $r->[1]; + ok(! defined $r1, "Weird range w/o space produces undef"); + $r1 = new NetAddr::IP::Lite $r->[0] . ' - ' . $r->[1]; + ok(! defined $r1, "Weird range with space produces undef"); +} + +for my $o (254, 252, 248, 240, 224, 192, 128) +{ + my $r1 = new NetAddr::IP::Lite '0.0.0.0 - ' . $o . '.0.0.0'; + ok(! defined $r1, "Weird $o range, first octet"); + $r1 = new NetAddr::IP::Lite '0.0.0.0 - 0.' . $o . '.0.0'; + ok(! defined $r1, "Weird $o range, second octet"); + $r1 = new NetAddr::IP::Lite '0.0.0.0 - 0.0.' . $o . '.0'; + ok(! defined $r1, "Weird $o range, third octet"); + $r1 = new NetAddr::IP::Lite '0.0.0.0 - 0.0.0.' . $o; + ok(! defined $r1, "Weird $o range, fourth octet"); +} diff --git a/Lite/t/v4-snew.t b/Lite/t/v4-snew.t new file mode 100644 index 0000000..596f95d --- /dev/null +++ b/Lite/t/v4-snew.t @@ -0,0 +1,29 @@ +use Test::More; +use NetAddr::IP::Lite; + +my %w = ('broadcast' => [ '255.255.255.255', '255.255.255.255' ], + 'default' => [ '0.0.0.0', '0.0.0.0' ], + 'loopback' => [ '127.0.0.1', '255.0.0.0' ], + '10.' => [ '10.0.0.0', '255.0.0.0' ], + '10/8' => [ '10.0.0.0', '255.0.0.0' ], + '127/8' => [ '127.0.0.0', '255.0.0.0' ], + '11.11.' => [ '11.11.0.0', '255.255.0.0' ], + '12.12.12.' => [ '12.12.12.0', '255.255.255.0' ], + '13.13.13.13' => [ '13.13.13.13', '255.255.255.255' ], + '0-127' => [ '0.0.0.0', '128.0.0.0' ], + '128-255' => [ '128.0.0.0', '128.0.0.0' ], + '0-63' => [ '0.0.0.0', '192.0.0.0' ], + '128-191' => [ '128.0.0.0', '192.0.0.0' ], + '10.128.0-127' => [ '10.128.0.0', '255.255.128.0' ], + '10.10.10/24' => [ '10.10.10.0', '255.255.255.0' ], + '10.10/16' => [ '10.10.0.0', '255.255.0.0' ], + '10.10.10' => [ '10.10.0.10', '255.255.255.255' ], + ); + +plan tests => 2 * scalar keys %w; + +for my $a (keys %w) { + my $ip = new NetAddr::IP::Lite $a; + is($ip->addr, $w{$a}->[0], "Matching ->addr()"); + is($ip->mask, $w{$a}->[1], "Matching ->mask()"); +} diff --git a/Lite/t/v4-wnew.t b/Lite/t/v4-wnew.t new file mode 100644 index 0000000..69e4f77 --- /dev/null +++ b/Lite/t/v4-wnew.t @@ -0,0 +1,23 @@ +use Test::More tests => 12; +use NetAddr::IP::Lite; + +my @good = (qw(default any broadcast loopback)); +my @bad = map { ("$_.neveranydomainlikethis.in-addr.arpa", + "nohostlikethis.${_}.in-addr.arpa") } @good; + +my $bad = scalar @bad; + +diag <new('not.defined.in-addr.arpa'); + ok(!defined NetAddr::IP::Lite->new($_), "not defined ->new($_)") + for @bad; + ok(defined NetAddr::IP::Lite->new($_), "defined ->new($_)") + for @good; +}; diff --git a/Lite/t/v4_new_cis.t b/Lite/t/v4_new_cis.t new file mode 100644 index 0000000..f9c3788 --- /dev/null +++ b/Lite/t/v4_new_cis.t @@ -0,0 +1,68 @@ +#use diagnostics; +use NetAddr::IP::Lite; + +use Test::More; + +my $binword; +{ + local $SIG{__WARN__} = sub {}; + $binword = eval "0b11111111111111110000000000000000"; +} +if ($@) { + $binword = 0xffff0000; + print STDERR "\t\tskipped! 0b11111111111111110000000000000000\n\t\tbinary bit strings unsupported in Perl version $]\n"; +} + +@a = ( + [ 'localhost', '127.0.0.1' ], + [ 0x01010101, '1.1.1.1' ], + [ 1, '1.0.0.0' ], # Because it will have a mask. 0.0.0.1 ow + [ 'default', '0.0.0.0' ], + [ 'any', '0.0.0.0' ], + [-809041407, '207.199.2.1'], + [3485925889, '207.199.2.1'], +); + +@m = ( + [ 0, '0.0.0.0' ], + [ 1, '128.0.0.0' ], + [ 2, '192.0.0.0' ], + [ 4, '240.0.0.0' ], + [ 8, '255.0.0.0' ], + [ 16, '255.255.0.0' ], + [ 17, '255.255.128.0' ], + [ 24, '255.255.255.0' ], + [ 'default', '0.0.0.0' ], + [ 32, '255.255.255.255' ], + [ 'host', '255.255.255.255' ], + [ 0xffffff00, '255.255.255.0' ], + [ '255.255.255.240', '255.255.255.240' ], + [ '255.255.128.0', '255.255.128.0' ], + [ $binword, '255.255.0.0' ], +); + +plan tests => (4 * scalar @a * scalar @m) + 4; + +foreach my $invalid (qw( + 256.1.1.1 + 256.256.1.1 + 256.256.256.1 + 256.256.256.256 +)) { + ok (! defined NetAddr::IP::Lite->new($invalid), "Invalid IP $invalid returns undef"); +} + +for my $a (@a) { + for my $m (@m) { + my $ip = new_cis NetAddr::IP::Lite "$a->[0] $m->[0]"; + SKIP: + { + skip "Failed to make an object for $a->[0]/$m->[0]", 4 + unless defined $ip; + is($ip->addr, $a->[1], "$a->[0] / $m->[0] is $a->[1]"); + is($ip->mask, $m->[1], "$a->[0] / $m->[0] is $m->[1]"); + is($ip->bits, 32, "$a->[0] / $m->[0] is 32 bits wide"); + is($ip->version, 4, "$a->[0] / $m->[0] is version 4"); + }; + } +} diff --git a/Lite/t/v6-cnew-uri.t b/Lite/t/v6-cnew-uri.t new file mode 100644 index 0000000..7e129f6 --- /dev/null +++ b/Lite/t/v6-cnew-uri.t @@ -0,0 +1,23 @@ +use NetAddr::IP::Lite; + +my @subnets = ( + [ '[dead:beef:1234::/16]', 'DEAD:BEEF:1234:0:0:0:0:0/16' ], + [ '[::1234:BEEF:DEAD/24]', '0:0:0:0:0:1234:BEEF:DEAD/24' ], + ); +$| = 1; + +print '1..', (scalar @subnets) , "\n"; + +my $count = 1; + +for my $n (@subnets) { + my $ip = new NetAddr::IP::Lite $n->[0]; + if ($ip eq $n->[1]) { + print "ok $count\n"; + } + else { + print $ip, "\nnot ok $count\n"; + } + + ++ $count; +} diff --git a/Lite/t/v6-cnew.t b/Lite/t/v6-cnew.t new file mode 100644 index 0000000..9becdab --- /dev/null +++ b/Lite/t/v6-cnew.t @@ -0,0 +1,27 @@ +use NetAddr::IP::Lite; + +my @subnets = ( + [ 'dead:beef:1234::/16', 'DEAD:BEEF:1234:0:0:0:0:0/16' ], + [ '::1234:BEEF:DEAD/24', '0:0:0:0:0:1234:BEEF:DEAD/24' ], +# include test for cisco syntax using space instead of '/' + [ 'dead:beef:1234:: 16', 'DEAD:BEEF:1234:0:0:0:0:0/16' ], + [ '::1234:BEEF:DEAD 24', '0:0:0:0:0:1234:BEEF:DEAD/24' ], + [ '::1234:BEEF:DEAD FFFF:FF00::', '0:0:0:0:0:1234:BEEF:DEAD/24' ], + ); +$| = 1; + +print '1..', (scalar @subnets) , "\n"; + +my $count = 1; + +for my $n (@subnets) { + my $ip = new NetAddr::IP::Lite $n->[0]; + if ($ip eq $n->[1]) { + print "ok $count\n"; + } + else { + print $ip, "\nnot ok $count\n"; + } + + ++ $count; +} diff --git a/Lite/t/v6-contains.t b/Lite/t/v6-contains.t new file mode 100644 index 0000000..82becc0 --- /dev/null +++ b/Lite/t/v6-contains.t @@ -0,0 +1,51 @@ +use NetAddr::IP::Lite; +use Test::More; + +my @yes_pairs = + ( + [ '::/0', '2001:620:0:4:a00:20ff:fe9c:7e4a' ], + [ '3ffe:2000:0:4::/64', '3ffe:2000:0:4:a00:20ff:fe9c:7e4a' ], + [ '3ffe:2000:0:4::/64', '3ffe:2000:0:4:a00:20ff:fe9c:7e4a/65' ], + [ '2001:620:0:4::/64', '2001:620:0:4:a00:20ff:fe9c:7e4a' ], + [ '2001:620:0:4::/64', '2001:620:0:4:a00:20ff:fe9c:7e4a/65' ], + [ '2001:620:0:4::/64', '2001:620:0:4::1' ], + [ '2001:620:0:4::/64', '2001:620:0:4:0:0:0:1' ], + [ 'deaf:beef::/32', 'deaf:beef::1' ], + [ 'deaf:beef::/32', 'deaf:beef::1:1' ], + [ 'deaf:beef::/32', 'deaf:beef::1:0:1' ], + [ 'deaf:beef::/32', 'deaf:beef::1:0:0:1' ], + [ 'deaf:beef::/32', 'deaf:beef::1:0:0:0:1' ], + ); + +my @no_pairs = + ( + [ '3ffe:2000:0:4::/64', '3ffe:2000:0:4:a00:20ff:fe9c:7e4a/63' ], + [ '2001:620:0:4::/64', '2001:620:0:4:a00:20ff:fe9c:7e4a/63' ], + [ 'deaf:beef::/32', 'dead:cafe::1' ], + [ 'deaf:beef::/32', 'dead:cafe::1:1' ], + [ 'deaf:beef::/32', 'dead:cafe::1:0:1' ], + [ 'deaf:beef::/32', 'dead:cafe::1:0:0:1' ], + [ 'deaf:beef::/32', 'dead:cafe::1:0:0:0:1' ], + ); + +my $tests = 6 * @yes_pairs + 1; +plan tests => $tests; + +ok(NetAddr::IP::Lite->new('::')->contains(NetAddr::IP::Lite->new('::')), + ":: contains itself"); + +for my $p (@yes_pairs) +{ + my $a = new NetAddr::IP::Lite $p->[0]; + my $b = new NetAddr::IP::Lite $p->[1]; + + isa_ok($a, 'NetAddr::IP::Lite', "$p->[0]"); + isa_ok($b, 'NetAddr::IP::Lite', "$p->[1]"); + + SKIP: { + ok($a->contains($b), "->contains $p->[0], $p->[1] is true"); + ok($b->within($a), "->within $p->[1], $p->[0] is true"); + ok(!$b->contains($a), "->contains $p->[1], $p->[0] is false"); + ok(!$a->within($b), "->within $p->[0], $p->[1] is false"); + } +} diff --git a/Lite/t/v6-inc.t b/Lite/t/v6-inc.t new file mode 100644 index 0000000..3a4bdcd --- /dev/null +++ b/Lite/t/v6-inc.t @@ -0,0 +1,38 @@ +use Test::More; +use NetAddr::IP::Lite; + +# Test ++ in IPv6 addresses (Bug rt.cpan.org #7070 by a guest) + +@ip = (NetAddr::IP::Lite->new('2001:468:ff:fffe::2/64'), + NetAddr::IP::Lite->new('2001:468:ff:fffe::2/64'), + NetAddr::IP::Lite->new('2001:468:ff:fffe::2/64')); + +$ip[1] ++; +$ip[2] ++; $ip[2] ++; + +plan tests => 11; + +# Test correct v6 creation +isa_ok($_, 'NetAddr::IP::Lite') for @ip; + +# Test that we did actually do something +diag "$ip[0] -- $ip[1]" + unless ok($ip[0] != $ip[1], "Auto incremented once differ"); +diag "$ip[0] -- $ip[2]" + unless ok($ip[0] != $ip[2], "Auto incremented twice differ"); +diag "$ip[1] -- $ip[2]" + unless ok($ip[1] != $ip[2], "Auto incremented two times differ"); + +# Test that what we did is correct +is($ip[1], $ip[0] + 1, "Test of first auto-increment"); +is($ip[2], $ip[0] + 2, "Test of second auto-increment"); + +# Now test auto-decrement + +$ip[1] --; +$ip[2] --; $ip[2] --; + +is($ip[0], $ip[1], "Decrement of decrement once is ok"); +is($ip[0], $ip[2], "Decrement of decrement twice is ok"); +is($ip[1], $ip[2], "Third case"); + diff --git a/Lite/t/v6-new-base-uri.t b/Lite/t/v6-new-base-uri.t new file mode 100644 index 0000000..3d97834 --- /dev/null +++ b/Lite/t/v6-new-base-uri.t @@ -0,0 +1,70 @@ +# This -*- perl -*- code excercises the basic v6 functionality + +sub mypass() {1} +sub myfail() {0} + +@addr = + ( + ['[::]', 3, '0:0:0:0:0:0:0:0/128',myfail], + ['[::1]', 3, '0:0:0:0:0:0:0:1/128',myfail], + ['[F34::123/40]', 2, 'F34:0:0:0:0:0:0:3/40',mypass], + ['[DEAD:BEEF::1/40]', 2, 'DEAD:BEEF:0:0:0:0:0:3/40',mypass], + ['[1000::2/40]', 0, '1000:0:0:0:0:0:0:1/40',mypass], + ['[1000::2000/40]', 0, '1000:0:0:0:0:0:0:1/40',mypass], + ['[DEAD::CAFE/40]', 0, 'DEAD:0:0:0:0:0:0:1/40',mypass], + ['[DEAD:BEEF::1/40]', 3, 'DEAD:BEEF:0:0:0:0:0:4/40',mypass], + ['[DEAD:BEEF::1/40]', 4, 'DEAD:BEEF:0:0:0:0:0:5/40',mypass], + ['[DEAD:BEEF::1/40]', 5, 'DEAD:BEEF:0:0:0:0:0:6/40',mypass], + ['[DEAD:BEEF::1/40]', 6, 'DEAD:BEEF:0:0:0:0:0:7/40',mypass], + ['[DEAD:BEEF::1/40]', 7, 'DEAD:BEEF:0:0:0:0:0:8/40',mypass], + ['[DEAD:BEEF::1/40]', 8, 'DEAD:BEEF:0:0:0:0:0:9/40',mypass], + ['[DEAD:BEEF::1/40]', 254, 'DEAD:BEEF:0:0:0:0:0:FF/40',mypass], + ['[DEAD:BEEF::1/40]', 255, 'DEAD:BEEF:0:0:0:0:0:100/40',mypass], + ['[DEAD:BEEF::1/40]', 256, 'DEAD:BEEF:0:0:0:0:0:101/40',mypass], + ['[DEAD:BEEF::1/40]', 65535, 'DEAD:BEEF:0:0:0:0:1:0/40',mypass], + ['[DEAD:BEEF::1/40]', 65536, 'DEAD:BEEF:0:0:0:0:1:1/40',mypass], + ['[2001:620:0:4::/64]', 0, '2001:620:0:4:0:0:0:1/64',mypass], + ['[3FFE:2000:0:4::/64]', 0, '3FFE:2000:0:4:0:0:0:1/64',mypass], + ['[2001:620:600::1]', 0, '2001:620:600:0:0:0:0:1/128',mypass], + ['[2001:620:600:0:1::1]', 0,'2001:620:600:0:1:0:0:1/128',mypass], + ); + +use NetAddr::IP::Lite; +use Test::More; + +my($a, $ip, $test); + +$test = 4 * @addr + 4; +plan tests => $test; + +$test = 1; + +sub tst { + for $a (@addr) { + $ip = new NetAddr::IP::Lite $a->[0]; + $a->[0] =~ s,/\d+,,; + isa_ok($ip, 'NetAddr::IP::Lite', "$a->[0] "); +# requires full NetAddr::IP +# is(uc $ip->short, $a->[0], "short returns $a->[0]"); + is($ip->bits, 128, "bits == 128"); + is($ip->version, 6, "version == 6"); + my $index = $a->[1]; + if ($a->[3]) { + is(uc $ip->nth($index), $a->[2], "nth $a->[0], $index"); + } else { + ok(!$ip->nth($index),"nth $a->[0], undef"); + } + } +} + +tst(); + + +$test = new NetAddr::IP::Lite 'f34::1'; +isa_ok($test, 'NetAddr::IP::Lite'); +ok($test->network->contains($test), "->contains"); + +$test = new NetAddr::IP::Lite 'f35::1/40'; +isa_ok($test, 'NetAddr::IP::Lite'); +ok($test->network->contains($test), "->contains"); + diff --git a/Lite/t/v6-new-base.t b/Lite/t/v6-new-base.t new file mode 100644 index 0000000..9d83fe3 --- /dev/null +++ b/Lite/t/v6-new-base.t @@ -0,0 +1,70 @@ +# This -*- perl -*- code excercises the basic v6 functionality + +sub mypass() {1} +sub myfail() {0} + +@addr = + ( + ['::', 3, '0:0:0:0:0:0:0:0/128',myfail], + ['::1', 3, '0:0:0:0:0:0:0:1/128',myfail], + ['F34::123/40', 2, 'F34:0:0:0:0:0:0:3/40',mypass], + ['DEAD:BEEF::1/40', 2, 'DEAD:BEEF:0:0:0:0:0:3/40',mypass], + ['1000::2/40', 0, '1000:0:0:0:0:0:0:1/40',mypass], + ['1000::2000/40', 0, '1000:0:0:0:0:0:0:1/40',mypass], + ['DEAD::CAFE/40', 0, 'DEAD:0:0:0:0:0:0:1/40',mypass], + ['DEAD:BEEF::1/40', 3, 'DEAD:BEEF:0:0:0:0:0:4/40',mypass], + ['DEAD:BEEF::1/40', 4, 'DEAD:BEEF:0:0:0:0:0:5/40',mypass], + ['DEAD:BEEF::1/40', 5, 'DEAD:BEEF:0:0:0:0:0:6/40',mypass], + ['DEAD:BEEF::1/40', 6, 'DEAD:BEEF:0:0:0:0:0:7/40',mypass], + ['DEAD:BEEF::1/40', 7, 'DEAD:BEEF:0:0:0:0:0:8/40',mypass], + ['DEAD:BEEF::1/40', 8, 'DEAD:BEEF:0:0:0:0:0:9/40',mypass], + ['DEAD:BEEF::1/40', 254, 'DEAD:BEEF:0:0:0:0:0:FF/40',mypass], + ['DEAD:BEEF::1/40', 255, 'DEAD:BEEF:0:0:0:0:0:100/40',mypass], + ['DEAD:BEEF::1/40', 256, 'DEAD:BEEF:0:0:0:0:0:101/40',mypass], + ['DEAD:BEEF::1/40', 65535, 'DEAD:BEEF:0:0:0:0:1:0/40',mypass], + ['DEAD:BEEF::1/40', 65536, 'DEAD:BEEF:0:0:0:0:1:1/40',mypass], + ['2001:620:0:4::/64', 0, '2001:620:0:4:0:0:0:1/64',mypass], + ['3FFE:2000:0:4::/64', 0, '3FFE:2000:0:4:0:0:0:1/64',mypass], + ['2001:620:600::1', 0, '2001:620:600:0:0:0:0:1/128',mypass], + ['2001:620:600:0:1::1', 0,'2001:620:600:0:1:0:0:1/128',mypass], + ); + +use NetAddr::IP::Lite; +use Test::More; + +my($a, $ip, $test); + +$test = 4 * @addr + 4; +plan tests => $test; + +$test = 1; + +sub tst { + for $a (@addr) { + $ip = new NetAddr::IP::Lite $a->[0]; + $a->[0] =~ s,/\d+,,; + isa_ok($ip, 'NetAddr::IP::Lite', "$a->[0] "); +# requires full NetAddr::IP +# is(uc $ip->short, $a->[0], "short returns $a->[0]"); + is($ip->bits, 128, "bits == 128"); + is($ip->version, 6, "version == 6"); + my $index = $a->[1]; + if ($a->[3]) { + is(uc $ip->nth($index), $a->[2], "nth $a->[0], $index"); + } else { + ok(!$ip->nth($index),"nth $a->[0], undef"); + } + } +} + +tst(); + + +$test = new NetAddr::IP::Lite 'f34::1'; +isa_ok($test, 'NetAddr::IP::Lite'); +ok($test->network->contains($test), "->contains"); + +$test = new NetAddr::IP::Lite 'f35::1/40'; +isa_ok($test, 'NetAddr::IP::Lite'); +ok($test->network->contains($test), "->contains"); + diff --git a/Lite/t/v6-new_cis6_base.t b/Lite/t/v6-new_cis6_base.t new file mode 100644 index 0000000..e03fd7b --- /dev/null +++ b/Lite/t/v6-new_cis6_base.t @@ -0,0 +1,69 @@ +# This -*- perl -*- code excercises the basic v6 functionality + +sub mypass() {1} +sub myfail() {0} + +@addr = + ( + ['::', 3, '0:0:0:0:0:0:0:0/128',myfail], + ['::1', 3, '0:0:0:0:0:0:0:1/128',myfail], + ['F34::123 40', 2, 'F34:0:0:0:0:0:0:3/40',mypass], + ['DEAD:BEEF::1 40', 2, 'DEAD:BEEF:0:0:0:0:0:3/40',mypass], + ['1000::2 40', 0, '1000:0:0:0:0:0:0:1/40',mypass], + ['1000::2000 40', 0, '1000:0:0:0:0:0:0:1/40',mypass], + ['DEAD::CAFE 40', 0, 'DEAD:0:0:0:0:0:0:1/40',mypass], + ['DEAD:BEEF::1 40', 3, 'DEAD:BEEF:0:0:0:0:0:4/40',mypass], + ['DEAD:BEEF::1 40', 4, 'DEAD:BEEF:0:0:0:0:0:5/40',mypass], + ['DEAD:BEEF::1 40', 5, 'DEAD:BEEF:0:0:0:0:0:6/40',mypass], + ['DEAD:BEEF::1 40', 6, 'DEAD:BEEF:0:0:0:0:0:7/40',mypass], + ['DEAD:BEEF::1 40', 7, 'DEAD:BEEF:0:0:0:0:0:8/40',mypass], + ['DEAD:BEEF::1 40', 8, 'DEAD:BEEF:0:0:0:0:0:9/40',mypass], + ['DEAD:BEEF::1 40', 254, 'DEAD:BEEF:0:0:0:0:0:FF/40',mypass], + ['DEAD:BEEF::1 40', 255, 'DEAD:BEEF:0:0:0:0:0:100/40',mypass], + ['DEAD:BEEF::1 40', 256, 'DEAD:BEEF:0:0:0:0:0:101/40',mypass], + ['DEAD:BEEF::1 40', 65535, 'DEAD:BEEF:0:0:0:0:1:0/40',mypass], + ['DEAD:BEEF::1 40', 65536, 'DEAD:BEEF:0:0:0:0:1:1/40',mypass], + ['2001:620:0:4::/64', 0, '2001:620:0:4:0:0:0:1/64',mypass], + ['3FFE:2000:0:4::/64', 0, '3FFE:2000:0:4:0:0:0:1/64',mypass], + ['2001:620:600::1', 0, '2001:620:600:0:0:0:0:1/128',mypass], + ['2001:620:600:0:1::1', 0,'2001:620:600:0:1:0:0:1/128',mypass], + ); + +use NetAddr::IP::Lite; +use Test::More; + +my($a, $ip, $test); + +$test = 4 * @addr + 4; +plan tests => $test; + +$test = 1; + +sub tst { + for $a (@addr) { + $ip = new_cis6 NetAddr::IP::Lite $a->[0]; + $a->[0] =~ s,/\d+,,; + isa_ok($ip, 'NetAddr::IP::Lite', "$a->[0] "); +# requires full NetAddr::IP +# is(uc $ip->short, $a->[0], "short returns $a->[0]"); + is($ip->bits, 128, "bits == 128"); + is($ip->version, 6, "version == 6"); + my $index = $a->[1]; + if ($a->[3]) { + is(uc $ip->nth($index), $a->[2], "nth $a->[0], $index"); + } else { + ok(!$ip->nth($index),"nth $a->[0], undef"); + } + } +} + +tst(); + +$test = new_cis6 NetAddr::IP::Lite 'f34::1'; +isa_ok($test, 'NetAddr::IP::Lite'); +ok($test->network->contains($test), "->contains"); + +$test = new_cis6 NetAddr::IP::Lite 'f35::1 40'; +isa_ok($test, 'NetAddr::IP::Lite'); +ok($test->network->contains($test), "->contains"); + diff --git a/Lite/t/v6-new_cis_base.t b/Lite/t/v6-new_cis_base.t new file mode 100644 index 0000000..61adfae --- /dev/null +++ b/Lite/t/v6-new_cis_base.t @@ -0,0 +1,69 @@ +# This -*- perl -*- code excercises the basic v6 functionality + +sub mypass() {1} +sub myfail() {0} + +@addr = + ( + ['::', 3, '0:0:0:0:0:0:0:0/128',myfail], + ['::1', 3, '0:0:0:0:0:0:0:1/128',myfail], + ['F34::123 40', 2, 'F34:0:0:0:0:0:0:3/40',mypass], + ['DEAD:BEEF::1 40', 2, 'DEAD:BEEF:0:0:0:0:0:3/40',mypass], + ['1000::2 40', 0, '1000:0:0:0:0:0:0:1/40',mypass], + ['1000::2000 40', 0, '1000:0:0:0:0:0:0:1/40',mypass], + ['DEAD::CAFE 40', 0, 'DEAD:0:0:0:0:0:0:1/40',mypass], + ['DEAD:BEEF::1 40', 3, 'DEAD:BEEF:0:0:0:0:0:4/40',mypass], + ['DEAD:BEEF::1 40', 4, 'DEAD:BEEF:0:0:0:0:0:5/40',mypass], + ['DEAD:BEEF::1 40', 5, 'DEAD:BEEF:0:0:0:0:0:6/40',mypass], + ['DEAD:BEEF::1 40', 6, 'DEAD:BEEF:0:0:0:0:0:7/40',mypass], + ['DEAD:BEEF::1 40', 7, 'DEAD:BEEF:0:0:0:0:0:8/40',mypass], + ['DEAD:BEEF::1 40', 8, 'DEAD:BEEF:0:0:0:0:0:9/40',mypass], + ['DEAD:BEEF::1 40', 254, 'DEAD:BEEF:0:0:0:0:0:FF/40',mypass], + ['DEAD:BEEF::1 40', 255, 'DEAD:BEEF:0:0:0:0:0:100/40',mypass], + ['DEAD:BEEF::1 40', 256, 'DEAD:BEEF:0:0:0:0:0:101/40',mypass], + ['DEAD:BEEF::1 40', 65535, 'DEAD:BEEF:0:0:0:0:1:0/40',mypass], + ['DEAD:BEEF::1 40', 65536, 'DEAD:BEEF:0:0:0:0:1:1/40',mypass], + ['2001:620:0:4::/64', 0, '2001:620:0:4:0:0:0:1/64',mypass], + ['3FFE:2000:0:4::/64', 0, '3FFE:2000:0:4:0:0:0:1/64',mypass], + ['2001:620:600::1', 0, '2001:620:600:0:0:0:0:1/128',mypass], + ['2001:620:600:0:1::1', 0,'2001:620:600:0:1:0:0:1/128',mypass], + ); + +use NetAddr::IP::Lite; +use Test::More; + +my($a, $ip, $test); + +$test = 4 * @addr + 4; +plan tests => $test; + +$test = 1; + +sub tst { + for $a (@addr) { + $ip = new_cis NetAddr::IP::Lite $a->[0]; + $a->[0] =~ s,/\d+,,; + isa_ok($ip, 'NetAddr::IP::Lite', "$a->[0] "); +# requires full NetAddr::IP +# is(uc $ip->short, $a->[0], "short returns $a->[0]"); + is($ip->bits, 128, "bits == 128"); + is($ip->version, 6, "version == 6"); + my $index = $a->[1]; + if ($a->[3]) { + is(uc $ip->nth($index), $a->[2], "nth $a->[0], $index"); + } else { + ok(!$ip->nth($index),"nth $a->[0], undef"); + } + } +} + +tst(); + +$test = new_cis NetAddr::IP::Lite 'f34::1'; +isa_ok($test, 'NetAddr::IP::Lite'); +ok($test->network->contains($test), "->contains"); + +$test = new_cis NetAddr::IP::Lite 'f35::1 40'; +isa_ok($test, 'NetAddr::IP::Lite'); +ok($test->network->contains($test), "->contains"); + diff --git a/Lite/t/v6-num.t b/Lite/t/v6-num.t new file mode 100644 index 0000000..66297eb --- /dev/null +++ b/Lite/t/v6-num.t @@ -0,0 +1,53 @@ +use NetAddr::IP::Lite; + +my $nets = { + 'F0::' => [ 128, '1' ], + 'F1::' => [ 127, '2' ], + 'F2::' => [ 126, '2' ], + 'F3::' => [ 125, '6' ], + 'F4::' => [ 124, '14' ], + 'F5::' => [ 123, '30' ], + 'F6::' => [ 122, '62' ], + 'F7::' => [ 100, '268435454' ], + 'F8::' => [ 99, '536870910' ], + 'F9::' => [ 98, '1073741822' ], + 'FA::' => [ 97, '2147483646' ], + 'FB::' => [ 96, '4294967294' ], + 'FC::' => [ 95, '8589934590' ], + 'FD::' => [ 94, '17179869182' ], + 'FE::' => [ 93, '34359738366' ], + 'FF::' => [ 92, '68719476734' ], + 'F10::' => [ 64, '18446744073709551614' ], + 'F20::' => [ 32, '79228162514264337593543950334' ], + 'F30::' => [ 16, '5192296858534827628530496329220094' ], + 'F40::' => [ 8, '1329227995784915872903807060280344574' ], + 'F50::' => [ 4, '21267647932558653966460912964485513214' ], + 'F60::' => [ 2, '85070591730234615865843651857942052862' ], + 'F70::' => [ 1, '170141183460469231731687303715884105726' ], + 'F80::' => [ 0, '340282366920938463463374607431768211454' ], + '0.0.0.1' => [ 31, '2' ], + '0.0.0.2' => [ 30, '2' ], + '0.0.0.3' => [ 2, '1073741822' ], + '0.0.0.4' => [ 1, '2147483646' ], + '0.0.0.5' => [ 0, '4294967294' ], + '0.0.0.6' => [ 32, '1' ], +}; + +$| = 1; + +$test = keys %$nets; +print "1..", $test, "\n"; + +$test = 1; +sub tst { + foreach my $a (sort keys %$nets) { + my $nc = $nets->{$a}->[1]; # net count + my $ip = new NetAddr::IP::Lite($a, $nets->{$a}->[0]); + print "/$nets->{$a}->[0] got: $_, exp: $nc\nnot " + unless ($_ = $ip->num) eq $nc; + print "ok ", $test++, "\n"; + } +} + +tst(); + diff --git a/Lite/t/v6-numeric-uri.t b/Lite/t/v6-numeric-uri.t new file mode 100644 index 0000000..bacb68c --- /dev/null +++ b/Lite/t/v6-numeric-uri.t @@ -0,0 +1,91 @@ +use NetAddr::IP::Lite; +use Test::More; + +my @pairs = + ( + [ '[::/0]', '0', '0' ], + [ '[::/128]', '0', '340282366920938463463374607431768211455' ], + [ '[cafe:cafe::/64]', + '269827015721314068804783158349174669312', + '340282366920938463444927863358058659840' ], + [ '[cafe:cafe::1/64]', + '269827015721314068804783158349174669313', + '340282366920938463444927863358058659840' ], + [ '[dead:beef::/100]', + '295990755014133383690938178081940045824', + '340282366920938463463374607431499776000' ], + [ '[dead:beef::1/100]', + '295990755014133383690938178081940045825', + '340282366920938463463374607431499776000' ], + ); + +my @scale = +qw( + 0000:0000:0000:0000:0000:0000:0000:0000 + 0000:0000:0000:0000:0000:0000:0000:0001 + 0000:0000:0000:0000:0000:0000:0000:0010 + 0000:0000:0000:0000:0000:0000:0000:0100 + 0000:0000:0000:0000:0000:0000:0000:1000 + 0000:0000:0000:0000:0000:0000:0001:0000 + 0000:0000:0000:0000:0000:0001:0000:0000 + 0000:0000:0000:0000:0000:0010:0000:0000 + 0000:0000:0000:0000:0000:0100:0000:0000 + 0000:0000:0000:0000:0000:1000:0000:0000 + 0000:0000:0000:0000:0001:0000:0000:0000 + 0000:0000:0000:0001:0000:0000:0000:0000 + 0000:0000:0000:0010:0000:0000:0000:0000 + 0000:0000:0000:0100:0000:0000:0000:0000 + 0000:0000:0000:1000:0000:0000:0000:0000 + 0000:0000:0001:0000:0000:0000:0000:0000 + 0000:0001:0000:0000:0000:0000:0000:0000 + 0000:0010:0000:0000:0000:0000:0000:0000 + 0000:0100:0000:0000:0000:0000:0000:0000 + 0000:1000:0000:0000:0000:0000:0000:0000 + 0001:0000:0000:0000:0000:0000:0000:0000 + 0010:0000:0000:0000:0000:0000:0000:0000 + 0100:0000:0000:0000:0000:0000:0000:0000 + 1000:0000:0000:0000:0000:0000:0000:0000 + ); + +my $tests = 4 * @pairs + @scale ** 2; +plan tests => $tests; + +for my $p (@pairs) +{ + my $a = new NetAddr::IP::Lite $p->[0]; + isa_ok($a, 'NetAddr::IP::Lite', "$p->[0]"); + is($a->numeric, $p->[1], "$p->[0] Scalar numeric ok"); + is(($a->numeric)[0], $p->[1], "$p->[0] Array numeric ok for network"); + is(($a->numeric)[1], $p->[2], "$p->[0] Array numeric ok for mask"); +} + +@ip_scale = map { new NetAddr::IP::Lite $_ } @scale; + +isa_ok($_, 'NetAddr::IP::Lite', $_->addr) for @ip_scale; + +for my $i (0 .. $#ip_scale) +{ + for my $l (0 .. $i - 1) + { + next if $l >= $i; + unless (ok($ip_scale[$i]->numeric > $ip_scale[$l]->numeric, + "[$i, $l] $scale[$i] > $scale[$l]")) + { + diag "assertion [$i]: " . $ip_scale[$i]->numeric . + " > " . $ip_scale[$l]->numeric; + } + } + + next if $i == $#ip_scale; + + for my $l ($i + 1 .. $#ip_scale) + { + next if $l <= $i; + unless (ok($ip_scale[$i]->numeric < $ip_scale[$l]->numeric, + "[$i, $l] $scale[$i] < $scale[$l]")) + { + diag "assertion [$i]: " . $ip_scale[$i]->numeric . + " < " . $ip_scale[$l]->numeric; + } + } +} diff --git a/Lite/t/v6-numeric.t b/Lite/t/v6-numeric.t new file mode 100644 index 0000000..4d68e74 --- /dev/null +++ b/Lite/t/v6-numeric.t @@ -0,0 +1,91 @@ +use NetAddr::IP::Lite; +use Test::More; + +my @pairs = + ( + [ '::/0', '0', '0' ], + [ '::/128', '0', '340282366920938463463374607431768211455' ], + [ 'cafe:cafe::/64', + '269827015721314068804783158349174669312', + '340282366920938463444927863358058659840' ], + [ 'cafe:cafe::1/64', + '269827015721314068804783158349174669313', + '340282366920938463444927863358058659840' ], + [ 'dead:beef::/100', + '295990755014133383690938178081940045824', + '340282366920938463463374607431499776000' ], + [ 'dead:beef::1/100', + '295990755014133383690938178081940045825', + '340282366920938463463374607431499776000' ], + ); + +my @scale = +qw( + 0000:0000:0000:0000:0000:0000:0000:0000 + 0000:0000:0000:0000:0000:0000:0000:0001 + 0000:0000:0000:0000:0000:0000:0000:0010 + 0000:0000:0000:0000:0000:0000:0000:0100 + 0000:0000:0000:0000:0000:0000:0000:1000 + 0000:0000:0000:0000:0000:0000:0001:0000 + 0000:0000:0000:0000:0000:0001:0000:0000 + 0000:0000:0000:0000:0000:0010:0000:0000 + 0000:0000:0000:0000:0000:0100:0000:0000 + 0000:0000:0000:0000:0000:1000:0000:0000 + 0000:0000:0000:0000:0001:0000:0000:0000 + 0000:0000:0000:0001:0000:0000:0000:0000 + 0000:0000:0000:0010:0000:0000:0000:0000 + 0000:0000:0000:0100:0000:0000:0000:0000 + 0000:0000:0000:1000:0000:0000:0000:0000 + 0000:0000:0001:0000:0000:0000:0000:0000 + 0000:0001:0000:0000:0000:0000:0000:0000 + 0000:0010:0000:0000:0000:0000:0000:0000 + 0000:0100:0000:0000:0000:0000:0000:0000 + 0000:1000:0000:0000:0000:0000:0000:0000 + 0001:0000:0000:0000:0000:0000:0000:0000 + 0010:0000:0000:0000:0000:0000:0000:0000 + 0100:0000:0000:0000:0000:0000:0000:0000 + 1000:0000:0000:0000:0000:0000:0000:0000 + ); + +my $tests = 4 * @pairs + @scale ** 2; +plan tests => $tests; + +for my $p (@pairs) +{ + my $a = new NetAddr::IP::Lite $p->[0]; + isa_ok($a, 'NetAddr::IP::Lite', "$p->[0]"); + is($a->numeric, $p->[1], "$p->[0] Scalar numeric ok"); + is(($a->numeric)[0], $p->[1], "$p->[0] Array numeric ok for network"); + is(($a->numeric)[1], $p->[2], "$p->[0] Array numeric ok for mask"); +} + +@ip_scale = map { new NetAddr::IP::Lite $_ } @scale; + +isa_ok($_, 'NetAddr::IP::Lite', $_->addr) for @ip_scale; + +for my $i (0 .. $#ip_scale) +{ + for my $l (0 .. $i - 1) + { + next if $l >= $i; + unless (ok($ip_scale[$i]->numeric > $ip_scale[$l]->numeric, + "[$i, $l] $scale[$i] > $scale[$l]")) + { + diag "assertion [$i]: " . $ip_scale[$i]->numeric . + " > " . $ip_scale[$l]->numeric; + } + } + + next if $i == $#ip_scale; + + for my $l ($i + 1 .. $#ip_scale) + { + next if $l <= $i; + unless (ok($ip_scale[$i]->numeric < $ip_scale[$l]->numeric, + "[$i, $l] $scale[$i] < $scale[$l]")) + { + diag "assertion [$i]: " . $ip_scale[$i]->numeric . + " < " . $ip_scale[$l]->numeric; + } + } +} diff --git a/Lite/t/v6-old-base-uri.t b/Lite/t/v6-old-base-uri.t new file mode 100644 index 0000000..961f15c --- /dev/null +++ b/Lite/t/v6-old-base-uri.t @@ -0,0 +1,70 @@ +# This -*- perl -*- code excercises the basic v6 functionality + +sub mypass() {1} +sub myfail() {0} + +@addr = + ( + ['[::]', 3, '0:0:0:0:0:0:0:0/128',myfail], + ['[::1]', 3, '0:0:0:0:0:0:0:1/128',myfail], + ['[F34::123/40]', 3, 'F34:0:0:0:0:0:0:3/40',mypass], + ['[DEAD:BEEF::1/40]', 3, 'DEAD:BEEF:0:0:0:0:0:3/40',mypass], + ['[1000::2/40]', 1, '1000:0:0:0:0:0:0:1/40',mypass], + ['[1000::2000/40]', 1, '1000:0:0:0:0:0:0:1/40',mypass], + ['[DEAD::CAFE/40]', 1, 'DEAD:0:0:0:0:0:0:1/40',mypass], + ['[DEAD:BEEF::1/40]', 4, 'DEAD:BEEF:0:0:0:0:0:4/40',mypass], + ['[DEAD:BEEF::1/40]', 5, 'DEAD:BEEF:0:0:0:0:0:5/40',mypass], + ['[DEAD:BEEF::1/40]', 6, 'DEAD:BEEF:0:0:0:0:0:6/40',mypass], + ['[DEAD:BEEF::1/40]', 7, 'DEAD:BEEF:0:0:0:0:0:7/40',mypass], + ['[DEAD:BEEF::1/40]', 8, 'DEAD:BEEF:0:0:0:0:0:8/40',mypass], + ['[DEAD:BEEF::1/40]', 9, 'DEAD:BEEF:0:0:0:0:0:9/40',mypass], + ['[DEAD:BEEF::1/40]', 255, 'DEAD:BEEF:0:0:0:0:0:FF/40',mypass], + ['[DEAD:BEEF::1/40]', 256, 'DEAD:BEEF:0:0:0:0:0:100/40',mypass], + ['[DEAD:BEEF::1/40]', 257, 'DEAD:BEEF:0:0:0:0:0:101/40',mypass], + ['[DEAD:BEEF::1/40]', 65536, 'DEAD:BEEF:0:0:0:0:1:0/40',mypass], + ['[DEAD:BEEF::1/40]', 65537, 'DEAD:BEEF:0:0:0:0:1:1/40',mypass], + ['[2001:620:0:4::/64]', 1, '2001:620:0:4:0:0:0:1/64',mypass], + ['[3FFE:2000:0:4::/64]', 1, '3FFE:2000:0:4:0:0:0:1/64',mypass], + ['[2001:620:600::1]', 1, '2001:620:600:0:0:0:0:1/128',myfail], + ['[2001:620:600:0:1::1]', 1,'2001:620:600:0:1:0:0:1/128',myfail], + ); + +use NetAddr::IP::Lite qw(:old_nth); +use Test::More; + +my($a, $ip, $test); + +$test = 4 * @addr + 4; +plan tests => $test; + +$test = 1; + +sub tst { + for $a (@addr) { + $ip = new NetAddr::IP::Lite $a->[0]; + $a->[0] =~ s,/\d+,,; + isa_ok($ip, 'NetAddr::IP::Lite', "$a->[0] "); +# requires full NetAddr::IP +# is(uc $ip->short, $a->[0], "short returns $a->[0]"); + is($ip->bits, 128, "bits == 128"); + is($ip->version, 6, "version == 6"); + my $index = $a->[1]; + if ($a->[3]) { + is(uc $ip->nth($index), $a->[2], "nth $a->[0], $index"); + } else { + ok(!$ip->nth($index),"nth $a->[0], undef"); + } + } +} + +tst(); + + +$test = new NetAddr::IP::Lite 'f34::1'; +isa_ok($test, 'NetAddr::IP::Lite'); +ok($test->network->contains($test), "->contains"); + +$test = new NetAddr::IP::Lite 'f35::1/40'; +isa_ok($test, 'NetAddr::IP::Lite'); +ok($test->network->contains($test), "->contains"); + diff --git a/Lite/t/v6-old-base.t b/Lite/t/v6-old-base.t new file mode 100644 index 0000000..05d3934 --- /dev/null +++ b/Lite/t/v6-old-base.t @@ -0,0 +1,70 @@ +# This -*- perl -*- code excercises the basic v6 functionality + +sub mypass() {1} +sub myfail() {0} + +@addr = + ( + ['::', 3, '0:0:0:0:0:0:0:0/128',myfail], + ['::1', 3, '0:0:0:0:0:0:0:1/128',myfail], + ['F34::123/40', 3, 'F34:0:0:0:0:0:0:3/40',mypass], + ['DEAD:BEEF::1/40', 3, 'DEAD:BEEF:0:0:0:0:0:3/40',mypass], + ['1000::2/40', 1, '1000:0:0:0:0:0:0:1/40',mypass], + ['1000::2000/40', 1, '1000:0:0:0:0:0:0:1/40',mypass], + ['DEAD::CAFE/40', 1, 'DEAD:0:0:0:0:0:0:1/40',mypass], + ['DEAD:BEEF::1/40', 4, 'DEAD:BEEF:0:0:0:0:0:4/40',mypass], + ['DEAD:BEEF::1/40', 5, 'DEAD:BEEF:0:0:0:0:0:5/40',mypass], + ['DEAD:BEEF::1/40', 6, 'DEAD:BEEF:0:0:0:0:0:6/40',mypass], + ['DEAD:BEEF::1/40', 7, 'DEAD:BEEF:0:0:0:0:0:7/40',mypass], + ['DEAD:BEEF::1/40', 8, 'DEAD:BEEF:0:0:0:0:0:8/40',mypass], + ['DEAD:BEEF::1/40', 9, 'DEAD:BEEF:0:0:0:0:0:9/40',mypass], + ['DEAD:BEEF::1/40', 255, 'DEAD:BEEF:0:0:0:0:0:FF/40',mypass], + ['DEAD:BEEF::1/40', 256, 'DEAD:BEEF:0:0:0:0:0:100/40',mypass], + ['DEAD:BEEF::1/40', 257, 'DEAD:BEEF:0:0:0:0:0:101/40',mypass], + ['DEAD:BEEF::1/40', 65536, 'DEAD:BEEF:0:0:0:0:1:0/40',mypass], + ['DEAD:BEEF::1/40', 65537, 'DEAD:BEEF:0:0:0:0:1:1/40',mypass], + ['2001:620:0:4::/64', 1, '2001:620:0:4:0:0:0:1/64',mypass], + ['3FFE:2000:0:4::/64', 1, '3FFE:2000:0:4:0:0:0:1/64',mypass], + ['2001:620:600::1', 1, '2001:620:600:0:0:0:0:1/128',myfail], + ['2001:620:600:0:1::1', 1,'2001:620:600:0:1:0:0:1/128',myfail], + ); + +use NetAddr::IP::Lite qw(:old_nth); +use Test::More; + +my($a, $ip, $test); + +$test = 4 * @addr + 4; +plan tests => $test; + +$test = 1; + +sub tst { + for $a (@addr) { + $ip = new NetAddr::IP::Lite $a->[0]; + $a->[0] =~ s,/\d+,,; + isa_ok($ip, 'NetAddr::IP::Lite', "$a->[0] "); +# requires full NetAddr::IP +# is(uc $ip->short, $a->[0], "short returns $a->[0]"); + is($ip->bits, 128, "bits == 128"); + is($ip->version, 6, "version == 6"); + my $index = $a->[1]; + if ($a->[3]) { + is(uc $ip->nth($index), $a->[2], "nth $a->[0], $index"); + } else { + ok(!$ip->nth($index),"nth $a->[0], undef"); + } + } +} + +tst(); + + +$test = new NetAddr::IP::Lite 'f34::1'; +isa_ok($test, 'NetAddr::IP::Lite'); +ok($test->network->contains($test), "->contains"); + +$test = new NetAddr::IP::Lite 'f35::1/40'; +isa_ok($test, 'NetAddr::IP::Lite'); +ok($test->network->contains($test), "->contains"); + diff --git a/Lite/t/version.t b/Lite/t/version.t new file mode 100644 index 0000000..24f11fb --- /dev/null +++ b/Lite/t/version.t @@ -0,0 +1,29 @@ + +#use diagnostics; +use NetAddr::IP::Lite; + +$| = 1; + +print "1..2\n"; + +my $test = 1; +sub ok() { + print 'ok ',$test++,"\n"; +} + +my $loip = new NetAddr::IP::Lite('1.2.3.4/24'); +my $hiip = new NetAddr::IP::Lite('FF00::1:4/120'); + +## test version lo +$exp = 4; +my $version = $loip->version; +print "got: $version, exp: $exp\nnot " + unless $version == $exp; +&ok; + +## test version hi +$exp = 6; +$version = $hiip->version; +print "got: $version, exp: $exp\nnot " + unless $version == $exp; +&ok; diff --git a/Lite/t/within.t b/Lite/t/within.t new file mode 100644 index 0000000..5093e1f --- /dev/null +++ b/Lite/t/within.t @@ -0,0 +1,40 @@ + +#use diagnostics; +use NetAddr::IP::Lite; + +$| = 1; + +print "1..12\n"; + +my $test = 1; +sub ok() { + print 'ok ',$test++,"\n"; +} + +my $net4 = NetAddr::IP::Lite->new('1.2.3.5/30'); +my $net6 = NetAddr::IP::Lite->new('FF::85/126'); +my @try = qw( + 1.2.3.3 0 + 1.2.3.4 1 + 1.2.3.5 1 + 1.2.3.6 1 + 1.2.3.7 1 + 1.2.3.8 0 + FF::83 0 + FF::84 1 + FF::85 1 + FF::86 1 + FF::87 1 + FF::88 0 +); + +for (my $i=0;$i<@try;$i+=2) { + my $ip = NetAddr::IP::Lite->new($try[$i]); + my $rv = ($try[$i] =~ /:/) + ? $ip->within($net6) + : $ip->within($net4); + print "got: $rv, exp: $try[$i+1]\nnot " + unless $rv == $try[$i+1]; + &ok; +} + diff --git a/MANIFEST b/MANIFEST new file mode 100644 index 0000000..5718622 --- /dev/null +++ b/MANIFEST @@ -0,0 +1,179 @@ +About-NetAddr-IP.txt +Artistic +Changes +Copying +IP.pm +MANIFEST +MANIFEST.SKIP +Makefile.PL +TODO +docs/rfc1884.txt +t/canon.t +t/constants.t +t/full.t +t/full6.t +t/imhoff.t +t/loops.t +t/lower.t +t/masklen.t +t/new-store.t +t/nofqdn.t +t/old-store.t +t/over-arr.t +t/over-qq.t +t/relops.t +t/rfc3021.t +t/short.t +t/splitref.t +t/v4-coalesce.t +t/v4-compact.t +t/v4-compplus.t +t/v4-hostenum.t +t/v4-re.t +t/v4-split-bulk.t +t/v4-split-list.t +t/v4-splitplan.t +t/v4-sprefix.t +t/v4-xprefix.t +t/v6-re.t +t/v6-split-bulk.t +t/v6-splitplan.t +t/wildcard.t +t/full6-uri.t +Lite/Changes +Lite/Lite.pm +Lite/MANIFEST +Lite/MANIFEST.SKIP +Lite/Makefile.PL +Lite/README +Lite/bug2742981 +Lite/t/addr.t +Lite/t/aton.t +Lite/t/bigint.t +Lite/t/bignums.t +Lite/t/bin_ips.t +Lite/t/bits.t +Lite/t/broadcast.t +Lite/t/bug62521.t +Lite/t/bug75976.t +Lite/t/cidr.t +Lite/t/constants.t +Lite/t/contains.t +Lite/t/copy.t +Lite/t/firstlast.t +Lite/t/ipv4FFFF.t +Lite/t/is_local.t +Lite/t/lemasklen.t +Lite/t/loops.t +Lite/t/lower.t +Lite/t/mask.t +Lite/t/masklen.t +Lite/t/netaddr.t +Lite/t/network.t +Lite/t/new-nth.t +Lite/t/new-num.t +Lite/t/nofqdn.t +Lite/t/numeric.t +Lite/t/old-nth.t +Lite/t/old-num.t +Lite/t/over-qq.t +Lite/t/over_comp.t +Lite/t/over_copy.t +Lite/t/over_equal.t +Lite/t/over_math.t +Lite/t/overminus.t +Lite/t/pathological.t +Lite/t/range.t +Lite/t/relops.t +Lite/t/rfc_1918.t +Lite/t/v4-aton.t +Lite/t/v4-badnm.t +Lite/t/v4-base.t +Lite/t/v4-basem.t +Lite/t/v4-cidr.t +Lite/t/v4-cnew.t +Lite/t/v4-contains.t +Lite/t/v4-last.t +Lite/t/v4-new-first.t +Lite/t/v4-new.t +Lite/t/v4-new_from_aton.t +Lite/t/v4-no_octal.t +Lite/t/v4-num.t +Lite/t/v4-numeric.t +Lite/t/v4-old-first.t +Lite/t/v4-range.t +Lite/t/v4-snew.t +Lite/t/v4-wnew.t +Lite/t/v4_new_cis.t +Lite/t/v6-cnew.t +Lite/t/v6-contains.t +Lite/t/v6-inc.t +Lite/t/v6-new-base.t +Lite/t/v6-new_cis6_base.t +Lite/t/v6-new_cis_base.t +Lite/t/v6-num.t +Lite/t/v6-numeric.t +Lite/t/v6-old-base.t +Lite/t/version.t +Lite/t/within.t +Lite/t/v6-cnew-uri.t +Lite/t/v6-new-base-uri.t +Lite/t/v6-numeric-uri.t +Lite/t/v6-old-base-uri.t +Lite/Util/Changes +Lite/Util/MANIFEST +Lite/Util/MANIFEST.SKIP +Lite/Util/Makefile.PL +Lite/Util/README +Lite/Util/Util.pm +Lite/Util/Util.xs +Lite/Util/config.h.in +Lite/Util/configure.cc +Lite/Util/configure.gcc +Lite/Util/configure.ac +Lite/Util/lib/NetAddr/IP/InetBase.pm +Lite/Util/lib/NetAddr/IP/UtilPP.pm +Lite/Util/localconf.h +Lite/Util/t/4to6.t +Lite/Util/t/add128.t +Lite/Util/t/addconst.t +Lite/Util/t/af_inet6.t +Lite/Util/t/anyto6.t +Lite/Util/t/badd.t +Lite/Util/t/bcd2bin.t +Lite/Util/t/bcdn2bin.t +Lite/Util/t/bin.t +Lite/Util/t/binet_n2ad.t +Lite/Util/t/binet_n2dx.t +Lite/Util/t/binet_pton.t +Lite/Util/t/bipv4_inet.t +Lite/Util/t/bipv6_any2n.t +Lite/Util/t/bipv6func.t +Lite/Util/t/bisIPv4.t +Lite/Util/t/bpackzeros.t +Lite/Util/t/comp128.t +Lite/Util/t/croak.t +Lite/Util/t/hasbits.t +Lite/Util/t/inet_4map6.t +Lite/Util/t/inet_n2ad.t +Lite/Util/t/inet_n2dx.t +Lite/Util/t/inet_pton.t +Lite/Util/t/ipv4_inet.t +Lite/Util/t/ipv6_any2n.t +Lite/Util/t/ipv6func.t +Lite/Util/t/ipv6to4.t +Lite/Util/t/isIPv4.t +Lite/Util/t/leftshift.t +Lite/Util/t/mode.t +Lite/Util/t/notcontiguous.t +Lite/Util/t/packzeros.t +Lite/Util/t/simple_pack.t +Lite/Util/t/sub128.t +Lite/Util/tlib/NetAddr/IP/Util_IS.pm +Lite/Util/t/binet_ntoa.t +Lite/Util/t/ipv6_ntoa.t +Lite/Util/t/naip_gethostbyname.t +Lite/Util/t/no6_naip_gethostbyname.t +Lite/Util/typemap + +META.yml Module meta-data (added by MakeMaker) diff --git a/MANIFEST.SKIP b/MANIFEST.SKIP new file mode 100644 index 0000000..963ab2a --- /dev/null +++ b/MANIFEST.SKIP @@ -0,0 +1,32 @@ +^Build$ +^_build/ +^blib/ +^blibdirs +Makefile$ +Makefile\.[a-z]+$ +pm_to_blib +CVS/.* +\.cvs +,v$ +^tmp/ +\.old$ +\.bak$ +\.tmp$ +\.xsc$ +~$ +^# +\.shar$ +\.tar$ +\.tgz$ +\.tar\.gz$ +\.zip$ +_uu$ +Util_IS\.pm$ +Util\.(bs|[co])$ +localStuff\.h$ +config\.log$ +config\.h$ +config\.status +localperl\.h +Lite/bug2742981.pl +META.yml diff --git a/META.yml b/META.yml new file mode 100644 index 0000000..bc33e33 --- /dev/null +++ b/META.yml @@ -0,0 +1,14 @@ +--- #YAML:1.0 +name: NetAddr-IP +version: 4.079 +abstract: Manages IPv4 and IPv6 addresses and subnets +license: ~ +author: + - Luis E. Muñoz , Michael Robinton +generated_by: ExtUtils::MakeMaker version 6.42 +distribution_type: module +requires: + Test::More: 0 +meta-spec: + url: http://module-build.sourceforge.net/META-spec-v1.3.html + version: 1.3 diff --git a/Makefile.PL b/Makefile.PL new file mode 100644 index 0000000..da50c62 --- /dev/null +++ b/Makefile.PL @@ -0,0 +1,90 @@ +use ExtUtils::MakeMaker; +# See lib/ExtUtils/MakeMaker.pm for details of how to influence +# the contents of the Makefile that is written. + +my $check0 = 0; +my $check1 = 0; +my $now = time; +my $then = (stat('./Makefile.old'))[9]; +# set number of seconds to view +my $view = $then +86400 < $now ? 5:0; + +my $pv = sprintf "%vd", $^V; +unless ($pv lt '5.8.0' || $pv gt '5.8.5') { + print +qq( +################################################################# +######################### WARNING ############################### +# # +# YOUR VERSION OF PERL = $pv HAS SERIOUS BUGS # +# # +# Early versions of perl 5.8.x contain bugs that cause certain # +# \@_ operations to fail. See perl bug [ 23429] # +# Please upgrade to at least perl 5.8.6 # +# # +################################################################# +); + sleep $view if $view; +} + +unless (grep { m/-noxs/ } @ARGV) { + print q{ +This build requires a C compiler by default except on Windows where +the Pure Perl version is mandatory. The Pure Perl version, which does +not require compilation of XS code, can be used by invoking this as: + + perl Makefile.PL -noxs + +}; + sleep $view if $view; +} + +sleep $view if $view && ($check0 || $check1); + +print <can('signature_target') ? (SIGN => 1) : ()), + 'NAME' => 'NetAddr::IP', + 'VERSION_FROM' => 'IP.pm', # finds $VERSION + 'PREREQ_PM' => { + Test::More => 0, + }, # e.g., Module::Name => 1.1 + ($] >= 5.005 ? ## Add these new keywords supported since 5.005 + (ABSTRACT_FROM => 'IP.pm', + AUTHOR => 'Luis E. Muñoz , Michael Robinton ') : ()), + clean => { FILES => "*~ tmp* META.yml"}, +); + +WriteMakefile(%makeparms); diff --git a/TODO b/TODO new file mode 100644 index 0000000..442e11c --- /dev/null +++ b/TODO @@ -0,0 +1,5 @@ + +o More tests for IPv6 functionality. This should be thoroughly tested. + +o Add support for other notations (when found). + diff --git a/docs/rfc1884.txt b/docs/rfc1884.txt new file mode 100644 index 0000000..76f8e88 --- /dev/null +++ b/docs/rfc1884.txt @@ -0,0 +1,1023 @@ +Network Working Group R. Hinden, Ipsilon Networks +Request for Comments: 1884 S. Deering, Xerox PARC +Category: Standards Track Editors + December 1995 + + + IP Version 6 Addressing Architecture + + + + +Status of this Memo + + This document specifies an Internet standards track protocol for the + Internet community, and requests discussion and suggestions for + improvements. Please refer to the current edition of the "Internet + Official Protocol Standards" (STD 1) for the standardization state + and status of this protocol. Distribution of this memo is unlimited. + + +Abstract + + This specification defines the addressing architecture of the IP + Version 6 protocol [IPV6]. The document includes the IPv6 addressing + model, text representations of IPv6 addresses, definition of IPv6 + unicast addresses, anycast addresses, and multicast addresses, and an + IPv6 nodes required addresses. + + + + + + + + + + + + + + + + + + + + + + + + +Hinden & Deering Standards Track [Page 1] + + +RFC 1884 IPv6 Addressing Architecture December 1995 + + +Table of Contents + + 1. Introduction................................................3 + + 2. IPv6 Addressing.............................................3 + 2.1 Addressing Model........................................4 + 2.2 Text Representation of Addresses........................4 + 2.3 Address Type Representation.............................5 + 2.4 Unicast Addresses.......................................7 + 2.4.1 Unicast Address Example.............................8 + 2.4.2 The Unspecified Address.............................9 + 2.4.3 The Loopback Address................................9 + 2.4.4 IPv6 Addresses with Embedded IPv4 Addresses.........9 + 2.4.5 NSAP Addresses......................................10 + 2.4.6 IPX Addresses.......................................10 + 2.4.7 Provider-Based Global Unicast Addresses.............10 + 2.4.8 Local-use IPv6 Unicast Addresses....................11 + 2.5 Anycast Addresses.......................................12 + 2.5.1 Required Anycast Address............................13 + 2.6 Multicast Addresses.....................................14 + 2.6.1 Pre-Defined Multicast Addresses.....................15 + 2.7 A Node's Required Addresses.............................17 + + REFERENCES.....................................................18 + + SECURITY CONSIDERATIONS........................................18 + + DOCUMENT EDITOR'S ADDRESSES....................................18 + + + + + + + + + + + + + + + + + + + + + + + +Hinden & Deering Standards Track [Page 2] + + +RFC 1884 IPv6 Addressing Architecture December 1995 + + +1.0 INTRODUCTION + + + This specification defines the addressing architecture of the IP + Version 6 protocol. It includes a detailed description of the + currently defined address formats for IPv6 [IPV6]. + + The editors would like to acknowledge the contributions of Paul + Francis, Jim Bound, Brian Carpenter, Deborah Estrin, Peter Ford, Bob + Gilligan, Christian Huitema, Tony Li, Greg Minshall, Erik Nordmark, + Yakov Rekhter, Bill Simpson, and Sue Thomson. + +2.0 IPv6 ADDRESSING + + + IPv6 addresses are 128-bit identifiers for interfaces and sets of + interfaces. There are three types of addresses: + + + Unicast: An identifier for a single interface. A packet sent + to a unicast address is delivered to the interface + identified by that address. + + Anycast: An identifier for a set of interfaces (typically + belonging to different nodes). A packet sent to an + anycast address is delivered to one of the interfaces + identified by that address (the "nearest" one, + according to the routing protocols' measure of + distance). + + Multicast: An identifier for a set of interfaces (typically + belonging to different nodes). A packet sent to a + multicast address is delivered to all interfaces + identified by that address. + + There are no broadcast addresses in IPv6, their function being + superseded by multicast addresses. + + In this document, fields in addresses are given a specific name, for + example "subscriber". When this name is used with the term "ID" for + identifier after the name (e.g., "subscriber ID"), it refers to the + contents of the named field. When it is used with the term "prefix" + (e.g., "subscriber prefix") it refers to all of the address up to and + including this field. + + In IPv6, all zeros and all ones are legal values for any field, + unless specifically excluded. Specifically, prefixes may contain + zero-valued fields or end in zeros. + + + + + +Hinden & Deering Standards Track [Page 3] + + +RFC 1884 IPv6 Addressing Architecture December 1995 + + + 2.1 Addressing Model + + IPv6 Addresses of all types are assigned to interfaces, not nodes. + Since each interface belongs to a single node, any of that node's + interfaces' unicast addresses may be used as an identifier for the + node. + + An IPv6 unicast address refers to a single interface. A single + interface may be assigned multiple IPv6 addresses of any type + (unicast, anycast, and multicast). There are two exceptions to this + model. These are: + + 1) A single address may be assigned to multiple physical interfaces + if the implementation treats the multiple physical interfaces as + one interface when presenting it to the internet layer. This is + useful for load-sharing over multiple physical interfaces. + + 2) Routers may have unnumbered interfaces (i.e., no IPv6 address + assigned to the interface) on point-to-point links to eliminate + the necessity to manually configure and advertise the addresses. + Addresses are not needed for point-to-point interfaces on + routers if those interfaces are not to be used as the origins or + destinations of any IPv6 datagrams. + + IPv6 continues the IPv4 model that a subnet is associated with one + link. Multiple subnets may be assigned to the same link. + + + 2.2 Text Representation of Addresses + + There are three conventional forms for representing IPv6 addresses as + text strings: + + 1. The preferred form is x:x:x:x:x:x:x:x, where the 'x's are the + hexadecimal values of the eight 16-bit pieces of the address. + Examples: + + FEDC:BA98:7654:3210:FEDC:BA98:7654:3210 + + 1080:0:0:0:8:800:200C:417A + + Note that it is not necessary to write the leading zeros in an + individual field, but there must be at least one numeral in + every field (except for the case described in 2.). + + 2. Due to the method of allocating certain styles of IPv6 + addresses, it will be common for addresses to contain long + strings of zero bits. In order to make writing addresses + + + +Hinden & Deering Standards Track [Page 4] + + +RFC 1884 IPv6 Addressing Architecture December 1995 + + + containing zero bits easier a special syntax is available to + compress the zeros. The use of "::" indicates multiple groups + of 16-bits of zeros. The "::" can only appear once in an + address. The "::" can also be used to compress the leading + and/or trailing zeros in an address. + + For example the following addresses: + + 1080:0:0:0:8:800:200C:417A a unicast address + FF01:0:0:0:0:0:0:43 a multicast address + 0:0:0:0:0:0:0:1 the loopback address + 0:0:0:0:0:0:0:0 the unspecified addresses + + may be represented as: + + 1080::8:800:200C:417A a unicast address + FF01::43 a multicast address + ::1 the loopback address + :: the unspecified addresses + + 3. An alternative form that is sometimes more convenient when + dealing with a mixed environment of IPv4 and IPv6 nodes is + x:x:x:x:x:x:d.d.d.d, where the 'x's are the hexadecimal values + of the six high-order 16-bit pieces of the address, and the 'd's + are the decimal values of the four low-order 8-bit pieces of the + address (standard IPv4 representation). Examples: + + 0:0:0:0:0:0:13.1.68.3 + + 0:0:0:0:0:FFFF:129.144.52.38 + + or in compressed form: + + ::13.1.68.3 + + ::FFFF:129.144.52.38 + + + 2.3 Address Type Representation + + The specific type of an IPv6 address is indicated by the leading bits + in the address. The variable-length field comprising these leading + bits is called the Format Prefix (FP). The initial allocation of + these prefixes is as follows: + + + + + + + +Hinden & Deering Standards Track [Page 5] + + +RFC 1884 IPv6 Addressing Architecture December 1995 + + + Allocation Prefix Fraction of + (binary) Address Space + ------------------------------- -------- ------------- + Reserved 0000 0000 1/256 + Unassigned 0000 0001 1/256 + + Reserved for NSAP Allocation 0000 001 1/128 + Reserved for IPX Allocation 0000 010 1/128 + + Unassigned 0000 011 1/128 + Unassigned 0000 1 1/32 + Unassigned 0001 1/16 + Unassigned 001 1/8 + + Provider-Based Unicast Address 010 1/8 + + Unassigned 011 1/8 + + Reserved for Geographic- + Based Unicast Addresses 100 1/8 + + Unassigned 101 1/8 + Unassigned 110 1/8 + Unassigned 1110 1/16 + Unassigned 1111 0 1/32 + Unassigned 1111 10 1/64 + Unassigned 1111 110 1/128 + + Unassigned 1111 1110 0 1/512 + + Link Local Use Addresses 1111 1110 10 1/1024 + Site Local Use Addresses 1111 1110 11 1/1024 + + Multicast Addresses 1111 1111 1/256 + + Note: The "unspecified address" (see section 2.4.2), the + loopback address (see section 2.4.3), and the IPv6 Addresses + with Embedded IPv4 Addresses (see section 2.4.4), are assigned + out of the 0000 0000 format prefix space. + + + This allocation supports the direct allocation of provider addresses, + local use addresses, and multicast addresses. Space is reserved for + NSAP addresses, IPX addresses, and geographic addresses. The + remainder of the address space is unassigned for future use. This + can be used for expansion of existing use (e.g., additional provider + addresses, etc.) or new uses (e.g., separate locators and + identifiers). Fifteen percent of the address space is initially + + + +Hinden & Deering Standards Track [Page 6] + + +RFC 1884 IPv6 Addressing Architecture December 1995 + + + allocated. The remaining 85% is reserved for future use. + + Unicast addresses are distinguished from multicast addresses by the + value of the high-order octet of the addresses: a value of FF + (11111111) identifies an address as a multicast address; any other + value identifies an address as a unicast address. Anycast addresses + are taken from the unicast address space, and are not syntactically + distinguishable from unicast addresses. + + + 2.4 Unicast Addresses + + The IPv6 unicast address is contiguous bit-wise maskable, similar to + IPv4 addresses under Class-less Interdomain Routing [CIDR]. + + There are several forms of unicast address assignment in IPv6, + including the global provider based unicast address, the geographic + based unicast address, the NSAP address, the IPX hierarchical + address, the site-local-use address, the link-local-use address, and + the IPv4-capable host address. Additional address types can be + defined in the future. + + IPv6 nodes may have considerable or little knowledge of the internal + structure of the IPv6 address, depending on the role the node plays + (for instance, host versus router). At a minimum, a node may + consider that unicast addresses (including its own) have no internal + structure: + + | 128 bits | + +-----------------------------------------------------------------+ + | node address | + +-----------------------------------------------------------------+ + + + A slightly sophisticated host (but still rather simple) may + additionally be aware of subnet prefix(es) for the link(s) it is + attached to, where different addresses may have different values for + n: + + | n bits | 128-n bits | + +------------------------------------------------+----------------+ + | subnet prefix | interface ID | + +------------------------------------------------+----------------+ + + + Still more sophisticated hosts may be aware of other hierarchical + boundaries in the unicast address. Though a very simple router may + have no knowledge of the internal structure of IPv6 unicast + + + +Hinden & Deering Standards Track [Page 7] + + +RFC 1884 IPv6 Addressing Architecture December 1995 + + + addresses, routers will more generally have knowledge of one or more + of the hierarchical boundaries for the operation of routing + protocols. The known boundaries will differ from router to router, + depending on what positions the router holds in the routing + hierarchy. + + + 2.4.1 Unicast Address Examples + + An example of a Unicast address format which will likely be common on + LANs and other environments where IEEE 802 MAC addresses are + available is: + + + | n bits | 80-n bits | 48 bits | + +--------------------------------+-----------+--------------------+ + | subscriber prefix | subnet ID | interface ID | + +--------------------------------+-----------+--------------------+ + + Where the 48-bit Interface ID is an IEEE-802 MAC address. The use of + IEEE 802 MAC addresses as a interface ID is expected to be very + common in environments where nodes have an IEEE 802 MAC address. In + other environments, where IEEE 802 MAC addresses are not available, + other types of link layer addresses can be used, such as E.164 + addresses, for the interface ID. + + The inclusion of a unique global interface identifier, such as an + IEEE MAC address, makes possible a very simple form of auto- + configuration of addresses. A node may discover a subnet ID by + listening to Router Advertisement messages sent by a router on its + attached link(s), and then fabricating an IPv6 address for itself by + using its IEEE MAC address as the interface ID on that subnet. + + Another unicast address format example is where a site or + organization requires additional layers of internal hierarchy. In + this example the subnet ID is divided into an area ID and a subnet + ID. Its format is: + + | s bits | n bits | m bits | 128-s-n-m bits | + +----------------------+---------+--------------+-----------------+ + | subscriber prefix | area ID | subnet ID | interface ID | + +----------------------+---------+--------------+-----------------+ + + This technique can be continued to allow a site or organization to + add additional layers of internal hierarchy. It may be desirable to + use an interface ID smaller than a 48-bit IEEE 802 MAC address to + allow more space for the additional layers of internal hierarchy. + These could be interface IDs which are administratively created by + + + +Hinden & Deering Standards Track [Page 8] + + +RFC 1884 IPv6 Addressing Architecture December 1995 + + + the site or organization. + + + 2.4.2 The Unspecified Address + + The address 0:0:0:0:0:0:0:0 is called the unspecified address. It + must never be assigned to any node. It indicates the absence of an + address. One example of its use is in the Source Address field of + any IPv6 datagrams sent by an initializing host before it has learned + its own address. + + The unspecified address must not be used as the destination address + of IPv6 datagrams or in IPv6 Routing Headers. + + + 2.4.3 The Loopback Address + + The unicast address 0:0:0:0:0:0:0:1 is called the loopback address. + It may be used by a node to send an IPv6 datagram to itself. It may + never be assigned to any interface. + + The loopback address must not be used as the source address in IPv6 + datagrams that are sent outside of a single node. An IPv6 datagram + with a destination address of loopback must never be sent outside of + a single node. + + + 2.4.4 IPv6 Addresses with Embedded IPv4 Addresses + + The IPv6 transition mechanisms include a technique for hosts and + routers to dynamically tunnel IPv6 packets over IPv4 routing + infrastructure. IPv6 nodes that utilize this technique are assigned + special IPv6 unicast addresses that carry an IPv4 address in the + low-order 32-bits. This type of address is termed an "IPv4- + compatible IPv6 address" and has the format: + + + | 80 bits | 16 | 32 bits | + +--------------------------------------+--------------------------+ + |0000..............................0000|0000| IPv4 address | + +--------------------------------------+----+---------------------+ + + + A second type of IPv6 address which holds an embedded IPv4 address is + also defined. This address is used to represent the addresses of + IPv4-only nodes (those that *do not* support IPv6) as IPv6 addresses. + This type of address is termed an "IPv4-mapped IPv6 address" and has + the format: + + + +Hinden & Deering Standards Track [Page 9] + + +RFC 1884 IPv6 Addressing Architecture December 1995 + + + + | 80 bits | 16 | 32 bits | + +--------------------------------------+--------------------------+ + |0000..............................0000|FFFF| IPv4 address | + +--------------------------------------+----+---------------------+ + + + + 2.4.5 NSAP Addresses + + This mapping of NSAP address into IPv6 addresses is as follows: + + + | 7 | 121 bits | + +-------+---------------------------------------------------------+ + |0000001| to be defined | + +-------+---------------------------------------------------------+ + + The draft definition, motivation, and usage are under study [NSAP]. + + + 2.4.6 IPX Addresses + + This mapping of IPX address into IPv6 addresses is as follows: + + + | 7 | 121 bits | + +-------+---------------------------------------------------------+ + |0000010| to be defined | + +-------+---------------------------------------------------------+ + + The draft definition, motivation, and usage are under study. + + + 2.4.7 Provider-Based Global Unicast Addresses + + The global provider-based unicast address is assigned as described in + [ALLOC]. This initial assignment plan for these unicast addresses is + similar to assignment of IPv4 addresses under the CIDR scheme [CIDR]. + The IPv6 global provider-based unicast address format is as follows: + + + | 3 | n bits | m bits | o bits | 125-n-m-o bits | + +---+-----------+-----------+-------------+--------------------+ + |010|registry ID|provider ID|subscriber ID| intra-subscriber | + +---+-----------+-----------+-------------+--------------------+ + + + + + +Hinden & Deering Standards Track [Page 10] + + +RFC 1884 IPv6 Addressing Architecture December 1995 + + + The high-order part of the address is assigned to registries, who + then assign portions of the address space to providers, who then + assign portions of the address space to subscribers, etc. + + The registry ID identifies the registry which assigns the provider + portion of the address. The term "registry prefix" refers to the + high-order part of the address up to and including the registry ID. + + The provider ID identifies a specific provider which assigns the + subscriber portion of the address. The term "provider prefix" refers + to the high-order part of the address up to and including the + provider ID. + + The subscriber ID distinguishes among multiple subscribers attached + to the provider identified by the provider ID. The term "subscriber + prefix" refers to the high-order part of the address up to and + including the subscriber ID. + + The intra-subscriber portion of the address is defined by an + individual subscriber and is organized according to the subscribers + local internet topology. It is likely that many subscribers will + choose to divide the intra-subscriber portion of the address into a + subnet ID and an interface ID. In this case the subnet ID identifies + a specific physical link and the interface ID identifies a single + interface on that subnet. + + + 2.4.8 Local-use IPv6 Unicast Addresses + + There are two types of local-use unicast addresses defined. These + are Link-Local and Site-Local. The Link-Local is for use on a single + link and the Site-Local is for use in a single site. Link-Local + addresses have the following format: + + | 10 | + | bits | n bits | 118-n bits | + +----------+-------------------------+----------------------------+ + |1111111010| 0 | interface ID | + +----------+-------------------------+----------------------------+ + + Link-Local addresses are designed to be used for addressing on a + single link for purposes such as auto-address configuration, neighbor + discovery, or when no routers are present. + + Routers MUST not forward any packets with link-local source + addresses. + + + + + +Hinden & Deering Standards Track [Page 11] + + +RFC 1884 IPv6 Addressing Architecture December 1995 + + + Site-Local addresses have the following format: + + | 10 | + | bits | n bits | m bits | 118-n-m bits | + +----------+---------+---------------+----------------------------+ + |1111111011| 0 | subnet ID | interface ID | + +----------+---------+---------------+----------------------------+ + + + Site-Local addresses may be used for sites or organizations that are + not (yet) connected to the global Internet. They do not need to + request or "steal" an address prefix from the global Internet address + space. IPv6 site-local addresses can be used instead. When the + organization connects to the global Internet, it can then form global + addresses by replacing the site-local prefix with a subscriber + prefix. + + Routers MUST not forward any packets with site-local source addresses + outside of the site. + + 2.5 Anycast Addresses + + An IPv6 anycast address is an address that is assigned to more than + one interface (typically belonging to different nodes), with the + property that a packet sent to an anycast address is routed to the + "nearest" interface having that address, according to the routing + protocols' measure of distance. + + Anycast addresses are allocated from the unicast address space, using + any of the defined unicast address formats. Thus, anycast addresses + are syntactically indistinguishable from unicast addresses. When a + unicast address is assigned to more than one interface, thus turning + it into an anycast address, the nodes to which the address is + assigned must be explicitly configured to know that it is an anycast + address. + + For any assigned anycast address, there is a longest address prefix P + that identifies the topological region in which all interfaces + belonging to that anycast address reside. Within the region + identified by P, each member of the anycast set must be advertised as + a separate entry in the routing system (commonly referred to as a + "host route"); outside the region identified by P, the anycast + address may be aggregated into the routing advertisement for prefix + P. + + Note that in, the worst case, the prefix P of an anycast set may be + the null prefix, i.e., the members of the set may have no topological + locality. In that case, the anycast address must be advertised as a + + + +Hinden & Deering Standards Track [Page 12] + + +RFC 1884 IPv6 Addressing Architecture December 1995 + + + separate routing entry throughout the entire internet, which presents + a severe scaling limit on how many such "global" anycast sets may be + supported. Therefore, it is expected that support for global anycast + sets may be unavailable or very restricted. + + One expected use of anycast addresses is to identify the set of + routers belonging to an internet service provider. Such addresses + could be used as intermediate addresses in an IPv6 Routing header, to + cause a packet to be delivered via a particular provider or sequence + of providers. Some other possible uses are to identify the set of + routers attached to a particular subnet, or the set of routers + providing entry into a particular routing domain. + + There is little experience with widespread, arbitrary use of internet + anycast addresses, and some known complications and hazards when + using them in their full generality [ANYCST]. Until more experience + has been gained and solutions agreed upon for those problems, the + following restrictions are imposed on IPv6 anycast addresses: + + o An anycast address MUST NOT be used as the source address of an + IPv6 packet. + + o An anycast address MUST NOT be assigned to an IPv6 host, that + is, it may be assigned to an IPv6 router only. + + + 2.5.1 Required Anycast Address + + The Subnet-Router anycast address is predefined. It's format is as + follows: + + + | n bits | 128-n bits | + +------------------------------------------------+----------------+ + | subnet prefix | 00000000000000 | + +------------------------------------------------+----------------+ + + + The "subnet prefix" in an anycast address is the prefix which + identifies a specific link. This anycast address is syntactically + the same as a unicast address for an interface on the link with the + interface identifier set to zero. + + Packets sent to the Subnet-Router anycast address will be delivered + to one router on the subnet. All routers are required to support the + Subnet-Router anycast addresses for the subnets which they have + interfaces. + + + + +Hinden & Deering Standards Track [Page 13] + + +RFC 1884 IPv6 Addressing Architecture December 1995 + + + The subnet-router anycast address is intended to be used for + applications where a node needs to communicate with one of a set of + routers on a remote subnet. For example when a mobile host needs to + communicate with one of the mobile agents on it's "home" subnet. + + + 2.6 Multicast Addresses + + An IPv6 multicast address is an identifier for a group of nodes. A + node may belong to any number of multicast groups. Multicast + addresses have the following format: + + | 8 | 4 | 4 | 112 bits | + +------ -+----+----+---------------------------------------------+ + |11111111|flgs|scop| group ID | + +--------+----+----+---------------------------------------------+ + + 11111111 at the start of the address identifies the address as + being a multicast address. + + +-+-+-+-+ + flgs is a set of 4 flags: |0|0|0|T| + +-+-+-+-+ + + The high-order 3 flags are reserved, and must be + initialized to 0. + + T = 0 indicates a permanently-assigned ("well-known") + multicast address, assigned by the global internet + numbering authority. + + T = 1 indicates a non-permanently-assigned ("transient") + multicast address. + + scop is a 4-bit multicast scope value used to limit the scope of + the multicast group. The values are: + + 0 reserved + 1 node-local scope + 2 link-local scope + 3 (unassigned) + 4 (unassigned) + 5 site-local scope + 6 (unassigned) + 7 (unassigned) + 8 organization-local scope + 9 (unassigned) + A (unassigned) + + + +Hinden & Deering Standards Track [Page 14] + + +RFC 1884 IPv6 Addressing Architecture December 1995 + + + B (unassigned) + C (unassigned) + D (unassigned) + E global scope + F reserved + + group ID identifies the multicast group, either permanent or + transient, within the given scope. + + The "meaning" of a permanently-assigned multicast address is + independent of the scope value. For example, if the "NTP servers + group" is assigned a permanent multicast address with a group ID of + 43 (hex), then: + + FF01:0:0:0:0:0:0:43 means all NTP servers on the same node as + the sender. + + FF02:0:0:0:0:0:0:43 means all NTP servers on the same link as + the sender. + + FF05:0:0:0:0:0:0:43 means all NTP servers at the same site as + the sender. + + FF0E:0:0:0:0:0:0:43 means all NTP servers in the internet. + + Non-permanently-assigned multicast addresses are meaningful only + within a given scope. For example, a group identified by the non- + permanent, site-local multicast address FF15:0:0:0:0:0:0:43 at one + site bears no relationship to a group using the same address at a + different site, nor to a non-permanent group using the same group ID + with different scope, nor to a permanent group with the same group + ID. + + Multicast addresses must not be used as source addresses in IPv6 + datagrams or appear in any routing header. + + + 2.6.1 Pre-Defined Multicast Addresses + + The following well-known multicast addresses are pre-defined: + + Reserved Multicast Addresses: FF00:0:0:0:0:0:0:0 + FF01:0:0:0:0:0:0:0 + FF02:0:0:0:0:0:0:0 + FF03:0:0:0:0:0:0:0 + FF04:0:0:0:0:0:0:0 + FF05:0:0:0:0:0:0:0 + FF06:0:0:0:0:0:0:0 + + + +Hinden & Deering Standards Track [Page 15] + + +RFC 1884 IPv6 Addressing Architecture December 1995 + + + FF07:0:0:0:0:0:0:0 + FF08:0:0:0:0:0:0:0 + FF09:0:0:0:0:0:0:0 + FF0A:0:0:0:0:0:0:0 + FF0B:0:0:0:0:0:0:0 + FF0C:0:0:0:0:0:0:0 + FF0D:0:0:0:0:0:0:0 + FF0E:0:0:0:0:0:0:0 + FF0F:0:0:0:0:0:0:0 + + The above multicast addresses are reserved and shall never be + assigned to any multicast group. + + All Nodes Addresses: FF01:0:0:0:0:0:0:1 + FF02:0:0:0:0:0:0:1 + + The above multicast addresses identify the group of all IPv6 nodes, + within scope 1 (node-local) or 2 (link-local). + + All Routers Addresses: FF01:0:0:0:0:0:0:2 + FF02:0:0:0:0:0:0:2 + + The above multicast addresses identify the group of all IPv6 routers, + within scope 1 (node-local) or 2 (link-local). + + DHCP Server/Relay-Agent: FF02:0:0:0:0:0:0:C + + The above multicast addresses identify the group of all IPv6 DHCP + Servers and Relay Agents within scope 2 (link-local). + + Solicited-Node Address: FF02:0:0:0:0:1:XXXX:XXXX + + The above multicast address is computed as a function of a node's + unicast and anycast addresses. The solicited-node multicast address + is formed by taking the low-order 32 bits of the address (unicast or + anycast) and appending those bits to the 96-bit prefix FF02:0:0:0:0:1 + resulting in a multicast address in the range + + FF02:0:0:0:0:1:0000:0000 + + to + + FF02:0:0:0:0:1:FFFF:FFFF + + For example, the solicited node multicast address corresponding to + the IPv6 address 4037::01:800:200E:8C6C is FF02::1:200E:8C6C. IPv6 + addresses that differ only in the high-order bits, e.g., due to + multiple high-order prefixes associated with different providers, + + + +Hinden & Deering Standards Track [Page 16] + + +RFC 1884 IPv6 Addressing Architecture December 1995 + + + will map to the same solicited-node address thereby reducing the + number of multicast addresses a node must join. + + A node is required to compute and support a Solicited-Node multicast + addresses for every unicast and anycast address it is assigned. + + 2.7 A Node's Required Addresses + + A host is required to recognize the following addresses as + identifying itself: + + o Its Link-Local Address for each interface + o Assigned Unicast Addresses + o Loopback Address + o All-Nodes Multicast Address + o Solicited-Node Multicast Address for each of its assigned + unicast and anycast addresses + o Multicast Addresses of all other groups which the host belongs. + + A router is required to recognize the following addresses as + identifying itself: + + o Its Link-Local Address for each interface + o Assigned Unicast Addresses + o Loopback Address + o The Subnet-Router anycast addresses for the links it has + interfaces. + o All other Anycast addresses with which the router has been + configured. + o All-Nodes Multicast Address + o All-Router Multicast Address + o Solicited-Node Multicast Address for each of its assigned + unicast and anycast addresses + o Multicast Addresses of all other groups which the router + belongs. + + The only address prefixes which should be predefined in an + implementation are the: + + o Unspecified Address + o Loopback Address + o Multicast Prefix (FF) + o Local-Use Prefixes (Link-Local and Site-Local) + o Pre-Defined Multicast Addresses + o IPv4-Compatible Prefixes + + Implementations should assume all other addresses are unicast unless + specifically configured (e.g., anycast addresses). + + + +Hinden & Deering Standards Track [Page 17] + + +RFC 1884 IPv6 Addressing Architecture December 1995 + + +REFERENCES + + [ALLOC] Rekhter, Y., and T. Li, "An Architecture for IPv6 Unicast + Address Allocation", RFC 1887, cisco Systems, December + 1995. + + [ANYCST] Partridge, C., Mendez, T., and W. Milliken, "Host + Anycasting Service", RFC 1546, BBN, November 1993. + + [CIDR] Fuller, V., Li, T., Varadhan, K., and J. Yu, "Supernetting: + an Address Assignment and Aggregation Strategy", RFC 1338, + BARRNet, cisco, Merit, OARnet, June 1992. + + [IPV6] Deering, S., and R. Hinden, Editors, "Internet Protocol, + Version 6 (IPv6) Specification", RFC 1883, Xerox PARC, + Ipsilon Networks, December 1995. + + [MULT] Deering, S., "Host Extensions for IP multicasting", STD 5, + RFC 1112, Stanford University, August 1989. + + [NSAP] Carpenter, B., Editor, "Mechanisms for OSIN SAPs, CLNP and + TP over IPv6", Work in Progress. + + + +SECURITY CONSIDERATIONS + + Security issues are not discussed in this document. + + +DOCUMENT EDITOR'S ADDRESSES + + Robert M. Hinden Stephen E. Deering + Ipsilon Networks, Inc. Xerox Palo Alto Research Center + 2191 E. Bayshore Road, Suite 100 3333 Coyote Hill Road + Palo Alto, CA 94303 Palo Alto, CA 94304 + USA USA + + Phone: +1 415 846 4604 Phone: +1 415 812 4839 + Fax: +1 415 855 1414 Fax: +1 415 812 4471 + EMail: hinden@ipsilon.com EMail: deering@parc.xerox.com + + + + + + + + + + +Hinden & Deering Standards Track [Page 18] diff --git a/t/canon.t b/t/canon.t new file mode 100644 index 0000000..91b72c3 --- /dev/null +++ b/t/canon.t @@ -0,0 +1,23 @@ +use Test::More; + +my %cases = +( + '127.1' => '127.0.0.1', + 'DEAD:BEEF::1' => 'dead:beef::1', + + '1234:5678:90AB:CDEF:0123:4567:890A:BCDE' + => '1234:5678:90ab:cdef:123:4567:890a:bcde', +); + +my $tests = keys %cases; +plan tests => 1 + $tests; + +SKIP: { + use_ok('NetAddr::IP') or skip "Failed to load NetAddr::IP", $tests; + for my $c (sort keys %cases) + { + my $ip = new NetAddr::IP $c; + my $rv = $ip->canon; + is($rv, $cases{$c}, "canon($c ) returns $rv"); + } +} diff --git a/t/constants.t b/t/constants.t new file mode 100644 index 0000000..0c89474 --- /dev/null +++ b/t/constants.t @@ -0,0 +1,20 @@ + +#use diagnostics; +use Test::More tests => 15; +use NetAddr::IP qw(Zeros Zero Ones V4mask V4net); + +my %const = ( + '0::' => Zeros, + '::' => Zero, + 'FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF' => Ones, + 'FFFF:FFFF:FFFF:FFFF:FFFF:FFFF::' => V4mask, + '::FFFF:FFFF' => V4net, +); + +my($ip,$rv); +foreach (sort keys %const) { + ok(($ip = new NetAddr::IP($_)),"netaddr $_"); + ok($ip->{addr} eq $const{$_},"match $_"); + ok(($rv = length($const{$_})) == 16, "length $_ is $rv"); +} + diff --git a/t/full.t b/t/full.t new file mode 100644 index 0000000..a703671 --- /dev/null +++ b/t/full.t @@ -0,0 +1,25 @@ +use Test::More; + +# $Id: short.t,v 1.1.1.1 2006/08/14 15:36:06 lem Exp $ + +my %cases = +( + '127.1' => '0000:0000:0000:0000:0000:0000:127.0.0.1', + '123.23.4.210' => '0000:0000:0000:0000:0000:0000:123.23.4.210', + 'DEAD:BEEF::1' => 'dead:beef:0000:0000:0000:0000:0000:0001', + '1:2:3:4:5:6:7:8' => '0001:0002:0003:0004:0005:0006:0007:0008', + '1234:5678:90AB:CDEF:0123:4567:890A:BCDE' => '1234:5678:90ab:cdef:0123:4567:890a:bcde', +); + +my $tests = keys %cases; +plan tests => 1 + $tests; + +SKIP: { + use_ok('NetAddr::IP') or skip "Failed to load NetAddr::IP", $tests; + for my $c (sort keys %cases) + { + my $ip = new NetAddr::IP $c; + my $rv = lc $ip->full; + is($rv, $cases{$c}, "full($c) returns $rv"); + } +} diff --git a/t/full6-uri.t b/t/full6-uri.t new file mode 100644 index 0000000..ce3d7ec --- /dev/null +++ b/t/full6-uri.t @@ -0,0 +1,25 @@ +use Test::More; + +# $Id: short.t,v 1.1.1.1 2006/08/14 15:36:06 lem Exp $ + +my %cases = +( + '127.1' => '0000:0000:0000:0000:0000:0000:7f00:0001', + '123.23.4.210' => '0000:0000:0000:0000:0000:0000:7b17:04d2', + '[DEAD:BEEF::1]' => 'dead:beef:0000:0000:0000:0000:0000:0001', + '[1:2:3:4:5:6:7:8]' => '0001:0002:0003:0004:0005:0006:0007:0008', + '[1234:5678:90AB:CDEF:0123:4567:890A:BCDE]' => '1234:5678:90ab:cdef:0123:4567:890a:bcde', +); + +my $tests = keys %cases; +plan tests => 1 + $tests; + +SKIP: { + use_ok('NetAddr::IP') or skip "Failed to load NetAddr::IP", $tests; + for my $c (sort keys %cases) + { + my $ip = new NetAddr::IP $c; + my $rv = lc $ip->full6; + is($rv, $cases{$c}, "full6($c ) returns $rv"); + } +} diff --git a/t/full6.t b/t/full6.t new file mode 100644 index 0000000..e2a1be1 --- /dev/null +++ b/t/full6.t @@ -0,0 +1,25 @@ +use Test::More; + +# $Id: short.t,v 1.1.1.1 2006/08/14 15:36:06 lem Exp $ + +my %cases = +( + '127.1' => '0000:0000:0000:0000:0000:0000:7f00:0001', + '123.23.4.210' => '0000:0000:0000:0000:0000:0000:7b17:04d2', + 'DEAD:BEEF::1' => 'dead:beef:0000:0000:0000:0000:0000:0001', + '1:2:3:4:5:6:7:8' => '0001:0002:0003:0004:0005:0006:0007:0008', + '1234:5678:90AB:CDEF:0123:4567:890A:BCDE' => '1234:5678:90ab:cdef:0123:4567:890a:bcde', +); + +my $tests = keys %cases; +plan tests => 1 + $tests; + +SKIP: { + use_ok('NetAddr::IP') or skip "Failed to load NetAddr::IP", $tests; + for my $c (sort keys %cases) + { + my $ip = new NetAddr::IP $c; + my $rv = lc $ip->full6; + is($rv, $cases{$c}, "full6($c ) returns $rv"); + } +} diff --git a/t/imhoff.t b/t/imhoff.t new file mode 100644 index 0000000..7aafbdc --- /dev/null +++ b/t/imhoff.t @@ -0,0 +1,35 @@ +#!/usr/bin/perl + +# This code was provided by Brent Imhoff and adapted to become a real test. +# What this excercises, is that ::compact() should provide the same result +# without caring about the order of its arguments. -lem + +use strict; +#use warnings; +use Test::More tests => 3; +use NetAddr::IP qw(Compact); + +my @temp = ; + +my @sortreg = sort @temp; +my @sortdec = sort { $b cmp $a} @temp; +my @sortnum = sort { $a cmp $b} @temp; + +my $sortnum = Compact(map { NetAddr::IP->new($_) } @sortnum); +my $sorttag = Compact(map { NetAddr::IP->new($_) } @sortreg); +my $sortdec = Compact(map { NetAddr::IP->new($_) } @sortdec); + +is($sortnum, $sorttag); +is($sortnum, $sortdec); +is($sortdec, $sorttag); # I know this one is redundant + +__END__ +205.170.190.0/24 +216.175.9.0/24 +205.170.188.0/24 +206.175.9.0/24 +205.170.0.0/20 +205.170.0.0/19 +205.170.0.0/18 +205.170.0.0/17 +205.170.0.0/16 diff --git a/t/loops.t b/t/loops.t new file mode 100644 index 0000000..d501e35 --- /dev/null +++ b/t/loops.t @@ -0,0 +1,33 @@ +# $Id: loops.t,v 1.2 2006/08/16 19:17:01 lem Exp $ + +use Test::More; + +my @deltas = (0, 1, 2, 3, 255); + +plan tests => 16 + @deltas; + +use_ok('NetAddr::IP'); +my $count = 1; + +for (my $ip = new NetAddr::IP '10.0.0.1/28'; + $ip < $ip->broadcast; + $ip ++) +{ + my $o = $ip->addr; + + $o =~ s/^.+\.(\d+)$/$1/; + is($o, $count, "Correct octet for " . $ip); + ++ $count; +} + +my $ip = new NetAddr::IP '10.0.0.255/24'; +$ip ++; + +is($ip, '10.0.0.0/24', "Correct mask wraparound"); + +$ip = new NetAddr::IP '10.0.0.0/24'; + +for my $v (@deltas) { + my $target = '10.0.0.' . $v . '/24'; + is($ip + $v, '10.0.0.' . $v . '/24', "$ip + $v vs $target"); +} diff --git a/t/lower.t b/t/lower.t new file mode 100644 index 0000000..6e09e0c --- /dev/null +++ b/t/lower.t @@ -0,0 +1,11 @@ + +#use diagnostics; +use Test::More tests => 2; + +use_ok ('NetAddr::IP', qw(:lower)); + +my $exp = 'ff:0:0:0:0:0:0:eeaa/128'; +my $ip = new NetAddr::IP('FF::eeAA'); +my $got = sprintf $ip; +ok ($got eq $exp,"lower case $got"); + diff --git a/t/masklen.t b/t/masklen.t new file mode 100644 index 0000000..5457380 --- /dev/null +++ b/t/masklen.t @@ -0,0 +1,21 @@ +use NetAddr::IP; + +# $Id: masklen.t,v 1.1.1.1 2006/08/14 15:36:06 lem Exp $ + +my @masks = 0 .. 32; + +$| = 1; + +print '1..', scalar @masks, "\n"; + +my $count = 1; + +for my $m (@masks) { + my $ip = new NetAddr::IP '10.0.0.1', $m; + if ($ip->masklen == $m) { + print "ok ", $count ++, "\n"; + } + else { + print "not ok ", $count ++, "\n"; + } +} diff --git a/t/new-store.t b/t/new-store.t new file mode 100644 index 0000000..0875062 --- /dev/null +++ b/t/new-store.t @@ -0,0 +1,40 @@ +# t/new-store.t - test new Storable related - methods + +use Test::More; + +my $tests = 7; + +plan tests => $tests; + +SKIP: +{ + skip "Failed to use Storable, module not found", $tests + unless eval {require Storable && use_ok("Storable", 'freeze', 'thaw')}; + + skip "Failed to use NetAddr::IP", $tests + unless use_ok("NetAddr::IP"); + + my $oip = new NetAddr::IP "localhost"; + my $nip; + + isa_ok($oip, 'NetAddr::IP', 'Correct return type'); + + my $serialized; + + eval { $serialized = freeze($oip) }; + unless (ok(!$@, "Freezing")) + { + diag $@; + } + +# diag "Result is '$serialized'"; + + eval { $nip = thaw($serialized) }; + unless (ok(!$@, "Thawing")) + { + diag $@; + } + + isa_ok($nip, 'NetAddr::IP', 'Recovered correct type'); + is("$nip", "$oip", "New object eq original object"); +} diff --git a/t/nofqdn.t b/t/nofqdn.t new file mode 100644 index 0000000..7d0c8d1 --- /dev/null +++ b/t/nofqdn.t @@ -0,0 +1,29 @@ + + +use NetAddr::IP; + +$| = 1; + +print "1..1\n"; + +my $test = 1; +sub ok() { + print 'ok ',$test++,"\n"; +} + + +my $ip = new NetAddr::IP('arin.net'); +if (defined $ip) { + print "ok $test # Skipped, resolved $ip\n"; + $test++; +} else { + print "ok $test # Skipped, resolver not working\n"; + $test++; +} + +#import NetAddr::IP qw(:nofqdn); +# +#$ip = new NetAddr::IP('arin.net'); +#print "unexpected response with :nofqdn\nnot " +# if defined $ip; +#&ok; diff --git a/t/old-store.t b/t/old-store.t new file mode 100644 index 0000000..598c90c --- /dev/null +++ b/t/old-store.t @@ -0,0 +1,40 @@ +# t/old-store.t - test backwards compatible Storable interaction + +use Test::More; + +my $tests = 7; + +plan tests => $tests; + +SKIP: +{ + skip "Failed to use Storable, module not found", $tests + unless eval { require Storable && use_ok("Storable", 'freeze', 'thaw')}; + + skip "Failed to use NetAddr::IP", $tests + unless use_ok("NetAddr::IP", ':old_storable'); + + my $oip = new NetAddr::IP "localhost"; + my $nip; + + isa_ok($oip, 'NetAddr::IP', 'Correct return type'); + + my $serialized; + + eval { $serialized = freeze($oip) }; + unless (ok(!$@, "Freezing")) + { + diag $@; + } + +# diag "Result is '$serialized'"; + + eval { $nip = thaw($serialized) }; + unless (ok(!$@, "Thawing")) + { + diag $@; + } + + isa_ok($nip, 'NetAddr::IP', 'Recovered correct type'); + is("$nip", "$oip", "New object eq original object"); +} diff --git a/t/over-arr.t b/t/over-arr.t new file mode 100644 index 0000000..386d320 --- /dev/null +++ b/t/over-arr.t @@ -0,0 +1,20 @@ +use NetAddr::IP; +use Test::More; + +my @addr = ( [ '10.0.0.0/24', '10.0.0.1/32' ], + [ '192.168.0.0/24', '192.168.0.1/32' ], + [ '127.0.0.1/32', '127.0.0.1/32' ] ); + +$| = 1; + +$tests = @addr; + +plan tests => $tests; + +SKIP: { + skip "overload dereferencing not supported in version $] of Perl", $tests, unless ($overload::ops{dereferencing} && $overload::ops{dereferencing} =~ /\@\{\}/); + for my $a (@addr) { + my $ip = new NetAddr::IP $a->[0]; + ok(@$ip[0]->cidr eq $a->[1],$a->[0]); + } +}; diff --git a/t/over-qq.t b/t/over-qq.t new file mode 100644 index 0000000..b427f22 --- /dev/null +++ b/t/over-qq.t @@ -0,0 +1,55 @@ +use NetAddr::IP; + +# $Id: over-qq.t,v 1.1.1.1 2006/08/14 15:36:06 lem Exp $ + +my @addr = ('10.0.0.0/8', '192.168.0.0/16', '127.0.0.1/32'); + +$| = 1; + +print "1..", 5 * scalar @addr, "\n"; + +my $count = 1; + +for my $a (@addr) { + my $ip = new NetAddr::IP $a; + if ($a eq "$ip") { + print "ok $count\n"; + } + else { + print "not ok $count\n"; + } + ++ $count; + + if ($a eq $ip) { + print "ok $count\n"; + } + else { + print "not ok $count\n"; + } + ++ $count; + + if ($ip eq $a) { + print "ok $count\n"; + } + else { + print "not ok $count\n"; + } + ++ $count; + + if ($ip eq $ip) { + print "ok $count\n"; + } + else { + print "not ok $count\n"; + } + ++ $count; + + if ($ip == $ip) { + print "ok $count\n"; + } + else { + print "not ok $count\n"; + } + ++ $count; + +} diff --git a/t/relops.t b/t/relops.t new file mode 100644 index 0000000..8d392c0 --- /dev/null +++ b/t/relops.t @@ -0,0 +1,59 @@ +use NetAddr::IP; + +BEGIN { +@gt = ( + [ '255.255.255.255/32', '0.0.0.0/0' ], + [ 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff', '::/0' ], + [ '10.0.1.0/16', '10.0.0.1/24' ], + [ '10.0.0.1/24', '10.0.0.0/24' ], + [ 'deaf:beef::1/64', 'dead:beef::/64' ], + ); + +@ngt = ( + [ '0.0.0.0/0', '255.255.255.255/32' ], + [ '::/0', 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff' ], + [ '10.0.0.0/24', '10.0.0.0/24' ], + [ 'dead:beef::/60', 'dead:beef::/60' ], + ); + +@cmp = ( + [ '0.0.0.0/0', '255.255.255.255/32', -1 ], + [ '::/0', 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff', -1 ], + [ '10.0.0.0/16', '10.0.0.0/8', 1 ], + [ 'dead:beef::/60', 'dead:beef::/40', 1 ], + [ '10.0.0.0/24', '10.0.0.0/8', 1 ], + [ '255.255.255.255/32', '0.0.0.0/0', 1 ], + [ 'ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff', '::/0', 1 ], + [ '142.52.5.87', '142.52.2.88', 1 ], + [ '10.0.0.0/24', '10.0.0.0/24', 0 ], + [ 'default', 'default', 0 ], + [ 'broadcast', 'broadcast', 0], + [ 'loopback', 'loopback', 0], + ); + +}; + +use Test::More tests => @gt + @ngt + (2 * @cmp); + +for my $a (@gt) { + $a_ip = new NetAddr::IP::Lite $a->[0]; + $b_ip = new NetAddr::IP::Lite $a->[1]; + + ok($a_ip > $b_ip, "$a_ip > $b_ip"); +} + +for my $a (@ngt) { + $a_ip = new NetAddr::IP::Lite $a->[0]; + $b_ip = new NetAddr::IP::Lite $a->[1]; + + ok(!($a_ip > $b_ip), "$a_ip !> $b_ip"); +} + +for $a (@cmp) { + $a_ip = new NetAddr::IP::Lite $a->[0]; + $b_ip = new NetAddr::IP::Lite $a->[1]; + + is($a_ip <=> $b_ip, $a->[2], "$a_ip <=> $b_ip is $a->[2]"); + is($a_ip cmp $b_ip, $a->[2], "$a_ip cmp $b_ip is $a->[2]"); +} + diff --git a/t/rfc3021.t b/t/rfc3021.t new file mode 100644 index 0000000..b955d47 --- /dev/null +++ b/t/rfc3021.t @@ -0,0 +1,31 @@ +use NetAddr::IP; + +$| = 1; + +print '1..4', "\n"; + +my $test = 1; + +my $ip = new NetAddr::IP('192.168.1.8/31'); +my @hosts = $ip->hostenum; + +print scalar(@hosts)," found where none expected\nnot " + if @hosts; +print "ok ",$test++,"\n"; + +NetAddr::IP::import qw(:rfc3021); + +@hosts = $ip->hostenum; + +print scalar(@hosts)," found where 2 expected\nnot " + unless @hosts == 2; +print "ok ",$test++,"\n"; + +print "got: $hosts[0], exp: 192.168.1.8/32\nnot " + unless "$hosts[0]" eq '192.168.1.8/32'; +print "ok ",$test++,"\n"; + +print "got: $hosts[1], exp: 192.168.1.9/32\nnot " + unless "$hosts[1]" eq '192.168.1.9/32'; +print "ok ",$test++,"\n"; + diff --git a/t/short.t b/t/short.t new file mode 100644 index 0000000..5c2be50 --- /dev/null +++ b/t/short.t @@ -0,0 +1,57 @@ +use Test::More; + +# $Id: short.t,v 1.1.1.1 2006/08/14 15:36:06 lem Exp $ + +my %cases = qw( + 127.1 127.0.0.1 + 127.0.1.1 127.0.1.1 + 127.1.0.1 127.1.0.1 + DEAD:BEEF::1 dead:beef::1 + ::1 0:0::1 + 2001:620:600::1 2001:620:600::1 + 2001:620:600:0:1::1 2001:620:600:0:1::1 + 2001:620:601:0:1::1 2001:620:601::1:0:0:1 + 0:0:33:44::CC:DD 0:0:33:44:0:0:CC:DD + 0:0:33:44::DD 0:0:33:44:0:0:0:DD + 0:0:33:44:AA:: 0:0:33:44:AA:0:0:0 + 0:0:33::BB:0:0 0:0:33:0:0:BB:0:0 + 0:22:33:44:0:BB:CC:0 0:22:33:44:0:BB:CC:0 + 0:22:33:44:0:BB:CC:DD 0:22:33:44:0:BB:CC:DD + 0:22:33:44:AA:BB:CC:0 0:22:33:44:AA:BB:CC:0 + 0:22:33:44:AA:BB:CC:DD 0:22:33:44:AA:BB:CC:DD + 110:0:0:44:AA:: 110:0:0:44:AA:0:0:0 + 11:0:33:44:0:BB:CC:DD 11:0:33:44:0:BB:CC:DD + 11:0:33:44:AA:BB:CC:DD 11:0:33:44:AA:BB:CC:DD + 11:22:0:44:AA::DD 11:22:0:44:AA:0:0:DD + 11:22:33:0:AA:BB:CC:0 11:22:33:0:AA:BB:CC:0 + 11:22:33:44:AA:: 11:22:33:44:AA:0:0:0 + 11:22::CC:DD 11:22:0:0:0:0:CC:DD + 11::44:AA:0:0:DD 11:0:0:44:AA:0:0:DD + 11::44:AA:BB:0:0 11:0:0:44:AA:BB:0:0 + 11::AA:0:0:DD 11:0:0:0:AA:0:0:DD + 11::AA:BB:0:0 11:0:0:0:AA:BB:0:0 + 1:: 1:0:0:0:0:0:0:0 + :: 0:0:0:0:0:0:0:0 + ::33:44:AA:BB:0:0 0:0:33:44:AA:BB:0:0 + ::44:0:0:CC:DD 0:0:0:44:0:0:CC:DD + ::44:AA:BB:0:0 0:0:0:44:AA:BB:0:0 + ::44:AA:BB:CC:DD 0:0:0:44:AA:BB:CC:DD + ::A 0:0:0:0:0:0:0:A + ); + +my $tests = 2 * keys %cases; +plan tests => 1 + $tests; + +SKIP: { + use_ok('NetAddr::IP') or skip "Failed to load NetAddr::IP", $tests; + for my $c (sort keys %cases) + { + my $ip = new NetAddr::IP $cases{$c}; + isa_ok($ip, 'NetAddr::IP', "$cases{$c}"); + my $short = uc $ip->short; + unless (is($short, $c, "short($cases{$c}) returns $short")) + { + diag "ip=$ip"; + } + } +} diff --git a/t/splitref.t b/t/splitref.t new file mode 100644 index 0000000..f487b2e --- /dev/null +++ b/t/splitref.t @@ -0,0 +1,27 @@ + +use Test::More qw(no_plan); #tests => 28; + +use_ok('NetAddr::IP'); + +my $ip = new NetAddr::IP('ffff:a123:b345:c789::/48'); +my $rv; +ok(($rv = sprintf("%s",$ip)) eq 'FFFF:A123:B345:C789:0:0:0:0/48',"$rv eq FFFF:A123:B345:C789:0:0:0:0/48"); +my $nets = $ip->splitref(48); +ok($nets,'there is a net'); +ok(@$nets == 1,'one item net'); +ok(($rv = sprintf("%s",$ip)) eq 'FFFF:A123:B345:C789:0:0:0:0/48',"$rv eq FFFF:A123:B345:C789:0:0:0:0/48"); + +$nets = $ip->splitref(49,50); +ok($nets,'there are nets'); +ok(($rv = @$nets) == 3,"$rv is 3 item net"); + +my @exp = qw( + FFFF:A123:B345:0:0:0:0:0/49 + FFFF:A123:B345:8000:0:0:0:0/50 + FFFF:A123:B345:C000:0:0:0:0/50 +); + +foreach(0..$#{$nets}) { + ok(($rv = sprintf("%s",$nets->[$_])) eq $exp[$_], "$rv eq $exp[$_]"); +} + diff --git a/t/v4-coalesce.t b/t/v4-coalesce.t new file mode 100644 index 0000000..61d3d77 --- /dev/null +++ b/t/v4-coalesce.t @@ -0,0 +1,54 @@ +use Test::More; + +if (defined($ENV{LIGHTERIPTESTS}) and $ENV{LIGHTERIPTESTS} =~ /yes/i) { + print "1..0 # Skipped: LIGHTERIPTESTS = yes\n"; + exit 0; +} + +plan tests => 21; + +die "# Cannot continue without NetAddr::IP\n" + unless use_ok('NetAddr::IP', 'Coalesce'); + +# Test a rather large set... + +my @ips = (); + +for my $o (0 .. 255) +{ + push @ips, new NetAddr::IP "10.0.$o.1"; + push @ips, new NetAddr::IP "10.0.$o.10"; + push @ips, new NetAddr::IP "10.0.$o.100"; +} + +sub tst { +# This should return the empty list... + my $r = Coalesce(24, 4, @ips); + diag "Coalesce returned $r" + unless isa_ok($r, 'ARRAY', 'Return type from Coalesce'); + is(@$r, 0, "Empty array returned as expected"); + +# This should produce a list with all the /24s + $r = Coalesce(24, 2, @ips); + diag "Coalesce returned $r" + unless isa_ok($r, 'ARRAY', 'Return type from Coalesce'); + is(@$r, 256, "Whole result set as expected"); + my @c = NetAddr::IP::Compact(@$r); + is(@c, 1, "Results are compactable"); + ok($c[0] eq '10.0.0.0/16', "Correct results"); + +# This should produce the same result as before, with an added /23 + $r = Coalesce(24, 2, @ips, NetAddr::IP->new('10.0.0.125/23')); + diag "Coalesce returned $r" + unless isa_ok($r, 'ARRAY', 'Return type from Coalesce'); + ok((grep { $_ eq '10.0.0.0/23' } @$r), "/23 went through"); + @c = NetAddr::IP::Compact(@$r); + is(@c, 1, "Results are compactable"); + ok($c[0] eq '10.0.0.0/16', "Correct results"); +} + +tst(); + +import NetAddr::IP qw(:old_nth); + +tst(); diff --git a/t/v4-compact.t b/t/v4-compact.t new file mode 100644 index 0000000..feca1de --- /dev/null +++ b/t/v4-compact.t @@ -0,0 +1,110 @@ +use NetAddr::IP qw(Compact); + +# $Id: v4-compact.t,v 1.1.1.1 2006/08/14 15:36:06 lem Exp $ + +my @r = ( + [ '10.0.0.0', '255.255.255.0'], + [ '11.0.0.0', '255.255.255.0'], + [ '12.0.0.0', '255.255.255.0'], + [ '20.0.0.0', '255.255.0.0'], + [ '30.0.0.0', '255.255.0.0'], + [ '40.0.0.0', '255.255.0.0'], + ); + +$| = 1; + +if (defined($ENV{LIGHTERIPTESTS}) and $ENV{LIGHTERIPTESTS} =~ /yes/i) { + print "1..0 # Skipped: LIGHTERIPTESTS = yes\n"; + exit 0; +} + +print "1..9\n"; + +my @ips1; + +for my $ip ('10.0.0.0', '11.0.0.0', '12.0.0.0') { + push @ips1, NetAddr::IP->new($ip, 24)->split(32); +} + +for my $ip ('20.0.0.0', '30.0.0.0', '40.0.0.0') { + push @ips1, NetAddr::IP->new($ip, 16)->split(28); +} + +my @ips2; + +for my $num (0 .. 255) { + push @ips2, NetAddr::IP->new("192.168.$num.0", 24); +} +my $ips2_compact = '192.168.0.0/16'; + +# Compact(@) +# +compact_ips1_check(1, Compact(@ips1)); +compact_ips2_check(2, Compact(@ips2)); + +# ->compact(@) +# +compact_ips1_check(3, $ips1[0]->compact(@ips1[1..$#ips1])); +compact_ips2_check(4, $ips2[0]->compact(@ips2[1..$#ips2])); + +# Compact([]) +# +compact_ips1_check(5, @{Compact(\@ips1)}); +compact_ips2_check(6, @{Compact(\@ips2)}); + +# ->compactref([]) +# +compact_ips1_check(7, @{$ips1[0]->compactref([@ips1[1..$#ips1]])}); +compact_ips2_check(8, @{$ips2[0]->compactref([@ips2[1..$#ips2]])}); + +# duplicate IP +# +@ips1 = (); + +for my $ip (qw(1.1.1.1 1.1.1.1 1.1.1.1 1.1.1.1)) { + push(@ips1, NetAddr::IP->new($ip)); +} + +@c = NetAddr::IP::compact(@ips1); + +if (@c == 1 and $c[0]->cidr() eq '1.1.1.1/32') { + print "ok 9\n"; +} +else { + print "not ok 9\n"; +} + + +###################################################################### +sub compact_ips1_check +{ + my $num = shift; + my @ips = shift; + + my @mips; + for my $ip (@ips) { + push @mips, grep { $ip->addr eq $_->[0] and $ip->mask eq $_->[1] } @r; + } + + if (@mips == @ips) { + print "ok $num\n"; + } + else { + print "not ok $num\n"; + } +} + + +###################################################################### +sub compact_ips2_check +{ + my $num = shift; + my @ips = shift; + + if (@ips == 1 and $ips[0] eq $ips2_compact) { + print "ok $num\n"; + } + else { + print "not ok $num\n"; + } +} diff --git a/t/v4-compplus.t b/t/v4-compplus.t new file mode 100644 index 0000000..0902afe --- /dev/null +++ b/t/v4-compplus.t @@ -0,0 +1,35 @@ +use NetAddr::IP; + +# $Id: v4-compplus.t,v 1.1.1.1 2006/08/14 15:36:06 lem Exp $ + +$| = 1; + +print "1..50\n"; + +my $count = 1; + +for my $bits (8 .. 32) { + my $large = new NetAddr::IP '10.0.0.0/8'; + my $small = new NetAddr::IP '10.0.0.0', $bits; + + my @c = NetAddr::IP::compact($large, $small); + + if (@c == 1) { + print "ok $count\n"; + } + else { + print "not ok $count\n"; + } + + ++$count; + + if ($c[0]->cidr eq '10.0.0.0/8') { + print "ok $count\n"; + } + else { + print "not ok $count\n"; + } + + ++$count; +} + diff --git a/t/v4-hostenum.t b/t/v4-hostenum.t new file mode 100644 index 0000000..5033156 --- /dev/null +++ b/t/v4-hostenum.t @@ -0,0 +1,50 @@ +use NetAddr::IP; + +# $Id: v4-hostenum.t,v 1.1.1.1 2006/08/14 15:36:06 lem Exp $ + +my %addr = ( + '10.0.0.0' => [ '255.255.255.252', + [ + '10.0.0.1', '10.0.0.2', + ]], + '11.0.0.0' => [ '255.255.255.255', + [ + '11.0.0.0', + ]], + '12.0.0.0' => [ '255.255.255.0', + []], + ); + +for my $o (1..254) { + push @{$addr{'12.0.0.0'}->[1]}, '12.0.0.' . $o; +} + +my $count = $| = 1; +print "1..", (2 * scalar keys %addr), "\n"; + +for my $a (keys %addr) { + my $ip = new NetAddr::IP $a, $addr{$a}->[0]; + my @r = $ip->hostenum; + my @m = (); + + if (scalar @r == @{$addr{$a}->[1]}) { + print "ok ", $count++, "\n"; + } + else { + print "not ok ", $count++, " (number $a)\n"; + } + + for my $r (@r) { + push @m, grep { $_ eq $r->addr } @{$addr{$a}->[1]}; + } + + if (scalar @m == scalar @r) { + print "ok ", $count++, "\n"; + } + else { + print "not ok ", $count++, " (match $a)\n"; + print "henum=", join(', ', (map { $_->addr } @r)), "\n"; + print "match=", join(', ', @m), "\n"; + + } +} diff --git a/t/v4-re.t b/t/v4-re.t new file mode 100644 index 0000000..e97c11a --- /dev/null +++ b/t/v4-re.t @@ -0,0 +1,38 @@ +use Test::More; + +# $Id: v4-re.t,v 1.1.1.1 2006/08/14 15:36:06 lem Exp $ + +my @ips = qw! + 10.11.12.13 + 10.11.12/24 + 10.11.0/27 + !; + +plan tests => 299; + +die "# Cannot continue without NetAddr::IP\n" + unless use_ok('NetAddr::IP'); + +my @addrs = map { new NetAddr::IP $_ } @ips; + +for my $a (@addrs) +{ + isa_ok($a, 'NetAddr::IP'); + my $re = $a->re; + my $rx; + + eval { $rx = qr/$re/ }; + diag "Compilation of the resulting regular expression failed: $@" + unless ok(!$@, "Compilation of the resulting regular expression"); + + for (my $ip = $a->network; + $ip < $a->broadcast && $a->masklen != 32; + $ip ++) + { + ok($a->addr =~ m/$rx/, "Match of $ip in $a"); + } + + ok($a->broadcast->addr =~ m/$rx/, "Match of broadcast of $a"); + ok(NetAddr::IP->new('default') !~ m/$rx/, "0/0 does not match"); +} + diff --git a/t/v4-split-bulk.t b/t/v4-split-bulk.t new file mode 100644 index 0000000..c0bb650 --- /dev/null +++ b/t/v4-split-bulk.t @@ -0,0 +1,23 @@ +use Test::More; +use NetAddr::IP; + +# $Id: v4-split-bulk.t,v 1.1.1.1 2006/08/14 15:36:06 lem Exp $ + +my @addr = ( [ '10.0.0.0', 20, 32, 4096 ], + [ '10.0.0.0', 22, 32, 1024 ], + [ '10.0.0.0', 22, 24, 4 ], + [ '10.0.0.0', 22, 23, 2 ], + [ '10.0.0.0', 24, 32, 256 ], + [ '10.0.0.0', 19, 32, 8192 ], + [ '10.0.0.0', 24, 24, 1 ], + [ '10.0.0.0', 31, 32, 2 ] + ); + +plan tests => (scalar @addr); + +for my $a (@addr) { + my $ip = new NetAddr::IP $a->[0], $a->[1]; + my $r = $ip->splitref($a->[2]); + + is(@$r, $a->[3]); +} diff --git a/t/v4-split-list.t b/t/v4-split-list.t new file mode 100644 index 0000000..ac7660a --- /dev/null +++ b/t/v4-split-list.t @@ -0,0 +1,54 @@ +use NetAddr::IP; + +# $Id: v4-split-list.t,v 1.1.1.1 2006/08/14 15:36:06 lem Exp $ + +my %addr = ( + '10.0.0.10' => [ '255.255.252.0', 24, + [ + '10.0.0.0', '10.0.1.0', + '10.0.2.0', '10.0.3.0' + ]], + '10.0.0.1' => [ '255.255.255.254', 32, + [ + '10.0.0.0', '10.0.0.1', + ]], + '10.0.0.2' => [ '255.255.255.255', 32, + [ + '10.0.0.2', + ]], + '10.0.0.3' => [ '255.255.255.252', 32, + [ + '10.0.0.0', '10.0.0.1', + '10.0.0.2', '10.0.0.3', + ]], + ); + +my $count = $| = 1; +print "1..", (2 * scalar keys %addr), "\n"; + +for my $a (keys %addr) { + my $ip = new NetAddr::IP $a, $addr{$a}->[0]; + my @r = $ip->split($addr{$a}->[1]); + my @m = (); + + if (scalar @r == @{$addr{$a}->[2]}) { + print "ok ", $count++, "\n"; + } + else { + print "not ok ", $count++, " (number $a)\n"; + } + + for my $r (@r) { + push @m, grep { $_ eq $r->addr } @{$addr{$a}->[2]}; + } + + if (scalar @m == scalar @r) { + print "ok ", $count++, "\n"; + } + else { + print "not ok ", $count++, " (match $a)\n"; + print "split=", join(', ', (map { $_->addr } @r)), "\n"; + print "match=", join(', ', @m), "\n"; + + } +} diff --git a/t/v4-splitplan.t b/t/v4-splitplan.t new file mode 100644 index 0000000..d8fc69d --- /dev/null +++ b/t/v4-splitplan.t @@ -0,0 +1,73 @@ + +use Test::More tests => 28; + +use_ok('NetAddr::IP'); + +my $ip = new NetAddr::IP('192.168.21.13/15'); +my $rv; +ok(($rv = sprintf("%s",$ip)) eq '192.168.21.13/15',"$rv eq 192.168.21.13/15"); + +my($plan,$masks) = $ip->_splitplan(15); +ok($plan,'there is a plan'); +ok(!$masks,'plan returns the orignal net'); +ok(@$plan == 1,'one item plan'); +ok(($rv = $plan->[0]) == 15,"plan $rv is original cidr 15"); + +my $cmask = new NetAddr::IP('255.126.0.0'); +ok(($rv = sprintf("%s",$cmask)) eq '255.126.0.0/32',"$rv eq 255.126.0.0/32"); + +($plan,$masks) = $ip->_splitplan($cmask); +ok(!$plan,'failing because of bits in mask'); + +$cmask = new NetAddr::IP('255.254.0.0'); +ok(($rv = sprintf("%s",$cmask)) eq '255.254.0.0/32',"$rv eq 255.254.0.0/32"); + +($plan,$masks) = $ip->_splitplan($cmask); +ok($plan,'there is a plan'); + +ok(!$masks,'plan returns the orignal net'); +ok(@$plan == 1,'one item plan'); +ok(($rv = $plan->[0]) == 15,"plan $rv is original cidr 15"); + +$cmask = '255.254.0.0'; # ipV4 text cmask +($plan,$masks) = $ip->_splitplan($cmask); +ok($plan,'there is a plan'); +ok(!$masks,'plan returns the orignal net'); +ok(@$plan == 1,'one item plan'); +ok(($rv = $plan->[0]) == 15,"plan $rv is original cidr 15"); + +$cmask = '255.126.0.0'; # ipV4 text cmask +($plan,$masks) = $ip->_splitplan($cmask); +ok(!$plan,'failing because of bits in mask'); + +$cmask = 'garbage'; +($plan,$masks) = $ip->_splitplan($cmask); +ok(!$plan,'failing because of garbage'); + +$cmask = 14; # cidr is bigger than requested +($plan,$masks) = $ip->_splitplan($cmask); +ok(!$plan,'failing because of 15 overange'); + +# cidr makes more nets than 2**16 +($plan,$masks) = $ip->_splitplan(32); +ok(!$plan,'failing to many nets 32 - 15 = 2**17'); + +($plan,$masks) = $ip->_splitplan(16,16,16); +ok(!$plan,'failing because of 3 * 16 overange'); + +# test for plan that just fits +($plan,$masks) = $ip->_splitplan(31); +ok($plan,'there is a plan 31'); +ok($masks,'plan has masks'); +ok(($rv = @{$plan}) == 2 ** 16,"$rv should = 65536"); + +# set netlimit internal to 4 nets +$NetAddr::IP::_netlimit = 4; +($plan,$masks) = $ip->_splitplan(17); # should fit +ok($plan,"plan of 4 17's"); + +($plan,$masks) = $ip->_splitplan(17,17,17,17,18); +ok(!plan,"fail plan of 4 17's + 18"); + +($plan,$masks) = $ip->_splitplan(18); +ok(!plan,"fail plan of 8 18's"); diff --git a/t/v4-sprefix.t b/t/v4-sprefix.t new file mode 100644 index 0000000..718e511 --- /dev/null +++ b/t/v4-sprefix.t @@ -0,0 +1,51 @@ +use NetAddr::IP; + +# $Id: v4-sprefix.t,v 1.1.1.1 2006/08/14 15:36:06 lem Exp $ + +my @addr = ( + [ '10.', '10.0.0.0/8' ], + [ '11.11.', '11.11.0.0/16' ], + [ '12.12.12.', '12.12.12.0/24' ], + [ '13.13.13.13', '13.13.13.13/32' ], + ); + +$| = 1; +print "1..", (3 * scalar @addr), "\n"; + +my $count = 1; + +for my $a (@addr) { + my $ip = new NetAddr::IP $a->[0]; + + if ($ip->cidr eq $a->[1]) { + print "ok $count\n"; + } + else { + print "not ok $count\n"; + } + + ++ $count; + + my $p = new NetAddr::IP $ip->cidr; + + if ($p->prefix eq $a->[0]) { + print "ok $count\n"; + } + else { + print "not ok $count\n"; + } + + ++ $count; + + if ($p->nprefix eq $a->[0]) { + print "ok $count\n"; + } + else { + print "not ok $count\n"; + } + + ++ $count; + +} + + diff --git a/t/v4-xprefix.t b/t/v4-xprefix.t new file mode 100644 index 0000000..3fce3cb --- /dev/null +++ b/t/v4-xprefix.t @@ -0,0 +1,48 @@ +use NetAddr::IP; + +# $Id: v4-xprefix.t,v 1.1.1.1 2006/08/14 15:36:06 lem Exp $ + +my @addr = ( + [ '0.0.0.0/1', '0-127' ], + [ '128.0.0.0/1', '128-255' ], + [ '0.0.0.0/2', '0-63' ], + [ '128.0.0.0/2', '128-191' ], + [ '10.128.0.0/17', '10.128.0-127.' ] + ); + +$| = 1; +print "1..", (2 * scalar @addr), "\n"; + +my $count = 1; + +for my $a (@addr) { + my $ip = new NetAddr::IP $a->[0]; + +# print "$a->[0] is ", $ip->prefix, "\n"; + + if ($ip->prefix eq $a->[1]) { + print "ok $count\n"; + } + else { + print "not ok $count\n"; + } + + ++ $count; + + my $p = new NetAddr::IP $ip->prefix; + +# print $ip->prefix, " is $p\n"; + + + if ($p->cidr eq $a->[0]) { + print "ok $count\n"; + } + else { + print "not ok $count\n"; + } + + ++ $count; + +} + + diff --git a/t/v6-re.t b/t/v6-re.t new file mode 100644 index 0000000..aed48b4 --- /dev/null +++ b/t/v6-re.t @@ -0,0 +1,69 @@ +#use diagnostics; +use Test::More; +use NetAddr::IP; +use NetAddr::IP::Util qw(addconst); + +my @ips = qw! + ::0:0f00 + ::FF:1e10 + ::ffFF:2d20 + ::eFF:3c30 + ::eeFF:4b40 + ::FF:5a50 + ::FF:6960 + ::FF:7870 + ::FF:8780 + ::FF:9690 + ::FF:a5a0 + ::FF:b4b0 + ::FF:c3c0 + ::FF:d2d0 + ::FF:e1e0 + ::FF:f0f0 +!; +my @mask = qw! 127 126 125 124 123 122 121 120 !; + +if (defined($ENV{LIGHTERIPTESTS}) and $ENV{LIGHTERIPTESTS} =~ /yes/i) { + pop @mask; pop @mask; +} + +my $tests = 0; +my @addrs; +foreach(@mask) { + foreach my $ip (@ips) { + push @addrs, new NetAddr::IP($ip,$_); + } + $tests += ((2**(128 - $_)) * @ips) +} + +$tests += (5 * @ips * @mask); + +plan tests => $tests; + +for my $a (@addrs) +{ + isa_ok($a, 'NetAddr::IP'); + my $re = $a->re6; + my $rx; + + eval { $rx = qr/$re/ }; + diag "Compilation of the resulting regular expression failed: $@" + unless ok(!$@, "Compilation of the resulting regular expression"); + + for (my $ip = $a->network; + $ip < $a->broadcast && $a->masklen != 128; + $ip ++) + { + ok($a->addr =~ m/$rx/, "Match of $ip in $a"); + } + + ok($a->broadcast->addr =~ m/$rx/, "Match of broadcast of $a"); + my $under = $a->network->copy; + $under->{addr} = (addconst($under->{addr},-1))[1]; + my $over = $a->broadcast->copy; + $over->{addr} = (addconst($over->{addr},1))[1]; + ok($under !~ m/$rx/, "$under does not match"); + ok($over !~ m/$rx/, "$over does not match"); + ok(NetAddr::IP->new('::') !~ m/$rx/, ":: does not match"); +} + diff --git a/t/v6-split-bulk.t b/t/v6-split-bulk.t new file mode 100644 index 0000000..3e59375 --- /dev/null +++ b/t/v6-split-bulk.t @@ -0,0 +1,21 @@ +use Test::More; +use NetAddr::IP; + +# $Id: v6-split-bulk.t,v 1.1.1.1 2006/08/14 15:36:06 lem Exp $ + +my @addr = ( + [ 'dead:beef::1', 126, 127, 2 ], + [ 'dead:beef::1', 127, 127, 1 ], + [ 'dead:beef::1', 127, 128, 2 ], + [ 'dead:beef::1', 128, 128, 1 ], + [ 'dead:beef::1', 124, 128, 16 ], + [ 'dead:beef::1', 124, 127, 8 ], + ); + +plan tests => (scalar @addr); + +for my $a (@addr) { + my $ip = new NetAddr::IP $a->[0], $a->[1]; + my $r = $ip->splitref($a->[2]); + is(@$r, $a->[3]); +} diff --git a/t/v6-splitplan.t b/t/v6-splitplan.t new file mode 100644 index 0000000..29bb2f2 --- /dev/null +++ b/t/v6-splitplan.t @@ -0,0 +1,72 @@ + +use Test::More tests => 28; + +use_ok('NetAddr::IP'); + +my $ip = new NetAddr::IP('ffff:a123:b345:c789::/48'); +my $rv; +ok(($rv = sprintf("%s",$ip)) eq 'FFFF:A123:B345:C789:0:0:0:0/48',"$rv eq FFFF:A123:B345:C789:0:0:0:0/48"); + +my($plan,$masks) = $ip->_splitplan(48); +ok($plan,'there is a plan'); +ok(!$masks,'plan returns the orignal net'); +ok(@$plan == 1,'one item plan'); +ok(($rv = $plan->[0]) == 48,"plan $rv is original cidr 48"); + +my $cmask = new NetAddr::IP('ffff:7fff:ffff:ffff::'); +ok(($rv = sprintf("%s",$cmask)) eq 'FFFF:7FFF:FFFF:FFFF:0:0:0:0/128',"$rv eq FFFF:7FFF:FFFF:FFFF:0:0:0:0/128"); + +($plan,$masks) = $ip->_splitplan($cmask); +ok(!$plan,'failing because of bits in mask'); + +$cmask = new NetAddr::IP('FFFF:fFFF:FFFF::'); +ok(($rv = sprintf("%s",$cmask)) eq 'FFFF:FFFF:FFFF:0:0:0:0:0/128',"$rv eq FFFF:fFFF:FFFF:0:0:0:0:0/128"); + +($plan,$masks) = $ip->_splitplan($cmask); +ok($plan,'there is a plan'); +ok(!$masks,'plan returns the orignal net'); +ok(@$plan == 1,'one item plan'); +ok(($rv = $plan->[0]) == 48,"plan $rv is original cidr 48"); + +$cmask = 'FFFF:FFFF:FFFF::'; # ipV6 text cmask +($plan,$masks) = $ip->_splitplan($cmask); +ok($plan,'there is a plan'); +ok(!$masks,'plan returns the orignal net'); +ok(@$plan == 1,'one item plan'); +ok(($rv = $plan->[0]) == 48,"plan $rv is original cidr 48"); + +$cmask = 'FFFF:FFF:FFFF::'; # ipV6 text cmask +($plan,$masks) = $ip->_splitplan($cmask); +ok(!$plan,'failing because of bits in mask'); + +$cmask = 'garbage'; +($plan,$masks) = $ip->_splitplan($cmask); +ok(!$plan,'failing because of garbage'); + +$cmask = 47; # cidr is bigger than requested +($plan,$masks) = $ip->_splitplan($cmask); +ok(!$plan,'failing because of 47 overange'); + +# cidr makes more nets than 2**16 +($plan,$masks) = $ip->_splitplan(65); +ok(!$plan,'failing to many nets 65-48 = 2**17'); + +($plan,$masks) = $ip->_splitplan(49,49,49); +ok(!$plan,'failing because of 3 * 49 overange'); + +# test for plan that just fits +($plan,$masks) = $ip->_splitplan(64); +ok($plan,'there is a plan 64'); +ok($masks,'plan has masks'); +ok(($rv = @{$plan}) == 2 ** 16,"$rv should = 65536"); + +# set netlimit internal to 4 nets +$NetAddr::IP::_netlimit = 4; +($plan,$masks) = $ip->_splitplan(50); # should fit +ok($plan,"plan of 4 50's"); + +($plan,$masks) = $ip->_splitplan(50,50,50,50,51); +ok(!plan,"fail plan of 4 50's + 51"); + +($plan,$masks) = $ip->_splitplan(51); +ok(!plan,"fail plan of 8 51's"); diff --git a/t/wildcard.t b/t/wildcard.t new file mode 100644 index 0000000..249b8bb --- /dev/null +++ b/t/wildcard.t @@ -0,0 +1,37 @@ +use NetAddr::IP; + +my @addr = ( + [ 'localhost', '0.0.0.0' ], + [ '10.0.0.0/24', '0.0.0.255' ], + [ '192.168.0.0/16', '0.0.255.255' ], + [ '10.128.0.1/17', '0.0.127.255' ] +); + +$| = 1; + +print "1..", 2 * scalar @addr, "\n"; + +my $count = 1; + +for my $a (@addr) { + my $ip = new NetAddr::IP $a->[0]; + + if ($ip->wildcard eq $a->[1]) { + print "ok $count\n"; + } + else { + print "not ok $count\n"; + } + + ++$count; + + + if (($ip->wildcard)[1] eq $a->[1]) { + print "ok $count\n"; + } + else { + print "not ok $count\n"; + } + + ++$count; +}