Log messages on packet reception
This commit is contained in:
parent
18741af602
commit
750f9e3672
1 changed files with 4 additions and 5 deletions
|
@ -163,7 +163,6 @@ void Protocol::pollNetwork() {
|
||||||
struct sockaddr* fromAddr = (struct sockaddr*)&fromAddr6;
|
struct sockaddr* fromAddr = (struct sockaddr*)&fromAddr6;
|
||||||
socklen_t fromAddrLen;
|
socklen_t fromAddrLen;
|
||||||
while(!terminating) {
|
while(!terminating) {
|
||||||
//TODO is it blocking?
|
|
||||||
ssize_t readDat = recvfrom(sock, buffer, MAX_MTU, 0,
|
ssize_t readDat = recvfrom(sock, buffer, MAX_MTU, 0,
|
||||||
fromAddr, &fromAddrLen);
|
fromAddr, &fromAddrLen);
|
||||||
if(readDat <= 0)
|
if(readDat <= 0)
|
||||||
|
@ -172,21 +171,21 @@ void Protocol::pollNetwork() {
|
||||||
u8 magic, version;
|
u8 magic, version;
|
||||||
data >> magic >> version;
|
data >> magic >> version;
|
||||||
if(magic != csts::MAGIC) {
|
if(magic != csts::MAGIC) {
|
||||||
//TODO log
|
fprintf(stderr, "[WARNING] Bad magic byte %u\n", magic);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if(version != csts::VERSION) {
|
if(version != csts::VERSION) {
|
||||||
//TODO log
|
fprintf(stderr, "[WARNING] Bad version %d\n", version);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
u16 bodyLen;
|
u16 bodyLen;
|
||||||
data >> bodyLen;
|
data >> bodyLen;
|
||||||
if(data.size() < bodyLen + 64u) {
|
if(data.size() < bodyLen + 64u) {
|
||||||
//TODO log bad length
|
fprintf(stderr, "[WARNING] Body too short\n");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if(data.size() != bodyLen + 64u) {
|
else if(data.size() != bodyLen + 64u) {
|
||||||
//TODO log warning bad length
|
fprintf(stderr, "[WARNING] Body too long\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
SockAddr convFromAddr;
|
SockAddr convFromAddr;
|
||||||
|
|
Loading…
Reference in a new issue