upnpcommands.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  1. /* $Id: upnpcommands.h,v 1.31 2015/07/21 13:16:55 nanard Exp $ */
  2. /* Miniupnp project : http://miniupnp.free.fr/
  3. * Author : Thomas Bernard
  4. * Copyright (c) 2005-2015 Thomas Bernard
  5. * This software is subject to the conditions detailed in the
  6. * LICENCE file provided within this distribution */
  7. #ifndef UPNPCOMMANDS_H_INCLUDED
  8. #define UPNPCOMMANDS_H_INCLUDED
  9. #include "upnpreplyparse.h"
  10. #include "portlistingparse.h"
  11. #include "miniupnpc_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. #define UPNPCOMMAND_INVALID_RESPONSE (-4)
  19. #define UPNPCOMMAND_MEM_ALLOC_ERROR (-5)
  20. #ifdef __cplusplus
  21. extern "C" {
  22. #endif
  23. MINIUPNP_LIBSPEC UNSIGNED_INTEGER
  24. UPNP_GetTotalBytesSent(const char * controlURL,
  25. const char * servicetype);
  26. MINIUPNP_LIBSPEC UNSIGNED_INTEGER
  27. UPNP_GetTotalBytesReceived(const char * controlURL,
  28. const char * servicetype);
  29. MINIUPNP_LIBSPEC UNSIGNED_INTEGER
  30. UPNP_GetTotalPacketsSent(const char * controlURL,
  31. const char * servicetype);
  32. MINIUPNP_LIBSPEC UNSIGNED_INTEGER
  33. UPNP_GetTotalPacketsReceived(const char * controlURL,
  34. const char * servicetype);
  35. /* UPNP_GetStatusInfo()
  36. * status and lastconnerror are 64 byte buffers
  37. * Return values :
  38. * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR
  39. * or a UPnP Error code */
  40. MINIUPNP_LIBSPEC int
  41. UPNP_GetStatusInfo(const char * controlURL,
  42. const char * servicetype,
  43. char * status,
  44. unsigned int * uptime,
  45. char * lastconnerror);
  46. /* UPNP_GetConnectionTypeInfo()
  47. * argument connectionType is a 64 character buffer
  48. * Return Values :
  49. * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR
  50. * or a UPnP Error code */
  51. MINIUPNP_LIBSPEC int
  52. UPNP_GetConnectionTypeInfo(const char * controlURL,
  53. const char * servicetype,
  54. char * connectionType);
  55. /* UPNP_GetExternalIPAddress() call the corresponding UPNP method.
  56. * if the third arg is not null the value is copied to it.
  57. * at least 16 bytes must be available
  58. *
  59. * Return values :
  60. * 0 : SUCCESS
  61. * NON ZERO : ERROR Either an UPnP error code or an unknown error.
  62. *
  63. * possible UPnP Errors :
  64. * 402 Invalid Args - See UPnP Device Architecture section on Control.
  65. * 501 Action Failed - See UPnP Device Architecture section on Control. */
  66. MINIUPNP_LIBSPEC int
  67. UPNP_GetExternalIPAddress(const char * controlURL,
  68. const char * servicetype,
  69. char * extIpAdd);
  70. /* UPNP_GetLinkLayerMaxBitRates()
  71. * call WANCommonInterfaceConfig:1#GetCommonLinkProperties
  72. *
  73. * return values :
  74. * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR
  75. * or a UPnP Error Code. */
  76. MINIUPNP_LIBSPEC int
  77. UPNP_GetLinkLayerMaxBitRates(const char* controlURL,
  78. const char* servicetype,
  79. unsigned int * bitrateDown,
  80. unsigned int * bitrateUp);
  81. /* UPNP_AddPortMapping()
  82. * if desc is NULL, it will be defaulted to "libminiupnpc"
  83. * remoteHost is usually NULL because IGD don't support it.
  84. *
  85. * Return values :
  86. * 0 : SUCCESS
  87. * NON ZERO : ERROR. Either an UPnP error code or an unknown error.
  88. *
  89. * List of possible UPnP errors for AddPortMapping :
  90. * errorCode errorDescription (short) - Description (long)
  91. * 402 Invalid Args - See UPnP Device Architecture section on Control.
  92. * 501 Action Failed - See UPnP Device Architecture section on Control.
  93. * 606 Action not authorized - The action requested REQUIRES authorization and
  94. * the sender was not authorized.
  95. * 715 WildCardNotPermittedInSrcIP - The source IP address cannot be
  96. * wild-carded
  97. * 716 WildCardNotPermittedInExtPort - The external port cannot be wild-carded
  98. * 718 ConflictInMappingEntry - The port mapping entry specified conflicts
  99. * with a mapping assigned previously to another client
  100. * 724 SamePortValuesRequired - Internal and External port values
  101. * must be the same
  102. * 725 OnlyPermanentLeasesSupported - The NAT implementation only supports
  103. * permanent lease times on port mappings
  104. * 726 RemoteHostOnlySupportsWildcard - RemoteHost must be a wildcard
  105. * and cannot be a specific IP address or DNS name
  106. * 727 ExternalPortOnlySupportsWildcard - ExternalPort must be a wildcard and
  107. * cannot be a specific port value
  108. * 728 NoPortMapsAvailable - There are not enough free ports available to
  109. * complete port mapping.
  110. * 729 ConflictWithOtherMechanisms - Attempted port mapping is not allowed
  111. * due to conflict with other mechanisms.
  112. * 732 WildCardNotPermittedInIntPort - The internal port cannot be wild-carded
  113. */
  114. MINIUPNP_LIBSPEC int
  115. UPNP_AddPortMapping(const char * controlURL, const char * servicetype,
  116. const char * extPort,
  117. const char * inPort,
  118. const char * inClient,
  119. const char * desc,
  120. const char * proto,
  121. const char * remoteHost,
  122. const char * leaseDuration);
  123. /* UPNP_AddAnyPortMapping()
  124. * if desc is NULL, it will be defaulted to "libminiupnpc"
  125. * remoteHost is usually NULL because IGD don't support it.
  126. *
  127. * Return values :
  128. * 0 : SUCCESS
  129. * NON ZERO : ERROR. Either an UPnP error code or an unknown error.
  130. *
  131. * List of possible UPnP errors for AddPortMapping :
  132. * errorCode errorDescription (short) - Description (long)
  133. * 402 Invalid Args - See UPnP Device Architecture section on Control.
  134. * 501 Action Failed - See UPnP Device Architecture section on Control.
  135. * 606 Action not authorized - The action requested REQUIRES authorization and
  136. * the sender was not authorized.
  137. * 715 WildCardNotPermittedInSrcIP - The source IP address cannot be
  138. * wild-carded
  139. * 716 WildCardNotPermittedInExtPort - The external port cannot be wild-carded
  140. * 728 NoPortMapsAvailable - There are not enough free ports available to
  141. * complete port mapping.
  142. * 729 ConflictWithOtherMechanisms - Attempted port mapping is not allowed
  143. * due to conflict with other mechanisms.
  144. * 732 WildCardNotPermittedInIntPort - The internal port cannot be wild-carded
  145. */
  146. MINIUPNP_LIBSPEC int
  147. UPNP_AddAnyPortMapping(const char * controlURL, const char * servicetype,
  148. const char * extPort,
  149. const char * inPort,
  150. const char * inClient,
  151. const char * desc,
  152. const char * proto,
  153. const char * remoteHost,
  154. const char * leaseDuration,
  155. char * reservedPort);
  156. /* UPNP_DeletePortMapping()
  157. * Use same argument values as what was used for AddPortMapping().
  158. * remoteHost is usually NULL because IGD don't support it.
  159. * Return Values :
  160. * 0 : SUCCESS
  161. * NON ZERO : error. Either an UPnP error code or an undefined error.
  162. *
  163. * List of possible UPnP errors for DeletePortMapping :
  164. * 402 Invalid Args - See UPnP Device Architecture section on Control.
  165. * 606 Action not authorized - The action requested REQUIRES authorization
  166. * and the sender was not authorized.
  167. * 714 NoSuchEntryInArray - The specified value does not exist in the array */
  168. MINIUPNP_LIBSPEC int
  169. UPNP_DeletePortMapping(const char * controlURL, const char * servicetype,
  170. const char * extPort, const char * proto,
  171. const char * remoteHost);
  172. /* UPNP_DeletePortRangeMapping()
  173. * Use same argument values as what was used for AddPortMapping().
  174. * remoteHost is usually NULL because IGD don't support it.
  175. * Return Values :
  176. * 0 : SUCCESS
  177. * NON ZERO : error. Either an UPnP error code or an undefined error.
  178. *
  179. * List of possible UPnP errors for DeletePortMapping :
  180. * 606 Action not authorized - The action requested REQUIRES authorization
  181. * and the sender was not authorized.
  182. * 730 PortMappingNotFound - This error message is returned if no port
  183. * mapping is found in the specified range.
  184. * 733 InconsistentParameters - NewStartPort and NewEndPort values are not consistent. */
  185. MINIUPNP_LIBSPEC int
  186. UPNP_DeletePortMappingRange(const char * controlURL, const char * servicetype,
  187. const char * extPortStart, const char * extPortEnd,
  188. const char * proto,
  189. const char * manage);
  190. /* UPNP_GetPortMappingNumberOfEntries()
  191. * not supported by all routers */
  192. MINIUPNP_LIBSPEC int
  193. UPNP_GetPortMappingNumberOfEntries(const char* controlURL,
  194. const char* servicetype,
  195. unsigned int * num);
  196. /* UPNP_GetSpecificPortMappingEntry()
  197. * retrieves an existing port mapping
  198. * params :
  199. * in extPort
  200. * in proto
  201. * in remoteHost
  202. * out intClient (16 bytes)
  203. * out intPort (6 bytes)
  204. * out desc (80 bytes)
  205. * out enabled (4 bytes)
  206. * out leaseDuration (16 bytes)
  207. *
  208. * return value :
  209. * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR
  210. * or a UPnP Error Code.
  211. *
  212. * List of possible UPnP errors for _GetSpecificPortMappingEntry :
  213. * 402 Invalid Args - See UPnP Device Architecture section on Control.
  214. * 501 Action Failed - See UPnP Device Architecture section on Control.
  215. * 606 Action not authorized - The action requested REQUIRES authorization
  216. * and the sender was not authorized.
  217. * 714 NoSuchEntryInArray - The specified value does not exist in the array.
  218. */
  219. MINIUPNP_LIBSPEC int
  220. UPNP_GetSpecificPortMappingEntry(const char * controlURL,
  221. const char * servicetype,
  222. const char * extPort,
  223. const char * proto,
  224. const char * remoteHost,
  225. char * intClient,
  226. char * intPort,
  227. char * desc,
  228. char * enabled,
  229. char * leaseDuration);
  230. /* UPNP_GetGenericPortMappingEntry()
  231. * params :
  232. * in index
  233. * out extPort (6 bytes)
  234. * out intClient (16 bytes)
  235. * out intPort (6 bytes)
  236. * out protocol (4 bytes)
  237. * out desc (80 bytes)
  238. * out enabled (4 bytes)
  239. * out rHost (64 bytes)
  240. * out duration (16 bytes)
  241. *
  242. * return value :
  243. * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR
  244. * or a UPnP Error Code.
  245. *
  246. * Possible UPNP Error codes :
  247. * 402 Invalid Args - See UPnP Device Architecture section on Control.
  248. * 606 Action not authorized - The action requested REQUIRES authorization
  249. * and the sender was not authorized.
  250. * 713 SpecifiedArrayIndexInvalid - The specified array index is out of bounds
  251. */
  252. MINIUPNP_LIBSPEC int
  253. UPNP_GetGenericPortMappingEntry(const char * controlURL,
  254. const char * servicetype,
  255. const char * index,
  256. char * extPort,
  257. char * intClient,
  258. char * intPort,
  259. char * protocol,
  260. char * desc,
  261. char * enabled,
  262. char * rHost,
  263. char * duration);
  264. /* UPNP_GetListOfPortMappings() Available in IGD v2
  265. *
  266. *
  267. * Possible UPNP Error codes :
  268. * 606 Action not Authorized
  269. * 730 PortMappingNotFound - no port mapping is found in the specified range.
  270. * 733 InconsistantParameters - NewStartPort and NewEndPort values are not
  271. * consistent.
  272. */
  273. MINIUPNP_LIBSPEC int
  274. UPNP_GetListOfPortMappings(const char * controlURL,
  275. const char * servicetype,
  276. const char * startPort,
  277. const char * endPort,
  278. const char * protocol,
  279. const char * numberOfPorts,
  280. struct PortMappingParserData * data);
  281. /* IGD:2, functions for service WANIPv6FirewallControl:1 */
  282. MINIUPNP_LIBSPEC int
  283. UPNP_GetFirewallStatus(const char * controlURL,
  284. const char * servicetype,
  285. int * firewallEnabled,
  286. int * inboundPinholeAllowed);
  287. MINIUPNP_LIBSPEC int
  288. UPNP_GetOutboundPinholeTimeout(const char * controlURL, const char * servicetype,
  289. const char * remoteHost,
  290. const char * remotePort,
  291. const char * intClient,
  292. const char * intPort,
  293. const char * proto,
  294. int * opTimeout);
  295. MINIUPNP_LIBSPEC int
  296. UPNP_AddPinhole(const char * controlURL, const char * servicetype,
  297. const char * remoteHost,
  298. const char * remotePort,
  299. const char * intClient,
  300. const char * intPort,
  301. const char * proto,
  302. const char * leaseTime,
  303. char * uniqueID);
  304. MINIUPNP_LIBSPEC int
  305. UPNP_UpdatePinhole(const char * controlURL, const char * servicetype,
  306. const char * uniqueID,
  307. const char * leaseTime);
  308. MINIUPNP_LIBSPEC int
  309. UPNP_DeletePinhole(const char * controlURL, const char * servicetype, const char * uniqueID);
  310. MINIUPNP_LIBSPEC int
  311. UPNP_CheckPinholeWorking(const char * controlURL, const char * servicetype,
  312. const char * uniqueID, int * isWorking);
  313. MINIUPNP_LIBSPEC int
  314. UPNP_GetPinholePackets(const char * controlURL, const char * servicetype,
  315. const char * uniqueID, int * packets);
  316. #ifdef __cplusplus
  317. }
  318. #endif
  319. #endif