diff --git a/src/core/operations/ParseEthernetFrame.mjs b/src/core/operations/ParseEthernetFrame.mjs index 9dac5d57..0be5e1a4 100644 --- a/src/core/operations/ParseEthernetFrame.mjs +++ b/src/core/operations/ParseEthernetFrame.mjs @@ -74,17 +74,14 @@ class ParseEthernetFrame extends Operation { const ethType = Utils.byteArrayToChars(input.slice(offset, offset+2)); offset += 2; - - if (ethType === "\x08\x00") { - break; - } else if (ethType === "\x81\x00" || ethType === "\x88\xA8") { + if (ethType === "\x81\x00" || ethType === "\x88\xA8") { // Parse the VLAN tag: // [0000] 0000 0000 0000 // ^^^ PRIO - Ignored // ^ DEI - Ignored // ^^^^ ^^^^ ^^^^ VLAN ID - const vlanTag = input.slice(offset+2, offset+4); - vlans.push((vlanTag[0] & 0b00001111) << 4 | vlanTag[1]); + const vlanTag = input.slice(offset, offset+2); + vlans.push(((vlanTag[0] & 0b00001111) << 8) | vlanTag[1]); offset += 2; } else { diff --git a/tests/operations/tests/ParseEthernetFrame.mjs b/tests/operations/tests/ParseEthernetFrame.mjs index c849e207..063255ed 100644 --- a/tests/operations/tests/ParseEthernetFrame.mjs +++ b/tests/operations/tests/ParseEthernetFrame.mjs @@ -23,7 +23,7 @@ TestRegister.addTests([ { name: "Parse Ethernet frame with one VLAN tag (802.1q)", input: "01000ccdcdd00013c3dfae188100a0760165aaaa", - expectedOutput: "Source MAC: 00:13:c3:df:ae:18\nDestination MAC: 01:00:0c:cd:cd:d0\nVLAN: 117\nData:\naa aa", + expectedOutput: "Source MAC: 00:13:c3:df:ae:18\nDestination MAC: 01:00:0c:cd:cd:d0\nVLAN: 118\nData:\naa aa", recipeConfig: [ { "op": "Parse Ethernet frame", @@ -34,7 +34,7 @@ TestRegister.addTests([ { name: "Parse Ethernet frame with two VLAN tags (802.1ad)", input: "0019aa7de688002155c8f13c810000d18100001408004500", - expectedOutput: "Source MAC: 00:21:55:c8:f1:3c\nDestination MAC: 00:19:aa:7d:e6:88\nVLAN: 16, 128\nData:\n45 00", + expectedOutput: "Source MAC: 00:21:55:c8:f1:3c\nDestination MAC: 00:19:aa:7d:e6:88\nVLAN: 209, 20\nData:\n45 00", recipeConfig: [ { "op": "Parse Ethernet frame",