MCPcopy Create free account
hub / github.com/Edgio/vflow / decodeIEEE802

Function decodeIEEE802

packet/ethernet.go:99–116  ·  view source on GitHub ↗
(b []byte)

Source from the content-addressed store, hash-verified

97}
98
99func decodeIEEE802(b []byte) (Datalink, error) {
100 var d Datalink
101
102 if len(b) < 14 {
103 return d, errShortEthernetLength
104 }
105
106 d.EtherType = uint16(b[13]) | uint16(b[12])<<8
107
108 hwAddrFmt := "%0.2x:%0.2x:%0.2x:%0.2x:%0.2x:%0.2x"
109
110 if d.EtherType != EtherTypeIEEE8021Q {
111 d.DstMAC = fmt.Sprintf(hwAddrFmt, b[0], b[1], b[2], b[3], b[4], b[5])
112 d.SrcMAC = fmt.Sprintf(hwAddrFmt, b[6], b[7], b[8], b[9], b[10], b[11])
113 }
114
115 return d, nil
116}

Callers 2

decodeEthernetMethod · 0.85
TestDecodeIEEE802Function · 0.85

Calls

no outgoing calls

Tested by 1

TestDecodeIEEE802Function · 0.68