diff --git a/src/FakeroutePacket.cpp b/src/FakeroutePacket.cpp index dfac219..33d09f6 100644 --- a/src/FakeroutePacket.cpp +++ b/src/FakeroutePacket.cpp @@ -110,17 +110,16 @@ void FakeroutePacket::buildIcmpHeader(char* packet, int protocol) { struct iphdr *fakeIpHdr; struct icmp *icmpHeader = (struct icmp*)packet; - char fakePacket[IP_HDR_SIZE] = {0}; - fakeIpHdr = (struct iphdr*)fakePacket; + icmpHeader->icmp_type = getIcmpType(); + icmpHeader->icmp_code = getIcmpCode(); + + fakeIpHdr = (struct iphdr*) &icmpHeader->icmp_ip; fakeIpHdr->ihl = 5; fakeIpHdr->version = 4; fakeIpHdr->protocol = protocol; fakeIpHdr->saddr = inet_addr(receivedSourceAddress); fakeIpHdr->daddr = inet_addr(spoofedDestinationAddress); - icmpHeader->icmp_type = getIcmpType(); - icmpHeader->icmp_code = getIcmpCode(); - icmpHeader->icmp_ip = *(struct ip*)fakePacket; icmpHeader->icmp_cksum = (unsigned short)in_cksum((unsigned short*)packet, ICMP_HDR_SIZE + 8); }