2
0

upnpcommands.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /* $Id: upnpcommands.h,v 1.17 2009/04/17 21:21:19 nanard Exp $ */
  2. /* Miniupnp project : http://miniupnp.free.fr/
  3. * Author : Thomas Bernard
  4. * Copyright (c) 2005-2008 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 "declspec.h"
  11. /* MiniUPnPc return codes : */
  12. #define UPNPCOMMAND_SUCCESS (0)
  13. #define UPNPCOMMAND_UNKNOWN_ERROR (-1)
  14. #define UPNPCOMMAND_INVALID_ARGS (-2)
  15. #ifdef __cplusplus
  16. extern "C" {
  17. #endif
  18. #if (defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L)
  19. #define UNSIGNED_INTEGER unsigned long long
  20. #define STRTOUI strtoull
  21. #else
  22. #define UNSIGNED_INTEGER unsigned int
  23. #define STRTOUI strtoul
  24. #endif
  25. LIBSPEC UNSIGNED_INTEGER
  26. UPNP_GetTotalBytesSent(const char * controlURL,
  27. const char * servicetype);
  28. LIBSPEC UNSIGNED_INTEGER
  29. UPNP_GetTotalBytesReceived(const char * controlURL,
  30. const char * servicetype);
  31. LIBSPEC UNSIGNED_INTEGER
  32. UPNP_GetTotalPacketsSent(const char * controlURL,
  33. const char * servicetype);
  34. LIBSPEC UNSIGNED_INTEGER
  35. UPNP_GetTotalPacketsReceived(const char * controlURL,
  36. const char * servicetype);
  37. /* UPNP_GetStatusInfo()
  38. * status and lastconnerror are 64 byte buffers
  39. * Return values :
  40. * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR
  41. * or a UPnP Error code */
  42. LIBSPEC int
  43. UPNP_GetStatusInfo(const char * controlURL,
  44. const char * servicetype,
  45. char * status,
  46. unsigned int * uptime,
  47. char * lastconnerror);
  48. /* UPNP_GetConnectionTypeInfo()
  49. * argument connectionType is a 64 character buffer
  50. * Return Values :
  51. * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR
  52. * or a UPnP Error code */
  53. LIBSPEC int
  54. UPNP_GetConnectionTypeInfo(const char * controlURL,
  55. const char * servicetype,
  56. char * connectionType);
  57. /* UPNP_GetExternalIPAddress() call the corresponding UPNP method.
  58. * if the third arg is not null the value is copied to it.
  59. * at least 16 bytes must be available
  60. *
  61. * Return values :
  62. * 0 : SUCCESS
  63. * NON ZERO : ERROR Either an UPnP error code or an unknown error.
  64. *
  65. * possible UPnP Errors :
  66. * 402 Invalid Args - See UPnP Device Architecture section on Control.
  67. * 501 Action Failed - See UPnP Device Architecture section on Control. */
  68. LIBSPEC int
  69. UPNP_GetExternalIPAddress(const char * controlURL,
  70. const char * servicetype,
  71. char * extIpAdd);
  72. /* UPNP_GetLinkLayerMaxBitRates()
  73. * call WANCommonInterfaceConfig:1#GetCommonLinkProperties
  74. *
  75. * return values :
  76. * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR
  77. * or a UPnP Error Code. */
  78. LIBSPEC int
  79. UPNP_GetLinkLayerMaxBitRates(const char* controlURL,
  80. const char* servicetype,
  81. unsigned int * bitrateDown,
  82. unsigned int * bitrateUp);
  83. /* UPNP_AddPortMapping()
  84. * if desc is NULL, it will be defaulted to "libminiupnpc"
  85. * remoteHost is usually NULL because IGD don't support it.
  86. *
  87. * Return values :
  88. * 0 : SUCCESS
  89. * NON ZERO : ERROR. Either an UPnP error code or an unknown error.
  90. *
  91. * List of possible UPnP errors for AddPortMapping :
  92. * errorCode errorDescription (short) - Description (long)
  93. * 402 Invalid Args - See UPnP Device Architecture section on Control.
  94. * 501 Action Failed - See UPnP Device Architecture section on Control.
  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. LIBSPEC int
  109. UPNP_AddPortMapping(const char * controlURL, const char * servicetype,
  110. const char * extPort,
  111. const char * inPort,
  112. const char * inClient,
  113. const char * desc,
  114. const char * proto,
  115. const char * remoteHost);
  116. /* UPNP_DeletePortMapping()
  117. * Use same argument values as what was used for AddPortMapping().
  118. * remoteHost is usually NULL because IGD don't support it.
  119. * Return Values :
  120. * 0 : SUCCESS
  121. * NON ZERO : error. Either an UPnP error code or an undefined error.
  122. *
  123. * List of possible UPnP errors for DeletePortMapping :
  124. * 402 Invalid Args - See UPnP Device Architecture section on Control.
  125. * 714 NoSuchEntryInArray - The specified value does not exist in the array */
  126. LIBSPEC int
  127. UPNP_DeletePortMapping(const char * controlURL, const char * servicetype,
  128. const char * extPort, const char * proto,
  129. const char * remoteHost);
  130. /* UPNP_GetPortMappingNumberOfEntries()
  131. * not supported by all routers */
  132. LIBSPEC int
  133. UPNP_GetPortMappingNumberOfEntries(const char* controlURL, const char* servicetype, unsigned int * num);
  134. /* UPNP_GetSpecificPortMappingEntry retrieves an existing port mapping
  135. * the result is returned in the intClient and intPort strings
  136. * please provide 16 and 6 bytes of data
  137. *
  138. * return value :
  139. * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR
  140. * or a UPnP Error Code. */
  141. LIBSPEC int
  142. UPNP_GetSpecificPortMappingEntry(const char * controlURL,
  143. const char * servicetype,
  144. const char * extPort,
  145. const char * proto,
  146. char * intClient,
  147. char * intPort);
  148. /* UPNP_GetGenericPortMappingEntry()
  149. *
  150. * return value :
  151. * UPNPCOMMAND_SUCCESS, UPNPCOMMAND_INVALID_ARGS, UPNPCOMMAND_UNKNOWN_ERROR
  152. * or a UPnP Error Code.
  153. *
  154. * Possible UPNP Error codes :
  155. * 402 Invalid Args - See UPnP Device Architecture section on Control.
  156. * 713 SpecifiedArrayIndexInvalid - The specified array index is out of bounds
  157. */
  158. LIBSPEC int
  159. UPNP_GetGenericPortMappingEntry(const char * controlURL,
  160. const char * servicetype,
  161. const char * index,
  162. char * extPort,
  163. char * intClient,
  164. char * intPort,
  165. char * protocol,
  166. char * desc,
  167. char * enabled,
  168. char * rHost,
  169. char * duration);
  170. #ifdef __cplusplus
  171. }
  172. #endif
  173. #endif