Odamex
Setting the Standard in Multiplayer Doom
libminiupnpc/upnpcommands.h
Go to the documentation of this file.
00001 /* $Id: upnpcommands.h,v 1.23 2011/04/11 09:14:00 nanard Exp $ */
00002 /* Miniupnp project : http://miniupnp.free.fr/
00003  * Author : Thomas Bernard
00004  * Copyright (c) 2005-2011 Thomas Bernard
00005  * This software is subject to the conditions detailed in the
00006  * LICENCE file provided within this distribution */
00007 #ifndef __UPNPCOMMANDS_H__
00008 #define __UPNPCOMMANDS_H__
00009 
00010 #include "upnpreplyparse.h"
00011 #include "portlistingparse.h"
00012 #include "declspec.h"
00013 #include "miniupnpctypes.h"
00014 
00015 /* MiniUPnPc return codes : */
00016 #define UPNPCOMMAND_SUCCESS (0)
00017 #define UPNPCOMMAND_UNKNOWN_ERROR (-1)
00018 #define UPNPCOMMAND_INVALID_ARGS (-2)
00019 #define UPNPCOMMAND_HTTP_ERROR (-3)
00020 
00021 #ifdef __cplusplus
00022 extern "C" {
00023 #endif
00024 
00025 LIBSPEC UNSIGNED_INTEGER
00026 UPNP_GetTotalBytesSent(const char * controlURL,
00027                                         const char * servicetype);
00028 
00029 LIBSPEC UNSIGNED_INTEGER
00030 UPNP_GetTotalBytesReceived(const char * controlURL,
00031                                                 const char * servicetype);
00032 
00033 LIBSPEC UNSIGNED_INTEGER
00034 UPNP_GetTotalPacketsSent(const char * controlURL,
00035                                         const char * servicetype);
00036 
00037 LIBSPEC UNSIGNED_INTEGER
00038 UPNP_GetTotalPacketsReceived(const char * controlURL,
00039                                         const char * servicetype);
00040 
00041 /* UPNP_GetStatusInfo()
00042  * status and lastconnerror are 64 byte buffers
00043  * Return values :
00044  * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR
00045  * or a UPnP Error code */
00046 LIBSPEC int
00047 UPNP_GetStatusInfo(const char * controlURL,
00048                                const char * servicetype,
00049                                    char * status,
00050                                    unsigned int * uptime,
00051                    char * lastconnerror);
00052 
00053 /* UPNP_GetConnectionTypeInfo()
00054  * argument connectionType is a 64 character buffer
00055  * Return Values :
00056  * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR
00057  * or a UPnP Error code */
00058 LIBSPEC int
00059 UPNP_GetConnectionTypeInfo(const char * controlURL,
00060                            const char * servicetype,
00061                                                    char * connectionType);
00062 
00063 /* UPNP_GetExternalIPAddress() call the corresponding UPNP method.
00064  * if the third arg is not null the value is copied to it.
00065  * at least 16 bytes must be available 
00066  *
00067  * Return values :
00068  * 0 : SUCCESS
00069  * NON ZERO : ERROR Either an UPnP error code or an unknown error.
00070  * 
00071  * possible UPnP Errors :
00072  * 402 Invalid Args - See UPnP Device Architecture section on Control.
00073  * 501 Action Failed - See UPnP Device Architecture section on Control. */
00074 LIBSPEC int
00075 UPNP_GetExternalIPAddress(const char * controlURL,
00076                           const char * servicetype,
00077                           char * extIpAdd);
00078 
00079 /* UPNP_GetLinkLayerMaxBitRates()
00080  * call WANCommonInterfaceConfig:1#GetCommonLinkProperties
00081  *
00082  * return values :
00083  * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR
00084  * or a UPnP Error Code. */
00085 LIBSPEC int
00086 UPNP_GetLinkLayerMaxBitRates(const char* controlURL,
00087                                                         const char* servicetype,
00088                                                         unsigned int * bitrateDown,
00089                                                         unsigned int * bitrateUp);
00090 
00091 /* UPNP_AddPortMapping()
00092  * if desc is NULL, it will be defaulted to "libminiupnpc"
00093  * remoteHost is usually NULL because IGD don't support it.
00094  *
00095  * Return values :
00096  * 0 : SUCCESS
00097  * NON ZERO : ERROR. Either an UPnP error code or an unknown error.
00098  * 
00099  * List of possible UPnP errors for AddPortMapping :
00100  * errorCode errorDescription (short) - Description (long)
00101  * 402 Invalid Args - See UPnP Device Architecture section on Control.
00102  * 501 Action Failed - See UPnP Device Architecture section on Control.
00103  * 715 WildCardNotPermittedInSrcIP - The source IP address cannot be
00104  *                                   wild-carded
00105  * 716 WildCardNotPermittedInExtPort - The external port cannot be wild-carded
00106  * 718 ConflictInMappingEntry - The port mapping entry specified conflicts
00107  *                     with a mapping assigned previously to another client
00108  * 724 SamePortValuesRequired - Internal and External port values
00109  *                              must be the same 
00110  * 725 OnlyPermanentLeasesSupported - The NAT implementation only supports
00111  *                  permanent lease times on port mappings
00112  * 726 RemoteHostOnlySupportsWildcard - RemoteHost must be a wildcard
00113  *                             and cannot be a specific IP address or DNS name
00114  * 727 ExternalPortOnlySupportsWildcard - ExternalPort must be a wildcard and
00115  *                                        cannot be a specific port value */
00116 LIBSPEC int
00117 UPNP_AddPortMapping(const char * controlURL, const char * servicetype,
00118                     const char * extPort,
00119                                     const char * inPort,
00120                                         const char * inClient,
00121                                         const char * desc,
00122                     const char * proto,
00123                     const char * remoteHost,
00124                     const char * leaseDuration);
00125 
00126 /* UPNP_DeletePortMapping()
00127  * Use same argument values as what was used for AddPortMapping().
00128  * remoteHost is usually NULL because IGD don't support it.
00129  * Return Values :
00130  * 0 : SUCCESS
00131  * NON ZERO : error. Either an UPnP error code or an undefined error.
00132  *
00133  * List of possible UPnP errors for DeletePortMapping :
00134  * 402 Invalid Args - See UPnP Device Architecture section on Control.
00135  * 714 NoSuchEntryInArray - The specified value does not exist in the array */
00136 LIBSPEC int
00137 UPNP_DeletePortMapping(const char * controlURL, const char * servicetype,
00138                        const char * extPort, const char * proto,
00139                        const char * remoteHost);
00140 
00141 /* UPNP_GetPortMappingNumberOfEntries()
00142  * not supported by all routers */
00143 LIBSPEC int
00144 UPNP_GetPortMappingNumberOfEntries(const char* controlURL,
00145                                    const char* servicetype,
00146                                    unsigned int * num);
00147 
00148 /* UPNP_GetSpecificPortMappingEntry()
00149  *    retrieves an existing port mapping
00150  * params :
00151  *  in   extPort
00152  *  in   proto
00153  *  out  intClient (16 bytes)
00154  *  out  intPort (6 bytes)
00155  *  out  desc (80 bytes)
00156  *  out  enabled (4 bytes)
00157  *  out  leaseDuration (16 bytes)
00158  *
00159  * return value :
00160  * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR
00161  * or a UPnP Error Code. */
00162 LIBSPEC int
00163 UPNP_GetSpecificPortMappingEntry(const char * controlURL,
00164                                  const char * servicetype,
00165                                  const char * extPort,
00166                                  const char * proto,
00167                                  char * intClient,
00168                                  char * intPort,
00169                                  char * desc,
00170                                  char * enabled,
00171                                  char * leaseDuration);
00172 
00173 /* UPNP_GetGenericPortMappingEntry()
00174  * params :
00175  *  in   index
00176  *  out  extPort (6 bytes)
00177  *  out  intClient (16 bytes)
00178  *  out  intPort (6 bytes)
00179  *  out  protocol (4 bytes)
00180  *  out  desc (80 bytes)
00181  *  out  enabled (4 bytes)
00182  *  out  rHost (64 bytes)
00183  *  out  duration (16 bytes)
00184  *
00185  * return value :
00186  * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR
00187  * or a UPnP Error Code.
00188  *
00189  * Possible UPNP Error codes :
00190  * 402 Invalid Args - See UPnP Device Architecture section on Control.
00191  * 713 SpecifiedArrayIndexInvalid - The specified array index is out of bounds
00192  */
00193 LIBSPEC int
00194 UPNP_GetGenericPortMappingEntry(const char * controlURL,
00195                                 const char * servicetype,
00196                                                                 const char * index,
00197                                                                 char * extPort,
00198                                                                 char * intClient,
00199                                                                 char * intPort,
00200                                                                 char * protocol,
00201                                                                 char * desc,
00202                                                                 char * enabled,
00203                                                                 char * rHost,
00204                                                                 char * duration);
00205 
00206 /* UPNP_GetListOfPortMappings()      Available in IGD v2
00207  *
00208  *
00209  * Possible UPNP Error codes :
00210  * 606 Action not Authorized
00211  * 730 PortMappingNotFound - no port mapping is found in the specified range.
00212  * 733 InconsistantParameters - NewStartPort and NewEndPort values are not
00213  *                              consistent.
00214  */
00215 LIBSPEC int
00216 UPNP_GetListOfPortMappings(const char * controlURL,
00217                            const char * servicetype,
00218                            const char * startPort,
00219                            const char * endPort,
00220                            const char * protocol,
00221                            const char * numberOfPorts,
00222                            struct PortMappingParserData * data);
00223 
00224 /* IGD:2, functions for service WANIPv6FirewallControl:1 */ 
00225 LIBSPEC int
00226 UPNP_GetFirewallStatus(const char * controlURL,
00227                                 const char * servicetype,
00228                                 int * firewallEnabled, 
00229                                 int * inboundPinholeAllowed);
00230 
00231 LIBSPEC int
00232 UPNP_GetOutboundPinholeTimeout(const char * controlURL, const char * servicetype,
00233                     const char * remoteHost,
00234                     const char * remotePort,
00235                     const char * intClient,
00236                     const char * intPort,
00237                     const char * proto,
00238                     int * opTimeout);
00239 
00240 LIBSPEC int
00241 UPNP_AddPinhole(const char * controlURL, const char * servicetype,
00242                     const char * remoteHost,
00243                     const char * remotePort,
00244                     const char * intClient,
00245                     const char * intPort,
00246                     const char * proto,
00247                     const char * leaseTime,
00248                     char * uniqueID);
00249 
00250 LIBSPEC int
00251 UPNP_UpdatePinhole(const char * controlURL, const char * servicetype,
00252                     const char * uniqueID,
00253                     const char * leaseTime);
00254 
00255 LIBSPEC int
00256 UPNP_DeletePinhole(const char * controlURL, const char * servicetype, const char * uniqueID);
00257 
00258 LIBSPEC int
00259 UPNP_CheckPinholeWorking(const char * controlURL, const char * servicetype,
00260                                  const char * uniqueID, int * isWorking);
00261 
00262 LIBSPEC int
00263 UPNP_GetPinholePackets(const char * controlURL, const char * servicetype,
00264                                  const char * uniqueID, int * packets);
00265 
00266 #ifdef __cplusplus
00267 }
00268 #endif
00269 
00270 #endif
00271 
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends