on FreeBSD, on a PF_INET6 socket, recvfrom and friends can actually

return a sockaddr with family PF_INET.  WTF?  Work around that.
master
leitner 11 years ago
parent 63b08692d0
commit 8581b74a84

@ -47,5 +47,11 @@ not enough memory is available.
array_allocate does \fInot\fR change \fIx\fR to have failed; if you want array_allocate does \fInot\fR change \fIx\fR to have failed; if you want
to do that, use array_fail. to do that, use array_fail.
.SH PERFORMANCE
This function can call realloc when the array needs to be enlarged.
Under exceptional circumstances, this can lead to blocking the current thread.
It will also zero-fill the newly enlarged part of the array, leading to
all pages being mapped in by the operating system. If a small array is
enlarged to a very large array, this can lead to swapping and blocking.
.SH "SEE ALSO" .SH "SEE ALSO"
array_get(3), array_start(3), array_fail(3) array_get(3), array_start(3), array_fail(3)

@ -87,7 +87,7 @@ incoming:
#endif #endif
#ifdef LIBC_HAS_IP6 #ifdef LIBC_HAS_IP6
if (sa.sin6_family==AF_INET) { if (noipv6 || sa.sin6_family==AF_INET || sa.sin6_family==PF_INET) {
struct sockaddr_in *sa4=(struct sockaddr_in*)&sa; struct sockaddr_in *sa4=(struct sockaddr_in*)&sa;
if (ip) { if (ip) {
byte_copy(ip,12,V4mappedprefix); byte_copy(ip,12,V4mappedprefix);

@ -24,7 +24,7 @@ int socket_local6(int s,char ip[16],uint16 *port,uint32 *scope_id)
if (getsockname(s,(void*) &si,&len) == -1) return winsock2errno(-1); if (getsockname(s,(void*) &si,&len) == -1) return winsock2errno(-1);
#ifdef LIBC_HAS_IP6 #ifdef LIBC_HAS_IP6
if (si.sin6_family==AF_INET) { if (noipv6 || si.sin6_family==AF_INET || si.sin6_family==PF_INET) {
struct sockaddr_in *si4=(void*)&si; struct sockaddr_in *si4=(void*)&si;
if (ip) { if (ip) {
byte_copy(ip,12,V4mappedprefix); byte_copy(ip,12,V4mappedprefix);

@ -26,7 +26,7 @@ ssize_t socket_recv6(int s,char *buf,size_t len,char ip[16],uint16 *port,uint32
if ((r = recvfrom(s,buf,len,0,(struct sockaddr *) &si,&Len))<0) return winsock2errno(-1); if ((r = recvfrom(s,buf,len,0,(struct sockaddr *) &si,&Len))<0) return winsock2errno(-1);
#ifdef LIBC_HAS_IP6 #ifdef LIBC_HAS_IP6
if (noipv6) { if (noipv6 || si.sin6_family==AF_INET || si.sin6_family==PF_INET) {
struct sockaddr_in *si4=(struct sockaddr_in *)&si; struct sockaddr_in *si4=(struct sockaddr_in *)&si;
if (ip) { if (ip) {
byte_copy(ip,12,V4mappedprefix); byte_copy(ip,12,V4mappedprefix);

@ -24,7 +24,7 @@ int socket_remote6(int s,char ip[16],uint16 *port,uint32 *scope_id)
if (getpeername(s,(struct sockaddr *) &si,&len) == -1) return winsock2errno(-1); if (getpeername(s,(struct sockaddr *) &si,&len) == -1) return winsock2errno(-1);
#ifdef LIBC_HAS_IP6 #ifdef LIBC_HAS_IP6
if (si.sin6_family==AF_INET) { if (noipv6 || si.sin6_family==AF_INET || si.sin6_family==PF_INET) {
struct sockaddr_in *si4=(struct sockaddr_in*)&si; struct sockaddr_in *si4=(struct sockaddr_in*)&si;
if (ip) { if (ip) {
byte_copy(ip,12,V4mappedprefix); byte_copy(ip,12,V4mappedprefix);

Loading…
Cancel
Save