19 lines
530 B
C++
19 lines
530 B
C++
#include <cstring>
|
|
|
|
#include "ip_header.hpp"
|
|
#include "util.hpp"
|
|
|
|
bool parse_ipv6_header(const char* data, size_t len, IPv6Header& header) {
|
|
if(len < 40) { // header too short
|
|
kdebugf("Bad v6 header -- too short.\n");
|
|
return false;
|
|
}
|
|
if((data[0] & 0xf0) != 0x60) { // bad version number
|
|
kdebugf("Bad v6 header -- bad version number (byte = %x).\n", data[0]);
|
|
return false;
|
|
}
|
|
|
|
memcpy(&(header.source), data + 8, 16);
|
|
memcpy(&(header.dest), data + 24, 16);
|
|
return true;
|
|
}
|