DecodeFromBytes makes the layer represent the provided bytes. It partially satisfies DecodingLayer.
(data []byte, df gopacket.DecodeFeedback)
| 109 | // DecodeFromBytes makes the layer represent the provided bytes. It partially |
| 110 | // satisfies DecodingLayer. |
| 111 | func (r *RMCP) DecodeFromBytes(data []byte, df gopacket.DecodeFeedback) error { |
| 112 | if len(data) < 4 { |
| 113 | df.SetTruncated() |
| 114 | return fmt.Errorf("invalid RMCP header, length %v less than 4", |
| 115 | len(data)) |
| 116 | } |
| 117 | |
| 118 | r.BaseLayer.Contents = data[:4] |
| 119 | r.BaseLayer.Payload = data[4:] |
| 120 | |
| 121 | r.Version = uint8(data[0]) |
| 122 | // 1 byte reserved |
| 123 | r.Sequence = uint8(data[2]) |
| 124 | r.Ack = data[3]&RMCPAck != 0 |
| 125 | r.Class = RMCPClass(data[3] & 0xF) |
| 126 | return nil |
| 127 | } |
| 128 | |
| 129 | // NextLayerType returns the data layer of this RMCP layer. This partially |
| 130 | // satisfies DecodingLayer. |