IPv6 packet constructor engineered
This commit is contained in:
parent
c07807fc86
commit
3eb51a7442
14
ipv6.ino
14
ipv6.ino
@ -53,7 +53,9 @@ IPv6Addr::IPv6Addr(const char* address) {
|
|||||||
|
|
||||||
/******** IPv6Packet ********/
|
/******** IPv6Packet ********/
|
||||||
IPv6Packet::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) {
|
IPv6Packet::IPv6Packet(const char* buffer, int len) {
|
||||||
@ -80,13 +82,9 @@ void IPv6Packet::setFlow(const char* flow) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void IPv6Packet::setPayload(char* payload, int len) {
|
void IPv6Packet::setPayload(char* payload, int len) {
|
||||||
memset(packet, 0, LEN);
|
*(packet + 4 + 0) = len >> 8;
|
||||||
|
*(packet + 4 + 1) = len & 0xff;
|
||||||
*(packet) = 0x60; /* IP version 6 */
|
memcpy(packet + 40, payload, len); /* payload */
|
||||||
*(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() {
|
||||||
|
Loading…
Reference in New Issue
Block a user