From a28dec3c2d4b91fe5d24930eb8a5738065f9054a Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 16 Feb 2022 17:54:01 +0100 Subject: [PATCH] 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 --- miniupnpd/configure | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/miniupnpd/configure b/miniupnpd/configure index 273762c..6dc030d 100755 --- a/miniupnpd/configure +++ b/miniupnpd/configure @@ -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= 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}