Beispiel #1
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);
     }
 }
Beispiel #2
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;
                }
            }
        }