示例#1
0
 def cksum(self, ip, data="", nx=0):
     """Calculate the checksum for this ICMPv6 header, outside
        of a chain."""
     p6 = pseudoipv6.pseudoipv6()
     p6.src = ip.src
     p6.dst = ip.dst
     p6.length = len(self.getbytes()) + len(data)
     if nx:
         p6.next_header = nx
     else:
         p6.next_header = ip.next_header
     pkt = p6.getbytes() + self.getbytes() + data
     return ipv4.ipv4_cksum(pkt)
示例#2
0
文件: icmpv6.py 项目: gvnn3/PCS
 def cksum(self, ip, data = "", nx = 0):
     """Calculate the checksum for this ICMPv6 header, outside
        of a chain."""
     p6 = pseudoipv6.pseudoipv6()
     p6.src = ip.src
     p6.dst = ip.dst
     p6.length = len(self.getbytes()) + len (data)
     if nx:
         p6.next_header = nx
     else:
         p6.next_header = ip.next_header
     pkt = p6.getbytes() + self.getbytes() + data
     return ipv4.ipv4_cksum(pkt)
示例#3
0
文件: tcp.py 项目: jeamland/PCS
 def calc_checksum_v6(self, ip6):
     """Calculate and store the checksum for the TCP segment
        when encapsulated as an IPv6 payload with the given header."""
     from pcs.packets.ipv4 import ipv4
     from pcs.packets.pseudoipv6 import pseudoipv6
     self.checksum = 0
     payload = self._head.collate_following(self)
     pip6 = pseudoipv6()
     pip6.src = ip6.src
     pip6.dst = ip6.dst
     pip6.next_header = ip6.next_header
     pip6.length = len(self.getbytes()) + len(payload)
     tmpbytes = pip6.getbytes() + self.getbytes() + payload
     self.checksum = ipv4.ipv4_cksum(tmpbytes)
示例#4
0
文件: tcp.py 项目: victorlawn/PCS
 def calc_checksum_v6(self, ip6):
     """Calculate and store the checksum for the TCP segment
        when encapsulated as an IPv6 payload with the given header."""
     from pcs.packets.ipv4 import ipv4
     from pcs.packets.pseudoipv6 import pseudoipv6
     self.checksum = 0
     payload = self._head.collate_following(self)
     pip6 = pseudoipv6()
     pip6.src = ip6.src
     pip6.dst = ip6.dst
     pip6.next_header = ip6.next_header
     pip6.length = len(self.getbytes()) + len(payload)
     tmpbytes = pip6.getbytes() + self.getbytes() + payload
     self.checksum = ipv4.ipv4_cksum(tmpbytes)
示例#5
0
 def cksum(self, ip, data = "", nx = 0):
     """Calculate the checksum for this UDPv6 header, outside
        of any existing chain."""
     from pcs.packets.ipv4 import ipv4
     from pcs.packets.pseudoipv6 import pseudoipv6
     p6 = pseudoipv6()
     p6.src = ip.src
     p6.dst = ip.dst
     p6.length = len(self.getbytes()) + len(data)
     if nx:
         p6.next_header = nx
     else:
         p6.next_header = ip.next_header
     tmpbytes = p6.getbytes() + self.getbytes() + data
     return ipv4.ipv4_cksum(tmpbytes)
示例#6
0
 def calc_checksum(self):
     """Calculate and store the checksum for this ICMPv6 header.
        ICMPv6 checksums are computed over data payloads and
        next-headers. The packet must be part of a chain."""
     self.checksum = 0
     if self._head is not None:
         payload = self._head.collate_following(self)
         ip6 = self._head.find_preceding(self, pcs.packets.ipv6)
         assert ip6 is not None, "No preceding IPv6 header."
         pip6 = pseudoipv6.pseudoipv6()
         pip6.src = ip6.src
         pip6.dst = ip6.dst
         pip6.next_header = ip6.next_header
         pip6.length = len(self.getbytes()) + len(payload)
         tmpbytes = pip6.getbytes() + self.getbytes() + payload
     else:
         tmpbytes = self.getbytes()
     self.checksum = ipv4.ipv4_cksum(tmpbytes)
示例#7
0
文件: icmpv6.py 项目: gvnn3/PCS
 def calc_checksum(self):
     """Calculate and store the checksum for this ICMPv6 header.
        ICMPv6 checksums are computed over data payloads and
        next-headers. The packet must be part of a chain."""
     self.checksum = 0
     if self._head is not None:
         payload = self._head.collate_following(self)
         ip6 = self._head.find_preceding(self, pcs.packets.ipv6)
         assert ip6 is not None, "No preceding IPv6 header."
         pip6 = pseudoipv6.pseudoipv6()
         pip6.src = ip6.src
         pip6.dst = ip6.dst
         pip6.next_header = ip6.next_header
         pip6.length = len(self.getbytes()) + len(payload)
         tmpbytes = pip6.getbytes() + self.getbytes() + payload
     else:
         tmpbytes = self.getbytes()
     self.checksum = ipv4.ipv4_cksum(tmpbytes)