2011-09-28 19:13:20 +00:00
|
|
|
|
#! /bin/sh
|
2020-10-30 22:11:44 +00:00
|
|
|
|
# $Id: configure,v 1.114 2020/10/30 22:10:26 nanard Exp $
|
2016-12-28 11:10:06 +00:00
|
|
|
|
# vim: tabstop=4 shiftwidth=4 noexpandtab
|
|
|
|
|
#
|
2011-09-28 19:13:20 +00:00
|
|
|
|
# miniupnp daemon
|
2018-01-16 01:06:46 +00:00
|
|
|
|
# http://miniupnp.free.fr or https://miniupnp.tuxfamily.org/
|
2020-03-29 08:54:26 +00:00
|
|
|
|
# (c) 2006-2020 Thomas Bernard
|
2011-09-28 19:13:20 +00:00
|
|
|
|
# This software is subject to the conditions detailed in the
|
|
|
|
|
# LICENCE file provided within the distribution
|
|
|
|
|
|
2015-12-19 10:52:38 +00:00
|
|
|
|
# default to UPnP Device Architecture (UDA) v1.1
|
|
|
|
|
# some control points do not like UDA v2.0
|
|
|
|
|
UPNP_VERSION_MAJOR=1
|
|
|
|
|
UPNP_VERSION_MINOR=1
|
2015-12-11 13:37:59 +00:00
|
|
|
|
|
2020-05-02 16:08:59 +00:00
|
|
|
|
# input environment variables :
|
|
|
|
|
# IPV6, IGD2, STRICT, DEBUG, LEASFILE, VENDORCFG, PCP_PEER,
|
|
|
|
|
# PORTINUSE, DISABLEPPPCONN, FW, IPTABLESPATH, TARGET_OPENWRT,
|
2020-06-03 21:43:58 +00:00
|
|
|
|
# PKG_CONFIG, NO_BACKGROUND_NO_PIDFILE
|
2020-05-02 16:08:59 +00:00
|
|
|
|
|
2012-04-14 22:35:31 +00:00
|
|
|
|
for argv; do
|
|
|
|
|
case "$argv" in
|
|
|
|
|
--ipv6) IPV6=1 ;;
|
|
|
|
|
--igd2) IGD2=1 ;;
|
|
|
|
|
--strict) STRICT=1 ;;
|
2019-10-06 08:06:44 +00:00
|
|
|
|
--debug) DEBUG=1 ;;
|
2012-04-14 22:35:31 +00:00
|
|
|
|
--leasefile) LEASEFILE=1 ;;
|
2013-12-13 18:40:52 +00:00
|
|
|
|
--vendorcfg) VENDORCFG=1 ;;
|
2014-03-13 10:24:04 +00:00
|
|
|
|
--pcp-peer) PCP_PEER=1 ;;
|
2014-03-13 13:48:52 +00:00
|
|
|
|
--portinuse) PORTINUSE=1 ;;
|
2015-12-11 13:37:59 +00:00
|
|
|
|
--uda-version=*)
|
|
|
|
|
UPNP_VERSION=$(echo $argv | cut -d= -f2)
|
|
|
|
|
UPNP_VERSION_MAJOR=$(echo $UPNP_VERSION | cut -s -d. -f1)
|
|
|
|
|
UPNP_VERSION_MINOR=$(echo $UPNP_VERSION | cut -s -d. -f2)
|
|
|
|
|
echo "Setting UPnP version major=$UPNP_VERSION_MAJOR minor=$UPNP_VERSION_MINOR"
|
|
|
|
|
if [ -z "$UPNP_VERSION_MAJOR" ] || [ -z "$UPNP_VERSION_MINOR" ] ; then
|
|
|
|
|
echo "UPnP Version invalid in option $argv"
|
|
|
|
|
exit 1
|
|
|
|
|
fi ;;
|
2015-12-13 14:57:49 +00:00
|
|
|
|
--disable-pppconn) DISABLEPPPCONN=1 ;;
|
2020-06-03 21:43:58 +00:00
|
|
|
|
--disable-fork) NO_BACKGROUND_NO_PIDFILE=1 ;;
|
2019-09-29 05:17:51 +00:00
|
|
|
|
--firewall=*)
|
|
|
|
|
FW=$(echo $argv | cut -d= -f2) ;;
|
2020-05-02 16:08:59 +00:00
|
|
|
|
--iptablespath=*)
|
|
|
|
|
IPTABLESPATH=$(echo $argv | cut -d= -f2) ;;
|
2012-04-14 22:35:31 +00:00
|
|
|
|
--help|-h)
|
|
|
|
|
echo "Usage : $0 [options]"
|
|
|
|
|
echo " --ipv6 enable IPv6"
|
|
|
|
|
echo " --igd2 build an IGDv2 instead of an IGDv1"
|
|
|
|
|
echo " --strict be more strict regarding compliance with UPnP specifications"
|
2019-10-06 08:06:44 +00:00
|
|
|
|
echo " --debug #define DEBUG 1"
|
2012-04-14 22:35:31 +00:00
|
|
|
|
echo " --leasefile enable lease file"
|
2013-12-13 18:40:52 +00:00
|
|
|
|
echo " --vendorcfg enable configuration of manufacturer info"
|
2013-07-09 13:36:53 +00:00
|
|
|
|
echo " --pcp-peer enable PCP PEER operation"
|
2014-03-13 13:48:52 +00:00
|
|
|
|
echo " --portinuse enable port in use check"
|
2015-12-12 08:10:54 +00:00
|
|
|
|
echo " --uda-version=x.x set advertised UPnP version (default to ${UPNP_VERSION_MAJOR}.${UPNP_VERSION_MINOR})"
|
2015-12-13 14:57:49 +00:00
|
|
|
|
echo " --disable-pppconn disable WANPPPConnection"
|
2020-04-20 22:20:43 +00:00
|
|
|
|
echo " --firewall=<name> force the firewall type (nftables, iptables, pf, ipf, ipfw)"
|
2020-05-02 16:08:59 +00:00
|
|
|
|
echo " --iptablespath=/path/to/iptables use a specific version of iptables"
|
2020-06-03 21:43:58 +00:00
|
|
|
|
echo " --disable-fork Do not go to background and do not write pid file"
|
2012-04-14 22:35:31 +00:00
|
|
|
|
exit 1
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
echo "Option not recognized : $argv"
|
|
|
|
|
echo "use -h option to display help"
|
|
|
|
|
exit 1
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
done
|
|
|
|
|
|
2020-06-03 21:54:24 +00:00
|
|
|
|
echo $* > .configure.cache
|
2020-05-03 23:31:31 +00:00
|
|
|
|
BASEDIR=`dirname "$0"`
|
2011-09-28 19:13:20 +00:00
|
|
|
|
RM="rm -f"
|
2013-04-24 17:04:00 +00:00
|
|
|
|
MV="mv"
|
2015-07-16 15:16:52 +00:00
|
|
|
|
CONFIGFILE=`mktemp tmp.config.h.XXXXXXXXXX`
|
2013-04-24 17:04:00 +00:00
|
|
|
|
CONFIGFILE_FINAL="config.h"
|
2012-09-20 20:52:51 +00:00
|
|
|
|
CONFIGMACRO="CONFIG_H_INCLUDED"
|
2020-04-28 23:51:00 +00:00
|
|
|
|
if [ -z "$PKG_CONFIG" ] ; then
|
|
|
|
|
PKG_CONFIG=`which pkg-config`
|
|
|
|
|
fi
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
2015-09-21 20:37:50 +00:00
|
|
|
|
MINIUPNPD_DATE=`date +"%Y%m%d"`
|
2017-04-13 19:08:51 +00:00
|
|
|
|
if [ -n "$SOURCE_DATE_EPOCH" ]; then
|
|
|
|
|
MINIUPNPD_DATE=`date --utc --date="@$SOURCE_DATE_EPOCH" +"%Y%m%d"`
|
|
|
|
|
fi
|
|
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
|
# Facility to syslog
|
|
|
|
|
LOG_MINIUPNPD="LOG_DAEMON"
|
|
|
|
|
|
|
|
|
|
# detecting the OS name and version
|
|
|
|
|
OS_NAME=`uname -s`
|
|
|
|
|
OS_VERSION=`uname -r`
|
2020-05-02 16:08:59 +00:00
|
|
|
|
OS_MACHINE=`uname -m`
|
2020-04-20 22:42:13 +00:00
|
|
|
|
# Makefile to use
|
|
|
|
|
MAKEFILE=
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
|
|
|
|
# pfSense special case
|
|
|
|
|
if [ -f /etc/platform ]; then
|
|
|
|
|
if [ `cat /etc/platform` = "pfSense" ]; then
|
|
|
|
|
OS_NAME=pfSense
|
|
|
|
|
OS_VERSION=`cat /etc/version`
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
# OpenWRT special case
|
|
|
|
|
if [ -f ./os.openwrt ]; then
|
|
|
|
|
OS_NAME=OpenWRT
|
|
|
|
|
OS_VERSION=$(cat ./os.openwrt)
|
|
|
|
|
fi
|
|
|
|
|
|
2012-07-10 21:19:08 +00:00
|
|
|
|
# AstLinux special case
|
|
|
|
|
if [ -f ./os.astlinux ]; then
|
|
|
|
|
OS_NAME=AstLinux
|
|
|
|
|
OS_VERSION=$(cat ./os.astlinux)
|
|
|
|
|
fi
|
|
|
|
|
|
2012-01-20 21:53:15 +00:00
|
|
|
|
# Tomato USB special case
|
|
|
|
|
if [ -f ../shared/tomato_version ]; then
|
|
|
|
|
OS_NAME=Tomato
|
2015-06-15 16:47:34 +00:00
|
|
|
|
TOMATO_VER=`cat ../shared/tomato_version | cut -d' ' -f2,3`
|
|
|
|
|
OS_VERSION="Tomato $TOMATO_VER"
|
2012-01-20 21:53:15 +00:00
|
|
|
|
fi
|
|
|
|
|
|
2018-12-23 02:47:45 +00:00
|
|
|
|
# OpenEmbedded special case
|
|
|
|
|
if [ -f ./os.openembedded ]; then
|
|
|
|
|
OS_NAME=OpenEmbedded
|
|
|
|
|
OS_VERSION=$(cat ./os.openembedded)
|
|
|
|
|
fi
|
|
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
|
${RM} ${CONFIGFILE}
|
|
|
|
|
|
|
|
|
|
echo "/* MiniUPnP Project" >> ${CONFIGFILE}
|
2017-05-27 08:25:53 +00:00
|
|
|
|
echo " * http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/" >> ${CONFIGFILE}
|
2020-03-29 08:54:26 +00:00
|
|
|
|
echo " * (c) 2006-2020 Thomas Bernard" >> ${CONFIGFILE}
|
2012-05-09 21:32:05 +00:00
|
|
|
|
echo " * generated by $0 on `date`" >> ${CONFIGFILE}
|
2015-12-12 08:13:05 +00:00
|
|
|
|
echo " * `uname -a`" >> ${CONFIGFILE}
|
2016-02-09 09:16:45 +00:00
|
|
|
|
if [ -z "$*" ] ; then
|
|
|
|
|
echo " * using no command line option */" >> ${CONFIGFILE}
|
|
|
|
|
else
|
|
|
|
|
echo " * using command line options $* */" >> ${CONFIGFILE}
|
|
|
|
|
fi
|
2011-09-28 19:13:20 +00:00
|
|
|
|
echo "#ifndef $CONFIGMACRO" >> ${CONFIGFILE}
|
|
|
|
|
echo "#define $CONFIGMACRO" >> ${CONFIGFILE}
|
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
echo "#include <inttypes.h>" >> ${CONFIGFILE}
|
|
|
|
|
echo "" >> ${CONFIGFILE}
|
2020-05-03 23:31:31 +00:00
|
|
|
|
echo "#define MINIUPNPD_VERSION \"`cat ${BASEDIR}/VERSION`\"" >> ${CONFIGFILE}
|
2015-09-21 20:37:50 +00:00
|
|
|
|
echo "#define MINIUPNPD_DATE \"$MINIUPNPD_DATE\"" >> ${CONFIGFILE}
|
2015-09-21 20:39:30 +00:00
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
|
2019-10-06 08:06:44 +00:00
|
|
|
|
if [ -n "$DEBUG" ] ; then
|
|
|
|
|
echo "#define DEBUG 1" >> ${CONFIGFILE}
|
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
fi
|
|
|
|
|
|
2015-09-21 20:39:30 +00:00
|
|
|
|
cat >> ${CONFIGFILE} <<EOF
|
|
|
|
|
#ifndef XSTR
|
|
|
|
|
#define XSTR(s) STR(s)
|
|
|
|
|
#define STR(s) #s
|
|
|
|
|
#endif /* XSTR */
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
cat >> ${CONFIGFILE} <<EOF
|
|
|
|
|
/* UPnP version reported in XML descriptions
|
|
|
|
|
* 1.0 / 1.1 / 2.0 depending on which UDA (UPnP Device Architecture) Version */
|
2015-12-11 13:37:59 +00:00
|
|
|
|
#define UPNP_VERSION_MAJOR ${UPNP_VERSION_MAJOR}
|
|
|
|
|
#define UPNP_VERSION_MINOR ${UPNP_VERSION_MINOR}
|
2015-09-21 20:39:30 +00:00
|
|
|
|
#define UPNP_VERSION_MAJOR_STR XSTR(UPNP_VERSION_MAJOR)
|
|
|
|
|
#define UPNP_VERSION_MINOR_STR XSTR(UPNP_VERSION_MINOR)
|
|
|
|
|
EOF
|
2011-09-28 19:13:20 +00:00
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
|
|
|
|
|
# OS Specific stuff
|
|
|
|
|
case $OS_NAME in
|
|
|
|
|
OpenBSD)
|
2020-04-20 22:42:13 +00:00
|
|
|
|
MAKEFILE=Makefile.bsd
|
2011-09-28 19:13:20 +00:00
|
|
|
|
MAJORVER=`echo $OS_VERSION | cut -d. -f1`
|
|
|
|
|
MINORVER=`echo $OS_VERSION | cut -d. -f2`
|
|
|
|
|
#echo "OpenBSD majorversion=$MAJORVER minorversion=$MINORVER"
|
2019-10-03 21:23:53 +00:00
|
|
|
|
# The pledge() system call first appeared in OpenBSD 5.9.
|
|
|
|
|
if [ \( $MAJORVER -ge 6 \) -o \( $MAJORVER -eq 5 -a $MINORVER -ge 9 \) ]; then
|
2020-06-03 21:10:53 +00:00
|
|
|
|
# as of writing (OpenBSD 6.7) DIOCGETRULES is not included in the
|
|
|
|
|
# operations allowed by the "pf" pledge.
|
2020-06-03 22:30:01 +00:00
|
|
|
|
echo "/*#define HAS_PLEDGE*/" >> ${CONFIGFILE}
|
2019-10-03 21:23:53 +00:00
|
|
|
|
fi
|
2011-09-28 19:13:20 +00:00
|
|
|
|
# rtableid was introduced in OpenBSD 4.0
|
|
|
|
|
if [ $MAJORVER -ge 4 ]; then
|
|
|
|
|
echo "#define PFRULE_HAS_RTABLEID" >> ${CONFIGFILE}
|
|
|
|
|
fi
|
|
|
|
|
# from the 3.8 version, packets and bytes counters are double : in/out
|
|
|
|
|
if [ \( $MAJORVER -ge 4 \) -o \( $MAJORVER -eq 3 -a $MINORVER -ge 8 \) ]; then
|
|
|
|
|
echo "#define PFRULE_INOUT_COUNTS" >> ${CONFIGFILE}
|
|
|
|
|
fi
|
|
|
|
|
# from the 4.7 version, new pf
|
|
|
|
|
if [ \( $MAJORVER -ge 5 \) -o \( $MAJORVER -eq 4 -a $MINORVER -ge 7 \) ]; then
|
|
|
|
|
echo "#define PF_NEWSTYLE" >> ${CONFIGFILE}
|
|
|
|
|
fi
|
2012-01-20 22:00:37 +00:00
|
|
|
|
# onrdomain was introduced in OpenBSD 5.0
|
|
|
|
|
if [ $MAJORVER -ge 5 ]; then
|
|
|
|
|
echo "#define PFRULE_HAS_ONRDOMAIN" >> ${CONFIGFILE}
|
|
|
|
|
fi
|
2020-10-30 21:14:45 +00:00
|
|
|
|
# before OpenBSD 5.5 inpt_queue was CIRCLEQ
|
|
|
|
|
if [ $MAJORVER -lt 5 ] || [ $MAJORVER -eq 5 -a $MINORVER -lt 5 ]; then
|
|
|
|
|
echo "#define INPT_QUEUE_IS_CIRCLEQ" >> ${CONFIGFILE}
|
|
|
|
|
fi
|
2011-09-28 19:13:20 +00:00
|
|
|
|
FW=pf
|
|
|
|
|
echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
|
|
|
|
|
OS_URL=http://www.openbsd.org/
|
2019-09-24 14:06:38 +00:00
|
|
|
|
# net.inet6.ip6.v6only has been removed in recent OpenBSD versions
|
|
|
|
|
# Default to 1 in that case
|
2019-09-26 21:46:24 +00:00
|
|
|
|
if sysctl net.inet6.ip6 | grep net.inet6.ip6.v6only ; then
|
|
|
|
|
V6SOCKETS_ARE_V6ONLY=`sysctl -n net.inet6.ip6.v6only`
|
|
|
|
|
else
|
|
|
|
|
V6SOCKETS_ARE_V6ONLY=1
|
|
|
|
|
fi
|
2011-09-28 19:13:20 +00:00
|
|
|
|
;;
|
2018-05-08 13:59:15 +00:00
|
|
|
|
FreeBSD | GNU/kFreeBSD)
|
2020-04-20 22:42:13 +00:00
|
|
|
|
MAKEFILE=Makefile.bsd
|
2011-09-28 19:13:20 +00:00
|
|
|
|
VER=`grep '#define __FreeBSD_version' /usr/include/sys/param.h | awk '{print $3}'`
|
|
|
|
|
if [ $VER -ge 700049 ]; then
|
|
|
|
|
echo "#define PFRULE_INOUT_COUNTS" >> ${CONFIGFILE}
|
|
|
|
|
fi
|
2015-08-25 18:33:47 +00:00
|
|
|
|
HAVE_IP_MREQN=1
|
2011-09-28 19:13:20 +00:00
|
|
|
|
# new way to see which one to use PF or IPF.
|
|
|
|
|
# see http://miniupnp.tuxfamily.org/forum/viewtopic.php?p=957
|
2020-04-20 22:20:43 +00:00
|
|
|
|
if [ -z $FW ] && [ -f /etc/rc.subr ] && [ -f /etc/defaults/rc.conf ] ; then
|
2012-05-31 13:33:16 +00:00
|
|
|
|
# source file with handy subroutines like checkyesno
|
|
|
|
|
. /etc/rc.subr
|
|
|
|
|
# source config file so we can probe vars
|
2020-03-29 08:54:26 +00:00
|
|
|
|
. /etc/defaults/rc.conf
|
|
|
|
|
if [ -f /etc/rc.conf ] ; then
|
|
|
|
|
. /etc/rc.conf
|
|
|
|
|
fi
|
2012-05-31 13:33:16 +00:00
|
|
|
|
if checkyesno ipfilter_enable; then
|
|
|
|
|
echo "Using ipf"
|
2016-12-28 11:10:06 +00:00
|
|
|
|
FW=ipf
|
2012-05-31 13:33:16 +00:00
|
|
|
|
elif checkyesno pf_enable; then
|
|
|
|
|
echo "Using pf"
|
|
|
|
|
FW=pf
|
|
|
|
|
elif checkyesno firewall_enable; then
|
|
|
|
|
echo "Using ifpw"
|
|
|
|
|
FW=ipfw
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
if [ -z $FW ] ; then
|
2012-04-14 22:35:31 +00:00
|
|
|
|
echo "Could not detect usage of ipf, pf, ipfw. Compiling for pf by default"
|
2011-09-28 19:13:20 +00:00
|
|
|
|
FW=pf
|
|
|
|
|
fi
|
|
|
|
|
echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
|
|
|
|
|
OS_URL=http://www.freebsd.org/
|
2014-03-13 10:30:24 +00:00
|
|
|
|
V6SOCKETS_ARE_V6ONLY=`sysctl -n net.inet6.ip6.v6only`
|
2011-09-28 19:13:20 +00:00
|
|
|
|
;;
|
|
|
|
|
pfSense)
|
2020-04-20 22:42:13 +00:00
|
|
|
|
MAKEFILE=Makefile.bsd
|
2011-09-28 19:13:20 +00:00
|
|
|
|
# we need to detect if PFRULE_INOUT_COUNTS macro is needed
|
|
|
|
|
FW=pf
|
|
|
|
|
echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
|
|
|
|
|
OS_URL=http://www.pfsense.com/
|
2014-03-13 10:30:24 +00:00
|
|
|
|
V6SOCKETS_ARE_V6ONLY=`sysctl -n net.inet6.ip6.v6only`
|
2011-09-28 19:13:20 +00:00
|
|
|
|
;;
|
|
|
|
|
NetBSD)
|
2020-04-20 22:42:13 +00:00
|
|
|
|
MAKEFILE=Makefile.bsd
|
2020-04-20 22:20:43 +00:00
|
|
|
|
if [ -z $FW ] && [ -f /etc/rc.subr ] && [ -f /etc/rc.conf ] ; then
|
2012-05-31 13:33:16 +00:00
|
|
|
|
# source file with handy subroutines like checkyesno
|
|
|
|
|
. /etc/rc.subr
|
|
|
|
|
# source config file so we can probe vars
|
|
|
|
|
. /etc/rc.conf
|
|
|
|
|
if checkyesno pf; then
|
|
|
|
|
FW=pf
|
|
|
|
|
elif checkyesno ipfilter; then
|
|
|
|
|
FW=ipf
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
if [ -z $FW ] ; then
|
2011-09-28 19:13:20 +00:00
|
|
|
|
echo "Could not detect ipf nor pf, defaulting to pf."
|
|
|
|
|
FW=pf
|
|
|
|
|
fi
|
|
|
|
|
echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
|
|
|
|
|
OS_URL=http://www.netbsd.org/
|
|
|
|
|
;;
|
|
|
|
|
DragonFly)
|
2020-04-20 22:42:13 +00:00
|
|
|
|
MAKEFILE=Makefile.bsd
|
2020-04-20 22:20:43 +00:00
|
|
|
|
if [ -z $FW ] && [ -f /etc/rc.subr ] && [ -f /etc/rc.conf ] ; then
|
2012-05-31 13:33:16 +00:00
|
|
|
|
# source file with handy subroutines like checkyesno
|
|
|
|
|
. /etc/rc.subr
|
|
|
|
|
# source config file so we can probe vars
|
|
|
|
|
. /etc/rc.conf
|
|
|
|
|
if checkyesno pf; then
|
|
|
|
|
FW=pf
|
|
|
|
|
elif checkyesno ipfilter; then
|
|
|
|
|
FW=ipf
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
if [ -z $FW ] ; then
|
2011-09-28 19:13:20 +00:00
|
|
|
|
echo "Could not detect ipf nor pf, defaulting to pf."
|
|
|
|
|
FW=pf
|
|
|
|
|
fi
|
|
|
|
|
echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
|
2016-08-16 09:39:54 +00:00
|
|
|
|
# PFRULE_INOUT_COUNTS should be set for DragonFly > 2.8
|
|
|
|
|
# version detection is not yet added to this script.
|
2016-07-23 05:39:42 +00:00
|
|
|
|
echo "#define PFRULE_INOUT_COUNTS" >> ${CONFIGFILE}
|
2016-07-23 06:08:32 +00:00
|
|
|
|
# net.inet6.ip6.v6only has been on by default for many years
|
|
|
|
|
# and this sysctl node has been removed
|
|
|
|
|
V6SOCKETS_ARE_V6ONLY=1
|
2011-09-28 19:13:20 +00:00
|
|
|
|
OS_URL=http://www.dragonflybsd.org/
|
|
|
|
|
;;
|
|
|
|
|
SunOS)
|
2020-04-20 22:42:13 +00:00
|
|
|
|
MAKEFILE=Makefile.bsd
|
2011-09-28 19:13:20 +00:00
|
|
|
|
echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
|
|
|
|
|
FW=ipf
|
|
|
|
|
echo "#define LOG_PERROR 0" >> ${CONFIGFILE}
|
|
|
|
|
echo "#define SOLARIS_KSTATS 1" >> ${CONFIGFILE}
|
2012-05-24 16:52:27 +00:00
|
|
|
|
# solaris 10 does not define u_int64_t ?
|
|
|
|
|
# but it does define uint64_t
|
|
|
|
|
echo "typedef uint64_t u_int64_t;" >> ${CONFIGFILE}
|
2011-09-28 19:13:20 +00:00
|
|
|
|
OS_URL=http://www.sun.com/solaris/
|
|
|
|
|
;;
|
|
|
|
|
Linux)
|
|
|
|
|
OS_URL=http://www.kernel.org/
|
|
|
|
|
KERNVERA=`echo $OS_VERSION | awk -F. '{print $1}'`
|
|
|
|
|
KERNVERB=`echo $OS_VERSION | awk -F. '{print $2}'`
|
|
|
|
|
KERNVERC=`echo $OS_VERSION | awk -F. '{print $3}'`
|
|
|
|
|
KERNVERD=`echo $OS_VERSION | awk -F. '{print $4}'`
|
|
|
|
|
#echo "$KERNVERA.$KERNVERB.$KERNVERC.$KERNVERD"
|
2015-08-25 18:33:47 +00:00
|
|
|
|
# from the 2.4 version, struct ip_mreqn instead of struct ip_mreq
|
|
|
|
|
if [ \( $KERNVERA -ge 3 \) -o \( $KERNVERA -eq 2 -a $KERNVERB -ge 4 \) ]; then
|
|
|
|
|
HAVE_IP_MREQN=1
|
|
|
|
|
fi
|
2011-09-28 19:13:20 +00:00
|
|
|
|
# Debian GNU/Linux special case
|
|
|
|
|
if [ -f /etc/debian_version ]; then
|
|
|
|
|
OS_NAME=Debian
|
|
|
|
|
OS_VERSION=`cat /etc/debian_version`
|
|
|
|
|
OS_URL=http://www.debian.org/
|
|
|
|
|
fi
|
|
|
|
|
# same thing for Gentoo linux
|
|
|
|
|
if [ -f /etc/gentoo-release ]; then
|
|
|
|
|
OS_NAME=Gentoo
|
|
|
|
|
OS_VERSION=`cat /etc/gentoo-release`
|
|
|
|
|
OS_URL=http://www.gentoo.org/
|
|
|
|
|
fi
|
2016-02-10 19:44:46 +00:00
|
|
|
|
# ClearOS special case
|
|
|
|
|
if [ -f /etc/clearos-release ]; then
|
|
|
|
|
OS_NAME=ClearOS
|
|
|
|
|
OS_VERSION=`grep ^base_version /etc/product | awk '{ print $3 }'`
|
|
|
|
|
OS_URL=https://www.clearos.com/
|
|
|
|
|
fi
|
2011-09-28 19:13:20 +00:00
|
|
|
|
# use lsb_release (Linux Standard Base) when available
|
|
|
|
|
LSB_RELEASE=`which lsb_release`
|
|
|
|
|
if [ 0 -eq $? ]; then
|
|
|
|
|
OS_NAME=`${LSB_RELEASE} -i -s`
|
|
|
|
|
OS_VERSION=`${LSB_RELEASE} -r -s`
|
|
|
|
|
case $OS_NAME in
|
|
|
|
|
Debian)
|
|
|
|
|
OS_URL=http://www.debian.org/
|
|
|
|
|
OS_VERSION=`${LSB_RELEASE} -c -s`
|
|
|
|
|
;;
|
|
|
|
|
Ubuntu)
|
|
|
|
|
OS_URL=http://www.ubuntu.com/
|
|
|
|
|
OS_VERSION=`${LSB_RELEASE} -c -s`
|
|
|
|
|
;;
|
|
|
|
|
Gentoo)
|
|
|
|
|
OS_URL=http://www.gentoo.org/
|
|
|
|
|
;;
|
2013-05-03 11:17:07 +00:00
|
|
|
|
arch)
|
|
|
|
|
OS_URL=http://www.archlinux.org/
|
|
|
|
|
OS_VERSION=`uname -r`
|
|
|
|
|
;;
|
2011-09-28 19:13:20 +00:00
|
|
|
|
esac
|
|
|
|
|
fi
|
|
|
|
|
echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
|
2019-09-29 05:17:51 +00:00
|
|
|
|
if [ -z ${FW} ]; then
|
|
|
|
|
# test the current environment to determine which to use
|
|
|
|
|
# Would be better to check for actual presence of nftable rules, but that requires root privileges
|
|
|
|
|
if [ -x "$(command -v nft)" ]; then
|
|
|
|
|
FW=nftables
|
|
|
|
|
else
|
|
|
|
|
FW=iptables
|
|
|
|
|
fi
|
2019-09-18 19:28:51 +00:00
|
|
|
|
fi
|
2020-10-31 09:05:50 +00:00
|
|
|
|
V6SOCKETS_ARE_V6ONLY=`$(find /sbin /bin /usr/sbin /usr/bin -name sysctl) -n net.ipv6.bindv6only`
|
2011-09-28 19:13:20 +00:00
|
|
|
|
;;
|
|
|
|
|
OpenWRT)
|
|
|
|
|
OS_URL=http://www.openwrt.org/
|
|
|
|
|
echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
|
2019-09-18 19:28:51 +00:00
|
|
|
|
FW=iptables
|
2012-01-20 21:53:15 +00:00
|
|
|
|
;;
|
2018-12-23 02:47:45 +00:00
|
|
|
|
OpenEmbedded)
|
|
|
|
|
OS_URL=http://www.openembedded.org/
|
|
|
|
|
echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
|
|
|
|
|
FW=iptables
|
|
|
|
|
;;
|
2012-07-10 21:19:08 +00:00
|
|
|
|
AstLinux)
|
|
|
|
|
OS_URL=http://www.astlinux.org/
|
|
|
|
|
echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
|
2019-09-18 19:28:51 +00:00
|
|
|
|
FW=iptables
|
2012-07-10 21:19:08 +00:00
|
|
|
|
;;
|
2012-01-20 21:53:15 +00:00
|
|
|
|
Tomato)
|
|
|
|
|
OS_NAME=UPnP
|
|
|
|
|
OS_URL=http://tomatousb.org/
|
|
|
|
|
echo "" >> ${CONFIGFILE}
|
2015-06-09 19:53:11 +00:00
|
|
|
|
echo "#ifndef TOMATO" >> ${CONFIGFILE}
|
|
|
|
|
echo "#define TOMATO" >> ${CONFIGFILE}
|
|
|
|
|
echo "#endif" >> ${CONFIGFILE}
|
|
|
|
|
echo "" >> ${CONFIGFILE}
|
2012-01-20 21:53:15 +00:00
|
|
|
|
echo "#ifdef LINUX26" >> ${CONFIGFILE}
|
|
|
|
|
echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
|
|
|
|
|
echo "#endif" >> ${CONFIGFILE}
|
|
|
|
|
echo "#ifdef TCONFIG_IPV6" >> ${CONFIGFILE}
|
|
|
|
|
echo "#define ENABLE_IPV6" >> ${CONFIGFILE}
|
|
|
|
|
echo "#endif" >> ${CONFIGFILE}
|
2019-09-18 19:28:51 +00:00
|
|
|
|
FW=iptables
|
2011-09-28 19:13:20 +00:00
|
|
|
|
;;
|
|
|
|
|
Darwin)
|
2020-04-20 22:42:13 +00:00
|
|
|
|
MAKEFILE=Makefile.macosx
|
2013-12-16 12:03:54 +00:00
|
|
|
|
MAJORVER=`echo $OS_VERSION | cut -d. -f1`
|
2011-09-28 19:13:20 +00:00
|
|
|
|
echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
|
2013-12-16 12:03:54 +00:00
|
|
|
|
# OS X switched to pf since 10.7 Lion (Darwin 11.0)
|
|
|
|
|
if [ $MAJORVER -ge 11 ] ; then
|
|
|
|
|
FW=pf
|
|
|
|
|
echo "#define PFRULE_INOUT_COUNTS" >> ${CONFIGFILE}
|
|
|
|
|
else
|
|
|
|
|
FW=ipfw
|
|
|
|
|
fi
|
2011-09-28 19:13:20 +00:00
|
|
|
|
OS_URL=http://developer.apple.com/macosx
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
echo "Unknown OS : $OS_NAME"
|
|
|
|
|
echo "Please contact the author at http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/."
|
|
|
|
|
exit 1
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
2012-04-14 22:35:31 +00:00
|
|
|
|
case $FW in
|
|
|
|
|
pf)
|
|
|
|
|
echo "#define USE_PF 1" >> ${CONFIGFILE}
|
|
|
|
|
;;
|
|
|
|
|
ipf)
|
|
|
|
|
echo "#define USE_IPF 1" >> ${CONFIGFILE}
|
|
|
|
|
;;
|
|
|
|
|
ipfw)
|
|
|
|
|
echo "#define USE_IPFW 1" >> ${CONFIGFILE}
|
|
|
|
|
;;
|
2019-09-18 19:28:51 +00:00
|
|
|
|
iptables)
|
2020-04-20 22:42:13 +00:00
|
|
|
|
MAKEFILE=Makefile.linux
|
2019-09-18 19:28:51 +00:00
|
|
|
|
echo "#define USE_NETFILTER 1" >> ${CONFIGFILE}
|
|
|
|
|
echo "#define USE_IPTABLES 1" >> ${CONFIGFILE}
|
2020-05-02 16:08:59 +00:00
|
|
|
|
echo "# generated by $0 on `date`" > config.mk
|
2020-05-03 23:31:31 +00:00
|
|
|
|
echo "SRCDIR = ${BASEDIR}" >> config.mk
|
|
|
|
|
echo "CPPFLAGS += -I." >> config.mk
|
2020-04-28 23:51:00 +00:00
|
|
|
|
if [ "$PKG_CONFIG" ] ; then
|
|
|
|
|
if ${PKG_CONFIG} --exists libiptc ; then
|
|
|
|
|
IPTABLESVERSION=`${PKG_CONFIG} --modversion libiptc`
|
|
|
|
|
echo "detected libiptc version $IPTABLESVERSION"
|
2020-05-02 16:08:59 +00:00
|
|
|
|
echo "# detected libiptc version $IPTABLESVERSION" >> config.mk
|
2020-04-28 23:51:00 +00:00
|
|
|
|
echo "IPTABLES_PCFILE_FOUND = 1" >> config.mk
|
|
|
|
|
IPTVER1=`echo $IPTABLESVERSION | cut -d. -f1`
|
|
|
|
|
IPTVER2=`echo $IPTABLESVERSION | cut -d. -f2`
|
|
|
|
|
IPTVER3=`echo $IPTABLESVERSION | cut -d. -f3`
|
|
|
|
|
if [ $IPTVER1 -gt 1 ] || \
|
|
|
|
|
[ \( $IPTVER1 -eq 1 \) -a \( \( $IPTVER2 -gt 4 \) \
|
|
|
|
|
-o \( \( $IPTVER2 -eq 4 \) -a \( $IPTVER3 -ge 3 \) \) \) ] ; then
|
|
|
|
|
IPTABLES_143=1
|
|
|
|
|
fi
|
|
|
|
|
echo "CFLAGS += `${PKG_CONFIG} --cflags libiptc`" >> config.mk
|
|
|
|
|
echo "LDLIBS += `${PKG_CONFIG} --static --libs-only-l libiptc`" >> config.mk
|
|
|
|
|
echo "LDFLAGS += `${PKG_CONFIG} --libs-only-L --libs-only-other libiptc`" >> config.mk
|
|
|
|
|
fi
|
|
|
|
|
if ${PKG_CONFIG} --atleast-version=1.0.2 libnetfilter_conntrack \
|
|
|
|
|
&& ${PKG_CONFIG} --atleast-version=1.0.3 libmnl ; then
|
|
|
|
|
echo "CPPFLAGS += -DUSE_NFCT" >> config.mk
|
|
|
|
|
echo "LDLIBS += `${PKG_CONFIG} --static --libs-only-l libmnl libnetfilter_conntrack`" >> config.mk
|
|
|
|
|
fi
|
|
|
|
|
fi
|
2020-05-02 16:08:59 +00:00
|
|
|
|
if [ "$IPTABLESPATH" ] ; then
|
|
|
|
|
echo "CPPFLAGS += -I${IPTABLESPATH}/include/" >> config.mk
|
|
|
|
|
echo "LDFLAGS += -L${IPTABLESPATH}/libiptc/" >> config.mk
|
|
|
|
|
# to test : change the following test to [ "$OS_NAME" != "OpenWRT" ]
|
|
|
|
|
if [ -z "$TARGET_OPENWRT" ] ; then
|
|
|
|
|
IPTABLESVERSION=`grep "\#define VERSION" ${IPTABLESPATH}/config.h | tr -d \" |cut -d" " -f3`
|
|
|
|
|
echo "detected libiptc version $IPTABLESVERSION"
|
|
|
|
|
echo "# detected libiptc version $IPTABLESVERSION" >> config.mk
|
|
|
|
|
IPTVER1=`echo $IPTABLESVERSION | cut -d. -f1`
|
|
|
|
|
IPTVER2=`echo $IPTABLESVERSION | cut -d. -f2`
|
|
|
|
|
IPTVER3=`echo $IPTABLESVERSION | cut -d. -f3`
|
|
|
|
|
if [ $IPTVER1 -gt 1 ] || \
|
|
|
|
|
[ \( $IPTVER1 -eq 1 \) -a \( \( $IPTVER2 -gt 4 \) \
|
|
|
|
|
-o \( \( $IPTVER2 -eq 4 \) -a \( $IPTVER3 -ge 3 \) \) \) ] ; then
|
|
|
|
|
IPTABLES_143=1
|
|
|
|
|
fi
|
|
|
|
|
if [ "$IPTABLES_143" -eq 1 ] ; then
|
|
|
|
|
echo "LDLIBS += ${IPTABLESPATH}/libiptc/.libs/libip4tc.o" >> config.mk
|
|
|
|
|
else
|
|
|
|
|
echo "LDLIBS += ${IPTABLESPATH}/libiptc/libiptc.a" >> config.mk
|
|
|
|
|
fi
|
|
|
|
|
else
|
|
|
|
|
# OpenWRT
|
|
|
|
|
# check for system-wide iptables files. Test if iptables version >= 1.4.3
|
|
|
|
|
# the following test has to be verified :
|
|
|
|
|
if test -f /usr/include/iptables/internal.h && \
|
|
|
|
|
grep -q "\#define IPTABLES_VERSION" /usr/include/iptables/internal.h ; then
|
|
|
|
|
IPTABLES_143=1
|
|
|
|
|
echo "LDLIBS += -liptc" >> config.mk
|
|
|
|
|
fi
|
|
|
|
|
arch=`echo $OS_MACHINE | grep -q x86_64 && echo 64`
|
|
|
|
|
if test -f /usr/lib${arch}/libiptc.a ; then
|
|
|
|
|
echo "LDLIBS += -liptc /usr/lib${arch}/libiptc.a" >> config.mk
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
elif [ -z "${PKG_CONFIG}" ] ; then
|
|
|
|
|
# IPTABLESPATH not defined and no pkg-config
|
|
|
|
|
if test -f /usr/include/xtables.h && \
|
|
|
|
|
grep -q "XTABLES_VERSION_CODE" /usr/include/xtables.h ; then
|
|
|
|
|
IPTABLES_143=1
|
|
|
|
|
echo "LDLIBS += -liptc" >> config.mk
|
|
|
|
|
if test -f /lib/libip4tc.so ; then
|
|
|
|
|
echo "LDLIBS += -lip4tc" >> config.mk
|
|
|
|
|
fi
|
|
|
|
|
if test -f /lib/libip6tc.so ; then
|
|
|
|
|
echo "LDLIBS += -lip6tc" >> config.mk
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
fi
|
2020-04-28 23:51:00 +00:00
|
|
|
|
echo "/* when IPTABLES_143 is defined, miniupnpd uses the new API" >> ${CONFIGFILE}
|
|
|
|
|
echo " * from libiptc 1.4.3+ */ " >> ${CONFIGFILE}
|
|
|
|
|
if [ "$IPTABLES_143" -eq 1 ] ; then
|
|
|
|
|
echo "#define IPTABLES_143" >> ${CONFIGFILE}
|
|
|
|
|
else
|
|
|
|
|
echo "#undef IPTABLES_143" >> ${CONFIGFILE}
|
|
|
|
|
fi
|
2019-09-18 19:28:51 +00:00
|
|
|
|
;;
|
|
|
|
|
nftables)
|
2020-04-20 22:42:13 +00:00
|
|
|
|
MAKEFILE=Makefile.linux_nft
|
2012-04-14 22:35:31 +00:00
|
|
|
|
echo "#define USE_NETFILTER 1" >> ${CONFIGFILE}
|
2019-09-18 19:28:51 +00:00
|
|
|
|
echo "#define USE_NFTABLES 1" >> ${CONFIGFILE}
|
2020-05-06 22:41:59 +00:00
|
|
|
|
echo "# generated by $0 on `date`" > config.mk
|
|
|
|
|
echo "SRCDIR = ${BASEDIR}" >> config.mk
|
|
|
|
|
echo "CPPFLAGS += -I." >> config.mk
|
2012-04-14 22:35:31 +00:00
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
echo "Unknown Firewall/packet filtering software [$FW]"
|
2019-10-13 19:33:32 +00:00
|
|
|
|
echo "Please contact the author at http://miniupnp.free.fr/ or https://miniupnp.tuxfamily.org/."
|
2012-04-14 22:35:31 +00:00
|
|
|
|
exit 1
|
|
|
|
|
;;
|
|
|
|
|
esac
|
|
|
|
|
|
2020-05-03 22:09:42 +00:00
|
|
|
|
if [ "$FW" = "iptables" ] || [ "$FW" = "nftables" ] ; then
|
|
|
|
|
# linux
|
|
|
|
|
if [ "$PKG_CONFIG" ] ; then
|
|
|
|
|
if ${PKG_CONFIG} --exists libcap-ng ; then
|
|
|
|
|
echo "detected libcap-ng `${PKG_CONFIG} --modversion libcap-ng`"
|
|
|
|
|
echo "CFLAGS += `${PKG_CONFIG} --cflags libcap-ng`" >> config.mk
|
2020-05-03 23:31:31 +00:00
|
|
|
|
echo "LDLIBS += `${PKG_CONFIG} --libs-only-l libcap-ng`" >> config.mk
|
2020-05-03 22:09:42 +00:00
|
|
|
|
echo "LDFLAGS += `${PKG_CONFIG} --libs-only-L --libs-only-other libcap-ng`" >> config.mk
|
|
|
|
|
echo "#define HAS_LIBCAP_NG" >> ${CONFIGFILE}
|
|
|
|
|
elif ${PKG_CONFIG} --exists libcap ; then
|
|
|
|
|
echo "detected libcap `${PKG_CONFIG} --modversion libcap`"
|
|
|
|
|
echo "CFLAGS += `${PKG_CONFIG} --cflags libcap`" >> config.mk
|
2020-05-03 23:31:31 +00:00
|
|
|
|
echo "LDLIBS += `${PKG_CONFIG} --libs-only-l libcap`" >> config.mk
|
2020-05-03 22:09:42 +00:00
|
|
|
|
echo "LDFLAGS += `${PKG_CONFIG} --libs-only-L --libs-only-other libcap`" >> config.mk
|
|
|
|
|
echo "#define HAS_LIBCAP" >> ${CONFIGFILE}
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
fi
|
|
|
|
|
|
2020-04-20 22:42:13 +00:00
|
|
|
|
if [ "$MAKEFILE" = "Makefile.bsd" ] || [ "$OS_NAME" = "Darwin" ] || [ "$OS_NAME" = "SunOS" ] ; then
|
2020-04-20 22:13:26 +00:00
|
|
|
|
echo "FWNAME = $FW" > bsdmake.inc
|
2020-05-11 21:30:19 +00:00
|
|
|
|
echo "SRCDIR = ${BASEDIR}" >> bsdmake.inc
|
|
|
|
|
echo "CPPFLAGS += -I." >> bsdmake.inc
|
2020-04-20 22:13:26 +00:00
|
|
|
|
fi
|
2020-04-20 22:42:13 +00:00
|
|
|
|
if [ "$MAKEFILE" ] ; then
|
2020-05-11 21:31:53 +00:00
|
|
|
|
cp "${BASEDIR}/${MAKEFILE}" Makefile && echo "${BASEDIR}/${MAKEFILE} -> Makefile"
|
2020-04-20 22:42:13 +00:00
|
|
|
|
fi
|
2020-04-20 22:13:26 +00:00
|
|
|
|
|
2016-02-11 10:39:28 +00:00
|
|
|
|
# UUID API
|
2019-08-29 20:44:40 +00:00
|
|
|
|
case $OS_NAME in
|
|
|
|
|
OpenWRT)
|
|
|
|
|
echo "#define LIB_UUID" >> ${CONFIGFILE}
|
|
|
|
|
;;
|
|
|
|
|
*)
|
|
|
|
|
if grep uuid_create /usr/include/uuid.h > /dev/null 2>&1 ; then
|
|
|
|
|
echo "#define BSD_UUID" >> ${CONFIGFILE}
|
|
|
|
|
fi
|
|
|
|
|
if grep uuid_generate /usr/include/uuid/uuid.h > /dev/null 2>&1 ; then
|
|
|
|
|
echo "#define LIB_UUID" >> ${CONFIGFILE}
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
esac
|
2016-02-11 10:39:28 +00:00
|
|
|
|
|
|
|
|
|
# set V6SOCKETS_ARE_V6ONLY to 0 if it was not set above
|
2014-03-13 10:30:24 +00:00
|
|
|
|
if [ -z "$V6SOCKETS_ARE_V6ONLY" ] ; then
|
|
|
|
|
V6SOCKETS_ARE_V6ONLY=0
|
|
|
|
|
fi
|
|
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
|
echo "Configuring compilation for [$OS_NAME] [$OS_VERSION] with [$FW] firewall software."
|
|
|
|
|
echo "Please edit config.h for more compilation options."
|
|
|
|
|
|
|
|
|
|
# define SUPPORT_REMOTEHOST if the FW related code really supports setting
|
|
|
|
|
# a RemoteHost
|
|
|
|
|
if [ \( "$FW" = "netfilter" \) -o \( "$FW" = "pf" \) -o \( "$FW" = "ipfw" \) ] ; then
|
|
|
|
|
echo "#define SUPPORT_REMOTEHOST" >> ${CONFIGFILE}
|
|
|
|
|
fi
|
|
|
|
|
|
2016-02-09 09:09:19 +00:00
|
|
|
|
echo "/* Enable IGD2 \"Port Triggering\" as defined in Section 2.5.16" >> ${CONFIGFILE}
|
|
|
|
|
echo " * figure 2.2 in UPnP-gw-WANIPConnection-v2-Service.pdf */" >> ${CONFIGFILE}
|
|
|
|
|
echo "#define ENABLE_PORT_TRIGGERING" >> ${CONFIGFILE}
|
|
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
echo "#define OS_NAME \"$OS_NAME\"" >> ${CONFIGFILE}
|
|
|
|
|
echo "#define OS_VERSION \"$OS_NAME/$OS_VERSION\"" >> ${CONFIGFILE}
|
|
|
|
|
echo "#define OS_URL \"${OS_URL}\"" >> ${CONFIGFILE}
|
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
|
|
|
|
|
echo "/* syslog facility to be used by miniupnpd */" >> ${CONFIGFILE}
|
|
|
|
|
echo "#define LOG_MINIUPNPD ${LOG_MINIUPNPD}" >> ${CONFIGFILE}
|
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
|
|
|
|
|
echo "/* Uncomment the following line to allow miniupnpd to be" >> ${CONFIGFILE}
|
|
|
|
|
echo " * controlled by miniupnpdctl */" >> ${CONFIGFILE}
|
|
|
|
|
echo "/*#define USE_MINIUPNPDCTL*/" >> ${CONFIGFILE}
|
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
|
|
|
|
|
echo "/* Comment the following line to disable NAT-PMP operations */" >> ${CONFIGFILE}
|
|
|
|
|
echo "#define ENABLE_NATPMP" >> ${CONFIGFILE}
|
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
|
2013-07-09 13:36:53 +00:00
|
|
|
|
echo "/* Comment the following line to disable PCP operations */" >> ${CONFIGFILE}
|
|
|
|
|
echo "#define ENABLE_PCP" >> ${CONFIGFILE}
|
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
|
|
|
|
|
echo "#ifdef ENABLE_PCP" >> ${CONFIGFILE}
|
|
|
|
|
if [ -n "$PCP_PEER" ]; then
|
|
|
|
|
echo "/* Comment the following line to disable PCP PEER operation */" >> ${CONFIGFILE}
|
|
|
|
|
echo "#define PCP_PEER" >> ${CONFIGFILE}
|
|
|
|
|
else
|
|
|
|
|
echo "/* Uncomment the following line to enable PCP PEER operation */" >> ${CONFIGFILE}
|
|
|
|
|
echo "/*#define PCP_PEER*/" >> ${CONFIGFILE}
|
|
|
|
|
fi
|
|
|
|
|
echo "#ifdef PCP_PEER" >> ${CONFIGFILE}
|
|
|
|
|
echo "/*#define PCP_FLOWP*/" >> ${CONFIGFILE}
|
2013-12-13 16:01:41 +00:00
|
|
|
|
echo "#endif /*PCP_PEER*/" >> ${CONFIGFILE}
|
2013-07-09 13:36:53 +00:00
|
|
|
|
echo "/*#define PCP_SADSCP*/" >> ${CONFIGFILE}
|
2013-12-13 16:01:41 +00:00
|
|
|
|
echo "#endif /*ENABLE_PCP*/" >> ${CONFIGFILE}
|
2013-07-09 13:36:53 +00:00
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
|
echo "/* Uncomment the following line to enable generation of" >> ${CONFIGFILE}
|
|
|
|
|
echo " * filter rules with pf */" >> ${CONFIGFILE}
|
|
|
|
|
echo "/*#define PF_ENABLE_FILTER_RULES*/">> ${CONFIGFILE}
|
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
|
2020-04-12 17:30:37 +00:00
|
|
|
|
echo "/* Uncomment the following line to set dst address in rdr rules with pf." >> ${CONFIGFILE}
|
|
|
|
|
echo " * It is disabled by default because of" >> ${CONFIGFILE}
|
|
|
|
|
echo " * https://github.com/miniupnp/miniupnp/issues/433 */" >> ${CONFIGFILE}
|
|
|
|
|
echo "/*#define PF_SET_DST_ADDR*/">> ${CONFIGFILE}
|
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
|
echo "/* Uncomment the following line to enable caching of results of" >> ${CONFIGFILE}
|
|
|
|
|
echo " * the getifstats() function */" >> ${CONFIGFILE}
|
|
|
|
|
echo "/*#define ENABLE_GETIFSTATS_CACHING*/" >> ${CONFIGFILE}
|
|
|
|
|
echo "/* The cache duration is indicated in seconds */" >> ${CONFIGFILE}
|
|
|
|
|
echo "#define GETIFSTATS_CACHING_DURATION 2" >> ${CONFIGFILE}
|
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
|
|
|
|
|
echo "/* Uncomment the following line to enable multiple external ip support */" >> ${CONFIGFILE}
|
|
|
|
|
echo "/* note : That is EXPERIMENTAL, do not use that unless you know perfectly what you are doing */" >> ${CONFIGFILE}
|
|
|
|
|
echo "/* Dynamic external ip adresses are not supported when this option is enabled." >> ${CONFIGFILE}
|
|
|
|
|
echo " * Also note that you would need to configure your .conf file accordingly. */" >> ${CONFIGFILE}
|
|
|
|
|
echo "/*#define MULTIPLE_EXTERNAL_IP*/" >> ${CONFIGFILE}
|
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
|
|
|
|
|
echo "/* Comment the following line to use home made daemonize() func instead" >> ${CONFIGFILE}
|
|
|
|
|
echo " * of BSD daemon() */" >> ${CONFIGFILE}
|
|
|
|
|
echo "#define USE_DAEMON" >> ${CONFIGFILE}
|
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
|
|
|
|
|
echo "/* Uncomment the following line to enable lease file support */" >> ${CONFIGFILE}
|
2012-04-14 22:35:31 +00:00
|
|
|
|
if [ -n "$LEASEFILE" ] ; then
|
|
|
|
|
echo "#define ENABLE_LEASEFILE" >> ${CONFIGFILE}
|
|
|
|
|
else
|
|
|
|
|
echo "/*#define ENABLE_LEASEFILE*/" >> ${CONFIGFILE}
|
|
|
|
|
fi
|
2018-05-02 07:40:12 +00:00
|
|
|
|
echo "/* Uncomment the following line to store remaining time in lease file */" >> ${CONFIGFILE}
|
|
|
|
|
echo "/*#define LEASEFILE_USE_REMAINING_TIME*/" >> ${CONFIGFILE}
|
2011-09-28 19:13:20 +00:00
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
|
2014-03-13 13:48:52 +00:00
|
|
|
|
echo "/* Uncomment the following line to enable port in use check */" >> ${CONFIGFILE}
|
|
|
|
|
if [ -n "$PORTINUSE" ]; then
|
|
|
|
|
echo "#define CHECK_PORTINUSE" >> ${CONFIGFILE}
|
|
|
|
|
else
|
|
|
|
|
echo "/*#define CHECK_PORTINUSE*/" >> ${CONFIGFILE}
|
|
|
|
|
fi
|
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
|
echo "/* Define one or none of the two following macros in order to make some" >> ${CONFIGFILE}
|
|
|
|
|
echo " * clients happy. It will change the XML Root Description of the IGD." >> ${CONFIGFILE}
|
|
|
|
|
echo " * Enabling the Layer3Forwarding Service seems to be the more compatible" >> ${CONFIGFILE}
|
|
|
|
|
echo " * option. */" >> ${CONFIGFILE}
|
|
|
|
|
echo "/*#define HAS_DUMMY_SERVICE*/" >> ${CONFIGFILE}
|
|
|
|
|
echo "#define ENABLE_L3F_SERVICE" >> ${CONFIGFILE}
|
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
|
2015-12-13 14:57:49 +00:00
|
|
|
|
echo "/* define ADVERTISE_WANPPPCONN to allow buggy Control Point to use" >> ${CONFIGFILE}
|
|
|
|
|
echo " * WANPPPConnection instead of WANIPConnection. */" >> ${CONFIGFILE}
|
|
|
|
|
if [ -n "$STRICT" ] || [ -n "$DISABLEPPPCONN" ] ; then
|
|
|
|
|
echo "/*#define ADVERTISE_WANPPPCONN*/" >> ${CONFIGFILE}
|
|
|
|
|
else
|
|
|
|
|
echo "#define ADVERTISE_WANPPPCONN" >> ${CONFIGFILE}
|
|
|
|
|
fi
|
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
|
echo "/* Enable IP v6 support */" >> ${CONFIGFILE}
|
2012-04-14 22:35:31 +00:00
|
|
|
|
if [ -n "$IPV6" ]; then
|
|
|
|
|
echo "#define ENABLE_IPV6" >> ${CONFIGFILE}
|
|
|
|
|
else
|
|
|
|
|
echo "/*#define ENABLE_IPV6*/" >> ${CONFIGFILE}
|
|
|
|
|
fi
|
2011-09-28 19:13:20 +00:00
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
|
2014-03-13 10:30:24 +00:00
|
|
|
|
echo "/* Define V6SOCKETS_ARE_V6ONLY if AF_INET6 sockets are restricted" >> ${CONFIGFILE}
|
|
|
|
|
echo " * to IPv6 communications only. */" >> ${CONFIGFILE}
|
|
|
|
|
if [ $V6SOCKETS_ARE_V6ONLY -eq 1 ] ; then
|
|
|
|
|
echo "#define V6SOCKETS_ARE_V6ONLY" >> ${CONFIGFILE}
|
|
|
|
|
else
|
|
|
|
|
echo "/*#define V6SOCKETS_ARE_V6ONLY*/" >> ${CONFIGFILE}
|
|
|
|
|
fi
|
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
|
2015-08-25 18:33:47 +00:00
|
|
|
|
if [ -n "$HAVE_IP_MREQN" ]; then
|
|
|
|
|
echo "#define HAVE_IP_MREQN" >> ${CONFIGFILE}
|
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
fi
|
|
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
|
echo "/* Enable the support of IGD v2 specification." >> ${CONFIGFILE}
|
|
|
|
|
echo " * This is not fully tested yet and can cause incompatibilities with some" >> ${CONFIGFILE}
|
|
|
|
|
echo " * control points, so enable with care. */" >> ${CONFIGFILE}
|
2012-04-14 22:35:31 +00:00
|
|
|
|
if [ -n "$IGD2" ]; then
|
|
|
|
|
echo "#define IGD_V2" >> ${CONFIGFILE}
|
|
|
|
|
else
|
|
|
|
|
echo "/*#define IGD_V2*/" >> ${CONFIGFILE}
|
|
|
|
|
fi
|
2011-09-28 19:13:20 +00:00
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
|
|
|
|
|
echo "#ifdef IGD_V2" >> ${CONFIGFILE}
|
|
|
|
|
echo "/* Enable DeviceProtection service (IGDv2) */" >> ${CONFIGFILE}
|
|
|
|
|
echo "#define ENABLE_DP_SERVICE" >> ${CONFIGFILE}
|
2014-04-09 13:35:06 +00:00
|
|
|
|
echo "/*#define ENABLE_HTTPS*/" >> ${CONFIGFILE}
|
2014-04-11 07:48:41 +00:00
|
|
|
|
echo "/*#define HTTPS_CERTFILE \"/path/to/certificate.pem\"*/" >> ${CONFIGFILE}
|
|
|
|
|
echo "/*#define HTTPS_KEYFILE \"/path/to/private.key\"*/" >> ${CONFIGFILE}
|
2011-09-28 19:13:20 +00:00
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
echo "/* Enable WANIPv6FirewallControl service (IGDv2). needs IPv6 */" >> ${CONFIGFILE}
|
|
|
|
|
echo "#ifdef ENABLE_IPV6" >> ${CONFIGFILE}
|
|
|
|
|
echo "#define ENABLE_6FC_SERVICE" >> ${CONFIGFILE}
|
|
|
|
|
echo "#endif /* ENABLE_IPV6 */" >> ${CONFIGFILE}
|
|
|
|
|
echo "#endif /* IGD_V2 */" >> ${CONFIGFILE}
|
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
|
|
|
|
|
echo "/* UPnP Events support. Working well enough to be enabled by default." >> ${CONFIGFILE}
|
|
|
|
|
echo " * It can be disabled to save a few bytes. */" >> ${CONFIGFILE}
|
|
|
|
|
echo "#define ENABLE_EVENTS" >> ${CONFIGFILE}
|
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
|
|
|
|
|
echo "/* include interface name in pf and ipf rules */" >> ${CONFIGFILE}
|
|
|
|
|
echo "#define USE_IFNAME_IN_RULES" >> ${CONFIGFILE}
|
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
|
|
|
|
|
echo "/* Experimental NFQUEUE support. */" >> ${CONFIGFILE}
|
|
|
|
|
echo "/*#define ENABLE_NFQUEUE*/" >> ${CONFIGFILE}
|
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
|
|
|
|
|
echo "/* Enable to make MiniUPnPd more strict about UPnP conformance" >> ${CONFIGFILE}
|
|
|
|
|
echo " * and the messages it receives from control points */" >> ${CONFIGFILE}
|
2012-04-14 22:35:31 +00:00
|
|
|
|
if [ -n "$STRICT" ] ; then
|
|
|
|
|
echo "#define UPNP_STRICT" >> ${CONFIGFILE}
|
|
|
|
|
else
|
|
|
|
|
echo "/*#define UPNP_STRICT*/" >> ${CONFIGFILE}
|
|
|
|
|
fi
|
2011-09-28 19:13:20 +00:00
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
|
2014-02-25 10:45:51 +00:00
|
|
|
|
echo "/* If SSDP_RESPOND_SAME_VERSION is defined, the M-SEARCH response" >> ${CONFIGFILE}
|
|
|
|
|
echo " * include the same device version as was contained in the search" >> ${CONFIGFILE}
|
|
|
|
|
echo " * request. It conforms to UPnP DA v1.1 */" >> ${CONFIGFILE}
|
|
|
|
|
echo "#define SSDP_RESPOND_SAME_VERSION" >> ${CONFIGFILE}
|
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
|
2012-10-04 22:17:40 +00:00
|
|
|
|
echo "/* Add the optional Date: header in all HTTP responses */" >> ${CONFIGFILE}
|
|
|
|
|
if [ -n "$STRICT" ] ; then
|
|
|
|
|
echo "#define ENABLE_HTTP_DATE" >> ${CONFIGFILE}
|
|
|
|
|
else
|
|
|
|
|
echo "/*#define ENABLE_HTTP_DATE*/" >> ${CONFIGFILE}
|
|
|
|
|
fi
|
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
|
2014-02-25 10:16:34 +00:00
|
|
|
|
echo "/* Wait a little before answering M-SEARCH request */" >> ${CONFIGFILE}
|
|
|
|
|
if [ -n "$STRICT" ] ; then
|
|
|
|
|
echo "#define DELAY_MSEARCH_RESPONSE" >> ${CONFIGFILE}
|
|
|
|
|
else
|
|
|
|
|
echo "/*#define DELAY_MSEARCH_RESPONSE*/" >> ${CONFIGFILE}
|
|
|
|
|
fi
|
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
|
2012-06-29 19:39:34 +00:00
|
|
|
|
echo "/* disable reading and parsing of config file (miniupnpd.conf) */" >> ${CONFIGFILE}
|
|
|
|
|
echo "/*#define DISABLE_CONFIG_FILE*/" >> ${CONFIGFILE}
|
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
|
2013-12-13 18:40:52 +00:00
|
|
|
|
echo "/* Uncomment the following line to configure all manufacturer infos through miniupnpd.conf */" >> ${CONFIGFILE}
|
|
|
|
|
if [ -n "$VENDORCFG" ] ; then
|
|
|
|
|
echo "#define ENABLE_MANUFACTURER_INFO_CONFIGURATION" >> ${CONFIGFILE}
|
|
|
|
|
else
|
|
|
|
|
echo "/*#define ENABLE_MANUFACTURER_INFO_CONFIGURATION*/" >> ${CONFIGFILE}
|
|
|
|
|
fi
|
2013-12-13 11:03:28 +00:00
|
|
|
|
echo "" >> ${CONFIGFILE}
|
|
|
|
|
|
2014-05-10 11:09:48 +00:00
|
|
|
|
cat >> ${CONFIGFILE} <<EOF
|
|
|
|
|
#if defined(ENABLE_6FC_SERVICE) || (defined(ENABLE_PCP) && defined(ENABLE_IPV6))
|
|
|
|
|
#define ENABLE_UPNPPINHOLE
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
2014-12-10 09:41:10 +00:00
|
|
|
|
cat >> ${CONFIGFILE} <<EOF
|
|
|
|
|
/* Uncomment the following line if your device does not have a proper clock
|
|
|
|
|
* BOOTID.UPNP.ORG can be set with command line */
|
|
|
|
|
#define USE_TIME_AS_BOOTID
|
2015-09-14 10:10:15 +00:00
|
|
|
|
|
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
cat >> ${CONFIGFILE} <<EOF
|
|
|
|
|
/* With the following macro defined, a random string is prepended to all URLs */
|
2017-05-26 15:44:45 +00:00
|
|
|
|
/*#define RANDOMIZE_URLS*/
|
2015-09-14 10:10:15 +00:00
|
|
|
|
|
2018-01-09 01:32:39 +00:00
|
|
|
|
/* maximum length of SSDP packets we are generating
|
2015-10-24 11:11:31 +00:00
|
|
|
|
* (reception is done in a 1500byte buffer) */
|
|
|
|
|
#define SSDP_PACKET_MAX_LEN 1024
|
|
|
|
|
|
2014-12-10 09:41:10 +00:00
|
|
|
|
EOF
|
|
|
|
|
|
2020-06-03 21:43:58 +00:00
|
|
|
|
echo "/* disable forking to the background and writing the pid file */" >> ${CONFIGFILE}
|
|
|
|
|
if [ -n "$NO_BACKGROUND_NO_PIDFILE" ] && [ $NO_BACKGROUND_NO_PIDFILE -eq 1 ] ; then
|
|
|
|
|
echo "#define NO_BACKGROUND_NO_PIDFILE" >> ${CONFIGFILE}
|
|
|
|
|
else
|
|
|
|
|
echo "/*#define NO_BACKGROUND_NO_PIDFILE*/" >> ${CONFIGFILE}
|
|
|
|
|
fi
|
|
|
|
|
|
2014-03-13 13:48:52 +00:00
|
|
|
|
echo "#endif /* ${CONFIGMACRO} */" >> ${CONFIGFILE}
|
2011-09-28 19:13:20 +00:00
|
|
|
|
|
2013-04-24 17:04:00 +00:00
|
|
|
|
${MV} ${CONFIGFILE} ${CONFIGFILE_FINAL}
|
|
|
|
|
|
2011-09-28 19:13:20 +00:00
|
|
|
|
exit 0
|