lwip-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lwip-users] Possible bug in src/api/tcpip.c


From: Erik Ekman
Subject: Re: [lwip-users] Possible bug in src/api/tcpip.c
Date: Sun, 4 May 2008 11:39:07 +0200

On 5/1/08, Rishi Khan <address@hidden> wrote:
> Ok. Maybe the tapif.c should be updated in ports/unix/netif because that's
> where I got the hairbrained idea to remove the ethernet header.
>
>         -rishi
>
>  P.S. I've written a unix driver that actually binds to eth0 (or other
> device) and operates there. This allows you to test inter-computer
> communication in unix (tap/tun seem to only work on the machine running the
> program and no other machine can access this). Is this something that is
> useful to the community?
>
>

You need to bridge the tun/tap interface with for instance eth0 for it
to be available on the "real" network. This is my sh script that does
bridging:


-------------------------------------snip
#!/bin/bash

#################################
# Set up Ethernet bridge on Linux
# Requires: bridge-utils and kernel support
#################################

PATH=$PATH:/sbin:/usr/sbin

# Define Bridge Interface
br="br0"

# Define list of TAP interfaces to be bridged,
# for example tap="tap0 tap1 tap2".
tap=$1

# Define physical ethernet interface to be bridged
# with TAP interface(s) above.
eth="eth0"
eth_ip=`ifconfig $eth|grep 'inet addr'|sed 's/^.*addr\:\([0-9.]*\).*/\1/'`
eth_netmask=`ifconfig $eth|grep 'inet addr'|sed 's/^.*Mask\:\([0-9.]*\).*/\1/'`
eth_broadcast=`ifconfig $eth|grep 'inet addr'|sed
's/^.*Bcast\:\([0-9.]*\).*/\1/'`
route=`route -n|grep ^0|awk '{ print $2 }'`

echo "Bridging $eth and $tap as $br"

#check for bridge-utils
BRCTL=`which brctl`

if [ -z "$BRCTL" ];
then
        exit 2;
fi

#check for running tap device
TAPDEV=`ifconfig $tap 2> /dev/null`

if [ -z "$TAPDEV" ];
then
        exit 1;
fi

#check for bridge device
BRIDGE_UP=`ifconfig $br 2> /dev/null`
if [ -z "$BRIDGE_UP" ];
then
        brctl addbr $br || exit 99
        brctl addif $br $eth || exit 99

        echo 1 > /proc/sys/net/ipv4/conf/$eth/forwarding
        echo 1 > /proc/sys/net/ipv4/conf/$br/forwarding

        ifconfig $eth 0.0.0.0 promisc up
        ifconfig $br $eth_ip netmask $eth_netmask broadcast $eth_broadcast
        sleep 2
        route add default gw $route
fi

brctl stp $br off
brctl setfd $br 0
brctl sethello $br 1
echo 1 > /proc/sys/net/ipv4/ip_nonlocal_bind

#start the tap device
for t in $tap; do
    ifconfig $t 0.0.0.0 promisc up
done

#add the tap device
for t in $tap; do
    brctl addif $br $t
    echo 1 > /proc/sys/net/ipv4/conf/$t/proxy_arp
    echo 1 > /proc/sys/net/ipv4/conf/$t/forwarding
done

sleep 2

exit 0
--------------------------------------snip

/Erik




reply via email to

[Prev in Thread] Current Thread [Next in Thread]