示例#1
0
 public Protocol(ProtocolProfile config, int sessionId, UserDataType userDataType, byte[] userData)
 {
     _UserData      = userData;
     _Version       = VERSION;
     _SessionID     = sessionId;
     _UserDataType  = userDataType;
     _CompressType  = config.Compress;
     _SerializeType = config.SerializerType;
     _ServiceID     = config.ServiceID;
     _TotalLen      = SFPStruct.Version + SFPStruct.TotalLen + SFPStruct.SessionId + SFPStruct.ServerId + SFPStruct.SerializeType + SFPStruct.SDPType + SFPStruct.Platform + SFPStruct.CompressType + userData.Length;
 }
        private void PopulateAllFields(int index)
        {
            int header_index = -1;
            int type_index = -1;
            ProtocolProfile profile = _profiles[index];

            textBoxName.Text = profile.Ident.Name;

            checkBoxCoreMetricTimeOverride.IsChecked = profile.OverridePacketTime;
            if (profile.OverridePacketTime)
            {
                textBoxCoreMetricTimeOverride.Text = profile.NewPacketTime.Abbreviation;
                CheckWiresharkFieldCoreMetric(checkBoxCoreMetricTimeOverride, textBoxCoreMetricTimeOverride, textBlockCoreMetricTimeFieldType, Enums.ValidateWiresharkFieldType.Timestamp, out header_index, out type_index);
                comboBoxCoreMetricTimeOverrideUnits.SelectedItem = profile.NewPacketTimeUnit.Abbreviation;
            }

            checkBoxCoreMetricSrcAddressOverride.IsChecked = profile.OverrideSourceAddress;
            if (profile.OverrideSourceAddress)
            {
                textBoxCoreMetricSrcAddressOverride.Text = profile.NewSourceAddress.Abbreviation;
                CheckWiresharkFieldCoreMetric(checkBoxCoreMetricSrcAddressOverride, textBoxCoreMetricSrcAddressOverride, textBlockCoreMetricSrcAddressFieldType, Enums.ValidateWiresharkFieldType.Address, out header_index, out type_index);
            }

            checkBoxCoreMetricDstAddressOverride.IsChecked = profile.OverrideDestinationAddress;
            if (profile.OverrideDestinationAddress)
            {
                textBoxCoreMetricDstAddressOverride.Text = profile.NewDestinationAddress.Abbreviation;
                CheckWiresharkFieldCoreMetric(checkBoxCoreMetricDstAddressOverride, textBoxCoreMetricDstAddressOverride, textBlockCoreMetricDstAddressFieldType, Enums.ValidateWiresharkFieldType.Address, out header_index, out type_index);
            }

            for (int i = 0; i < profile.ProtocolMetrics.Count; i++)
                listBoxProtocolMetric.Items.Add(profile.ProtocolMetrics[i].Abbreviation);
            listBoxProtocolMetric.SelectedIndex = -1;

            textBoxProtocolFilter.Text = profile.ProtocolFilter;

            _current_profile = profile;

            buttonProtocolAdd.IsEnabled = false;
            buttonProtocolUpdate.IsEnabled = true;
            buttonProtocolDelete.IsEnabled = true;
        }
        /// <summary>
        /// Clear all the fields in the window to enter a new protocol profile.
        /// </summary>
        private void ClearAllFields()
        {
            textBoxName.Text = "";

            checkBoxCoreMetricTimeOverride.IsChecked = false;
            textBoxCoreMetricTimeOverride.Background = Constants.TextBoxBackgroundBrushReadOnly;
            textBoxCoreMetricTimeOverride.Text = "";
            textBlockCoreMetricTimeFieldType.Text = "";
            comboBoxCoreMetricTimeOverrideUnits.SelectedIndex = -1;

            checkBoxCoreMetricSrcAddressOverride.IsChecked = false;
            textBoxCoreMetricSrcAddressOverride.Background = Constants.TextBoxBackgroundBrushReadOnly;
            textBoxCoreMetricSrcAddressOverride.Text = "";
            textBlockCoreMetricSrcAddressFieldType.Text = "";

            checkBoxCoreMetricDstAddressOverride.IsChecked = false;
            textBoxCoreMetricDstAddressOverride.Background = Constants.TextBoxBackgroundBrushReadOnly;
            textBoxCoreMetricDstAddressOverride.Text = "";
            textBlockCoreMetricDstAddressFieldType.Text = "";

            listBoxProtocolMetric.Items.Clear();
            ClearProtocolMetricFields();

            textBoxProtocolFilter.Text = "";

            buttonProtocolAdd.IsEnabled = false;
            buttonProtocolUpdate.IsEnabled = false;
            buttonProtocolDelete.IsEnabled = false;

            _current_profile = new ProtocolProfile();
        }