]> git.pld-linux.org Git - packages/freenet6-client.git/blob - freenet6-client-pld.patch
- BR: libstdc++-devel
[packages/freenet6-client.git] / freenet6-client-pld.patch
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
4 @@ -48,7 +48,7 @@
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 = '/';
11  
12  int RootUid = 0;
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
16 @@ -0,0 +1,295 @@
17 +/*
18 +---------------------------------------------------------------------------
19 + $Id$
20 +---------------------------------------------------------------------------
21 +This source code copyright (c) Hexago Inc. 2002-2007.
22 +
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 +---------------------------------------------------------------------------
29 +*/
30 +
31 +/* LINUX */
32 +
33 +#include <stdio.h>
34 +#include <stdlib.h>
35 +#include <unistd.h>
36 +#include <string.h>
37 +
38 +#include <sys/types.h>
39 +#include <sys/wait.h>
40 +#include <sys/stat.h>
41 +
42 +#define _USES_SYS_SOCKET_H_
43 +#define _USES_ARPA_INET_H_
44 +
45 +#include "platform.h"
46 +
47 +#include "config.h"         /* tConf */
48 +#include "xml_tun.h"        /* tTunnel */
49 +#include "net.h"            /* net_tools_t */
50 +#include "tsp_net.h"        /* tspClose */
51 +
52 +#include "log.h"            // Display
53 +#include "hex_strings.h"    // Various string constants
54 +#include "errors.h"         // Error codes.
55 +
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()
60 +
61 +/* these globals are defined by US used by alot of things in  */
62 +
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 = '/';
69 +
70 +int RootUid = 0;
71 +int indSigHUP = 0;    // Set to 1 when HUP signal is trapped.
72 +
73 +
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; }
81 +
82 +
83 +// --------------------------------------------------------------------------
84 +/* Verify for ipv6 support */
85 +//
86 +static int tspTestIPv6Support()
87 +{
88 +  struct stat buf;
89 +  if(stat("/proc/net/if_inet6",&buf) == -1)
90 +  {
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;
94 +  }
95 +  Display(LOG_LEVEL_2,ELInfo,"tspTestIPv6Support",HEX_STR_IPV6_SUPPORT_FOUND);
96 +
97 +  return NO_ERROR;
98 +}
99 +
100 +
101 +// --------------------------------------------------------------------------
102 +// linux specific to setup an env variable
103 +//
104 +void tspSetEnv(char *Variable, char *Value, int Flag)
105 +{
106 +  setenv( Variable, Value, Flag );
107 +  Display( LOG_LEVEL_3, ELInfo, "tspSetEnv", "%s=%s", Variable, Value );
108 +}
109 +
110 +// --------------------------------------------------------------------------
111 +// Checks if the Gateway6 Client has been requested to stop and exit.
112 +//
113 +// Returns 1 if Gateway6 Client is being requested to stop and exit.
114 +// Else, waits 'uiWaitMs' miliseconds and returns 0.
115 +//
116 +// Defined in tsp_client.h
117 +//
118 +int tspCheckForStopOrWait( const unsigned int uiWaitMs )
119 +{
120 +  // Sleep for the amount of time specified, if signal has not been sent.
121 +  if( indSigHUP == 0 )
122 +  {
123 +    // usleep is expecting microseconds (1 microsecond = 0.000001 second).
124 +    usleep( uiWaitMs * 1000 );
125 +  }
126 +
127 +  return indSigHUP;
128 +}
129 +
130 +
131 +// --------------------------------------------------------------------------
132 +// Called from tsp_setup.c -> tspSetupInterface
133 +//   Do extra platform-specific stuff before tunnel script is launched.
134 +//
135 +int tspSetupInterfaceLocal( tConf* pConf, tTunnel* pTun )
136 +{
137 +  return 0;
138 +}
139 +
140 +
141 +// --------------------------------------------------------------------------
142 +// Returns local address.
143 +// tspSetupTunnel() will callback here
144 +//
145 +char* tspGetLocalAddress(int socket, char *buffer, int size)
146 +{
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;
150 +  socklen_t len;
151 +
152 +  len = sizeof addr;
153 +  if (getsockname(socket, (struct sockaddr *)&addr, &len) < 0)
154 +  {
155 +    Display(LOG_LEVEL_3, ELError, "TryServer", HEX_STR_ERR_FIND_SRC_IP);
156 +    return NULL;
157 +  }
158 +
159 +  if (addr.sin6_family == AF_INET6)
160 +    return (char *)inet_ntop(AF_INET6, (const void*) &addr_v6->sin6_addr, buffer, size);
161 +  else
162 +    return (char *)inet_ntop(AF_INET, (const void*) &addr_v4->sin_addr, buffer, size);
163 +}
164 +
165 +// --------------------------------------------------------------------------
166 +// Setup tunneling interface and any daemons
167 +// tspSetupTunnel() will callback here.
168 +//
169 +int tspStartLocal(SOCKET socket, tConf *c, tTunnel *t, net_tools_t *nt)
170 +{
171 +  TUNNEL_LOOP_CONFIG tun_loop_cfg;
172 +  int status = NO_ERROR;
173 +  int keepalive_interval = 0;
174 +
175 +  /* Test for root privileges */
176 +  if(geteuid() != 0)
177 +  {
178 +    Display( LOG_LEVEL_1, ELError, "tspStartLocal", HEX_STR_FATAL_NOT_ROOT_FOR_TUN );
179 +    return INTERFACE_SETUP_FAILED;
180 +  }
181 +
182 +  /* Check Ipv6 support */
183 +  Display( LOG_LEVEL_2, ELInfo, "tspStartLocal", HEX_STR_CHECKING_LINUX_IPV6_SUPPORT );
184 +  if( tspTestIPv6Support() == INTERFACE_SETUP_FAILED )
185 +  {
186 +    return INTERFACE_SETUP_FAILED;
187 +  }
188 +
189 +  if (t->keepalive_interval != NULL)
190 +  {
191 +    keepalive_interval = atoi( t->keepalive_interval );
192 +    Display( LOG_LEVEL_3, ELInfo, "tspStartLocal", HEX_STR_KEEPALIVE_INTERVAL, t->keepalive_interval );
193 +  }
194 +  {
195 +    int tunfd = (-1);
196 +
197 +    // Daemonize!
198 +    Display( LOG_LEVEL_3, ELInfo, "tspStartLocal", HEX_STR_GOING_DAEMON );
199 +    if( daemon(1,0) == -1 )
200 +    {
201 +      Display( LOG_LEVEL_3, ELError, "tspStartLocal", HEX_STR_CANT_FORK );
202 +      return INTERFACE_SETUP_FAILED;
203 +    }
204 +
205 +    // Initialize TUN device, if using V6UDPV4 tunnel mode.
206 +    if( strcasecmp(t->type, STR_CONFIG_TUNNELMODE_V6UDPV4) == 0 )
207 +    {
208 +      tunfd = TunInit(c->if_tunnel_v6udpv4);
209 +      if( tunfd == -1 )
210 +      {
211 +        Display( LOG_LEVEL_3, ELError, "tspStartLocal", HEX_STR_CANT_INIT_TUN_DEV );
212 +        return INTERFACE_SETUP_FAILED;
213 +      }
214 +    }
215 +    // V4V6 tunnel mode is not supported on this platform.
216 +    else if( strcasecmp(t->type, STR_CONFIG_TUNNELMODE_V4V6) == 0 )
217 +    {
218 +      Display( LOG_LEVEL_1, ELError, "tspStartLocal", HEX_STR_NO_V4V6_ON_PLATFORM );
219 +      return(INTERFACE_SETUP_FAILED);
220 +    }
221 +
222 +    /* Run the template script in a child process, and close socket.
223 +    //
224 +    // This is important because otherwise the tunnnel will stay open even
225 +    // if we get killed
226 +    */
227 +    {
228 +      int pid = fork();
229 +      if( pid < 0 )
230 +      {
231 +        // fork() error
232 +        return INTERFACE_SETUP_FAILED;
233 +      }
234 +      else if (pid == 0)
235 +      {
236 +        // Child process:
237 +        close(tunfd);
238 +
239 +        // Execute template script.
240 +        if (tspSetupInterface(c, t) != 0)
241 +          exit(INTERFACE_SETUP_FAILED);
242 +
243 +        // Successfully executed template script.
244 +        exit(0);
245 +      }
246 +      else
247 +      {
248 +        // Parent process
249 +        int s = 0;
250 +
251 +        // Wait for child to exit.
252 +        Display( LOG_LEVEL_3, ELInfo, "tspStartLocal", HEX_STR_WAITING_FOR_SETUP_SCRIPT );
253 +        if( wait(&s) == pid )
254 +        {
255 +          // ok our child returned
256 +          if( !WIFEXITED(s) )
257 +          {
258 +            Display( LOG_LEVEL_3, ELError, "tspStartLocal", HEX_STR_SCRIPT_FAILED );
259 +            return INTERFACE_SETUP_FAILED;
260 +          }
261 +
262 +          // Verify child exit code.
263 +          if( WEXITSTATUS(s) != 0 )
264 +          {
265 +            Display( LOG_LEVEL_3, ELError, "tspStartLocal", HEX_STR_SCRIPT_FAILED );
266 +            return INTERFACE_SETUP_FAILED;
267 +          }
268 +          // else everything is fine
269 +        }
270 +        else
271 +        {
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;
275 +        }
276 +      }
277 +    }
278 +
279 +    if( strcasecmp(t->type, STR_CONFIG_TUNNELMODE_V6UDPV4) == 0 )
280 +    {
281 +      status = TunMainLoop( tunfd, socket, c->keepalive,
282 +                            keepalive_interval, t->client_address_ipv6,
283 +                            t->keepalive_address);
284 +
285 +      /* We got out of V6UDPV4 "TUN" tunnel loop */
286 +      close(tunfd);
287 +      tspClose(socket, nt);
288 +    }
289 +    else if( strcasecmp(t->type, STR_CONFIG_TUNNELMODE_V6V4) == 0 )
290 +    {
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;
297 +
298 +      status = tspPerformTunnelLoop( &tun_loop_cfg );
299 +    }
300 +  }
301 +
302 +
303 +  // Handle tunnel teardown.
304 +  if( tspTearDownTunnel( c, t ) != 0 )
305 +  {
306 +    // Log the error.
307 +    Display( LOG_LEVEL_2, ELError, "tspStartLocal", HEX_STR_SCRIPT_FAILED );
308 +  }
309 +
310 +  return status;
311 +}
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
315 @@ -76,7 +76,6 @@
316  Display 1 "--- Start of configuration script. ---"
317  Display 1 "Script: " `basename $0`
318  
319 -ifconfig=/sbin/ifconfig
320  route=/sbin/route
321  ipconfig=/sbin/ip
322  rtadvd=/usr/sbin/radvd
323 @@ -128,7 +127,7 @@
324      fi
325  
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
329    fi
330  
331    # Delete default IPv6 route(s).
332 @@ -141,18 +140,18 @@
333      ExecNoCheck $ipconfig tunnel del $TSP_TUNNEL_INTERFACE
334    else  
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
339  
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
347        fi
348  
349        # Bring interface down
350 -      ExecNoCheck $ifconfig $TSP_TUNNEL_INTERFACE down
351 +      ExecNoCheck $ipconfig link set $TSP_TUNNEL_INTERFACE down
352      fi
353    fi
354    
355 @@ -176,24 +175,25 @@
356          ExecNoCheck $ipconfig tunnel del $TSP_TUNNEL_INTERFACE
357          ExecNoCheck sleep 1
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
360        else
361           Exec $ifconfig $TSP_TUNNEL_INTERFACE tunnel ::$TSP_SERVER_ADDRESS_IPV4
362 +                                Exec $ifconfig $TSP_TUNNEL_INTERFACE up
363        fi
364     fi
365  
366 -   Exec $ifconfig $TSP_TUNNEL_INTERFACE up
367  
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
376     fi
377  
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
383  
384     # 
385     # Default route  
386 @@ -219,13 +219,13 @@
387     fi
388  
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 
396     fi
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
400  
401  
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
406 @@ -0,0 +1,260 @@
407 +#!/bin/sh
408 +#
409 +# $Id$
410 +#
411 +# This source code copyright (c) Hexago Inc. 2002-2006.
412 +#
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.
418 +#
419 +# Note: IPV6 support and tun Support must be enabled before calling this script.
420 +# 
421 +
422 +
423 +LANGUAGE=C
424 +
425 +if [ -z $TSP_VERBOSE ]; then
426 +   TSP_VERBOSE=0
427 +fi
428 +
429 +KillProcess()
430 +{
431 +   if [ ! -z $TSP_VERBOSE ]; then
432 +      if [ $TSP_VERBOSE -ge 2 ]; then
433 +         echo killing $*
434 +      fi
435 +   fi
436 +   PID=`ps axww | grep $1 | grep -v grep | awk '{ print $1;}'`
437 +   echo $PID
438 +   if [ ! -z $PID ]; then
439 +      kill $PID
440 +   fi
441 +}
442 +
443 +Display()
444 +{
445 +   if [ -z $TSP_VERBOSE ]; then
446 +      return;
447 +   fi
448 +   if [ $TSP_VERBOSE -lt $1 ]; then
449 +      return;
450 +   fi
451 +   shift
452 +   echo "$*"
453 +}
454 +
455 +Exec()
456 +{
457 +   if [ ! -z $TSP_VERBOSE ]; then
458 +      if [ $TSP_VERBOSE -ge 2 ]; then
459 +         echo $*
460 +      fi
461 +   fi
462 +   $* # Execute command
463 +   if [ $? -ne 0 ]; then
464 +      echo "Error while executing $1"
465 +      echo "   Command: $*"
466 +      exit 1
467 +   fi
468 +}
469 +
470 +ExecNoCheck()
471 +{
472 +   if [ ! -z $TSP_VERBOSE ]; then
473 +      if [ $TSP_VERBOSE -ge 2 ]; then
474 +         echo $*
475 +      fi
476 +   fi
477 +   $* # Execute command
478 +}
479 +
480 +# Program localization 
481 +
482 +Display 1 "--- Start of configuration script. ---"
483 +Display 1 "Script: " `basename $0`
484 +
485 +ifconfig=/sbin/ifconfig
486 +route=/sbin/route
487 +ipconfig=/sbin/ip
488 +rtadvd=/usr/sbin/radvd
489 +rtadvd_pid=/var/run/radvd/radvd.pid
490 +sysctl=/sbin/sysctl
491 +rtadvdconfigfilename=gw6c-rtadvd.conf
492 +rtadvdconfigfile=$TSP_HOME_DIR/$rtadvdconfigfilename
493 +
494 +if [ -z $TSP_HOME_DIR ]; then
495 +   echo "TSP_HOME_DIR variable not specified!;"
496 +   exit 1
497 +fi
498 +
499 +if [ ! -d $TSP_HOME_DIR ]; then
500 +   echo "Error : directory $TSP_HOME_DIR does not exist"
501 +   exit 1
502 +fi
503 +#
504 +
505 +if [ -z $TSP_HOST_TYPE ]; then
506 +   echo Error: TSP_HOST_TYPE not defined.
507 +   exit 1
508 +fi
509 +
510 +
511 +#############################################################################
512 +# Tunnel destruction script.
513 +#
514 +#   Is invoked by the Gateway6 Client on shutdown when it receives the 
515 +#   SIGHUP signal. Use "kill -HUP <gw6c pid>".
516 +#
517 +if [ X"${TSP_OPERATION}" = X"TSP_TUNNEL_TEARDOWN" ]; then
518 +
519 +  Display 1 Tunnel tear down starting...
520 +
521 +
522 +  # Router deconfiguration.
523 +  if [ X"${TSP_HOST_TYPE}" = X"router" ]; then
524 +
525 +    # Kill router advertisement daemon
526 +    KillProcess $rtadvdconfigfile
527 +
528 +    # Remove prefix routing on TSP_HOME_INTERFACE
529 +    ExecNoCheck $route -A inet6 del $TSP_PREFIX::/$TSP_PREFIXLEN
530 +
531 +    # Remove Blackhole.
532 +    if [ X"${TSP_PREFIXLEN}" != X"64" ]; then
533 +      ExecNoCheck $route -A inet6 del $TSP_PREFIX::/$TSP_PREFIXLEN dev lo
534 +    fi
535 +
536 +    # Remove address from TSP HOME INTERFACE
537 +    ExecNoCheck $ifconfig $TSP_HOME_INTERFACE inet6 del $TSP_PREFIX::1/64
538 +  fi
539 +
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
543 +
544 +  # Destroy tunnel interface
545 +  if [ -x $ipconfig ]; then
546 +    # Delete tunnel via ipconfig
547 +    ExecNoCheck $ipconfig tunnel del $TSP_TUNNEL_INTERFACE
548 +  else  
549 +    # Check if interface exists and remove it
550 +    $ifconfig $TSP_TUNNEL_INTERFACE >/dev/null 2>/dev/null
551 +    if [ $? -eq 0 ]; then
552 +
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
558 +      fi
559 +
560 +      # Bring interface down
561 +      ExecNoCheck $ifconfig $TSP_TUNNEL_INTERFACE down
562 +    fi
563 +  fi
564 +  
565 +
566 +  Display 1 Tunnel tear down completed.
567 +
568 +  exit 0
569 +fi
570 +
571 +
572 +#############################################################################
573 +# Tunnel creation script.
574 +#
575 +if [ X"${TSP_HOST_TYPE}" = X"host" ] || [ X"${TSP_HOST_TYPE}" = X"router" ]; then
576 +
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
585 +      else
586 +         Exec $ifconfig $TSP_TUNNEL_INTERFACE tunnel ::$TSP_SERVER_ADDRESS_IPV4
587 +      fi
588 +   fi
589 +
590 +   Exec $ifconfig $TSP_TUNNEL_INTERFACE up
591 +
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
598 +   fi
599 +
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
603 +
604 +   # 
605 +   # Default route  
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
611 +fi
612 +
613 +# Router configuration if required
614 +if [ X"${TSP_HOST_TYPE}" = X"router" ]; then
615 +
616 +   Display 1 "Router configuration"
617 +
618 +   # Tell kernel to forward IPv6 traffic.
619 +   Exec $sysctl -w net.ipv6.conf.all.forwarding=1
620 +
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
625 +   fi
626 +
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
632 +   fi
633 +   Display 1 "Adding prefix to $TSP_HOME_INTERFACE"
634 +   Exec $ifconfig $TSP_HOME_INTERFACE add $TSP_PREFIX::1/64
635 +
636 +
637 +   # Stop radvd daemon if it was running. Twice.
638 +   /etc/init.d/radvd stop
639 +   if [ -f $rtadvdconfigfile ]; then
640 +     KillProcess $rtadvdconfigfile
641 +   fi
642 +
643 +   # Create new radvd configuration file.
644 +   cat > "$rtadvdconfigfile" <<EOF
645 +##### rtadvd.conf made by Gateway6 Client ####
646 +interface $TSP_HOME_INTERFACE
647 +{
648 +  AdvSendAdvert on;
649 +  prefix $TSP_PREFIX::/64
650 +  {
651 +    AdvOnLink on;
652 +    AdvAutonomous on;
653 +  };
654 +};
655 +EOF
656 +
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
660 +fi
661 +
662 +Display 1 "--- End of configuration script. ---"
663 +
664 +exit 0
665 +
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
670 @@ -0,0 +1,92 @@
671 +***************
672 +*** 107,139 ****
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
680 +-       else
681 +-          Exec $ifconfig $TSP_TUNNEL_INTERFACE tunnel ::$TSP_SERVER_ADDRESS_IPV4
682 +-       fi
683 +     fi
684 +  
685 +-    Exec $ifconfig $TSP_TUNNEL_INTERFACE up
686 +  
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
692 +     fi
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
696 +     # 
697 +     # Default route  
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
703 +  fi
704 +  
705 +  # Router configuration if required
706 +--- 106,134 ----
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
713 +     fi
714 +  
715 ++    Exec $ipconfig link set $TSP_TUNNEL_INTERFACE up
716 +  
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
722 +     fi
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
726 +     # 
727 +     # Default route  
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
733 +  fi
734 +  
735 +  # Router configuration if required
736 +***************
737 +*** 146,157 ****
738 +     fi
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
745 +     fi
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"
750 +--- 141,152 ----
751 +     fi
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
758 +     fi
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"
This page took 0.223269 seconds and 3 git commands to generate.