示例#1
0
 def _read(self):
     self._debug['body']['start'] = self._io.pos()
     _on = self.protocol
     if _on == self._root.ProtocolEnum.ipv6_nonxt:
         self.body = self._root.NoNextHeader(self._io, self, self._root)
         self.body._read()
     elif _on == self._root.ProtocolEnum.ipv4:
         self.body = ipv4_packet.Ipv4Packet(self._io)
         self.body._read()
     elif _on == self._root.ProtocolEnum.udp:
         self.body = udp_datagram.UdpDatagram(self._io)
         self.body._read()
     elif _on == self._root.ProtocolEnum.icmp:
         self.body = icmp_packet.IcmpPacket(self._io)
         self.body._read()
     elif _on == self._root.ProtocolEnum.hopopt:
         self.body = self._root.OptionHopByHop(self._io, self, self._root)
         self.body._read()
     elif _on == self._root.ProtocolEnum.ipv6:
         self.body = ipv6_packet.Ipv6Packet(self._io)
         self.body._read()
     elif _on == self._root.ProtocolEnum.tcp:
         self.body = tcp_segment.TcpSegment(self._io)
         self.body._read()
     self._debug['body']['end'] = self._io.pos()
示例#2
0
 def _read(self):
     _on = self.protocol
     if _on == ProtocolBody.ProtocolEnum.ipv6_nonxt:
         self.body = ProtocolBody.NoNextHeader(self._io, self, self._root)
     elif _on == ProtocolBody.ProtocolEnum.ipv4:
         self.body = ipv4_packet.Ipv4Packet(self._io)
     elif _on == ProtocolBody.ProtocolEnum.udp:
         self.body = udp_datagram.UdpDatagram(self._io)
     elif _on == ProtocolBody.ProtocolEnum.icmp:
         self.body = icmp_packet.IcmpPacket(self._io)
     elif _on == ProtocolBody.ProtocolEnum.hopopt:
         self.body = ProtocolBody.OptionHopByHop(self._io, self, self._root)
     elif _on == ProtocolBody.ProtocolEnum.ipv6:
         self.body = ipv6_packet.Ipv6Packet(self._io)
     elif _on == ProtocolBody.ProtocolEnum.tcp:
         self.body = tcp_segment.TcpSegment(self._io)
示例#3
0
    def _read(self):
        self.dst_mac = self._io.read_bytes(6)
        self.src_mac = self._io.read_bytes(6)
        self.ether_type_1 = KaitaiStream.resolve_enum(EthernetFrame.EtherTypeEnum, self._io.read_u2be())
        if self.ether_type_1 == EthernetFrame.EtherTypeEnum.ieee_802_1q_tpid:
            self.tci = EthernetFrame.TagControlInfo(self._io, self, self._root)

        if self.ether_type_1 == EthernetFrame.EtherTypeEnum.ieee_802_1q_tpid:
            self.ether_type_2 = KaitaiStream.resolve_enum(EthernetFrame.EtherTypeEnum, self._io.read_u2be())

        _on = self.ether_type
        if _on == EthernetFrame.EtherTypeEnum.ipv4:
            self._raw_body = self._io.read_bytes_full()
            _io__raw_body = KaitaiStream(BytesIO(self._raw_body))
            self.body = ipv4_packet.Ipv4Packet(_io__raw_body)
        elif _on == EthernetFrame.EtherTypeEnum.ipv6:
            self._raw_body = self._io.read_bytes_full()
            _io__raw_body = KaitaiStream(BytesIO(self._raw_body))
            self.body = ipv6_packet.Ipv6Packet(_io__raw_body)
        else:
            self.body = self._io.read_bytes_full()
    def _read(self):
        self._debug['dst_mac']['start'] = self._io.pos()
        self.dst_mac = self._io.read_bytes(6)
        self._debug['dst_mac']['end'] = self._io.pos()
        self._debug['src_mac']['start'] = self._io.pos()
        self.src_mac = self._io.read_bytes(6)
        self._debug['src_mac']['end'] = self._io.pos()
        self._debug['ether_type_1']['start'] = self._io.pos()
        self.ether_type_1 = KaitaiStream.resolve_enum(self._root.EtherTypeEnum,
                                                      self._io.read_u2be())
        self._debug['ether_type_1']['end'] = self._io.pos()
        if self.ether_type_1 == self._root.EtherTypeEnum.ieee_802_1q_tpid:
            self._debug['tci']['start'] = self._io.pos()
            self.tci = self._root.TagControlInfo(self._io, self, self._root)
            self.tci._read()
            self._debug['tci']['end'] = self._io.pos()

        if self.ether_type_1 == self._root.EtherTypeEnum.ieee_802_1q_tpid:
            self._debug['ether_type_2']['start'] = self._io.pos()
            self.ether_type_2 = KaitaiStream.resolve_enum(
                self._root.EtherTypeEnum, self._io.read_u2be())
            self._debug['ether_type_2']['end'] = self._io.pos()

        self._debug['body']['start'] = self._io.pos()
        _on = self.ether_type
        if _on == self._root.EtherTypeEnum.ipv4:
            self._raw_body = self._io.read_bytes_full()
            _io__raw_body = KaitaiStream(BytesIO(self._raw_body))
            self.body = ipv4_packet.Ipv4Packet(_io__raw_body)
            self.body._read()
        elif _on == self._root.EtherTypeEnum.ipv6:
            self._raw_body = self._io.read_bytes_full()
            _io__raw_body = KaitaiStream(BytesIO(self._raw_body))
            self.body = ipv6_packet.Ipv6Packet(_io__raw_body)
            self.body._read()
        else:
            self.body = self._io.read_bytes_full()
        self._debug['body']['end'] = self._io.pos()