2 # $Id: genconfig.sh,v 1.49 2011/06/04 16:20:31 nanard Exp $
4 # http://miniupnp.free.fr or http://miniupnp.tuxfamily.org/
5 # (c) 2006-2011 Thomas Bernard
6 # This software is subject to the conditions detailed in the
7 # LICENCE file provided within the distribution
11 CONFIGMACRO
="__CONFIG_H__"
13 # version reported in XML descriptions
14 #UPNP_VERSION=20070827
15 UPNP_VERSION
=`date +"%Y%m%d"`
17 LOG_MINIUPNPD
="LOG_DAEMON"
19 # detecting the OS name and version
23 # pfSense special case
24 if [ -f /etc
/platform
]; then
25 if [ `cat /etc/platform` = "pfSense" ]; then
27 OS_VERSION
=`cat /etc/version`
31 # OpenWRT special case
32 if [ -f .
/os.openwrt
]; then
34 OS_VERSION
=$
(cat .
/os.openwrt
)
37 # Tomato USB special case
38 if [ -f ..
/shared
/tomato_version
]; then
40 OS_VERSION
="Tomato $(cat ../shared/tomato_version)"
45 echo "/* MiniUPnP Project" >> ${CONFIGFILE}
46 echo " * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/" >> ${CONFIGFILE}
47 echo " * (c) 2006-2011 Thomas Bernard" >> ${CONFIGFILE}
48 echo " * generated by $0 on `date` */" >> ${CONFIGFILE}
49 echo "#ifndef $CONFIGMACRO" >> ${CONFIGFILE}
50 echo "#define $CONFIGMACRO" >> ${CONFIGFILE}
51 echo "" >> ${CONFIGFILE}
52 echo "#include <inttypes.h>" >> ${CONFIGFILE}
53 echo "" >> ${CONFIGFILE}
54 echo "#define MINIUPNPD_VERSION \"`cat VERSION`\"" >> ${CONFIGFILE}
55 echo "" >> ${CONFIGFILE}
56 echo "#define UPNP_VERSION \"$UPNP_VERSION\"" >> ${CONFIGFILE}
61 MAJORVER
=`echo $OS_VERSION | cut -d. -f1`
62 MINORVER
=`echo $OS_VERSION | cut -d. -f2`
63 #echo "OpenBSD majorversion=$MAJORVER minorversion=$MINORVER"
64 # rtableid was introduced in OpenBSD 4.0
65 if [ $MAJORVER -ge 4 ]; then
66 echo "#define PFRULE_HAS_RTABLEID" >> ${CONFIGFILE}
68 # from the 3.8 version, packets and bytes counters are double : in/out
69 if [ \
( $MAJORVER -ge 4 \
) -o \
( $MAJORVER -eq 3 -a $MINORVER -ge 8 \
) ]; then
70 echo "#define PFRULE_INOUT_COUNTS" >> ${CONFIGFILE}
72 # from the 4.7 version, new pf
73 if [ \
( $MAJORVER -ge 5 \
) -o \
( $MAJORVER -eq 4 -a $MINORVER -ge 7 \
) ]; then
74 echo "#define PF_NEWSTYLE" >> ${CONFIGFILE}
76 echo "#define USE_PF 1" >> ${CONFIGFILE}
78 echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
79 OS_URL
=http
://www.openbsd.org
/
82 VER
=`grep '#define __FreeBSD_version' /usr/include/sys/param.h | awk '{print $3}'`
83 if [ $VER -ge 700049 ]; then
84 echo "#define PFRULE_INOUT_COUNTS" >> ${CONFIGFILE}
86 # new way to see which one to use PF or IPF.
87 # see http://miniupnp.tuxfamily.org/forum/viewtopic.php?p=957
88 # source file with handy subroutines like checkyesno
90 # source config file so we can probe vars
92 if checkyesno ipfilter_enable
; then
95 echo "#define USE_IPF 1" >> ${CONFIGFILE}
96 elif checkyesno pf_enable
; then
99 echo "#define USE_PF 1" >> ${CONFIGFILE}
100 # TODO : Add support for IPFW
101 # echo "#define USE_IPFW 1" >> ${CONFIGFILE}
104 echo "Could not detect usage of ipf or pf. Compiling for pf by default"
106 echo "#define USE_PF 1" >> ${CONFIGFILE}
108 echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
109 OS_URL
=http
://www.freebsd.org
/
112 # we need to detect if PFRULE_INOUT_COUNTS macro is needed
113 echo "#define USE_PF 1" >> ${CONFIGFILE}
115 echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
116 OS_URL
=http
://www.pfsense.com
/
119 # source file with handy subroutines like checkyesno
121 # source config file so we can probe vars
123 if checkyesno pf
; then
124 echo "#define USE_PF 1" >> ${CONFIGFILE}
126 elif checkyesno ipfilter
; then
127 echo "#define USE_IPF 1" >> ${CONFIGFILE}
130 echo "Could not detect ipf nor pf, defaulting to pf."
131 echo "#define USE_PF 1" >> ${CONFIGFILE}
134 echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
135 OS_URL
=http
://www.netbsd.org
/
138 # source file with handy subroutines like checkyesno
140 # source config file so we can probe vars
142 if checkyesno pf
; then
143 echo "#define USE_PF 1" >> ${CONFIGFILE}
145 elif checkyesno ipfilter
; then
146 echo "#define USE_IPF 1" >> ${CONFIGFILE}
149 echo "Could not detect ipf nor pf, defaulting to pf."
150 echo "#define USE_PF 1" >> ${CONFIGFILE}
153 echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
154 OS_URL
=http
://www.dragonflybsd.org
/
157 echo "#define USE_IPF 1" >> ${CONFIGFILE}
158 echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
160 echo "#define LOG_PERROR 0" >> ${CONFIGFILE}
161 echo "#define SOLARIS_KSTATS 1" >> ${CONFIGFILE}
162 OS_URL
=http
://www.sun.com
/solaris
/
165 OS_URL
=http
://www.kernel.org
/
166 KERNVERA
=`echo $OS_VERSION | awk -F. '{print $1}'`
167 KERNVERB
=`echo $OS_VERSION | awk -F. '{print $2}'`
168 KERNVERC
=`echo $OS_VERSION | awk -F. '{print $3}'`
169 KERNVERD
=`echo $OS_VERSION | awk -F. '{print $4}'`
170 #echo "$KERNVERA.$KERNVERB.$KERNVERC.$KERNVERD"
171 # Debian GNU/Linux special case
172 if [ -f /etc
/debian_version
]; then
174 OS_VERSION
=`cat /etc/debian_version`
175 OS_URL
=http
://www.debian.org
/
177 # same thing for Gentoo linux
178 if [ -f /etc
/gentoo-release
]; then
180 OS_VERSION
=`cat /etc/gentoo-release`
181 OS_URL
=http
://www.gentoo.org
/
183 # use lsb_release (Linux Standard Base) when available
184 LSB_RELEASE
=`which lsb_release`
185 if [ 0 -eq $?
]; then
186 OS_NAME
=`${LSB_RELEASE} -i -s`
187 OS_VERSION
=`${LSB_RELEASE} -r -s`
190 OS_URL
=http
://www.debian.org
/
191 OS_VERSION
=`${LSB_RELEASE} -c -s`
194 OS_URL
=http
://www.ubuntu.com
/
195 OS_VERSION
=`${LSB_RELEASE} -c -s`
198 OS_URL
=http
://www.gentoo.org
/
202 echo "#define USE_NETFILTER 1" >> ${CONFIGFILE}
203 echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
207 OS_URL
=http
://www.openwrt.org
/
208 echo "#define USE_NETFILTER 1" >> ${CONFIGFILE}
209 echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
214 OS_URL
=http
://tomatousb.org
/
215 echo "#define USE_NETFILTER 1" >> ${CONFIGFILE}
216 echo "" >> ${CONFIGFILE}
217 echo "#include <tomato_config.h>" >> ${CONFIGFILE}
218 echo "" >> ${CONFIGFILE}
219 echo "#ifdef LINUX26" >> ${CONFIGFILE}
220 echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
221 echo "#endif" >> ${CONFIGFILE}
222 echo "#ifdef TCONFIG_IPV6" >> ${CONFIGFILE}
223 echo "#define ENABLE_IPV6" >> ${CONFIGFILE}
224 echo "#endif" >> ${CONFIGFILE}
228 echo "#define USE_IPFW 1" >> ${CONFIGFILE}
229 echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
231 OS_URL
=http
://developer.apple.com
/macosx
234 echo "Unknown OS : $OS_NAME"
235 echo "Please contact the author at http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/."
240 echo "Configuring compilation for [$OS_NAME] [$OS_VERSION] with [$FW] firewall software."
241 echo "Please edit config.h for more compilation options."
243 # define SUPPORT_REMOTEHOST if the FW related code really supports setting
245 if [ "$FW" = "netfilter" ] ; then
246 echo "#define SUPPORT_REMOTEHOST" >> ${CONFIGFILE}
249 echo "" >> ${CONFIGFILE}
250 echo "#define OS_NAME \"$OS_NAME\"" >> ${CONFIGFILE}
251 echo "#define OS_VERSION \"$OS_NAME/$OS_VERSION\"" >> ${CONFIGFILE}
252 echo "#define OS_URL \"${OS_URL}\"" >> ${CONFIGFILE}
253 echo "" >> ${CONFIGFILE}
255 echo "/* syslog facility to be used by miniupnpd */" >> ${CONFIGFILE}
256 echo "#define LOG_MINIUPNPD ${LOG_MINIUPNPD}" >> ${CONFIGFILE}
257 echo "" >> ${CONFIGFILE}
259 echo "/* Uncomment the following line to allow miniupnpd to be" >> ${CONFIGFILE}
260 echo " * controlled by miniupnpdctl */" >> ${CONFIGFILE}
261 echo "/*#define USE_MINIUPNPDCTL*/" >> ${CONFIGFILE}
262 echo "" >> ${CONFIGFILE}
264 echo "/* Comment the following line to disable NAT-PMP operations */" >> ${CONFIGFILE}
265 echo "#define ENABLE_NATPMP" >> ${CONFIGFILE}
266 echo "" >> ${CONFIGFILE}
268 echo "/* Uncomment the following line to enable generation of" >> ${CONFIGFILE}
269 echo " * filter rules with pf */" >> ${CONFIGFILE}
270 echo "/*#define PF_ENABLE_FILTER_RULES*/">> ${CONFIGFILE}
271 echo "" >> ${CONFIGFILE}
273 echo "/* Uncomment the following line to enable caching of results of" >> ${CONFIGFILE}
274 echo " * the getifstats() function */" >> ${CONFIGFILE}
275 echo "/*#define ENABLE_GETIFSTATS_CACHING*/" >> ${CONFIGFILE}
276 echo "/* The cache duration is indicated in seconds */" >> ${CONFIGFILE}
277 echo "#define GETIFSTATS_CACHING_DURATION 2" >> ${CONFIGFILE}
278 echo "" >> ${CONFIGFILE}
280 echo "/* Uncomment the following line to enable multiple external ip support */" >> ${CONFIGFILE}
281 echo "/* note : That is EXPERIMENTAL, do not use that unless you know perfectly what you are doing */" >> ${CONFIGFILE}
282 echo "/* Dynamic external ip adresses are not supported when this option is enabled." >> ${CONFIGFILE}
283 echo " * Also note that you would need to configure your .conf file accordingly. */" >> ${CONFIGFILE}
284 echo "/*#define MULTIPLE_EXTERNAL_IP*/" >> ${CONFIGFILE}
285 echo "" >> ${CONFIGFILE}
287 echo "/* Comment the following line to use home made daemonize() func instead" >> ${CONFIGFILE}
288 echo " * of BSD daemon() */" >> ${CONFIGFILE}
289 echo "#define USE_DAEMON" >> ${CONFIGFILE}
290 echo "" >> ${CONFIGFILE}
292 echo "/* Uncomment the following line to enable lease file support */" >> ${CONFIGFILE}
293 echo "/*#define ENABLE_LEASEFILE*/" >> ${CONFIGFILE}
294 echo "" >> ${CONFIGFILE}
296 echo "/* Define one or none of the two following macros in order to make some" >> ${CONFIGFILE}
297 echo " * clients happy. It will change the XML Root Description of the IGD." >> ${CONFIGFILE}
298 echo " * Enabling the Layer3Forwarding Service seems to be the more compatible" >> ${CONFIGFILE}
299 echo " * option. */" >> ${CONFIGFILE}
300 echo "/*#define HAS_DUMMY_SERVICE*/" >> ${CONFIGFILE}
301 echo "#define ENABLE_L3F_SERVICE" >> ${CONFIGFILE}
302 echo "" >> ${CONFIGFILE}
304 echo "/* Enable IP v6 support */" >> ${CONFIGFILE}
305 echo "/*#define ENABLE_IPV6*/" >> ${CONFIGFILE}
306 echo "" >> ${CONFIGFILE}
308 echo "/* Enable the support of IGD v2 specification */" >> ${CONFIGFILE}
309 echo "/*#define IGD_V2*/" >> ${CONFIGFILE}
310 echo "" >> ${CONFIGFILE}
312 echo "#ifdef IGD_V2" >> ${CONFIGFILE}
313 echo "/* Enable DeviceProtection service (IGDv2) */" >> ${CONFIGFILE}
314 echo "#define ENABLE_DP_SERVICE" >> ${CONFIGFILE}
315 echo "" >> ${CONFIGFILE}
316 echo "/* Enable WANIPv6FirewallControl service (IGDv2). needs IPv6 */" >> ${CONFIGFILE}
317 echo "#ifdef ENABLE_IPV6" >> ${CONFIGFILE}
318 echo "#define ENABLE_6FC_SERVICE" >> ${CONFIGFILE}
319 echo "#endif /* ENABLE_IPV6 */" >> ${CONFIGFILE}
320 echo "#endif /* IGD_V2 */" >> ${CONFIGFILE}
321 echo "" >> ${CONFIGFILE}
323 echo "/* UPnP Events support. Working well enough to be enabled by default." >> ${CONFIGFILE}
324 echo " * It can be disabled to save a few bytes. */" >> ${CONFIGFILE}
325 echo "#define ENABLE_EVENTS" >> ${CONFIGFILE}
326 echo "" >> ${CONFIGFILE}
328 echo "/* include interface name in pf and ipf rules */" >> ${CONFIGFILE}
329 echo "#define USE_IFNAME_IN_RULES" >> ${CONFIGFILE}
330 echo "" >> ${CONFIGFILE}
332 echo "/* Experimental NFQUEUE support. */" >> ${CONFIGFILE}
333 echo "/*#define ENABLE_NFQUEUE*/" >> ${CONFIGFILE}
334 echo "" >> ${CONFIGFILE}
336 echo "/* Enable to make MiniUPnPd more strict about UPnP conformance" >> ${CONFIGFILE}
337 echo " * and the messages it receive from control points */" >> ${CONFIGFILE}
338 echo "/*#define UPNP_STRICT*/" >> ${CONFIGFILE}
339 echo "" >> ${CONFIGFILE}
341 echo "#endif" >> ${CONFIGFILE}