Skip to content

Multiple changes#39

Draft
jogibear9988 wants to merge 55 commits into
thomas-v2:masterfrom
dotnetprojects:master
Draft

Multiple changes#39
jogibear9988 wants to merge 55 commits into
thomas-v2:masterfrom
dotnetprojects:master

Conversation

@jogibear9988

Copy link
Copy Markdown
  • switch to new csproj file format.
  • create a version for net472 and net8
  • automaticly load correct openssl dll
  • switch to ne solution file format (slnx)

@jogibear9988

Copy link
Copy Markdown
Author

Maybe the switch to slnx is a little bit early and should not be done yet, I need to look if building with dotnet command is already possible atm.
I'm also looking to generate a build pipline wich would automaticly create a nuget package. Would this be okay, or do you not want this?

@jogibear9988

Copy link
Copy Markdown
Author

I also added your fix in zlib to cinderblocks/zlib.net#5
So the nuget here: https://www.nuget.org/packages/zlib.net-mutliplatform/1.0.7 could be used (when it is merged)

@thomas-v2

Copy link
Copy Markdown
Owner

I can't use .Net Core, and I have to stay at Visual Studio 2019 for some reason.

@thomas-v2

thomas-v2 commented Aug 22, 2024

Copy link
Copy Markdown
Owner

I had to fix a bug in zlib.net, which is also still present in the .Net core version (maybe no one used zlib with dictionaries, or .Net core handles type casts in a different manner). So I'd like to keep it internally, also I prefer to reduce external dependencies to an absolute minimum. Download the source, and you should be ready to go.

@jogibear9988 jogibear9988 marked this pull request as draft August 22, 2024 20:52
@jogibear9988

Copy link
Copy Markdown
Author

I've seen the bug, I've created a pull with your fix at a zlib nuget package. wich merged it : cinderblocks/zlib.net#5

But no problem to keep it internal.

@jogibear9988

Copy link
Copy Markdown
Author

VS2019 should be possible ( I think, need to try), but for sure the SLNX will not work

@jogibear9988

Copy link
Copy Markdown
Author

@thomas-v2 my changes compile now also in VS2019

jogibear9988 and others added 9 commits January 22, 2025 10:04
-> switching dll names does not work very well, and openssl has -x64 on the 64bit dlls.
atm supporting full framework is not needed

add support for win arm (needs test)
and osx (needs test)
# Conflicts:
#	src/S7CommPlusGUIBrowser/Form1.cs
jogibear9988 and others added 20 commits February 23, 2025 22:45
install_name_tool -change /tmp/openssl-arm/lib/libcrypto.3.dylib @rpath/libcrypto.3.dylib libssl.3.dylib
install_name_tool -add_rpath @loader_path libssl.3.dylib
# Conflicts:
#	src/S7CommPlusDriver/S7CommPlusConnection.cs
#	src/S7CommPlusDriver/S7CommPlusDriver.csproj
#	src/S7CommPlusGUIBrowser/Form1.Designer.cs
#	src/S7CommPlusGUIBrowser/Form1.cs
#	src/S7CommPlusGUIBrowser/Form1.resx
# Conflicts:
#	src/S7CommPlusDriver/Core/Ids.cs
#	src/S7CommPlusDriver/S7CommPlusConnection.cs
Add S7CommPlusClient as the production async API with typed options, result types, connection state events, typed exceptions, serialized operations, read-side reconnect, and an explicit write enable safety gate.

Replace the legacy receive polling/mutex path with channel-backed dispatch, add bounded disconnect handling, route S7Client through injectable IS7Transport/SocketS7Transport, and harden socket send/receive error handling for disconnects and timeouts.

Move library diagnostics away from Console.WriteLine, remove obsolete SHA1Managed usage, fix partial stream reads and switch exhaustiveness warnings, and clean package metadata.

Add unit, receive-dispatch, transport, and opt-in read-only live PLC smoke tests for the production behavior.
Rewrite the root README around the production S7CommPlusClient API, including async usage, write safety, error handling, logging, test commands, and opt-in read-only PLC smoke testing.
Add selectable S7CommPlus security modes for TLS, legacy challenge authentication, and automatic negotiation, including negotiated-mode exposure on the client options. Keep net6 on the TLS-only path while enabling legacy challenge authentication and protected protocol-v3 framing for newer builds.

HarpoS7 usage for Legacy connection.

Build the legacy session handshake structurally instead of relying on canned frames. Parse fingerprints, challenges, session versions, roles, and security attributes from CreateObject responses; generate CreateObject and authentication SetMultiVariables requests from typed protocol values; support S7-1500 V3/V3.1, compact, high-session, low-session, and PLCSIM authentication shapes; and retry compatible ES/HMI session roles and TSAPs when needed.

Align legacy protocol-v3 integrity handling with observed PLC behavior. Include the protected-frame digest length field, sign and verify the correct body data, accumulate digest input across continuation fragments, reassemble legacy receive fragments, restore normal request timeouts after authentication, and reject oversized protected legacy requests before they can trigger PLC integrity disconnects.

Split large legacy read batches before they exceed the single protected-frame payload budget, while leaving TLS batching unchanged. Add a reusable payload-budget calculation and return a dedicated legacy-request-too-large error for huge single requests, writes, or future protected operations that would require unsupported outgoing legacy fragmentation.

Add production support for session password legitimation, active-alarm reads, disposable tag and alarm subscriptions, snapshot-backed alarm subscription startup, CPU culture information, PLC communication defaults/resources, online view support, Bouncy Castle connection support, raw PLC structure XML access, and parsed PLC block/tag-table browsing through the async client pipeline.

Harden subscription and alarm behavior by serializing subscription operations through the production client gate, deleting the real subscription object id, updating alarm credit on the alarm subscription object, handling idle waits and communication faults, filtering malformed alarm objects, preserving connect errors during cleanup, and replaying early notifications captured during alarm snapshots.

Harden parser, transport, and connection failure handling. Surface fatal SSL/OpenSSL failures through normal receive errors, guard ISO/OpenSSL receive loops against stalls, oversized PDUs, repeated empty packets, and silent spins, validate remote TSAP values and COTP connection confirms, validate item addresses and one-byte PLC CHAR values, fail malformed blob decompression cleanly, tolerate PLC structure blobs without zlib trailers, and add parser progress checks for truncated or non-advancing protocol data.

Apply Siemens/OMS protocol naming across the driver and Harpo-backed legacy path. Centralize constants for CSI/TLS security modes, session roles, public-key families, security object ids, digest framing, value-array flags, subscription ids, alarm message types, ASOM job/protection values, system-limit LIDs, and PLC communication resources; replace remaining raw magic values where practical; and expose readable alarm/notification result names.

Refactor the client/session architecture by narrowing the public API surface, splitting connection feature services, refining protocol-session responsibilities, keeping sockets open across receive timeouts, resolving alarm text placeholders, improving PLCcom alarm metadata support, and routing block browsing/content access through the same timeout, reconnect, and typed-error behavior as other production operations.

Refresh README and protocol notes with the final TLS and legacy challenge flows, security-mode selection, legitimation behavior, subscription usage, active-alarm snapshot startup, PLC defaults/resources, block browsing, packet integrity layout, known legacy-fragment limits, and live read-only PLC verification results.

Extend regression coverage for legacy challenge parsing, authentication frame selection, protected V3 digest framing, continuation-fragment handling, structural CreateObject/authentication requests, TSAP validation, COTP confirms, legacy payload budgeting, oversized legacy request rejection, malformed parser inputs, decompression fallback, PLC CHAR and item-address validation, subscriptions, alarm snapshots, CPU culture/default/resource APIs, parsed block structure browsing, and Siemens/OMS constant mappings.
Route subscription notifications by PLC subscription object id and keep per-subscription state for tag, alarm, and TIS watch subscriptions so multiple subscriptions can share one client connection.

Remove implicit companion-client alarm snapshot APIs; snapshot reads now require an explicit caller-owned S7CommPlusClient. Update docs and regression tests for alarm snapshots, active alarm reads after subscription start, and multiple TIS watches on one connection.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants