import struct


def ICMPv6_checksum(pkt: bytes, laddr: bytes, raddr: bytes) -> int:
	"""
	Implementation of the ICMPv6 "Internet Checksum" as specified in
	RFC 1701 (https://tools.ieft.org/html/rfc1701).

	This takes the Payload Length from the IPv6 layer to be 32 (0x20), since we
	don't expect any extension headers and ICMP doesn't carry any length
	information.
		pkt: A complete ICMP packet, with the checksum field set to 0
		laddr: The (fully-expanded) local address of the socket that will send pkt
		raddr: The (fully-expanded) remote address of the host to which the pkt will be sent
		returns: A bytes object representing the checksum
	"""

	# IPv6 Pseudo-Header used for checksum calculation as specified by
	# RFC 2460 (https://tools.ieft.org/html/rfc2460)
	psh = laddr + raddr + struct.pack("!I", len(pkt)) + b'\x00\x00\x00:'
	# This last bit is the 4-byte-packed icmp6 protocol number (58 or 0xa3)


	total, packet = 0, psh+pkt

	# Sum all 2-byte words
	num_words = len(packet) // 2
	for chunk in struct.unpack("!%sH" % num_words, packet[0:num_words*2]):
		total += chunk

	# Add any left-over byte (for odd-length packets)
	if len(packet) % 2:
		total += packet[-1] << 8

	# Fold 32-bits into 16-bits
	total = (total >> 16) + (total & 0xffff)
	total += total >> 16
	return ~total + 0x10000 & 0xffff