import struct


def icmpParse(pkt: bytes, ipv6: bool) -> int:
	"""
	Parses an icmp packet, returning its sequence number.

	If the packet is found to be not an echo reply, this will
		immediately return -1, indicating that this packet
		should be disregarded.
	"""
	try:
		if ipv6:
			if pkt[0] == 129:
				return struct.unpack("!H", pkt[6:8])[0]
			return -1
		if pkt[20] == 0:
			return struct.unpack("!H", pkt[26:28])[0]
		return -1
	except (IndexError, struct.error):
		return -1