ESP32 compile fixes
This commit is contained in:
parent
bd0304c5e2
commit
142d1f6ff1
2 changed files with 5 additions and 7 deletions
|
@ -5,6 +5,7 @@
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "bus.h"
|
||||||
#include "console_esp32.h"
|
#include "console_esp32.h"
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "esp32.h"
|
#include "esp32.h"
|
||||||
|
|
11
utils.cpp
11
utils.cpp
|
@ -6,6 +6,7 @@
|
||||||
#if defined(ESP32) || defined(BUILD_FOR_RP2040)
|
#if defined(ESP32) || defined(BUILD_FOR_RP2040)
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
#include "rp2040.h"
|
#include "rp2040.h"
|
||||||
|
#include <netdb.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
#include <ws2tcpip.h>
|
#include <ws2tcpip.h>
|
||||||
|
@ -261,15 +262,11 @@ void set_nodelay(const int fd)
|
||||||
|
|
||||||
std::string get_endpoint_name(const int fd)
|
std::string get_endpoint_name(const int fd)
|
||||||
{
|
{
|
||||||
char host[64] { "?" };
|
sockaddr_in addr { 0 };
|
||||||
char serv[32] { "?" };
|
socklen_t addr_len = sizeof addr;
|
||||||
sockaddr_in6 addr { 0 };
|
|
||||||
socklen_t addr_len = sizeof addr;
|
|
||||||
|
|
||||||
if (getpeername(fd, reinterpret_cast<sockaddr *>(&addr), &addr_len) == -1)
|
if (getpeername(fd, reinterpret_cast<sockaddr *>(&addr), &addr_len) == -1)
|
||||||
return format("FAILED TO FIND NAME OF %d: %s", fd, strerror(errno));
|
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(inet_ntoa(addr.sin_addr)) + "." + format("%d", ntohs(addr.sin_port));
|
||||||
|
|
||||||
return std::string(host) + "." + std::string(serv);
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue