From ec81a2e4414625e2cdd6aa164276f45d1351f578 Mon Sep 17 00:00:00 2001 From: Tim Niemeyer Date: Fri, 11 Apr 2014 22:17:34 +0200 Subject: [PATCH] bsp: wr841n9: configure network Make the network config more dynamically. Signed-off-by: Tim Niemeyer --- bsp/default/root_file_system/etc/rc.local.tpl | 3 +- .../root_file_system/etc/config/network | 64 ++++++++----------- .../root_file_system/etc/config/nodewatcher | 1 - .../root_file_system/etc/rc.local.board | 9 --- .../etc/rc.local.tl-wr841n-v9 | 60 +++++++++++++++++ 5 files changed, 87 insertions(+), 50 deletions(-) delete mode 100755 bsp/wr841n9/root_file_system/etc/rc.local.board create mode 100755 bsp/wr841n9/root_file_system/etc/rc.local.tl-wr841n-v9 diff --git a/bsp/default/root_file_system/etc/rc.local.tpl b/bsp/default/root_file_system/etc/rc.local.tpl index e1c8631d..f1581b66 100755 --- a/bsp/default/root_file_system/etc/rc.local.tpl +++ b/bsp/default/root_file_system/etc/rc.local.tpl @@ -4,7 +4,8 @@ # collect environment info and write to dot-script /etc/environment.sh > /tmp/environment -. /etc/rc.local.board +BOARD=$(cat /var/sysinfo/board_name) +. /etc/rc.local.$BOARD # Starting NTP-Client Daemon ntpd -p ${NTPD_IP} diff --git a/bsp/wr841n9/root_file_system/etc/config/network b/bsp/wr841n9/root_file_system/etc/config/network index be3fd598..6ecaf209 100644 --- a/bsp/wr841n9/root_file_system/etc/config/network +++ b/bsp/wr841n9/root_file_system/etc/config/network @@ -1,41 +1,27 @@ +config interface 'loopback' + option ifname 'lo' + option proto 'static' + option ipaddr '127.0.0.1' + option netmask '255.0.0.0' -config 'interface' 'loopback' - option 'ifname' 'lo' - option 'proto' 'static' - option 'ipaddr' '127.0.0.1' - option 'netmask' '255.0.0.0' - -config 'interface' 'wlanmesh' - option 'ifname' 'wlan1' - option 'mtu' '1528' - -config 'interface' 'mesh' - option 'type' 'bridge' - option 'ifname' 'eth1.1 wlan0 bat0 tap0' - option 'auto' '1' - -config 'interface' 'wan' - option 'ifname' 'eth0' - option 'proto' 'dhcp' - -config 'interface' 'ethmesh' - option 'ifname' 'eth1.3' - option 'mtu' '1528' - -config 'switch' - option 'name' 'eth1' - option 'reset' '1' - option 'enable_vlan' '1' - -#1. und 2. LAN Port -config 'switch_vlan' - option 'device' 'eth1' - option 'vlan' '1' - option 'ports' '1 4 0t' - -#3. und 4. LAN Port -config 'switch_vlan' - option 'device' 'eth1' - option 'vlan' '3' - option 'ports' '3 2 0t' +config interface 'wlanmesh' + option mtu '1532' + option proto 'batadv' + option mesh 'bat0' +config interface 'mesh' + option type 'bridge' + option auto '1' + +config interface 'wan' + option proto 'dhcp' + option ifname 'eth1' + +config interface 'ethmesh' + option mtu '1532' + option proto 'batadv' + option mesh 'bat0' + +config interface 'bat' + option ifname 'bat0' + option mtu '1500' diff --git a/bsp/wr841n9/root_file_system/etc/config/nodewatcher b/bsp/wr841n9/root_file_system/etc/config/nodewatcher index 5fe1408f..dfee7dcb 100644 --- a/bsp/wr841n9/root_file_system/etc/config/nodewatcher +++ b/bsp/wr841n9/root_file_system/etc/config/nodewatcher @@ -6,4 +6,3 @@ config 'script' config 'network' option 'mesh_interface' 'br-mesh' - option 'client_interfaces' 'wlan0 eth1.1' diff --git a/bsp/wr841n9/root_file_system/etc/rc.local.board b/bsp/wr841n9/root_file_system/etc/rc.local.board deleted file mode 100755 index 00dcd520..00000000 --- a/bsp/wr841n9/root_file_system/etc/rc.local.board +++ /dev/null @@ -1,9 +0,0 @@ - -#Set Mac-Addr of wr1043nd wifi interface if not right -WLAN0_MACADDR=$(cat /sys/class/net/wlan0/address) -BRMESH_MACADDR=$(cat /sys/class/net/br-mesh/address) - - -batctl if add wlan0-1 -batctl if add eth1.3 - diff --git a/bsp/wr841n9/root_file_system/etc/rc.local.tl-wr841n-v9 b/bsp/wr841n9/root_file_system/etc/rc.local.tl-wr841n-v9 new file mode 100755 index 00000000..ed69d2f8 --- /dev/null +++ b/bsp/wr841n9/root_file_system/etc/rc.local.tl-wr841n-v9 @@ -0,0 +1,60 @@ + +if ! uci get nodewatcher.@network[0].client_interfaces; then + IF="eth0.1 wlan0-1" + echo "Setting nodewatchers client interfaces to: $IF" + uci set nodewatcher.@network[0].client_interfaces="$IF" + uci commit +fi + +WANDEV=eth1 +SWITCHDEV=eth0 +CLIENT_PORTS="1 2 0t" +WAN_PORTS= +BATMAN_PORTS="3 4 0t" + +if ! uci get network.$SWITCHDEV.ifname; then + uci set network.$SWITCHDEV=switch + uci set network.$SWITCHDEV.enable=1 + uci set network.$SWITCHDEV.reset=1 + uci set network.$SWITCHDEV.enable_vlan=1 + + uci set network.${SWITCHDEV}_1=switch_vlan + uci set network.${SWITCHDEV}_1.device=$SWITCHDEV + uci set network.${SWITCHDEV}_1.vlan=1 + uci set network.${SWITCHDEV}_1.ports="$CLIENT_PORTS" + + if [[ "$WANDEV" = "$SWITCHDEV" ]]; then + uci set network.${SWITCHDEV}_2=switch_vlan + uci set network.${SWITCHDEV}_2.device=$SWITCHDEV + uci set network.${SWITCHDEV}_2.vlan=2 + uci set network.${SWITCHDEV}_2.ports="$WAN_PORTS" + fi + + uci set network.${SWITCHDEV}_3=switch_vlan + uci set network.${SWITCHDEV}_3.device=$SWITCHDEV + uci set network.${SWITCHDEV}_3.vlan=3 + uci set network.${SWITCHDEV}_3.ports="$BATMAN_PORTS" + + uci set network.mesh.ifname="$SWITCHDEV.1 bat0" + + uci set network.ethmesh.ifname="$SWITCHDEV.3" + + uci set network.wan.ifname=$WANDEV + + uci commit + /etc/init.d/network reload +fi + +if uci get network.ethmesh.macaddr +then + echo "MAC for ethmesh is set already" +else + echo "Fixing MAC on eth0.3 (ethmesh)" + NEW_MACADDR=$(cat /sys/class/net/eth1/address) + uci set network.ethmesh.macaddr=$NEW_MACADDR + uci commit + ifconfig eth0.3 down + ifconfig eth0.3 hw ether $NEW_MACADDR + ifconfig eth0.3 up + /etc/init.d/network reload +fi