private static void CheckWrapperAddress(GXDLMSSettings settings,
GXByteBuffer buff)
{
int value;
if (settings.IsServer)
{
value = buff.GetUInt16();
// Check that client addresses match.
if (settings.ClientAddress != 0
&& settings.ClientAddress != value)
{
throw new GXDLMSException(
"Source addresses do not match. It is "
+ value.ToString() + ". It should be "
+ settings.ClientAddress.ToString()
+ ".");
}
else
{
settings.ClientAddress = value;
}
value = buff.GetUInt16();
// Check that server addresses match.
if (settings.ServerAddress != 0
&& settings.ServerAddress != value)
{
throw new GXDLMSException(
"Destination addresses do not match. It is "
+ value.ToString() + ". It should be "
+ settings.ServerAddress.ToString()
+ ".");
}
else
{
settings.ServerAddress = value;
}
}
else
{
value = buff.GetUInt16();
// Check that server addresses match.
if (settings.ClientAddress != 0
&& settings.ServerAddress != value)
{
throw new GXDLMSException(
"Source addresses do not match. It is "
+ value.ToString() + ". It should be "
+ settings.ServerAddress.ToString()
+ ".");
}
else
{
settings.ServerAddress = value;
}
value = buff.GetUInt16();
// Check that client addresses match.
if (settings.ClientAddress != 0
&& settings.ClientAddress != value)
{
throw new GXDLMSException(
"Destination addresses do not match. It is "
+ value.ToString() + ". It should be "
+ settings.ClientAddress.ToString()
+ ".");
}
else
{
settings.ClientAddress = value;
}
}
}