011-gluon-network 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/bin/sh
  2. . /lib/ar71xx.sh
  3. local lan_ifname="$(uci get network.lan.ifname)"
  4. local board="$(ar71xx_board_name)"
  5. uci -q batch <<EOF
  6. delete network.lan
  7. set network.wan.type='bridge'
  8. set network.wan.proto='dhcp'
  9. set network.wan.auto='1'
  10. set network.client='interface'
  11. set network.client.ifname='$lan_ifname bat0'
  12. set network.client.type='bridge'
  13. set network.client.proto='dhcpv6'
  14. set network.client.reqprefix='no'
  15. set network.client.peerdns='0'
  16. set network.mesh='interface'
  17. set network.mesh.proto='batadv'
  18. set network.mesh.mtu='1528'
  19. set network.mesh.mesh='bat0'
  20. set network.mesh_vpn='interface'
  21. set network.mesh_vpn.ifname='mesh-vpn'
  22. set network.mesh_vpn.proto='batadv'
  23. set network.mesh_vpn.mesh='bat0'
  24. EOF
  25. get_main_address() {
  26. case "$board" in
  27. tl-wdr3600|tl-wdr4300)
  28. cat /sys/class/ieee80211/phy1/macaddress
  29. ;;
  30. *)
  31. cat /sys/class/ieee80211/phy0/macaddress
  32. ;;
  33. esac
  34. }
  35. local mainaddr=$(get_main_address)
  36. local oIFS="$IFS"; IFS=":"; set -- $mainaddr; IFS="$oIFS"
  37. local b2mask=0x02
  38. local vpnaddr=$(printf "%02x:%s:%s:%02x:%s:%s" $(( 0x$1 | $b2mask )) $2 $3 $(( (0x$4 + 1) % 0x100 )) $5 $6)
  39. uci set network.client.macaddr="$mainaddr"
  40. uci set network.mesh_vpn.macaddr="$vpnaddr"
  41. case "$board" in
  42. tl-wr1043nd|\
  43. tl-wdr3600|\
  44. tl-wdr4300) # fix up duplicate mac addresses
  45. local wanaddr=$(printf "%02x:%s:%s:%02x:%s:%02x" $(( 0x$1 | $b2mask )) $2 $3 $(( (0x$4 + 1) % 0x100 )) $5 $(( (0x$6 + 1) % 0x100 )) )
  46. uci set network.wan.macaddr="$wanaddr"
  47. ;;
  48. esac
  49. uci commit network