Skip to content

nblair2/go-dnp3

Repository files navigation

go-dnp3

GoDoc Go Version License

DNP3 parsing in go.

  • FromBytes([]byte) to parse a byte slice and interpret it as DNP3
  • ToBytes() to go from a struct back to bytes (calculates length, calculates and inserts CRCs on the way)
  • String() to get packet as human-readable indented string (Reserved and CRCs not shown)
  • json.Marshal(DNP3) to get packet as machine-friendly

Improvements

  • accept interfaces, return structs
  • consistency on plural / singular of bits / bit and bytes / byte. Functions and attributes should be named based on what they actually are, and be as small as possible
  • errors always available / checked in FromBytes and ToBytes methods. Should buble these up but not fail if possible.
  • re-write a generic Point called PointBytes with flags and all possible fields (Prefix, Flags, AbsTime, RelTime) rather than the many different types we have now
  • clean up the the String method so we aren't always appending newlines, these should be the responsibility of the caller
  • consolidate the 3 different massive switch statements for Group / Variation into one
  • Events / Quality, Prefix parsing
  • DIR field / PRM

Test

Run go test ./dnp3 -v to check a few different DNP3 messages. You can also use the -args -pcaps=opendnp3_test1.pcap argument to pass in a full PCAP. Data taken from opendnp3 conformance reports.

Spec

I don't have access to the DNP3 spec, so working off of Wireshark's Parser and odd PDFs I find around the web (one)

About

DNP3 layer for gopacket

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages