1 // Copyright 2012 Google, Inc. All rights reserved.
3 // Use of this source code is governed by a BSD-style license
4 // that can be found in the LICENSE file in the root of the source
11 "github.com/google/gopacket"
14 // EtherIP is the struct for storing RFC 3378 EtherIP packet headers.
21 // LayerType returns gopacket.LayerTypeEtherIP.
22 func (e *EtherIP) LayerType() gopacket.LayerType { return LayerTypeEtherIP }
24 // DecodeFromBytes decodes the given bytes into this layer.
25 func (e *EtherIP) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error {
26 e.Version = data[0] >> 4
27 e.Reserved = binary.BigEndian.Uint16(data[:2]) & 0x0fff
28 e.BaseLayer = BaseLayer{data[:2], data[2:]}
32 // CanDecode returns the set of layer types that this DecodingLayer can decode.
33 func (e *EtherIP) CanDecode() gopacket.LayerClass {
34 return LayerTypeEtherIP
37 // NextLayerType returns the layer type contained by this DecodingLayer.
38 func (e *EtherIP) NextLayerType() gopacket.LayerType {
39 return LayerTypeEthernet
42 func decodeEtherIP(data []byte, p gopacket.PacketBuilder) error {
44 return decodingLayerDecoder(e, data, p)