base-files: board.d: support dsl modems, atm bridges and pppoe protocol
authorJo-Philipp Wich <jow@openwrt.org>
Fri, 4 Dec 2015 09:56:55 +0000 (09:56 +0000)
committerJo-Philipp Wich <jow@openwrt.org>
Fri, 4 Dec 2015 09:56:55 +0000 (09:56 +0000)
This adds support for specifying the dsl modem, atm bridge configs and setting
the pppoe protocol for wan.

These additions are required to port the Lantiq target to board.d.

Signed-off-by: Jo-Philipp Wich <jow@openwrt.org>
SVN-Revision: 47750

package/base-files/files/bin/config_generate
package/base-files/files/lib/functions/uci-defaults-new.sh

index 02f6998c84dec4c0708dd159a8081f71f27a362b..49784ebfaec6b0bc7d4852b1ac8ae2bfdcdcd963 100755 (executable)
@@ -18,6 +18,40 @@ generate_static_network() {
                set network.globals='globals'
                set network.globals.ula_prefix='auto'
        EOF
+
+       if json_is_a dsl object; then
+               json_select dsl
+                       if json_is_a atmbridge object; then
+                               json_select atmbridge
+                                       local vpi vci encaps payload
+                                       json_get_vars vpi vci encaps payload
+                                       uci -q batch <<-EOF
+                                               delete network.atm
+                                               set network.atm='atm-bridge'
+                                               set network.atm.vpi='$vpi'
+                                               set network.atm.vci='$vci'
+                                               set network.atm.encaps='$encaps'
+                                               set network.atm.payload='$payload'
+                                       EOF
+                               json_select ..
+                       fi
+
+                       if json_is_a modem object; then
+                               json_select modem
+                                       local type annex firmware tone xfer_mode
+                                       json_get_vars type annex firmware tone xfer_mode
+                                       uci -q batch <<-EOF
+                                               delete network.dsl
+                                               set network.dsl='$type'
+                                               set network.dsl.annex='$annex'
+                                               set network.dsl.firmware='$firmware'
+                                               set network.dsl.tone='$tone'
+                                               set network.dsl.xfer_mode='$xfer_mode'
+                                       EOF
+                               json_select ..
+                       fi
+               json_select ..
+       fi
 }
 
 addr_offset=2
@@ -74,6 +108,22 @@ generate_network() {
                                set network.${1}6.proto='dhcpv6'
                        EOF
                ;;
+
+               pppoe)
+                       # fixup IPv6 slave interface
+                       ifname="pppoe-$1"
+
+                       uci -q batch <<-EOF
+                               set network.$1.proto='pppoe'
+                               set network.$1.username='username'
+                               set network.$1.password='password'
+                               set network.$1.ipv6='auto'
+                               delete network.${1}6
+                               set network.${1}6='interface'
+                               set network.${1}6.ifname='$ifname'
+                               set network.${1}6.proto='dhcpv6'
+                       EOF
+               ;;
        esac
 }
 
index 919aac88d364c9c7696c88320eea1f104ed080e3..b9703830498b91826121145f5fec6e7b34a9e544 100755 (executable)
@@ -39,7 +39,7 @@ _ucidef_set_interface() {
 
        if ! json_is_a protocol string; then
                case "$proto" in
-                       static|dhcp|none) : ;;
+                       static|dhcp|none|pppoe) : ;;
                        *)
                                case "$name" in
                                        lan) proto="static" ;;
@@ -304,6 +304,52 @@ ucidef_set_interface_macaddr() {
        json_select ..
 }
 
+ucidef_add_atm_bridge() {
+       local vpi="$1"
+       local vci="$2"
+       local encaps="$3"
+       local payload="$4"
+
+       json_select_object dsl
+               json_select_object atmbridge
+                       json_add_int vpi "$vpi"
+                       json_add_int vci "$vci"
+                       json_add_string encaps "$encaps"
+                       json_add_string payload "$payload"
+               json_select ..
+       json_select ..
+}
+
+ucidef_add_adsl_modem() {
+       local annex="$1"
+       local firmware="$2"
+
+       json_select_object dsl
+               json_select_object modem
+                       json_add_string type "adsl"
+                       json_add_string annex "$annex"
+                       json_add_string firmware "$firmware"
+               json_select ..
+       json_select ..
+}
+
+ucidef_add_vdsl_modem() {
+       local annex="$1"
+       local firmware="$2"
+       local tone="$3"
+       local xfer_mode="$4"
+
+       json_select_object dsl
+               json_select_object modem
+                       json_add_string type "vdsl"
+                       json_add_string annex "$annex"
+                       json_add_string firmware "$firmware"
+                       json_add_string tone "$tone"
+                       json_add_string xfer_mode "$xfer_mode"
+               json_select ..
+       json_select ..
+}
+
 ucidef_set_led_netdev() {
        local cfg="led_$1"
        local name="$2"