miniupnpc.h

Go to the documentation of this file.
00001 /* $Id: miniupnpc.h,v 1.17 2007/12/19 14:58:54 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 LIBSPEC struct UPNPDev * upnpDiscover(int delay, const char * multicastif,
00044                                       const char * minissdpdsock);
00045 /* freeUPNPDevlist()
00046  * free list returned by upnpDiscover() */
00047 LIBSPEC void freeUPNPDevlist(struct UPNPDev * devlist);
00048 
00049 /* parserootdesc() :
00050  * parse root XML description of a UPnP device and fill the IGDdatas
00051  * structure. */
00052 LIBSPEC void parserootdesc(const char *, int, struct IGDdatas *);
00053 
00054 /* structure used to get fast access to urls
00055  * controlURL: controlURL of the WANIPConnection
00056  * ipcondescURL: url of the description of the WANIPConnection
00057  * controlURL_CIF: controlURL of the WANCommonInterfaceConfig
00058  */
00059 struct UPNPUrls {
00060         char * controlURL;
00061         char * ipcondescURL;
00062         char * controlURL_CIF;
00063 };
00064 
00065 /* UPNP_GetValidIGD() :
00066  * return values :
00067  *     0 = NO IGD found
00068  *     1 = A valid connected IGD has been found
00069  *     2 = A valid IGD has been found but it reported as
00070  *         not connected
00071  *     3 = an UPnP device has been found but was not recognized as an IGD
00072  *
00073  * In any non zero return case, the urls and data structures
00074  * passed as parameters are set. Donc forget to call FreeUPNPUrls(urls) to
00075  * free allocated memory.
00076  */
00077 LIBSPEC int
00078 UPNP_GetValidIGD(struct UPNPDev * devlist,
00079                  struct UPNPUrls * urls,
00080                                  struct IGDdatas * data,
00081                                  char * lanaddr, int lanaddrlen);
00082 
00083 /* UPNP_GetIGDFromUrl()
00084  * Used when skipping the discovery process.
00085  * return value :
00086  *   0 - Not ok
00087  *   1 - OK */
00088 LIBSPEC int
00089 UPNP_GetIGDFromUrl(const char * rootdescurl,
00090                    struct UPNPUrls * urls,
00091                    struct IGDdatas * data,
00092                    char * lanaddr, int lanaddrlen);
00093 
00094 LIBSPEC void GetUPNPUrls(struct UPNPUrls *, struct IGDdatas *, const char *);
00095 
00096 LIBSPEC void FreeUPNPUrls(struct UPNPUrls *);
00097 
00098 /* Reads data from the specified socket. 
00099  * Returns the number of bytes read if successful, zero if no bytes were 
00100  * read or if we timed out. Returns negative if there was an error. */
00101 int ReceiveData(int socket, char * data, int length, int timeout);
00102 
00103 #ifdef __cplusplus
00104 }
00105 #endif
00106 
00107 #endif
00108 

Generated on Wed Nov 26 21:02:38 2008 for Vidalia by  doxygen 1.5.6