Giter Club home page Giter Club logo

ipv6calc's Introduction

ipv6calc will do some format changes and calculations for you

(P) & (C) 2001-2024 by Peter Bieringer <pb (at) bieringer.de>
                   published under GNU GPLv2

For suggestions and bug report please contact author

More help is available using 'ipv6calc -?'


Intention:
* This utility can be used by the IPv6 enabled initscripts for better duplicate
address detection on setup of IPv6 addresses

* Also migrate "ip6_int" of Keith Owens <[email protected]> into this utility


Known bugs:
* ipv6calc is sure not the securest C program around the world


Contents:
* "ipv6calc": the main utility
* "ipv6calcweb": CGI wrapper for ipv6calc's address information output
* "ipv6logconv": log converter (IPv4/IPv6)
* "ipv6loganon": log anonymizer (IPv4/IPv6)
* "ipv6logstats": log statistic generator (IPv4/IPv6)
* "mod_ipv6calc": Apache module


Included internal databases:
* IEEE IAB, OUI, OUI-36 databases (for decoding vendor part of MAC/EUI-48/EUI-64)
* IPv4 assignment databases from IANA, ARIN, RIPENCC, APNIC, LACNIC, AFRINIC (for selecting proper registry in ipv6calcweb.cgi and IPv4 anonymization)
* IPv6 assignment databases from IANA, ARIN, RIPENCC, APNIC, LACNIC, AFRINIC (for selecting proper registry in ipv6calcweb.cgi and IPv6 anonymization)
* ASN assignment databases from IANA, ARIN, RIPENCC, APNIC, LACNIC, AFRINIC (for IPv4/IPv6 anonymization)

Supported external databases:
* GeoIP(MaxMindDB) - internally handled as GEOIP2
* IP2Location
* DB-IP.com(MaxMindDB) - internally handled as DBIP2


Where to get:
 Homepage:
  https://www.deepspace6.net/projects/ipv6calc.html

 Latest version of sources:
  ftp://ftp.bieringer.de/pub/linux/IPv6/ipv6calc/
  http://www.bieringer.de/ftp/pub/linux/IPv6/ipv6calc/
  https://www.bieringer.de/ftp/pub/linux/IPv6/ipv6calc/

  ftp://ftp.deepspace6.net/pub/ds6/sources/ipv6calc/
  http://www.deepspace6.net/ftp/pub/ds6/sources/ipv6calc/
  https://www.deepspace6.net/ftp/pub/ds6/sources/ipv6calc/

 GitHub access:
  https://github.com/pbiering/ipv6calc

 Available formats:
  tar.gz
  spec-file is included, so you can build an RPM from source tarball using rpm -ta ipv6calc-version.tar.gz

 Ready to use packages for several operating systems:
  Linux:
   Fedora (https://src.fedoraproject.org/rpms/ipv6calc)
    Core 6: initial developing platform, so use given hint above to create a RPM
    since 7: package is included
   Enterprise Linux (https://src.fedoraproject.org/rpms/ipv6calc / https://koji.fedoraproject.org/koji/packageinfo?packageID=366):
    EL3: build from source package potentially still work but not tested anymore, OS is EOSL
    EL4: build from source package potentially still work but not tested anymore, OS is EOSL
    EL5: build from source package potentially still work but not tested anymore, OS is EOSL
    EL6: build from source package potentially still work but not tested anymore, OS is EOSL
    EL7: package is available via EPEL
    EL8: package is available via EPEL
    EL9: package is available via EPEL
   Mandrake (EOSL):
    similar to Red Hat, rebuild should work, too
   Debian:
    maintained package at http://packages.debian.org/ipv6calc
   Ubuntu:
    maintained package at http://packages.ubuntu.com/ipv6calc
     or http://packages.ubuntu.com/cgi-bin/search_packages.pl?searchon=names&version=all&exact=1&keywords=ipv6calc

  BSD:
   NetBSD:
    ftp://ftp.netbsd.org/pub/pkgsrc/current/pkgsrc/net/ipv6calc/README.html
   FreeBSD:
    http://www.freshports.org/net-mgmt/ipv6calc/ (http://www.freebsd.org/cgi/query-pr.cgi?pr=34441)
   OpenBSD:
    http://www.openbsd.org/cgi-bin/cvsweb/ports/net/ipv6calc/


Mailing lists:
 ipv6calc-announce
  Reason: sending announcements of new versions
  Traffic: very low
  Postings: only moderators are allowed to post, others are rejected automatically
  Subscription: https://lists.deepspace6.net/postorius/lists/ipv6calc-announce.lists.deepspace6.net/

 ipv6calc
  Reason: discussions
  Traffic: medium
  Postings: only subscribers are allowed to post
  Subscription: https://lists.deepspace6.net/postorius/lists/ipv6calc.lists.deepspace6.net/

ipv6calc's People

Contributors

grayed avatar jsarenik avatar jwakely avatar lytboris avatar pbiering avatar scop avatar sunpoet avatar thesamesam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ipv6calc's Issues

Incorrect use of AC_ARG_ENABLE() throughout configure.in

At a few points throughout configure.in, the macro AC_ARG_ENABLE() is incorrectly used. The parameters should be interpreted as follows:

AC_ARG_ENABLE(option-name, help-string, action-if-present, action-if-not-present)

but instead it seems that you are interpreting the 3rd and 4th parameters as what to do if the option is enabled and what to do if it is disabled, respectively. An example of this problem is at line 1440 where you have

AC_ARG_ENABLE([mod_ipv6calc], 
	AS_HELP_STRING([--enable-mod_ipv6calc],
		[Enable build of mod_ipv6calc for Apache (default: disabled)]),
	[
		ENABLE_MOD_IPV6CALC="1"
	],[
		ENABLE_MOD_IPV6CALC="0"
])

This leads to the result that ./configure --disable-mod_ipv6calc actually enables mod_ipv6calc, as does ./configure --enable-mod_ipv6calc. The only way to disable this option is to NOT pass either --disable-mod_ipv6calc nor --enable-mod_ipv6calc.

To fix this, the 3rd parameter above should be changed from ENABLE_MOD_IPV6CALC="1" to ENABLE_MOD_IPV6CALC="$enable_mod_ipv6calc", and the 4th parameter can be left as is if you want --disable_mod_ipv6calc to be the default if this flag is not passed.

I did make your team aware of this some years ago, and sent a patch (if memory serves), but it seems that the same erroneous logic is being re-introduced. Take a look at (say) the db-ipv4 option on line 366 for a correct example.

Also, to modernize things, you should rename configure.in -> configure.ac. The former name has been deprecated for years.

ipv6addr: unrecognized option '---no-prefixlength'

According to the docs I can do this:

$ ipv6calc --out ipv6 --examples
  --forceprefix <num>: Force prefix to <num>
  --no-prefixlength: Don't print prefix length if given on input

However those two options don't seem to work:

$ ipv6calc --in prefix+mac "1:2:3:4::/56" "11:22:33:44:55:66" --action prefixmac2ipv6 --out ipv6addr --no-prefixlength
ipv6calc: unrecognized option '--no-prefixlength'
$ ipv6calc --in prefix+mac "1:2:3:4::" "11:22:33:44:55:66" --action prefixmac2ipv6 --out ipv6addr --force-prefix 56
ipv6calc: unrecognized option '--force-prefix'

The other options listed in --examples work.

Potential buffer overflows identified by GCC

Build environment

GCC: gcc (Debian 13.2.0-7) 13.2.0

*** CFLAGS_EXTRA               =-fPIC -Wformat -Werror -Werror=format-security -Wsizeof-array-argument -Wextra -Werror=format-truncation=0 -Werror=char-subscripts -Wno-deprecated-declarations
*** LDFLAGS_EXTRA              =
*** LDFLAGS_EXTRA_STATIC       =
*** LD_LIBRARY_PATH            =
*** LD_LIBRARY_PATH_BASIC      =
*** CPPFLAGS                   = -Wdate-time -DFORTIFY_SOURCE=2
*** CFLAGS                     =-g -O2 -ffile-prefix-map=/root/2023-12-ipv6calc/ipv6calc=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection
*** LDFLAGS                    =-Wl,-z,relro -Wl,-z,now

Results in the following build warnings, that honestly seem pretty serious (overflows etc.):

libipv6calc_db_wrapper_GeoIP2.c
gcc -c libipv6calc_db_wrapper_GeoIP2.c -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -ffile-prefix-map=/root/2023-12-ipv6calc/ipv6calc=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -D__EXTENSIONS__ -fPIC -D__EXTENSIONS__ -fPIC -I../../lib -I../..
libipv6calc_db_wrapper_GeoIP2.c: In function ‘libipv6calc_db_wrapper_GeoIP2_dbfilename’:
libipv6calc_db_wrapper_GeoIP2.c:580:51: warning: ‘%s’ directive output may be truncated writing up to 4095 bytes into a region of size 1024 [-Wformat-truncation=]
  580 |         snprintf(tempstring, sizeof(tempstring), "%s/%s", geoip2_db_dir, libipv6calc_db_wrapper_GeoIP2_db_file_desc[i].filename);
      |                                                   ^~      ~~~~~~~~~~~~~
In file included from /usr/include/stdio.h:906,
                 from libipv6calc_db_wrapper_GeoIP2.c:11:
In function ‘snprintf’,
    inlined from ‘libipv6calc_db_wrapper_GeoIP2_dbfilename’ at libipv6calc_db_wrapper_GeoIP2.c:580:2:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:54:10: note: ‘__builtin___snprintf_chk’ output 2 or more bytes (assuming 4097) into a destination of size 1024
   54 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   55 |                                    __glibc_objsize (__s), __fmt,
      |                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   56 |                                    __va_arg_pack ());
      |                                    ~~~~~~~~~~~~~~~~~
libipv6calc_db_wrapper_GeoIP2.c: In function ‘libipv6calc_db_wrapper_GeoIP2_database_info’:
libipv6calc_db_wrapper_GeoIP2.c:789:53: warning: ‘, created: ’ directive output may be truncated writing 11 bytes into a region of size between 1 and 1024 [-Wformat-truncation=]
  789 |         snprintf(tempstring, sizeof(tempstring), "%s, created: %s", resultstring, datastring);
      |                                                     ^~~~~~~~~~~
In function ‘snprintf’,
    inlined from ‘libipv6calc_db_wrapper_GeoIP2_database_info’ at libipv6calc_db_wrapper_GeoIP2.c:789:2:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:54:10: note: ‘__builtin___snprintf_chk’ output between 12 and 2058 bytes into a destination of size 1024
   54 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   55 |                                    __glibc_objsize (__s), __fmt,
      |                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   56 |                                    __va_arg_pack ());
      |                                    ~~~~~~~~~~~~~~~~~
libipv6calc_db_wrapper_GeoIP2.c: In function ‘libipv6calc_db_wrapper_GeoIP2_wrapper_db_info_used’:
libipv6calc_db_wrapper_GeoIP2.c:542:77: warning: ‘ / ’ directive output may be truncated writing 3 bytes into a region of size between 1 and 1024 [-Wformat-truncation=]
  542 |                                 snprintf(tempstring, sizeof(tempstring), "%s / %s", geoip2_db_usage_string, info);
      |                                                                             ^~~
In function ‘snprintf’,
    inlined from ‘libipv6calc_db_wrapper_GeoIP2_wrapper_db_info_used’ at libipv6calc_db_wrapper_GeoIP2.c:542:5:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:54:10: note: ‘__builtin___snprintf_chk’ output 4 or more bytes (assuming 1027) into a destination of size 1024
   54 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   55 |                                    __glibc_objsize (__s), __fmt,
      |                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   56 |                                    __va_arg_pack ());
      |                                    ~~~~~~~~~~~~~~~~~
libipv6calc_db_wrapper_DBIP2.c
gcc -c libipv6calc_db_wrapper_DBIP2.c -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -ffile-prefix-map=/root/2023-12-ipv6calc/ipv6calc=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -D__EXTENSIONS__ -fPIC -D__EXTENSIONS__ -fPIC -I../../lib -I../..
libipv6calc_db_wrapper_DBIP2.c: In function ‘libipv6calc_db_wrapper_DBIP2_dbfilename’:
libipv6calc_db_wrapper_DBIP2.c:561:51: warning: ‘%s’ directive output may be truncated writing up to 4095 bytes into a region of size 1024 [-Wformat-truncation=]
  561 |         snprintf(tempstring, sizeof(tempstring), "%s/%s", dbip2_db_dir, libipv6calc_db_wrapper_DBIP2_db_file_desc[i].filename);
      |                                                   ^~      ~~~~~~~~~~~~
In file included from /usr/include/stdio.h:906,
                 from libipv6calc_db_wrapper_DBIP2.c:11:
In function ‘snprintf’,
    inlined from ‘libipv6calc_db_wrapper_DBIP2_dbfilename’ at libipv6calc_db_wrapper_DBIP2.c:561:2:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:54:10: note: ‘__builtin___snprintf_chk’ output 2 or more bytes (assuming 4097) into a destination of size 1024
   54 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   55 |                                    __glibc_objsize (__s), __fmt,
      |                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   56 |                                    __va_arg_pack ());
      |                                    ~~~~~~~~~~~~~~~~~
libipv6calc_db_wrapper_DBIP2.c: In function ‘libipv6calc_db_wrapper_DBIP2_database_info’:
libipv6calc_db_wrapper_DBIP2.c:770:53: warning: ‘, created: ’ directive output may be truncated writing 11 bytes into a region of size between 1 and 1024 [-Wformat-truncation=]
  770 |         snprintf(tempstring, sizeof(tempstring), "%s, created: %s", resultstring, datastring);
      |                                                     ^~~~~~~~~~~
In function ‘snprintf’,
    inlined from ‘libipv6calc_db_wrapper_DBIP2_database_info’ at libipv6calc_db_wrapper_DBIP2.c:770:2:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:54:10: note: ‘__builtin___snprintf_chk’ output between 12 and 2058 bytes into a destination of size 1024
   54 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   55 |                                    __glibc_objsize (__s), __fmt,
      |                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   56 |                                    __va_arg_pack ());
      |                                    ~~~~~~~~~~~~~~~~~
libipv6calc_db_wrapper_DBIP2.c: In function ‘libipv6calc_db_wrapper_DBIP2_wrapper_db_info_used’:
libipv6calc_db_wrapper_DBIP2.c:523:77: warning: ‘ / ’ directive output may be truncated writing 3 bytes into a region of size between 1 and 1024 [-Wformat-truncation=]
  523 |                                 snprintf(tempstring, sizeof(tempstring), "%s / %s", dbip2_db_usage_string, info);
      |                                                                             ^~~
In function ‘snprintf’,
    inlined from ‘libipv6calc_db_wrapper_DBIP2_wrapper_db_info_used’ at libipv6calc_db_wrapper_DBIP2.c:523:5:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:54:10: note: ‘__builtin___snprintf_chk’ output 4 or more bytes (assuming 1027) into a destination of size 1024
   54 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   55 |                                    __glibc_objsize (__s), __fmt,
      |                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   56 |                                    __va_arg_pack ());
      |                                    ~~~~~~~~~~~~~~~~~
libipv6calc_db_wrapper_BuiltIn.c ``` gcc -c libipv6calc_db_wrapper_BuiltIn.c -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -ffile-prefix-map=/root/2023-12-ipv6calc/ipv6calc=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -D__EXTENSIONS__ -fPIC -D__EXTENSIONS__ -fPIC -I../../lib -I../.. libipv6calc_db_wrapper_BuiltIn.c: In function ‘libipv6calc_db_wrapper_BuiltIn_wrapper_db_info_used’: libipv6calc_db_wrapper_BuiltIn.c:299:77: warning: ‘ / ’ directive output may be truncated writing 3 bytes into a region of size between 1 and 1024 [-Wformat-truncation=] 299 | snprintf(tempstring, sizeof(tempstring), "%s / %s", builtin_db_usage_string, info); | ^~~ In file included from /usr/include/stdio.h:906, from libipv6calc_db_wrapper_BuiltIn.c:12: In function ‘snprintf’, inlined from ‘libipv6calc_db_wrapper_BuiltIn_wrapper_db_info_used’ at libipv6calc_db_wrapper_BuiltIn.c:299:5: /usr/include/x86_64-linux-gnu/bits/stdio2.h:54:10: note: ‘__builtin___snprintf_chk’ output between 4 and 2050 bytes into a destination of size 1024 54 | return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 55 | __glibc_objsize (__s), __fmt, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 56 | __va_arg_pack ()); | ~~~~~~~~~~~~~~~~~ ```
libipv6calc.c
gcc -c libipv6calc.c -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -ffile-prefix-map=/root/2023-12-ipv6calc/ipv6calc=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -D__EXTENSIONS__ -fPIC -D__EXTENSIONS__ -fPIC -I. -I../ -I../databases/lib/  -I../md5
libipv6calc.c: In function ‘string_to_reverse_dotted’:
libipv6calc.c:147:62: warning: ‘__builtin___snprintf_chk’ output may be truncated before the last format character [-Wformat-truncation=]
  147 |                 snprintf(tempstring, sizeof(tempstring), "%s.", resultstring);
      |                                                              ^
In file included from /usr/include/stdio.h:906,
                 from libipv6calc.c:11:
In function ‘snprintf’,
    inlined from ‘string_to_reverse_dotted’ at libipv6calc.c:147:3:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:54:10: note: ‘__builtin___snprintf_chk’ output between 2 and 1025 bytes into a destination of size 1024
   54 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   55 |                                    __glibc_objsize (__s), __fmt,
      |                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   56 |                                    __va_arg_pack ());
      |                                    ~~~~~~~~~~~~~~~~~
libipv6calc.c: In function ‘string_to_reverse_dotted’:
libipv6calc.c:158:72: warning: ‘__builtin___snprintf_chk’ output may be truncated before the last format character [-Wformat-truncation=]
  158 |                         snprintf(tempstring, sizeof(tempstring), "%s.%s", token, resultstring);
      |                                                                        ^
In function ‘snprintf’,
    inlined from ‘string_to_reverse_dotted’ at libipv6calc.c:158:4:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:54:10: note: ‘__builtin___snprintf_chk’ output 2 or more bytes (assuming 1025) into a destination of size 1024
   54 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   55 |                                    __glibc_objsize (__s), __fmt,
      |                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   56 |                                    __va_arg_pack ());
      |                                    ~~~~~~~~~~~~~~~~~
libipv6calc.c: In function ‘string_to_reverse_dotted’:
libipv6calc.c:166:62: warning: ‘__builtin___snprintf_chk’ output may be truncated before the last format character [-Wformat-truncation=]
  166 |                 snprintf(tempstring, sizeof(tempstring), ".%s", resultstring);
      |                                                              ^
In function ‘snprintf’,
    inlined from ‘string_to_reverse_dotted’ at libipv6calc.c:166:3:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:54:10: note: ‘__builtin___snprintf_chk’ output between 2 and 1025 bytes into a destination of size 1024
   54 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   55 |                                    __glibc_objsize (__s), __fmt,
      |                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   56 |                                    __va_arg_pack ());
      |                                    ~~~~~~~~~~~~~~~~~
ipv6calc.c
gcc -c ipv6calc.c -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -ffile-prefix-map=/root/2023-12-ipv6calc/ipv6calc=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -I../md5    -I../ -I../lib/ -I../databases/lib/
ipv6calc.c: In function ‘main’:
ipv6calc.c:1942:95: warning: ‘%s’ directive output may be truncated writing up to 16383 bytes into a region of size 1024 [-Wformat-truncation=]
 1942 |                                                 snprintf(resultstring, sizeof(resultstring), "%s %s", input1, resultstring3);
      |                                                                                               ^~
In file included from /usr/include/stdio.h:906,
                 from ipv6calc.c:12:
In function ‘snprintf’,
    inlined from ‘main’ at ipv6calc.c:1942:7:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:54:10: note: ‘__builtin___snprintf_chk’ output 2 or more bytes (assuming 16385) into a destination of size 1024
   54 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   55 |                                    __glibc_objsize (__s), __fmt,
      |                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   56 |                                    __va_arg_pack ());
      |                                    ~~~~~~~~~~~~~~~~~
ipv6calc.c: In function ‘main’:
ipv6calc.c:1940:95: warning: ‘%s’ directive output may be truncated writing up to 16383 bytes into a region of size 1024 [-Wformat-truncation=]
 1940 |                                                 snprintf(resultstring, sizeof(resultstring), "%s uncomparable", input1);
      |                                                                                               ^~
In function ‘snprintf’,
    inlined from ‘main’ at ipv6calc.c:1940:7:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:54:10: note: ‘__builtin___snprintf_chk’ output between 14 and 16397 bytes into a destination of size 1024
   54 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   55 |                                    __glibc_objsize (__s), __fmt,
      |                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   56 |                                    __va_arg_pack ());
      |                                    ~~~~~~~~~~~~~~~~~
ipv6calc.c: In function ‘main’:
ipv6calc.c:1935:87: warning: ‘%s’ directive output may be truncated writing up to 16383 bytes into a region of size 1024 [-Wformat-truncation=]
 1935 |                                         snprintf(resultstring, sizeof(resultstring), "%s %s", linebuffer, resultstring3);
      |                                                                                       ^~      ~~~~~~~~~~
In function ‘snprintf’,
    inlined from ‘main’ at ipv6calc.c:1935:6:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:54:10: note: ‘__builtin___snprintf_chk’ output 2 or more bytes (assuming 16385) into a destination of size 1024
   54 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   55 |                                    __glibc_objsize (__s), __fmt,
      |                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   56 |                                    __va_arg_pack ());
      |                                    ~~~~~~~~~~~~~~~~~
ipv6calc.c: In function ‘main’:
ipv6calc.c:1933:87: warning: ‘%s’ directive output may be truncated writing up to 16383 bytes into a region of size 1024 [-Wformat-truncation=]
 1933 |                                         snprintf(resultstring, sizeof(resultstring), "%s uncomparable", linebuffer);
      |                                                                                       ^~                ~~~~~~~~~~
In function ‘snprintf’,
    inlined from ‘main’ at ipv6calc.c:1933:6:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:54:10: note: ‘__builtin___snprintf_chk’ output between 14 and 16397 bytes into a destination of size 1024
   54 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   55 |                                    __glibc_objsize (__s), __fmt,
      |                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   56 |                                    __va_arg_pack ());
      |                                    ~~~~~~~~~~~~~~~~~
ipv6calc.c: In function ‘main’:
ipv6calc.c:1731:79: warning: ‘%s’ directive output may be truncated writing up to 16383 bytes into a region of size 1024 [-Wformat-truncation=]
 1731 |                                 snprintf(resultstring, sizeof(resultstring), "%s", linebuffer);
      |                                                                               ^~   ~~~~~~~~~~
In function ‘snprintf’,
    inlined from ‘main’ at ipv6calc.c:1731:5:
/usr/include/x86_64-linux-gnu/bits/stdio2.h:54:10: note: ‘__builtin_snprintf’ output between 1 and 16384 bytes into a destination of size 1024
   54 |   return __builtin___snprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   55 |                                    __glibc_objsize (__s), __fmt,
      |                                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   56 |                                    __va_arg_pack ());
      |                                    ~~~~~~~~~~~~~~~~~

static build of "ipv6calc" is not working in case of OpenSSL EVP or libmd MD5 is used

current "master" contains now support for OpenSSL 3 which deprecated the really old MD5 functions.

But after switching to new EVP MD5 functions, static build reports a warning, don't know how to solve this proper.

$ gcc -o ipv6calc-static ipv6calc.o showinfo.o ipv6calchelp_local.o  -L../lib/ -L../databases/lib/ -lipv6calc_db_wrapper -lipv6calc    -lm -lpthread -lc -lcrypto -ldl -lz  -static
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/11/../../../../lib64/libcrypto.a(fips.o): in function `verify_checksums':
(.text+0x4e6): warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/11/../../../../lib64/libcrypto.a(b_addr.o): in function `BIO_lookup_ex':
(.text+0xd35): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/gcc/x86_64-redhat-linux/11/../../../../lib64/libcrypto.a(b_sock.o): in function `BIO_gethostbyname':
(.text+0x75): warning: Using 'gethostbyname' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

LGPLness in lib

I have to admit that I have lust in my heart to be able to lift bits of ipv6calc into a simpler library mostly dedicated to dealing with prefix pools quickly (sse2 and arm intrinsics for the fast stuff). But to do that, I'd have to license it LGPL, and it looks as though ipv6calc the program is GPLv2 (which is fine) and most of the libraries could be LGPL, except that they aren't.

CPPFLAGS not used by the build system

While autoconf (./configure) seems to be obeying CPPFLAGS from the environment, this does not seem to be used by Makefile etc. when building .c files to .o.

(Note: I see that in master the CPPLAGS -> CPPFLAGS typo has been fixed. This is unrelated.)

Distributions often pass default build flags through both CFLAGS and CPPFLAGS, as appropriate. For example, Debian, when the "foritfy" hardening flag is enabled, passes "-D_FORTIFY_SOURCE=2" to CPPFLAGS. The build system seems to entirely ignore this right now, requiring the use of workarounds.

Separately, I don't understand the DEFAULT_CFLAGS variable. Given one can pass CFLAGS to ./configure through the environment, why employ an additional variable?

"make install" installs source-level tools to the system

"make install" seems to be installing all of the files under "tools" to (e.g.) /usr/share/ipv6calc/tools.

However, most of these seem to be internal, source-level tools, e.g. regenerating header files out of IEEE databases and such, and are not really useful in the "destionation" system or in /usr.

A real-world problem that arises with this is when building ipv6calc for a distribution, such as Debian.

configure.in -> configure.ac; outdated autoconf

autoreconf: warning: autoconf input should be named 'configure.ac', not 'configure.in'
aclocal: warning: autoconf input should be named 'configure.ac', not 'configure.in'
configure.in:47: warning: The macro `AC_CONFIG_HEADER' is obsolete.
configure.in:47: You should run autoupdate.
./lib/autoconf/status.m4:719: AC_CONFIG_HEADER is expanded from...
configure.in:47: the top level
configure.in:57: warning: The macro `AC_HEADER_STDC' is obsolete.
configure.in:57: You should run autoupdate.
./lib/autoconf/headers.m4:704: AC_HEADER_STDC is expanded from...
configure.in:57: the top level
configure.in:1318: warning: The macro `AC_HELP_STRING' is obsolete.
configure.in:1318: You should run autoupdate.
./lib/autoconf/general.m4:204: AC_HELP_STRING is expanded from...
configure.in:1318: the top level
configure.in:1399: warning: AC_OUTPUT should be used without arguments.
configure.in:1399: You should run autoupdate.
autoheader: warning: autoconf input should be named 'configure.ac', not 'configure.in'

Pregenerated contrib/ipv6calc.spec is shipped in the source tree & tarball

While contrib/ipv6calc.spec is generated from contrib/ipv6calc.spec.in, the pregenerated file is shipped in the source tree and resulting tarball. This is unlike e.g. Makefiles, that are also generated from Makefile.in, but in this case no pregenerated Makefiles being shipped.

This results into a dirty source tree when running "make; make clean" and requires workarounds in the Debian package.

Cross compile issue (64-bit ARM)

ipv6calc version: 3.0.0
Host: Ubuntu 18.04 64-bit
Target: ARM 64-bit
Cross compiler toolchain: gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu

I have developed this bash script to grab the code and build it:

#!/bin/sh

SDK_SYSROOT_DIR="/opt/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/sysroots/aarch64-linux"
SDK_CROSSCOMPILER_DIR="/opt/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/sysroots/x86_64-arago-linux/usr/bin"


# Grab the 3.0.0 ipv6calc release stable branch
rm -rf ipv6calc-3.0.0
wget https://github.com/pbiering/ipv6calc/archive/3.0.0.tar.gz
tar -xzvf 3.0.0.tar.gz
rm 3.0.0.tar.gz


cd ipv6calc-3.0.0


# Configure ipv6calc for cross compile
./configure \
        --build=x86_64-linux \
        --host=aarch64-linux \
        --target=aarch64-linux \
        --prefix=$SDK_SYSROOT_DIR/usr/local \
        --with-sysroot=$SDK_SYSROOT_DIR \
        CC=$SDK_CROSSCOMPILER_DIR/aarch64-linux-gnu-gcc \
        CXX=$SDK_CROSSCOMPILER_DIR/aarch64-linux-gnu-g++ \
        CFLAGS="-march=armv8-a -fPIC -mcpu=cortex-a72 --sysroot=$SDK_SYSROOT_DIR $CFLAGS" \
        CPPFLAGS="-march=armv8-a -fPIC -mcpu=cortex-a72 --sysroot=$SDK_SYSROOT_DIR $CPPFLAGS" \
        LDFLAGS="-march=armv8-a -fPIC -mcpu=cortex-a72 --sysroot=$SDK_SYSROOT_DIR -L$SDK_SYSROOT_DIR/usr/lib -L$SDK_SYSROOT_DIR/usr/lib/aarch64-linux-gnu/8.3.0 $LDFLAGS" \
        --disable-dynamic-load  --disable-db-ieee --disable-db-ipv4  --disable-db-ipv6  --disable-db-as-registry --disable-db-cc-registry --disable-geoip2 --disable-dbip2 --disable-bundled-md5


# make ipv6calc
make

# install ipv6calc to $SDK_SYSROOT_DIR/usr/local
sudo make install

Config log:

configure: WARNING: unrecognized options: --with-sysroot, --disable-geoip2
checking for gawk... gawk
checking for aarch64-linux-gcc... /opt/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/sysroots/x86_64-arago-linux/usr/bin/aarch64-linux-gnu-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /opt/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/sysroots/x86_64-arago-linux/usr/bin/aarch64-linux-gnu-gcc accepts -g... yes
checking for /opt/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/sysroots/x86_64-arago-linux/usr/bin/aarch64-linux-gnu-gcc option to accept ISO C89... none needed
checking for aarch64-linux-ranlib... no
checking for ranlib... ranlib
configure: WARNING: using cross tools not prefixed with host triplet
checking whether make sets $(MAKE)... yes
checking how to run the C preprocessor... /opt/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/sysroots/x86_64-arago-linux/usr/bin/aarch64-linux-gnu-gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for an ANSI C-conforming const... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for off_t... yes
checking for size_t... yes
checking whether byte ordering is bigendian... no
checking for working memcmp... no
checking for strspn... yes
checking for strstr... yes
**** analyze compiler options: CC=/opt/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/sysroots/x86_64-arago-linux/usr/bin/aarch64-linux-gnu-gcc
*** check for CFLAGS: -Werror=format-security
*** CFLAGS supported: -Werror=format-security
*** check for CFLAGS: -Wsizeof-array-argument
*** CFLAGS supported: -Wsizeof-array-argument
*** check for CFLAGS: -Wparentheses-equality
configure: WARNING: *** missing CFLAGS support: -Wparentheses-equality
*** check for CFLAGS: -Wextra
*** CFLAGS supported: -Wextra
*** check for CFLAGS: -Werror=format-truncation=0
*** CFLAGS supported: -Werror=format-truncation=0
checking for getopt_long... yes
*** use of system getopt library autoselected
*** use of system MD5 library forced
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
*** Dynamic loading of libraries is SUPPORTED
configure: WARNING: Build of mod_ipv6calc NOT enabled
configure: creating ./config.status
config.status: creating Makefile
config.status: creating md5/Makefile
config.status: creating tools/Makefile
config.status: creating getopt/Makefile
config.status: creating ipv6calc/Makefile
config.status: creating lib/Makefile
config.status: creating man/Makefile
config.status: creating databases/lib/Makefile
config.status: creating ipv6logconv/Makefile
config.status: creating ipv6loganon/Makefile
config.status: creating ipv6logstats/Makefile
config.status: creating ipv6calcweb/Makefile
config.status: creating contrib/ipv6calc.spec
config.status: creating tools/ipv6calc-db-update.sh
config.status: creating tools/DBIP-update.sh
config.status: creating tools/IP2Location-update.sh
config.status: creating tools/GeoIP-update.sh
config.status: creating mod_ipv6calc/Makefile
config.status: creating VERSION
config.status: creating config.h
configure: WARNING: unrecognized options: --with-sysroot, --disable-geoip2
***** Summary
*** MMDB                       =no
*** MMDB_DYN                   =
*** MMDB_DYN_LIB               =libmaxminddb.so.0
*** MMDB_INCLUDE               =
*** MMDB_INCLUDE_VERSION       =
*** MMDB_LIB                   =
*** MMDB_LIB_NAME              =maxminddb
*** MMDB_LIB_DIR               =

*** IP2LOCATION                =no
*** IP2LOCATION_DB             =/usr/share/IP2Location
*** IP2LOCATION_DYN            =
*** IP2LOCATION_DYN_LIB        =libIP2Location.so.3
*** IP2LOCATION_INCLUDE        =
*** IP2LOCATION_INCLUDE_VERSION=
*** IP2LOCATION_LIB            =
*** IP2LOCATION_LIB_NAME       =IP2Location
*** IP2LOCATION_LIB_DIR        =

*** GEOIP2                     =no
*** GEOIP2_DB                  =/usr/share/GeoIP

*** DBIP2                      =no
*** DBIP2_DB                   =/usr/share/DBIP

*** EXTERNAL                   =no
*** EXTERNAL_DB                =/usr/share/ipv6calc/db

*** BUILTIN                    =
*** DB_IPV4                    =no
*** DB_IPV6                    =no
*** DB_IEEE                    =no
*** DB_AS_REG                  =no
*** DB_CC_REG                  =no

*** CC                         =/opt/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/sysroots/x86_64-arago-linux/usr/bin/aarch64-linux-gnu-gcc
*** CFLAGS_EXTRA               =-march=armv8-a -fPIC -mcpu=cortex-a72 --sysroot=/opt/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/sysroots/aarch64-linux  -Wformat -Werror -Werror=format-security -Wsizeof-array-argument -Wextra -Werror=format-truncation=0
*** LDFLAGS_EXTRA              =-lcrypto -march=armv8-a -fPIC -mcpu=cortex-a72 --sysroot=/opt/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/sysroots/aarch64-linux -L/opt/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/sysroots/aarch64-linux/usr/lib -L/opt/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/sysroots/aarch64-linux/usr/lib/arm-poky-linux-gnueabi/7.3.0 
*** LD_LIBRARY_PATH            =
*** LD_LIBRARY_PATH_BASIC      =

*** CPPLAGS                    =
*** CFLAGS                     =-march=armv8-a -fPIC -mcpu=cortex-a72 --sysroot=/opt/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/sysroots/aarch64-linux 
*** LDFLAGS                    =-march=armv8-a -fPIC -mcpu=cortex-a72 --sysroot=/opt/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/sysroots/aarch64-linux -L/opt/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/sysroots/aarch64-linux/usr/lib -L/opt/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/sysroots/aarch64-linux/usr/lib/arm-poky-linux-gnueabi/7.3.0 

*** PACKAGE_VERSION_NUMERIC    =3000000
*** PACKAGE_VERSION_STRING     =3.0.0
*** API_VERSION_NUMERIC        =3000000
*** API_VERSION_STRING         =3.0.0

*** ENABLE_MOD_IPV6CALC        =0

Compile log:

cd databases/ieee-oui && make
make[1]: Entering directory '/home/ipv6/ipv6calc-3.0.0/databases/ieee-oui'
test -f dbieee_oui.h || make update
make[1]: Leaving directory '/home/ipv6/ipv6calc-3.0.0/databases/ieee-oui'
cd databases/ieee-iab && make
make[1]: Entering directory '/home/ipv6/ipv6calc-3.0.0/databases/ieee-iab'
test -f dbieee_iab.h || make update
make[1]: Leaving directory '/home/ipv6/ipv6calc-3.0.0/databases/ieee-iab'
cd databases/ipv4-assignment && make
make[1]: Entering directory '/home/ipv6/ipv6calc-3.0.0/databases/ipv4-assignment'
test -f dbipv4addr_assignment.h || make update
make[1]: Leaving directory '/home/ipv6/ipv6calc-3.0.0/databases/ipv4-assignment'
cd databases/ipv6-assignment && make
make[1]: Entering directory '/home/ipv6/ipv6calc-3.0.0/databases/ipv6-assignment'
test -f dbipv6addr_assignment.h || make update
make[1]: Leaving directory '/home/ipv6/ipv6calc-3.0.0/databases/ipv6-assignment'
cd databases/lib && make
make[1]: Entering directory '/home/ipv6/ipv6calc-3.0.0/databases/lib'
make libipv6calc_db_wrapper.a
make[2]: Entering directory '/home/ipv6/ipv6calc-3.0.0/databases/lib'
/opt/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/sysroots/x86_64-arago-linux/usr/bin/aarch64-linux-gnu-gcc -c libipv6calc_db_wrapper.c -D_GNU_SOURCE -O2 -Wall -g -march=armv8-a -fPIC -mcpu=cortex-a72 --sysroot=/opt/gcc-arm-8.3-2019.03-x86_64-aarch64-linux-gnu/sysroots/aarch64-linux  -Wformat -Werror -Werror=format-security -Wsizeof-array-argument -Wextra -Werror=format-truncation=0 -D__EXTENSIONS__ -fPIC -I../../lib -I../..  
libipv6calc_db_wrapper.c: In function ‘libipv6calc_db_wrapper_info’:
libipv6calc_db_wrapper.c:476:61: error: unused parameter ‘size’ [-Werror=unused-parameter]
 void libipv6calc_db_wrapper_info(char *string, const size_t size) {
                                                ~~~~~~~~~~~~~^~~~
libipv6calc_db_wrapper.c: In function ‘libipv6calc_db_wrapper_capabilities’:
libipv6calc_db_wrapper.c:547:48: error: unused parameter ‘string’ [-Werror=unused-parameter]
 void libipv6calc_db_wrapper_capabilities(char *string, const size_t size) {
                                          ~~~~~~^~~~~~
libipv6calc_db_wrapper.c:547:69: error: unused parameter ‘size’ [-Werror=unused-parameter]
 void libipv6calc_db_wrapper_capabilities(char *string, const size_t size) {
                                                        ~~~~~~~~~~~~~^~~~
libipv6calc_db_wrapper.c: In function ‘libipv6calc_db_wrapper_print_features_verbose’:
libipv6calc_db_wrapper.c:629:7: error: unused variable ‘string’ [-Werror=unused-variable]
  char string[NI_MAXHOST] = "";
       ^~~~~~
libipv6calc_db_wrapper.c: In function ‘libipv6calc_db_wrapper_print_db_info’:
libipv6calc_db_wrapper.c:783:53: error: unused parameter ‘level_verbose’ [-Werror=unused-parameter]
 void libipv6calc_db_wrapper_print_db_info(const int level_verbose, const char *prefix_string) {
                                           ~~~~~~~~~~^~~~~~~~~~~~~
libipv6calc_db_wrapper.c: In function ‘libipv6calc_db_wrapper_ieee_vendor_string_by_macaddr’:
libipv6calc_db_wrapper.c:1950:64: error: unused parameter ‘resultstring’ [-Werror=unused-parameter]
 int libipv6calc_db_wrapper_ieee_vendor_string_by_macaddr(char *resultstring, const size_t resultstring_length, const ipv6calc_macaddr *macaddrp) {
                                                          ~~~~~~^~~~~~~~~~~~
libipv6calc_db_wrapper.c:1950:91: error: unused parameter ‘resultstring_length’ [-Werror=unused-parameter]
 int libipv6calc_db_wrapper_ieee_vendor_string_by_macaddr(char *resultstring, const size_t resultstring_length, const ipv6calc_macaddr *macaddrp) {
                                                                              ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
libipv6calc_db_wrapper.c:1950:136: error: unused parameter ‘macaddrp’ [-Werror=unused-parameter]
 int libipv6calc_db_wrapper_ieee_vendor_string_by_macaddr(char *resultstring, const size_t resultstring_length, const ipv6calc_macaddr *macaddrp) {
                                                                                                                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
libipv6calc_db_wrapper.c: In function ‘libipv6calc_db_wrapper_ieee_vendor_string_short_by_macaddr’:
libipv6calc_db_wrapper.c:1965:70: error: unused parameter ‘resultstring’ [-Werror=unused-parameter]
 int libipv6calc_db_wrapper_ieee_vendor_string_short_by_macaddr(char *resultstring, const size_t resultstring_length, const ipv6calc_macaddr *macaddrp) {
                                                                ~~~~~~^~~~~~~~~~~~
libipv6calc_db_wrapper.c:1965:97: error: unused parameter ‘resultstring_length’ [-Werror=unused-parameter]
 int libipv6calc_db_wrapper_ieee_vendor_string_short_by_macaddr(char *resultstring, const size_t resultstring_length, const ipv6calc_macaddr *macaddrp) {
                                                                                    ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~
libipv6calc_db_wrapper.c:1965:142: error: unused parameter ‘macaddrp’ [-Werror=unused-parameter]
 int libipv6calc_db_wrapper_ieee_vendor_string_short_by_macaddr(char *resultstring, const size_t resultstring_length, const ipv6calc_macaddr *macaddrp) {
                                                                                                                      ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
libipv6calc_db_wrapper.c: In function ‘libipv6calc_db_wrapper_info_by_ipv4addr’:
libipv6calc_db_wrapper.c:2384:87: error: unused parameter ‘string’ [-Werror=unused-parameter]
 int libipv6calc_db_wrapper_info_by_ipv4addr(const ipv6calc_ipv4addr *ipv4addrp, char *string, const size_t string_len) {
                                                                                 ~~~~~~^~~~~~
libipv6calc_db_wrapper.c:2384:108: error: unused parameter ‘string_len’ [-Werror=unused-parameter]
 int libipv6calc_db_wrapper_info_by_ipv4addr(const ipv6calc_ipv4addr *ipv4addrp, char *string, const size_t string_len) {
                                                                                               ~~~~~~~~~~~~~^~~~~~~~~~
libipv6calc_db_wrapper.c: In function ‘libipv6calc_db_wrapper_info_by_ipv6addr’:
libipv6calc_db_wrapper.c:2441:87: error: unused parameter ‘string’ [-Werror=unused-parameter]
 int libipv6calc_db_wrapper_info_by_ipv6addr(const ipv6calc_ipv6addr *ipv6addrp, char *string, const size_t string_len) {
                                                                                 ~~~~~~^~~~~~
libipv6calc_db_wrapper.c:2441:108: error: unused parameter ‘string_len’ [-Werror=unused-parameter]
 int libipv6calc_db_wrapper_info_by_ipv6addr(const ipv6calc_ipv6addr *ipv6addrp, char *string, const size_t string_len) {
                                                                                               ~~~~~~~~~~~~~^~~~~~~~~~
cc1: all warnings being treated as errors
Makefile:46: recipe for target 'libipv6calc_db_wrapper.o' failed
make[2]: *** [libipv6calc_db_wrapper.o] Error 1
make[2]: Leaving directory '/home/ipv6/ipv6calc-3.0.0/databases/lib'
Makefile:42: recipe for target 'all' failed
make[1]: *** [all] Error 2
make[1]: Leaving directory '/home/ipv6/ipv6calc-3.0.0/databases/lib'
Makefile:124: recipe for target 'db-wrapper-make' failed
make: *** [db-wrapper-make] Error 2

Add support for IPv6 -> EUI64/MAC

At present you cannot extract the EUI64 or MAC component from an IPv6 address:

ipv6calc --in ipv6 2001:db8::a8bb:ccff:fedd:eeff --out eui64
Specify proper action or input for output format: eui64
$ ipv6calc --in ipv6 2001:db8::a8bb:ccff:fedd:eeff --out mac  
No valid MAC address given!

However if you use --showinfo then both these values are extracted:

ipv6calc --in ipv6 2001:db8::a8bb:ccff:fedd:eeff --showinfo
Interface identifier: a8bb:ccff:fedd:eeff
EUI-48/MAC address: aa:bb:cc:dd:ee:ff

It would be very helpful if we could extract these values without scraping the --showinfo output.

My reason for requesting this feature is that I would like to take an internal IPv6 address from DNS for a number of hosts on my LAN, extract the EUI64 or MAC component of each, and then append that onto a routable IPv6 prefix from my ISP in order to construct a valid global IPv6 address for each host. I then plan to update DNS records with these newly constructed global IPv6 addresses, so that when my router's IPv4 address changes, all my hosts get their DNS entries updated with their new public IPv6 addresses.

Essentially, I have an IPv6 address and I want to replace the prefix on it with a different prefix. For example, I have the private IP fd00::1234 and I should remove the fd00::/64 prefix, then replace it with the 2001:db8:aaaa:bbbb::/64 prefix instead, to produce the public address 2001:db8:aaaa:bbbb::1234. The prefix is a 6rd one generated from my ISP's IPv6 prefix and my IPv4 address.

I can use ipv6calc to convert the IPv4 address into a valid 6rd prefix, however there doesn't seem to be a way to replace the prefix on a private IPv6 address with a public prefix, or to extract the EUI64/MAC so you can use string concatenation to replace the prefix either.

doc: point to openjade; provide instructions for Lyx->SGML; provide pointers to Debian packages

It took me a while to figure out how to regenerate the ipv6calc.html file from the source ipv6calc.lyx file. I'm filing this to document this for others, and perhaps as a feature enhancement request for doc/generate.sh:

This is a two step process: first, the Lyx file is generated to an SGML. Second, the SGML to the HTML. (Note: I have not figured out what the purpose of the XML file in the source tree is.).

Only the second step is actually in generate.sh.

Step 1: Lyx to SGML

  1. apt install lyx docbook-utils
  2. cd doc && lyx --export docbook ipv6calc.lyx

Step 2: SGML to HTML

The build system seems to be using "jade", but this is an old piece of software that has been forked in the meantime. Replacing "jade" with "openjade" seems to work just fine.

  1. apt install opensp openjade docbook docbook-dsssl
  2. cd doc && onsgmls -s ipv6calc.sgml (This is optional and just validates the SGML. ./generate.sh does this)
  3. cd doc && openjade -t sgml -i html -V nochunks -d "ldp.dsl#html" ipv6calc.sgml > ipv6calc.html (./generate.sh does this)

As an alternative:

  1. (as above)
  2. (as above)
  3. apt install ldp-docbook-dsssl
  4. cd doc && openjade -t sgml -i html -V nochunks -d "docbook/stylesheet/dsssl/ldp/ldp.dsl#html" ipv6calc.sgml > ipv6calc.html (in this case, doc/ldp.dsl is not necessary and can be removed)

ldp here stands for "Linux Documentation Project", and the ldp.dsl file is almost a pristine copy compared to the system copy as shipped in the ldp-docbook-dsssl package.

Versions used

This was under a Debian sid with Lyx v2.3.7, Docbook 4.5, Docbook-utils 0.6.14, Docbook-DSSSL 1.79, OpenJade 1.4devel1, opensp 1.5.2

DBIP Source and DBIP-Generate.pl

The current DBIP source only implements the free databases, as well as the DBIP-Generate.pl script. Is it possible to get them working with the full version from DBIP to improve the output?

I wanted to contact you about looking into the changes since any modifications would be something you could do faster then others being the author of the code.

Build problem on FreeBSD

Hi, I got this when trying to build 0.99.1 on FreeBSD 12 current:

ipv6calc.c:1212:26: error: equality comparison with extraneous parentheses [-Werror,-Wparentheses-equality]
} else if ( (inputtype == FORMAT_mac) ) {
~~~~~~~~~~^~~~~~~~~~~~~
ipv6calc.c:1212:26: note: remove extraneous parentheses around the comparison to silence this warning
} else if ( (inputtype == FORMAT_mac) ) {
~ ^ ~
ipv6calc.c:1212:26: note: use '=' to turn this equality comparison into an assignment
} else if ( (inputtype == FORMAT_mac) ) {
^~
=
ipv6calc.c:1214:26: error: equality comparison with extraneous parentheses [-Werror,-Wparentheses-equality]
} else if ( (inputtype == FORMAT_eui64) ) {
~~~~~~~~~~^~~~~~~~~~~~~~~
ipv6calc.c:1214:26: note: remove extraneous parentheses around the comparison to silence this warning
} else if ( (inputtype == FORMAT_eui64) ) {
~ ^ ~
ipv6calc.c:1214:26: note: use '=' to turn this equality comparison into an assignment
} else if ( (inputtype == FORMAT_eui64) ) {
^~
=
2 errors generated.

After removing parentheses, it builded fine.

Regards.

mod_ipv6calc cannot be build with clang / apxs libtool issue

while libtool honors clang from apxs option call -S CC=clang during --mode compile , it uses unconditional gcc on --mode link

/usr/bin/apxs -S CC=clang -L../lib/ -L../databases/lib/ -lipv6calc_db_wrapper -lipv6calc   -lm -I../ -I../lib/ -I../databases/lib/ -c -Wl,"-lcrypto -ldb -ldb -lcrypto " -Wc,"-O2 -Wall -g -fPIC -D__EXTENSIONS__ -Wformat -Werror -Werror=format-security -Wsizeof-array-argument -Wparentheses-equality -Wextra -Werror=char-subscripts -Wno-deprecated-declarations -Wdate-time -Wno-ignored-optimization-argument" mod_ipv6calc.c
/usr/lib64/apr-1/build/libtool --silent --mode=compile clang -prefer-pic -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS  -fstack-protector-strong  -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer  -DLINUX -D_REENTRANT -D_GNU_SOURCE  -I/usr/include/httpd  -I/usr/include/apr-1   -I/usr/include/apr-1  -O2 -Wall -g -fPIC -D__EXTENSIONS__ -Wformat -Werror -Werror=format-security -Wsizeof-array-argument -Wparentheses-equality -Wextra -Werror=char-subscripts -Wno-deprecated-declarations -Wdate-time -Wno-ignored-optimization-argument -I../ -I../lib/ -I../databases/lib/  -c -o mod_ipv6calc.lo mod_ipv6calc.c && touch mod_ipv6calc.slo
/usr/lib64/apr-1/build/libtool --silent --mode=link clang -Wl,-z,relro -Wl,--as-needed -Wl,-z,now   -Wl,--build-id=sha1   -o mod_ipv6calc.la -lcrypto -ldb -ldb -lcrypto   -L../lib/ -L../databases/lib/ -lipv6calc_db_wrapper -lipv6calc -lm -rpath /usr/lib64/httpd/modules -module -avoid-version    mod_ipv6calc.lo
.libs/mod_ipv6calc.o: file not recognized: file format not recognized
collect2: error: ld returned 1 exit status
apxs:Error: Command failed with rc=65536

bash trace output of --mode link

bash -x /usr/lib64/apr-1/build/libtool --silent --mode=link clang -Wl,-z,relro -Wl,--as-needed -Wl,-z,now   -Wl,--build-id=sha1   -o mod_ipv6calc.la -lcrypto -ldb -ldb -lcrypto   -L../lib/ -L../databases/lib/ -lipv6calc_db_wrapper -lipv6calc -lm -rpath /usr/lib64/httpd/modules -module -avoid-version    mod_ipv6calc.lo
...
+ eval 'gcc -shared  -fPIC -DPIC  .libs/mod_ipv6calc.o   -ldb -lcrypto -L../lib/ -L../databases/lib/ -lipv6calc_db_wrapper -lipv6calc -lm -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-z -Wl,relro -Wl,--as-needed -Wl,-z -Wl,now -Wl,--build-id=sha1   -Wl,-soname -Wl,mod_ipv6calc.so -o .libs/mod_ipv6calc.so'
++ gcc -shared -fPIC -DPIC .libs/mod_ipv6calc.o -ldb -lcrypto -L../lib/ -L../databases/lib/ -lipv6calc_db_wrapper -lipv6calc -lm -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -Wl,-z -Wl,relro -Wl,--as-needed -Wl,-z -Wl,now -Wl,--build-id=sha1 -Wl,-soname -Wl,mod_ipv6calc.so -o .libs/mod_ipv6calc.so
.libs/mod_ipv6calc.o: file not recognized: file format not recognized
collect2: error: ld returned 1 exit status
...

any ideas how to fix this?

Build issue (link) with -fno-common

Issue appeared on FreeBSD HEAD.

LLVM/Clang 11 and GCC 10 has switched to use -fno-common by default.

More info:
Clang modified-compiler-flags
GCC porting
GCC changes

Build issue:

[...]
gmake[5]: Entering directory '/wrkdirs/usr/ports/net-mgmt/ipv6calc/work/ipv6calc-2.2.0/lib'
gmake[5]: 'libipv6calc.a' is up to date.
gmake[5]: Leaving directory '/wrkdirs/usr/ports/net-mgmt/ipv6calc/work/ipv6calc-2.2.0/lib'
gmake libipv6calc.so.2.2.0
gmake[5]: Entering directory '/wrkdirs/usr/ports/net-mgmt/ipv6calc/work/ipv6calc-2.2.0/lib'
ld: error: duplicate symbol: cache_lru_limit
>>> defined at ipv6logconv.h:24 (./ipv6logconv.h:24)
>>>            ipv6logconv.o:(cache_lru_limit)
>>> defined at ipv6logconv.h:24 (./ipv6logconv.h:24)
>>>            ipv6logconvhelp.o:(.bss+0x0)
echo "Nothing to do (shared libary mode is not enabled)"
Nothing to do (shared libary mode is not enabled)
gmake[5]: Leaving directory '/wrkdirs/usr/ports/net-mgmt/ipv6calc/work/ipv6calc-2.2.0/lib'
gmake[4]: Leaving directory '/wrkdirs/usr/ports/net-mgmt/ipv6calc/work/ipv6calc-2.2.0/lib'
gmake[3]: Leaving directory '/wrkdirs/usr/ports/net-mgmt/ipv6calc/work/ipv6calc-2.2.0'
cc -o ipv6calc ipv6calc.o showinfo.o ipv6calchelp_local.o  -L../lib/ -L../databases/lib/ -lipv6calc_db_wrapper -lipv6calc     -lm   -fstack-protector-strong  -lcrypto   -fstack-protector-strong  -lcrypto   -fstack-protector-strong 
cc: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[2]: *** [Makefile:51: ipv6logconv] Error 1
gmake[2]: Leaving directory '/wrkdirs/usr/ports/net-mgmt/ipv6calc/work/ipv6calc-2.2.0/ipv6logconv'
gmake[1]: *** [Makefile:106: ipv6logconv-make] Error 2
gmake[1]: *** Waiting for unfinished jobs....
gmake[2]: Leaving directory '/wrkdirs/usr/ports/net-mgmt/ipv6calc/work/ipv6calc-2.2.0/ipv6logstats'
gmake[2]: Leaving directory '/wrkdirs/usr/ports/net-mgmt/ipv6calc/work/ipv6calc-2.2.0/ipv6loganon'
gmake[2]: Leaving directory '/wrkdirs/usr/ports/net-mgmt/ipv6calc/work/ipv6calc-2.2.0/ipv6calc'
gmake[1]: Leaving directory '/wrkdirs/usr/ports/net-mgmt/ipv6calc/work/ipv6calc-2.2.0'
===> Compilation failed unexpectedly.
Try to set MAKE_JOBS_UNSAFE=yes and rebuild before reporting the failure to
the maintainer.
*** Error code 1

ipv6calc-db-update.sh won't download files

In ipv6calc-db-update.sh, the "skip_download" variable is always set to "true", so it won't download any files. The variable should be set to "false" by default, and only assigned "true" when the "-s" switch is provided.

ipv6calc 3.0.1 osx build failure

👋 trying to build the latest release, but run into some build issue. The error log is as below:

build failure
==> ./configure --prefix=/usr/local/Cellar/ipv6calc/3.0.1 --mandir=/usr/local/Cellar/ipv6calc/3.0.1/share/man
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking for gcc... clang
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether clang accepts -g... yes
checking for clang option to accept ISO C89... none needed
checking for ranlib... ranlib
checking whether make sets $(MAKE)... yes
checking how to run the C preprocessor... clang -E
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for ANSI C header files... yes
checking for an ANSI C-conforming const... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for off_t... yes
checking for size_t... yes
checking whether byte ordering is bigendian... no
**** analyze compiler options: CC=clang
*** check for CFLAGS: -Werror=format-security
*** CFLAGS supported: -Werror=format-security
*** check for CFLAGS: -Wsizeof-array-argument
*** CFLAGS supported: -Wsizeof-array-argument
*** check for CFLAGS: -Wparentheses-equality
*** CFLAGS supported: -Wparentheses-equality
*** check for CFLAGS: -Wextra
*** CFLAGS supported: -Wextra
*** check for CFLAGS: -Werror=format-truncation=0
configure: WARNING: *** missing CFLAGS support: -Werror=format-truncation=0
checking for getopt_long... yes
*** use of system getopt library autoselected
checking openssl/md5.h usability... no
checking openssl/md5.h presence... no
checking for openssl/md5.h... no
configure: WARNING: openssl/md5.h header file not found (will use bundled MD5 function).
checking dlfcn.h usability... yes
checking dlfcn.h presence... yes
checking for dlfcn.h... yes
libipv6calc_db_wrapper.c:2330:39: error: no member named 's6_addr32' in 'struct in6_addr'
            &&  (&cache_lu_ipv6addr.in6_addr.s6_addr32[0] == &ipv6addrp->in6_addr.s6_addr32[0])
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
libipv6calc_db_wrapper.c:2330:76: error: no member named 's6_addr32' in 'struct in6_addr'
            &&  (&cache_lu_ipv6addr.in6_addr.s6_addr32[0] == &ipv6addrp->in6_addr.s6_addr32[0])
                                                              ~~~~~~~~~~~~~~~~~~~ ^
libipv6calc_db_wrapper.c:2331:39: error: no member named 's6_addr32' in 'struct in6_addr'
            &&  (&cache_lu_ipv6addr.in6_addr.s6_addr32[1] == &ipv6addrp->in6_addr.s6_addr32[1])
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
libipv6calc_db_wrapper.c:2331:76: error: no member named 's6_addr32' in 'struct in6_addr'
            &&  (&cache_lu_ipv6addr.in6_addr.s6_addr32[1] == &ipv6addrp->in6_addr.s6_addr32[1])
                                                              ~~~~~~~~~~~~~~~~~~~ ^
libipv6calc_db_wrapper.c:2332:39: error: no member named 's6_addr32' in 'struct in6_addr'
            &&  (&cache_lu_ipv6addr.in6_addr.s6_addr32[2] == &ipv6addrp->in6_addr.s6_addr32[2])
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
libipv6calc_db_wrapper.c:2332:76: error: no member named 's6_addr32' in 'struct in6_addr'
            &&  (&cache_lu_ipv6addr.in6_addr.s6_addr32[2] == &ipv6addrp->in6_addr.s6_addr32[2])
                                                              ~~~~~~~~~~~~~~~~~~~ ^
libipv6calc_db_wrapper.c:2333:39: error: no member named 's6_addr32' in 'struct in6_addr'
            &&  (&cache_lu_ipv6addr.in6_addr.s6_addr32[3] == &ipv6addrp->in6_addr.s6_addr32[3])
                  ~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
libipv6calc_db_wrapper.c:2333:76: error: no member named 's6_addr32' in 'struct in6_addr'
            &&  (&cache_lu_ipv6addr.in6_addr.s6_addr32[3] == &ipv6addrp->in6_addr.s6_addr32[3])
                                                              ~~~~~~~~~~~~~~~~~~~ ^
8 errors generated.
make[2]: *** [libipv6calc_db_wrapper.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [all] Error 2
make: *** [db-wrapper-make] Error 2

Full build log is in here, https://github.com/Homebrew/homebrew-core/runs/1698228351
relates to Homebrew/homebrew-core#68962

Compiled timestamp in the help output hurts build reproducibility

Building with -Wdate-time results into this warning:

gcc -c ipv6calchelp.c -Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -ffile-prefix-map=/root/2023-12-ipv6calc/ipv6calc=. -fstack-protector-stro
ng -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -D__EXTENSIONS__ -fPIC -D__EXTENSIONS__ -fPIC -I. -I../ -I
../databases/lib/  -I../md5  
ipv6calchelp.c: In function ‘ipv6calc_print_features_verbose’:
ipv6calchelp.c:950:49: warning: macro "__DATE__" might prevent reproducible builds [-Wdate-time]
  950 |         fprintf(stderr, "Compiled: %s  %s\n\n", __DATE__, __TIME__);
      |                                                 ^~~~~~~~
ipv6calchelp.c:950:59: warning: macro "__TIME__" might prevent reproducible builds [-Wdate-time]
  950 |         fprintf(stderr, "Compiled: %s  %s\n\n", __DATE__, __TIME__);
      |                                                           ^~~~~~~~

Build reproducibility is the concept that builds in equivalent build environments should result in the same output. https://reproducible-builds.org/ has more information.

I'd recommend avoiding this fprintf altogether.

Compilation fails due to unused parameter errors

Though I had succeeded at compiling the code from git in recent past, the recent code fails to compile due to unused parameter errors.

make[2]: Entering directory '/var/build-git/ipv6calc/databases/lib'
gcc -c libipv6calc_db_wrapper.c -D_GNU_SOURCE -O2 -Wall -g -fPIC -Wformat -Werror -Werror=format-security -Wsizeof-array-argument -Wextra -Werror=format-truncation=0 -Werror=char-subscripts -D__EXTENSIONS__ -fPIC -I../../lib -I../..
libipv6calc_db_wrapper.c: In function ‘libipv6calc_db_dump’:
libipv6calc_db_wrapper.c:3842:126: error: unused parameter ‘outputtype’ [-Werror=unused-parameter]
 3842 | p(const int source, const int selector, const s_ipv6calc_filter_master *filter_master, const uint32_t outputtype, const uint32_t formatoptions, const char *name_ipset) {
      |                                                                                        ~~~~~~~~~~~~~~~^~~~~~~~~~

libipv6calc_db_wrapper.c:3842:180: error: unused parameter ‘name_ipset’ [-Werror=unused-parameter]
 3842 | pv6calc_filter_master *filter_master, const uint32_t outputtype, const uint32_t formatoptions, const char *name_ipset) {
      |                                                                                                ~~~~~~~~~~~~^~~~~~~~~~

cc1: all warnings being treated as errors
make[2]: *** [Makefile:46: libipv6calc_db_wrapper.o] Error 1
make[2]: Leaving directory '/var/build-git/ipv6calc/databases/lib'
make[1]: *** [Makefile:42: all] Error 2
make[1]: Leaving directory '/var/build-git/ipv6calc/databases/lib'
make: *** [Makefile:124: db-wrapper-make] Error 2

Fix compiler warning related to predefined defaults for external lib and database dir

Currently idea missing how to proper fix this without breaking existing code:

gcc -o libipv6calc_db_wrapper.so.3.1.0 libipv6calc_db_wrapper.o libipv6calc_db_wrapper_MMDB.o libipv6calc_db_wrapper_GeoIP2.o libipv6calc_db_wrapper_IP2Location.o libipv6calc_db_wrapper_DBIP2.o libipv6calc_db_wrapper_External.o libipv6calc_db_wrapper_BuiltIn.o -lcrypto -Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld  -ldb -shared -Wl,-soname,libipv6calc_db_wrapper.so.3.1.0
libipv6calc_db_wrapper_External.h:69:13: warning: type of 'external_db_dir' does not match original declaration [-Wlto-type-mismatch]
   69 | extern char external_db_dir[NI_MAXHOST];
      |             ^
libipv6calc_db_wrapper_External.c:33:6: note: array types have different bounds
   33 | char external_db_dir[NI_MAXHOST] = EXTERNAL_DB;
      |      ^
libipv6calc_db_wrapper_External.c:33:6: note: 'external_db_dir' was previously declared here
libipv6calc_db_wrapper_IP2Location.h:597:13: warning: type of 'ip2location_db_dir' does not match original declaration [-Wlto-type-mismatch]
  597 | extern char ip2location_db_dir[NI_MAXHOST];
      |             ^
libipv6calc_db_wrapper_IP2Location.c:33:6: note: array types have different bounds
   33 | char ip2location_db_dir[NI_MAXHOST] = IP2LOCATION_DB;
      |      ^
libipv6calc_db_wrapper_IP2Location.c:33:6: note: 'ip2location_db_dir' was previously declared here
libipv6calc_db_wrapper_IP2Location.h:596:13: warning: type of 'ip2location_lib_file' does not match original declaration [-Wlto-type-mismatch]
  596 | extern char ip2location_lib_file[NI_MAXHOST];
      |             ^
libipv6calc_db_wrapper_IP2Location.c:45:6: note: array types have different bounds
   45 | char ip2location_lib_file[NI_MAXHOST] = IP2LOCATION_DYN_LIB;
      |      ^
libipv6calc_db_wrapper_IP2Location.c:45:6: note: 'ip2location_lib_file' was previously declared here

Several questions regarding IPv6 categorization

Hi,

I have a list with some IPv6 addresses I would like to put them into perspective.
I would like to specify to which of those assignment a specific IP belongs.
http://www.iana.org/assignments/ipv6-unicast-address-assignments/ipv6-unicast-address-assignments.xhtml
What I need to do for that is making a comparison of a given network prefix like 2001:0600::/23 and see if my specific IP address belongs to that range.

Is there any way your toolkit can do this for me? If not, do you have any suggestions for me?

Tests fail when the machine running them has high load

While building and running tests for ipv6calc 2.0.0 on a quite busy machine, it failed unexpectedly:

$ make test-minimal
...
make[3]: Leaving directory '/build/ipv6calc/src/ipv6calc-2.0.0/ipv6calc'
~/ipv6calc/src/ipv6calc-2.0.0/ipv6calcweb
# Pseudo random selected
LD_LIBRARY_PATH=../lib:../databases/lib: ./test_ipv6calcweb.sh 2001:200:1:ea::1 || exit 1
++ HTTP_IPV6CALCWEB_OUTPUT_FORMAT=html
++ HTTP_IPV6CALCWEB_OUTPUT_FORMAT_HTML_DB=subcolumns
++ REMOTE_ADDR=50.60.70.80
++ ./ipv6calcweb.cgi
+ stderr='ipv6calcweb.cgi WARN  : System overloaded by load15 load=17.25/17.63/17.16 load_norm=2.15625/2.20375/2.145 limit=2/1.5/1 cpus=8'
+ set +x
ERROR : stderr not empty: ipv6calcweb.cgi WARN  : System overloaded by load15 load=17.25/17.63/17.16 load_norm=2.15625/2.20375/2.145 limit=2/1.5/1 cpus=8
make[2]: *** [Makefile:32: test] Error 1
make[2]: Leaving directory '/build/ipv6calc/src/ipv6calc-2.0.0/ipv6calcweb'
make[1]: *** [Makefile:43: test-minimal] Error 2
make[1]: Leaving directory '/build/ipv6calc/src/ipv6calc-2.0.0/ipv6calcweb'
Result: 2
make: *** [Makefile:176: test-minimal] Error 2

I wouldn't expect the system load to impact the results of tests! Is it possible to disable this kind of warnings during tests?

IPv6 addresses do not follow RFC 5952

Compressed IPv6 addresses are formatted as per RFC 1884 section 2.2, which is arguably unclear about whether a single zero should be replaced by ::. (Even though RFC 1884 does say "[the] use of "::" indicates multiple groups of 16-bits of zeros", with the most common interpretation of "multiple" being "> 1".)

However RFC 1884 was obsoleted by successive versions of "IP Version 6 Addressing Architecture", with the latest being RFC 4291 (which explicitly allows for both :0: and ::). But RFC 4291 was (according to IETF) updated by (among others) RFC 5952 and while the latter is titled "Recommendation", in section 4.2.2 it explicitly disallows using :: to replace a single zero:

   The symbol "::" MUST NOT be used to shorten just one 16-bit 0 field.
   For example, the representation 2001:db8:0:1:1:1:1:1 is correct, but
   2001:db8::1:1:1:1:1 is not correct.

It would seem to me like the only code change necessary in ipv6calc would be to bump this >= 0 test to >= 1. (And maybe simplify the logic a bit. And rename the file from librfc1884.c to librfc5952.c.)


For context, we are running into issues string matching (within Prometheus labels) IPv6 addresses generated by Rust library code (that implements RFC 5952) with ones generated by ipv6calc for about half the IP addresses we use (which have exactly one zero segment). And make it impossible to match the instance label of our process with that of node-exporter, so we're "missing" machine metrics for about half our instances.

Tarball signature issues

  1. The signature seems to be using the obsolete SHA1 digest algorithm:
gpgv: Signature made Tue Jun 13 03:23:32 2023 UTC
gpgv:                using RSA key AAB38CB797C750C778C608C6DDEB141DF7380F61
gpgv: Note: signatures using the SHA1 algorithm are rejected
gpgv: Can't check signature: Bad public key

This is likely due to an older version of GnuPG as I think newer versions have improved defaults.

But you can override the defaults using --personal-cipher-preferences, I believe.

  1. It looks like your key has expired:
$ gpg --list-keys AAB38CB797C750C778C608C6DDEB141DF7380F61
pub   rsa4096/0xDDEB141DF7380F61 2013-11-04 [SC] [expired: 2022-02-04]
      Key fingerprint = AAB3 8CB7 97C7 50C7 78C6  08C6 DDEB 141D F738 0F61
uid                   [ expired] Peter Bieringer (Code Signing Key 2013) <[email protected]>
uid                   [ expired] [jpeg image of size 2653]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.