/thirdparty/libportfwd/third-party/miniupnpc-1.6/upnpcommands.h

http://github.com/tomahawk-player/tomahawk · C Header · 271 lines · 129 code · 27 blank · 115 comment · 0 complexity · 37ae629f1622180b67fabaa001af9148 MD5 · raw file

  1. /* $Id: upnpcommands.h,v 1.23 2011/04/11 09:14:00 nanard Exp $ */
  2. /* Miniupnp project : http://miniupnp.free.fr/
  3. * Author : Thomas Bernard
  4. * Copyright (c) 2005-2011 Thomas Bernard
  5. * This software is subject to the conditions detailed in the
  6. * LICENCE file provided within this distribution */
  7. #ifndef __UPNPCOMMANDS_H__
  8. #define __UPNPCOMMANDS_H__
  9. #include "upnpreplyparse.h"
  10. #include "portlistingparse.h"
  11. #include "declspec.h"
  12. #include "miniupnpctypes.h"
  13. /* MiniUPnPc return codes : */
  14. #define UPNPCOMMAND_SUCCESS (0)
  15. #define UPNPCOMMAND_UNKNOWN_ERROR (-1)
  16. #define UPNPCOMMAND_INVALID_ARGS (-2)
  17. #define UPNPCOMMAND_HTTP_ERROR (-3)
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. LIBSPEC UNSIGNED_INTEGER
  22. UPNP_GetTotalBytesSent(const char * controlURL,
  23. const char * servicetype);
  24. LIBSPEC UNSIGNED_INTEGER
  25. UPNP_GetTotalBytesReceived(const char * controlURL,
  26. const char * servicetype);
  27. LIBSPEC UNSIGNED_INTEGER
  28. UPNP_GetTotalPacketsSent(const char * controlURL,
  29. const char * servicetype);
  30. LIBSPEC UNSIGNED_INTEGER
  31. UPNP_GetTotalPacketsReceived(const char * controlURL,
  32. const char * servicetype);
  33. /* UPNP_GetStatusInfo()
  34. * status and lastconnerror are 64 byte buffers
  35. * Return values :
  36. * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR
  37. * or a UPnP Error code */
  38. LIBSPEC int
  39. UPNP_GetStatusInfo(const char * controlURL,
  40. const char * servicetype,
  41. char * status,
  42. unsigned int * uptime,
  43. char * lastconnerror);
  44. /* UPNP_GetConnectionTypeInfo()
  45. * argument connectionType is a 64 character buffer
  46. * Return Values :
  47. * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR
  48. * or a UPnP Error code */
  49. LIBSPEC int
  50. UPNP_GetConnectionTypeInfo(const char * controlURL,
  51. const char * servicetype,
  52. char * connectionType);
  53. /* UPNP_GetExternalIPAddress() call the corresponding UPNP method.
  54. * if the third arg is not null the value is copied to it.
  55. * at least 16 bytes must be available
  56. *
  57. * Return values :
  58. * 0 : SUCCESS
  59. * NON ZERO : ERROR Either an UPnP error code or an unknown error.
  60. *
  61. * possible UPnP Errors :
  62. * 402 Invalid Args - See UPnP Device Architecture section on Control.
  63. * 501 Action Failed - See UPnP Device Architecture section on Control. */
  64. LIBSPEC int
  65. UPNP_GetExternalIPAddress(const char * controlURL,
  66. const char * servicetype,
  67. char * extIpAdd);
  68. /* UPNP_GetLinkLayerMaxBitRates()
  69. * call WANCommonInterfaceConfig:1#GetCommonLinkProperties
  70. *
  71. * return values :
  72. * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR
  73. * or a UPnP Error Code. */
  74. LIBSPEC int
  75. UPNP_GetLinkLayerMaxBitRates(const char* controlURL,
  76. const char* servicetype,
  77. unsigned int * bitrateDown,
  78. unsigned int * bitrateUp);
  79. /* UPNP_AddPortMapping()
  80. * if desc is NULL, it will be defaulted to "libminiupnpc"
  81. * remoteHost is usually NULL because IGD don't support it.
  82. *
  83. * Return values :
  84. * 0 : SUCCESS
  85. * NON ZERO : ERROR. Either an UPnP error code or an unknown error.
  86. *
  87. * List of possible UPnP errors for AddPortMapping :
  88. * errorCode errorDescription (short) - Description (long)
  89. * 402 Invalid Args - See UPnP Device Architecture section on Control.
  90. * 501 Action Failed - See UPnP Device Architecture section on Control.
  91. * 715 WildCardNotPermittedInSrcIP - The source IP address cannot be
  92. * wild-carded
  93. * 716 WildCardNotPermittedInExtPort - The external port cannot be wild-carded
  94. * 718 ConflictInMappingEntry - The port mapping entry specified conflicts
  95. * with a mapping assigned previously to another client
  96. * 724 SamePortValuesRequired - Internal and External port values
  97. * must be the same
  98. * 725 OnlyPermanentLeasesSupported - The NAT implementation only supports
  99. * permanent lease times on port mappings
  100. * 726 RemoteHostOnlySupportsWildcard - RemoteHost must be a wildcard
  101. * and cannot be a specific IP address or DNS name
  102. * 727 ExternalPortOnlySupportsWildcard - ExternalPort must be a wildcard and
  103. * cannot be a specific port value */
  104. LIBSPEC int
  105. UPNP_AddPortMapping(const char * controlURL, const char * servicetype,
  106. const char * extPort,
  107. const char * inPort,
  108. const char * inClient,
  109. const char * desc,
  110. const char * proto,
  111. const char * remoteHost,
  112. const char * leaseDuration);
  113. /* UPNP_DeletePortMapping()
  114. * Use same argument values as what was used for AddPortMapping().
  115. * remoteHost is usually NULL because IGD don't support it.
  116. * Return Values :
  117. * 0 : SUCCESS
  118. * NON ZERO : error. Either an UPnP error code or an undefined error.
  119. *
  120. * List of possible UPnP errors for DeletePortMapping :
  121. * 402 Invalid Args - See UPnP Device Architecture section on Control.
  122. * 714 NoSuchEntryInArray - The specified value does not exist in the array */
  123. LIBSPEC int
  124. UPNP_DeletePortMapping(const char * controlURL, const char * servicetype,
  125. const char * extPort, const char * proto,
  126. const char * remoteHost);
  127. /* UPNP_GetPortMappingNumberOfEntries()
  128. * not supported by all routers */
  129. LIBSPEC int
  130. UPNP_GetPortMappingNumberOfEntries(const char* controlURL,
  131. const char* servicetype,
  132. unsigned int * num);
  133. /* UPNP_GetSpecificPortMappingEntry()
  134. * retrieves an existing port mapping
  135. * params :
  136. * in extPort
  137. * in proto
  138. * out intClient (16 bytes)
  139. * out intPort (6 bytes)
  140. * out desc (80 bytes)
  141. * out enabled (4 bytes)
  142. * out leaseDuration (16 bytes)
  143. *
  144. * return value :
  145. * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR
  146. * or a UPnP Error Code. */
  147. LIBSPEC int
  148. UPNP_GetSpecificPortMappingEntry(const char * controlURL,
  149. const char * servicetype,
  150. const char * extPort,
  151. const char * proto,
  152. char * intClient,
  153. char * intPort,
  154. char * desc,
  155. char * enabled,
  156. char * leaseDuration);
  157. /* UPNP_GetGenericPortMappingEntry()
  158. * params :
  159. * in index
  160. * out extPort (6 bytes)
  161. * out intClient (16 bytes)
  162. * out intPort (6 bytes)
  163. * out protocol (4 bytes)
  164. * out desc (80 bytes)
  165. * out enabled (4 bytes)
  166. * out rHost (64 bytes)
  167. * out duration (16 bytes)
  168. *
  169. * return value :
  170. * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR
  171. * or a UPnP Error Code.
  172. *
  173. * Possible UPNP Error codes :
  174. * 402 Invalid Args - See UPnP Device Architecture section on Control.
  175. * 713 SpecifiedArrayIndexInvalid - The specified array index is out of bounds
  176. */
  177. LIBSPEC int
  178. UPNP_GetGenericPortMappingEntry(const char * controlURL,
  179. const char * servicetype,
  180. const char * index,
  181. char * extPort,
  182. char * intClient,
  183. char * intPort,
  184. char * protocol,
  185. char * desc,
  186. char * enabled,
  187. char * rHost,
  188. char * duration);
  189. /* UPNP_GetListOfPortMappings() Available in IGD v2
  190. *
  191. *
  192. * Possible UPNP Error codes :
  193. * 606 Action not Authorized
  194. * 730 PortMappingNotFound - no port mapping is found in the specified range.
  195. * 733 InconsistantParameters - NewStartPort and NewEndPort values are not
  196. * consistent.
  197. */
  198. LIBSPEC int
  199. UPNP_GetListOfPortMappings(const char * controlURL,
  200. const char * servicetype,
  201. const char * startPort,
  202. const char * endPort,
  203. const char * protocol,
  204. const char * numberOfPorts,
  205. struct PortMappingParserData * data);
  206. /* IGD:2, functions for service WANIPv6FirewallControl:1 */
  207. LIBSPEC int
  208. UPNP_GetFirewallStatus(const char * controlURL,
  209. const char * servicetype,
  210. int * firewallEnabled,
  211. int * inboundPinholeAllowed);
  212. LIBSPEC int
  213. UPNP_GetOutboundPinholeTimeout(const char * controlURL, const char * servicetype,
  214. const char * remoteHost,
  215. const char * remotePort,
  216. const char * intClient,
  217. const char * intPort,
  218. const char * proto,
  219. int * opTimeout);
  220. LIBSPEC int
  221. UPNP_AddPinhole(const char * controlURL, const char * servicetype,
  222. const char * remoteHost,
  223. const char * remotePort,
  224. const char * intClient,
  225. const char * intPort,
  226. const char * proto,
  227. const char * leaseTime,
  228. char * uniqueID);
  229. LIBSPEC int
  230. UPNP_UpdatePinhole(const char * controlURL, const char * servicetype,
  231. const char * uniqueID,
  232. const char * leaseTime);
  233. LIBSPEC int
  234. UPNP_DeletePinhole(const char * controlURL, const char * servicetype, const char * uniqueID);
  235. LIBSPEC int
  236. UPNP_CheckPinholeWorking(const char * controlURL, const char * servicetype,
  237. const char * uniqueID, int * isWorking);
  238. LIBSPEC int
  239. UPNP_GetPinholePackets(const char * controlURL, const char * servicetype,
  240. const char * uniqueID, int * packets);
  241. #ifdef __cplusplus
  242. }
  243. #endif
  244. #endif