add ENABLE_PORT_TRIGGERING macro in config.h

enabled by default. Will allow people to disable the code :)
This commit is contained in:
Thomas Bernard 2016-02-09 10:09:19 +01:00
parent 5f74a08dd6
commit 06049f1e7d
2 changed files with 15 additions and 2 deletions

View File

@ -2,7 +2,7 @@
# $Id: genconfig.sh,v 1.81 2015/07/16 15:00:21 nanard Exp $
# miniupnp daemon
# http://miniupnp.free.fr or http://miniupnp.tuxfamily.org/
# (c) 2006-2015 Thomas Bernard
# (c) 2006-2016 Thomas Bernard
# This software is subject to the conditions detailed in the
# LICENCE file provided within the distribution
@ -96,7 +96,7 @@ ${RM} ${CONFIGFILE}
echo "/* MiniUPnP Project" >> ${CONFIGFILE}
echo " * http://miniupnp.free.fr/ or http://miniupnp.tuxfamily.org/" >> ${CONFIGFILE}
echo " * (c) 2006-2015 Thomas Bernard" >> ${CONFIGFILE}
echo " * (c) 2006-2016 Thomas Bernard" >> ${CONFIGFILE}
echo " * generated by $0 on `date`" >> ${CONFIGFILE}
echo " * `uname -a`" >> ${CONFIGFILE}
echo " * using command line options $* */" >> ${CONFIGFILE}
@ -370,6 +370,10 @@ if [ \( "$FW" = "netfilter" \) -o \( "$FW" = "pf" \) -o \( "$FW" = "ipfw" \) ] ;
echo "#define SUPPORT_REMOTEHOST" >> ${CONFIGFILE}
fi
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}
echo "" >> ${CONFIGFILE}
echo "#define OS_NAME \"$OS_NAME\"" >> ${CONFIGFILE}
echo "#define OS_VERSION \"$OS_NAME/$OS_VERSION\"" >> ${CONFIGFILE}

View File

@ -72,11 +72,13 @@ static int
add_filter_rule(int proto, const char * rhost,
const char * iaddr, unsigned short iport);
#ifdef ENABLE_PORT_TRIGGERING
static int
addmasqueraderule(int proto,
unsigned short eport,
const char * iaddr, unsigned short iport,
const char * rhost/*, const char * extif*/);
#endif /* ENABLE_PORT_TRIGGERING */
static int
addpeernatrule(int proto,
@ -230,10 +232,13 @@ add_redirect_rule2(const char * ifname,
r = addnatrule(proto, eport, iaddr, iport, rhost);
if(r >= 0) {
add_redirect_desc(eport, proto, desc, timestamp);
#ifdef ENABLE_PORT_TRIGGERING
/* TODO : check if this should be done only with UDP */
r = addmasqueraderule(proto, eport, iaddr, iport, rhost/*, ifname*/);
if(r < 0) {
syslog(LOG_NOTICE, "add_redirect_rule2(): addmasqueraderule returned %d", r);
}
#endif /* ENABLE_PORT_TRIGGERING */
}
return r;
}
@ -1017,6 +1022,7 @@ get_dscp_target(unsigned char dscp)
return target;
}
#ifdef ENABLE_PORT_TRIGGERING
static struct ipt_entry_target *
get_masquerade_target(unsigned short port)
{
@ -1039,6 +1045,7 @@ get_masquerade_target(unsigned short port)
range->flags |= IP_NAT_RANGE_PROTO_SPECIFIED;
return target;
}
#endif /* ENABLE_PORT_TRIGGERING */
/* iptc_init_verify_and_append()
* return 0 on success, -1 on failure */
@ -1181,6 +1188,7 @@ addnatrule(int proto, unsigned short eport,
* iptables -t nat -A MINIUPNPD-POSTROUTING {-o <extif>} -s <iaddr>
* -p <proto> [-d <rhost>] --sport <iport> -j MASQUERADE --to-ports <eport>
*/
#ifdef ENABLE_PORT_TRIGGERING
static int
addmasqueraderule(int proto,
unsigned short eport,
@ -1253,6 +1261,7 @@ addmasqueraderule(int proto,
free(e);
return r;
}
#endif /* ENABLE_PORT_TRIGGERING */
/* called by add_peer_redirect_rule2()
*