The library implements frame serialization/deserialization in pure Go. The list of the supported Ethernet standards:
See the *_test.go
files.
dstAddr := ethernet.NewHardwareAddr(0x8C, 0x8E, 0xC4, 0xFF, 0x9E, 0xA2)
srcAddr := ethernet.NewHardwareAddr(0x8C, 0x8E, 0xC4, 0xAA, 0x4E, 0xF1)
f := ethernet.NewFrame(srcAddr, dst, []byte("Hello :)"))
f.SetTag8021q(ðernet.Tag8021q{Tpid: 0x8100, Tci: ethernet.Encode8021qTci(3, 0, 1024)})
b := f.Marshal()
b := f.Marshal()
var f Frame
err := ethernet.Unmarshal(b, &f)
if err != nil {
panic(err)
}
pcp, dei, vlan := ethernet.Decode8021qTci(f.Tag8021q().Tci)
fmt.Println("PCP:", pcp)
fmt.Println("DEI:", dei)
fmt.Println("VLAN ID:", vlan)
fmt.Println("EtherType:", f.EtherType())
fmt.Println("Checksum (FCS):", f.FCS())