miniupnpc.h

Go to the documentation of this file.
00001 /* $Id: miniupnpc.h,v 1.19 2009/10/10 19:15:35 nanard Exp $ */
00002 /* Project: miniupnp
00003  * http://miniupnp.free.fr/
00004  * Author: Thomas Bernard
00005  * Copyright (c) 2005-2006 Thomas Bernard
00006  * This software is subjects to the conditions detailed
00007  * in the LICENCE file provided within this distribution */
00008 #ifndef __MINIUPNPC_H__
00009 #define __MINIUPNPC_H__
00010 
00011 #include "declspec.h"
00012 #include "igd_desc_parse.h"
00013 
00014 #ifdef __cplusplus
00015 extern "C" {
00016 #endif
00017 
00018 /* Structures definitions : */
00019 struct UPNParg { const char * elt; const char * val; };
00020 
00021 int simpleUPnPcommand(int, const char *, const char *,
00022                       const char *, struct UPNParg *,
00023                       char *, int *);
00024 
00025 struct UPNPDev {
00026         struct UPNPDev * pNext;
00027         char * descURL;
00028         char * st;
00029         char buffer[2];
00030 };
00031 
00032 /* upnpDiscover()
00033  * discover UPnP devices on the network.
00034  * The discovered devices are returned as a chained list.
00035  * It is up to the caller to free the list with freeUPNPDevlist().
00036  * delay (in millisecond) is the maximum time for waiting any device
00037  * response.
00038  * If available, device list will be obtained from MiniSSDPd.
00039  * Default path for minissdpd socket will be used if minissdpdsock argument
00040  * is NULL.
00041  * If multicastif is not NULL, it will be used instead of the default
00042  * multicast interface for sending SSDP discover packets.
00043  * If sameport is not null, SSDP packets will be sent from the source port
00044  * 1900 (same as destination port) otherwise system assign a source port. */
00045 LIBSPEC struct UPNPDev * upnpDiscover(int delay, const char * multicastif,
00046                                       const char * minissdpdsock, int sameport);
00047 /* freeUPNPDevlist()
00048  * free list returned by upnpDiscover() */
00049 LIBSPEC void freeUPNPDevlist(struct UPNPDev * devlist);
00050 
00051 /* parserootdesc() :
00052  * parse root XML description of a UPnP device and fill the IGDdatas
00053  * structure. */
00054 LIBSPEC void parserootdesc(const char *, int, struct IGDdatas *);
00055 
00056 /* structure used to get fast access to urls
00057  * controlURL: controlURL of the WANIPConnection
00058  * ipcondescURL: url of the description of the WANIPConnection
00059  * controlURL_CIF: controlURL of the WANCommonInterfaceConfig
00060  */
00061 struct UPNPUrls {
00062         char * controlURL;
00063         char * ipcondescURL;
00064         char * controlURL_CIF;
00065 };
00066 
00067 /* UPNP_GetValidIGD() :
00068  * return values :
00069  *     0 = NO IGD found
00070  *     1 = A valid connected IGD has been found
00071  *     2 = A valid IGD has been found but it reported as
00072  *         not connected
00073  *     3 = an UPnP device has been found but was not recognized as an IGD
00074  *
00075  * In any non zero return case, the urls and data structures
00076  * passed as parameters are set. Donc forget to call FreeUPNPUrls(urls) to
00077  * free allocated memory.
00078  */
00079 LIBSPEC int
00080 UPNP_GetValidIGD(struct UPNPDev * devlist,
00081                  struct UPNPUrls * urls,
00082                                  struct IGDdatas * data,
00083                                  char * lanaddr, int lanaddrlen);
00084 
00085 /* UPNP_GetIGDFromUrl()
00086  * Used when skipping the discovery process.
00087  * return value :
00088  *   0 - Not ok
00089  *   1 - OK */
00090 LIBSPEC int
00091 UPNP_GetIGDFromUrl(const char * rootdescurl,
00092                    struct UPNPUrls * urls,
00093                    struct IGDdatas * data,
00094                    char * lanaddr, int lanaddrlen);
00095 
00096 LIBSPEC void GetUPNPUrls(struct UPNPUrls *, struct IGDdatas *, const char *);
00097 
00098 LIBSPEC void FreeUPNPUrls(struct UPNPUrls *);
00099 
00100 /* Reads data from the specified socket. 
00101  * Returns the number of bytes read if successful, zero if no bytes were 
00102  * read or if we timed out. Returns negative if there was an error. */
00103 int ReceiveData(int socket, char * data, int length, int timeout);
00104 
00105 /* return 0 or 1 */
00106 LIBSPEC int UPNPIGD_IsConnected(struct UPNPUrls *, struct IGDdatas *);
00107 
00108 
00109 #ifdef __cplusplus
00110 }
00111 #endif
00112 
00113 #endif
00114 

Generated on Mon Aug 30 19:14:02 2010 for Vidalia by  doxygen 1.5.9