Skip to content

nblair2/go-dnp3

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-dnp3

GoDoc Go Version License

go-dnp3 is a Go library for parsing and encoding DNP3 (Distributed Network Protocol) frames.

DNP3 Gopher

Usage

  • Parsing: Use FromBytes([]byte) to parse raw byte slices into structured DNP3 objects.
  • Encoding: Use ToBytes() to serialize structs back into bytes. This automatically handles length calculations and inserts CRCs on the fly.
  • Inspection: Use String() to generate human-readable, indented string representations of packets (excluds reserved fields and CRCs).
  • Serialization: Full support for json.Marshal() to convert packets into machine-friendly JSON formats.

Development

Setup

Run make setup to install development tools used by this repository.

Testing

Data for tests is sourced from opendnp3 conformance reports

Run make test to run basic tests.

PCAP Testing

Pass a full PCAP file using the -args option -pcaps=comma.pcap,delimited.pcap,list.pcap.

go test ./dnp3 -v -args -pcaps=my-custom.pcap

Printing Strings

View the string and json outputs of test cases using the -args flag -print-string and -print-json.

go test ./dnp3 -args -print

Linting

golangci-lint is used for lint and format checking. Run make lint to check for errors, and make fix to try to automatically fix linting or formatting errors.

Implementation

Based on Wireshark's parser and publicly available documents (such as this validation guide), as access to the official DNP3 specification is restricted.

About

DNP3 layer for gopacket

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages