コード例 #1
0
        private void _parse()
        {
            _dstMac    = m_io.ReadBytes(6);
            _srcMac    = m_io.ReadBytes(6);
            _etherType = ((EtherTypeEnum)m_io.ReadU2be());
            switch (EtherType)
            {
            case EtherTypeEnum.Ipv4:
            {
                __raw_body = m_io.ReadBytesFull();
                var io___raw_body = new KaitaiStream(__raw_body);
                _body = new Ipv4Packet(io___raw_body);
                break;
            }

            case EtherTypeEnum.Ipv6:
            {
                __raw_body = m_io.ReadBytesFull();
                var io___raw_body = new KaitaiStream(__raw_body);
                _body = new Ipv6Packet(io___raw_body);
                break;
            }

            default:
            {
                _body = m_io.ReadBytesFull();
                break;
            }
            }
        }
コード例 #2
0
        private void _parse()
        {
            _version      = m_io.ReadBitsInt(4);
            _trafficClass = m_io.ReadBitsInt(8);
            _flowLabel    = m_io.ReadBitsInt(20);
            m_io.AlignToByte();
            _payloadLength  = m_io.ReadU2be();
            _nextHeaderType = m_io.ReadU1();
            _hopLimit       = m_io.ReadU1();
            _srcIpv6Addr    = m_io.ReadBytes(16);
            _dstIpv6Addr    = m_io.ReadBytes(16);
            switch (NextHeaderType)
            {
            case 17:
            {
                _nextHeader = new UdpDatagram(m_io);
                break;
            }

            case 0:
            {
                _nextHeader = new OptionHopByHop(m_io, this, m_root);
                break;
            }

            case 4:
            {
                _nextHeader = new Ipv4Packet(m_io);
                break;
            }

            case 6:
            {
                _nextHeader = new TcpSegment(m_io);
                break;
            }

            case 59:
            {
                _nextHeader = new NoNextHeader(m_io, this, m_root);
                break;
            }
            }
            _rest = m_io.ReadBytesFull();
        }
コード例 #3
0
 public Ipv4Option(KaitaiStream io, Ipv4Options parent = null, Ipv4Packet root = null) : base(io)
 {
     m_parent = parent;
     m_root   = root;
     _parse();
 }
コード例 #4
0
 public Ipv4Packet(KaitaiStream io, KaitaiStruct parent = null, Ipv4Packet root = null) : base(io)
 {
     m_parent = parent;
     m_root   = root ?? this;
     _parse();
 }