source: trunk/third-party/miniupnp/miniupnpc.h @ 9282

Last change on this file since 9282 was 9282, checked in by livings124, 12 years ago

update to miniupnpc-20091010

File size: 3.6 KB
Line 
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
15extern "C" {
16#endif
17
18/* Structures definitions : */
19struct UPNParg { const char * elt; const char * val; };
20
21int simpleUPnPcommand(int, const char *, const char *,
22                      const char *, struct UPNParg *,
23                      char *, int *);
24
25struct 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. */
45LIBSPEC struct UPNPDev * upnpDiscover(int delay, const char * multicastif,
46                                      const char * minissdpdsock, int sameport);
47/* freeUPNPDevlist()
48 * free list returned by upnpDiscover() */
49LIBSPEC void freeUPNPDevlist(struct UPNPDev * devlist);
50
51/* parserootdesc() :
52 * parse root XML description of a UPnP device and fill the IGDdatas
53 * structure. */
54LIBSPEC 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 */
61struct UPNPUrls {
62        char * controlURL;
63        char * ipcondescURL;
64        char * controlURL_CIF;
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 */
79LIBSPEC int
80UPNP_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 */
90LIBSPEC int
91UPNP_GetIGDFromUrl(const char * rootdescurl,
92                   struct UPNPUrls * urls,
93                   struct IGDdatas * data,
94                   char * lanaddr, int lanaddrlen);
95
96LIBSPEC void GetUPNPUrls(struct UPNPUrls *, struct IGDdatas *, const char *);
97
98LIBSPEC 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. */
103int ReceiveData(int socket, char * data, int length, int timeout);
104
105/* return 0 or 1 */
106LIBSPEC int UPNPIGD_IsConnected(struct UPNPUrls *, struct IGDdatas *);
107
108
109#ifdef __cplusplus
110}
111#endif
112
113#endif
114
Note: See TracBrowser for help on using the repository browser.