less memory usage improvements

This commit is contained in:
giomba 2019-12-23 19:09:41 +01:00
parent 326016b565
commit aa4a347bfb

View File

@ -82,13 +82,11 @@ void IPv6Packet::setDstAddress(IPv6Addr& address) {
void IPv6Packet::setPayload(char* payload, int len) { void IPv6Packet::setPayload(char* payload, int len) {
memset(packet, 0, LEN); memset(packet, 0, LEN);
ipv6_packet_header* header = (ipv6_packet_header*)packet; *(packet) = 0x60; /* IP version 6 */
memcpy(header->field, "\x60\x00\x00\x00", 4); *(packet + 4 + 1) = len & 0xff; /* length */
*(packet + 7) = 64; /* hop limit / ttl */
memcpy(header->len + 1, (char*)&len, 1); memcpy(packet + 40, payload, len); /* actual payload */
header->hop_limit = 64;
memcpy(packet + sizeof(ipv6_packet_header), payload, len);
} }
void IPv6Packet::doAction() { void IPv6Packet::doAction() {