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

Subversion Repositories openrisc_me

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

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
# - <tap> is/are the persistent TAP interface(s)
34
 
35
# The tap interfaces must have been previously set up persistently by the
36
# superuser using for example:
37
 
38
# openvpn --mktun --dev tap<n> --user <username> --group <groupname>
39
 
40
# Define Bridge Interface
41
br=$1
42
shift
43
 
44
# Host ethernet interface to use
45
eth=$1
46
shift
47
 
48
# Determine the IP address, netmask and broadcast of the host.
49
eth_ip=`ifconfig $eth | \
50
        grep "inet addr" | \
51
        head -1 | \
52
        sed -e 's/^.*inet addr:\([^ \t]*\).*$/\1/'`
53
eth_netmask=`ifconfig $eth | \
54
        grep "Mask" | \
55
        head -1 | \
56
        sed -e 's/^.*Mask:\([^ \t]*\).*$/\1/'`
57
eth_broadcast=`ifconfig $eth | \
58
        grep "Bcast" | \
59
        head -1 | \
60
        sed -e 's/^.*Bcast:\([^ \t]*\).*$/\1/'`
61
 
62
# Define list of TAP interfaces to be bridged,
63
tap=$*
64
 
65
echo "Creating bridge $br"
66
echo "  Host Ethernet device: $eth"
67
echo "  Host IP address:      $eth_ip"
68
echo "  Host netmask:         $eth_netmask"
69
echo "  Host broadcast:       $eth_broadcast"
70
echo "  Target TAP device(s): $tap"
71
 
72
# Create the bridge
73
brctl addbr $br
74
 
75
# Add the host Ethernet and TAP interfaces
76
brctl addif $br $eth
77
 
78
for t in $tap; do
79
    brctl addif $br $t
80
done
81
 
82
# Remove the IP addresses of the underlying interfaces
83
ifconfig $eth 0.0.0.0 promisc up
84
 
85
for t in $tap; do
86
    ifconfig $t 0.0.0.0 promisc up
87
done
88
 
89
# Reconfigure the bridge to have the Ethernet address that had been used just
90
# by $eth.
91
# ifconfig $br $eth_ip netmask $eth_netmask broadcast $eth_broadcast
92
dhclient $br

powered by: WebSVN 2.1.0

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