lib60870-sys
Raw FFI bindings to lib60870-C, an IEC 60870-5-101/104 protocol implementation.
This is a -sys crate that provides low-level, unsafe bindings to the C library. For a safe, idiomatic Rust API, consider using the lib60870 crate.
Features
- Raw FFI bindings - Direct access to all lib60870-C functions
Platform Support
| Platform | Status |
|---|---|
| Linux | ✅ Fully supported |
| macOS | ✅ Fully supported |
| Windows | ⚠️ Experimental (build works, runtime issues) |
Note: Windows support is experimental. The library compiles successfully but may have runtime issues related to DLL dependencies. Contributions to improve Windows support are welcome!
Usage
Add this to your Cargo.toml:
[]
= "0.4"
# With TLS support:
= { = "0.4", = ["tls"] }
Example
use *;
use CString;
Run the example:
Safety: All functions in this crate are
unsafebecause they directly call C code. Users must ensure proper memory management, null pointer handling, and correct C string formatting.
Cargo Features
| Feature | Description |
|---|---|
tls |
Enable TLS support (downloads mbedtls 2.28) |
debug |
Enable printf debug output |
no-threads |
Disable threading (for embedded systems) |
tcp-keepalive |
Enable TCP keep-alive |
How the Build Works
The build script (build.rs) automatically:
- Downloads lib60870 v2.3.6 from GitHub releases
- Downloads mbedtls v2.28.9 (only if
tlsfeature is enabled) - Compiles with CMake - builds the static library
- Generates Rust bindings with bindgen
All downloads are cached in target/ so subsequent builds are fast.
Pre-generated Bindings
For docs.rs and environments without network access, this crate includes pre-generated bindings in src/bindings_pregenerated.rs. These are used automatically when building with the docsrs cfg flag.
Building from Source
Requirements:
- Rust 1.70 or later
- CMake 3.10 or later
- C compiler (GCC, Clang, or MSVC)
- Internet connection (for first build only)
License
lib60870-C is dual-licensed under GPLv3 and a commercial license. This crate inherits the GPL-3.0 license. See the lib60870 repository for commercial licensing options.