Vidalia  0.3.1
miniupnpc.h
Go to the documentation of this file.
1 /* $Id: miniupnpc.h,v 1.19 2009/10/10 19:15:35 nanard Exp $ */
2 /* Project: miniupnp
3  * http://miniupnp.free.fr/
4  * Author: Thomas Bernard
5  * Copyright (c) 2005-2006 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 #ifdef __cplusplus
15 extern "C" {
16 #endif
17 
18 /* Structures definitions : */
19 struct UPNParg { const char * elt; const char * val; };
20 
21 int simpleUPnPcommand(int, const char *, const char *,
22  const char *, struct UPNParg *,
23  char *, int *);
24 
25 struct UPNPDev {
26  struct UPNPDev * pNext;
27  char * descURL;
28  char * st;
29  char buffer[2];
30 };
31 
32 /* upnpDiscover()
33  * discover UPnP devices on the network.
34  * The discovered devices are returned as a chained list.
35  * It is up to the caller to free the list with freeUPNPDevlist().
36  * delay (in millisecond) is the maximum time for waiting any device
37  * response.
38  * If available, device list will be obtained from MiniSSDPd.
39  * Default path for minissdpd socket will be used if minissdpdsock argument
40  * is NULL.
41  * If multicastif is not NULL, it will be used instead of the default
42  * multicast interface for sending SSDP discover packets.
43  * If sameport is not null, SSDP packets will be sent from the source port
44  * 1900 (same as destination port) otherwise system assign a source port. */
45 LIBSPEC struct UPNPDev * upnpDiscover(int delay, const char * multicastif,
46  const char * minissdpdsock, int sameport);
47 /* freeUPNPDevlist()
48  * free list returned by upnpDiscover() */
49 LIBSPEC void freeUPNPDevlist(struct UPNPDev * devlist);
50 
51 /* parserootdesc() :
52  * parse root XML description of a UPnP device and fill the IGDdatas
53  * structure. */
54 LIBSPEC void parserootdesc(const char *, int, struct IGDdatas *);
55 
56 /* structure used to get fast access to urls
57  * controlURL: controlURL of the WANIPConnection
58  * ipcondescURL: url of the description of the WANIPConnection
59  * controlURL_CIF: controlURL of the WANCommonInterfaceConfig
60  */
61 struct UPNPUrls {
62  char * controlURL;
63  char * ipcondescURL;
65 };
66 
67 /* UPNP_GetValidIGD() :
68  * return values :
69  * 0 = NO IGD found
70  * 1 = A valid connected IGD has been found
71  * 2 = A valid IGD has been found but it reported as
72  * not connected
73  * 3 = an UPnP device has been found but was not recognized as an IGD
74  *
75  * In any non zero return case, the urls and data structures
76  * passed as parameters are set. Donc forget to call FreeUPNPUrls(urls) to
77  * free allocated memory.
78  */
79 LIBSPEC int
80 UPNP_GetValidIGD(struct UPNPDev * devlist,
81  struct UPNPUrls * urls,
82  struct IGDdatas * data,
83  char * lanaddr, int lanaddrlen);
84 
85 /* UPNP_GetIGDFromUrl()
86  * Used when skipping the discovery process.
87  * return value :
88  * 0 - Not ok
89  * 1 - OK */
90 LIBSPEC int
91 UPNP_GetIGDFromUrl(const char * rootdescurl,
92  struct UPNPUrls * urls,
93  struct IGDdatas * data,
94  char * lanaddr, int lanaddrlen);
95 
96 LIBSPEC void GetUPNPUrls(struct UPNPUrls *, struct IGDdatas *, const char *);
97 
98 LIBSPEC void FreeUPNPUrls(struct UPNPUrls *);
99 
100 /* Reads data from the specified socket.
101  * Returns the number of bytes read if successful, zero if no bytes were
102  * read or if we timed out. Returns negative if there was an error. */
103 int ReceiveData(int socket, char * data, int length, int timeout);
104 
105 /* return 0 or 1 */
106 LIBSPEC int UPNPIGD_IsConnected(struct UPNPUrls *, struct IGDdatas *);
107 
108 
109 #ifdef __cplusplus
110 }
111 #endif
112 
113 #endif
114 
parserootdesc
LIBSPEC void parserootdesc(const char *, int, struct IGDdatas *)
declspec.h
UPNPUrls::controlURL
char * controlURL
Definition: miniupnpc.h:62
UPNPDev::st
char * st
Definition: miniupnpc.h:28
UPNPDev::buffer
char buffer[2]
Definition: miniupnpc.h:29
UPNP_GetIGDFromUrl
LIBSPEC int UPNP_GetIGDFromUrl(const char *rootdescurl, struct UPNPUrls *urls, struct IGDdatas *data, char *lanaddr, int lanaddrlen)
UPNPUrls::ipcondescURL
char * ipcondescURL
Definition: miniupnpc.h:63
upnpDiscover
LIBSPEC struct UPNPDev * upnpDiscover(int delay, const char *multicastif, const char *minissdpdsock, int sameport)
UPNPUrls::controlURL_CIF
char * controlURL_CIF
Definition: miniupnpc.h:64
UPNPDev::pNext
struct UPNPDev * pNext
Definition: miniupnpc.h:26
UPNPDev::descURL
char * descURL
Definition: miniupnpc.h:27
UPNPDev
Definition: miniupnpc.h:25
LIBSPEC
#define LIBSPEC
Definition: declspec.h:11
GetUPNPUrls
LIBSPEC void GetUPNPUrls(struct UPNPUrls *, struct IGDdatas *, const char *)
ReceiveData
int ReceiveData(int socket, char *data, int length, int timeout)
FreeUPNPUrls
LIBSPEC void FreeUPNPUrls(struct UPNPUrls *)
UPNParg::val
const char * val
Definition: miniupnpc.h:19
freeUPNPDevlist
LIBSPEC void freeUPNPDevlist(struct UPNPDev *devlist)
UPNParg
Definition: miniupnpc.h:19
UPNPIGD_IsConnected
LIBSPEC int UPNPIGD_IsConnected(struct UPNPUrls *, struct IGDdatas *)
UPNPUrls
Definition: miniupnpc.h:61
igd_desc_parse.h
IGDdatas
Definition: igd_desc_parse.h:23
UPNParg::elt
const char * elt
Definition: miniupnpc.h:19
UPNP_GetValidIGD
LIBSPEC int UPNP_GetValidIGD(struct UPNPDev *devlist, struct UPNPUrls *urls, struct IGDdatas *data, char *lanaddr, int lanaddrlen)
simpleUPnPcommand
int simpleUPnPcommand(int, const char *, const char *, const char *, struct UPNParg *, char *, int *)