123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- #!/bin/sh
- . /lib/ar71xx.sh
- local lan_ifname="$(uci get network.lan.ifname)"
- local board="$(ar71xx_board_name)"
- uci -q batch <<EOF
- delete network.lan
- set network.wan.type='bridge'
- set network.wan.proto='dhcp'
- set network.wan.auto='1'
- set network.client='interface'
- set network.client.ifname='$lan_ifname bat0'
- set network.client.type='bridge'
- set network.client.proto='dhcpv6'
- set network.client.reqprefix='no'
- set network.client.peerdns='0'
- set network.mesh='interface'
- set network.mesh.proto='batadv'
- set network.mesh.mtu='1528'
- set network.mesh.mesh='bat0'
- set network.mesh_vpn='interface'
- set network.mesh_vpn.ifname='mesh-vpn'
- set network.mesh_vpn.proto='batadv'
- set network.mesh_vpn.mesh='bat0'
- EOF
- get_main_address() {
- case "$board" in
- tl-wdr3600|tl-wdr4300)
- cat /sys/class/ieee80211/phy1/macaddress
- ;;
- *)
- cat /sys/class/ieee80211/phy0/macaddress
- ;;
- esac
- }
- local mainaddr=$(get_main_address)
- local oIFS="$IFS"; IFS=":"; set -- $mainaddr; IFS="$oIFS"
- local b2mask=0x02
- local vpnaddr=$(printf "%02x:%s:%s:%02x:%s:%s" $(( 0x$1 | $b2mask )) $2 $3 $(( (0x$4 + 1) % 0x100 )) $5 $6)
- uci set network.client.macaddr="$mainaddr"
- uci set network.mesh_vpn.macaddr="$vpnaddr"
- case "$board" in
- tl-wr1043nd|\
- tl-wdr3600|\
- tl-wdr4300) # fix up duplicate mac addresses
- local wanaddr=$(printf "%02x:%s:%s:%02x:%s:%02x" $(( 0x$1 | $b2mask )) $2 $3 $(( (0x$4 + 1) % 0x100 )) $5 $(( (0x$6 + 1) % 0x100 )) )
- uci set network.wan.macaddr="$wanaddr"
- ;;
- esac
- uci commit network
|