• Home
  • History
  • Annotate
  • Line#
  • Navigate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/transmission/transmission-2.73/third-party/miniupnp/
1/* $Id: miniupnpc.h,v 1.25 2011/10/09 16:17:29 nanard Exp $ */
2/* Project: miniupnp
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__
10
11#include "declspec.h"
12#include "igd_desc_parse.h"
13
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)
19
20/* versions : */
21#define MINIUPNPC_VERSION	"1.7"
22#define MINIUPNPC_API_VERSION	8
23
24#ifdef __cplusplus
25extern "C" {
26#endif
27
28/* Structures definitions : */
29struct UPNParg { const char * elt; const char * val; };
30
31char *
32simpleUPnPcommand(int, const char *, const char *,
33                  const char *, struct UPNParg *,
34                  int *);
35
36struct UPNPDev {
37	struct UPNPDev * pNext;
38	char * descURL;
39	char * st;
40	char buffer[2];
41};
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 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. */
56LIBSPEC struct UPNPDev *
57upnpDiscover(int delay, const char * multicastif,
58             const char * minissdpdsock, int sameport,
59             int ipv6,
60             int * error);
61/* freeUPNPDevlist()
62 * free list returned by upnpDiscover() */
63LIBSPEC void freeUPNPDevlist(struct UPNPDev * devlist);
64
65/* parserootdesc() :
66 * parse root XML description of a UPnP device and fill the IGDdatas
67 * structure. */
68LIBSPEC void parserootdesc(const char *, int, struct IGDdatas *);
69
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
75 */
76struct UPNPUrls {
77	char * controlURL;
78	char * ipcondescURL;
79	char * controlURL_CIF;
80	char * controlURL_6FC;
81	char * rootdescURL;
82};
83
84/* UPNP_GetValidIGD() :
85 * return values :
86 *     0 = NO IGD found
87 *     1 = A valid connected IGD has been found
88 *     2 = A valid IGD has been found but it reported as
89 *         not connected
90 *     3 = an UPnP device has been found but was not recognized as an IGD
91 *
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.
95 */
96LIBSPEC int
97UPNP_GetValidIGD(struct UPNPDev * devlist,
98                 struct UPNPUrls * urls,
99				 struct IGDdatas * data,
100				 char * lanaddr, int lanaddrlen);
101
102/* UPNP_GetIGDFromUrl()
103 * Used when skipping the discovery process.
104 * return value :
105 *   0 - Not ok
106 *   1 - OK */
107LIBSPEC int
108UPNP_GetIGDFromUrl(const char * rootdescurl,
109                   struct UPNPUrls * urls,
110                   struct IGDdatas * data,
111                   char * lanaddr, int lanaddrlen);
112
113LIBSPEC void GetUPNPUrls(struct UPNPUrls *, struct IGDdatas *, const char *);
114
115LIBSPEC void FreeUPNPUrls(struct UPNPUrls *);
116
117/* return 0 or 1 */
118LIBSPEC int UPNPIGD_IsConnected(struct UPNPUrls *, struct IGDdatas *);
119
120
121#ifdef __cplusplus
122}
123#endif
124
125#endif
126
127