1 /* $Id: miniupnpc.h,v 1.35 2014/01/31 13:26:34 nanard Exp $ */
3 * http://miniupnp.free.fr/
4 * Author: Thomas Bernard
5 * Copyright (c) 2005-2012 Thomas Bernard
6 * This software is subjects to the conditions detailed
7 * in the LICENCE file provided within this distribution */
8 #ifndef MINIUPNPC_H_INCLUDED
9 #define MINIUPNPC_H_INCLUDED
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.9.20140401"
22 #define MINIUPNPC_API_VERSION 10
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
;
40 unsigned int scope_id
;
45 * discover UPnP devices on the network.
46 * The discovered devices are returned as a chained list.
47 * It is up to the caller to free the list with freeUPNPDevlist().
48 * delay (in millisecond) is the maximum time for waiting any device
50 * If available, device list will be obtained from MiniSSDPd.
51 * Default path for minissdpd socket will be used if minissdpdsock argument
53 * If multicastif is not NULL, it will be used instead of the default
54 * multicast interface for sending SSDP discover packets.
55 * If sameport is not null, SSDP packets will be sent from the source port
56 * 1900 (same as destination port) otherwise system assign a source port. */
57 LIBSPEC
struct UPNPDev
*
58 upnpDiscover(int delay
, const char * multicastif
,
59 const char * minissdpdsock
, int sameport
,
63 * free list returned by upnpDiscover() */
64 LIBSPEC
void freeUPNPDevlist(struct UPNPDev
* devlist
);
67 * parse root XML description of a UPnP device and fill the IGDdatas
69 LIBSPEC
void parserootdesc(const char *, int, struct IGDdatas
*);
71 /* structure used to get fast access to urls
72 * controlURL: controlURL of the WANIPConnection
73 * ipcondescURL: url of the description of the WANIPConnection
74 * controlURL_CIF: controlURL of the WANCommonInterfaceConfig
75 * controlURL_6FC: controlURL of the WANIPv6FirewallControl
80 char * controlURL_CIF
;
81 char * controlURL_6FC
;
85 /* UPNP_GetValidIGD() :
88 * 1 = A valid connected IGD has been found
89 * 2 = A valid IGD has been found but it reported as
91 * 3 = an UPnP device has been found but was not recognized as an IGD
93 * In any non zero return case, the urls and data structures
94 * passed as parameters are set. Donc forget to call FreeUPNPUrls(urls) to
95 * free allocated memory.
98 UPNP_GetValidIGD(struct UPNPDev
* devlist
,
99 struct UPNPUrls
* urls
,
100 struct IGDdatas
* data
,
101 char * lanaddr
, int lanaddrlen
);
103 /* UPNP_GetIGDFromUrl()
104 * Used when skipping the discovery process.
109 UPNP_GetIGDFromUrl(const char * rootdescurl
,
110 struct UPNPUrls
* urls
,
111 struct IGDdatas
* data
,
112 char * lanaddr
, int lanaddrlen
);
115 GetUPNPUrls(struct UPNPUrls
*, struct IGDdatas
*,
116 const char *, unsigned int);
119 FreeUPNPUrls(struct UPNPUrls
*);
122 LIBSPEC
int UPNPIGD_IsConnected(struct UPNPUrls
*, struct IGDdatas
*);