Skip to content

Commit

Permalink
ESP32 compile fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
folkertvanheusden committed May 10, 2024
1 parent bd0304c commit 142d1f6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
1 change: 1 addition & 0 deletions ESP32/console_esp32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <stdio.h>
#include <unistd.h>

#include "bus.h"
#include "console_esp32.h"
#include "cpu.h"
#include "esp32.h"
Expand Down
11 changes: 4 additions & 7 deletions utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#if defined(ESP32) || defined(BUILD_FOR_RP2040)
#include <Arduino.h>
#include "rp2040.h"
#include <netdb.h>
#include <sys/socket.h>
#elif defined(_WIN32)
#include <ws2tcpip.h>
Expand Down Expand Up @@ -261,15 +262,11 @@ void set_nodelay(const int fd)

std::string get_endpoint_name(const int fd)
{
char host[64] { "?" };
char serv[32] { "?" };
sockaddr_in6 addr { 0 };
socklen_t addr_len = sizeof addr;
sockaddr_in addr { 0 };
socklen_t addr_len = sizeof addr;

if (getpeername(fd, reinterpret_cast<sockaddr *>(&addr), &addr_len) == -1)
return format("FAILED TO FIND NAME OF %d: %s", fd, strerror(errno));

getnameinfo(reinterpret_cast<sockaddr *>(&addr), addr_len, host, sizeof(host), serv, sizeof(serv), NI_NUMERICHOST | NI_NUMERICSERV);

return std::string(host) + "." + std::string(serv);
return std::string(inet_ntoa(addr.sin_addr)) + "." + format("%d", ntohs(addr.sin_port));
}

0 comments on commit 142d1f6

Please sign in to comment.