Ejemplo n.º 1
0
 def compute_checksum(self):
     self.header_checksum.val = 0
     
     packet = self.raw_val(parents=False)
     
     self.header_checksum.val = utils.cksum(packet)
     
     return self.header_checksum.val
Ejemplo n.º 2
0
 def compute_checksum(self):
     self.checksum.val = 0
     
     ipv4_pseudo_header = '%s%s\x00%s%s' % (
         self._parent.saddr.raw_val(),
         self._parent.daddr.raw_val(),
         self._parent.protocol.raw_val('B'),
         fields.Int(self.length.val).raw_val('!H'),
     )
     
     self.checksum.val = utils.cksum(ipv4_pseudo_header + self.raw_val(parents=False) + self.payload)
     
     return self.checksum.val
Ejemplo n.º 3
0
 def compute_checksum(self):
     self.checksum = fields.HexIntClass(0, 4)
     packet = self.raw_val(parents=False) + self.payload
     self.checksum.val = utils.cksum(packet)
     
     return self.checksum