Commit Graph
1021 Commits
Author SHA1 Message Date
Erdnusschokolade ba919280ac Address PR #233 review feedback
- itoa16_html: add comment that the function is sufficient for VLAN
  IDs (<=4094); generalization not needed.
- send_vlanlist: replace post-write bounds check with a pre-write
  guard using worst-case entry size (138 bytes + 1 for closing
  bracket). Old comment claimed ~45 bytes per entry, which only
  held for short names. With a 117-char name (the actual bound from
  CMD_BUF_SIZE) entries can reach 138 bytes, and the post-check
  would not have prevented an overflow.
- Document the 0x02 check in sfr_data[0] as the VLAN table entry
  valid flag.
2026-05-24 23:31:18 +02:00
Erdnusschokolade dcc60c3824 Fix conf_overwrite vlan/mgmt conflict
The pattern /^vlan\s+\d{1,4}\b/ matched both VLAN membership entries
(vlan N <ports>) and management entries (vlan N mgmt), causing them
to overwrite each other in configuration[]. When saving, whichever
form came last in the cmd_log would dedupe the other out of the
final config — resulting in either lost membership or a stale mgmt
setting.

Split into two patterns using negative lookahead:
- /^vlan\s+\d{1,4}\s+mgmt$/      matches only mgmt entries
- /^vlan\s+\d{1,4}(?!\s+mgmt\b)/  matches everything else

Both dedup independently. Discovered via hardware test on 6XH-X
where 'vlan 44 mgmt' silently dropped 'vlan 44 management 2t 5u'
from saved config, locking out web UI on next boot.
2026-05-24 11:26:04 +02:00
Erdnusschokolade caad366b3b Fix config persistence: missing commands, delete handling, multipart
Multiple related bugs in the Save-to-Flash path:

1. Multipart upload was missing the required filename argument,
   causing the backend parser to fail. Added 'config.txt' to the
   form.append call. This was likely the primary reason Save-to-Flash
   was unreliable.

2. Web UI was not pausing its polling interval during flash write,
   causing CPU contention and intermittent crashes. Added isSaving
   lock and clearInterval before sendConfig.

3. conf_cmds whitelist was incomplete. Added: syslog, passwd, pvid,
   ingress, port name, lag, laghash, isolate, stp, igmp, mtu, bw,
   vlan N mgmt, vlan N d.

4. VLAN regex blocked named VLANs. New pattern allows optional name
   (starts with letter, matching CLI parser semantics).

5. vlan N d (delete) was not persisted. parseConf now removes the
   matching vlan N ... entry from configuration[] when seeing a
   delete command, without storing the delete itself. Result: the
   saved config describes the end state.

6. configuration[] was not cleared between flashSave invocations,
   leading to stale entries from prior interactions.

7. conf_overwrite boundary fix: 'pvid 1' no longer matches 'pvid 10'
   etc. Added trailing space in startsWith check.

8. All conf_cmds patterns now anchored with ^...$ for full-line
   match. parseConf normalizes whitespace before testing.

9. Port range widened to \d{1,2} so ports 11+ are accepted.

Structural fixes (1, 2, 6, 7, 8) ported from mcaptur's closed PR #219;
remaining fixes (3, 4, 5, 9) and overall regex strategy are new.
2026-05-24 11:26:04 +02:00
Erdnusschokolade ce0ee859d6 Fix: Untagged Ports column included non-member ports
The hardware bitmask format encodes both "untagged members" and
"non-members" in the upper 10 bits (per doc/vlan.md). The existing
fetchVLAN() correctly masks this with the membership bitmask before
display, but loadVlanTable() did not, causing non-member ports to
appear in the Untagged Ports column.

Tested on KeepLiNK KP-9000-6XH-X.
2026-05-24 11:20:57 +02:00
Erdnusschokolade a369e46fe6 Add VLAN overview table to VLAN configuration page
Below the configuration form, a new table lists all configured VLANs
with their port memberships: Member, Tagged, Untagged, and PVID
columns. Port ranges are formatted compactly (e.g. "1-2,5").

Port-to-bit mapping uses the existing physToLogPort[] array populated
by /status.json, so the table is consistent with the icon view in
fetchVLAN() and works on any supported machine.

Each row has a delete button that sends "vlan N d" via /cmd, with
a confirmation dialog. VLAN 1 cannot be deleted (no button shown).

Table and dropdown both refresh automatically after Update/Create
and after delete via a new refreshVlanViews() helper.

The N+1 request pattern (1x /vlanlist + Nx /vlan.json) keeps the
backend simple and avoids buffer overflow risks for systems with
many VLANs. For typical configurations (<50 VLANs), page load
remains under one second.
2026-05-24 11:20:57 +02:00
Erdnusschokolade defb37c06a Add VLAN selector dropdown to VLAN configuration page
A new <select> element above the VLAN ID input lets users pick an
existing VLAN by name instead of typing the ID. Options are loaded
from /vlanlist on page load and re-loaded after successful
Update/Create operations.

Selection triggers the existing fetchVLAN() flow.

Falls back gracefully if /vlanlist returns an empty list or fails:
the dropdown is hidden and the existing ID input remains functional.
2026-05-24 11:20:57 +02:00
Erdnusschokolade a5f77e4caf Add /vlanlist HTTP endpoint
Returns a JSON array of all configured VLANs with their IDs and names,
e.g. [{"id":1,"name":""},{"id":20,"name":"IoT"}].

The endpoint iterates VLAN IDs 1..4094 and filters by the validity bit
in sfr_data[0] (0x02), following the same pattern as vlan_create() and
vlan_setup() in rtl837x_port.c.

Also adds a small itoa16_html() helper for emitting decimal numbers
up to 4 digits (analogous to the existing 8-bit itoa_html()), used
for VLAN IDs which can reach 4094. Response builder uses the existing
vlan_name() helper for the name lookup, consistent with send_vlan().

Buffer overflow is prevented by breaking out of the iteration loop at
TCP_OUTBUF_SIZE - 60.

This endpoint is the foundation for upcoming UI improvements
(VLAN selector dropdown and overview table).
2026-05-24 11:20:57 +02:00
logicog 1311cb9ea9 Merge pull request #232 from Erdnusschokolade/fix/vlan-name-rename
Fix VLAN name persistence across rename and delete operations
2026-05-23 12:47:06 +02:00
Erdnusschokoladeandlogicog 7d0d8525d2 Fix two OOB reads in parse_vlan()
1. While loop scanning VLAN name terminated only on ' ', not '\0'.
   When the name is the last token in cmd_buffer, the loop reads past
   the buffer into adjacent XRAM.

2. Entering 'vlan' without arguments causes parse_vlan() to read
   cmd_words_b[1] which points to undefined memory, causing atoi_short()
   to interpret residual bytes from previous commands as a VLAN ID.
   Bug found and fix proposed by logicog during review of PR #232.

Co-Authored-By: logicog <logicog@users.noreply.github.com>
2026-05-23 11:19:42 +02:00
logicog 201289990b Merge pull request #236 from Erdnusschokolade/doc/vlan-mgmt-command
doc: document vlan <id> mgmt command
2026-05-23 07:31:39 +02:00
Erdnusschokolade 3a93ce1786 doc: document vlan <id> mgmt command
Adds CLI reference for the previously undocumented vlan <id> mgmt
command, including the disable case (vlan 0 mgmt), default state,
and a lockout warning.

Fixes #235
2026-05-23 00:26:13 +02:00
René van Dorst 4b42be8cae Merge pull request #234 from logicog/fix_duplex
Fix duplex setting on the CLI
2026-05-22 19:38:33 +00:00
logicog 32f9b91def Fix duplex setting on the CLI
Fixes commands such as
> port 1 duplex half
2026-05-22 21:07:29 +02:00
Erdnusschokolade 21f33abfa7 Fix VLAN name persistence across rename and delete operations
Previously, renaming a VLAN or deleting and recreating it with a
different name did not update the displayed name. The vlan_names[]
array is an append-only buffer where vlan_name() returns the first
matching entry, so stale entries kept winning.

This commit adds vlan_name_remove(), which locates an entry by
VLAN ID and removes it via array compaction. The function is called
in two places:

  - parse_vlan() in cmd_parser.c, before appending a new name entry,
    to remove any pre-existing entry for the same VLAN ID
  - vlan_delete() in rtl837x_port.c, to clean up the name when a
    VLAN is removed

The implementation reuses the existing vlan_name() lookup, scans for
the trailing space of the matched entry, then shifts remaining bytes
left. Locals are declared as static __xdata to avoid the SDCC
overlay segment limit on banked functions.

Tested on KeepLiNK KP-9000-6XH-X:
  - vlan 99 AAA p1u; vlan 99 BBB -> name updated to BBB
  - vlan 99 d; vlan 99 CCC p1u   -> name correctly CCC, not stale AAA

Note: This fix addresses the runtime XMEM state. Persistence of
renamed VLAN names across reboot requires the user to download and
re-upload /config, as is the existing pattern for all configuration
changes in this firmware.
2026-05-21 17:39:29 +02:00
René van Dorst d253c9feee Merge pull request #231 from xristos-sk/fix-rtl837x_stp-bug,-cmpMac-always-0-when-checking-for-new-root
fix: rtl837x_stp bug, cmpMac always 0 when checking for new root
2026-05-19 19:57:45 +00:00
sk_thes 2552f586d8 fix: rtl837x_stp bug, cmpMac always 0 when checking for new root
When checking for a new root, a root_bridge with the same priority as STP_I will never be adopted as cmpMAC always returns 0.

This PR fixes this bug by changing the comparison of MACs to what was intended
2026-05-18 22:47:31 +00:00
logicog f113b2c0e5 Merge pull request #230 from vDorst/refactor_is_word
Refactor is_word() and is_word_x()
2026-05-18 18:31:17 +02:00
logicog 2d912d80c9 Merge pull request #229 from vDorst/fix_login
Fix and refactor is_url_word_x()
2026-05-18 18:30:28 +02:00
logicog 0682df3027 Merge pull request #226 from UAb5eSMn/execute_commands
Support for executing multiple commands via /cmd
2026-05-18 18:29:55 +02:00
René van Dorst 4b40efafbb Fix and refactor is_url_word_x().
With content_type = "application/x-www-form-urlencoded", "+" means space.
This case was not handled.

Also refactor the code to make a loop to process the hex digits.
2026-05-17 21:23:35 +02:00
René van Dorst 02992771ad change is_word_x() return type from char to bool.
Saves 10 bytes.
2026-05-17 21:15:39 +02:00
René van Dorst f81c497728 refactor is_word_x()
Saved 22 bytes.
2026-05-17 21:13:07 +02:00
René van Dorst b46cc2087f change is_word() return type from char to bool.
Saves 52 bytes.
2026-05-17 21:12:57 +02:00
René van Dorst 3904daced7 refactor is_word()
Saved 23 bytes.
2026-05-17 19:14:27 +02:00
René van Dorst 623247da4f httpd: Added extra content_type check for login.
Ensure login content_type is "application/x-www-form-urlencoded".
2026-05-17 17:17:15 +02:00
René van Dorst aa5368cf34 Merge pull request #228 from zectaiga/add-fns1200p
Add support for FOXNEO FNS-1200P (RTL8372, 4x2.5G PoE+ + 2x SFP+)
2026-05-17 11:58:18 +00:00
René van Dorst 2b39d723c7 Merge pull request #225 from orbisai0security/fix-v010-firmware-upload-auth-integrity
fix: authenticate config upload before flash erase and abort failed firmware CRC
2026-05-17 11:52:22 +00:00
Taiga Ogawa f6cb1152f9 Add support for FOXNEO FNS-1200P (RTL8372, 4x2.5G PoE+ + 2x SFP+)
- machine.c/h: add MACHINE_FNS1200P with verified GPIO assignments for
  both SFP ports, LED SET0 (amber 2.5G / green 1G-100M-10M) and SET1
  (SFP all-speeds), led_mux from original firmware register dump, and
  machine_custom_init() enabling LED_GLB_IO_EN bit 6
- doc/devices/FNS-1200P.md: device overview, port layout, serial
  console (S1 three through-holes = UART0 115200 8N1 3.3V),
  LED and SFP GPIO tables
- doc/devices/photos/FNS-1200P/: chassis front panel and PCB top photos
- doc/supported_devices.md: add FNS-1200P to the list

GPIO assignments and LED register values were cross-checked between
live GPIO observation (RTLPlayground gpio command) and an original
firmware register dump.
2026-05-16 17:53:32 +09:00
René van Dorst bf9fa35338 Merge pull request #224 from logicog/fix_passwd
Add URL decoding for password comparison.
2026-05-15 20:04:15 +00:00
logicog 8ab2a6a9da Add URL decoding for password comparison. 2026-05-15 16:04:48 +02:00
UAb5eSMn 2316ffd493 Support for executing multiple commands via /cmd 2026-05-15 13:27:09 +02:00
orbisai0security a71eb57702 fix: V-010 security vulnerability
Automated security fix generated by Orbis Security AI
2026-05-15 02:46:09 +00:00
René van Dorst a2b2dbcfbf Merge pull request #221 from feelfree69/kp9000
Adding Keeplink KP-9000-6XH-X2
2026-05-15 02:08:42 +00:00
feelfree69 8cee16e96b add documentation for KP-9000-6XH-X2.md 2026-05-10 12:20:04 +02:00
feelfree69 a1135863bb add MACHINE_KP_9000_6XH_X2 2026-05-10 12:16:48 +02:00
dobodu ede4137101 Revise compiling section and add cautionary notes since #193 (#211)
* Revise compiling section and add cautionary notes

Updated compiling instructions and added warnings about flashing procedures.

* Refactor caution messages in README.md

Updated caution messages to use new formatting for emphasis.

* Revise caution and reminder notes in README

Updated caution and reminder sections for clarity and consistency.

* Fix typos in README regarding firmware update

Corrected typo errors in the README.

* Add image for advanced settings

Add advanced_seetings.png

* Add advanced settings configuration details to README

Added advanced settings section with configuration instructions.

* Fix image source in README for advanced settings

Corrected the image source filename for advanced settings.

* Revise IP and port command descriptions in README

Updated command descriptions in README for clarity.

* Revise README.md for clarity and updated instructions

Updated sections in README.md for clarity and accuracy, including compiling requirements, installation instructions, and cautionary notes.

* Revise README for clarity and emphasis

Updated formatting and emphasized important notes in the README.

* Correct image file name and compilation output in README

Updated README to reflect changes in image file names and compilation output.
2026-05-08 08:32:07 +02:00
logicog 0106f99ee0 Merge pull request #214 from feelfree69/flash_erase
Erase flash before writing upload image
2026-05-08 08:30:45 +02:00
logicog 733348059d Merge pull request #217 from mcaptur/main
Hi-Source HI-k0801WS - deleted a line by mistake
2026-05-08 08:27:12 +02:00
Mark Captur 950b763d69 Hi-Source HI-k0801WS - deleted a line by mistake 2026-05-08 07:38:43 +02:00
feelfree69 22aaa9fbfe Renamed and moved FLASH_PAGE_SIZE; added compile-time check 2026-05-08 07:13:41 +02:00
logicog 89e22f0893 Merge pull request #216 from mcaptur/main
Add hardware profile and LED fix for Hi-Source HI-k0801WS
2026-05-08 06:40:29 +02:00
Mark Captur 809efaa8d8 Hi-Source HI-k0801WS 2026-05-08 06:11:43 +02:00
Mark Captur 271878a62f Hi-Source HI-k0801WS 2026-05-08 06:09:17 +02:00
Mark Captur 299b54f2a3 Add pics for Hi-Source HI-k0801WS 2026-05-08 06:03:15 +02:00
Mark Captur f47fec7098 Add pics for Hi-Source HI-k0801WS 2026-05-08 06:02:21 +02:00
Mark Captur 04ce2cb8a1 Add doc for Hi-Source HI-k0801WS 2026-05-08 05:53:04 +02:00
Mark Captur 96eddf5a0c Add hardware profile and LED fix for Hi-Source HI-k0801WS 2026-05-07 16:06:00 +02:00
logicog 2cd6f5d782 Merge pull request #212 from feelfree69/make
Makefile: Improve filenames of images
2026-05-04 07:55:54 +02:00
feelfree69 c6dc5cc21c Don't delete *.bin files on 'make clean' - 'make distclean' does this 2026-05-04 07:11:44 +02:00
feelfree69 502033590e untracked files don't mark a build as -dirty 2026-05-04 06:55:11 +02:00