def SendPacketTooBig(self, packet): src = packet.getlayer(scapy.IPv6).src datalen = IPV6_MIN_MTU - ICMPV6_HEADER_LEN self.SendPacket( scapy.IPv6(src=self.INTERMEDIATE_IPV6, dst=src) / scapy.ICMPv6PacketTooBig(mtu=self.LINK_MTU) / str(packet)[:datalen])
def ICMPPacketTooBig(version, srcaddr, dstaddr, packet): if version == 4: return ("ICMPv4 fragmentation needed", scapy.IP(src=srcaddr, dst=dstaddr, proto=1) / scapy.ICMPerror(type=3, code=4, unused=1280) / str(packet)[:64]) else: udp = packet.getlayer("UDP") udp.payload = str(udp.payload)[:1280-40-8] return ("ICMPv6 Packet Too Big", scapy.IPv6(src=srcaddr, dst=dstaddr) / scapy.ICMPv6PacketTooBig() / str(packet)[:1232])
def ICMPPacketTooBig(version, srcaddr, dstaddr, packet): if version == 4: desc = "ICMPv4 fragmentation needed" pkt = (scapy.IP(src=srcaddr, dst=dstaddr, proto=1) / scapy.ICMPerror(type=3, code=4) / str(packet)[:64]) # Only newer versions of scapy understand that since RFC 1191, the last two # bytes of a fragmentation needed ICMP error contain the MTU. if hasattr(scapy.ICMP, "nexthopmtu"): pkt[scapy.ICMPerror].nexthopmtu = PTB_MTU else: pkt[scapy.ICMPerror].unused = PTB_MTU return desc, pkt else: return ("ICMPv6 Packet Too Big", scapy.IPv6(src=srcaddr, dst=dstaddr) / scapy.ICMPv6PacketTooBig(mtu=PTB_MTU) / str(packet)[:1232])