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