ethernet: refactor VLAN API

This commit is contained in:
Patricio Whittingslow
2026-02-18 16:58:52 -03:00
parent bf2d07d9f0
commit 1a07928ca8
3 changed files with 7 additions and 26 deletions
-16
View File
@@ -76,9 +76,6 @@ func (efrm Frame) SetEtherType(v Type) {
binary.BigEndian.PutUint16(efrm.buf[12:14], uint16(v))
}
// VLANTag returns the VLAN tag field following the TPID=0x8100. See [VLANTag]. Call [Frame.ValidateSize] to ensure this function does not panic.
func (efrm Frame) VLANTag() VLANTag { return VLANTag(binary.BigEndian.Uint16(efrm.buf[14:16])) }
// SetVLAN sets following 3 fields:
// - 12:14 ethernet frame type set to constant [TypeVLAN].
// - 14:16 set to VLANTag argument value vt
@@ -97,19 +94,6 @@ func (efrm Frame) VLAN() (VLANTag, Type) {
return VLANTag(vt), Type(et)
}
// SetVLANTag sets the VLAN tag field of the Ethernet Header. See [VLANTag]. Call [Frame.ValidateSize] to ensure this function does not panic.
func (efrm Frame) SetVLANTag(vt VLANTag) { binary.BigEndian.PutUint16(efrm.buf[14:16], uint16(vt)) }
// VLANEtherType returns the [EtherType] for a VLAN ethernet frame (octet position 16). Call [Frame.ValidateSize] to ensure this function does not panic.
func (efrm Frame) VLANEtherType() Type {
return Type(binary.BigEndian.Uint16(efrm.buf[16:18]))
}
// SetVLANEtherType sets the [EtherType] for a VLAN ethernet frame (octet position 16). Call [Frame.ValidateSize] to ensure this function does not panic.
func (efrm Frame) SetVLANEtherType(vt Type) {
binary.BigEndian.PutUint16(efrm.buf[16:18], uint16(vt))
}
// IsVLAN returns true if the SizeOrEtherType is set to the VLAN tag 0x8100. This
// indicates the EthernetHeader is invalid as-is and instead of EtherType the field
// contains the first two octets of a 4 octet 802.1Q VLAN tag. In this case 4 more bytes