2015-07-23 20:44:37 +00:00
|
|
|
/* $Id: miniupnpc.h,v 1.44 2015/07/23 20:40:10 nanard Exp $ */
|
2011-09-27 20:25:35 +00:00
|
|
|
/* Project: miniupnp
|
|
|
|
* http://miniupnp.free.fr/
|
|
|
|
* Author: Thomas Bernard
|
2015-05-22 10:25:51 +00:00
|
|
|
* Copyright (c) 2005-2015 Thomas Bernard
|
2011-09-27 20:25:35 +00:00
|
|
|
* This software is subjects to the conditions detailed
|
|
|
|
* in the LICENCE file provided within this distribution */
|
2012-09-20 20:52:51 +00:00
|
|
|
#ifndef MINIUPNPC_H_INCLUDED
|
|
|
|
#define MINIUPNPC_H_INCLUDED
|
2011-09-27 20:25:35 +00:00
|
|
|
|
2015-07-21 10:39:40 +00:00
|
|
|
#include "miniupnpc_declspec.h"
|
2011-09-27 20:25:35 +00:00
|
|
|
#include "igd_desc_parse.h"
|
|
|
|
|
|
|
|
/* error codes : */
|
|
|
|
#define UPNPDISCOVER_SUCCESS (0)
|
|
|
|
#define UPNPDISCOVER_UNKNOWN_ERROR (-1)
|
|
|
|
#define UPNPDISCOVER_SOCKET_ERROR (-101)
|
|
|
|
#define UPNPDISCOVER_MEMORY_ERROR (-102)
|
|
|
|
|
2012-01-07 10:35:45 +00:00
|
|
|
/* versions : */
|
2014-01-31 13:32:26 +00:00
|
|
|
#define MINIUPNPC_VERSION "1.9"
|
2015-07-23 20:44:37 +00:00
|
|
|
#define MINIUPNPC_API_VERSION 14
|
2012-01-07 10:35:45 +00:00
|
|
|
|
2011-09-27 20:25:35 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* Structures definitions : */
|
|
|
|
struct UPNParg { const char * elt; const char * val; };
|
|
|
|
|
|
|
|
char *
|
|
|
|
simpleUPnPcommand(int, const char *, const char *,
|
|
|
|
const char *, struct UPNParg *,
|
|
|
|
int *);
|
|
|
|
|
|
|
|
struct UPNPDev {
|
|
|
|
struct UPNPDev * pNext;
|
|
|
|
char * descURL;
|
|
|
|
char * st;
|
2012-06-23 22:55:31 +00:00
|
|
|
unsigned int scope_id;
|
2015-07-22 09:08:52 +00:00
|
|
|
char * usn;
|
|
|
|
char buffer[3];
|
2011-09-27 20:25:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/* upnpDiscover()
|
|
|
|
* discover UPnP devices on the network.
|
|
|
|
* The discovered devices are returned as a chained list.
|
|
|
|
* It is up to the caller to free the list with freeUPNPDevlist().
|
|
|
|
* delay (in millisecond) is the maximum time for waiting any device
|
|
|
|
* response.
|
|
|
|
* If available, device list will be obtained from MiniSSDPd.
|
|
|
|
* Default path for minissdpd socket will be used if minissdpdsock argument
|
|
|
|
* is NULL.
|
|
|
|
* 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
|
2015-05-22 10:25:51 +00:00
|
|
|
* 1900 (same as destination port) otherwise system assign a source port.
|
|
|
|
* "searchalltypes" parameter is useful when searching several types,
|
2015-07-23 20:44:37 +00:00
|
|
|
* if 0, the discovery will stop with the first type returning results.
|
|
|
|
* TTL should default to 2. */
|
2014-06-01 10:35:13 +00:00
|
|
|
MINIUPNP_LIBSPEC struct UPNPDev *
|
2011-09-27 20:25:35 +00:00
|
|
|
upnpDiscover(int delay, const char * multicastif,
|
|
|
|
const char * minissdpdsock, int sameport,
|
2015-07-23 20:44:37 +00:00
|
|
|
int ipv6, unsigned char ttl,
|
2011-09-27 20:25:35 +00:00
|
|
|
int * error);
|
2013-02-20 16:04:53 +00:00
|
|
|
|
2014-11-13 10:05:09 +00:00
|
|
|
MINIUPNP_LIBSPEC struct UPNPDev *
|
2013-02-20 16:04:53 +00:00
|
|
|
upnpDiscoverAll(int delay, const char * multicastif,
|
|
|
|
const char * minissdpdsock, int sameport,
|
2015-07-23 20:44:37 +00:00
|
|
|
int ipv6, unsigned char ttl,
|
2013-02-20 16:04:53 +00:00
|
|
|
int * error);
|
|
|
|
|
2014-11-13 10:05:09 +00:00
|
|
|
MINIUPNP_LIBSPEC struct UPNPDev *
|
2014-01-31 13:59:21 +00:00
|
|
|
upnpDiscoverDevice(const char * device, int delay, const char * multicastif,
|
|
|
|
const char * minissdpdsock, int sameport,
|
2015-07-23 20:44:37 +00:00
|
|
|
int ipv6, unsigned char ttl,
|
2014-01-31 13:59:21 +00:00
|
|
|
int * error);
|
|
|
|
|
2014-11-13 10:05:09 +00:00
|
|
|
MINIUPNP_LIBSPEC struct UPNPDev *
|
2014-01-31 13:59:21 +00:00
|
|
|
upnpDiscoverDevices(const char * const deviceTypes[],
|
|
|
|
int delay, const char * multicastif,
|
|
|
|
const char * minissdpdsock, int sameport,
|
2015-07-23 20:44:37 +00:00
|
|
|
int ipv6, unsigned char ttl,
|
2015-05-22 10:25:51 +00:00
|
|
|
int * error,
|
|
|
|
int searchalltypes);
|
2014-01-31 13:59:21 +00:00
|
|
|
|
2011-09-27 20:25:35 +00:00
|
|
|
/* freeUPNPDevlist()
|
|
|
|
* free list returned by upnpDiscover() */
|
2014-06-01 10:35:13 +00:00
|
|
|
MINIUPNP_LIBSPEC void freeUPNPDevlist(struct UPNPDev * devlist);
|
2011-09-27 20:25:35 +00:00
|
|
|
|
|
|
|
/* parserootdesc() :
|
|
|
|
* parse root XML description of a UPnP device and fill the IGDdatas
|
|
|
|
* structure. */
|
2014-06-01 10:35:13 +00:00
|
|
|
MINIUPNP_LIBSPEC void parserootdesc(const char *, int, struct IGDdatas *);
|
2011-09-27 20:25:35 +00:00
|
|
|
|
|
|
|
/* structure used to get fast access to urls
|
|
|
|
* controlURL: controlURL of the WANIPConnection
|
|
|
|
* ipcondescURL: url of the description of the WANIPConnection
|
|
|
|
* controlURL_CIF: controlURL of the WANCommonInterfaceConfig
|
|
|
|
* controlURL_6FC: controlURL of the WANIPv6FirewallControl
|
|
|
|
*/
|
|
|
|
struct UPNPUrls {
|
|
|
|
char * controlURL;
|
|
|
|
char * ipcondescURL;
|
|
|
|
char * controlURL_CIF;
|
|
|
|
char * controlURL_6FC;
|
|
|
|
char * rootdescURL;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* UPNP_GetValidIGD() :
|
|
|
|
* return values :
|
|
|
|
* 0 = NO IGD found
|
|
|
|
* 1 = A valid connected IGD has been found
|
|
|
|
* 2 = A valid IGD has been found but it reported as
|
|
|
|
* not connected
|
|
|
|
* 3 = an UPnP device has been found but was not recognized as an IGD
|
|
|
|
*
|
|
|
|
* In any non zero return case, the urls and data structures
|
|
|
|
* passed as parameters are set. Donc forget to call FreeUPNPUrls(urls) to
|
|
|
|
* free allocated memory.
|
|
|
|
*/
|
2014-06-01 10:35:13 +00:00
|
|
|
MINIUPNP_LIBSPEC int
|
2011-09-27 20:25:35 +00:00
|
|
|
UPNP_GetValidIGD(struct UPNPDev * devlist,
|
|
|
|
struct UPNPUrls * urls,
|
|
|
|
struct IGDdatas * data,
|
|
|
|
char * lanaddr, int lanaddrlen);
|
|
|
|
|
|
|
|
/* UPNP_GetIGDFromUrl()
|
|
|
|
* Used when skipping the discovery process.
|
2015-01-01 18:39:47 +00:00
|
|
|
* When succeding, urls, data, and lanaddr arguments are set.
|
2011-09-27 20:25:35 +00:00
|
|
|
* return value :
|
|
|
|
* 0 - Not ok
|
|
|
|
* 1 - OK */
|
2014-06-01 10:35:13 +00:00
|
|
|
MINIUPNP_LIBSPEC int
|
2011-09-27 20:25:35 +00:00
|
|
|
UPNP_GetIGDFromUrl(const char * rootdescurl,
|
|
|
|
struct UPNPUrls * urls,
|
|
|
|
struct IGDdatas * data,
|
|
|
|
char * lanaddr, int lanaddrlen);
|
|
|
|
|
2014-06-01 10:35:13 +00:00
|
|
|
MINIUPNP_LIBSPEC void
|
2012-06-28 19:05:50 +00:00
|
|
|
GetUPNPUrls(struct UPNPUrls *, struct IGDdatas *,
|
|
|
|
const char *, unsigned int);
|
2011-09-27 20:25:35 +00:00
|
|
|
|
2014-06-01 10:35:13 +00:00
|
|
|
MINIUPNP_LIBSPEC void
|
2012-06-28 19:05:50 +00:00
|
|
|
FreeUPNPUrls(struct UPNPUrls *);
|
2011-09-27 20:25:35 +00:00
|
|
|
|
|
|
|
/* return 0 or 1 */
|
2014-06-01 10:35:13 +00:00
|
|
|
MINIUPNP_LIBSPEC int UPNPIGD_IsConnected(struct UPNPUrls *, struct IGDdatas *);
|
2011-09-27 20:25:35 +00:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|