ESP32 compile fixes

This commit is contained in:
folkert van heusden 2024-05-10 20:21:18 +02:00
parent bd0304c5e2
commit 142d1f6ff1
Signed by untrusted user who does not match committer: folkert
GPG key ID: 6B6455EDFEED3BD1
2 changed files with 5 additions and 7 deletions

View file

@ -5,6 +5,7 @@
#include <stdio.h>
#include <unistd.h>
#include "bus.h"
#include "console_esp32.h"
#include "cpu.h"
#include "esp32.h"

View file

@ -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>
@ -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));
}