IPv6 packet constructor engineered
This commit is contained in:
parent
c07807fc86
commit
3eb51a7442
20
ipv6.ino
20
ipv6.ino
@ -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,16 +82,12 @@ void IPv6Packet::setFlow(const char* flow) {
|
||||
}
|
||||
|
||||
void IPv6Packet::setPayload(char* payload, int len) {
|
||||
memset(packet, 0, LEN);
|
||||
*(packet + 4 + 0) = len >> 8;
|
||||
*(packet + 4 + 1) = len & 0xff;
|
||||
memcpy(packet + 40, payload, len); /* payload */
|
||||
}
|
||||
|
||||
*(packet) = 0x60; /* IP version 6 */
|
||||
*(packet + 4 + 1) = len & 0xff; /* length */
|
||||
*(packet + 7) = 64; /* hop limit / ttl */
|
||||
|
||||
memcpy(packet + 40, payload, len); /* actual payload */
|
||||
}
|
||||
|
||||
void IPv6Packet::doAction() {
|
||||
void IPv6Packet::doAction() {
|
||||
/* if destination is my address, or destination is "all nodes" address, then... */
|
||||
if ((memcmp(&(ALL_NODES_ADDRESS), packet + 24, 16) == 0) || (memcmp(&(coppino::address), packet + 24, 16) == 0)) {
|
||||
int len = ((*(packet + 4)) << 8) + (*(packet + 5));
|
||||
@ -106,7 +104,7 @@ void IPv6Packet::setPayload(char* payload, int len) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void handleICMP(const char* src_addr, const char* dst_addr, const char* flow, char* packet, int len) {
|
||||
uint8_t type = *(packet);
|
||||
|
Loading…
Reference in New Issue
Block a user