From f36baf9897bb3651aa4c9c04b5c3032444b6346e Mon Sep 17 00:00:00 2001 From: Paolo Invernizzi Date: Sat, 20 Jul 2024 19:05:21 +0200 Subject: [PATCH] Add EtherType method --- protocols/eth.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/protocols/eth.go b/protocols/eth.go index c512cac..211837a 100644 --- a/protocols/eth.go +++ b/protocols/eth.go @@ -41,9 +41,11 @@ func EthFrameFromBytes(raw []byte) (*EthernetFrame, error) { }, nil } -// Info returns an human-readable string containing all the ETH frame data -func (f *EthernetFrame) Info() string { - etv := etherTypesValues[f.etherType] +func (f EthernetFrame) EtherType() string { + return etherTypesValues[f.etherType] +} - return fmt.Sprintf("%s Ethernet Frame from MAC %s to MAC %s", etv, f.sourceMAC, f.destinationMAC) +// Info returns an human-readable string containing all the ETH frame data +func (f EthernetFrame) Info() string { + return fmt.Sprintf("%s Ethernet Frame from MAC %s to MAC %s", f.EtherType(), f.sourceMAC, f.destinationMAC) }