MCPcopy Index your code
hub / github.com/google/gopacket / decodeModbusTCP

Function decodeModbusTCP

layers/modbustcp.go:79–94  ·  view source on GitHub ↗

****************************************************************************** decodeModbusTCP analyses a byte slice and attempts to decode it as an ModbusTCP record of a TCP packet. If it succeeds, it loads p with information about the packet and returns nil. If it fails, it returns an error (non

(data []byte, p gopacket.PacketBuilder)

Source from the content-addressed store, hash-verified

77//
78// This function is employed in layertypes.go to register the ModbusTCP layer.
79func decodeModbusTCP(data []byte, p gopacket.PacketBuilder) error {
80
81 // Attempt to decode the byte slice.
82 d := &ModbusTCP{}
83 err := d.DecodeFromBytes(data, p)
84 if err != nil {
85 return err
86 }
87 // If the decoding worked, add the layer to the packet and set it
88 // as the application layer too, if there isn't already one.
89 p.AddLayer(d)
90 p.SetApplicationLayer(d)
91
92 return p.NextDecoder(d.NextLayerType())
93
94}
95
96//******************************************************************************
97

Callers

nothing calls this directly

Calls 5

DecodeFromBytesMethod · 0.95
NextLayerTypeMethod · 0.95
AddLayerMethod · 0.65
SetApplicationLayerMethod · 0.65
NextDecoderMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…