AP_HAL: added IP4_STR_LEN

This commit is contained in:
Andrew Tridgell 2024-01-17 09:11:12 +11:00
parent 4e49481d3a
commit 07fee626d9
2 changed files with 3 additions and 2 deletions

View File

@ -360,8 +360,7 @@ ssize_t SOCKET_CLASS_NAME::recv(void *buf, size_t size, uint32_t timeout_ms)
*/ */
void SOCKET_CLASS_NAME::last_recv_address(const char *&ip_addr, uint16_t &port) const void SOCKET_CLASS_NAME::last_recv_address(const char *&ip_addr, uint16_t &port) const
{ {
// 16 bytes for aaa.bbb.ccc.ddd with null term static char buf[IP4_STR_LEN];
static char buf[16];
auto *str = last_recv_address(buf, sizeof(buf), port); auto *str = last_recv_address(buf, sizeof(buf), port);
ip_addr = str; ip_addr = str;
} }

View File

@ -25,6 +25,8 @@
#error "Don't include Socket.hpp directly" #error "Don't include Socket.hpp directly"
#endif #endif
#define IP4_STR_LEN 16
class SOCKET_CLASS_NAME { class SOCKET_CLASS_NAME {
public: public:
SOCKET_CLASS_NAME(bool _datagram); SOCKET_CLASS_NAME(bool _datagram);