RetroArch
miniupnpc.h
Go to the documentation of this file.
1 /* $Id: miniupnpc.h,v 1.50 2016/04/19 21:06:21 nanard Exp $ */
2 /* Project: miniupnp
3  * http://miniupnp.free.fr/
4  * Author: Thomas Bernard
5  * Copyright (c) 2005-2016 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
10 
11 #include "miniupnpc_declspec.h"
12 #include "igd_desc_parse.h"
13 #include "upnpdev.h"
14 
15 /* error codes : */
16 #define UPNPDISCOVER_SUCCESS (0)
17 #define UPNPDISCOVER_UNKNOWN_ERROR (-1)
18 #define UPNPDISCOVER_SOCKET_ERROR (-101)
19 #define UPNPDISCOVER_MEMORY_ERROR (-102)
20 
21 /* versions : */
22 #define MINIUPNPC_VERSION "2.0"
23 #define MINIUPNPC_API_VERSION 16
24 
25 /* Source port:
26  Using "1" as an alias for 1900 for backwards compatability
27  (presuming one would have used that for the "sameport" parameter) */
28 #define UPNP_LOCAL_PORT_ANY 0
29 #define UPNP_LOCAL_PORT_SAME 1
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
35 /* Structures definitions : */
36 struct UPNParg { const char * elt; const char * val; };
37 
38 char *
39 simpleUPnPcommand(int, const char *, const char *,
40  const char *, struct UPNParg *,
41  int *);
42 
43 /* upnpDiscover()
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
48  * response.
49  * If available, device list will be obtained from MiniSSDPd.
50  * Default path for minissdpd socket will be used if minissdpdsock argument
51  * is NULL.
52  * If multicastif is not NULL, it will be used instead of the default
53  * multicast interface for sending SSDP discover packets.
54  * If localport is set to UPNP_LOCAL_PORT_SAME(1) SSDP packets will be sent
55  * from the source port 1900 (same as destination port), if set to
56  * UPNP_LOCAL_PORT_ANY(0) system assign a source port, any other value will
57  * be attempted as the source port.
58  * "searchalltypes" parameter is useful when searching several types,
59  * if 0, the discovery will stop with the first type returning results.
60  * TTL should default to 2. */
62 upnpDiscover(int delay, const char * multicastif,
63  const char * minissdpdsock, int localport,
64  int ipv6, unsigned char ttl,
65  int * error);
66 
68 upnpDiscoverAll(int delay, const char * multicastif,
69  const char * minissdpdsock, int localport,
70  int ipv6, unsigned char ttl,
71  int * error);
72 
74 upnpDiscoverDevice(const char * device, int delay, const char * multicastif,
75  const char * minissdpdsock, int localport,
76  int ipv6, unsigned char ttl,
77  int * error);
78 
80 upnpDiscoverDevices(const char * const deviceTypes[],
81  int delay, const char * multicastif,
82  const char * minissdpdsock, int localport,
83  int ipv6, unsigned char ttl,
84  int * error,
85  int searchalltypes);
86 
87 /* parserootdesc() :
88  * parse root XML description of a UPnP device and fill the IGDdatas
89  * structure. */
90 MINIUPNP_LIBSPEC void parserootdesc(const char *, int, struct IGDdatas *);
91 
92 /* structure used to get fast access to urls
93  * controlURL: controlURL of the WANIPConnection
94  * ipcondescURL: url of the description of the WANIPConnection
95  * controlURL_CIF: controlURL of the WANCommonInterfaceConfig
96  * controlURL_6FC: controlURL of the WANIPv6FirewallControl
97  */
98 struct UPNPUrls {
99  char * controlURL;
100  char * ipcondescURL;
103  char * rootdescURL;
104 };
105 
106 /* UPNP_GetValidIGD() :
107  * return values :
108  * 0 = NO IGD found
109  * 1 = A valid connected IGD has been found
110  * 2 = A valid IGD has been found but it reported as
111  * not connected
112  * 3 = an UPnP device has been found but was not recognized as an IGD
113  *
114  * In any non zero return case, the urls and data structures
115  * passed as parameters are set. Donc forget to call FreeUPNPUrls(urls) to
116  * free allocated memory.
117  */
119 UPNP_GetValidIGD(struct UPNPDev * devlist,
120  struct UPNPUrls * urls,
121  struct IGDdatas * data,
122  char * lanaddr, int lanaddrlen);
123 
124 /* UPNP_GetIGDFromUrl()
125  * Used when skipping the discovery process.
126  * When succeding, urls, data, and lanaddr arguments are set.
127  * return value :
128  * 0 - Not ok
129  * 1 - OK */
131 UPNP_GetIGDFromUrl(const char * rootdescurl,
132  struct UPNPUrls * urls,
133  struct IGDdatas * data,
134  char * lanaddr, int lanaddrlen);
135 
136 MINIUPNP_LIBSPEC void
137 GetUPNPUrls(struct UPNPUrls *, struct IGDdatas *,
138  const char *, unsigned int);
139 
140 MINIUPNP_LIBSPEC void
141 FreeUPNPUrls(struct UPNPUrls *);
142 
143 /* return 0 or 1 */
144 MINIUPNP_LIBSPEC int UPNPIGD_IsConnected(struct UPNPUrls *, struct IGDdatas *);
145 
146 
147 #ifdef __cplusplus
148 }
149 #endif
150 
151 #endif
152 
Definition: miniupnpc.h:98
char * controlURL_CIF
Definition: miniupnpc.h:101
MINIUPNP_LIBSPEC struct UPNPDev * upnpDiscoverAll(int delay, const char *multicastif, const char *minissdpdsock, int localport, int ipv6, unsigned char ttl, int *error)
Definition: miniupnpc.c:381
Definition: upnpdev.h:17
char * controlURL
Definition: miniupnpc.h:99
char * controlURL_6FC
Definition: miniupnpc.h:102
MINIUPNP_LIBSPEC int UPNP_GetValidIGD(struct UPNPDev *devlist, struct UPNPUrls *urls, struct IGDdatas *data, char *lanaddr, int lanaddrlen)
Definition: miniupnpc.c:559
MINIUPNP_LIBSPEC struct UPNPDev * upnpDiscover(int delay, const char *multicastif, const char *minissdpdsock, int localport, int ipv6, unsigned char ttl, int *error)
Definition: miniupnpc.c:357
Definition: ibxm.h:9
MINIUPNP_LIBSPEC void parserootdesc(const char *, int, struct IGDdatas *)
Definition: miniupnpc.c:97
MINIUPNP_LIBSPEC int UPNPIGD_IsConnected(struct UPNPUrls *, struct IGDdatas *)
Definition: miniupnpc.c:529
const char * val
Definition: miniupnpc.h:36
static l_noret error(LoadState *S, const char *why)
Definition: lundump.c:39
MINIUPNP_LIBSPEC struct UPNPDev * upnpDiscoverDevices(const char *const deviceTypes[], int delay, const char *multicastif, const char *minissdpdsock, int localport, int ipv6, unsigned char ttl, int *error, int searchalltypes)
Definition: miniupnpc.c:285
Definition: miniupnpc.h:36
#define MINIUPNP_LIBSPEC
Definition: miniupnpc_declspec.h:8
MINIUPNP_LIBSPEC int UPNP_GetIGDFromUrl(const char *rootdescurl, struct UPNPUrls *urls, struct IGDdatas *data, char *lanaddr, int lanaddrlen)
Definition: miniupnpc.c:702
MINIUPNP_LIBSPEC void FreeUPNPUrls(struct UPNPUrls *)
Definition: miniupnpc.c:512
const char * elt
Definition: miniupnpc.h:36
MINIUPNP_LIBSPEC struct UPNPDev * upnpDiscoverDevice(const char *device, int delay, const char *multicastif, const char *minissdpdsock, int localport, int ipv6, unsigned char ttl, int *error)
Definition: miniupnpc.c:398
char * rootdescURL
Definition: miniupnpc.h:103
char * simpleUPnPcommand(int, const char *, const char *, const char *, struct UPNParg *, int *)
Definition: miniupnpc.c:255
char * ipcondescURL
Definition: miniupnpc.h:100
MINIUPNP_LIBSPEC void GetUPNPUrls(struct UPNPUrls *, struct IGDdatas *, const char *, unsigned int)
Definition: miniupnpc.c:487
Definition: igd_desc_parse.h:23
struct nk_device device
Definition: nk_common.c:44