IPv6 packet constructor engineered

This commit is contained in:
giomba 2019-12-24 10:01:27 +01:00
parent c07807fc86
commit 3eb51a7442

View File

@ -53,7 +53,9 @@ IPv6Addr::IPv6Addr(const char* address) {
/******** IPv6Packet ********/
IPv6Packet::IPv6Packet() {
;
memset(packet, 0, LEN);
*(packet) = 0x60; /* IP version 6 */
*(packet + 7) = 64; /* hop limit / ttl */
}
IPv6Packet::IPv6Packet(const char* buffer, int len) {
@ -80,13 +82,9 @@ void IPv6Packet::setFlow(const char* flow) {
}
void IPv6Packet::setPayload(char* payload, int len) {
memset(packet, 0, LEN);
*(packet) = 0x60; /* IP version 6 */
*(packet + 4 + 1) = len & 0xff; /* length */
*(packet + 7) = 64; /* hop limit / ttl */
memcpy(packet + 40, payload, len); /* actual payload */
*(packet + 4 + 0) = len >> 8;
*(packet + 4 + 1) = len & 0xff;
memcpy(packet + 40, payload, len); /* payload */
}
void IPv6Packet::doAction() {