transmission 2.83
[tomato.git] / release / src-rt-6.x.4708 / router / transmission / third-party / miniupnp / miniupnpc.h
blob3af109cf12579ce20ef1b936dcd5f755c91c83de
1 /* $Id: miniupnpc.h,v 1.35 2014/01/31 13:26:34 nanard Exp $ */
2 /* Project: miniupnp
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
11 #include "declspec.h"
12 #include "igd_desc_parse.h"
14 /* error codes : */
15 #define UPNPDISCOVER_SUCCESS (0)
16 #define UPNPDISCOVER_UNKNOWN_ERROR (-1)
17 #define UPNPDISCOVER_SOCKET_ERROR (-101)
18 #define UPNPDISCOVER_MEMORY_ERROR (-102)
20 /* versions : */
21 #define MINIUPNPC_VERSION "1.9.20140401"
22 #define MINIUPNPC_API_VERSION 10
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
28 /* Structures definitions : */
29 struct UPNParg { const char * elt; const char * val; };
31 char *
32 simpleUPnPcommand(int, const char *, const char *,
33 const char *, struct UPNParg *,
34 int *);
36 struct UPNPDev {
37 struct UPNPDev * pNext;
38 char * descURL;
39 char * st;
40 unsigned int scope_id;
41 char buffer[2];
44 /* upnpDiscover()
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
49 * response.
50 * If available, device list will be obtained from MiniSSDPd.
51 * Default path for minissdpd socket will be used if minissdpdsock argument
52 * is NULL.
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,
60 int ipv6,
61 int * error);
62 /* freeUPNPDevlist()
63 * free list returned by upnpDiscover() */
64 LIBSPEC void freeUPNPDevlist(struct UPNPDev * devlist);
66 /* parserootdesc() :
67 * parse root XML description of a UPnP device and fill the IGDdatas
68 * structure. */
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
77 struct UPNPUrls {
78 char * controlURL;
79 char * ipcondescURL;
80 char * controlURL_CIF;
81 char * controlURL_6FC;
82 char * rootdescURL;
85 /* UPNP_GetValidIGD() :
86 * return values :
87 * 0 = NO IGD found
88 * 1 = A valid connected IGD has been found
89 * 2 = A valid IGD has been found but it reported as
90 * not connected
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.
97 LIBSPEC int
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.
105 * return value :
106 * 0 - Not ok
107 * 1 - OK */
108 LIBSPEC int
109 UPNP_GetIGDFromUrl(const char * rootdescurl,
110 struct UPNPUrls * urls,
111 struct IGDdatas * data,
112 char * lanaddr, int lanaddrlen);
114 LIBSPEC void
115 GetUPNPUrls(struct UPNPUrls *, struct IGDdatas *,
116 const char *, unsigned int);
118 LIBSPEC void
119 FreeUPNPUrls(struct UPNPUrls *);
121 /* return 0 or 1 */
122 LIBSPEC int UPNPIGD_IsConnected(struct UPNPUrls *, struct IGDdatas *);
125 #ifdef __cplusplus
127 #endif
129 #endif