Several fixes to correctly use SOCKET (and related) types instead of non-portable variations.
(cherry picked from commit fed316ff3e
)
This commit is contained in:
parent
f8831d0196
commit
7392697aec
@ -255,6 +255,10 @@ Version 1.8.0
|
|||||||
Version 1.6.14
|
Version 1.6.14
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
|
|
||||||
|
2011-03-08 Iain Denniston <iain.denniston(at)gmail.com>
|
||||||
|
|
||||||
|
Several fixes to correctly use SOCKET (and related) types instead of
|
||||||
|
non-portable variations.
|
||||||
|
|
||||||
*******************************************************************************
|
*******************************************************************************
|
||||||
Version 1.6.13
|
Version 1.6.13
|
||||||
|
@ -3242,7 +3242,7 @@ int UpnpGetIfInfo(const char *IfName)
|
|||||||
ifname_found = 1;
|
ifname_found = 1;
|
||||||
}
|
}
|
||||||
/* Create an unbound datagram socket to do the SIOCGIFADDR ioctl on. */
|
/* Create an unbound datagram socket to do the SIOCGIFADDR ioctl on. */
|
||||||
if ((LocalSock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0) {
|
if ((LocalSock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) {
|
||||||
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
|
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
|
||||||
"Can't create addrlist socket\n");
|
"Can't create addrlist socket\n");
|
||||||
return UPNP_E_INIT;
|
return UPNP_E_INIT;
|
||||||
@ -3662,7 +3662,7 @@ int getlocalhostname(char *out, size_t out_len)
|
|||||||
|
|
||||||
/* Create an unbound datagram socket to do the SIOCGIFADDR ioctl on. */
|
/* Create an unbound datagram socket to do the SIOCGIFADDR ioctl on. */
|
||||||
LocalSock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
LocalSock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||||
if (LocalSock < 0) {
|
if (LocalSock == INVALID_SOCKET) {
|
||||||
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
|
UpnpPrintf(UPNP_ALL, API, __FILE__, __LINE__,
|
||||||
"Can't create addrlist socket\n");
|
"Can't create addrlist socket\n");
|
||||||
return UPNP_E_INIT;
|
return UPNP_E_INIT;
|
||||||
|
@ -222,8 +222,8 @@ SOCKET http_Connect(
|
|||||||
http_FixUrl(destination_url, url);
|
http_FixUrl(destination_url, url);
|
||||||
|
|
||||||
connfd = socket(url->hostport.IPaddress.ss_family, SOCK_STREAM, 0);
|
connfd = socket(url->hostport.IPaddress.ss_family, SOCK_STREAM, 0);
|
||||||
if (connfd == -1) {
|
if (connfd == INVALID_SOCKET) {
|
||||||
return UPNP_E_OUTOF_SOCKET;
|
return (SOCKET)(UPNP_E_OUTOF_SOCKET);
|
||||||
}
|
}
|
||||||
sockaddr_len = (socklen_t)(url->hostport.IPaddress.ss_family == AF_INET6 ?
|
sockaddr_len = (socklen_t)(url->hostport.IPaddress.ss_family == AF_INET6 ?
|
||||||
sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in));
|
sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in));
|
||||||
@ -236,7 +236,7 @@ SOCKET http_Connect(
|
|||||||
#endif
|
#endif
|
||||||
shutdown(connfd, SD_BOTH);
|
shutdown(connfd, SD_BOTH);
|
||||||
UpnpCloseSocket(connfd);
|
UpnpCloseSocket(connfd);
|
||||||
return UPNP_E_SOCKET_CONNECT;
|
return (SOCKET)(UPNP_E_SOCKET_CONNECT);
|
||||||
}
|
}
|
||||||
|
|
||||||
return connfd;
|
return connfd;
|
||||||
@ -548,7 +548,7 @@ int http_RequestAndResponse(
|
|||||||
|
|
||||||
tcp_connection = socket(
|
tcp_connection = socket(
|
||||||
destination->hostport.IPaddress.ss_family, SOCK_STREAM, 0);
|
destination->hostport.IPaddress.ss_family, SOCK_STREAM, 0);
|
||||||
if (tcp_connection == -1) {
|
if (tcp_connection == INVALID_SOCKET) {
|
||||||
parser_response_init(response, req_method);
|
parser_response_init(response, req_method);
|
||||||
return UPNP_E_SOCKET_ERROR;
|
return UPNP_E_SOCKET_ERROR;
|
||||||
}
|
}
|
||||||
@ -969,7 +969,7 @@ int http_OpenHttpPost(
|
|||||||
handle->contentLength = contentLength;
|
handle->contentLength = contentLength;
|
||||||
tcp_connection = socket(url.hostport.IPaddress.ss_family,
|
tcp_connection = socket(url.hostport.IPaddress.ss_family,
|
||||||
SOCK_STREAM, 0);
|
SOCK_STREAM, 0);
|
||||||
if (tcp_connection == -1) {
|
if (tcp_connection == INVALID_SOCKET) {
|
||||||
ret_code = UPNP_E_SOCKET_ERROR;
|
ret_code = UPNP_E_SOCKET_ERROR;
|
||||||
goto errorHandler;
|
goto errorHandler;
|
||||||
}
|
}
|
||||||
@ -1446,7 +1446,7 @@ int http_OpenHttpGetProxy(const char *url_str, const char *proxy_str,
|
|||||||
parser_response_init(&handle->response, HTTPMETHOD_GET);
|
parser_response_init(&handle->response, HTTPMETHOD_GET);
|
||||||
tcp_connection =
|
tcp_connection =
|
||||||
socket(peer->hostport.IPaddress.ss_family, SOCK_STREAM, 0);
|
socket(peer->hostport.IPaddress.ss_family, SOCK_STREAM, 0);
|
||||||
if (tcp_connection == -1) {
|
if (tcp_connection == INVALID_SOCKET) {
|
||||||
ret_code = UPNP_E_SOCKET_ERROR;
|
ret_code = UPNP_E_SOCKET_ERROR;
|
||||||
goto errorHandler;
|
goto errorHandler;
|
||||||
}
|
}
|
||||||
@ -1965,7 +1965,7 @@ int http_OpenHttpGetEx(
|
|||||||
memset(handle, 0, sizeof(*handle));
|
memset(handle, 0, sizeof(*handle));
|
||||||
parser_response_init(&handle->response, HTTPMETHOD_GET);
|
parser_response_init(&handle->response, HTTPMETHOD_GET);
|
||||||
tcp_connection = socket(url.hostport.IPaddress.ss_family, SOCK_STREAM, 0);
|
tcp_connection = socket(url.hostport.IPaddress.ss_family, SOCK_STREAM, 0);
|
||||||
if (tcp_connection == -1) {
|
if (tcp_connection == INVALID_SOCKET) {
|
||||||
errCode = UPNP_E_SOCKET_ERROR;
|
errCode = UPNP_E_SOCKET_ERROR;
|
||||||
free(handle);
|
free(handle);
|
||||||
break;
|
break;
|
||||||
|
@ -86,12 +86,12 @@ int sock_destroy(SOCKINFO *info, int ShutdownMethod)
|
|||||||
{
|
{
|
||||||
int ret = UPNP_E_SUCCESS;
|
int ret = UPNP_E_SUCCESS;
|
||||||
|
|
||||||
if (info->socket != -1) {
|
if (info->socket != INVALID_SOCKET) {
|
||||||
shutdown(info->socket, ShutdownMethod);
|
shutdown(info->socket, ShutdownMethod);
|
||||||
if (sock_close(info->socket) == -1) {
|
if (sock_close(info->socket) == -1) {
|
||||||
ret = UPNP_E_SOCKET_ERROR;
|
ret = UPNP_E_SOCKET_ERROR;
|
||||||
}
|
}
|
||||||
info->socket = -1;
|
info->socket = INVALID_SOCKET;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -74,7 +74,7 @@ static UPNP_INLINE int sock_close(
|
|||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
if (sock != -1)
|
if (sock != INVALID_SOCKET)
|
||||||
ret = UpnpCloseSocket(sock);
|
ret = UpnpCloseSocket(sock);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -452,7 +452,7 @@ int SearchByTarget(int Mx, char *St, void *Cookie)
|
|||||||
struct Handle_Info *ctrlpt_info = NULL;
|
struct Handle_Info *ctrlpt_info = NULL;
|
||||||
enum SsdpSearchType requestType;
|
enum SsdpSearchType requestType;
|
||||||
unsigned long addrv4 = inet_addr(gIF_IPV4);
|
unsigned long addrv4 = inet_addr(gIF_IPV4);
|
||||||
int max_fd = 0;
|
SOCKET max_fd = 0;
|
||||||
|
|
||||||
/*ThreadData *ThData; */
|
/*ThreadData *ThData; */
|
||||||
ThreadPoolJob job;
|
ThreadPoolJob job;
|
||||||
|
@ -181,7 +181,7 @@ static int NewRequestHandler(
|
|||||||
int ret = UPNP_E_SUCCESS;
|
int ret = UPNP_E_SUCCESS;
|
||||||
|
|
||||||
ReplySock = socket(DestAddr->sa_family, SOCK_DGRAM, 0);
|
ReplySock = socket(DestAddr->sa_family, SOCK_DGRAM, 0);
|
||||||
if (ReplySock == -1) {
|
if (ReplySock == INVALID_SOCKET) {
|
||||||
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
|
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
|
||||||
UpnpPrintf(UPNP_INFO, SSDP, __FILE__, __LINE__,
|
UpnpPrintf(UPNP_INFO, SSDP, __FILE__, __LINE__,
|
||||||
"SSDP_LIB: New Request Handler:"
|
"SSDP_LIB: New Request Handler:"
|
||||||
|
@ -736,7 +736,7 @@ static int create_ssdp_sock_v4(
|
|||||||
struct in_addr addr;
|
struct in_addr addr;
|
||||||
|
|
||||||
*ssdpSock = socket(AF_INET, SOCK_DGRAM, 0);
|
*ssdpSock = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
if (*ssdpSock == -1) {
|
if (*ssdpSock == INVALID_SOCKET) {
|
||||||
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
|
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
|
||||||
UpnpPrintf(UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
|
UpnpPrintf(UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
|
||||||
"Error in socket(): %s\n", errorBuffer);
|
"Error in socket(): %s\n", errorBuffer);
|
||||||
@ -847,7 +847,7 @@ static int create_ssdp_sock_reqv4(
|
|||||||
u_char ttl = 4;
|
u_char ttl = 4;
|
||||||
|
|
||||||
*ssdpReqSock = socket(AF_INET, SOCK_DGRAM, 0);
|
*ssdpReqSock = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
if (*ssdpReqSock == -1) {
|
if (*ssdpReqSock == INVALID_SOCKET) {
|
||||||
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
|
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
|
||||||
UpnpPrintf(UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
|
UpnpPrintf(UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
|
||||||
"Error in socket(): %s\n", errorBuffer);
|
"Error in socket(): %s\n", errorBuffer);
|
||||||
@ -877,7 +877,7 @@ static int create_ssdp_sock_v6(
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
*ssdpSock = socket(AF_INET6, SOCK_DGRAM, 0);
|
*ssdpSock = socket(AF_INET6, SOCK_DGRAM, 0);
|
||||||
if (*ssdpSock == -1) {
|
if (*ssdpSock == INVALID_SOCKET) {
|
||||||
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
|
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
|
||||||
UpnpPrintf(UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
|
UpnpPrintf(UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
|
||||||
"Error in socket(): %s\n", errorBuffer);
|
"Error in socket(): %s\n", errorBuffer);
|
||||||
@ -978,7 +978,7 @@ static int create_ssdp_sock_v6_ula_gua(
|
|||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
*ssdpSock = socket(AF_INET6, SOCK_DGRAM, 0);
|
*ssdpSock = socket(AF_INET6, SOCK_DGRAM, 0);
|
||||||
if (*ssdpSock == -1) {
|
if (*ssdpSock == INVALID_SOCKET) {
|
||||||
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
|
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
|
||||||
UpnpPrintf(UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
|
UpnpPrintf(UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
|
||||||
"Error in socket(): %s\n", errorBuffer);
|
"Error in socket(): %s\n", errorBuffer);
|
||||||
@ -1076,7 +1076,7 @@ static int create_ssdp_sock_reqv6(
|
|||||||
char hops = 1;
|
char hops = 1;
|
||||||
|
|
||||||
*ssdpReqSock = socket(AF_INET6, SOCK_DGRAM, 0);
|
*ssdpReqSock = socket(AF_INET6, SOCK_DGRAM, 0);
|
||||||
if (*ssdpReqSock == -1) {
|
if (*ssdpReqSock == INVALID_SOCKET) {
|
||||||
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
|
strerror_r(errno, errorBuffer, ERROR_BUFFER_LEN);
|
||||||
UpnpPrintf(UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
|
UpnpPrintf(UPNP_CRITICAL, SSDP, __FILE__, __LINE__,
|
||||||
"Error in socket(): %s\n", errorBuffer);
|
"Error in socket(): %s\n", errorBuffer);
|
||||||
|
Loading…
Reference in New Issue
Block a user