Git Product home page Git Product logo

stepfunc / dnp3 Goto Github PK

View Code? Open in Web Editor NEW
106.0 106.0 23.0 4.11 MB

Rust implementation of DNP3 (IEEE 1815) with idiomatic bindings for C, .NET, C++, and Java

Home Page: https://stepfunc.io/products/libraries/dnp3/

License: Other

Rust 80.02% Scala 6.96% CMake 0.10% C 2.19% C# 1.70% Java 1.55% JavaScript 0.41% CSS 0.09% HTML 0.02% TypeScript 0.16% C++ 1.47% MDX 5.33%
c cpp dnp3 dotnet-core java rust tokio-rs

dnp3's People

Contributors

emgre avatar jadamcrain avatar mwaterous avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

dnp3's Issues

consider changing master ffi `Association` from class type to native struct

We should limit the number of class type resources in our APIs whenever possible as they have to be destroyed in C and handled specially in C#/Java.

An association is really just an address token and as far as the ffi is concerned can just be:

struct Association {
   address: u16
}

All of the methods on Association can be moved to Master and take an additional Association argument. A rust association is just a MasterHandle paired with an EndpointAddress anyway:

#[derive(Clone, Debug)]
pub struct AssociationHandle {
    address: EndpointAddress,
    master: MasterHandle,
}

This change will eliminate resource leaks related to not freeing associations. It's much easier for the user to just have to deal with freeing a master or outstation.

replace `log` with `tracing`

Tracing can provide additional context, e.g. each connection can be identified in some way, whereas the log crate has no such info and will make it impossible to correlate logs with sessions without injecting identifiers down into the log calls themselves.

Miscellaneous master parameters (some are non-conformant)

  • Ignore restart IIN
  • Define which classes should be requested in an event scan when detecting corresponding events available IIN
  • Define the time delay before failing a non-recurring task (e.g. commands) that cannot start
  • Index qualifier code optimization (one-byte vs two-byte)

Audit all log statements

With tracing integrated, it's worth going through each log statement in the library to determine if context in the log statement should be moved into a parent span instead.

Logging handler cannot be set more than once

Setting the log handler more than once panics with unable to install tracing subscriber here:

tracing::subscriber::set_global_default(adapter(config, handler))
.expect("unable to install tracing subscriber");

The tracing docs of tracing::subscriber::set_global_default says:

Libraries should NOT call set_global_default()! That will cause conflicts when executables try to set them later.

Custom syntax highlighting colors

Let's customize the syntax colors to be more on-brand:

The default background appears to be the same purplish thing used in the footer.

  • the comment color could stand out a bit more
  • we don't need a separate color for bool/literal, at least we can get rid of the red

image

Custom retry strategy

Add the ability to have a custom reconnection strategy, instead of the hard-coded exponential backoff.

FFI command_result_t

In the FFI, the command callback yields the following enum:

/// @brief Result of a command
typedef enum command_result_t
{
    /// @brief Command was a success
    CommandResult_Success = 0,
    /// @brief Failed b/c of a generic task execution error
    CommandResult_TaskError = 1,
    /// @brief Outstation indicated that a command was not SUCCESS
    CommandResult_BadStatus = 2,
    /// @brief Number of headers in the response doesn't match the number in the request
    CommandResult_HeaderCountMismatch = 3,
    /// @brief Header in the response doesn't match the request
    CommandResult_HeaderTypeMismatch = 4,
    /// @brief Number of objects in one of the headers doesn't match the request
    CommandResult_ObjectCountMismatch = 5,
    /// @brief Value in one of the objects in the response doesn't match the request
    CommandResult_ObjectValueMismatch = 6,
} command_result_t;

Its a little strange that we have 4 different kinds of details about why the device might not respond to a select/operate correctly, i.e. all the header count mismatches, yet there's just a single TaskError. We might consider rolling up all the "mismatch" errors into something like "BadReply".

The TaskError should at least be able to differentiate between "response timeout" and "disconnected".

Audit Rust public API

Preludes:

use dnp3::prelude::*;
use dnp3::prelude::master::*;
use dnp3::prelude::outstation::*;

Also, move entry functions to master and outstation modules.

Also add all missing public Rustdoc

Configure the bubbling of errors at the transport level

Parameterize the link layer parser so that it bubbles up or swallows framing errors. TCP/TLS should bubble up errors and close the stream by default, but it shouldn't be hard coded by channel type (except for perhaps serial) b/c of the use of terminal servers which can convert serial to IP.

This was noted in #35 but wasn't implemented in it.

Performance benchmark

Add performance benchmark where a set of masters communicate with an outstation as fast as possible using criterion to collect statistics.

Infinite loop when receiving unknown data type

When connecting the dnp3rs master to the OpenDNP3 outstation example, the startup integrity poll fails because it does not expect g50v4 (see #10) in the response, and then retries it immediatly. It creates a loop of request/response. Perhaps it should wait a couple of seconds before retrying that integrity poll.

Add serial support

Also, parameterize the link layer parser so that it bubbles up or swallows framing errors. TCP/TLS should bubble up errors and close the stream by default, but it shouldn't be hard coded by channel type (except for perhaps serial) b/c of the use of terminal servers which can convert serial to IP.

Custom footer layout

Let's get rid of the purple background and replace with something on-brand. I think the footer is an opportunity to integrate one of our nice illustration, perhaps with animation.

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.