public override string GetValue(UInt64 ID)
 {
     try
     {
         var s = EvalString.Replace("?", ID.ToString());
         return(DataLookups.EvalUInt64(s).ToString());
     }
     catch
     {
         return("MATH-ERROR");
     }
 }
Exemplo n.º 2
0
        public string GetJobFlagsAtPos(int pos)
        {
            string res = "";

            if (pos > (RawBytes.Count - 4))
            {
                return(res);
            }
            UInt32 Flags = GetUInt32AtPos(pos);

            for (uint BitShiftCount = 0; BitShiftCount < 32; BitShiftCount++)
            {
                if ((Flags & 0x00000001) == 1)
                {
                    if (res != "")
                    {
                        res += " ";
                    }

                    if (BitShiftCount == 0)
                    {
                        res += "SubJob";
                    }
                    else
                    {
                        var JobName = DataLookups.NLU(DataLookups.LU_Job).GetValue(BitShiftCount);
                        if (JobName == "")
                        {
                            JobName = "[Bit" + BitShiftCount.ToString() + "]";
                        }
                        res += JobName;
                    }
                }
                Flags = Flags >> 1;
            }

            return(res);
        }
Exemplo n.º 3
0
        public bool SaveToFile(string filename)
        {
            List <string> sl = new List <string>();

            sl.Add("rem;original-file;" + Path.GetFileName(filename));
            switch (FilterOutType)
            {
            case FilterType.Off:
                sl.Add("outtype;off");
                break;

            case FilterType.ShowPackets:
                sl.Add("outtype;show");
                break;

            case FilterType.HidePackets:
                sl.Add("outtype;hide");
                break;

            case FilterType.AllowNone:
                sl.Add("outtype;none");
                break;
            }
            foreach (UInt16 i in FilterOutList)
            {
                sl.Add("out;0x" + i.ToString("X3") + ";" + DataLookups.NLU(DataLookups.LU_PacketOut).GetValue(i));
            }

            switch (FilterInType)
            {
            case FilterType.Off:
                sl.Add("intype;off");
                break;

            case FilterType.ShowPackets:
                sl.Add("intype;show");
                break;

            case FilterType.HidePackets:
                sl.Add("intype;hide");
                break;

            case FilterType.AllowNone:
                sl.Add("intype;none");
                break;
            }
            foreach (UInt16 i in FilterInList)
            {
                sl.Add("in;0x" + i.ToString("X3") + ";" + DataLookups.NLU(DataLookups.LU_PacketIn).GetValue(i));
            }

            try
            {
                File.WriteAllLines(filename, sl);
            }
            catch (Exception x)
            {
                MessageBox.Show("Failed to save " + filename + "\r\nException: " + x.Message, "Save Filter Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            return(true);
        }
Exemplo n.º 4
0
        public bool LoadFromFile(string filename)
        {
            try
            {
                List <string> sl = File.ReadAllLines(filename).ToList();

                Clear();
                foreach (string line in sl)
                {
                    var fields = line.Split(';');
                    if (fields.Length <= 1)
                    {
                        continue;
                    }

                    var f0 = fields[0].ToLower();
                    var f1 = fields[1].ToLower();

                    switch (f0)
                    {
                    case "outtype":
                        switch (f1)
                        {
                        case "off":
                            FilterOutType = FilterType.Off;
                            break;

                        case "show":
                            FilterOutType = FilterType.ShowPackets;
                            break;

                        case "hide":
                            FilterOutType = FilterType.HidePackets;
                            break;

                        case "none":
                            FilterOutType = FilterType.AllowNone;
                            break;
                        }
                        break;

                    case "intype":
                        switch (f1)
                        {
                        case "off":
                            FilterInType = FilterType.Off;
                            break;

                        case "show":
                            FilterInType = FilterType.ShowPackets;
                            break;

                        case "hide":
                            FilterInType = FilterType.HidePackets;
                            break;

                        case "none":
                            FilterInType = FilterType.AllowNone;
                            break;
                        }
                        break;

                    case "out":
                        if (DataLookups.TryFieldParse(f1, out int nout))
                        {
                            AddOutFilterValueToList((UInt16)nout);
                        }
                        break;

                    case "in":
                        if (DataLookups.TryFieldParse(f1, out int nin))
                        {
                            AddInFilterValueToList((UInt16)nin);
                        }
                        break;
                    }
                }
            }
            catch (Exception x)
            {
                MessageBox.Show("Failed to load " + filename + "\r\nException: " + x.Message, "Load Filter Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            return(true);
        }
Exemplo n.º 5
0
        public bool CompileData(PacketLogFileFormats plff)
        {
            if (RawBytes.Count < 4)
            {
                PacketID       = 0xFFFF;
                PacketDataSize = 0;
                HeaderText     = "Invalid Packet Size < 4";
                return(false);
            }
            PacketID       = (UInt16)(GetByteAtPos(0) + ((GetByteAtPos(1) & 0x01) * 0x100));
            PacketDataSize = (UInt16)((GetByteAtPos(1) & 0xFE) * 2);
            PacketSync     = (UInt16)(GetByteAtPos(2) + (GetByteAtPos(3) * 0x100));
            string TS = "";

            if (TimeStamp.Ticks > 0)
            {
                TS = TimeStamp.ToString("HH:mm:ss");
            }
            if (plff == PacketLogFileFormats.AshitaPacketeer)
            {
                // Packeteer doesn't have time info (yet)
                TimeStamp          = new DateTime(0);
                OriginalTimeString = "0000-00-00 00:00";
            }
            if (plff == PacketLogFileFormats.WindowerPacketViewer)
            {
                // Try to determine timestamp from header
                var P1 = OriginalHeaderText.IndexOf('[');
                var P2 = OriginalHeaderText.IndexOf(']');
                if ((P1 >= 0) && (P2 >= 0) && (P2 > P1))
                {
                    OriginalTimeString = OriginalHeaderText.Substring(P1 + 1, P2 - P1 - 1);
                    if (OriginalTimeString.Length > 0)
                    {
                        try
                        {
                            // try quick-parse first
                            DateTime dt;
                            if (DateTimeParse(OriginalTimeString, out dt))
                            {
                                TimeStamp = dt;
                            }
                            else
                            {
                                TimeStamp = DateTime.Parse(OriginalTimeString, cultureForDateTimeParse, stylesForDateTimeParse);
                            }
                            TS = TimeStamp.ToString("HH:mm:ss");
                        }
                        catch (FormatException)
                        {
                            TimeStamp          = new DateTime(0);
                            TS                 = "";
                            OriginalTimeString = "0000-00-00 00:00";
                        }
                    }
                }
            }
            VirtualTimeStamp = TimeStamp;
            if (TimeStamp.Ticks == 0)
            {
                TS = "";
            }

            string S = "";

            switch (PacketLogType)
            {
            case PacketLogTypes.Outgoing:
                S = "OUT ";
                break;

            case PacketLogTypes.Incoming:
                S = "IN  ";
                break;

            default:
                S = "??? ";
                break;
            }
            S          = TS + " : " + S + "0x" + PacketID.ToString("X3") + " - ";
            HeaderText = S + DataLookups.PacketTypeToString(PacketLogType, PacketID);
            return(true);
        }