File:  [ELWIX - Embedded LightWeight unIX -] / embedaddon / miniupnpd / genconfig.sh
Revision 1.1.1.2 (vendor branch): download - view: text, annotated - select for diffs - revision graph
Tue May 29 12:55:57 2012 UTC (12 years, 1 month ago) by misho
Branches: miniupnpd, elwix, MAIN
CVS tags: v1_6elwix, HEAD
miniupnpd 1.6+patches

    1: #! /bin/sh
    2: # $Id: genconfig.sh,v 1.1.1.2 2012/05/29 12:55:57 misho Exp $
    3: # miniupnp daemon
    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
    8: 
    9: RM="rm -f"
   10: CONFIGFILE="config.h"
   11: CONFIGMACRO="__CONFIG_H__"
   12: 
   13: # version reported in XML descriptions
   14: #UPNP_VERSION=20070827
   15: UPNP_VERSION=`date +"%Y%m%d"`
   16: # Facility to syslog
   17: LOG_MINIUPNPD="LOG_DAEMON"
   18: 
   19: # detecting the OS name and version
   20: OS_NAME=`uname -s`
   21: OS_VERSION=`uname -r`
   22: 
   23: # pfSense special case
   24: if [ -f /etc/platform ]; then
   25: 	if [ `cat /etc/platform` = "pfSense" ]; then
   26: 		OS_NAME=pfSense
   27: 		OS_VERSION=`cat /etc/version`
   28: 	fi
   29: fi
   30: 
   31: # OpenWRT special case
   32: if [ -f ./os.openwrt ]; then
   33: 	OS_NAME=OpenWRT
   34: 	OS_VERSION=$(cat ./os.openwrt)
   35: fi
   36: 
   37: ${RM} ${CONFIGFILE}
   38: 
   39: echo "/* MiniUPnP Project" >> ${CONFIGFILE}
   40: echo " * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/" >> ${CONFIGFILE}
   41: echo " * (c) 2006-2011 Thomas Bernard" >> ${CONFIGFILE}
   42: echo " * generated by $0 on `date` */" >> ${CONFIGFILE}
   43: echo "#ifndef $CONFIGMACRO" >> ${CONFIGFILE}
   44: echo "#define $CONFIGMACRO" >> ${CONFIGFILE}
   45: echo "" >> ${CONFIGFILE}
   46: echo "#include <inttypes.h>" >> ${CONFIGFILE}
   47: echo "" >> ${CONFIGFILE}
   48: echo "#define MINIUPNPD_VERSION \"`cat VERSION`\"" >> ${CONFIGFILE}
   49: echo "" >> ${CONFIGFILE}
   50: echo "#define UPNP_VERSION	\"$UPNP_VERSION\"" >> ${CONFIGFILE}
   51: 
   52: # OS Specific stuff
   53: case $OS_NAME in
   54: 	OpenBSD)
   55: 		MAJORVER=`echo $OS_VERSION | cut -d. -f1`
   56: 		MINORVER=`echo $OS_VERSION | cut -d. -f2`
   57: 		#echo "OpenBSD majorversion=$MAJORVER minorversion=$MINORVER"
   58: 		# rtableid was introduced in OpenBSD 4.0
   59: 		if [ $MAJORVER -ge 4 ]; then
   60: 			echo "#define PFRULE_HAS_RTABLEID" >> ${CONFIGFILE}
   61: 		fi
   62: 		# from the 3.8 version, packets and bytes counters are double : in/out
   63: 		if [ \( $MAJORVER -ge 4 \) -o \( $MAJORVER -eq 3 -a $MINORVER -ge 8 \) ]; then
   64: 			echo "#define PFRULE_INOUT_COUNTS" >> ${CONFIGFILE}
   65: 		fi
   66: 		# from the 4.7 version, new pf
   67: 		if [ \( $MAJORVER -ge 5 \) -o \( $MAJORVER -eq 4 -a $MINORVER -ge 7 \) ]; then
   68: 			echo "#define PF_NEWSTYLE" >> ${CONFIGFILE}
   69: 		fi
   70: 		echo "#define USE_PF 1" >> ${CONFIGFILE}
   71: 		FW=pf
   72: 		echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
   73: 		OS_URL=http://www.openbsd.org/
   74: 		;;
   75: 	FreeBSD)
   76: 		VER=`grep '#define __FreeBSD_version' /usr/include/sys/param.h | awk '{print $3}'`
   77: 		if [ $VER -ge 700049 ]; then
   78: 			echo "#define PFRULE_INOUT_COUNTS" >> ${CONFIGFILE}
   79: 		fi
   80: 		# new way to see which one to use PF or IPF.
   81: 		# see http://miniupnp.tuxfamily.org/forum/viewtopic.php?p=957
   82: 		# source file wource config file so we can probe vars
   83: 		if [ -f /etc/rc.subr ] && [ -f /etc/rc.conf ]; then
   84: 			# source file with handy subroutines like checkyesno
   85: 			. /etc/rc.subr
   86: 			# source config file so we can probe vars
   87: 			. /etc/rc.conf
   88: 			if checkyesno ipfilter_enable; then
   89: 				echo "Using ipf"
   90: 				FW=ipf
   91: 				echo "#define USE_IPF 1" >> ${CONFIGFILE}
   92: 			elif checkyesno pf_enable; then
   93: 				echo "Using pf"
   94: 				FW=pf
   95: 				echo "#define USE_PF 1" >> ${CONFIGFILE}
   96: 			else
   97: 				echo "Could not detect usage of ipf or pf. Compiling for pf by default"
   98: 				FW=pf
   99: 				echo "#define USE_PF 1" >> ${CONFIGFILE}
  100: 			fi
  101: 		# TODO : Add support for IPFW
  102: 		# echo "#define USE_IPFW 1" >> ${CONFIGFILE}
  103: 		# FW=ipfw
  104: 		else
  105: 			echo "Could not detect usage of ipf or pf. Compiling for pf by default"
  106: 			FW=pf
  107: 			echo "#define USE_PF 1" >> ${CONFIGFILE}
  108: 		fi
  109: 		echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
  110: 		OS_URL=http://www.freebsd.org/
  111: 		;;
  112: 	pfSense)
  113: 		# we need to detect if PFRULE_INOUT_COUNTS macro is needed
  114: 		echo "#define USE_PF 1" >> ${CONFIGFILE}
  115: 		FW=pf
  116: 		echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
  117: 		OS_URL=http://www.pfsense.com/
  118: 		;;
  119: 	NetBSD)
  120: 		# source file with handy subroutines like checkyesno
  121: 		. /etc/rc.subr
  122: 		# source config file so we can probe vars
  123: 		. /etc/rc.conf
  124: 		if checkyesno pf; then
  125: 			echo "#define USE_PF 1" >> ${CONFIGFILE}
  126: 			FW=pf
  127: 		elif checkyesno ipfilter; then
  128: 			echo "#define USE_IPF 1" >> ${CONFIGFILE}
  129: 			FW=ipf
  130: 		else
  131: 			echo "Could not detect ipf nor pf, defaulting to pf."
  132: 			echo "#define USE_PF 1" >> ${CONFIGFILE}
  133: 			FW=pf
  134: 		fi
  135: 		echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
  136: 		OS_URL=http://www.netbsd.org/
  137: 		;;
  138: 	DragonFly)
  139: 		# source file with handy subroutines like checkyesno
  140: 		. /etc/rc.subr
  141: 		# source config file so we can probe vars
  142: 		. /etc/rc.conf
  143: 		if checkyesno pf; then
  144: 			echo "#define USE_PF 1" >> ${CONFIGFILE}
  145: 			FW=pf
  146: 		elif checkyesno ipfilter; then
  147: 			echo "#define USE_IPF 1" >> ${CONFIGFILE}
  148: 			FW=ipf
  149: 		else
  150: 			echo "Could not detect ipf nor pf, defaulting to pf."
  151: 			echo "#define USE_PF 1" >> ${CONFIGFILE}
  152: 			FW=pf
  153: 		fi
  154: 		echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
  155: 		OS_URL=http://www.dragonflybsd.org/
  156: 		;;
  157: 	SunOS)
  158: 		echo "#define USE_IPF 1" >> ${CONFIGFILE}
  159: 		echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
  160: 		FW=ipf
  161: 		echo "#define LOG_PERROR 0" >> ${CONFIGFILE}
  162: 		echo "#define SOLARIS_KSTATS 1" >> ${CONFIGFILE}
  163: 		OS_URL=http://www.sun.com/solaris/
  164: 		;;
  165: 	Linux)
  166: 		OS_URL=http://www.kernel.org/
  167: 		KERNVERA=`echo $OS_VERSION | awk -F. '{print $1}'`
  168: 		KERNVERB=`echo $OS_VERSION | awk -F. '{print $2}'`
  169: 		KERNVERC=`echo $OS_VERSION | awk -F. '{print $3}'`
  170: 		KERNVERD=`echo $OS_VERSION | awk -F. '{print $4}'`
  171: 		#echo "$KERNVERA.$KERNVERB.$KERNVERC.$KERNVERD"
  172: 		# Debian GNU/Linux special case
  173: 		if [ -f /etc/debian_version ]; then
  174: 			OS_NAME=Debian
  175: 			OS_VERSION=`cat /etc/debian_version`
  176: 			OS_URL=http://www.debian.org/
  177: 		fi
  178: 		# same thing for Gentoo linux
  179: 		if  [ -f /etc/gentoo-release ]; then
  180: 			OS_NAME=Gentoo
  181: 			OS_VERSION=`cat /etc/gentoo-release`
  182: 			OS_URL=http://www.gentoo.org/
  183: 		fi
  184: 		# use lsb_release (Linux Standard Base) when available
  185: 		LSB_RELEASE=`which lsb_release`
  186: 		if [ 0 -eq $? ]; then
  187: 			OS_NAME=`${LSB_RELEASE} -i -s`
  188: 			OS_VERSION=`${LSB_RELEASE} -r -s`
  189: 			case $OS_NAME in
  190: 				Debian)
  191: 					OS_URL=http://www.debian.org/
  192: 					OS_VERSION=`${LSB_RELEASE} -c -s`
  193: 					;;
  194: 				Ubuntu)
  195: 					OS_URL=http://www.ubuntu.com/
  196: 					OS_VERSION=`${LSB_RELEASE} -c -s`
  197: 					;;
  198: 				Gentoo)
  199: 					OS_URL=http://www.gentoo.org/
  200: 					;;
  201: 			esac
  202: 		fi
  203: 		echo "#define USE_NETFILTER 1" >> ${CONFIGFILE}
  204: 		echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
  205: 		FW=netfilter
  206: 		;;
  207: 	OpenWRT)
  208: 		OS_URL=http://www.openwrt.org/
  209: 		echo "#define USE_NETFILTER 1" >> ${CONFIGFILE}
  210: 		echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
  211: 		FW=netfilter
  212: 		;;
  213: 	Darwin)
  214: 		echo "#define USE_IPFW 1" >> ${CONFIGFILE}
  215: 		echo "#define USE_IFACEWATCHER 1" >> ${CONFIGFILE}
  216: 		FW=ipfw
  217: 		OS_URL=http://developer.apple.com/macosx
  218: 		;;
  219: 	*)
  220: 		echo "Unknown OS : $OS_NAME"
  221: 		echo "Please contact the author at http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/."
  222: 		exit 1
  223: 		;;
  224: esac
  225: 
  226: echo "Configuring compilation for [$OS_NAME] [$OS_VERSION] with [$FW] firewall software."
  227: echo "Please edit config.h for more compilation options."
  228: 
  229: # define SUPPORT_REMOTEHOST if the FW related code really supports setting
  230: # a RemoteHost
  231: if [ \( "$FW" = "netfilter" \) -o \( "$FW" = "pf" \) -o \( "$FW" = "ipfw" \) ] ; then
  232: 	echo "#define SUPPORT_REMOTEHOST" >> ${CONFIGFILE}
  233: fi
  234: 
  235: echo "" >> ${CONFIGFILE}
  236: echo "#define OS_NAME		\"$OS_NAME\"" >> ${CONFIGFILE}
  237: echo "#define OS_VERSION	\"$OS_NAME/$OS_VERSION\"" >> ${CONFIGFILE}
  238: echo "#define OS_URL		\"${OS_URL}\"" >> ${CONFIGFILE}
  239: echo "" >> ${CONFIGFILE}
  240: 
  241: echo "/* syslog facility to be used by miniupnpd */" >> ${CONFIGFILE}
  242: echo "#define LOG_MINIUPNPD		 ${LOG_MINIUPNPD}" >> ${CONFIGFILE}
  243: echo "" >> ${CONFIGFILE}
  244: 
  245: echo "/* Uncomment the following line to allow miniupnpd to be" >> ${CONFIGFILE}
  246: echo " * controlled by miniupnpdctl */" >> ${CONFIGFILE}
  247: echo "/*#define USE_MINIUPNPDCTL*/" >> ${CONFIGFILE}
  248: echo "" >> ${CONFIGFILE}
  249: 
  250: echo "/* Comment the following line to disable NAT-PMP operations */" >> ${CONFIGFILE}
  251: echo "#define ENABLE_NATPMP" >> ${CONFIGFILE}
  252: echo "" >> ${CONFIGFILE}
  253: 
  254: echo "/* Uncomment the following line to enable generation of" >> ${CONFIGFILE}
  255: echo " * filter rules with pf */" >> ${CONFIGFILE}
  256: echo "#define PF_ENABLE_FILTER_RULES">> ${CONFIGFILE}
  257: echo "" >> ${CONFIGFILE}
  258: 
  259: echo "/* Uncomment the following line to enable caching of results of" >> ${CONFIGFILE}
  260: echo " * the getifstats() function */" >> ${CONFIGFILE}
  261: echo "/*#define ENABLE_GETIFSTATS_CACHING*/" >> ${CONFIGFILE}
  262: echo "/* The cache duration is indicated in seconds */" >> ${CONFIGFILE}
  263: echo "#define GETIFSTATS_CACHING_DURATION 2" >> ${CONFIGFILE}
  264: echo "" >> ${CONFIGFILE}
  265: 
  266: echo "/* Uncomment the following line to enable multiple external ip support */" >> ${CONFIGFILE}
  267: echo "/* note : That is EXPERIMENTAL, do not use that unless you know perfectly what you are doing */" >> ${CONFIGFILE}
  268: echo "/* Dynamic external ip adresses are not supported when this option is enabled." >> ${CONFIGFILE}
  269: echo " * Also note that you would need to configure your .conf file accordingly. */" >> ${CONFIGFILE}
  270: echo "/*#define MULTIPLE_EXTERNAL_IP*/" >> ${CONFIGFILE}
  271: echo "" >> ${CONFIGFILE}
  272: 
  273: echo "/* Comment the following line to use home made daemonize() func instead" >> ${CONFIGFILE}
  274: echo " * of BSD daemon() */" >> ${CONFIGFILE}
  275: echo "#define USE_DAEMON" >> ${CONFIGFILE}
  276: echo "" >> ${CONFIGFILE}
  277: 
  278: echo "/* Uncomment the following line to enable lease file support */" >> ${CONFIGFILE}
  279: echo "/*#define ENABLE_LEASEFILE*/" >> ${CONFIGFILE}
  280: echo "" >> ${CONFIGFILE}
  281: 
  282: echo "/* Define one or none of the two following macros in order to make some" >> ${CONFIGFILE}
  283: echo " * clients happy. It will change the XML Root Description of the IGD." >> ${CONFIGFILE}
  284: echo " * Enabling the Layer3Forwarding Service seems to be the more compatible" >> ${CONFIGFILE}
  285: echo " * option. */" >> ${CONFIGFILE}
  286: echo "/*#define HAS_DUMMY_SERVICE*/" >> ${CONFIGFILE}
  287: echo "#define ENABLE_L3F_SERVICE" >> ${CONFIGFILE}
  288: echo "" >> ${CONFIGFILE}
  289: 
  290: echo "/* Enable IP v6 support */" >> ${CONFIGFILE}
  291: echo "/*#define ENABLE_IPV6*/" >> ${CONFIGFILE}
  292: echo "" >> ${CONFIGFILE}
  293: 
  294: echo "/* Enable the support of IGD v2 specification." >> ${CONFIGFILE}
  295: echo " * This is not fully tested yet and can cause incompatibilities with some" >> ${CONFIGFILE}
  296: echo " * control points, so enable with care. */" >> ${CONFIGFILE}
  297: echo "/*#define IGD_V2*/" >> ${CONFIGFILE}
  298: echo "" >> ${CONFIGFILE}
  299: 
  300: echo "#ifdef IGD_V2" >> ${CONFIGFILE}
  301: echo "/* Enable DeviceProtection service (IGDv2) */" >> ${CONFIGFILE}
  302: echo "#define ENABLE_DP_SERVICE" >> ${CONFIGFILE}
  303: echo "" >> ${CONFIGFILE}
  304: echo "/* Enable WANIPv6FirewallControl service (IGDv2). needs IPv6 */" >> ${CONFIGFILE}
  305: echo "#ifdef ENABLE_IPV6" >> ${CONFIGFILE}
  306: echo "#define ENABLE_6FC_SERVICE" >> ${CONFIGFILE}
  307: echo "#endif /* ENABLE_IPV6 */" >> ${CONFIGFILE}
  308: echo "#endif /* IGD_V2 */" >> ${CONFIGFILE}
  309: echo "" >> ${CONFIGFILE}
  310: 
  311: echo "/* UPnP Events support. Working well enough to be enabled by default." >> ${CONFIGFILE}
  312: echo " * It can be disabled to save a few bytes. */" >> ${CONFIGFILE}
  313: echo "#define ENABLE_EVENTS" >> ${CONFIGFILE}
  314: echo "" >> ${CONFIGFILE}
  315: 
  316: echo "/* include interface name in pf and ipf rules */" >> ${CONFIGFILE}
  317: echo "#define USE_IFNAME_IN_RULES" >> ${CONFIGFILE}
  318: echo "" >> ${CONFIGFILE}
  319: 
  320: echo "/* Experimental NFQUEUE support. */" >> ${CONFIGFILE}
  321: echo "/*#define ENABLE_NFQUEUE*/" >> ${CONFIGFILE}
  322: echo "" >> ${CONFIGFILE}
  323: 
  324: echo "/* Enable to make MiniUPnPd more strict about UPnP conformance" >> ${CONFIGFILE}
  325: echo " * and the messages it receives from control points */" >> ${CONFIGFILE}
  326: echo "/*#define UPNP_STRICT*/" >> ${CONFIGFILE}
  327: echo "" >> ${CONFIGFILE}
  328: 
  329: echo "#endif" >> ${CONFIGFILE}
  330: 
  331: exit 0

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>