miniupnpc: add searchalltypes param to upnpDiscoverDevices()

increase API_VERSION to 13
This commit is contained in:
Thomas Bernard 2015-05-22 12:25:51 +02:00
parent f11b8b2a0d
commit 5c6a140098
7 changed files with 47 additions and 22 deletions

View File

@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 2.6)
project (miniupnpc C)
set (MINIUPNPC_VERSION 1.9)
set (MINIUPNPC_API_VERSION 12)
set (MINIUPNPC_API_VERSION 13)
if (NOT CMAKE_BUILD_TYPE)
if (WIN32)

View File

@ -1,6 +1,10 @@
$Id: Changelog.txt,v 1.203 2015/04/27 15:50:19 nanard Exp $
$Id: Changelog.txt,v 1.206 2015/05/22 10:23:47 nanard Exp $
miniUPnP client Changelog.
2015/05/22:
add searchalltypes param to upnpDiscoverDevices()
increments API_VERSION to 13
2015/04/30:
upnpc: output version on the terminal

View File

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.120 2015/01/07 09:07:32 nanard Exp $
# $Id: Makefile,v 1.122 2015/05/22 10:23:47 nanard Exp $
# MiniUPnP Project
# http://miniupnp.free.fr/
# http://miniupnp.tuxfamily.org/
@ -55,7 +55,7 @@ ifeq (SunOS, $(OS))
endif
# APIVERSION is used to build SONAME
APIVERSION = 12
APIVERSION = 13
SRCS = igd_desc_parse.c miniupnpc.c minixml.c minisoap.c miniwget.c \
upnpc.c upnpcommands.c upnpreplyparse.c testminixml.c \

View File

@ -1,7 +1,13 @@
$Id: apiversions.txt,v 1.3 2014/01/31 13:14:32 nanard Exp $
$Id: apiversions.txt,v 1.6 2015/05/22 10:23:48 nanard Exp $
Differences in API between miniUPnPc versions
API version 13
miniupnpc.h:
add searchalltype param to upnpDiscoverDevices() function
updated macro :
#define MINIUPNPC_API_VERSION 13
API version 12
miniupnpc.h :
add upnpDiscoverAll() / upnpDiscoverDevice() / upnpDiscoverDevices()

View File

@ -1,4 +1,4 @@
/* $Id: listdevices.c,v 1.2 2014/11/17 09:50:56 nanard Exp $ */
/* $Id: listdevices.c,v 1.3 2015/05/22 10:14:04 nanard Exp $ */
/* Project : miniupnp
* Author : Thomas Bernard
* Copyright (c) 2013-2014 Thomas Bernard

View File

@ -1,8 +1,8 @@
/* $Id: miniupnpc.c,v 1.124 2014/12/01 09:25:11 nanard Exp $ */
/* $Id: miniupnpc.c,v 1.126 2015/05/22 10:12:58 nanard Exp $ */
/* Project : miniupnp
* Web : http://miniupnp.free.fr/
* Author : Thomas BERNARD
* copyright (c) 2005-2014 Thomas Bernard
* copyright (c) 2005-2015 Thomas Bernard
* This software is subjet to the conditions detailed in the
* provided LICENSE file. */
#define __EXTENSIONS__ 1
@ -346,7 +346,8 @@ upnpDiscoverDevices(const char * const deviceTypes[],
int delay, const char * multicastif,
const char * minissdpdsock, int sameport,
int ipv6,
int * error)
int * error,
int searchalltypes)
{
struct UPNPDev * tmp;
struct UPNPDev * devlist = 0;
@ -382,11 +383,22 @@ upnpDiscoverDevices(const char * const deviceTypes[],
/* first try to get infos from minissdpd ! */
if(!minissdpdsock)
minissdpdsock = "/var/run/minissdpd.sock";
for(deviceIndex = 0; !devlist && deviceTypes[deviceIndex]; deviceIndex++) {
devlist = getDevicesFromMiniSSDPD(deviceTypes[deviceIndex],
minissdpdsock);
for(deviceIndex = 0; deviceTypes[deviceIndex]; deviceIndex++) {
tmp = getDevicesFromMiniSSDPD(deviceTypes[deviceIndex],
minissdpdsock);
if(tmp) {
#ifdef DEBUG
printf("returned by MiniSSDPD: %s\n", tmp->st);
#endif /* DEBUG */
tmp->pNext = devlist;
devlist = tmp;
if(!searchalltypes && !strstr(tmp->st, "rootdevice"))
break;
}
}
for(tmp = devlist; tmp != NULL; tmp = tmp->pNext) {
/* We return what we have found if it was not only a rootdevice */
if(devlist && !strstr(deviceTypes[deviceIndex], "rootdevice")) {
if(!strstr(tmp->st, "rootdevice")) {
if(error)
*error = UPNPDISCOVER_SUCCESS;
return devlist;
@ -650,7 +662,7 @@ upnpDiscoverDevices(const char * const deviceTypes[],
goto error;
} else if (n == 0) {
/* no data or Time Out */
if (devlist) {
if (devlist && !searchalltypes) {
/* found some devices, stop now*/
if(error)
*error = UPNPDISCOVER_SUCCESS;
@ -733,7 +745,7 @@ upnpDiscover(int delay, const char * multicastif,
};
return upnpDiscoverDevices(deviceList,
delay, multicastif, minissdpdsock, sameport,
ipv6, error);
ipv6, error, 0);
}
/* upnpDiscoverAll() Discover all UPnP devices */
@ -750,7 +762,7 @@ upnpDiscoverAll(int delay, const char * multicastif,
};
return upnpDiscoverDevices(deviceList,
delay, multicastif, minissdpdsock, sameport,
ipv6, error);
ipv6, error, 0);
}
/* upnpDiscoverDevice() Discover a specific device */
@ -766,7 +778,7 @@ upnpDiscoverDevice(const char * device, int delay, const char * multicastif,
};
return upnpDiscoverDevices(deviceList,
delay, multicastif, minissdpdsock, sameport,
ipv6, error);
ipv6, error, 0);
}
/* freeUPNPDevlist() should be used to

View File

@ -1,8 +1,8 @@
/* $Id: miniupnpc.h,v 1.39 2014/12/20 09:13:51 nanard Exp $ */
/* $Id: miniupnpc.h,v 1.41 2015/05/22 10:23:48 nanard Exp $ */
/* Project: miniupnp
* http://miniupnp.free.fr/
* Author: Thomas Bernard
* Copyright (c) 2005-2014 Thomas Bernard
* Copyright (c) 2005-2015 Thomas Bernard
* This software is subjects to the conditions detailed
* in the LICENCE file provided within this distribution */
#ifndef MINIUPNPC_H_INCLUDED
@ -19,7 +19,7 @@
/* versions : */
#define MINIUPNPC_VERSION "1.9"
#define MINIUPNPC_API_VERSION 12
#define MINIUPNPC_API_VERSION 13
#ifdef __cplusplus
extern "C" {
@ -53,7 +53,9 @@ struct UPNPDev {
* If multicastif is not NULL, it will be used instead of the default
* multicast interface for sending SSDP discover packets.
* If sameport is not null, SSDP packets will be sent from the source port
* 1900 (same as destination port) otherwise system assign a source port. */
* 1900 (same as destination port) otherwise system assign a source port.
* "searchalltypes" parameter is useful when searching several types,
* if 0, the discovery will stop with the first type returning results. */
MINIUPNP_LIBSPEC struct UPNPDev *
upnpDiscover(int delay, const char * multicastif,
const char * minissdpdsock, int sameport,
@ -77,7 +79,8 @@ upnpDiscoverDevices(const char * const deviceTypes[],
int delay, const char * multicastif,
const char * minissdpdsock, int sameport,
int ipv6,
int * error);
int * error,
int searchalltypes);
/* freeUPNPDevlist()
* free list returned by upnpDiscover() */