Esempio n. 1
0
        private void _read()
        {
            _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;
            }
            }
        }
 public Ipv4Option(KaitaiStream p__io, Ipv4Packet.Ipv4Options p__parent = null, Ipv4Packet p__root = null) : base(p__io)
 {
     m_parent   = p__parent;
     m_root     = p__root;
     f_copy     = false;
     f_optClass = false;
     f_number   = false;
     _read();
 }
 public Ipv4Packet(KaitaiStream p__io, KaitaiStruct p__parent = null, Ipv4Packet p__root = null) : base(p__io)
 {
     m_parent   = p__parent;
     m_root     = p__root ?? this;
     f_version  = false;
     f_ihl      = false;
     f_ihlBytes = false;
     _read();
 }
        private void _read()
        {
            _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();
        }
 public Ipv4Options(KaitaiStream p__io, Ipv4Packet p__parent = null, Ipv4Packet p__root = null) : base(p__io)
 {
     m_parent = p__parent;
     m_root   = p__root;
     _read();
 }