Exemplo n.º 1
0
 def _update_fields(self):
     if self.sum_au_active and self._changed():
         # logger.debug(">>> IP: calculating sum")
         # reset checksum for recalculation,  mark as changed / clear cache
         self.sum = 0
         # logger.debug(">>> IP: bytes for sum: %s" % self.header_bytes)
         self.sum = checksum.in_cksum(
             packetracer.Packet.bin(self, update_auto_fields=True))
Exemplo n.º 2
0
    def _calc_sum(self):
        try:
            # we need src/dst for checksum-calculation
            src, dst = self._lower_layer.src, self._lower_layer.dst
        except Exception:
            # not an IP packet as lower layer (src, dst not present) or invalid src/dst
            # logger.debug("could not calculate checksum: %r" % e)
            return

        # pseudoheader
        # packet length = length of upper layers
        self.sum = 0
        # logger.debug("TCP sum recalc: IP6= len(src)=%d\n%s\n%s\nhdr=%s\nbody=%s" %
        #			 (len(src), src, dst, self.header_bytes, self.body_bytes))
        pkt = self.header_bytes + self.body_bytes
        hdr = pack_ipv6_icmp6(src, dst, len(pkt), 58)
        # this will set the header status to changes, should be reset by calling bin()
        self.sum = checksum.in_cksum(hdr + pkt)
Exemplo n.º 3
0
 def _update_fields(self):
     if self.sum_au_active and self._changed():
         self.sum = 0
         self.sum = checksum.in_cksum(packetracer.Packet.bin(self))