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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [or1ksim/] [brstart.sh] - Diff between revs 440 and 443

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 440 Rev 443
#!/bin/bash
#!/bin/bash
 
 
# Copyright (C) 2010 ORSoC AB
# Copyright (C) 2010 ORSoC AB
# Copyright (C) 2010 Embecosm Limited
# Copyright (C) 2010 Embecosm Limited
 
 
# Contributor Julius Baxter <julius.baxter@orsoc.se>
# Contributor Julius Baxter <julius.baxter@orsoc.se>
# Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
# Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
 
 
# This file is a superuser script to set up an Ethernet bridge that can be
# This file is a superuser script to set up an Ethernet bridge that can be
# used with Or1ksim via the TUN/TAP interface.
# used with Or1ksim via the TUN/TAP interface.
 
 
# This program is free software; you can redistribute it and/or modify it
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 3 of the License, or (at your option)
# Software Foundation; either version 3 of the License, or (at your option)
# any later version.
# any later version.
 
 
# This program is distributed in the hope that it will be useful, but WITHOUT
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
# more details.
# more details.
 
 
# You should have received a copy of the GNU General Public License along
# You should have received a copy of the GNU General Public License along
# with this program.  If not, see <http://www.gnu.org/licenses/>.
# with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 
# ------------------------------------------------------------------------------
# ------------------------------------------------------------------------------
 
 
# Pre-requisites: bridge-utils must be installed.
# Pre-requisites: bridge-utils must be installed.
 
 
# Usage: ./brset.sh <bridge> <eth> <tap> [<tap> <tap> ...]
# Usage: ./brset.sh <bridge> <eth> <tap> [<tap> <tap> ...]
 
 
# - <bridge> is the bridge interface to use, e.g. br0
# - <bridge> is the bridge interface to use, e.g. br0
# - <eth> is the hardware ethernet interface to use, e.g. eth0
# - <eth> is the hardware ethernet interface to use, e.g. eth0
# - <mac> is the MAC of the Or1ksim Linux instance
 
# - <tap> is/are the persistent TAP interface(s)
# - <tap> is/are the persistent TAP interface(s)
 
 
# The tap interfaces must have been previously set up persistently by the
# The tap interfaces must have been previously set up persistently by the
# superuser using for example:
# superuser using for example:
 
 
# openvpn --mktun --dev tap<n> --user <username> --group <groupname>
# openvpn --mktun --dev tap<n> --user <username> --group <groupname>
 
 
# Define Bridge Interface
# Define Bridge Interface
br=$1
br=$1
shift
shift
 
 
# Host ethernet interface to use
# Host ethernet interface to use
eth=$1
eth=$1
shift
shift
 
 
# Determine the IP address, netmask and broadcast of the host.
# Determine the IP address, netmask and broadcast of the host.
eth_ip=`ifconfig $eth | \
eth_ip=`ifconfig $eth | \
        grep "inet addr" | \
        grep "inet addr" | \
        head -1 | \
        head -1 | \
        sed -e 's/^.*inet addr:\([^ \t]*\).*$/\1/'`
        sed -e 's/^.*inet addr:\([^ \t]*\).*$/\1/'`
eth_netmask=`ifconfig $eth | \
eth_netmask=`ifconfig $eth | \
        grep "Mask" | \
        grep "Mask" | \
        head -1 | \
        head -1 | \
        sed -e 's/^.*Mask:\([^ \t]*\).*$/\1/'`
        sed -e 's/^.*Mask:\([^ \t]*\).*$/\1/'`
eth_broadcast=`ifconfig $eth | \
eth_broadcast=`ifconfig $eth | \
        grep "Bcast" | \
        grep "Bcast" | \
        head -1 | \
        head -1 | \
        sed -e 's/^.*Bcast:\([^ \t]*\).*$/\1/'`
        sed -e 's/^.*Bcast:\([^ \t]*\).*$/\1/'`
 
 
# Define list of TAP interfaces to be bridged,
# Define list of TAP interfaces to be bridged,
tap=$*
tap=$*
 
 
echo "Creating bridge $br"
echo "Creating bridge $br"
echo "  Host Ethernet device: $eth"
echo "  Host Ethernet device: $eth"
echo "  Host IP address:      $eth_ip"
echo "  Host IP address:      $eth_ip"
echo "  Host netmask:         $eth_netmask"
echo "  Host netmask:         $eth_netmask"
echo "  Host broadcast:       $eth_broadcast"
echo "  Host broadcast:       $eth_broadcast"
echo "  Target TAP device(s): $tap"
echo "  Target TAP device(s): $tap"
 
 
# Create the bridge
# Create the bridge
brctl addbr $br
brctl addbr $br
 
 
# Add the host Ethernet and TAP interfaces
# Add the host Ethernet and TAP interfaces
brctl addif $br $eth
brctl addif $br $eth
 
 
for t in $tap; do
for t in $tap; do
    brctl addif $br $t
    brctl addif $br $t
done
done
 
 
# Remove the IP addresses of the underlying interfaces
# Remove the IP addresses of the underlying interfaces
ifconfig $eth 0.0.0.0 promisc up
ifconfig $eth 0.0.0.0 promisc up
 
 
for t in $tap; do
for t in $tap; do
    ifconfig $t 0.0.0.0 promisc up
    ifconfig $t 0.0.0.0 promisc up
done
done
 
 
# Reconfigure the bridge to have the Ethernet address that had been used just
# Reconfigure the bridge to have the Ethernet address that had been used just
# by $eth.
# by $eth.
# ifconfig $br $eth_ip netmask $eth_netmask broadcast $eth_broadcast
# ifconfig $br $eth_ip netmask $eth_netmask broadcast $eth_broadcast
dhclient $br
dhclient $br
 
 

powered by: WebSVN 2.1.0

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