diff --git a/cube/User/Src/networkAbstractionLayer_lan.c b/cube/User/Src/networkAbstractionLayer_lan.c index bf19092..d7becae 100644 --- a/cube/User/Src/networkAbstractionLayer_lan.c +++ b/cube/User/Src/networkAbstractionLayer_lan.c @@ -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], diff --git a/docs/ntp.pcap b/docs/ntp.pcap new file mode 100644 index 0000000..f081487 Binary files /dev/null and b/docs/ntp.pcap differ