configure: expose USE_GETIFADDRS configuration

The miniupnpd sources contain a working getifaddrs() based implementation
to fetch the IP address of an interface but that implementation is guarded
by a USE_GETIFADDRS define which can only be passed manually via CFLAGS.

Introduce a new `--getifaddrs` option to the configure script which can be
used to explicitly enable `getifaddrs()` usage.

Also extend the OpenWrt configuration case to enable `getifaddrs()` since
OpenWrt ships with a working implementation of it since several years
already.

Signed-off-by: Jo-Philipp Wich <jo@mein.io>
This commit is contained in:
Jo-Philipp Wich 2022-02-16 17:54:01 +01:00
parent 9df2f43e08
commit a28dec3c2d
1 changed files with 10 additions and 0 deletions

10
miniupnpd/configure vendored
View File

@ -47,6 +47,7 @@ case "$argv" in
FW=$(echo $argv | cut -d= -f2) ;;
--iptablespath=*)
IPTABLESPATH=$(echo $argv | cut -d= -f2) ;;
--getifaddrs) GETIFADDRS=1 ;;
--help|-h)
echo "Usage : $0 [options]"
echo " --ipv6 enable IPv6"
@ -62,6 +63,7 @@ case "$argv" in
echo " --firewall=<name> force the firewall type (nftables, iptables, pf, ipf, ipfw)"
echo " --iptablespath=/path/to/iptables use a specific version of iptables"
echo " --disable-fork Do not go to background and do not write pid file"
echo " --getifaddrs Force use getifaddrs() to obtain interface addresses"
exit 1
;;
*)
@ -387,6 +389,7 @@ case $OS_NAME in
OpenWrt)
OS_URL=http://www.openwrt.org/
echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
GETIFADDRS=1
;;
OpenEmbedded)
OS_URL=http://www.openembedded.org/
@ -850,6 +853,13 @@ else
echo "/*#define NO_BACKGROUND_NO_PIDFILE*/" >> ${CONFIGFILE}
fi
echo "/* Whether to use getifaddrs() to determine interface addresses */" >> ${CONFIGFILE}
if [ -n "$GETIFADDRS" ] && [ $GETIFADDRS -eq 1 ] ; then
echo "#define USE_GETIFADDRS" >> ${CONFIGFILE}
else
echo "/*#define USE_GETIFADDRS*/" >> ${CONFIGFILE}
fi
echo "#endif /* ${CONFIGMACRO} */" >> ${CONFIGFILE}
${MV} ${CONFIGFILE} ${CONFIGFILE_FINAL}