1 /* $Id: miniupnpc.h,v 1.25 2011/10/09 16:17:29 nanard Exp $ */
3 * http://miniupnp.free.fr/
4 * Author: Thomas Bernard
5 * Copyright (c) 2005-2011 Thomas Bernard
6 * This software is subjects to the conditions detailed
7 * in the LICENCE file provided within this distribution */
8 #ifndef __MINIUPNPC_H__
9 #define __MINIUPNPC_H__
12 #include "igd_desc_parse.h"
15 #define UPNPDISCOVER_SUCCESS (0)
16 #define UPNPDISCOVER_UNKNOWN_ERROR (-1)
17 #define UPNPDISCOVER_SOCKET_ERROR (-101)
18 #define UPNPDISCOVER_MEMORY_ERROR (-102)
21 #define MINIUPNPC_VERSION "1.6.20120320"
22 #define MINIUPNPC_API_VERSION 8
28 /* Structures definitions : */
29 struct UPNParg
{ const char * elt
; const char * val
; };
32 simpleUPnPcommand(int, const char *, const char *,
33 const char *, struct UPNParg
*,
37 struct UPNPDev
* pNext
;
44 * discover UPnP devices on the network.
45 * The discovered devices are returned as a chained list.
46 * It is up to the caller to free the list with freeUPNPDevlist().
47 * delay (in millisecond) is the maximum time for waiting any device
49 * If available, device list will be obtained from MiniSSDPd.
50 * Default path for minissdpd socket will be used if minissdpdsock argument
52 * If multicastif is not NULL, it will be used instead of the default
53 * multicast interface for sending SSDP discover packets.
54 * If sameport is not null, SSDP packets will be sent from the source port
55 * 1900 (same as destination port) otherwise system assign a source port. */
56 LIBSPEC
struct UPNPDev
*
57 upnpDiscover(int delay
, const char * multicastif
,
58 const char * minissdpdsock
, int sameport
,
62 * free list returned by upnpDiscover() */
63 LIBSPEC
void freeUPNPDevlist(struct UPNPDev
* devlist
);
66 * parse root XML description of a UPnP device and fill the IGDdatas
68 LIBSPEC
void parserootdesc(const char *, int, struct IGDdatas
*);
70 /* structure used to get fast access to urls
71 * controlURL: controlURL of the WANIPConnection
72 * ipcondescURL: url of the description of the WANIPConnection
73 * controlURL_CIF: controlURL of the WANCommonInterfaceConfig
74 * controlURL_6FC: controlURL of the WANIPv6FirewallControl
79 char * controlURL_CIF
;
80 char * controlURL_6FC
;
84 /* UPNP_GetValidIGD() :
87 * 1 = A valid connected IGD has been found
88 * 2 = A valid IGD has been found but it reported as
90 * 3 = an UPnP device has been found but was not recognized as an IGD
92 * In any non zero return case, the urls and data structures
93 * passed as parameters are set. Donc forget to call FreeUPNPUrls(urls) to
94 * free allocated memory.
97 UPNP_GetValidIGD(struct UPNPDev
* devlist
,
98 struct UPNPUrls
* urls
,
99 struct IGDdatas
* data
,
100 char * lanaddr
, int lanaddrlen
);
102 /* UPNP_GetIGDFromUrl()
103 * Used when skipping the discovery process.
108 UPNP_GetIGDFromUrl(const char * rootdescurl
,
109 struct UPNPUrls
* urls
,
110 struct IGDdatas
* data
,
111 char * lanaddr
, int lanaddrlen
);
113 LIBSPEC
void GetUPNPUrls(struct UPNPUrls
*, struct IGDdatas
*, const char *);
115 LIBSPEC
void FreeUPNPUrls(struct UPNPUrls
*);
118 LIBSPEC
int UPNPIGD_IsConnected(struct UPNPUrls
*, struct IGDdatas
*);