mirror of
https://github.com/status-im/miniupnp.git
synced 2025-02-28 05:20:30 +00:00
upnpDiscover() => upnpDiscoverDevices()
This commit is contained in:
parent
9f1a9a91e6
commit
f9ea7ad372
@ -321,7 +321,8 @@ parseMSEARCHReply(const char * reply, int size,
|
|||||||
* It is up to the caller to free the chained list
|
* It is up to the caller to free the chained list
|
||||||
* delay is in millisecond (poll) */
|
* delay is in millisecond (poll) */
|
||||||
LIBSPEC struct UPNPDev *
|
LIBSPEC struct UPNPDev *
|
||||||
upnpDiscover(int delay, const char * multicastif,
|
upnpDiscoverDevices(const char * const deviceTypes[],
|
||||||
|
int delay, const char * multicastif,
|
||||||
const char * minissdpdsock, int sameport,
|
const char * minissdpdsock, int sameport,
|
||||||
int ipv6,
|
int ipv6,
|
||||||
int * error)
|
int * error)
|
||||||
@ -337,20 +338,6 @@ upnpDiscover(int delay, const char * multicastif,
|
|||||||
"MAN: \"ssdp:discover\"\r\n"
|
"MAN: \"ssdp:discover\"\r\n"
|
||||||
"MX: %u\r\n"
|
"MX: %u\r\n"
|
||||||
"\r\n";
|
"\r\n";
|
||||||
static const char * const deviceList[] = {
|
|
||||||
#if 0
|
|
||||||
"urn:schemas-upnp-org:device:InternetGatewayDevice:2",
|
|
||||||
"urn:schemas-upnp-org:service:WANIPConnection:2",
|
|
||||||
#endif
|
|
||||||
#if 0
|
|
||||||
"urn:schemas-upnp-org:device:InternetGatewayDevice:1",
|
|
||||||
"urn:schemas-upnp-org:service:WANIPConnection:1",
|
|
||||||
"urn:schemas-upnp-org:service:WANPPPConnection:1",
|
|
||||||
#endif
|
|
||||||
"upnp:rootdevice",
|
|
||||||
"ssdp:all",
|
|
||||||
0
|
|
||||||
};
|
|
||||||
int deviceIndex = 0;
|
int deviceIndex = 0;
|
||||||
char bufr[1536]; /* reception and emission buffer */
|
char bufr[1536]; /* reception and emission buffer */
|
||||||
int sudp;
|
int sudp;
|
||||||
@ -374,11 +361,11 @@ upnpDiscover(int delay, const char * multicastif,
|
|||||||
/* first try to get infos from minissdpd ! */
|
/* first try to get infos from minissdpd ! */
|
||||||
if(!minissdpdsock)
|
if(!minissdpdsock)
|
||||||
minissdpdsock = "/var/run/minissdpd.sock";
|
minissdpdsock = "/var/run/minissdpd.sock";
|
||||||
while(!devlist && deviceList[deviceIndex]) {
|
while(!devlist && deviceTypes[deviceIndex]) {
|
||||||
devlist = getDevicesFromMiniSSDPD(deviceList[deviceIndex],
|
devlist = getDevicesFromMiniSSDPD(deviceTypes[deviceIndex],
|
||||||
minissdpdsock);
|
minissdpdsock);
|
||||||
/* We return what we have found if it was not only a rootdevice */
|
/* We return what we have found if it was not only a rootdevice */
|
||||||
if(devlist && !strstr(deviceList[deviceIndex], "rootdevice")) {
|
if(devlist && !strstr(deviceTypes[deviceIndex], "rootdevice")) {
|
||||||
if(error)
|
if(error)
|
||||||
*error = UPNPDISCOVER_SUCCESS;
|
*error = UPNPDISCOVER_SUCCESS;
|
||||||
return devlist;
|
return devlist;
|
||||||
@ -549,7 +536,7 @@ upnpDiscover(int delay, const char * multicastif,
|
|||||||
/* Calculating maximum response time in seconds */
|
/* Calculating maximum response time in seconds */
|
||||||
mx = ((unsigned int)delay) / 1000u;
|
mx = ((unsigned int)delay) / 1000u;
|
||||||
/* receiving SSDP response packet */
|
/* receiving SSDP response packet */
|
||||||
for(n = 0; deviceList[deviceIndex]; deviceIndex++)
|
for(n = 0; deviceTypes[deviceIndex]; deviceIndex++)
|
||||||
{
|
{
|
||||||
if(n == 0)
|
if(n == 0)
|
||||||
{
|
{
|
||||||
@ -559,7 +546,7 @@ upnpDiscover(int delay, const char * multicastif,
|
|||||||
ipv6 ?
|
ipv6 ?
|
||||||
(linklocal ? "[" UPNP_MCAST_LL_ADDR "]" : "[" UPNP_MCAST_SL_ADDR "]")
|
(linklocal ? "[" UPNP_MCAST_LL_ADDR "]" : "[" UPNP_MCAST_SL_ADDR "]")
|
||||||
: UPNP_MCAST_ADDR,
|
: UPNP_MCAST_ADDR,
|
||||||
deviceList[deviceIndex], mx);
|
deviceTypes[deviceIndex], mx);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("Sending %s", bufr);
|
printf("Sending %s", bufr);
|
||||||
#endif
|
#endif
|
||||||
@ -704,6 +691,29 @@ error:
|
|||||||
return devlist;
|
return devlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LIBSPEC struct UPNPDev *
|
||||||
|
upnpDiscover(int delay, const char * multicastif,
|
||||||
|
const char * minissdpdsock, int sameport,
|
||||||
|
int ipv6,
|
||||||
|
int * error)
|
||||||
|
{
|
||||||
|
static const char * const deviceList[] = {
|
||||||
|
#if 0
|
||||||
|
"urn:schemas-upnp-org:device:InternetGatewayDevice:2",
|
||||||
|
"urn:schemas-upnp-org:service:WANIPConnection:2",
|
||||||
|
#endif
|
||||||
|
"urn:schemas-upnp-org:device:InternetGatewayDevice:1",
|
||||||
|
"urn:schemas-upnp-org:service:WANIPConnection:1",
|
||||||
|
"urn:schemas-upnp-org:service:WANPPPConnection:1",
|
||||||
|
"upnp:rootdevice",
|
||||||
|
"ssdp:all",
|
||||||
|
0
|
||||||
|
};
|
||||||
|
return upnpDiscoverDevices(deviceList,
|
||||||
|
delay, multicastif, minissdpdsock, sameport,
|
||||||
|
ipv6, error);
|
||||||
|
}
|
||||||
|
|
||||||
/* freeUPNPDevlist() should be used to
|
/* freeUPNPDevlist() should be used to
|
||||||
* free the chained list returned by upnpDiscover() */
|
* free the chained list returned by upnpDiscover() */
|
||||||
LIBSPEC void freeUPNPDevlist(struct UPNPDev * devlist)
|
LIBSPEC void freeUPNPDevlist(struct UPNPDev * devlist)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user