Exemple #1
0
        private ProtocolStack GetManagementBranch()
        {
            ProtocolStackState managementBranchState = new ProtocolStackState();

            managementBranchState.MiddleProtocols.Add(new TransportInfoProtocol());  // Transport Info
            ProtocolStack managementBranch = new ProtocolStack();

            managementBranch.SetState(managementBranchState);
            managementBranchState.Type = DataProtocolType.Management;
            return(managementBranch);
        }
Exemple #2
0
        private ProtocolStack GetTextBranch()
        {
            // Text Branch
            ProtocolStackState textBranchState = new ProtocolStackState();

            textBranchState.MiddleProtocols.Add(new UTF8Protocol());  // UTF8
            ProtocolStack textBranch = new ProtocolStack();

            textBranch.SetState(textBranchState);
            textBranchState.Type = DataProtocolType.Text;
            return(textBranch);
        }
Exemple #3
0
        private ProtocolStack GetFileBranch()
        {
            // File Branch
            ProtocolStackState fileBranchState = new ProtocolStackState();

            fileBranchState.MiddleProtocols.Add(new SmallFileProtocol());  // SmallFileProtocol
            ProtocolStack fileBranch = new ProtocolStack();

            fileBranch.SetState(fileBranchState);
            fileBranchState.Type = DataProtocolType.SmallFile;
            return(fileBranch);
        }
Exemple #4
0
        private static void AddBasicSecurityLayer(ProtocolStackState stackState, AESProtocolState aesState)
        {
            // Heartbeat
            stackState.MiddleProtocols.Add(new HeartbeatProtocol());
            // Timestamp
            stackState.MiddleProtocols.Add(new TimestampProtocol());
            // Seq (this protocol will block broadcasted messages)
            stackState.MiddleProtocols.Add(new SequenceProtocol());
            // AES
            AESProtocol aesP = new AESProtocol();

            aesP.SetState((AESProtocolState)aesState.Clone());
            stackState.MiddleProtocols.Add(aesP);
            // Framing
            stackState.MiddleProtocols.Add(new FramingProtocol());
        }
Exemple #5
0
        private ProtocolStack GetDefaultStack()
        {
            ProtocolStackState state = new ProtocolStackState();

            // branching
            List <ProtocolStack> branches = new List <ProtocolStack>();

            branches.Add(GetTextBranch());       // index 0
            branches.Add(GetFileBranch());       // index 1
            branches.Add(GetManagementBranch()); // index 2
            TypeBranchingProtocol branchingProtocol = new TypeBranchingProtocol();

            branchingProtocol.SetBranches(branches);
            state.MiddleProtocols.Add(branchingProtocol);

            // Block invalid DataContent
            state.MiddleProtocols.Add(new BlockProtocol());
            // Type tagging
            TypeTagProtocol typeTagProtocol = new TypeTagProtocol();

            state.MiddleProtocols.Add(typeTagProtocol);

            // Block invalid DataContent
            state.MiddleProtocols.Add(new BlockProtocol());
            // AES
            AESProtocol aesP = new AESProtocol();

            aesP.SetState((AESProtocolState)_options.SecondLowAESProtocolState.Clone());
            state.MiddleProtocols.Add(aesP);

            // Block invalid data and report
            state.MiddleProtocols.Add(new BlockProtocol());
            // Basic Security Layers
            AddBasicSecurityLayer(state, _options.FirstLowAESProtocolState);

            state.Type = DataProtocolType.Text;
            ProtocolStack protocolStack = new ProtocolStack();

            protocolStack.SetState(state);
            return(protocolStack);
        }
Exemple #6
0
 // setup Event chains
 public void SetState(ProtocolStackState state)
 {
     UnlinkMiddleProtocols();
     _state = state;
     LinkMiddleProtocols();
 }