source: fedkit/setup_bridge.pl

Last change on this file was a80a4a7, checked in by Ted Faber <faber@…>, 10 years ago

Keep state for desktop disconnect/connect cycles to work

  • Property mode set to 100644
File size: 2.2 KB
Line 
1#!/usr/bin/perl
2
3use strict;
4
5use gateway_lib;
6
7use Getopt::Long;
8
9use IO::File;
10
11my $tapno;
12my $addr;
13my $dest;
14my $iface;
15my $fedkit_dir= "/usr/local/federation";
16my $perl = "/usr/bin/perl";
17my $peer;
18my $use_file;
19my %opts = (
20    'tapno=s' => \$tapno,
21    'addr=s' => \$addr,
22    'dest=s' => \$dest,
23    'peer=s' => \$peer,
24    'use_file', \$use_file,
25);
26
27exit(20) unless GetOptions(%opts);
28gateway_lib::read_config(gateway_lib::config_filename(), \%opts)
29    if $use_file;
30
31die "Only one of dest and addr is allowed\n" if $addr && $dest;
32
33$iface = $dest ? 
34    gateway_lib::dest_to_iface($dest) : gateway_lib::addr_to_iface($addr) 
35        if !$iface;
36
37print "iface is $iface\n";
38
39# Make a copy of the interface for unsetup_bridge.pl
40my $f = new IO::File(">/tmp/interface$tapno");
41print $f "$iface\n" if $f;
42$f->close( )if $f;
43
44gateway_lib::bind_tap_to_iface($tapno, $iface);
45gateway_lib::ping_peer($peer)
46    if $peer;
47
48exit(0);
49
50=pod
51
52=head1 NAME
53
54B<setup_bridge.pl> - Connect a tap and local interface.  Called both remotely
55and locally to establish the two sides of the bridge.
56
57=head1 OPTIONS
58
59=over 8
60
61=item B<addr=>I<address>
62
63Address of the local interface to connect to the given tap interface on the
64given bridge interface.
65
66=item B<dest=>I<destination>
67
68Attach the interface on which I<destination> can be reached to the given
69tap/bridge combo.
70
71=item B<tapno=>I<integer>
72
73The tap interface to connect. This will be the integer that follows tap and
74bridge in the interface names.
75
76=item B<use_file>
77
78If given read additional parameters from the file in
79/proj/I<project>/exp/I<experiment>/tmp/I<hostname>.gw/conf where those are the
80current testbed project and experiment and the hostname is before the first
81dot.  The file is option: value.
82
83
84=back
85
86=head1 SYNOPSIS
87
88B<setup_bridge.pl> connects the established ssh tunnel (a tap interface) to
89a local interface through a bridge interface.  Traffic on the local interface
90will cross the network over the ssh tunnel and be released onto the net via a
91symmetrical setup on the peer.
92
93The interface to attach can be given either by its interface or an address/DNS
94name to reach.  In either case, all IP addresses are removed from the
95bound interface.
96
97=head1 AUTHORS
98
99Ted Faber <faber@isi.edu>
100
101=cut
Note: See TracBrowser for help on using the repository browser.