Monero
Loading...
Searching...
No Matches
miniupnpc.h
Go to the documentation of this file.
1/* $Id: miniupnpc.h,v 1.56 2020/12/20 18:07:35 nanard Exp $ */
2/* vim: tabstop=4 shiftwidth=4 noexpandtab
3 * Project: miniupnp
4 * http://miniupnp.free.fr/
5 * Author: Thomas Bernard
6 * Copyright (c) 2005-2018 Thomas Bernard
7 * This software is subjects to the conditions detailed
8 * in the LICENCE file provided within this distribution */
9#ifndef MINIUPNPC_H_INCLUDED
10#define MINIUPNPC_H_INCLUDED
11
12#include "miniupnpc_declspec.h"
13#include "igd_desc_parse.h"
14#include "upnpdev.h"
15
16/* error codes : */
17#define UPNPDISCOVER_SUCCESS (0)
18#define UPNPDISCOVER_UNKNOWN_ERROR (-1)
19#define UPNPDISCOVER_SOCKET_ERROR (-101)
20#define UPNPDISCOVER_MEMORY_ERROR (-102)
21
22/* versions : */
23#define MINIUPNPC_VERSION "2.2.1"
24#define MINIUPNPC_API_VERSION 17
25
26/* Source port:
27 Using "1" as an alias for 1900 for backwards compatibility
28 (presuming one would have used that for the "sameport" parameter) */
29#define UPNP_LOCAL_PORT_ANY 0
30#define UPNP_LOCAL_PORT_SAME 1
31
32#ifdef __cplusplus
33extern "C" {
34#endif
35
36/* Structures definitions : */
37struct UPNParg { const char * elt; const char * val; };
38
39char *
40simpleUPnPcommand(int, const char *, const char *,
41 const char *, struct UPNParg *,
42 int *);
43
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 localport is set to UPNP_LOCAL_PORT_SAME(1) SSDP packets will be sent
56 * from the source port 1900 (same as destination port), if set to
57 * UPNP_LOCAL_PORT_ANY(0) system assign a source port, any other value will
58 * be attempted as the source port.
59 * "searchalltypes" parameter is useful when searching several types,
60 * if 0, the discovery will stop with the first type returning results.
61 * TTL should default to 2. */
63upnpDiscover(int delay, const char * multicastif,
64 const char * minissdpdsock, int localport,
65 int ipv6, unsigned char ttl,
66 int * error);
67
69upnpDiscoverAll(int delay, const char * multicastif,
70 const char * minissdpdsock, int localport,
71 int ipv6, unsigned char ttl,
72 int * error);
73
75upnpDiscoverDevice(const char * device, int delay, const char * multicastif,
76 const char * minissdpdsock, int localport,
77 int ipv6, unsigned char ttl,
78 int * error);
79
81upnpDiscoverDevices(const char * const deviceTypes[],
82 int delay, const char * multicastif,
83 const char * minissdpdsock, int localport,
84 int ipv6, unsigned char ttl,
85 int * error,
86 int searchalltypes);
87
88/* parserootdesc() :
89 * parse root XML description of a UPnP device and fill the IGDdatas
90 * structure. */
91MINIUPNP_LIBSPEC void parserootdesc(const char *, int, struct IGDdatas *);
92
93/* structure used to get fast access to urls
94 * controlURL: controlURL of the WANIPConnection
95 * ipcondescURL: url of the description of the WANIPConnection
96 * controlURL_CIF: controlURL of the WANCommonInterfaceConfig
97 * controlURL_6FC: controlURL of the WANIPv6FirewallControl
98 */
106
107/* UPNP_GetValidIGD() :
108 * return values :
109 * 0 = NO IGD found
110 * 1 = A valid connected IGD has been found
111 * 2 = A valid IGD has been found but it reported as
112 * not connected
113 * 3 = an UPnP device has been found but was not recognized as an IGD
114 *
115 * In any non zero return case, the urls and data structures
116 * passed as parameters are set. Donc forget to call FreeUPNPUrls(urls) to
117 * free allocated memory.
118 */
121 struct UPNPUrls * urls,
122 struct IGDdatas * data,
123 char * lanaddr, int lanaddrlen);
124
125/* UPNP_GetIGDFromUrl()
126 * Used when skipping the discovery process.
127 * When succeding, urls, data, and lanaddr arguments are set.
128 * return value :
129 * 0 - Not ok
130 * 1 - OK */
132UPNP_GetIGDFromUrl(const char * rootdescurl,
133 struct UPNPUrls * urls,
134 struct IGDdatas * data,
135 char * lanaddr, int lanaddrlen);
136
138GetUPNPUrls(struct UPNPUrls *, struct IGDdatas *,
139 const char *, unsigned int);
140
142FreeUPNPUrls(struct UPNPUrls *);
143
144/* return 0 or 1 */
146
147
148#ifdef __cplusplus
149}
150#endif
151
152#endif
153
struct device * devlist
Definition minissdpd.c:107
#define MINIUPNP_LIBSPEC
Definition miniupnpc_declspec.h:16
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:342
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:366
MINIUPNP_LIBSPEC int UPNP_GetIGDFromUrl(const char *rootdescurl, struct UPNPUrls *urls, struct IGDdatas *data, char *lanaddr, int lanaddrlen)
Definition miniupnpc.c:676
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:383
char * simpleUPnPcommand(int, const char *, const char *, const char *, struct UPNParg *, int *)
Definition miniupnpc.c:238
MINIUPNP_LIBSPEC void parserootdesc(const char *, int, struct IGDdatas *)
Definition miniupnpc.c:78
MINIUPNP_LIBSPEC int UPNPIGD_IsConnected(struct UPNPUrls *, struct IGDdatas *)
Definition miniupnpc.c:514
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:268
MINIUPNP_LIBSPEC int UPNP_GetValidIGD(struct UPNPDev *devlist, struct UPNPUrls *urls, struct IGDdatas *data, char *lanaddr, int lanaddrlen)
Definition miniupnpc.c:544
MINIUPNP_LIBSPEC void GetUPNPUrls(struct UPNPUrls *, struct IGDdatas *, const char *, unsigned int)
Definition miniupnpc.c:472
MINIUPNP_LIBSPEC void FreeUPNPUrls(struct UPNPUrls *)
Definition miniupnpc.c:497
Definition igd_desc_parse.h:23
Definition upnpdev.h:17
Definition miniupnpc.h:99
char * controlURL
Definition miniupnpc.h:100
char * controlURL_CIF
Definition miniupnpc.h:102
char * rootdescURL
Definition miniupnpc.h:104
char * controlURL_6FC
Definition miniupnpc.h:103
char * ipcondescURL
Definition miniupnpc.h:101
Definition miniupnpc.h:37
const char * elt
Definition miniupnpc.h:37
const char * val
Definition miniupnpc.h:37
Definition minissdpd.c:75
std::string data
Definition base58.cpp:37