****************************************************************************** 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)
| 77 | // |
| 78 | // This function is employed in layertypes.go to register the ModbusTCP layer. |
| 79 | func 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 |
nothing calls this directly
no test coverage detected
searching dependent graphs…