Add gw6c and make it link against uclibcxx (#2125)

git-svn-id: svn://svn.openwrt.org/openwrt/packages@13148 3c298f89-4303-0410-b956-a3cf2f4a3e73
This commit is contained in:
florian 2008-11-09 16:14:40 +00:00
parent b2e615280e
commit c557c57ae3
4 changed files with 433 additions and 0 deletions

75
ipv6/gw6c/Makefile Normal file
View File

@ -0,0 +1,75 @@
#
# Copyright (C) 2008 OpenWrt.org
#
# $Id: $
include $(TOPDIR)/rules.mk
PKG_NAME:=gw6c
PKG_VERSION:=5.0
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
include $(INCLUDE_DIR)/package.mk
define Package/gw6c
SECTION:=ipv6
CATEGORY:=IPv6
DEPENDS:=+libpthread +ip +kmod-tun +kmod-ipv6 +uclibcxx +radvd
TITLE:=IPv6 tunnel client software
URL:=http://www.go6.net
endef
define Package/gw6c/description
Client to configure an IPv6 tunnel to
Hexago/freenet6/go6.net's migration broker.
endef
define Build/Prepare
wget -t1 --timeout=20 -O $(DL_DIR)/$(PKG_NAME)-$(PKG_VERSION).tar.bz2 "http://www.go6.net/4105/file.asp?file_id=136"
$(INSTALL_DIR) $(PKG_BUILD_DIR)
bzcat $(DL_DIR)/$(PKG_NAME)-$(PKG_VERSION).tar.bz2 | $(TAR) -C $(PKG_BUILD_DIR) -xvf -
$(CP) $(PKG_BUILD_DIR)/gw6c/src/gw6c-config/gw6cconfig/gw6c_c_wrapper.h $(PKG_BUILD_DIR)/gw6c/src/gw6c/include
endef
GW6C_OPTS:= \
C_COMPILER="$(TARGET_CC) -c -DNO_STDLIBCXX" \
COMPILER="$(TARGET_CROSS)g++ -c -DNO_STDLIBCXX" \
CPP_FLAGS="$(TARGET_CFLAGS) -fno-builtin -nostdinc++ -I. -Wall -DNDEBUG -I$(STAGING_DIR)/usr/include/uClibc++ -I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include" \
RANLIB="$(TARGET_CROSS)ranlib" \
ARCHIVER="$(TARGET_CROSS)ar" \
C_LINKER="$(TARGET_CC)" \
LINKER="$(TARGET_CROSS)g++" \
exportdir=$(PKG_BUILD_DIR)/gw6c/src/gw6c \
export
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR)/gw6c/src/gw6c-config \
$(GW6C_OPTS)
$(MAKE) -C $(PKG_BUILD_DIR)/gw6c/src/gw6c-messaging \
$(GW6C_OPTS)
$(MAKE) -C $(PKG_BUILD_DIR)/gw6c/src/gw6c \
CC="$(TARGET_CC)" \
CFLAGS="$(TARGET_CFLAGS) -fno-builtin -Wall -I$(PKG_BUILD_DIR)/gw6c/src/gw6c/include \
-I$(PKG_BUILD_DIR)/gw6c/src/gw6c/platform/openwrt -I$(PKG_BUILD_DIR)/gw6c/src/gw6c" \
LDFLAGS="-L$(PKG_BUILD_DIR)/gw6c/src/gw6c/gw6cconfig \
-L$(PKG_BUILD_DIR)/gw6c/src/gw6c/gw6cmessaging \
-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib -nodefaultlibs -luClibc++ -lgcc_s" \
target="openwrt" \
installdir="$(PKG_INSTALL_DIR)"
endef
define Package/gw6c/install
$(INSTALL_DIR) $(1)/usr/sbin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/gw6c/src/gw6c/bin/$(PKG_NAME) $(1)/usr/sbin
$(INSTALL_DIR) $(1)/usr/share/gw6c/template
$(CP) ./files/openwrt.sh $(1)/usr/share/gw6c/template
$(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/gw6c.init $(1)/etc/init.d/gw6c
$(INSTALL_DIR) $(1)/etc/config
$(INSTALL_CONF) ./files/gw6c.config $(1)/etc/config/gw6c
endef
$(eval $(call BuildPackage,gw6c))

View File

@ -0,0 +1,66 @@
config gw6c basic
#Comment out next line to enable gw6c
option disabled 1
#Leave empty if connecting anonymously
option userid
option passwd
#For anonymous use anon.frenet6.net and
#account holders should use broker.freenet6.net
option server anon.freenet6.net
#auth_method <anonymous|any|passds-3des-1|digest-md5|plain>
#Use anonymous with anonymous access and
#any if you are account holder
option auth_method anonymous
config gw6c routing
#host_type <host|router>
option host_type host
option prefixlen 48
option ifprefix br-lan
#DNS server list to which the reverse prefix
#will be delegated. Separate servers with :
option dns_server
config gw6c advanced
#Location where to store configuration file
option gw6c_conf /tmp/gw6c.conf
option gw6c_dir /usr/share/gw6c
option auto_retry yes
option retry_delay 30
option keepalive yes
#keepalive interval
option interval 30
#tunnel_mode <v6v4|v6udpv4|v6anyv4|v4v6>
option if_tunnel_mode v6anyv4
option if_v6v4 sit1
option if_v6udpv4 tun
option if_v4v6 sit0
option client_v4 auto
option client_v6 auto
option template openwrt
option proxy_client no
config gw6c broker
option broker_list /tmp/gw6c-broker-list.txt
option last_server /tmp/gw6c-last-server.txt
# Always use last known working server? <yes|no>
option always_same_serv no
config gw6c logging
option log_console 0
option log_stderr 1
option log_file 0
option log_syslog 0
option log_filename /var/log/gw6c.log
option log_rotation yes
#Max size when using log file rotation
#possible values: 16|32|128|1024
option log_maxsize 32
#<USER|LOCAL[0-7]>
option syslog_facility USER

111
ipv6/gw6c/files/gw6c.init Executable file
View File

@ -0,0 +1,111 @@
#!/bin/sh /etc/rc.common
#Copyright (C) 2007 RoadRunner.cx
START=52
genconf() {
[ -f /etc/config/gw6c ] || {
echo "You are missing configuration file /etc/config/gw6c"
return 0
}
config_load "gw6c"
config_get DISABLED basic disabled
[ "$DISABLED" == "1" ] && {
echo "You haven't edited your configuration file. Gateway6 is disabled."
return 0
}
config_get USERID basic userid
config_get PASSWORD basic passwd
config_get SERVER basic server
config_get AUTH_METHOD basic auth_method
config_get HOST_TYPE routing host_type
config_get PREFIX_LEN routing prefixlen
config_get IF_PREFIX routing ifprefix
config_get DNS_SERVER routing dns_server
config_get GW6C_CONF advanced gw6c_conf
config_get GW6C_DIR advanced gw6c_dir
config_get AUTO_RETRY advanced auto_retry
config_get RETRY_DELAY advanced retry_delay
config_get KEEPALIVE advanced keepalive
config_get KEEPALIVE_INTERVAL advanced interval
config_get TUNNEL_MODE advanced if_tunnel_mode
config_get IF_V6V4 advanced if_v6v4
config_get IF_V6UDPV4 advanced if_v6udpv4
config_get IF_V4V6 advanced if_v4v6
config_get CLIENT_V4 advanced client_v4
config_get CLIENT_V6 advanced client_v6
config_get TEMPLATE advanced template
config_get PROXY_CLIENT advanced proxy_client
config_get BROKER_LIST broker broker_list
config_get LAST_SERVER broker last_server
config_get ALWAYS_SAMESERV broker always_same_serv
config_get LOG_CONSOLE logging log_console
config_get LOG_STDERR logging log_stderr
config_get LOG_FILE logging log_file
config_get LOG_SYSLOG logging log_syslog
config_get LOG_FILENAME logging log_filename
config_get LOG_ROTATE logging log_rotation
config_get LOG_MAXSIZE logging log_maxsize
config_get SYSLOG_FACILITY logging syslog_facility
cat >$GW6C_CONF <<EOF
userid=$USERID
passwd=$PASSWORD
server=$SERVER
auth_method=$AUTH_METHOD
host_type=$HOST_TYPE
prefixlen=$PREFIX_LEN
if_prefix=$IF_PREFIX
dns_server=$DNS_SERVER
gw6_dir=$GW6C_DIR
auto_retry_connect=$AUTO_RETRY
retry_delay=$RETRY_DELAY
keepalive=$KEEPALIVE
keepalive_interval=$KEEPALIVE_INTERVAL
tunnel_mode=$TUNNEL_MODE
if_tunnel_v6v4=$IF_V6V4
if_tunnel_v6udpv4=$IF_V6UDPV4
if_tunnel_v4v6=$IF_V4V6
client_v4=$CLIENT_V4
client_v6=$CLIENT_V6
template=$TEMPLATE
proxy_client=$PROXY_CLIENT
broker_list=$BROKER_LIST
last_server=$LAST_SERVER
always_use_same_server=$ALWAYS_SAMESERV
log_console=$LOG_CONSOLE
log_stderr=$LOG_STDERR
log_file=$LOG_FILE
log_syslog=$LOG_SYSLOG
log_filename=$LOG_FILENAME
log_rotation=$LOG_ROTATE
log_rotation_size=$LOG_MAXSIZE
syslog_facility=$SYSLOG_FACILITY
EOF
}
start() {
genconf
if [ -z "$GW6C_CONF" ] || [ ! -f "$GW6C_CONF" ]; then
echo "Gateway6 client cannot start."
else
echo "Starting Gateway6 client."
/usr/sbin/gw6c -f "$GW6C_CONF"
fi
}
stop() {
[ `ps ax|grep -v grep|grep -c gw6c` != "0" ] && {
killall -q gw6c
[ `ps ax|grep -v grep|grep -c radvd` != "0" ] && killall -q radvd
echo 0 > /proc/sys/net/ipv6/conf/all/forwarding
}
}

181
ipv6/gw6c/files/openwrt.sh Executable file
View File

@ -0,0 +1,181 @@
#!/bin/sh
#
# openwrt.sh,v 1.1.4.1 2007/01/12 19:16:12 dgregoire Exp
#
# This source code copyright (c) Hexago Inc. 2002-2007.
#
# LICENSE NOTICE: You may use and modify this source code only if you
# have executed a valid license agreement with Hexago Inc. granting
# you the right to do so, the said license agreement governing such
# use and modifications. Copyright or other intellectual property
# notices are not to be removed from the source code.
#
# Note: IPV6 support and tun Support must be enabled before calling this script.
#
LANGUAGE=C
if [ -z $TSP_VERBOSE ]; then
TSP_VERBOSE=0
fi
KillProcess()
{
if [ ! -z $TSP_VERBOSE ]; then
if [ $TSP_VERBOSE -ge 2 ]; then
echo killing $*
fi
fi
PID=`ps axww | grep $1 | grep -v grep | awk '{ print $1;}'`
echo $PID
if [ ! -z $PID ]; then
kill $PID
fi
}
Display()
{
if [ -z $TSP_VERBOSE ]; then
return;
fi
if [ $TSP_VERBOSE -lt $1 ]; then
return;
fi
shift
echo "$*"
}
Exec()
{
if [ ! -z $TSP_VERBOSE ]; then
if [ $TSP_VERBOSE -ge 2 ]; then
echo $*
fi
fi
$* # Execute command
if [ $? -ne 0 ]; then
echo "Error while executing $1"
echo " Command: $*"
exit 1
fi
}
ExecNoCheck()
{
if [ ! -z $TSP_VERBOSE ]; then
if [ $TSP_VERBOSE -ge 2 ]; then
echo $*
fi
fi
$* # Execute command
}
# Program localization
Display 1 "--- Start of configuration script. ---"
Display 1 "Script: " `basename $0`
ifconfig=/sbin/ifconfig
route=/sbin/route
ipconfig=/usr/sbin/ip
rtadvd=/usr/sbin/radvd
rtadvd_pid=/var/run/radvd.pid
sysctl=/sbin/sysctl
rtadvdconfigfilename=gw6c-radvd.conf
rtadvdconfigfile=/tmp/$rtadvdconfigfilename
if [ -z $TSP_HOME_DIR ]; then
echo "TSP_HOME_DIR variable not specified!;"
exit 1
fi
if [ ! -d $TSP_HOME_DIR ]; then
echo "Error : directory $TSP_HOME_DIR does not exist"
exit 1
fi
#
if [ -z $TSP_HOST_TYPE ]; then
echo Error: TSP_HOST_TYPE not defined.
exit 1
fi
if [ X"${TSP_HOST_TYPE}" = X"host" ] || [ X"${TSP_HOST_TYPE}" = X"router" ]; then
#
# Configured tunnel config (IPv6)
Display 1 "$TSP_TUNNEL_INTERFACE setup"
if [ X"${TSP_TUNNEL_MODE}" = X"v6v4" ]; then
Display 1 "Setting up link to $TSP_SERVER_ADDRESS_IPV4"
ExecNoCheck $ipconfig tunnel del $TSP_TUNNEL_INTERFACE
ExecNoCheck sleep 1
Exec $ipconfig tunnel add $TSP_TUNNEL_INTERFACE mode sit ttl 64 remote $TSP_SERVER_ADDRESS_IPV4
fi
Exec $ifconfig $TSP_TUNNEL_INTERFACE up
PREF=`echo $TSP_CLIENT_ADDRESS_IPV6 | sed "s/:0*/:/g" |cut -d : -f1-2`
OLDADDR=`$ifconfig $TSP_TUNNEL_INTERFACE | grep "inet6.* $PREF" | sed -e "s/^.*inet6 addr: //" -e "s/ Scope.*\$//"`
if [ ! -z $OLDADDR ]; then
Display 1 "Removing old IPv6 address $OLDADDR"
Exec $ifconfig $TSP_TUNNEL_INTERFACE inet6 del $OLDADDR
fi
Display 1 "This host is: $TSP_CLIENT_ADDRESS_IPV6/$TSP_TUNNEL_PREFIXLEN"
Exec $ifconfig $TSP_TUNNEL_INTERFACE add $TSP_CLIENT_ADDRESS_IPV6/$TSP_TUNNEL_PREFIXLEN
Exec $ifconfig $TSP_TUNNEL_INTERFACE mtu 1280
#
# Default route
Display 1 "Adding default route"
ExecNoCheck $route -A inet6 del ::/0 2>/dev/null # delete old default route
ExecNoCheck $route -A inet6 del 2000::/3 2>/dev/null # delete old gw route
Exec $route -A inet6 add ::/0 dev $TSP_TUNNEL_INTERFACE
Exec $route -A inet6 add 2000::/3 dev $TSP_TUNNEL_INTERFACE
fi
# Router configuration if required
if [ X"${TSP_HOST_TYPE}" = X"router" ]; then
Display 1 "Router configuration"
Display 1 "Kernel setup"
if [ X"${TSP_PREFIXLEN}" != X"64" ]; then
#Better way on linux to avoid loop with the remaining /48?
$route -A inet6 add $TSP_PREFIX::/$TSP_PREFIXLEN dev $TSP_HOME_INTERFACE 2>/dev/null
fi
Display 1 "Adding prefix to $TSP_HOME_INTERFACE"
OLDADDR=`$ifconfig $TSP_HOME_INTERFACE | grep "inet6.* $PREF" | sed -e "s/^.*inet6 addr: //" -e "s/ Scope.*\$//"`
if [ ! -z $OLDADDR ]; then
Display 1 "Removing old IPv6 address $OLDADDR"
Exec $ifconfig $TSP_HOME_INTERFACE del $OLDADDR
fi
Exec $ifconfig $TSP_HOME_INTERFACE add $TSP_PREFIX::1/64
# Router advertisement configuration
Display 1 "Create new $rtadvdconfigfile"
echo "##### rtadvd.conf made by Gateway6 Client ####" > "$rtadvdconfigfile"
echo "interface $TSP_HOME_INTERFACE" >> "$rtadvdconfigfile"
echo "{" >> "$rtadvdconfigfile"
echo " AdvSendAdvert on;" >> "$rtadvdconfigfile"
echo " prefix $TSP_PREFIX::/64" >> "$rtadvdconfigfile"
echo " {" >> "$rtadvdconfigfile"
echo " AdvOnLink on;" >> "$rtadvdconfigfile"
echo " AdvAutonomous on;" >> "$rtadvdconfigfile"
echo " };" >> "$rtadvdconfigfile"
echo "};" >> "$rtadvdconfigfile"
echo "" >> "$rtadvdconfigfile"
/etc/init.d/radvd stop
# Then enable forwarding. Killing
# radvd disables forwarding and radvd
# does NOT start without forwarding enabled
Exec $sysctl -w net.ipv6.conf.all.forwarding=1 # ipv6_forwarding enabled
if [ -f $rtadvdconfigfile ]; then
Exec $rtadvd -p $rtadvd_pid -C $rtadvdconfigfile
Display 1 "Starting radvd: $rtadvd -p $rtadvd_pid -C $rtadvdconfigfile"
else
echo "Error : file $rtadvdconfigfile not found"
exit 1
fi
fi
Display 1 "--- End of configuration script. ---"
exit 0
#---------------------------------------------------------------------