Use MINISSDPC_* error codes instead of UPNPDISCOVER_*.
This commit is contained in:
parent
353f101655
commit
a95c501959
|
@ -68,7 +68,6 @@ struct ip_mreqn
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "minissdpc.h"
|
#include "minissdpc.h"
|
||||||
#include "miniupnpc.h"
|
|
||||||
|
|
||||||
#include "codelength.h"
|
#include "codelength.h"
|
||||||
#include "receivedata.h"
|
#include "receivedata.h"
|
||||||
|
@ -470,7 +469,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
|
||||||
int linklocal = 1;
|
int linklocal = 1;
|
||||||
|
|
||||||
if(error)
|
if(error)
|
||||||
*error = UPNPDISCOVER_UNKNOWN_ERROR;
|
*error = MINISSDPC_UNKNOWN_ERROR;
|
||||||
|
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
sudp = socket(ipv6 ? PF_INET6 : PF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
sudp = socket(ipv6 ? PF_INET6 : PF_INET, SOCK_DGRAM, IPPROTO_UDP);
|
||||||
|
@ -480,7 +479,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
|
||||||
if(sudp < 0)
|
if(sudp < 0)
|
||||||
{
|
{
|
||||||
if(error)
|
if(error)
|
||||||
*error = UPNPDISCOVER_SOCKET_ERROR;
|
*error = MINISSDPC_SOCKET_ERROR;
|
||||||
PRINT_SOCKET_ERROR("socket");
|
PRINT_SOCKET_ERROR("socket");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -568,7 +567,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
if(error)
|
if(error)
|
||||||
*error = UPNPDISCOVER_SOCKET_ERROR;
|
*error = MINISSDPC_SOCKET_ERROR;
|
||||||
PRINT_SOCKET_ERROR("setsockopt(SO_REUSEADDR,...)");
|
PRINT_SOCKET_ERROR("setsockopt(SO_REUSEADDR,...)");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
@ -631,14 +630,14 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
|
||||||
ipv6 ? sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in)) != 0)
|
ipv6 ? sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in)) != 0)
|
||||||
{
|
{
|
||||||
if(error)
|
if(error)
|
||||||
*error = UPNPDISCOVER_SOCKET_ERROR;
|
*error = MINISSDPC_SOCKET_ERROR;
|
||||||
PRINT_SOCKET_ERROR("bind");
|
PRINT_SOCKET_ERROR("bind");
|
||||||
closesocket(sudp);
|
closesocket(sudp);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(error)
|
if(error)
|
||||||
*error = UPNPDISCOVER_SUCCESS;
|
*error = MINISSDPC_SUCCESS;
|
||||||
/* Calculating maximum response time in seconds */
|
/* Calculating maximum response time in seconds */
|
||||||
mx = ((unsigned int)delay) / 1000u;
|
mx = ((unsigned int)delay) / 1000u;
|
||||||
if(mx == 0) {
|
if(mx == 0) {
|
||||||
|
@ -683,7 +682,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
|
||||||
ipv6 ? sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in));
|
ipv6 ? sizeof(struct sockaddr_in6) : sizeof(struct sockaddr_in));
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
if(error)
|
if(error)
|
||||||
*error = UPNPDISCOVER_SOCKET_ERROR;
|
*error = MINISSDPC_SOCKET_ERROR;
|
||||||
PRINT_SOCKET_ERROR("sendto");
|
PRINT_SOCKET_ERROR("sendto");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -697,7 +696,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
|
||||||
: UPNP_MCAST_ADDR,
|
: UPNP_MCAST_ADDR,
|
||||||
XSTR(PORT), &hints, &servinfo)) != 0) {
|
XSTR(PORT), &hints, &servinfo)) != 0) {
|
||||||
if(error)
|
if(error)
|
||||||
*error = UPNPDISCOVER_SOCKET_ERROR;
|
*error = MINISSDPC_SOCKET_ERROR;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
fprintf(stderr, "getaddrinfo() failed: %d\n", rv);
|
fprintf(stderr, "getaddrinfo() failed: %d\n", rv);
|
||||||
#else
|
#else
|
||||||
|
@ -722,7 +721,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
|
||||||
freeaddrinfo(servinfo);
|
freeaddrinfo(servinfo);
|
||||||
if(n < 0) {
|
if(n < 0) {
|
||||||
if(error)
|
if(error)
|
||||||
*error = UPNPDISCOVER_SOCKET_ERROR;
|
*error = MINISSDPC_SOCKET_ERROR;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
#endif /* #ifdef NO_GETADDRINFO */
|
#endif /* #ifdef NO_GETADDRINFO */
|
||||||
|
@ -734,7 +733,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
|
||||||
if (n < 0) {
|
if (n < 0) {
|
||||||
/* error */
|
/* error */
|
||||||
if(error)
|
if(error)
|
||||||
*error = UPNPDISCOVER_SOCKET_ERROR;
|
*error = MINISSDPC_SOCKET_ERROR;
|
||||||
goto error;
|
goto error;
|
||||||
} else if (n == 0) {
|
} else if (n == 0) {
|
||||||
/* no data or Time Out */
|
/* no data or Time Out */
|
||||||
|
@ -744,7 +743,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
|
||||||
if (devlist && !searchalltypes) {
|
if (devlist && !searchalltypes) {
|
||||||
/* found some devices, stop now*/
|
/* found some devices, stop now*/
|
||||||
if(error)
|
if(error)
|
||||||
*error = UPNPDISCOVER_SUCCESS;
|
*error = MINISSDPC_SUCCESS;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -777,7 +776,7 @@ ssdpDiscoverDevices(const char * const deviceTypes[],
|
||||||
if(!tmp) {
|
if(!tmp) {
|
||||||
/* memory allocation error */
|
/* memory allocation error */
|
||||||
if(error)
|
if(error)
|
||||||
*error = UPNPDISCOVER_MEMORY_ERROR;
|
*error = MINISSDPC_MEMORY_ERROR;
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
tmp->pNext = devlist;
|
tmp->pNext = devlist;
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
|
|
||||||
/* error codes : */
|
/* error codes : */
|
||||||
#define MINISSDPC_SUCCESS (0)
|
#define MINISSDPC_SUCCESS (0)
|
||||||
|
#define MINISSDPC_UNKNOWN_ERROR (-1)
|
||||||
#define MINISSDPC_SOCKET_ERROR (-101)
|
#define MINISSDPC_SOCKET_ERROR (-101)
|
||||||
#define MINISSDPC_MEMORY_ERROR (-102)
|
#define MINISSDPC_MEMORY_ERROR (-102)
|
||||||
#define MINISSDPC_INVALID_INPUT (-103)
|
#define MINISSDPC_INVALID_INPUT (-103)
|
||||||
|
|
Loading…
Reference in New Issue