/// <summary> /// Constructor. /// </summary> /// <param name="field">Parent field.</param> /// <param name="lowerBound">Lower bound of values the string corresponds to.</param> /// <param name="upperBound">Upper bound of values the string corresponds to.</param> /// <param name="stringValue">Human readable string.</param> public TSharkStringRange(TSharkField field, long lowerBound, long upperBound, string stringValue) : base(field) { this.LowerBound = lowerBound; this.UpperBound = upperBound; this.StringValue = stringValue; }
/// <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); } }
/// <summary> /// Adds a string to the schema. /// </summary> /// <param name="fieldShortName">Parent field short name.</param> /// <param name="trueString">Human readable string corresponding to a value of true.</param> /// <param name="falseString">Human readable string corresponding to a value of false.</param> public void AddTrueFalseString(string fieldShortName, string trueString, string falseString) { TSharkField field = GetField(fieldShortName); string key = string.Concat(fieldShortName, "(t/f)"); TSharkString existing; if (Strings.TryGetValue(key, out existing)) { TSharkStringTrueFalse existingStringTrueFalse = (TSharkStringTrueFalse)existing; existingStringTrueFalse.Merge(trueString, falseString); } else { Strings[key] = new TSharkStringTrueFalse(field, trueString, falseString); } }
/// <summary> /// Adds a string to the schema. /// </summary> /// <param name="fieldShortName">Parent field short name.</param> /// <param name="value">Value the string corresponds to.</param> /// <param name="valueString">Human readable string.</param> public void AddValueString(string fieldShortName, long value, string valueString) { TSharkField field = GetField(fieldShortName); string key = string.Concat(fieldShortName, "(", value, ")"); TSharkString existing; if (Strings.TryGetValue(key, out existing)) { TSharkStringValue existingStringValue = (TSharkStringValue)existing; existingStringValue.Merge(valueString); } else { Strings[key] = new TSharkStringValue(field, value, valueString); } }
/// <summary> /// Adds a string to the schema. /// </summary> /// <param name="fieldShortName">Parent field short name.</param> /// <param name="lowerBound">Lower bound for values the string corresponds to.</param> /// <param name="upperBound">Upper bound for values the string corresponds to.</param> /// <param name="rangeString">Human readable string.</param> public void AddRangeString(string fieldShortName, long lowerBound, long upperBound, string rangeString) { TSharkField field = GetField(fieldShortName); string key = string.Concat(fieldShortName, "(", lowerBound, "-", upperBound, ")"); TSharkString existing; if (Strings.TryGetValue(key, out existing)) { TSharkStringRange existingStringRange = (TSharkStringRange)existing; existingStringRange.Merge(rangeString); } else { Strings[key] = new TSharkStringRange(field, lowerBound, upperBound, rangeString); } }
/// <summary> /// Constructor. /// </summary> /// <param name="field">Parent field.</param> /// <param name="trueStringValue">The true string value.</param> /// <param name="falseStringValue">The false string value.</param> public TSharkStringTrueFalse(TSharkField field, string trueStringValue, string falseStringValue) : base(field) { this.TrueStringValue = trueStringValue; this.FalseStringValue = falseStringValue; }
/// <summary> /// Constructor. /// </summary> /// <param name="field">Parent field.</param> /// <param name="value">Value the string corresponds to.</param> /// <param name="stringValue">Human readable string.</param> public TSharkStringValue(TSharkField field, long value, string stringValue) : base(field) { this.Value = value; this.StringValue = stringValue; }
/// <summary> /// Constructor. /// </summary> /// <param name="field">Parent field.</param> public TSharkString(TSharkField field) { this.Field = field; field.Strings.Add(this); }
/// <summary> /// Parses an unsigned integer value, storing it in the smallest available unsigned integer type. /// </summary> /// <remarks> /// This method is called internally by GetTypedValue. /// </remarks> /// <param name="show">Value to parse.</param> /// <param name="typedType">Receives the parsed type.</param> /// <param name="typedValue">Receives the parsed value.</param> /// <param name="field">The field descriptor.</param> private static void ParseUnsigned(string show, ref Type typedType, ref object typedValue, TSharkField field) { if (field.DisplayBase.Equals("BASE_NONE")) { typedType = typeof(string); typedValue = show; return; } // oct values seem to be stored in decimal form...? ulong v; if (field.DisplayBase.StartsWith("BASE_HEX")) { v = BitConverter.ToUInt64(TSharkTypeParser.Reverse(TSharkTypeParser.ParseHexBytes(show, 8)), 0); } /*else if (field.DisplayBase.StartsWith("BASE_OCT")) * { * v = BitConverter.ToUInt64(TSharkTypeParser.Reverse(TSharkTypeParser.ParseOctBytes(show, 8)), 0); * }*/ else //if (field.DisplayBase.StartsWith("BASE_DEC")) { v = ulong.Parse(show); } if (v >= byte.MinValue && v <= byte.MaxValue) { typedType = typeof(byte); typedValue = (byte)v; } else if (v >= ushort.MinValue && v <= ushort.MaxValue) { typedType = typeof(ushort); typedValue = (ushort)v; } else if (v >= uint.MinValue && v <= uint.MaxValue) { typedType = typeof(uint); typedValue = (uint)v; } else //if (v >= ulong.MinValue && v <= ulong.MaxValue) { typedType = typeof(ulong); typedValue = (ulong)v; } }
/// <summary> /// Parses an unsigned integer value, storing it in the smallest available unsigned integer type. /// </summary> /// <remarks> /// This method is called internally by GetTypedValue. /// </remarks> /// <param name="show">Value to parse.</param> /// <param name="typedType">Receives the parsed type.</param> /// <param name="typedValue">Receives the parsed value.</param> /// <param name="field">The field descriptor.</param> private static void ParseUnsigned(string show, ref Type typedType, ref object typedValue, TSharkField field) { if (field.DisplayBase.Equals("BASE_NONE")) { typedType = typeof(string); typedValue = show; return; } // oct values seem to be stored in decimal form...? ulong v; if (field.DisplayBase.StartsWith("BASE_HEX")) { v = BitConverter.ToUInt64(TSharkTypeParser.Reverse(TSharkTypeParser.ParseHexBytes(show, 8)), 0); } /*else if (field.DisplayBase.StartsWith("BASE_OCT")) { v = BitConverter.ToUInt64(TSharkTypeParser.Reverse(TSharkTypeParser.ParseOctBytes(show, 8)), 0); }*/ else //if (field.DisplayBase.StartsWith("BASE_DEC")) { v = ulong.Parse(show); } if (v >= byte.MinValue && v <= byte.MaxValue) { typedType = typeof(byte); typedValue = (byte)v; } else if (v >= ushort.MinValue && v <= ushort.MaxValue) { typedType = typeof(ushort); typedValue = (ushort)v; } else if (v >= uint.MinValue && v <= uint.MaxValue) { typedType = typeof(uint); typedValue = (uint)v; } else //if (v >= ulong.MinValue && v <= ulong.MaxValue) { typedType = typeof(ulong); typedValue = (ulong)v; } }
/// <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); } }
/// <summary> /// Constructor. /// </summary> /// <param name="field">Parent field.</param> /// <param name="value">Value the string corresponds to.</param> /// <param name="stringValue">Human readable string.</param> public TSharkStringValue(TSharkField field, long value, string stringValue) : base(field) { this.Value = value; this.StringValue = stringValue; }
/// <summary> /// Constructor. /// </summary> /// <param name="field">Parent field.</param> /// <param name="trueStringValue">The true string value.</param> /// <param name="falseStringValue">The false string value.</param> public TSharkStringTrueFalse(TSharkField field, string trueStringValue, string falseStringValue) : base(field) { this.TrueStringValue = trueStringValue; this.FalseStringValue = falseStringValue; }
/// <summary> /// Constructor. /// </summary> /// <param name="field">Parent field.</param> /// <param name="lowerBound">Lower bound of values the string corresponds to.</param> /// <param name="upperBound">Upper bound of values the string corresponds to.</param> /// <param name="stringValue">Human readable string.</param> public TSharkStringRange(TSharkField field, long lowerBound, long upperBound, string stringValue) : base(field) { this.LowerBound = lowerBound; this.UpperBound = upperBound; this.StringValue = stringValue; }
/// <summary> /// Constructor. /// </summary> /// <param name="field">Parent field.</param> public TSharkString(TSharkField field) { this.Field = field; field.Strings.Add(this); }