Skip to content

Commit

Permalink
sntp: Build fix
Browse files Browse the repository at this point in the history
Add log levels in order to fix build errors.
  • Loading branch information
dracc authored Oct 7, 2021
1 parent 799527a commit c936b6d
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions Includes/sntpClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,23 @@ void sntpClient::updateTime() const {
socklen_t saddr_len = sizeof(saddr);
int sent = sendto(s, &message, sizeof(message), 0, (struct sockaddr*)&saddr, saddr_len);
if (sent != sizeof(message)) {
InfoLog::outputLine("SNTP: Failed to send request message\n");
InfoLog::outputLine(InfoLog::INFO, "SNTP: Failed to send request message\n");
close(s);
return;
}

int received = recvfrom(s, &message, sizeof(message), 0, &saddr, &saddr_len);
close(s);
if (received != sizeof(message)) {
InfoLog::outputLine("SNTP: Failed to receive response: %d\n", received);
InfoLog::outputLine(InfoLog::INFO, "SNTP: Failed to receive response: %d\n", received);
return;
}

message.originTimestamp.seconds = htonl(message.originTimestamp.seconds);
message.originTimestamp.fractionalSeconds =
htonl(message.originTimestamp.fractionalSeconds);
if (message.originTimestamp.seconds || message.originTimestamp.fractionalSeconds) {
InfoLog::outputLine("SNTP: Origin epoch is not 0: %lld\n", message.originTimestamp);
InfoLog::outputLine(InfoLog::INFO, "SNTP: Origin epoch is not 0: %lld\n", message.originTimestamp);
}

message.transmitTimestamp.seconds = htonl(message.transmitTimestamp.seconds);
Expand All @@ -95,10 +95,10 @@ void sntpClient::updateTime() const {
}

if (delta > allowedDriftSeconds) {
InfoLog::outputLine("SNTP: Updating system clock (%llu seconds of drift)\n", delta);
InfoLog::outputLine(InfoLog::DEBUG, "SNTP: Updating system clock (%llu seconds of drift)\n", delta);
NTSTATUS status = NtSetSystemTime(&serverTime, nullptr);
if (!NT_SUCCESS(status)) {
InfoLog::outputLine("SNTP: NtSetSystemTime failed: %X\n", status);
InfoLog::outputLine(InfoLog::INFO, "SNTP: NtSetSystemTime failed: %X\n", status);
}
}

Expand All @@ -108,7 +108,7 @@ void sntpClient::updateTime() const {
#ifdef NXDK
static int sntpConnect(std::string const& sntpHost, uint32_t port, struct sockaddr& saddr) {
if (port > 0xFFFF) {
InfoLog::outputLine("SNTP: invalid port: %d\n", port);
InfoLog::outputLine(InfoLog::WARNING, "SNTP: invalid port: %d\n", port);
return -1;
}

Expand All @@ -124,14 +124,14 @@ static int sntpConnect(std::string const& sntpHost, uint32_t port, struct sockad
struct addrinfo* ai;
int status = getaddrinfo(sntpHost.c_str(), portString, &hints, &ai);
if (status) {
InfoLog::outputLine("SNTP: getaddrinfo failed: %d\n", status);
InfoLog::outputLine(InfoLog::INFO, "SNTP: getaddrinfo failed: %d\n", status);
return -1;
}

int ret;
ret = socket(ai->ai_family, ai->ai_socktype, ai->ai_protocol);
if (ret < 0) {
InfoLog::outputLine("SNTP: Failed to create socket: %d\n", errno);
InfoLog::outputLine(InfoLog::INFO, "SNTP: Failed to create socket: %d\n", errno);
freeaddrinfo(ai);
return ret;
}
Expand Down

0 comments on commit c936b6d

Please sign in to comment.