mirror of
https://github.com/gchq/CyberChef.git
synced 2026-04-11 00:31:08 -07:00
ParseEthernetFrame - Fix vlan calculation (#2295)
This commit is contained in:
parent
b0fa1f8d1b
commit
6aa98b4a66
2 changed files with 5 additions and 8 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue