From 4f6da292be79f5725eb505b38de7b208757d7425 Mon Sep 17 00:00:00 2001 From: Astro Date: Tue, 29 Nov 2016 16:18:35 +0100 Subject: [PATCH] cpe: TL-WDR4300 --- salt-pillar/cpe/aps.sls | 35 +++++++++++++++++--------------- salt/cpe/ap.sh | 44 +++++++++++++++++++++++++++++++++-------- 2 files changed, 55 insertions(+), 24 deletions(-) diff --git a/salt-pillar/cpe/aps.sls b/salt-pillar/cpe/aps.sls index 88b025b..af27097 100644 --- a/salt-pillar/cpe/aps.sls +++ b/salt-pillar/cpe/aps.sls @@ -16,13 +16,13 @@ cpe: -----END PGP MESSAGE----- model: TL-WR841N location: abhanden - access-ports: pub + lan-access: pub radios: 'platform/qca953x_wmac': channel: 1 htmode: HT40+ ssids: - 'Zentralwerk': + 'ZW public': net: pub 'C3D2 legacy': net: priv1 @@ -57,14 +57,15 @@ cpe: =Tlu+ -----END PGP MESSAGE----- - model: TL-Archer-C7 + model: TL-WDR4300 # TL-Archer-C7 location: Netzbiotop Main - access-ports: priv1 + lan-access: priv1 radios: radio0: channel: 1 + htmode: HT40+ ssids: - 'Zentralwerk': + 'ZW public': net: pub 'C3D2 legacy': net: priv1 @@ -82,9 +83,10 @@ cpe: =TEEI -----END PGP MESSAGE----- radio1: - channel: 130 + channel: 36 + htmode: HT40+ ssids: - 'Zentralwerk': + 'ZW public': net: pub 'C3D2': net: priv1 @@ -103,7 +105,6 @@ cpe: -----END PGP MESSAGE----- ap3: - firstboot: true password: | -----BEGIN PGP MESSAGE----- @@ -118,14 +119,15 @@ cpe: =kpf2 -----END PGP MESSAGE----- - model: TL-WR1043ND + model: TL-WDR4300 location: weg - access-ports: priv1 + lan-access: priv1 radios: - radio0: - channel: 1 + 'platform/ar934x_wmac': + channel: 6 + htmode: HT40+ ssids: - 'Zentralwerk': + 'ZW public': net: pub 'C3D2 legacy': net: priv1 @@ -142,10 +144,11 @@ cpe: rA== =TEEI -----END PGP MESSAGE----- - radio1: - channel: 130 + 'pci0000:00/0000:00:00.0': + channel: 36 + htmode: HT40+ ssids: - 'Zentralwerk': + 'ZW public': net: pub 'C3D2': net: priv1 diff --git a/salt/cpe/ap.sh b/salt/cpe/ap.sh index 8711703..643e4a8 100644 --- a/salt/cpe/ap.sh +++ b/salt/cpe/ap.sh @@ -27,19 +27,46 @@ delete network.wan6 delete wireless.default_radio0 delete wireless.default_radio1 +{%- if conf['model'] == 'TL-WDR4300' %} +# These models have a shared Ethernet chip for LAN/WAN and therefore +# need switching +set network.@switch[0]=switch +set network.@switch[0].reset=1 +set network.@switch[0].enable=1 +set network.@switch[0].enable_vlan=1 +set network.@switch[0].name=switch0 +set network.@switch_vlan[0]=switch_vlan +set network.@switch_vlan[0].device='switch0' +set network.@switch_vlan[0].vlan='1' +set network.@switch_vlan[0].ports='0t 2 3 4 5' +set network.@switch_vlan[0].comment='LAN ports' +set network.@switch_vlan[1]=switch_vlan +set network.@switch_vlan[1].device='switch0' +set network.@switch_vlan[1].vlan='2' +set network.@switch_vlan[1].ports='0t 1' +set network.@switch_vlan[1].comment='WAN port' +{%- set lan_port = 'eth0.1' %} +{%- set wan_port = 'eth0.2' %} + +{%- else %} +# All other models may have separate Ethernet chips for LAN/WAN set network.@switch[0].reset=1 set network.@switch[0].enable=1 set network.@switch[0].enable_vlan=0 +{%- set lan_port = 'eth0' %} +{%- set wan_port = 'eth1' %} + +{%- endif %} set network.mgmt=interface -set network.mgmt.ifname=eth1.1 +set network.mgmt.ifname={{ wan_port }}.1 set network.mgmt.proto=static set network.mgmt.ipaddr={{ pillar['hosts-inet']['mgmt'][hostname] }} set network.mgmt.netmask=255.255.255.0 {%- set bridges = {} %} -{%- if conf.get('access-ports') %} -{%- do bridges.__setitem__(conf['access-ports'], True) %} +{%- if conf.get('lan-access') %} +{%- do bridges.__setitem__(conf['lan-access'], True) %} {%- endif %} {%- for path, radio in conf['radios'].items() %} {%- for ssid, ssidconf in radio['ssids'].items() %} @@ -52,14 +79,15 @@ set network.mgmt.netmask=255.255.255.0 set network.{{ net }}=interface set network.{{ net }}.type=bridge set network.{{ net }}.proto=static -{%- set ports = ['eth1.' ~ pillar['vlans'][net]] %} -{%- if conf.get('access-ports') == net %} -{%- do ports.append('eth0') %} +{%- set ports = [wan_port ~ '.' ~ pillar['vlans'][net]] %} +{%- if conf.get('lan-access') == net %} +{%- do ports.append(lan_port) %} {%- endif %} set network.{{ net }}.ifname='{{ ' '.join(ports) }}' {%- endfor %} {%- set radionum = 0 %} +{%- set ifnum = 0 %} {%- for path, radio in conf['radios'].items() %} set wireless.radio{{ radionum }}=wifi-device set wireless.radio{{ radionum }}.type=mac80211 @@ -70,8 +98,8 @@ set wireless.radio{{ radionum }}.htmode={{ radio.get('htmode') or 'HT20' }} set wireless.radio{{ radionum }}.noscan=1 delete wireless.radio{{ radionum }}.disabled -{%- set ifnum = 0 %} {%- for ssid, ssidconf in radio['ssids'].items() %} +{%- set ifnum = ifnum + loop.index0 %} set wireless.wifi{{ ifnum }}=wifi-iface set wireless.wifi{{ ifnum }}.device=radio{{ radionum }} set wireless.wifi{{ ifnum }}.ssid='{{ ssid }}' @@ -84,9 +112,9 @@ set wireless.wifi{{ ifnum }}.key='{{ ssidconf['psk'] }}' set wireless.wifi{{ ifnum }}.encryption=none {%- endif %} -{%- set ifnum = ifnum + 1 %} {%- endfor %} +{%- set ifnum = ifnum + radio['ssids'].items()|length %} {%- set radionum = radionum + 1 %} {%- endfor %}