Esempio n. 1
0
        /// <summary>
        /// Merges the given values into this instance.
        /// </summary>
        /// <param name="protocol">Parent protocol.</param>
        /// <param name="longName">Field long name.</param>
        /// <param name="shortName">Field short name.</param>
        /// <param name="description">Field description.</param>
        /// <param name="displayBase">Field display base.</param>
        /// <param name="bitmask">Field bitmask.</param>
        /// <param name="type">Field type.</param>
        public void Merge(TSharkProtocol protocol, string longName, string shortName, string description, string displayBase, string bitmask, Type type)
        {
            if (Protocol != protocol)
            {
                throw new Exception(string.Format("Unable to merge duplicate fields (protocol conflict): {0}", shortName));
            }

            if (!ShortName.Equals(shortName, StringComparison.OrdinalIgnoreCase))
            {
                throw new Exception(string.Format("Unable to merge duplicate fields (short name conflict): {0}", shortName));
            }

            if (Type != null && type != null && Type != type)
            {
                throw new Exception(string.Format("Unable to merge duplicate fields (type conflict): {0}", shortName));
            }

            if (Type == null)
            {
                Type = type;
            }

            if (string.IsNullOrEmpty(Bitmask))
            {
                Bitmask = bitmask;
            }
            else if (!bitmask.Equals(Bitmask, StringComparison.OrdinalIgnoreCase))
            {
                Bitmask = string.Concat(Bitmask, " / ", bitmask);
            }

            if (string.IsNullOrEmpty(LongName))
            {
                LongName = longName;
            }
            else if (!longName.Equals(LongName, StringComparison.OrdinalIgnoreCase))
            {
                LongName = string.Concat(LongName, " / ", longName);
            }

            if (string.IsNullOrEmpty(Description))
            {
                Description = description;
            }
            else if (!description.Equals(Description, StringComparison.OrdinalIgnoreCase))
            {
                Description = string.Concat(Description, " / ", description);
            }

            if (string.IsNullOrEmpty(DisplayBase))
            {
                DisplayBase = displayBase;
            }
            else if (!displayBase.Equals(DisplayBase, StringComparison.OrdinalIgnoreCase))
            {
                DisplayBase = string.Concat(DisplayBase, " / ", displayBase);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Adds a protocol to the schema.
        /// </summary>
        /// <param name="longName">Protocol long name.</param>
        /// <param name="shortName">Protocol short name.</param>
        /// <param name="filterName">Protocol filter name.</param>
        public void AddProtocol(string longName, string shortName, string filterName)
        {
            TSharkProtocol existing;

            if (Protocols.TryGetValue(shortName, out existing))
            {
                existing.Merge(longName, shortName, filterName);
            }
            else
            {
                Protocols[shortName] = new TSharkProtocol(longName, shortName, filterName);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="protocol">Parent protocol.</param>
        /// <param name="longName">Field long name.</param>
        /// <param name="shortName">Field short name.</param>
        /// <param name="description">Field description.</param>
        /// <param name="displayBase">Field display base.</param>
        /// <param name="bitmask">Field bitmask.</param>
        /// <param name="type">Field type.</param>
        public TSharkField(TSharkProtocol protocol, string longName, string shortName, string description, string displayBase, string bitmask, Type type)
        {
            this.Protocol    = protocol;
            this.LongName    = longName;
            this.ShortName   = shortName;
            this.Description = description;
            this.DisplayBase = displayBase;
            this.Bitmask     = bitmask;
            this.Type        = type;
            this.Strings     = new List <TSharkString>();

            protocol.Fields.Add(this);
        }
Esempio n. 4
0
        /// <summary>
        /// Adds a field to the schema.
        /// </summary>
        /// <param name="longName">Field long name.</param>
        /// <param name="shortName">Field short name.</param>
        /// <param name="ftenumType">Field type (e.g. FT_INT32, FT_STRING, etc)</param>
        /// <param name="protocolShortName">Parent protocol's short name.</param>
        /// <param name="description">Description of the field.</param>
        /// <param name="displayBase">Display base of the field (e.g. BASE_DEC, BASE_HEX, BASE_DEC).</param>
        /// <param name="bitmask">Bitmask of the field.</param>
        public void AddField(string longName, string shortName, string ftenumType, string protocolShortName, string description, string displayBase, string bitmask)
        {
            TSharkProtocol protocol = GetProtocol(protocolShortName);

            Type        type = TranslateFtenum(ftenumType);
            TSharkField existing;

            if (Fields.TryGetValue(shortName, out existing))
            {
                existing.Merge(protocol, longName, shortName, description, displayBase, bitmask, type);
            }
            else
            {
                Fields[shortName] = new TSharkField(protocol, longName, shortName, description, displayBase, bitmask, type);
            }
        }
Esempio n. 5
0
        /// <summary>
        /// Merges the given values into this instance.
        /// </summary>
        /// <param name="protocol">Parent protocol.</param>
        /// <param name="longName">Field long name.</param>
        /// <param name="shortName">Field short name.</param>
        /// <param name="description">Field description.</param>
        /// <param name="displayBase">Field display base.</param>
        /// <param name="bitmask">Field bitmask.</param>
        /// <param name="type">Field type.</param>
        public void Merge(TSharkProtocol protocol, string longName, string shortName, string description, string displayBase, string bitmask, Type type)
        {
            if (Protocol != protocol)
                throw new Exception(string.Format("Unable to merge duplicate fields (protocol conflict): {0}", shortName));

            if (!ShortName.Equals(shortName, StringComparison.OrdinalIgnoreCase))
                throw new Exception(string.Format("Unable to merge duplicate fields (short name conflict): {0}", shortName));

            if (Type != null && type != null && Type != type)
                throw new Exception(string.Format("Unable to merge duplicate fields (type conflict): {0}", shortName));

            if (Type == null)
                Type = type;

            if (string.IsNullOrEmpty(Bitmask))
            {
                Bitmask = bitmask;
            }
            else if (!bitmask.Equals(Bitmask, StringComparison.OrdinalIgnoreCase))
            {
                Bitmask = string.Concat(Bitmask, " / ", bitmask);
            }

            if (string.IsNullOrEmpty(LongName))
            {
                LongName = longName;
            }
            else if (!longName.Equals(LongName, StringComparison.OrdinalIgnoreCase))
            {
                LongName = string.Concat(LongName, " / ", longName);
            }

            if (string.IsNullOrEmpty(Description))
            {
                Description = description;
            }
            else if (!description.Equals(Description, StringComparison.OrdinalIgnoreCase))
            {
                Description = string.Concat(Description, " / ", description);
            }

            if (string.IsNullOrEmpty(DisplayBase))
            {
                DisplayBase = displayBase;
            }
            else if (!displayBase.Equals(DisplayBase, StringComparison.OrdinalIgnoreCase))
            {
                DisplayBase = string.Concat(DisplayBase, " / ", displayBase);
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="protocol">Parent protocol.</param>
        /// <param name="longName">Field long name.</param>
        /// <param name="shortName">Field short name.</param>
        /// <param name="description">Field description.</param>
        /// <param name="displayBase">Field display base.</param>
        /// <param name="bitmask">Field bitmask.</param>
        /// <param name="type">Field type.</param>
        public TSharkField(TSharkProtocol protocol, string longName, string shortName, string description, string displayBase, string bitmask, Type type)
        {
            this.Protocol = protocol;
            this.LongName = longName;
            this.ShortName = shortName;
            this.Description = description;
            this.DisplayBase = displayBase;
            this.Bitmask = bitmask;
            this.Type = type;
            this.Strings = new List<TSharkString>();

            protocol.Fields.Add(this);
        }
Esempio n. 7
0
 /// <summary>
 /// Adds a protocol to the schema.
 /// </summary>
 /// <param name="longName">Protocol long name.</param>
 /// <param name="shortName">Protocol short name.</param>
 /// <param name="filterName">Protocol filter name.</param>
 public void AddProtocol(string longName, string shortName, string filterName)
 {
     TSharkProtocol existing;
     if (Protocols.TryGetValue(shortName, out existing))
     {
         existing.Merge(longName, shortName, filterName);
     }
     else
     {
         Protocols[shortName] = new TSharkProtocol(longName, shortName, filterName);
     }
 }