upnpcommands.h 13 KB

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