Skip to content

Commit

Permalink
Fix network configuration serialization (#342)
Browse files Browse the repository at this point in the history
***NO_CI***
  • Loading branch information
josesimoes authored Mar 23, 2022
1 parent 8d101bd commit 171931a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,9 @@ static internal uint FromIPv4Address(IPAddress address)
{
var addressAsArray = address.GetAddressBytes();

return (((uint)addressAsArray[3] << 24) |
((uint)addressAsArray[2] << 16) |
((uint)addressAsArray[1] << 8) |
return (((uint)addressAsArray[3] << 24) |
((uint)addressAsArray[2] << 16) |
((uint)addressAsArray[1] << 8) |
(addressAsArray[0]));
}
catch { };
Expand All @@ -145,12 +145,12 @@ static internal uint[] FromIPv6Address(IPAddress address)
{
try
{
var addressAsArray = address.ToString().Split(new string[] { ":", "::" }, StringSplitOptions.RemoveEmptyEntries);
var addressBytesReversed = address.GetAddressBytes().Reverse().ToArray();

return new uint[] { uint.Parse(addressAsArray[3], NumberStyles.HexNumber),
uint.Parse(addressAsArray[2], NumberStyles.HexNumber),
uint.Parse(addressAsArray[1], NumberStyles.HexNumber),
uint.Parse(addressAsArray[0], NumberStyles.HexNumber) };
return new uint[] { BitConverter.ToUInt32(addressBytesReversed, 0),
BitConverter.ToUInt32(addressBytesReversed, 4),
BitConverter.ToUInt32(addressBytesReversed, 8),
BitConverter.ToUInt32(addressBytesReversed, 12) };
}
catch { };

Expand Down Expand Up @@ -193,11 +193,11 @@ public NetworkConfigurationProperties(NetworkConfigurationBase value)

if (value.SpecificConfigId == EmptySpecificConfigValue)
{
SpecificConfigId = null;
SpecificConfigId = null;
}
else
{
SpecificConfigId = value.SpecificConfigId;
SpecificConfigId = value.SpecificConfigId;
}

// reset unknown flag
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ public NetworkConfigurationBase()
{
// need to init this here to match the expected size on the struct to be sent to the device
Marker = new byte[4];

IPv6Address = new uint[] { 0, 0, 0, 0 };
IPv6NetMask = new uint[] { 0, 0, 0, 0 };
IPv6GatewayAddress = new uint[] { 0, 0, 0, 0 };
IPv6DNSAddress1 = new uint[] { 0, 0, 0, 0 };
IPv6DNSAddress2 = new uint[] { 0, 0, 0, 0 };
}
}
}

0 comments on commit 171931a

Please sign in to comment.