OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or1ksim/] [brstart.sh] - Blame information for rev 440

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 440 jeremybenn
#!/bin/bash
2
 
3
# Copyright (C) 2010 ORSoC AB
4
# Copyright (C) 2010 Embecosm Limited
5
 
6
# Contributor Julius Baxter <julius.baxter@orsoc.se>
7
# Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
8
 
9
# This file is a superuser script to set up an Ethernet bridge that can be
10
# used with Or1ksim via the TUN/TAP interface.
11
 
12
# This program is free software; you can redistribute it and/or modify it
13
# under the terms of the GNU General Public License as published by the Free
14
# Software Foundation; either version 3 of the License, or (at your option)
15
# any later version.
16
 
17
# This program is distributed in the hope that it will be useful, but WITHOUT
18
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
20
# more details.
21
 
22
# You should have received a copy of the GNU General Public License along
23
# with this program.  If not, see <http://www.gnu.org/licenses/>.
24
 
25
# ------------------------------------------------------------------------------
26
 
27
# Pre-requisites: bridge-utils must be installed.
28
 
29
# Usage: ./brset.sh <bridge> <eth> <tap> [<tap> <tap> ...]
30
 
31
# - <bridge> is the bridge interface to use, e.g. br0
32
# - <eth> is the hardware ethernet interface to use, e.g. eth0
33
# - <mac> is the MAC of the Or1ksim Linux instance
34
# - <tap> is/are the persistent TAP interface(s)
35
 
36
# The tap interfaces must have been previously set up persistently by the
37
# superuser using for example:
38
 
39
# openvpn --mktun --dev tap<n> --user <username> --group <groupname>
40
 
41
# Define Bridge Interface
42
br=$1
43
shift
44
 
45
# Host ethernet interface to use
46
eth=$1
47
shift
48
 
49
# Determine the IP address, netmask and broadcast of the host.
50
eth_ip=`ifconfig $eth | \
51
        grep "inet addr" | \
52
        head -1 | \
53
        sed -e 's/^.*inet addr:\([^ \t]*\).*$/\1/'`
54
eth_netmask=`ifconfig $eth | \
55
        grep "Mask" | \
56
        head -1 | \
57
        sed -e 's/^.*Mask:\([^ \t]*\).*$/\1/'`
58
eth_broadcast=`ifconfig $eth | \
59
        grep "Bcast" | \
60
        head -1 | \
61
        sed -e 's/^.*Bcast:\([^ \t]*\).*$/\1/'`
62
 
63
# Define list of TAP interfaces to be bridged,
64
tap=$*
65
 
66
echo "Creating bridge $br"
67
echo "  Host Ethernet device: $eth"
68
echo "  Host IP address:      $eth_ip"
69
echo "  Host netmask:         $eth_netmask"
70
echo "  Host broadcast:       $eth_broadcast"
71
echo "  Target TAP device(s): $tap"
72
 
73
# Create the bridge
74
brctl addbr $br
75
 
76
# Add the host Ethernet and TAP interfaces
77
brctl addif $br $eth
78
 
79
for t in $tap; do
80
    brctl addif $br $t
81
done
82
 
83
# Remove the IP addresses of the underlying interfaces
84
ifconfig $eth 0.0.0.0 promisc up
85
 
86
for t in $tap; do
87
    ifconfig $t 0.0.0.0 promisc up
88
done
89
 
90
# Reconfigure the bridge to have the Ethernet address that had been used just
91
# by $eth.
92
# ifconfig $br $eth_ip netmask $eth_netmask broadcast $eth_broadcast
93
dhclient $br

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.