00001 /* $Id: upnpcommands.h,v 1.13 2008/02/18 13:27:24 nanard Exp $ */ 00002 /* Miniupnp project : http://miniupnp.free.fr/ 00003 * Author : Thomas Bernard 00004 * Copyright (c) 2005-2006 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 "declspec.h" 00012 00013 /* MiniUPnPc return codes : */ 00014 #define UPNPCOMMAND_SUCCESS (0) 00015 #define UPNPCOMMAND_UNKNOWN_ERROR (-1) 00016 #define UPNPCOMMAND_INVALID_ARGS (-2) 00017 00018 #ifdef __cplusplus 00019 extern "C" { 00020 #endif 00021 00022 LIBSPEC unsigned int 00023 UPNP_GetTotalBytesSent(const char * controlURL, 00024 const char * servicetype); 00025 00026 LIBSPEC unsigned int 00027 UPNP_GetTotalBytesReceived(const char * controlURL, 00028 const char * servicetype); 00029 00030 LIBSPEC unsigned int 00031 UPNP_GetTotalPacketsSent(const char * controlURL, 00032 const char * servicetype); 00033 00034 LIBSPEC unsigned int 00035 UPNP_GetTotalPacketsReceived(const char * controlURL, 00036 const char * servicetype); 00037 00038 /* UPNP_GetStatusInfo() 00039 * status and lastconnerror are 64 byte buffers 00040 * Return values : 00041 * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR 00042 * or a UPnP Error code */ 00043 LIBSPEC int 00044 UPNP_GetStatusInfo(const char * controlURL, 00045 const char * servicetype, 00046 char * status, 00047 unsigned int * uptime, 00048 char * lastconnerror); 00049 00050 /* UPNP_GetConnectionTypeInfo() 00051 * argument connectionType is a 64 character buffer 00052 * Return Values : 00053 * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR 00054 * or a UPnP Error code */ 00055 LIBSPEC int 00056 UPNP_GetConnectionTypeInfo(const char * controlURL, 00057 const char * servicetype, 00058 char * connectionType); 00059 00060 /* UPNP_GetExternalIPAddress() call the corresponding UPNP method. 00061 * if the third arg is not null the value is copied to it. 00062 * at least 16 bytes must be available 00063 * 00064 * Return values : 00065 * 0 : SUCCESS 00066 * NON ZERO : ERROR Either an UPnP error code or an unknown error. 00067 * 00068 * possible UPnP Errors : 00069 * 402 Invalid Args - See UPnP Device Architecture section on Control. 00070 * 501 Action Failed - See UPnP Device Architecture section on Control. */ 00071 LIBSPEC int 00072 UPNP_GetExternalIPAddress(const char * controlURL, 00073 const char * servicetype, 00074 char * extIpAdd); 00075 00076 /* UPNP_GetLinkLayerMaxBitRates() 00077 * call WANCommonInterfaceConfig:1#GetCommonLinkProperties 00078 * 00079 * return values : 00080 * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR 00081 * or a UPnP Error Code. */ 00082 LIBSPEC int 00083 UPNP_GetLinkLayerMaxBitRates(const char* controlURL, 00084 const char* servicetype, 00085 unsigned int * bitrateDown, 00086 unsigned int * bitrateUp); 00087 00088 /* UPNP_AddPortMapping() 00089 * 00090 * Return values : 00091 * 0 : SUCCESS 00092 * NON ZERO : ERROR. Either an UPnP error code or an unknown error. 00093 * 00094 * List of possible UPnP errors for AddPortMapping : 00095 * errorCode errorDescription (short) - Description (long) 00096 * 402 Invalid Args - See UPnP Device Architecture section on Control. 00097 * 501 Action Failed - See UPnP Device Architecture section on Control. 00098 * 715 WildCardNotPermittedInSrcIP - The source IP address cannot be 00099 * wild-carded 00100 * 716 WildCardNotPermittedInExtPort - The external port cannot be wild-carded 00101 * 718 ConflictInMappingEntry - The port mapping entry specified conflicts 00102 * with a mapping assigned previously to another client 00103 * 724 SamePortValuesRequired - Internal and External port values 00104 * must be the same 00105 * 725 OnlyPermanentLeasesSupported - The NAT implementation only supports 00106 * permanent lease times on port mappings 00107 * 726 RemoteHostOnlySupportsWildcard - RemoteHost must be a wildcard 00108 * and cannot be a specific IP address or DNS name 00109 * 727 ExternalPortOnlySupportsWildcard - ExternalPort must be a wildcard and 00110 * cannot be a specific port value */ 00111 LIBSPEC int 00112 UPNP_AddPortMapping(const char * controlURL, const char * servicetype, 00113 const char * extPort, 00114 const char * inPort, 00115 const char * inClient, 00116 const char * desc, 00117 const char * proto); 00118 00119 /* UPNP_DeletePortMapping() 00120 * Return Values : 00121 * 0 : SUCCESS 00122 * NON ZERO : error. Either an UPnP error code or an undefined error. 00123 * 00124 * List of possible UPnP errors for DeletePortMapping : 00125 * 402 Invalid Args - See UPnP Device Architecture section on Control. 00126 * 714 NoSuchEntryInArray - The specified value does not exist in the array */ 00127 LIBSPEC int 00128 UPNP_DeletePortMapping(const char * controlURL, const char * servicetype, 00129 const char * extPort, const char * proto); 00130 00131 /* UPNP_GetPortMappingNumberOfEntries() 00132 * not supported by all routers */ 00133 LIBSPEC int 00134 UPNP_GetPortMappingNumberOfEntries(const char* controlURL, const char* servicetype, unsigned int * num); 00135 00136 /* UPNP_GetSpecificPortMappingEntry retrieves an existing port mapping 00137 * the result is returned in the intClient and intPort strings 00138 * please provide 16 and 6 bytes of data 00139 * 00140 * return value : 00141 * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR 00142 * or a UPnP Error Code. */ 00143 LIBSPEC int 00144 UPNP_GetSpecificPortMappingEntry(const char * controlURL, 00145 const char * servicetype, 00146 const char * extPort, 00147 const char * proto, 00148 char * intClient, 00149 char * intPort); 00150 00151 /* UPNP_GetGenericPortMappingEntry() 00152 * 00153 * return value : 00154 * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR 00155 * or a UPnP Error Code. 00156 * 00157 * Possible UPNP Error codes : 00158 * 402 Invalid Args - See UPnP Device Architecture section on Control. 00159 * 713 SpecifiedArrayIndexInvalid - The specified array index is out of bounds 00160 */ 00161 LIBSPEC int 00162 UPNP_GetGenericPortMappingEntry(const char * controlURL, 00163 const char * servicetype, 00164 const char * index, 00165 char * extPort, 00166 char * intClient, 00167 char * intPort, 00168 char * protocol, 00169 char * desc, 00170 char * enabled, 00171 char * rHost, 00172 char * duration); 00173 00174 #ifdef __cplusplus 00175 } 00176 #endif 00177 00178 #endif 00179