Odamex
Setting the Standard in Multiplayer Doom
libminiupnpc/miniupnpc.h
Go to the documentation of this file.
00001 /* $Id: miniupnpc.h,v 1.23 2011/04/11 08:21:46 nanard Exp $ */
00002 /* Project: miniupnp
00003  * http://miniupnp.free.fr/
00004  * Author: Thomas Bernard
00005  * Copyright (c) 2005-2011 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 /* error codes : */
00015 #define UPNPDISCOVER_SUCCESS (0)
00016 #define UPNPDISCOVER_UNKNOWN_ERROR (-1)
00017 #define UPNPDISCOVER_SOCKET_ERROR (-101)
00018 #define UPNPDISCOVER_MEMORY_ERROR (-102)
00019 
00020 #ifdef __cplusplus
00021 extern "C" {
00022 #endif
00023 
00024 /* Structures definitions : */
00025 struct UPNParg { const char * elt; const char * val; };
00026 
00027 char *
00028 simpleUPnPcommand(int, const char *, const char *,
00029                   const char *, struct UPNParg *,
00030                   int *);
00031 
00032 struct UPNPDev {
00033         struct UPNPDev * pNext;
00034         char * descURL;
00035         char * st;
00036         char buffer[2];
00037 };
00038 
00039 /* upnpDiscover()
00040  * discover UPnP devices on the network.
00041  * The discovered devices are returned as a chained list.
00042  * It is up to the caller to free the list with freeUPNPDevlist().
00043  * delay (in millisecond) is the maximum time for waiting any device
00044  * response.
00045  * If available, device list will be obtained from MiniSSDPd.
00046  * Default path for minissdpd socket will be used if minissdpdsock argument
00047  * is NULL.
00048  * If multicastif is not NULL, it will be used instead of the default
00049  * multicast interface for sending SSDP discover packets.
00050  * If sameport is not null, SSDP packets will be sent from the source port
00051  * 1900 (same as destination port) otherwise system assign a source port. */
00052 LIBSPEC struct UPNPDev *
00053 upnpDiscover(int delay, const char * multicastif,
00054              const char * minissdpdsock, int sameport,
00055              int ipv6,
00056              int * error);
00057 /* freeUPNPDevlist()
00058  * free list returned by upnpDiscover() */
00059 LIBSPEC void freeUPNPDevlist(struct UPNPDev * devlist);
00060 
00061 /* parserootdesc() :
00062  * parse root XML description of a UPnP device and fill the IGDdatas
00063  * structure. */
00064 LIBSPEC void parserootdesc(const char *, int, struct IGDdatas *);
00065 
00066 /* structure used to get fast access to urls
00067  * controlURL: controlURL of the WANIPConnection
00068  * ipcondescURL: url of the description of the WANIPConnection
00069  * controlURL_CIF: controlURL of the WANCommonInterfaceConfig
00070  * controlURL_6FC: controlURL of the WANIPv6FirewallControl
00071  */
00072 struct UPNPUrls {
00073         char * controlURL;
00074         char * ipcondescURL;
00075         char * controlURL_CIF;
00076         char * controlURL_6FC;
00077 };
00078 
00079 /* UPNP_GetValidIGD() :
00080  * return values :
00081  *     0 = NO IGD found
00082  *     1 = A valid connected IGD has been found
00083  *     2 = A valid IGD has been found but it reported as
00084  *         not connected
00085  *     3 = an UPnP device has been found but was not recognized as an IGD
00086  *
00087  * In any non zero return case, the urls and data structures
00088  * passed as parameters are set. Donc forget to call FreeUPNPUrls(urls) to
00089  * free allocated memory.
00090  */
00091 LIBSPEC int
00092 UPNP_GetValidIGD(struct UPNPDev * devlist,
00093                  struct UPNPUrls * urls,
00094                                  struct IGDdatas * data,
00095                                  char * lanaddr, int lanaddrlen);
00096 
00097 /* UPNP_GetIGDFromUrl()
00098  * Used when skipping the discovery process.
00099  * return value :
00100  *   0 - Not ok
00101  *   1 - OK */
00102 LIBSPEC int
00103 UPNP_GetIGDFromUrl(const char * rootdescurl,
00104                    struct UPNPUrls * urls,
00105                    struct IGDdatas * data,
00106                    char * lanaddr, int lanaddrlen);
00107 
00108 LIBSPEC void GetUPNPUrls(struct UPNPUrls *, struct IGDdatas *, const char *);
00109 
00110 LIBSPEC void FreeUPNPUrls(struct UPNPUrls *);
00111 
00112 /* return 0 or 1 */
00113 LIBSPEC int UPNPIGD_IsConnected(struct UPNPUrls *, struct IGDdatas *);
00114 
00115 
00116 #ifdef __cplusplus
00117 }
00118 #endif
00119 
00120 #endif
00121 
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends