aboutsummaryrefslogtreecommitdiffstats
path: root/package/base-files/files/bin
diff options
context:
space:
mode:
authorJo-Philipp Wich <jow@openwrt.org>2015-12-03 22:27:06 +0000
committerJo-Philipp Wich <jow@openwrt.org>2015-12-03 22:27:06 +0000
commitb7dcc615b9d3ef5b2fb977b4d7563fa93713152a (patch)
tree3f8678455385f4de5a681542c4ad7bc77e78518f /package/base-files/files/bin
parentfd83873d6440d699fee4277151729e2c0ebbdc6d (diff)
downloadmaster-187ad058-b7dcc615b9d3ef5b2fb977b4d7563fa93713152a.tar.gz
master-187ad058-b7dcc615b9d3ef5b2fb977b4d7563fa93713152a.tar.bz2
master-187ad058-b7dcc615b9d3ef5b2fb977b4d7563fa93713152a.zip
base-files: board.d: support specifiying the protocol of lan and wan
Some boards, e.g. the Sheeva Plug, require the lan interface to be set to DHCP instead of a static address, therfore support that. Signed-off-by: Jo-Philipp Wich <jow@openwrt.org> git-svn-id: svn://svn.openwrt.org/openwrt/trunk@47732 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'package/base-files/files/bin')
-rwxr-xr-xpackage/base-files/files/bin/config_generate32
1 files changed, 21 insertions, 11 deletions
diff --git a/package/base-files/files/bin/config_generate b/package/base-files/files/bin/config_generate
index 264f7d3ed1..02f6998c84 100755
--- a/package/base-files/files/bin/config_generate
+++ b/package/base-files/files/bin/config_generate
@@ -20,12 +20,13 @@ generate_static_network() {
EOF
}
+addr_offset=2
generate_network() {
- local ifname macaddr type
+ local ifname macaddr protocol type
json_select network
json_select "$1"
- json_get_vars ifname macaddr
+ json_get_vars ifname macaddr protocol
json_select ..
json_select ..
@@ -45,23 +46,32 @@ generate_network() {
set network.$1.macaddr='$macaddr'
EOF
- case "$1" in
- lan)
+ case "$protocol" in
+ static)
+ local ipaddr
+ case "$1" in
+ lan) ipaddr="192.168.1.1" ;;
+ *) ipaddr="192.168.$((addr_offset++)).1" ;;
+ esac
+
uci -q batch <<-EOF
set network.$1.proto='static'
- set network.$1.ipaddr='192.168.1.1'
+ set network.$1.ipaddr='$ipaddr'
set network.$1.netmask='255.255.255.0'
set network.$1.ip6assign='60'
EOF
;;
- wan)
+
+ dhcp)
+ # fixup IPv6 slave interface if parent is a bridge
+ [ "$type" = "bridge" ] && ifname="br-$1"
+
uci -q batch <<-EOF
set network.$1.proto='dhcp'
- delete network.wan6
- set network.wan6='interface'
- set network.wan6.type='$type'
- set network.wan6.ifname='$ifname'
- set network.wan6.proto='dhcpv6'
+ delete network.${1}6
+ set network.${1}6='interface'
+ set network.${1}6.ifname='$ifname'
+ set network.${1}6.proto='dhcpv6'
EOF
;;
esac