1 diff -Nur tspc-advanced.orig/platform/linux/tsp_local.c tspc-advanced.pld/platform/linux/tsp_local.c
2 --- tspc-advanced.orig/platform/linux/tsp_local.c 2007-12-12 13:44:35.000000000 -0700
3 +++ tspc-advanced.pld/platform/linux/tsp_local.c 2008-02-02 12:54:09.000000000 -0700
5 char *ScriptInterpretor = "/bin/sh";
6 char *ScriptExtension = "sh";
7 char *ScriptDir = NULL;
8 -char *TspHomeDir = "/usr/local/etc/gw6";
9 +char *TspHomeDir = "/etc/gw6";
10 char DirSeparator = '/';
13 diff -Nur tspc-advanced.orig/platform/linux/tsp_local.c.orig tspc-advanced.pld/platform/linux/tsp_local.c.orig
14 --- tspc-advanced.orig/platform/linux/tsp_local.c.orig 1969-12-31 17:00:00.000000000 -0700
15 +++ tspc-advanced.pld/platform/linux/tsp_local.c.orig 2008-02-02 12:53:41.000000000 -0700
18 +---------------------------------------------------------------------------
20 +---------------------------------------------------------------------------
21 +This source code copyright (c) Hexago Inc. 2002-2007.
23 + LICENSE NOTICE: You may use and modify this source code only if you
24 + have executed a valid license agreement with Hexago Inc. granting
25 + you the right to do so, the said license agreement governing such
26 + use and modifications. Copyright or other intellectual property
27 + notices are not to be removed from the source code.
28 +---------------------------------------------------------------------------
38 +#include <sys/types.h>
39 +#include <sys/wait.h>
40 +#include <sys/stat.h>
42 +#define _USES_SYS_SOCKET_H_
43 +#define _USES_ARPA_INET_H_
45 +#include "platform.h"
47 +#include "config.h" /* tConf */
48 +#include "xml_tun.h" /* tTunnel */
49 +#include "net.h" /* net_tools_t */
50 +#include "tsp_net.h" /* tspClose */
52 +#include "log.h" // Display
53 +#include "hex_strings.h" // Various string constants
54 +#include "errors.h" // Error codes.
56 +#include "tsp_tun.h" // linux tun support
57 +#include "tsp_client.h" // tspSetupInterfaceLocal()
58 +#include "tsp_setup.h" // tspSetupInterface()
59 +#include "tsp_tun_mgt.h" // tspPerformTunnelLoop()
61 +/* these globals are defined by US used by alot of things in */
63 +char *FileName = "gw6c.conf";
64 +char *ScriptInterpretor = "/bin/sh";
65 +char *ScriptExtension = "sh";
66 +char *ScriptDir = NULL;
67 +char *TspHomeDir = "/usr/local/etc/gw6";
68 +char DirSeparator = '/';
71 +int indSigHUP = 0; // Set to 1 when HUP signal is trapped.
74 +#include <gw6cmessaging/gw6cuistrings.h>
75 +// Dummy implementation for non-win32 targets
76 +// (Library gw6cmessaging is not linked in non-win32 targets).
77 +error_t send_status_info( void ) { return GW6CM_UIS__NOERROR; }
78 +error_t send_tunnel_info( void ) { return GW6CM_UIS__NOERROR; }
79 +error_t send_broker_list( void ) { return GW6CM_UIS__NOERROR; }
80 +error_t send_hap6_status_info( void ) { return GW6CM_UIS__NOERROR; }
83 +// --------------------------------------------------------------------------
84 +/* Verify for ipv6 support */
86 +static int tspTestIPv6Support()
89 + if(stat("/proc/net/if_inet6",&buf) == -1)
91 + Display(LOG_LEVEL_1,ELError,"tspTestIPv6Support",HEX_STR_NO_IPV6_SUPPORT_FOUND);
92 + Display(LOG_LEVEL_1,ELError,"tspTestIPv6Support",HEX_STR_TRY_MODPROBE_IPV6);
93 + return INTERFACE_SETUP_FAILED;
95 + Display(LOG_LEVEL_2,ELInfo,"tspTestIPv6Support",HEX_STR_IPV6_SUPPORT_FOUND);
101 +// --------------------------------------------------------------------------
102 +// linux specific to setup an env variable
104 +void tspSetEnv(char *Variable, char *Value, int Flag)
106 + setenv( Variable, Value, Flag );
107 + Display( LOG_LEVEL_3, ELInfo, "tspSetEnv", "%s=%s", Variable, Value );
110 +// --------------------------------------------------------------------------
111 +// Checks if the Gateway6 Client has been requested to stop and exit.
113 +// Returns 1 if Gateway6 Client is being requested to stop and exit.
114 +// Else, waits 'uiWaitMs' miliseconds and returns 0.
116 +// Defined in tsp_client.h
118 +int tspCheckForStopOrWait( const unsigned int uiWaitMs )
120 + // Sleep for the amount of time specified, if signal has not been sent.
121 + if( indSigHUP == 0 )
123 + // usleep is expecting microseconds (1 microsecond = 0.000001 second).
124 + usleep( uiWaitMs * 1000 );
131 +// --------------------------------------------------------------------------
132 +// Called from tsp_setup.c -> tspSetupInterface
133 +// Do extra platform-specific stuff before tunnel script is launched.
135 +int tspSetupInterfaceLocal( tConf* pConf, tTunnel* pTun )
141 +// --------------------------------------------------------------------------
142 +// Returns local address.
143 +// tspSetupTunnel() will callback here
145 +char* tspGetLocalAddress(int socket, char *buffer, int size)
147 + struct sockaddr_in6 addr; /* enough place for v4 and v6 */
148 + struct sockaddr_in *addr_v4 = (struct sockaddr_in *)&addr;
149 + struct sockaddr_in6 *addr_v6 = (struct sockaddr_in6 *)&addr;
153 + if (getsockname(socket, (struct sockaddr *)&addr, &len) < 0)
155 + Display(LOG_LEVEL_3, ELError, "TryServer", HEX_STR_ERR_FIND_SRC_IP);
159 + if (addr.sin6_family == AF_INET6)
160 + return (char *)inet_ntop(AF_INET6, (const void*) &addr_v6->sin6_addr, buffer, size);
162 + return (char *)inet_ntop(AF_INET, (const void*) &addr_v4->sin_addr, buffer, size);
165 +// --------------------------------------------------------------------------
166 +// Setup tunneling interface and any daemons
167 +// tspSetupTunnel() will callback here.
169 +int tspStartLocal(SOCKET socket, tConf *c, tTunnel *t, net_tools_t *nt)
171 + TUNNEL_LOOP_CONFIG tun_loop_cfg;
172 + int status = NO_ERROR;
173 + int keepalive_interval = 0;
175 + /* Test for root privileges */
178 + Display( LOG_LEVEL_1, ELError, "tspStartLocal", HEX_STR_FATAL_NOT_ROOT_FOR_TUN );
179 + return INTERFACE_SETUP_FAILED;
182 + /* Check Ipv6 support */
183 + Display( LOG_LEVEL_2, ELInfo, "tspStartLocal", HEX_STR_CHECKING_LINUX_IPV6_SUPPORT );
184 + if( tspTestIPv6Support() == INTERFACE_SETUP_FAILED )
186 + return INTERFACE_SETUP_FAILED;
189 + if (t->keepalive_interval != NULL)
191 + keepalive_interval = atoi( t->keepalive_interval );
192 + Display( LOG_LEVEL_3, ELInfo, "tspStartLocal", HEX_STR_KEEPALIVE_INTERVAL, t->keepalive_interval );
198 + Display( LOG_LEVEL_3, ELInfo, "tspStartLocal", HEX_STR_GOING_DAEMON );
199 + if( daemon(1,0) == -1 )
201 + Display( LOG_LEVEL_3, ELError, "tspStartLocal", HEX_STR_CANT_FORK );
202 + return INTERFACE_SETUP_FAILED;
205 + // Initialize TUN device, if using V6UDPV4 tunnel mode.
206 + if( strcasecmp(t->type, STR_CONFIG_TUNNELMODE_V6UDPV4) == 0 )
208 + tunfd = TunInit(c->if_tunnel_v6udpv4);
211 + Display( LOG_LEVEL_3, ELError, "tspStartLocal", HEX_STR_CANT_INIT_TUN_DEV );
212 + return INTERFACE_SETUP_FAILED;
215 + // V4V6 tunnel mode is not supported on this platform.
216 + else if( strcasecmp(t->type, STR_CONFIG_TUNNELMODE_V4V6) == 0 )
218 + Display( LOG_LEVEL_1, ELError, "tspStartLocal", HEX_STR_NO_V4V6_ON_PLATFORM );
219 + return(INTERFACE_SETUP_FAILED);
222 + /* Run the template script in a child process, and close socket.
224 + // This is important because otherwise the tunnnel will stay open even
225 + // if we get killed
232 + return INTERFACE_SETUP_FAILED;
239 + // Execute template script.
240 + if (tspSetupInterface(c, t) != 0)
241 + exit(INTERFACE_SETUP_FAILED);
243 + // Successfully executed template script.
251 + // Wait for child to exit.
252 + Display( LOG_LEVEL_3, ELInfo, "tspStartLocal", HEX_STR_WAITING_FOR_SETUP_SCRIPT );
253 + if( wait(&s) == pid )
255 + // ok our child returned
256 + if( !WIFEXITED(s) )
258 + Display( LOG_LEVEL_3, ELError, "tspStartLocal", HEX_STR_SCRIPT_FAILED );
259 + return INTERFACE_SETUP_FAILED;
262 + // Verify child exit code.
263 + if( WEXITSTATUS(s) != 0 )
265 + Display( LOG_LEVEL_3, ELError, "tspStartLocal", HEX_STR_SCRIPT_FAILED );
266 + return INTERFACE_SETUP_FAILED;
268 + // else everything is fine
272 + // Error occured: we have no other child
273 + Display( LOG_LEVEL_1, ELError, "tspStartLocal", HEX_STR_ERR_WAITING_SCRIPT );
274 + return INTERFACE_SETUP_FAILED;
279 + if( strcasecmp(t->type, STR_CONFIG_TUNNELMODE_V6UDPV4) == 0 )
281 + status = TunMainLoop( tunfd, socket, c->keepalive,
282 + keepalive_interval, t->client_address_ipv6,
283 + t->keepalive_address);
285 + /* We got out of V6UDPV4 "TUN" tunnel loop */
287 + tspClose(socket, nt);
289 + else if( strcasecmp(t->type, STR_CONFIG_TUNNELMODE_V6V4) == 0 )
291 + memset( &tun_loop_cfg, 0x00, sizeof(TUNNEL_LOOP_CONFIG) );
292 + tun_loop_cfg.ka_interval = keepalive_interval;
293 + tun_loop_cfg.ka_src_addr = t->client_address_ipv6;
294 + tun_loop_cfg.ka_dst_addr = t->keepalive_address;
295 + tun_loop_cfg.sa_family = AF_INET6;
296 + tun_loop_cfg.tun_lifetime = 0;
298 + status = tspPerformTunnelLoop( &tun_loop_cfg );
303 + // Handle tunnel teardown.
304 + if( tspTearDownTunnel( c, t ) != 0 )
307 + Display( LOG_LEVEL_2, ELError, "tspStartLocal", HEX_STR_SCRIPT_FAILED );
312 diff -Nur tspc-advanced.orig/template/linux.sh tspc-advanced.pld/template/linux.sh
313 --- tspc-advanced.orig/template/linux.sh 2007-12-07 12:23:10.000000000 -0700
314 +++ tspc-advanced.pld/template/linux.sh 2008-02-02 14:27:30.000000000 -0700
316 Display 1 "--- Start of configuration script. ---"
317 Display 1 "Script: " `basename $0`
319 -ifconfig=/sbin/ifconfig
322 rtadvd=/usr/sbin/radvd
326 # Remove address from TSP HOME INTERFACE
327 - ExecNoCheck $ifconfig $TSP_HOME_INTERFACE inet6 del $TSP_PREFIX::1/64
328 + ExecNoCheck $ipconfig address add $TSP_PREFIX::1/64 dev $TSP_HOME_INTERFACE
331 # Delete default IPv6 route(s).
332 @@ -141,18 +140,18 @@
333 ExecNoCheck $ipconfig tunnel del $TSP_TUNNEL_INTERFACE
335 # Check if interface exists and remove it
336 - $ifconfig $TSP_TUNNEL_INTERFACE >/dev/null 2>/dev/null
337 + $ipconfig link show $TSP_TUNNEL_INTERFACE >/dev/null 2>/dev/null
338 if [ $? -eq 0 ]; then
340 Delete interface IPv6 configuration.
341 PREF=`echo $TSP_CLIENT_ADDRESS_IPV6 | sed "s/:0*/:/g" |cut -d : -f1-2`
342 - OLDADDR=`$ifconfig $TSP_TUNNEL_INTERFACE | grep "inet6.* $PREF" | sed -e "s/^.*inet6 addr: //" -e "s/ Scope.*\$//"`
343 + OLDADDR=`$ipconfig addr show dev $TSP_TUNNEL_INTERFACE | grep "inet6.* $PREF" | sed -e "s/^.*inet6 //" -e "s/ scope.*\$//"`
344 if [ ! -z $OLDADDR ]; then
345 - ExecNoCheck $ifconfig $TSP_TUNNEL_INTERFACE inet6 del $OLDADDR
346 + ExecNoCheck $ipconfig addr del $OLDADDR dev $TSP_TUNNEL_INTERFACE
349 # Bring interface down
350 - ExecNoCheck $ifconfig $TSP_TUNNEL_INTERFACE down
351 + ExecNoCheck $ipconfig link set $TSP_TUNNEL_INTERFACE down
355 @@ -176,24 +175,25 @@
356 ExecNoCheck $ipconfig tunnel del $TSP_TUNNEL_INTERFACE
358 Exec $ipconfig tunnel add $TSP_TUNNEL_INTERFACE mode sit ttl 64 remote $TSP_SERVER_ADDRESS_IPV4
359 + Exec $ipconfig link set $TSP_TUNNEL_INTERFACE up
361 Exec $ifconfig $TSP_TUNNEL_INTERFACE tunnel ::$TSP_SERVER_ADDRESS_IPV4
362 + Exec $ifconfig $TSP_TUNNEL_INTERFACE up
366 - Exec $ifconfig $TSP_TUNNEL_INTERFACE up
368 # Clean-up old interface IPv6 configuration.
369 PREF=`echo $TSP_CLIENT_ADDRESS_IPV6 | sed "s/:0*/:/g" |cut -d : -f1-2`
370 - OLDADDR=`$ifconfig $TSP_TUNNEL_INTERFACE | grep "inet6.* $PREF" | sed -e "s/^.*inet6 addr: //" -e "s/ Scope.*\$//"`
371 + OLDADDR=`$ipconfig address show dev $TSP_TUNNEL_INTERFACE | grep "inet6.* $PREF" | sed -e "s/^.*inet6 //" -e "s/ scope.*\$//"`
372 if [ ! -z $OLDADDR ]; then
373 Display 1 "Removing old IPv6 address $OLDADDR"
374 - Exec $ifconfig $TSP_TUNNEL_INTERFACE inet6 del $OLDADDR
375 + Exec $ipconfig address del $OLDADDR dev $TSP_TUNNEL_INTERFACE
378 Display 1 "This host is: $TSP_CLIENT_ADDRESS_IPV6/$TSP_TUNNEL_PREFIXLEN"
379 - Exec $ifconfig $TSP_TUNNEL_INTERFACE add $TSP_CLIENT_ADDRESS_IPV6/$TSP_TUNNEL_PREFIXLEN
380 - Exec $ifconfig $TSP_TUNNEL_INTERFACE mtu 1280
381 + Exec $ipconfig address add $TSP_CLIENT_ADDRESS_IPV6/$TSP_TUNNEL_PREFIXLEN dev $TSP_TUNNEL_INTERFACE
382 + Exec $ipconfig link set $TSP_TUNNEL_INTERFACE mtu 1280
386 @@ -219,13 +219,13 @@
389 # Add prefix::1 on advertising interface. Clean up before.
390 - OLDADDR=`$ifconfig $TSP_HOME_INTERFACE | grep "inet6.* $PREF" | sed -e "s/^.*inet6 addr: //" -e "s/ Scope.*\$//"`
391 + OLDADDR=`$ipconfig $TSP_HOME_INTERFACE | grep "inet6.* $PREF" | sed -e "s/^.*inet6 //" -e "s/ scope.*\$//"`
392 if [ ! -z $OLDADDR ]; then
393 Display 1 "Removing old IPv6 address $OLDADDR"
394 - Exec $ifconfig $TSP_HOME_INTERFACE inet6 del $OLDADDR
395 + Exec $ipconfig address del $OLDADDR dev $TSP_HOME_INTERFACE
397 Display 1 "Adding prefix to $TSP_HOME_INTERFACE"
398 - Exec $ifconfig $TSP_HOME_INTERFACE add $TSP_PREFIX::1/64
399 + Exec $ipconfig address add $TSP_PREFIX::1/64 dev $TSP_HOME_INTERFACE
402 # Stop radvd daemon if it was running. Twice.
403 diff -Nur tspc-advanced.orig/template/linux.sh.orig tspc-advanced.pld/template/linux.sh.orig
404 --- tspc-advanced.orig/template/linux.sh.orig 1969-12-31 17:00:00.000000000 -0700
405 +++ tspc-advanced.pld/template/linux.sh.orig 2008-02-02 12:53:45.000000000 -0700
411 +# This source code copyright (c) Hexago Inc. 2002-2006.
413 +# LICENSE NOTICE: You may use and modify this source code only if you
414 +# have executed a valid license agreement with Hexago Inc. granting
415 +# you the right to do so, the said license agreement governing such
416 +# use and modifications. Copyright or other intellectual property
417 +# notices are not to be removed from the source code.
419 +# Note: IPV6 support and tun Support must be enabled before calling this script.
425 +if [ -z $TSP_VERBOSE ]; then
431 + if [ ! -z $TSP_VERBOSE ]; then
432 + if [ $TSP_VERBOSE -ge 2 ]; then
436 + PID=`ps axww | grep $1 | grep -v grep | awk '{ print $1;}'`
438 + if [ ! -z $PID ]; then
445 + if [ -z $TSP_VERBOSE ]; then
448 + if [ $TSP_VERBOSE -lt $1 ]; then
457 + if [ ! -z $TSP_VERBOSE ]; then
458 + if [ $TSP_VERBOSE -ge 2 ]; then
462 + $* # Execute command
463 + if [ $? -ne 0 ]; then
464 + echo "Error while executing $1"
465 + echo " Command: $*"
472 + if [ ! -z $TSP_VERBOSE ]; then
473 + if [ $TSP_VERBOSE -ge 2 ]; then
477 + $* # Execute command
480 +# Program localization
482 +Display 1 "--- Start of configuration script. ---"
483 +Display 1 "Script: " `basename $0`
485 +ifconfig=/sbin/ifconfig
488 +rtadvd=/usr/sbin/radvd
489 +rtadvd_pid=/var/run/radvd/radvd.pid
491 +rtadvdconfigfilename=gw6c-rtadvd.conf
492 +rtadvdconfigfile=$TSP_HOME_DIR/$rtadvdconfigfilename
494 +if [ -z $TSP_HOME_DIR ]; then
495 + echo "TSP_HOME_DIR variable not specified!;"
499 +if [ ! -d $TSP_HOME_DIR ]; then
500 + echo "Error : directory $TSP_HOME_DIR does not exist"
505 +if [ -z $TSP_HOST_TYPE ]; then
506 + echo Error: TSP_HOST_TYPE not defined.
511 +#############################################################################
512 +# Tunnel destruction script.
514 +# Is invoked by the Gateway6 Client on shutdown when it receives the
515 +# SIGHUP signal. Use "kill -HUP <gw6c pid>".
517 +if [ X"${TSP_OPERATION}" = X"TSP_TUNNEL_TEARDOWN" ]; then
519 + Display 1 Tunnel tear down starting...
522 + # Router deconfiguration.
523 + if [ X"${TSP_HOST_TYPE}" = X"router" ]; then
525 + # Kill router advertisement daemon
526 + KillProcess $rtadvdconfigfile
528 + # Remove prefix routing on TSP_HOME_INTERFACE
529 + ExecNoCheck $route -A inet6 del $TSP_PREFIX::/$TSP_PREFIXLEN
531 + # Remove Blackhole.
532 + if [ X"${TSP_PREFIXLEN}" != X"64" ]; then
533 + ExecNoCheck $route -A inet6 del $TSP_PREFIX::/$TSP_PREFIXLEN dev lo
536 + # Remove address from TSP HOME INTERFACE
537 + ExecNoCheck $ifconfig $TSP_HOME_INTERFACE inet6 del $TSP_PREFIX::1/64
540 + # Delete default IPv6 route(s).
541 + ExecNoCheck $route -A inet6 del ::/0 2>/dev/null # delete default route
542 + ExecNoCheck $route -A inet6 del 2000::/3 2>/dev/null # delete gw route
544 + # Destroy tunnel interface
545 + if [ -x $ipconfig ]; then
546 + # Delete tunnel via ipconfig
547 + ExecNoCheck $ipconfig tunnel del $TSP_TUNNEL_INTERFACE
549 + # Check if interface exists and remove it
550 + $ifconfig $TSP_TUNNEL_INTERFACE >/dev/null 2>/dev/null
551 + if [ $? -eq 0 ]; then
553 + Delete interface IPv6 configuration.
554 + PREF=`echo $TSP_CLIENT_ADDRESS_IPV6 | sed "s/:0*/:/g" |cut -d : -f1-2`
555 + OLDADDR=`$ifconfig $TSP_TUNNEL_INTERFACE | grep "inet6.* $PREF" | sed -e "s/^.*inet6 addr: //" -e "s/ Scope.*\$//"`
556 + if [ ! -z $OLDADDR ]; then
557 + ExecNoCheck $ifconfig $TSP_TUNNEL_INTERFACE inet6 del $OLDADDR
560 + # Bring interface down
561 + ExecNoCheck $ifconfig $TSP_TUNNEL_INTERFACE down
566 + Display 1 Tunnel tear down completed.
572 +#############################################################################
573 +# Tunnel creation script.
575 +if [ X"${TSP_HOST_TYPE}" = X"host" ] || [ X"${TSP_HOST_TYPE}" = X"router" ]; then
577 + # Set tunnel IPv6 configuration
578 + Display 1 "$TSP_TUNNEL_INTERFACE setup"
579 + if [ X"${TSP_TUNNEL_MODE}" = X"v6v4" ]; then
580 + Display 1 "Setting up link to $TSP_SERVER_ADDRESS_IPV4"
581 + if [ -x $ipconfig ]; then
582 + ExecNoCheck $ipconfig tunnel del $TSP_TUNNEL_INTERFACE
583 + ExecNoCheck sleep 1
584 + Exec $ipconfig tunnel add $TSP_TUNNEL_INTERFACE mode sit ttl 64 remote $TSP_SERVER_ADDRESS_IPV4
586 + Exec $ifconfig $TSP_TUNNEL_INTERFACE tunnel ::$TSP_SERVER_ADDRESS_IPV4
590 + Exec $ifconfig $TSP_TUNNEL_INTERFACE up
592 + # Clean-up old interface IPv6 configuration.
593 + PREF=`echo $TSP_CLIENT_ADDRESS_IPV6 | sed "s/:0*/:/g" |cut -d : -f1-2`
594 + OLDADDR=`$ifconfig $TSP_TUNNEL_INTERFACE | grep "inet6.* $PREF" | sed -e "s/^.*inet6 addr: //" -e "s/ Scope.*\$//"`
595 + if [ ! -z $OLDADDR ]; then
596 + Display 1 "Removing old IPv6 address $OLDADDR"
597 + Exec $ifconfig $TSP_TUNNEL_INTERFACE inet6 del $OLDADDR
600 + Display 1 "This host is: $TSP_CLIENT_ADDRESS_IPV6/$TSP_TUNNEL_PREFIXLEN"
601 + Exec $ifconfig $TSP_TUNNEL_INTERFACE add $TSP_CLIENT_ADDRESS_IPV6/$TSP_TUNNEL_PREFIXLEN
602 + Exec $ifconfig $TSP_TUNNEL_INTERFACE mtu 1280
606 + Display 1 "Adding default route"
607 + ExecNoCheck $route -A inet6 del ::/0 2>/dev/null # delete old default route
608 + ExecNoCheck $route -A inet6 del 2000::/3 2>/dev/null # delete old gw route
609 + Exec $route -A inet6 add ::/0 dev $TSP_TUNNEL_INTERFACE
610 + Exec $route -A inet6 add 2000::/3 dev $TSP_TUNNEL_INTERFACE
613 +# Router configuration if required
614 +if [ X"${TSP_HOST_TYPE}" = X"router" ]; then
616 + Display 1 "Router configuration"
618 + # Tell kernel to forward IPv6 traffic.
619 + Exec $sysctl -w net.ipv6.conf.all.forwarding=1
621 + # Blackholing on interface lo, if prefixlen is not 64.
622 + if [ X"${TSP_PREFIXLEN}" != X"64" ]; then
623 + # Sometimes this route does not show when using 'netstat -rn6'.
624 + ExecNoCheck $route -A inet6 add $TSP_PREFIX::/$TSP_PREFIXLEN dev lo 2>/dev/null
627 + # Add prefix::1 on advertising interface. Clean up before.
628 + OLDADDR=`$ifconfig $TSP_HOME_INTERFACE | grep "inet6.* $PREF" | sed -e "s/^.*inet6 addr: //" -e "s/ Scope.*\$//"`
629 + if [ ! -z $OLDADDR ]; then
630 + Display 1 "Removing old IPv6 address $OLDADDR"
631 + Exec $ifconfig $TSP_HOME_INTERFACE inet6 del $OLDADDR
633 + Display 1 "Adding prefix to $TSP_HOME_INTERFACE"
634 + Exec $ifconfig $TSP_HOME_INTERFACE add $TSP_PREFIX::1/64
637 + # Stop radvd daemon if it was running. Twice.
638 + /etc/init.d/radvd stop
639 + if [ -f $rtadvdconfigfile ]; then
640 + KillProcess $rtadvdconfigfile
643 + # Create new radvd configuration file.
644 + cat > "$rtadvdconfigfile" <<EOF
645 +##### rtadvd.conf made by Gateway6 Client ####
646 +interface $TSP_HOME_INTERFACE
649 + prefix $TSP_PREFIX::/64
657 + # Start the radvd daemon.
658 + Display 1 "Starting radvd: $rtadvd -u radvd -C $rtadvdconfigfile"
659 + Exec $rtadvd -u radvd -p $rtadvd_pid -C $rtadvdconfigfile
662 +Display 1 "--- End of configuration script. ---"
666 +#---------------------------------------------------------------------
667 diff -Nur tspc-advanced.orig/template/linux.sh.rej tspc-advanced.pld/template/linux.sh.rej
668 --- tspc-advanced.orig/template/linux.sh.rej 1969-12-31 17:00:00.000000000 -0700
669 +++ tspc-advanced.pld/template/linux.sh.rej 2008-02-02 12:54:10.000000000 -0700
673 + Display 1 "$TSP_TUNNEL_INTERFACE setup"
674 + if [ X"${TSP_TUNNEL_MODE}" = X"v6v4" ]; then
675 + Display 1 "Setting up link to $TSP_SERVER_ADDRESS_IPV4"
676 +- if [ -x $ipconfig ]; then
677 + ExecNoCheck $ipconfig tunnel del $TSP_TUNNEL_INTERFACE
678 + ExecNoCheck sleep 1
679 + Exec $ipconfig tunnel add $TSP_TUNNEL_INTERFACE mode sit ttl 64 remote $TSP_SERVER_ADDRESS_IPV4
681 +- Exec $ifconfig $TSP_TUNNEL_INTERFACE tunnel ::$TSP_SERVER_ADDRESS_IPV4
685 +- Exec $ifconfig $TSP_TUNNEL_INTERFACE up
687 + PREF=`echo $TSP_CLIENT_ADDRESS_IPV6 | sed "s/:0*/:/g" |cut -d : -f1-2`
688 +- OLDADDR=`$ifconfig $TSP_TUNNEL_INTERFACE | grep "inet6.* $PREF" | sed -e "s/^.*inet6 addr: //" -e "s/ Scope.*\$//"`
689 + if [ ! -z $OLDADDR ]; then
690 + Display 1 "Removing old IPv6 address $OLDADDR"
691 +- Exec $ifconfig $TSP_TUNNEL_INTERFACE inet6 del $OLDADDR
693 + Display 1 "This host is: $TSP_CLIENT_ADDRESS_IPV6/$TSP_TUNNEL_PREFIXLEN"
694 +- Exec $ifconfig $TSP_TUNNEL_INTERFACE add $TSP_CLIENT_ADDRESS_IPV6/$TSP_TUNNEL_PREFIXLEN
695 +- Exec $ifconfig $TSP_TUNNEL_INTERFACE mtu 1280
698 + Display 1 "Adding default route"
699 +- ExecNoCheck $route -A inet6 del ::/0 2>/dev/null # delete old default route
700 +- ExecNoCheck $route -A inet6 del 2000::/3 2>/dev/null # delete old gw route
701 +- Exec $route -A inet6 add ::/0 dev $TSP_TUNNEL_INTERFACE
702 +- Exec $route -A inet6 add 2000::/3 dev $TSP_TUNNEL_INTERFACE
705 + # Router configuration if required
707 + Display 1 "$TSP_TUNNEL_INTERFACE setup"
708 + if [ X"${TSP_TUNNEL_MODE}" = X"v6v4" ]; then
709 + Display 1 "Setting up link to $TSP_SERVER_ADDRESS_IPV4"
710 + ExecNoCheck $ipconfig tunnel del $TSP_TUNNEL_INTERFACE
711 + ExecNoCheck sleep 1
712 + Exec $ipconfig tunnel add $TSP_TUNNEL_INTERFACE mode sit ttl 64 remote $TSP_SERVER_ADDRESS_IPV4
715 ++ Exec $ipconfig link set $TSP_TUNNEL_INTERFACE up
717 + PREF=`echo $TSP_CLIENT_ADDRESS_IPV6 | sed "s/:0*/:/g" |cut -d : -f1-2`
718 ++ OLDADDR=`$ipconfig addr show dev $TSP_TUNNEL_INTERFACE | grep "inet6.* $PREF" | sed -e "s/^.*inet6 addr: //" -e "s/ Scope.*\$//"`
719 + if [ ! -z $OLDADDR ]; then
720 + Display 1 "Removing old IPv6 address $OLDADDR"
721 ++ Exec $ipconfig addr del $OLDADDR dev $TSP_TUNNEL_INTERFACE
723 + Display 1 "This host is: $TSP_CLIENT_ADDRESS_IPV6/$TSP_TUNNEL_PREFIXLEN"
724 ++ Exec $ipconfig addr add $TSP_CLIENT_ADDRESS_IPV6/$TSP_TUNNEL_PREFIXLEN dev $TSP_TUNNEL_INTERFACE
725 ++ Exec $ipconfig link set $TSP_TUNNEL_INTERFACE mtu 1280
728 + Display 1 "Adding default route"
729 ++ ExecNoCheck $ipconfig -6 route add del ::/0 2>/dev/null # delete old default route
730 ++ ExecNoCheck $ipconfig -6 route del 2000::/3 2>/dev/null # delete old gw route
731 ++ Exec $ipconfig -6 route add ::/0 dev $TSP_TUNNEL_INTERFACE
732 ++ Exec $ipconfig -6 route add 2000::/3 dev $TSP_TUNNEL_INTERFACE
735 + # Router configuration if required
739 + Exec $sysctl -w net.ipv6.conf.all.forwarding=1 # ipv6_forwarding enabled
740 + Display 1 "Adding prefix to $TSP_HOME_INTERFACE"
741 +- OLDADDR=`$ifconfig $TSP_HOME_INTERFACE | grep "inet6.* $PREF" | sed -e "s/^.*inet6 addr: //" -e "s/ Scope.*\$//"`
742 + if [ ! -z $OLDADDR ]; then
743 + Display 1 "Removing old IPv6 address $OLDADDR"
744 +- Exec $ifconfig $TSP_HOME_INTERFACE inet6 del $OLDADDR
746 +- Exec $ifconfig $TSP_HOME_INTERFACE add $TSP_PREFIX::1/64
747 + # Router advertisement configuration
748 + Display 1 "Create new $rtadvdconfigfile"
749 + echo "##### rtadvd.conf made by Gateway6 Client ####" > "$rtadvdconfigfile"
752 + Exec $sysctl -w net.ipv6.conf.all.forwarding=1 # ipv6_forwarding enabled
753 + Display 1 "Adding prefix to $TSP_HOME_INTERFACE"
754 ++ OLDADDR=`$ipconfig addr show dev $TSP_HOME_INTERFACE | grep "inet6.* $PREF" | sed -e "s/^.*inet6 addr: //" -e "s/ Scope.*\$//"`
755 + if [ ! -z $OLDADDR ]; then
756 + Display 1 "Removing old IPv6 address $OLDADDR"
757 ++ Exec $ipconfig addr del $OLDADDR dev $TSP_HOME_INTERFACE
759 ++ Exec $ipconfig addr add $TSP_PREFIX::1/64 dev $TSP_HOME_INTERFACE
760 + # Router advertisement configuration
761 + Display 1 "Create new $rtadvdconfigfile"
762 + echo "##### rtadvd.conf made by Gateway6 Client ####" > "$rtadvdconfigfile"