diff --git a/html/i18n.js b/html/i18n.js index a8d43cb..791074d 100644 --- a/html/i18n.js +++ b/html/i18n.js @@ -144,6 +144,10 @@ var LANG = { sys_netmask: 'Netmask:', sys_gateway: 'Gateway:', sys_language: 'Language:', + sys_mgmt_vlan: 'Management VLAN:', + sys_mgmt_untagged: 'untagged', + sys_mgmt_confirm: 'Move switch management to VLAN ', + sys_mgmt_warn: 'The switch will start tagging its own traffic with that VLAN. If the port you are connected through does not carry it, this page becomes unreachable and the setting can only be undone over the console. Continue?', sys_ip_note: 'When updating the above settings, remember to point your browser to the new IP afterwards:', sys_update: 'Update Settings', sys_save_label: 'Save all current settings to Flash:', @@ -326,6 +330,10 @@ var LANG = { sys_netmask: 'ネットマスク:', sys_gateway: 'ゲートウェイ:', sys_language: '言語:', + sys_mgmt_vlan: 'Management VLAN:', + sys_mgmt_untagged: 'untagged', + sys_mgmt_confirm: 'Move switch management to VLAN ', + sys_mgmt_warn: 'The switch will start tagging its own traffic with that VLAN. If the port you are connected through does not carry it, this page becomes unreachable and the setting can only be undone over the console. Continue?', sys_ip_note: '上記設定を変更した場合は、ブラウザで新しい IP にアクセスしてください:', sys_update: '設定更新', sys_save_label: '現在の設定をフラッシュに保存:', @@ -508,6 +516,10 @@ var LANG = { sys_netmask: '子网掩码:', sys_gateway: '网关:', sys_language: '语言:', + sys_mgmt_vlan: 'Management VLAN:', + sys_mgmt_untagged: 'untagged', + sys_mgmt_confirm: 'Move switch management to VLAN ', + sys_mgmt_warn: 'The switch will start tagging its own traffic with that VLAN. If the port you are connected through does not carry it, this page becomes unreachable and the setting can only be undone over the console. Continue?', sys_ip_note: '更新上述设置后,请使用新的 IP 地址重新访问管理界面:', sys_update: '更新设置', sys_save_label: '将当前全部设置保存到 Flash:', diff --git a/html/system.html b/html/system.html index 4b147c1..9c07fdc 100644 --- a/html/system.html +++ b/html/system.html @@ -32,7 +32,7 @@
-
+
@@ -46,6 +46,10 @@
+
+
+
+
diff --git a/html/system.js b/html/system.js index 0add17f..cb48a40 100644 --- a/html/system.js +++ b/html/system.js @@ -133,6 +133,7 @@ function fetchIP() { document.getElementById("gw").value=s.ip_gateway; document.getElementById("hostname").value=s.hostname; document.getElementById("model").textContent=s.hw_ver; + loadMgmtVlan(parseInt(s.mgmt_vlan, 10) || 0); clearInterval(systemInterval); // Fetch and populate the config textbox fetchConfig().then((configText) => { @@ -165,3 +166,44 @@ window.addEventListener("load", function() { if (langSel) langSel.value = rtlLang; systemInterval = setInterval(fetchIP, 1000); }); + + +var mgmtVlanCurrent = 0; + +/* Populate the management-VLAN picker from the configured VLANs. If management + * is untagged there is no VLAN to select, so show that as a disabled entry + * rather than inventing an id the switch would reject. */ +function loadMgmtVlan(cur) { + var sel = document.getElementById('mgmtvlan'); + if (!sel) return; + mgmtVlanCurrent = cur; + fetch('/vlanlist').then(function(r) { return r.json(); }).then(function(list) { + sel.innerHTML = ''; + if (!cur) { + var none = document.createElement('option'); + none.value = 0; none.disabled = true; + none.textContent = t('sys_mgmt_untagged'); + sel.appendChild(none); + } + for (var i = 0; i < list.length; i++) { + var o = document.createElement('option'); + o.value = list[i].id; + o.textContent = list[i].name ? (list[i].id + ' (' + list[i].name + ')') : list[i].id; + sel.appendChild(o); + } + sel.value = cur; + }).catch(function(err) { console.error('VLAN list failed:', err); }); +} + +function mgmtVlanChanged() { + var sel = document.getElementById('mgmtvlan'); + var id = parseInt(sel.value, 10); + if (!id || id === mgmtVlanCurrent) return; + if (!confirm(t('sys_mgmt_confirm') + id + '.\n\n' + t('sys_mgmt_warn'))) { + sel.value = mgmtVlanCurrent; + return; + } + fetch('/cmd', { method: 'POST', body: 'vlan ' + id + ' mgmt' }) + .then(function() { mgmtVlanCurrent = id; }) + .catch(function(err) { console.error('Set management VLAN failed:', err); sel.value = mgmtVlanCurrent; }); +} diff --git a/httpd/page_impl.c b/httpd/page_impl.c index cb9125b..c78c2e1 100644 --- a/httpd/page_impl.c +++ b/httpd/page_impl.c @@ -26,6 +26,7 @@ extern __code const struct machine machine; extern __xdata uint8_t outbuf[TCP_OUTBUF_SIZE]; extern __xdata uint16_t slen; +extern __xdata uint16_t management_vlan; extern __xdata uint16_t cont_len; extern __xdata uint32_t cont_addr; extern __code uint8_t * __code hex; @@ -264,7 +265,10 @@ void send_basic_info(void) slen += strtox(outbuf + slen, BUILD_DATE); slen += strtox(outbuf + slen, "\",\"hw_ver\":\""); slen += strtox(outbuf + slen, machine.machine_name); - slen += strtox(outbuf + slen, "\",\"flash_size\":\""); + /* VLAN carrying switch management, 0 = untagged. */ + slen += strtox(outbuf + slen, "\",\"mgmt_vlan\":"); + itoa16_html(management_vlan); + slen += strtox(outbuf + slen, ",\"flash_size\":\""); string_to_html(get_flash_size_str()); if (machine.n_sfp) {