Skip to content

Commit

Permalink
Backport fixes for renewing secure channels, bump version.
Browse files Browse the repository at this point in the history
  • Loading branch information
nauful committed Nov 13, 2024
1 parent 9a0709c commit 0794efd
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 6 deletions.
2 changes: 1 addition & 1 deletion NET Core/LibUA/LibUA.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<Title>LibUA Core</Title>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/nauful/libua</RepositoryUrl>
<Version>1.0.30</Version>
<Version>1.0.31</Version>
<PackageReadmeFile>README.md</PackageReadmeFile>
<PackageLicenseFile>LICENSE</PackageLicenseFile>
</PropertyGroup>
Expand Down
11 changes: 10 additions & 1 deletion NET Core/LibUA/NetDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -564,13 +564,22 @@ protected override int Consume(MemoryBuffer recvBuf)
}
else if (messageType == (uint)MessageType.Open)
{
uint messageSize =
(uint)recvBuf.Buffer[4] | (uint)(recvBuf.Buffer[5] << 8) |
(uint)(recvBuf.Buffer[6] << 16) | (uint)(recvBuf.Buffer[7] << 24);

if (messageSize > recvBuf.Capacity)
{
return 0;
}

if (config.TL == null)
{
logger?.Log(LogLevel.Error, "{LoggerID}: Message type 0x{messageType:X} is not supported before Hello", LoggerID(), messageType);
return ErrorInternal;
}

return DispatchOpen(config, recvBuf);
return DispatchOpen(config, recvBuf.Duplicate((int)messageSize));
}
else if (messageType == (uint)MessageType.Message ||
messageType == (uint)MessageType.Close)
Expand Down
12 changes: 10 additions & 2 deletions NET/LibUA/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1397,15 +1397,23 @@ private int Consume(SLChannel config, MemoryBuffer recvBuf)
}
else if (messageType == (uint)MessageType.Open)
{
ManualResetEvent ev = null;
messageSize =
(uint)recvBuf.Buffer[4] | (uint)(recvBuf.Buffer[5] << 8) |
(uint)(recvBuf.Buffer[6] << 16) | (uint)(recvBuf.Buffer[7] << 24);

if (messageSize > recvBuf.Capacity)
{
return 0;
}

ManualResetEvent ev = null;
lock (recvQueue)
{
var key = new Tuple<uint, uint>(messageType, 0);
recvQueue[key] = new RecvHandler()
{
Header = null,
RecvBuf = recvBuf.Duplicate(),
RecvBuf = recvBuf.Duplicate((int)messageSize),
Type = NodeId.Zero
};

Expand Down
10 changes: 10 additions & 0 deletions NET/LibUA/MemoryBuffer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -766,6 +766,16 @@ public MemoryBuffer Duplicate()

return mb;
}

public MemoryBuffer Duplicate(int TargetCapacity)
{
var mb = new MemoryBuffer(TargetCapacity);

mb.Append(Buffer, TargetCapacity);
mb.Position = Position;

return mb;
}
}
}
}
11 changes: 10 additions & 1 deletion NET/LibUA/NetDispatcher.cs
Original file line number Diff line number Diff line change
Expand Up @@ -565,13 +565,22 @@ protected override int Consume(MemoryBuffer recvBuf)
}
else if (messageType == (uint)MessageType.Open)
{
uint messageSize =
(uint)recvBuf.Buffer[4] | (uint)(recvBuf.Buffer[5] << 8) |
(uint)(recvBuf.Buffer[6] << 16) | (uint)(recvBuf.Buffer[7] << 24);

if (messageSize > recvBuf.Capacity)
{
return 0;
}

if (config.TL == null)
{
logger?.Log(LogLevel.Error, "{LoggerID}: Message type 0x{messageType:X} is not supported before Hello", LoggerID(), messageType);
return ErrorInternal;
}

return DispatchOpen(config, recvBuf);
return DispatchOpen(config, recvBuf.Duplicate((int)messageSize));
}
else if (messageType == (uint)MessageType.Message ||
messageType == (uint)MessageType.Close)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# LibUA
Open-source OPC UA client and server library for .NET Framework and .NET Core based on IEC 62541. Available a library, a demo client and a demo server. Tested and commercially used in industrial applications with commercial vendors' UA servers and clients.

Available as a nuget package for .NET Core (1.0.30):
Available as a nuget package for .NET Core (1.0.31):
https://www.nuget.org/packages/nauful-LibUA-core

### Features
Expand Down

0 comments on commit 0794efd

Please sign in to comment.