Bug fix for IPv4-mapped IPv6 addresses.
Setting IPv6 sockets with IPV6_V6ONLY flag to avoid getting IP packets with IPv4-mapped IPv6 addresses on IPv6 sockets.
This commit is contained in:
parent
a9c24fc7f3
commit
33fcfeb79f
@ -2,6 +2,7 @@
|
||||
*
|
||||
* Copyright (c) 2000-2003 Intel Corporation
|
||||
* All rights reserved.
|
||||
* Copyright (C) 2012 France Telecom All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@ -512,6 +513,7 @@ static int get_miniserver_sockets(
|
||||
struct sockaddr_in6* serverAddr6 = (struct sockaddr_in6*)&__ss_v6;
|
||||
SOCKET listenfd6;
|
||||
uint16_t actual_port6;
|
||||
int onOff;
|
||||
#endif
|
||||
int ret_code;
|
||||
int reuseaddr_on = 0;
|
||||
@ -527,8 +529,17 @@ static int get_miniserver_sockets(
|
||||
#ifdef UPNP_ENABLE_IPV6
|
||||
listenfd6 = socket(AF_INET6, SOCK_STREAM, 0);
|
||||
if (listenfd6 == INVALID_SOCKET) {
|
||||
sock_close(listenfd4);
|
||||
return UPNP_E_OUTOF_SOCKET;
|
||||
}
|
||||
onOff = 1;
|
||||
sockError = setsockopt(listenfd6, IPPROTO_IPV6, IPV6_V6ONLY,
|
||||
(char *)&onOff, sizeof(onOff));
|
||||
if (sockError == SOCKET_ERROR) {
|
||||
sock_close(listenfd4);
|
||||
sock_close(listenfd6);
|
||||
return UPNP_E_SOCKET_BIND;
|
||||
}
|
||||
#endif
|
||||
/* As per the IANA specifications for the use of ports by applications
|
||||
* override the listen port passed in with the first available. */
|
||||
|
@ -2,7 +2,7 @@
|
||||
*
|
||||
* Copyright (c) 2000-2003 Intel Corporation
|
||||
* All rights reserved.
|
||||
* Copyright (C) 2011 France Telecom All rights reserved.
|
||||
* Copyright (C) 2011-2012 France Telecom All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
@ -948,6 +948,19 @@ static int create_ssdp_sock_v6(
|
||||
return UPNP_E_SOCKET_ERROR;
|
||||
}
|
||||
#endif /* BSD, __OSX__, __APPLE__ */
|
||||
onOff = 1;
|
||||
ret = setsockopt(*ssdpSock, IPPROTO_IPV6, IPV6_V6ONLY,
|
||||
(char *)&onOff, sizeof(onOff));
|
||||
if (ret == -1) {
|
||||
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
|
||||
UpnpPrintf(UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
|
||||
"Error in setsockopt() IPV6_V6ONLY: %s\n",
|
||||
errorBuffer);
|
||||
shutdown(*ssdpSock, SD_BOTH);
|
||||
UpnpCloseSocket(*ssdpSock);
|
||||
|
||||
return UPNP_E_SOCKET_ERROR;
|
||||
}
|
||||
memset(&__ss, 0, sizeof(__ss));
|
||||
ssdpAddr6->sin6_family = AF_INET6;
|
||||
ssdpAddr6->sin6_addr = in6addr_any;
|
||||
@ -1049,6 +1062,19 @@ static int create_ssdp_sock_v6_ula_gua(
|
||||
return UPNP_E_SOCKET_ERROR;
|
||||
}
|
||||
#endif /* BSD, __OSX__, __APPLE__ */
|
||||
onOff = 1;
|
||||
ret = setsockopt(*ssdpSock, IPPROTO_IPV6, IPV6_V6ONLY,
|
||||
(char *)&onOff, sizeof(onOff));
|
||||
if (ret == -1) {
|
||||
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
|
||||
UpnpPrintf(UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
|
||||
"Error in setsockopt() IPV6_V6ONLY: %s\n",
|
||||
errorBuffer);
|
||||
shutdown(*ssdpSock, SD_BOTH);
|
||||
UpnpCloseSocket(*ssdpSock);
|
||||
|
||||
return UPNP_E_SOCKET_ERROR;
|
||||
}
|
||||
memset(&__ss, 0, sizeof(__ss));
|
||||
ssdpAddr6->sin6_family = AF_INET6;
|
||||
ssdpAddr6->sin6_addr = in6addr_any;
|
||||
|
Loading…
Reference in New Issue
Block a user