Example #1
0
        private void _parse()
        {
            f_version       = false;
            f_ihl           = false;
            f_ihlBytes      = false;
            _b1             = m_io.ReadU1();
            _b2             = m_io.ReadU1();
            _totalLength    = m_io.ReadU2be();
            _identification = m_io.ReadU2be();
            _b67            = m_io.ReadU2be();
            _ttl            = m_io.ReadU1();
            _protocol       = ((ProtocolEnum)m_io.ReadU1());
            _headerChecksum = m_io.ReadU2be();
            _srcIpAddr      = m_io.ReadBytes(4);
            _dstIpAddr      = m_io.ReadBytes(4);
            __raw_options   = m_io.ReadBytes((IhlBytes - 20));
            var io___raw_options = new KaitaiStream(__raw_options);

            _options = new Ipv4Options(io___raw_options, this, m_root);
            switch (Protocol)
            {
            case ProtocolEnum.Tcp: {
                __raw_body = m_io.ReadBytes((TotalLength - IhlBytes));
                var io___raw_body = new KaitaiStream(__raw_body);
                _body = new TcpSegment(io___raw_body);
                break;
            }

            case ProtocolEnum.Icmp: {
                __raw_body = m_io.ReadBytes((TotalLength - IhlBytes));
                var io___raw_body = new KaitaiStream(__raw_body);
                _body = new IcmpPacket(io___raw_body);
                break;
            }

            case ProtocolEnum.Udp: {
                __raw_body = m_io.ReadBytes((TotalLength - IhlBytes));
                var io___raw_body = new KaitaiStream(__raw_body);
                _body = new UdpDatagram(io___raw_body);
                break;
            }

            case ProtocolEnum.Ipv6: {
                __raw_body = m_io.ReadBytes((TotalLength - IhlBytes));
                var io___raw_body = new KaitaiStream(__raw_body);
                _body = new Ipv6Packet(io___raw_body);
                break;
            }

            default: {
                _body = m_io.ReadBytes((TotalLength - IhlBytes));
                break;
            }
            }
        }
Example #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();
        }
Example #3
0
            private void _parse()
            {
                _nextHeaderType = m_io.ReadU1();
                _hdrExtLen      = m_io.ReadU1();
                _body           = m_io.ReadBytes((HdrExtLen - 1));
                switch (NextHeaderType)
                {
                case 0: {
                    _nextHeader = new OptionHopByHop(m_io, this, m_root);
                    break;
                }

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

                case 59: {
                    _nextHeader = new NoNextHeader(m_io, this, m_root);
                    break;
                }
                }
            }
Example #4
0
 public TcpSegment(KaitaiStream io, KaitaiStruct parent = null, TcpSegment root = null) : base(io)
 {
     m_parent = parent;
     m_root   = root ?? this;
     _parse();
 }