MCPcopy
hub / github.com/google/gopacket / DecodeFromBytes

Method DecodeFromBytes

layers/rmcp.go:111–127  ·  view source on GitHub ↗

DecodeFromBytes makes the layer represent the provided bytes. It partially satisfies DecodingLayer.

(data []byte, df gopacket.DecodeFeedback)

Source from the content-addressed store, hash-verified

109// DecodeFromBytes makes the layer represent the provided bytes. It partially
110// satisfies DecodingLayer.
111func (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.

Callers 2

decodeRMCPFunction · 0.95
TestRMCPDecodeFromBytesFunction · 0.95

Calls 2

RMCPClassTypeAlias · 0.85
SetTruncatedMethod · 0.65

Tested by 1

TestRMCPDecodeFromBytesFunction · 0.76