This commit is contained in:
2021-02-28 21:24:45 +01:00
parent 45d5f8af9b
commit f04376ddd9
2 changed files with 27 additions and 1 deletions

View File

@ -104,12 +104,38 @@ void networkSntpEngine(void *handle) {
coloredMsg(LOG_BLUE, "nes, nothing received yet, try again");
schAdd(networkSntpEngine, (void*) localHandle, 100, 0);
}
} else if (recvLen == sizeof(localHandle->ntpMsg)) {
} else if (recvLen >= sizeof(localHandle->ntpMsg)) {
memset(&(localHandle->ntpMsg), 0, sizeof(localHandle->ntpMsg));
uint8_t srcAddr[4];
uint16_t srcPort;
/*
recvfrom(SNTP_SOCK, (uint8_t*)(&(localHandle->ntpMsg)),
sizeof(localHandle->ntpMsg), srcAddr, &srcPort);
*/
uint8_t buf[90];
recvfrom(SNTP_SOCK, buf, sizeof(buf), srcAddr, &srcPort);
uint8_t x = 0;
coloredMsg(LOG_BLUE, "%02x %02x %02x %02x %02x %02x %02x %02x",
buf[x+0], buf[x+1], buf[x+2], buf[x+3], buf[x+4], buf[x+5], buf[x+6], buf[x+7]);
x += 8;
coloredMsg(LOG_BLUE, "%02x %02x %02x %02x %02x %02x %02x %02x",
buf[x+0], buf[x+1], buf[x+2], buf[x+3], buf[x+4], buf[x+5], buf[x+6], buf[x+7]);
x += 8;
coloredMsg(LOG_BLUE, "%02x %02x %02x %02x %02x %02x %02x %02x",
buf[x+0], buf[x+1], buf[x+2], buf[x+3], buf[x+4], buf[x+5], buf[x+6], buf[x+7]);
x += 8;
coloredMsg(LOG_BLUE, "%02x %02x %02x %02x %02x %02x %02x %02x",
buf[x+0], buf[x+1], buf[x+2], buf[x+3], buf[x+4], buf[x+5], buf[x+6], buf[x+7]);
x += 8;
coloredMsg(LOG_BLUE, "%02x %02x %02x %02x %02x %02x %02x %02x",
buf[x+0], buf[x+1], buf[x+2], buf[x+3], buf[x+4], buf[x+5], buf[x+6], buf[x+7]);
x += 8;
coloredMsg(LOG_BLUE, "%02x %02x %02x %02x %02x %02x %02x %02x",
buf[x+0], buf[x+1], buf[x+2], buf[x+3], buf[x+4], buf[x+5], buf[x+6], buf[x+7]);
x += 8;
coloredMsg(LOG_BLUE, "%02x %02x %02x %02x %02x %02x %02x %02x",
buf[x+0], buf[x+1], buf[x+2], buf[x+3], buf[x+4], buf[x+5], buf[x+6], buf[x+7]);
close(SNTP_SOCK);
coloredMsg(LOG_BLUE, "nes, msg received from %d.%d.%d.%d:%d",
srcAddr[0], srcAddr[1], srcAddr[2], srcAddr[3],

BIN
docs/ntp.pcap Normal file

Binary file not shown.