DNP3 Source Code Library

Our ANSI C source code library provides a quick and cost effective way to implement a DNP3 master or outstation.  A .NET component version is also available. 

For almost 30 years, Triangle has provided the diagnostic tools and protocol expertise to  our customers to support all their conformance  & certification needs. We will work with you to ensure that your implementation of our source code libraries will pass all industry related certification and conformance testing.

Related Products

What's New

Current Release: v3.32.0
Release Date:  March 2024

Newest Features in this Release

  • In WinIoTarg improvements to UDP/TCP receiving will avoid errors if the UDP broadcast message received in middle of the TCP octets.
  • Added TCP channel callback functions to retrieve IP addresses when the server is connected or disconnected.

  • Channels are no longer closed automatically when the last session on the channel is closed.

  • In WinIoTarg, added a channel diagnostic mask bit to control whether diagnostics messages are generated.

  • In LinIoTarg improvements to use linked list instead of array for keep channels listening on a particular port. That improvement will allow unlimited channels be configured to one specific TCP port.
  • MDNPResponseParser capture authChallengeData for g120v9 response.

  • In WinIoTarg, if the TCP listening thread is not started due to the port being occupied, the channel is now closed more quickly (previously could take up to 5 seconds).

 

Key Additions to Recent Releases

v3.31

  • "Slave" has been replaced by "Outstation", "Controlled Station", or "Server" depending on protocol in documentation, filenames, variable names, and function names. An effort has been made to maintain interface backward compatibility where possible.

  • Minor changes to allow SCL to build with VS2019 and VS2022 without modifications related to std::string and .NET Framework version.

  • Added support for OpenSSL Version 3.x.x. Open SSL Version 1.1.1 is still supported, however, according to openssl.org the End of Life date for the 1.1.1 series is September 11, 2023. Support for Version 1.0.2 has been removed.

  • In WinloTarg and LinLoTarg improvements to UDP functionality including Listen Mask and Range of Addresses Support as well as changes to isolate the differences between IPV4 and IPV6 handling. 

  • In WinloTarg and Linlo Targ add clientSourceIpPort to allow TCP Client Channels to specify the IP Port to use for orignating TCP Connections. 

  • Add support for TMWDIAG_ID_OCTETS but to determine whether the actual HEX Octets from a transmitted or received message are formatted and/or displayed in a diagnostic message.

  • Clean up some header comments in mdnpdata.h and sdnpdata.h so that they can be better parsed by customer software. 

  • Include DNP MasterDatasets and DNPOutstationDatasets example application source code.

  • In WinloTarg and LinloTarg added ability to configure DNP Outstation to provide both TCP Server and UDP Request/Responses. This allows an Outstation to be configured to receive TCP connections OR to act as a UDP-ONLY outstation. It will respond to TCP requests over TCP and respond to UDP (non-broadcast) requests over UDP. This functionality was described and tested in DNP3 IED Certification Procedure Version 3.1 April 2022 and removed in a later version. 

  • If the TCP listening thread is not started due to the port is occupied, it might take up to 5 seconds to close the channel. That has been improved in this release.

  • Clena up some header comments in mdnpdata and sdnpdata.h so that they can be better parsed by customer software. 

  • Correct some “SUPPORT” #defines in sdnpdata.h to indicate the correct DNP3 Level for some Object/Variations. Changes were made to SDNPDATA_CNFG_SUPPORT_DOUBLE, SDNPDATA_SUPPORT_OBJ10_V1 and V2, SDNPDATA_SUPPORT_OBJ12_V3 and V5.and SDNPDATA_SUPPORT_OBJ21_v6.
    Double Precision Floating Point variations are beyond Level 4 and therefore now dependent on (SDNPDATA_CNFG_LEVEL_TMW && TMWCNFG_SUPPORT_DOUBLE).

  • Generate Binary Output and Analog Output Command Events on both success or failure if sendCommandEvent is configured for the SDNP Session.

  • Added support for sdnpdata_xxxOutSelect and sdnpdata_xxxOutOperate to return status PROCESSING for slow commands to allow SCL to perform other processing. In particular for a gateway implementation, it will allow commands to be forwarded downstream and responses processed. It also allows a channel supporting multiple sessions to process requests for other sessions while the command is still processing. DNP3 allows only a single command per association/session at a time to be in progress.

v3.30

  • In LinIoTarg speed up processing during TCP Channel closing.

  • In LinIoTarg function call to deprecated pthread_mutexattr_setkind_np() has been replaced with a call to pthread_mutexattr_settype().

  • Add support for multiple Polled Timers and disabling the Windows Target Layer multiple timers to allow application to run SCL in the context of its own threads.

  • Secure Authentication. Improve tmwcrypto.c support for multiple sessions when Simulated Crypto Database is being used during initial portation.

  • .NET Secure Authentication. Improve tmwcrypto.c TMWCRYPTO_ASYMTESTING if compiled in so that sample asymmetric key files can be found.

  • MDNP display a better diagnostic message if response contains an unsupported Object Group.
  • Improve diagnostic messages when control requests fail, making it clear the status value received in the request and the status value sent in the response.
  • .NET SCL. Improve SDNPSimPoint LocalMode Property performance.

  • .NET SCL. Add AssocPoint property to SDNPSimBinOut and SDNPSimAnlgOut which when set will cause the associated input point value to change when a control from Master changes the output value.

v3.29

  • Added new functionality to send a request message to remove static objects from
    class 0 assignment according to TB2021-001.

  • Discard a fragment that contains group 2 or 4 variation 3 (relative time) if it is not
    preceded in that same fragment by a Common Time Object 51 according to
    TB2018-001.

  • When a binary or double-bit input event is generated and the time is
    invalid/unsynchronized send variation 3 instead of variation 2 according to TB2017-
    003a.

  • Add support to allow responses for counters and analogs to optionally switch
    variation to indicate the precision supported for each point even when a specific
    non-zero variation is requested.

  • Add configuration to SDNP Session to allow events to be sorted by timestamp as
    they were in the past and not by the order they are added to the event queue as is
    now required by TB2018-001.

  • In WinIoTarg add define to allow channel thread code to be compiled out.

  • Improved TLS example code and included sample TLS Certificates for ANSI C and
    .NET SCLs.

  • Added Object 50 Variation 4 Indexed Absolute time and long interval to Device
    Profile.

  • Combine Binary Input and Double-bit Input event objects into a single internal
    queue to better support the User Managed Event code to sort these together by
    when they occur.

  • Added configuration options and example code to disable or restrict File Transfer
    functionality at run time when File Transfer functionality is compiled in.

  • Reduce default compiled in features and functionality to Level 3 for ANSI C and
    .NET SDNP SCL. All functionality must be carefully chosen, tested and then
    documented in the Device Profile specific to your device. The .NET SDNP SCL will
    now have the same default functionality compiled in as the ANSI C SCL. The file
    tmwprvt.h will no longer be provided to turn on additional .NET functionality.



v3.28

  • In WinIoTarg potentially speed up waiting for a channel thread to exit when a
    channel with polledMode=false is closed.
  • In WinIoTarg improved diagnostics when configured for UDP-Only mode.
  • In LinIoTarg replaced deprecated stime() with clock_settime().
  • In LinIoTarg speed up new connection indication to protocol library when running
    with polledMode=true.
  • Enhance Big/Little Endian code in tmwtarg.c to support 64 bit IEEE 754 Double
    Floating Point conversion as was previously done for other data types without
    customer intervention.
  • Added diagnostic information for CROB and Analog Output Controls to show points
    and values sent by MDNP.
  • Added support for Object Group 50 Variation 4 Indexed Absolute Time and Long
    Interval read and write.
  • Enhanced MDNP SCL to support file transfer target layer interface even when simulated database is compiled out.
  • Enhanced MDNP SA SCL to reset the CSQ to zero when the master detects the
    Outstation is restarted. While not in the specification it allows the AES-GMAC
    algorithm if configured to continue to work properly over an Outstation restart.
  • Corrected MDNP SA issue when trying to send a g120v13 Update Key Change
    request the User Update Key cannot be retrieved the library could display more
    data in a diagnostic message than actually exists in the buffer.
  • Moved .NET rxLinkHdrCallbackEvent and rxTransportCallbackEvent from
    TMWChannel.h to DNPChannel.h since those two events only apply to DNP
    channels.
  • IED Certification Procedure Version 3.0 released in December 2020 specified new behavior for a response to a read request of a supported data type such as Binary Input that currently has no points in the database. The SDNP library will now reply with a NULL Response with Error IIN bits set. Previously it was considered optional to set the Error IIN bits.
  • IED Certification Procedure Version 3.0 added tests for devices that do not have a
    valid timestamp to support events with time variations. Normally, for SDNP you
    would compile out support for the events with time variations. However, to better
    allow the events with time variation support to be compiled in but in some instances
    not have a clock to provide timestamps; Added supportEventsWithTime
    configuration to SDNP defaulting to true. If false SDNP will send without time
    variations for events when events with time variations are requested. A timestamp
    of Jan 1 1970 can be passed to sdnpxxx_addEvent and will not be sent over DNP.

v3.27.1

  • Changed “configuration signature” to “configuration digest” for default Device
    Attribute Object 0 Variations 200 and 201 as directed by TB2013-004b. Affects
    Diagnostics and #defines only.
  • In LinIoTarg use localIpAddress when a TCP Client binds to the connect socket.
  • Allow “::” in addition to “*.*.*.*” for the IPV6 Ip Address to indicate that ANY MDNP
    device may connect to this channel.
  • Added session configuration unsolOfflineDelayOnce to allow
    unsolOfflineRetryDelay to be used once and then to revert back to unsolRetryDelay
    until the next time the retry count is exceeded.
  • Allow compile time code that can be configured per session to allow read requests
    between select operate requests. This is not compliant with the DNP Specification
    and would fail DNP Conformance tests. However, it was required for certain
    gateway customers to allow DNP Masters that don’t follow the rules.
  • Changed “configuration signature” to “configuration digest” for default Device
    Attribute Object 0 Variations 200 and 201 as directed by TB2013-004b. Affects
    Diagnostics and #defines only.
  • If file name is longer than configured maximum DNPCNFG_MAX_FILENAME, stop
    parsing the request sending an error response to the Master. Using a truncated
    filename should not work and it could access a different file than intended.
  • In LinIoTarg use localIpAddress when a TCP Client binds to the connect socket.

v3.26.00:

  • Decrement unsolicited pending count of events for an event class when an event is
    removed from the event queue because of event mode or other reasons. 
  • Improved the sDNP SA example to show authority interaction and asymmetric key
    change methods. Enhanced tmwcrypto simulated crypto database to support
    multiple sessions and sectors to make it clear what configuration in the exampe
    code applies only to the simulated crypto database and is not used by the SCLs. 
  • Changed “configuration signature” to “configuration digest” for default Device
    Attribute Object 0 Variations 200 and 201 as directed by TB2013-004b. Affects
    sDNP simulated database description. 
  • Added virtual terminal and string point names to the generated sDNP Device Profile
    current values.
  • Add any missing pChannel and pSession to DNPDIAG_ERROR where they are
    available.
  • Created additional SDNP example, sdnpDer implementing DER Application Note
    2018-001 DNP3 Profile for Communications with Distributed Energy Resources
    DERs). This serves as a starting point for developing DER devices that use DNP.

v3.25.00:

  • Created an implementation guide for SCLs.  
  • Added support DNP File Transfer in Simulated Database for Linux.  The target layers for Linux and Windows have been updated to include File I/O functions to support DNP. They reside in mdnptarg.c and sdnptarg.c with their common prototypes defined in dnp/mdnptarg.h and dnp/sdnptarg.h. sdnpdata.c have been updated to call these functions to support file operations even when the simulated database is not enabled.   
  • Support for Freeze and Freeze at Time FC 11 and 12 with obj50v2 has been implemented. The Device Profile has been updated to show support for these. 
  • Added session configuration parameter unsolSendByClass. When set to true, only unsolicited events for the class whose timer expires or count is exceeded will be sent. Otherwise, unsolicited events for all classes will be sent. 
  • Support User Managed Events for g33, g115, g120, and g122 events.
  • Support for start-stop qualifiers has been added to write operations for Object Groups 34, 110, & 114 and the Device Profiles updated accordingly. 
  • Better support for optional the g120v7 event on another DNP Association with optional error text that does not fit in current or any response fragment.
  • Generate a session statistic when a Link Status Request is received. 
  • Provide tmwcrypto_verifyUserCertificate function using OpenSSL to verify received X.509 Certificate.
  • The SCL sample target layers now support a common serial configuration structure.
  • The SCL has been updated to work with OpenSSL 1.1.x while retaining backward compatibility with version 1.0.x. For Windows builds a new define has been added, TMWCNFG_USE_OPENSSL_1_0_2 that should be defined when running with the legacy version. 
  • Added event driven receive data support for Windows serial channel. 
  • WinIoTarg now uses the Channel thread to check for received data eliminating the need for a separate CheckForInput thread/class. 
  • The wintoolkit samples now include TLS support. The samples include certificates that are compatible with those used by the Test Harness and the default configurations for both Linux and Windows are set to use them. Only a single define USE_TLS which defaults to false needs to be updated to configure the sample to use TLS for both DNP and 101/4 Secure Authentication builds. 
  • Updated Linux target layer to use consistent logging technique
  • Added TLS support to the Linux target layer.
  • LinIoTarg now creates a thread per channel (when not configured to run in polled mode). Once the channel has been opened, this thread will establish/listen for the channel connection and wait on the data socket for incoming data. This eliminates the latency when polling for received data. Also, locking has been reduced by eliminating the linked list of TCP Channels which required locking each time the list was accessed. 
  • Updated linTCP_transmit to check the error code returned by send. If its EAGAIN indicating that the socket is busy, wait for the socket to become writable and retry the send instead of disconnecting immediately. 
  • The Linux target layer has been updated to provide a basis for porting a target layer to another OS: 

    • The dependency on threads has been removed.
    • The Linux target layer will conditionally support poll and select. The Linux target layer will default to use epoll/poll which is more efficient than select and correctly handles file descriptors greater than 1024. However, select will continue to be supported by using a conditional so that it can be tested with Linux and provide a porting example for OS's that only support select.
    • A tmwtargcnfg.h file has been added to both the Linux and Windows target layer implementations. This configuration file defines which features a given target layer supports. This will allow customers porting the Linux target layer to other OS's to easily identify code that may be unnecessary for their application and remove it instead of wasting time porting it. Target layer features currently defined in this file are:
    1. RS232
    2. TCP
    3. UDP (Only required for DNP)
    4. TLS
    5. EPOLL

  • In addition, SampleIoTarg has been created. This Sample target layer is a target layer example that can be compiled and linked with the wintoolkit C example programs that has no OS dependencies. It can be used as a baseline target layer to help port the library to another OS or RTOS.  It can be built by specifying build=sample from the Linux command line.

v3.24.00:
  • Implement DNP String and Vterm changes spelled out in TB2015-001 including adding support for Extended String Object Groups 114 & 115.
  • Support for Frozen Analog Input Event Object Groups 31 and 33 has been added.
  • Modified handle in .NET libraries to be an IntPtr to avoid warnings with 64 bit build and to provide better 64 bit functionality.
  • Made improvements to target layer timer examples.
  • Implemented event driven receive data in winiotarg so channels don’t have to be polled. This is also available in liniotarg.
  • Updated the Linux target layer, replaced LINIOCNFG_EVENT_DRIVEN conditional with polledMode configuration.
  • Made improvements to target layer timer examples.
  • Implemented event driven receive data in winiotarg so channels don’t have to be polled. This is also available in liniotarg.
  • Updated the Linux target layer, replaced LINIOCNFG_EVENT_DRIVEN conditional.
  • Support for epoll has been added to the Linux target layer. This support is controlled by the preprocessor conditional LINIOTARG_SUPPORT_EPOLL. If this is not defined, select is used. The select option has been left in place so we continue to have an example that can be ported to OS’s that do not support epoll.
  • Added configuration to sDNP SCL to disable sending the initial Null Unsolicited Response (UR) at startup and therefore not require it to be application confirmed by the master. This is non-standard behavior differs from the DNP specification, but facilitates interoperability with a non-compliant master that does not process the Initial Null UR correctly, but does handle subsequent URs containing DNP events.
  • Improved sDNP user manual and sample code with respect to event generation. Updated slave examples to include add event for DNP, 101,102, 103, and 104.
  • Include files to allow SCL customers to generate Windows project files for different versions of Visual Studio.
  • Support for 64-bit versions of the .NET Protocol Components has been added.
  • Added configuration for the generation of diagnostic messages per sector, session, and channel to allow maximum flexibility. Maximum performance can be achieved by configuring each mask to zero so no diagnostic messages are generated, thus no messages would be forwarded to the .NET code. This also would allow a user to enable diagnostic messages on a single sector, session, etc. in a large configuration on a problem connection and avoid having to filter out diagnostic messages from all other connections.

v3.23.00:

  • Added support for TLS v1.2 in the Windows target layer
  • Included support for 64 bit builds in the example project and solution files provided for Visual Studio
  • Updated Device Profile Current Values section for Outstations to schema Version 2.11 April 2016
  • Added x.509 certificates and support for DNP Secure Authentication g120v8 requests
  • Updated simulated database for Outstation example to support DNP Technical Bulletin TB2017-001 Supervisory Mode
  • Resolved warnings when compiling on Linux with strict checking turned on
  • Improved Secure Authentication Version 2 to better support the expiration and updating of User Session Keys (in the same way as described in the SAv5 specification) 
  • Added capability in Master to notify the application via a callback if commands or secure authentication requests time out
  • Improved the algorithm in the Master for managing multiple sessions in a single channel
  • Several other enhancements (see release notes)
v3.22.00:
  • Improved performance of database interface and other library functions
  • Restructured directories and sample code for Windows and Linux target layer libraries
  • Added support for IPv6 in Linux target layer
  • Expanded Windows target layer support for resolving IP address from destination host name
  • Updated Linux sample makefiles to generate debug information by default
  • Added multiple enhancements to Secure Authentication library and documentation

v3.21

  • Improved Linux® makefiles and Windows® solution and project files
  • Improved integration with OpenSSL library
  • Added parsing of Object 91 response for DNP3 Master
  • Added GetRxBuf() method for DNP3 Master so that application can view the entire received message
  • Added capability to configure use of Aggressive Mode for Secure Authentication critical functions launched from the “Auto Request Mask” for DNP3 Master 
  • Added capability for DNP3 channel to skip offline sessions for specified amount of time
  • Several improvements to DNP3 Secure Authentication
  • Improved DNP3 Dual End Point mode

v3.20.00:
  • Implemented several improvements to DNP3 Secure Authentication including all items suggested in TB2016-002, addressing some deficiencies in DNP3-SAv5
  • Added a configurable feature that would allow the user to issue two separate BRM commands, holding off other automatic behavior
  • Added statistic indicating Link Status was received
  • Made improvements to DNP3 Device Profile

v3.19.00:
  • Added support for Assign Class Function Code for Virtual Terminal object group
  • Added Session Statistic event to indicate a Link Status response is received
  • Added configuration to disable default behavior required on TCP by the DNP specification to disconnect and reconnect when a link status request times out
  • Modified code to allow use of either UNICODE or MBCS character set

v3.18.00:
  • Updated the DNP3 libraries to include DNP3 Device Profile November 2014 version 2.10
  • Improved the handling of DNP messages with the wrong link address
  • DNP Secure Authentication improvements including a configurable 4-32 byte challenge data object, a new device attribute for the version of Secure Authentication that is supported by the Outstation, corrected session statistics, and improved aggressive mode support
  • Exposed DNP Unsolicited class mask for .NET components (propertyUnsolnitialClassMask)
  • Added multiple new DNP3 device attributes in the default simulated database
  • Improved support of Linux® networking layer for UDP
  • Added ability to disable function codes for device specific addresses as described in AN2014-001
  • Implemented DNP device attribute time type described in TB2013-004
  • Updated the code to use C99 standard types for 16 bit and 32 bit types for improved Linux® implementations
  • Improved handling of unsolicited messages under special cases
  • Improved support of DNP3 points set to local mode

v3.17.00:
  • Additional support for DNP3 device profile, including secure authentication, control broadcast configuration, and other fields
  • Added cryptography interface for Secure Authentication V2 (the Library already has this interface for SAv5)
  • Enhanced the tolerance for restart in Master and Outstation with Secure Authentication, including initialization of keys
  • Added compile time choice of using either standard or Microsoft “safe” string functions that include the length of the buffer to be written to (ie strcpy or strcpy_s)
  • Added more checking to discard improperly formatted messages

v3.16.01 - Corrected an issue where DNP3 transport layer would reject a message 

v3.16.00:
  • Addressed all items associated with ICS-CERT Advisory (ICSA-13-240-01)
  • Improved input verification
  • Made improvements to DNP3 Secure Authentication interface
  • Enhanced Assign Class functions
  • Added configuration option to disable support for receiving broadcast messages

v3.14 - Enhanced DNP3 SAv5 implementation

v3.07 - Added sample Linux® and Windows® target implementation

v3.05.01 - Added updates to DNP3 SA approved by DNP3 TC

v3.01.01 - Added ability to keep time on a per-session basis

v3.01.00 - Added support for DNP3 SAv2

v3.00.44 - Updates to Data Sets

v3.00.43 - Added support for Data Sets and Object 0 (Device Description)

v3.00.38 - Added support for Double Bit data types and Self Address Discovery mechanism

v3.00.36 - Added support for File Transfer Event Mode

v3.00.35 - Added memory alignment support

v3.00.32 - Added support for multiple threads


 

 TMWLogo

 
Quick Links  Contact Us:
Home
Products
Videos
Training
Support
Reference
About Us

Triangle MicroWorks, Inc.
Sales: +1 919.870.5101
Support: +1 919.781.1931
Fax: +1 919.870.6692
sales@TriangleMicroWorks.com
support@TriangleMicroWorks.com

Follow us on YouTube Follow us on Facebook Visit us on LinkedIn Follow us on Twitter

 
Copyright © 2013-2024 Triangle MicroWorks, Inc. All Rights Reserved