final fixes for building for PSP without IPv6 support

This commit is contained in:
Dima Pulkinen 2024-02-28 09:38:54 +02:00
parent b41e0a03c2
commit 69d4916a0f
3 changed files with 13 additions and 1 deletions

View File

@ -371,6 +371,7 @@ const char *inet_trydisconnect(p_socket ps, int family, p_timeout tm)
return socket_strerror(socket_connect(ps, (SA *) &sin, return socket_strerror(socket_connect(ps, (SA *) &sin,
sizeof(sin), tm)); sizeof(sin), tm));
} }
#ifndef NOIPV6
case AF_INET6: { case AF_INET6: {
struct sockaddr_in6 sin6; struct sockaddr_in6 sin6;
struct in6_addr addrany = IN6ADDR_ANY_INIT; struct in6_addr addrany = IN6ADDR_ANY_INIT;
@ -380,6 +381,7 @@ const char *inet_trydisconnect(p_socket ps, int family, p_timeout tm)
return socket_strerror(socket_connect(ps, (SA *) &sin6, return socket_strerror(socket_connect(ps, (SA *) &sin6,
sizeof(sin6), tm)); sizeof(sin6), tm));
} }
#endif
} }
return NULL; return NULL;
} }
@ -438,7 +440,9 @@ const char *inet_tryaccept(p_socket server, int family, p_socket client,
socklen_t len; socklen_t len;
t_sockaddr_storage addr; t_sockaddr_storage addr;
switch (family) { switch (family) {
#ifndef NOIPV6
case AF_INET6: len = sizeof(struct sockaddr_in6); break; case AF_INET6: len = sizeof(struct sockaddr_in6); break;
#endif
case AF_INET: len = sizeof(struct sockaddr_in); break; case AF_INET: len = sizeof(struct sockaddr_in); break;
default: len = sizeof(addr); break; default: len = sizeof(addr); break;
} }
@ -526,9 +530,11 @@ int inet_pton(int af, const char *src, void *dst)
if (af == AF_INET) { if (af == AF_INET) {
struct sockaddr_in *in = (struct sockaddr_in *) res->ai_addr; struct sockaddr_in *in = (struct sockaddr_in *) res->ai_addr;
memcpy(dst, &in->sin_addr, sizeof(in->sin_addr)); memcpy(dst, &in->sin_addr, sizeof(in->sin_addr));
#ifndef NOIPV6
} else if (af == AF_INET6) { } else if (af == AF_INET6) {
struct sockaddr_in6 *in = (struct sockaddr_in6 *) res->ai_addr; struct sockaddr_in6 *in = (struct sockaddr_in6 *) res->ai_addr;
memcpy(dst, &in->sin6_addr, sizeof(in->sin6_addr)); memcpy(dst, &in->sin6_addr, sizeof(in->sin6_addr));
#endif
} else { } else {
ret = -1; ret = -1;
} }

View File

@ -312,7 +312,7 @@ SOCKET=$(SOCKET_$(PLAT))
# #
CC=$(CC_$(PLAT)) CC=$(CC_$(PLAT))
DEF=$(DEF_$(PLAT)) DEF=$(DEF_$(PLAT))
CFLAGS=$(MYCFLAGS) $(CFLAGS_$(PLAT)) -DHAVE_CONFIG_H CFLAGS=$(MYCFLAGS) $(CFLAGS_$(PLAT)) -DHAVE_CONFIG_H -DSOCKET_SELECT -DNOIPV6
LDFLAGS=$(MYLDFLAGS) $(LDFLAGS_$(PLAT)) LDFLAGS=$(MYLDFLAGS) $(LDFLAGS_$(PLAT))
LD=$(LD_$(PLAT)) LD=$(LD_$(PLAT))
LUAINC= $(LUAINC_$(PLAT)) LUAINC= $(LUAINC_$(PLAT))

View File

@ -36,6 +36,10 @@
#include "getaddrinfo.h" #include "getaddrinfo.h"
#endif #endif
#ifndef INET6_ADDRSTRLEN
#define INET6_ADDRSTRLEN INET_ADDRSTRLEN
#endif
/* Replacement for sockaddr storage that we can use internally on platforms /* Replacement for sockaddr storage that we can use internally on platforms
* that lack it. It is not space-efficient, but neither is sockaddr_storage. * that lack it. It is not space-efficient, but neither is sockaddr_storage.
*/ */
@ -43,7 +47,9 @@ struct sockaddr_storage {
union { union {
struct sockaddr ss_sa; struct sockaddr ss_sa;
struct sockaddr_in ss_sin; struct sockaddr_in ss_sin;
#ifndef NOIPV6
struct sockaddr_in6 ss_sin6; struct sockaddr_in6 ss_sin6;
#endif
char ss_padding[128]; char ss_padding[128];
} ss_union; } ss_union;
}; };