Exemple #1
0
 public EricScanner(uint recordLength, uint recordType, BigEndianBinaryReader contentStream)
 {
     RecordLength = recordLength;
     RecordType = recordType;
     Hour = contentStream.ReadByte();
     Minute = contentStream.ReadByte();
     Second = contentStream.ReadUInt16();
     Millisecond = contentStream.ReadUInt16();
     Scannerid = contentStream.ReadUInts(3);
     Status = contentStream.ReadByte();
     PaddingBytes = contentStream.ReadChars(2);
 }
 public void TestMethod()
 {
     byte[] buffer = { 0, 0, 0x12, 0x34, 0x56, 120 };
     MemoryStream input = new MemoryStream(buffer);
     BigEndianBinaryReader reader = new BigEndianBinaryReader(input);
     Assert.That(reader.ReadUInt32(), Is.EqualTo(0x1234));
     Assert.That(reader.ReadUInt16(), Is.EqualTo(0x5678));
 }
Exemple #3
0
 public EricUdpStream(uint recordLength, uint recordType, BigEndianBinaryReader contentStream)
 {
     RecordLength = recordLength;
     RecordType = recordType;
     FileFormatVersion = contentStream.ReadChars(5);
     PmRecordingRevision = contentStream.ReadChars(5);
     TraceReference = contentStream.ReadChars(6);
     Scanner = contentStream.ReadUInt16();
     Package = contentStream.ReadUInt32();
 }
Exemple #4
0
 public EricHeader(uint recordLength, uint recordType, BigEndianBinaryReader contentStream)
 {
     RecordLength = recordLength;
     RecordType = recordType;
     FileFormatVersion = contentStream.ReadChars(5);
     PmRecordingRevision = contentStream.ReadChars(((int)RecordLength) - 0x18f);
     Year = contentStream.ReadUInt16();
     Month = contentStream.ReadByte();
     Day = contentStream.ReadByte();
     Hour = contentStream.ReadByte();
     Minute = contentStream.ReadByte();
     Second = contentStream.ReadByte();
     NeUserLabel = contentStream.ReadChars(0x80);
     NeLogicalName = contentStream.ReadChars(0xff);
 }
Exemple #5
0
 public EricTcpStream(uint recordLength, uint recordType, BigEndianBinaryReader contentStream)
 {
     RecordLength = recordLength;
     RecordType = recordType;
     FileFormatVersion = contentStream.ReadChars(5);
     PmRecordingRevision = contentStream.ReadChars(5);
     Year = contentStream.ReadUInt16();
     Month = contentStream.ReadUInt16();
     Day = contentStream.ReadUInt16();
     Hour = contentStream.ReadUInt16();
     Minute = contentStream.ReadUInt16();
     Second = contentStream.ReadUInt16();
     NeUserLabel = contentStream.ReadChars(0x80);
     NeLogicalName = contentStream.ReadChars(0xff);
     Scanner = contentStream.ReadUInt16();
     CauseOfHeader = contentStream.ReadUInt16();
     NoOfDroppedEvents = contentStream.ReadUInt32();
 }
Exemple #6
0
        public static List<IEric> ParseEricFile(string outPath, string binPath, bool isGz, bool isParseAsn, uint[] parTraces = null)
        {
            Stream stream;
            if (!string.IsNullOrEmpty(outPath))
            {
                new StringBuilder();
            }
            Hashtable ericPmEvents = EricPmEvent.GetEricPmEvents();
            if (isGz)
            {
                stream = UnzipToMemoryStream(binPath);
            }
            else
            {
                stream = new FileStream(binPath, FileMode.Open, FileAccess.Read);
            }
            stream.Position = 0L;
            BigEndianBinaryReader contentStream = new BigEndianBinaryReader(stream);
            List<IEric> list = new List<IEric>();
            while (!contentStream.Eof())
            {
                uint recordLength = contentStream.ReadUInt16();
                uint recordType = contentStream.ReadUInt16();
                IEric item = null;
                switch (((EricHeadEnum)recordType))
                {
                    case EricHeadEnum.EricHeader:
                        item = new EricHeader(recordLength, recordType, contentStream);
                        break;

                    case EricHeadEnum.EricTcpStream:
                        item = new EricTcpStream(recordLength, recordType, contentStream);
                        break;

                    case EricHeadEnum.EricUdpStream:
                        item = new EricUdpStream(recordLength, recordType, contentStream);
                        break;

                    case EricHeadEnum.EricScanner:
                        item = new EricScanner(recordLength, recordType, contentStream);
                        break;

                    case EricHeadEnum.EricEvent:
                        item = new EricEvent(recordLength, recordType, contentStream, ericPmEvents, false);
                        break;

                    case EricHeadEnum.EricFooter:
                        item = new EricFooter(recordLength, recordType, contentStream);
                        break;
                }
                if ((parTraces != null) && (item is EricEvent))
                {
                    if (parTraces.Contains(((EricEvent)item).EventId))
                    {
                        list.Add(item);
                    }
                    if (isParseAsn)
                    {
                        ((EricEvent)item).ParseAsn();
                    }
                }
                else
                {
                    if (isParseAsn && (item is EricEvent))
                    {
                        ((EricEvent)item).ParseAsn();
                    }
                    list.Add(item);
                }
            }
            return list;
        }
Exemple #7
0
 private void ParseMsg0(BigEndianBinaryReader reader)
 {
     string str;
     Msg0Block item = new Msg0Block
     {
         typeid_ui4 = reader.ReadUInt32(),
         head_length_ui2 = reader.ReadUInt16(),
         callid_ui4 = reader.ReadUInt32(),
         cell_id_ui4 = reader.ReadUInt32(),
         year_ui2 = reader.ReadUInt16(),
         month_ui1 = reader.ReadSByte(),
         day_ui1 = reader.ReadSByte(),
         hour_ui1 = reader.ReadSByte(),
         minute_ui1 = reader.ReadSByte(),
         second_ui1 = reader.ReadSByte(),
         localcell_id_ui1 = reader.ReadSByte(),
         micro_second_ui4 = reader.ReadUInt32(),
         direction_ui1 = reader.ReadSByte(),
         reserved_ui1 = reader.ReadSByte()
     };
     reader.BaseStream.Seek(item.head_length_ui2 - 0x16, SeekOrigin.Current);
     item.body_length_ui2 = reader.ReadUInt16();
     byte[] buffer = new byte[item.body_length_ui2];
     reader.Read(buffer, 0, item.body_length_ui2);
     item.setBody_bytes(buffer);
     Typeswitch.TryGetValue(item.typeid_ui4, out str);
     item.AsnParseClass = str;
     if ((ParTraces != null) && ParTraces.Contains(item.typeid_ui4))
     {
         if (IsParseAsn)
         {
             item.ParseAsn();
         }
         lstmsg.Add(item);
     }
     else if (ParTraces == null)
     {
         if (IsParseAsn)
         {
             item.ParseAsn();
         }
         lstmsg.Add(item);
     }
 }
Exemple #8
0
        public void Parse(Stream stream, bool isParseAsn, uint[] parTraces = null)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }
            BigEndianBinaryReader reader = new BigEndianBinaryReader(stream);
            FileHeader header = new FileHeader
            {
                file_flag_ui4 = reader.ReadUInt32()
            };
            reader.ReadString(4);
            reader.ReadUInt32();
            header.fver_ui2 = reader.ReadUInt16();
            reader.ReadString(4);
            reader.ReadUInt32();
            header.ttyp_ui2 = reader.ReadUInt16();
            reader.ReadString(4);
            reader.ReadUInt32();
            header.fno_ui4 = reader.ReadUInt32();
            reader.ReadString(4);
            reader.ReadUInt32();
            header.ntyp_i1 = reader.ReadByte();
            reader.ReadString(4);
            reader.ReadUInt32();
            header.nver_s40 = reader.ReadString(40);
            reader.ReadString(4);
            reader.ReadUInt32();
            header.ndep_ui1 = reader.ReadSByte();
            OnFileHeader(header);

            ParTraces = parTraces;
            IsParseAsn = isParseAsn;
            uint num = BlockType("msg0");
            while (!reader.Eof())
            {
                uint num2 = reader.ReadUInt32();
                if (num2 == num)
                {
                    ParseMsg0(reader);
                }
                else
                {
                    Console.WriteLine("unknown block type as {0:X}, expect {1:X}, but {2:X}",
                        reader.BaseStream.Position, num, num2);
                    return;
                }
            }
        }
Exemple #9
0
 private void InitailEvent(uint recordLength, uint recordType, BigEndianBinaryReader _contentStream, Hashtable htEventPm)
 {
     RecordLength = recordLength;
     RecordType = recordType;
     byte[] buffer = _contentStream.ReadBytes(((int)recordLength) - 4);
     recordLength -= 4;
     MemoryStream input = new MemoryStream(buffer);
     BigEndianBinaryReader reader = new BigEndianBinaryReader(input);
     long position = reader.BaseStream.Position;
     long num3;
     EventId = reader.ReadUInts(3);
     _AsnType = htEventPm[(int)EventId] as EricPmEvent;
     TimeStampHour = reader.ReadByte();
     TimeStampMinute = reader.ReadByte();
     TimeStampSecond = reader.ReadByte();
     TimeStampMilliSec = reader.ReadUInt16();
     ScannerId = reader.ReadUInts(3);
     RbsModuleId = reader.ReadByte();
     GlobalCellId = reader.ReadUInt32();
     if (((_AsnType == null) || _AsnType.EventType.Equals("CELL")) || _AsnType.EventType.Equals("RBS"))
     {
         num3 = reader.BaseStream.Position - position;
         UnPaserTraseContent = reader.ReadHex((int)(recordLength - num3));
     }
     else
     {
         EnbS1ApId = reader.ReadUInts(3);
         MmeS1ApId = reader.ReadUInt32();
         Gummei = reader.ReadHex(7);
         RacUeRef = reader.ReadUInt32();
         TraceRecordingSessionReference = reader.ReadUInts(3);
         MessageDirection = reader.ReadByte();
         if (_AsnType.EventType.Equals("UE"))
         {
             num3 = reader.BaseStream.Position - position;
             UnPaserTraseContent = reader.ReadHex((int)(recordLength - num3));
         }
         else
         {
             L3MessageLength = reader.ReadUInt16();
             L3MessageContents = reader.ReadBytes(L3MessageLength);
             num3 = reader.BaseStream.Position - position;
             PaddingBytes = reader.ReadChars((int)(recordLength - num3));
         }
     }
 }