Beispiel #1
0
 public void SetTestFrameBroadcastS2(SecurityS2TestFrames testFrame, bool?isBroadcast)
 {
     if (isBroadcast != null)
     {
         if (!TestFramesS2.ContainsKey(testFrame))
         {
             TestFramesS2.Add(testFrame, new TestFrameS2Settings
             {
                 FrameTypeV           = testFrame,
                 IsBroadcast          = isBroadcast.Value,
                 IsBroadcastSpecified = true
             });
         }
         else
         {
             TestFramesS2[testFrame].IsBroadcast          = isBroadcast.Value;
             TestFramesS2[testFrame].IsBroadcastSpecified = true;
         }
     }
     else
     {
         if (TestFramesS2.ContainsKey(testFrame))
         {
             TestFramesS2[testFrame].IsBroadcast          = false;
             TestFramesS2[testFrame].IsBroadcastSpecified = false;
         }
     }
 }
Beispiel #2
0
 public void SetTestFrameEncryptedS2(SecurityS2TestFrames testFrame, bool?isEncrypted)
 {
     if (isEncrypted != null)
     {
         if (!TestFramesS2.ContainsKey(testFrame))
         {
             TestFramesS2.Add(testFrame, new TestFrameS2Settings
             {
                 FrameTypeV           = testFrame,
                 IsEncrypted          = isEncrypted.Value,
                 IsEncryptedSpecified = true
             });
         }
         else
         {
             TestFramesS2[testFrame].IsEncrypted          = isEncrypted.Value;
             TestFramesS2[testFrame].IsEncryptedSpecified = true;
         }
     }
     else
     {
         if (TestFramesS2.ContainsKey(testFrame))
         {
             TestFramesS2[testFrame].IsEncrypted          = false;
             TestFramesS2[testFrame].IsEncryptedSpecified = false;
         }
     }
 }
Beispiel #3
0
 public void SetTestFrameDelayS2(SecurityS2TestFrames testFrame, int delay)
 {
     if (delay > 0)
     {
         if (!TestFramesS2.ContainsKey(testFrame))
         {
             TestFramesS2.Add(testFrame, new TestFrameS2Settings
             {
                 FrameTypeV     = testFrame,
                 Delay          = delay,
                 DelaySpecified = true
             });
         }
         else
         {
             TestFramesS2[testFrame].Delay          = delay;
             TestFramesS2[testFrame].DelaySpecified = true;
         }
     }
     else
     {
         if (TestFramesS2.ContainsKey(testFrame))
         {
             TestFramesS2[testFrame].Delay          = 0;
             TestFramesS2[testFrame].DelaySpecified = false;
         }
     }
 }
Beispiel #4
0
 public void SetTestFrameCommandS2(SecurityS2TestFrames testFrame, byte[] data)
 {
     if (data != null && data.Length > 0)
     {
         if (!TestFramesS2.ContainsKey(testFrame))
         {
             TestFramesS2.Add(testFrame, new TestFrameS2Settings
             {
                 FrameTypeV = testFrame,
                 Command    = data
             });
         }
         else
         {
             TestFramesS2[testFrame].Command = data;
         }
     }
     else
     {
         if (TestFramesS2.ContainsKey(testFrame))
         {
             TestFramesS2[testFrame].Command = null;
         }
     }
 }
Beispiel #5
0
 public void SetTestFrameNetworkKeyS2(SecurityS2TestFrames testFrame, byte[] networkKey, bool isTemp)
 {
     if (!TestFramesS2.ContainsKey(testFrame))
     {
         TestFramesS2.Add(testFrame, new TestFrameS2Settings
         {
             FrameTypeV = testFrame,
             NetworkKey = networkKey,
             IsTemp     = isTemp
         });
     }
     else
     {
         TestFramesS2[testFrame].NetworkKey = networkKey;
         TestFramesS2[testFrame].IsTemp     = isTemp;
     }
 }
Beispiel #6
0
        public void ActivateTestPropertiesForFrame(SecurityS2TestFrames testFrameType, ApiOperation apiOperation)
        {
            if (_securityManagerInfo.TestFramesS2.ContainsKey(testFrameType))
            {
                var  testFrame = _securityManagerInfo.TestFramesS2[testFrameType];
                byte nodeId    = 0x00;
                InvariantPeerNodeId peerNodeId;

                if (apiOperation is RequestDataOperation)
                {
                    var operation = (apiOperation as RequestDataOperation);
                    nodeId         = operation.DestNodeId;
                    operation.Data = testFrame.Command ?? operation.Data;
                }
                else if (apiOperation is SendDataOperation)
                {
                    var operation = (apiOperation as SendDataOperation);
                    nodeId         = operation.NodeId;
                    operation.Data = testFrame.Command ?? operation.Data;
                }
                else if (apiOperation is SendDataExOperation)
                {
                    var operation = (apiOperation as SendDataExOperation);
                    nodeId         = operation.NodeId;
                    operation.Data = testFrame.Command ?? operation.Data;
                }
                else if (apiOperation is SendDataBridgeOperation)
                {
                    var operation = (apiOperation as SendDataBridgeOperation);
                    nodeId         = operation.DestNodeId;
                    operation.Data = testFrame.Command ?? operation.Data;
                }
                peerNodeId = new InvariantPeerNodeId(_securityManagerInfo.Network.NodeId, nodeId);

                if (testFrame.IsEncryptedSpecified)
                {
                    if (testFrame.IsEncrypted)
                    {
                        apiOperation.SubstituteSettings.ClearFlag(SubstituteFlags.DenySecurity);
                        if (testFrame.IsTemp)
                        {
                            if (testFrame.NetworkKey != null)
                            {
                                _securityManagerInfo.ActivateNetworkKeyS2CustomForNode(peerNodeId, testFrame.IsTemp, testFrame.NetworkKey);
                            }
                            else
                            {
                                _securityManagerInfo.ActivateNetworkKeyS2CustomForNode(peerNodeId, testFrame.IsTemp, _securityManagerInfo.GetActualNetworkKeyS2Temp());
                            }
                        }
                        else
                        {
                            if (testFrame.NetworkKey != null)
                            {
                                _securityManagerInfo.ActivateNetworkKeyS2CustomForNode(peerNodeId, testFrame.IsTemp, testFrame.NetworkKey);
                            }
                        }
                    }
                    else
                    {
                        apiOperation.SubstituteSettings.SetFlag(SubstituteFlags.DenySecurity);
                    }
                }
                if (testFrame.IsMulticastSpecified)
                {
                    if (testFrame.IsMulticast)
                    {
                        apiOperation.SubstituteSettings.ClearFlag(SubstituteFlags.DenyMulticast);
                        apiOperation.SubstituteSettings.SetFlag(SubstituteFlags.UseMulticast);
                        if (_isInclusionProcesses)
                        {
                            apiOperation.SubstituteSettings.ClearFlag(SubstituteFlags.UseFollowup);
                            apiOperation.SubstituteSettings.SetFlag(SubstituteFlags.DenyFollowup);
                        }
                    }
                    else
                    {
                        apiOperation.SubstituteSettings.ClearFlag(SubstituteFlags.UseMulticast);
                        apiOperation.SubstituteSettings.SetFlag(SubstituteFlags.DenyMulticast);
                    }
                }
                if (testFrame.IsBroadcastSpecified)
                {
                    if (testFrame.IsBroadcast)
                    {
                        apiOperation.SubstituteSettings.ClearFlag(SubstituteFlags.DenyBroadcast);
                        apiOperation.SubstituteSettings.SetFlag(SubstituteFlags.UseBroadcast);
                        if (_isInclusionProcesses)
                        {
                            apiOperation.SubstituteSettings.ClearFlag(SubstituteFlags.UseFollowup);
                            apiOperation.SubstituteSettings.SetFlag(SubstituteFlags.DenyFollowup);
                        }
                    }
                    else
                    {
                        apiOperation.SubstituteSettings.ClearFlag(SubstituteFlags.UseBroadcast);
                        apiOperation.SubstituteSettings.SetFlag(SubstituteFlags.DenyBroadcast);
                    }
                }
                if (testFrame.DelaySpecified)
                {
                    Thread.Sleep(testFrame.Delay);
                }
                ;
            }
        }