From b41e0a03c21227d6e52936a82f78dac0b722567a Mon Sep 17 00:00:00 2001 From: Dima Pulkinen Date: Wed, 28 Feb 2024 09:34:01 +0200 Subject: [PATCH] add sockaddr storage struct from libevent by Niels Provos and Nick Mathewson --- src/usocket.h | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/usocket.h b/src/usocket.h index 54a4ffc..ef7ace0 100644 --- a/src/usocket.h +++ b/src/usocket.h @@ -29,12 +29,26 @@ #include /* TCP options (nagle algorithm disable) */ #include +#ifndef PSP #include - +#else #ifndef HAVE_GETADDRINFO #include "getaddrinfo.h" #endif +/* Replacement for sockaddr storage that we can use internally on platforms + * that lack it. It is not space-efficient, but neither is sockaddr_storage. + */ +struct sockaddr_storage { + union { + struct sockaddr ss_sa; + struct sockaddr_in ss_sin; + struct sockaddr_in6 ss_sin6; + char ss_padding[128]; + } ss_union; +}; +#endif + #ifndef SO_REUSEPORT #define SO_REUSEPORT SO_REUSEADDR #endif