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

http://github.com/tomahawk-player/tomahawk · C Header · 121 lines · 52 code · 18 blank · 51 comment · 0 complexity · be0df35da6d76cf29696ad8ee2d2247f MD5 · raw file

  1. /* $Id: miniupnpc.h,v 1.23 2011/04/11 08:21:46 nanard Exp $ */
  2. /* Project: miniupnp
  3. * http://miniupnp.free.fr/
  4. * Author: Thomas Bernard
  5. * Copyright (c) 2005-2011 Thomas Bernard
  6. * This software is subjects to the conditions detailed
  7. * in the LICENCE file provided within this distribution */
  8. #ifndef __MINIUPNPC_H__
  9. #define __MINIUPNPC_H__
  10. #include "declspec.h"
  11. #include "igd_desc_parse.h"
  12. /* error codes : */
  13. #define UPNPDISCOVER_SUCCESS (0)
  14. #define UPNPDISCOVER_UNKNOWN_ERROR (-1)
  15. #define UPNPDISCOVER_SOCKET_ERROR (-101)
  16. #define UPNPDISCOVER_MEMORY_ERROR (-102)
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. /* Structures definitions : */
  21. struct UPNParg { const char * elt; const char * val; };
  22. char *
  23. simpleUPnPcommand(int, const char *, const char *,
  24. const char *, struct UPNParg *,
  25. int *);
  26. struct UPNPDev {
  27. struct UPNPDev * pNext;
  28. char * descURL;
  29. char * st;
  30. char buffer[2];
  31. };
  32. /* upnpDiscover()
  33. * discover UPnP devices on the network.
  34. * The discovered devices are returned as a chained list.
  35. * It is up to the caller to free the list with freeUPNPDevlist().
  36. * delay (in millisecond) is the maximum time for waiting any device
  37. * response.
  38. * If available, device list will be obtained from MiniSSDPd.
  39. * Default path for minissdpd socket will be used if minissdpdsock argument
  40. * is NULL.
  41. * If multicastif is not NULL, it will be used instead of the default
  42. * multicast interface for sending SSDP discover packets.
  43. * If sameport is not null, SSDP packets will be sent from the source port
  44. * 1900 (same as destination port) otherwise system assign a source port. */
  45. LIBSPEC struct UPNPDev *
  46. upnpDiscover(int delay, const char * multicastif,
  47. const char * minissdpdsock, int sameport,
  48. int ipv6,
  49. int * error);
  50. /* freeUPNPDevlist()
  51. * free list returned by upnpDiscover() */
  52. LIBSPEC void freeUPNPDevlist(struct UPNPDev * devlist);
  53. /* parserootdesc() :
  54. * parse root XML description of a UPnP device and fill the IGDdatas
  55. * structure. */
  56. LIBSPEC void parserootdesc(const char *, int, struct IGDdatas *);
  57. /* structure used to get fast access to urls
  58. * controlURL: controlURL of the WANIPConnection
  59. * ipcondescURL: url of the description of the WANIPConnection
  60. * controlURL_CIF: controlURL of the WANCommonInterfaceConfig
  61. * controlURL_6FC: controlURL of the WANIPv6FirewallControl
  62. */
  63. struct UPNPUrls {
  64. char * controlURL;
  65. char * ipcondescURL;
  66. char * controlURL_CIF;
  67. char * controlURL_6FC;
  68. };
  69. /* UPNP_GetValidIGD() :
  70. * return values :
  71. * 0 = NO IGD found
  72. * 1 = A valid connected IGD has been found
  73. * 2 = A valid IGD has been found but it reported as
  74. * not connected
  75. * 3 = an UPnP device has been found but was not recognized as an IGD
  76. *
  77. * In any non zero return case, the urls and data structures
  78. * passed as parameters are set. Donc forget to call FreeUPNPUrls(urls) to
  79. * free allocated memory.
  80. */
  81. LIBSPEC int
  82. UPNP_GetValidIGD(struct UPNPDev * devlist,
  83. struct UPNPUrls * urls,
  84. struct IGDdatas * data,
  85. char * lanaddr, int lanaddrlen);
  86. /* UPNP_GetIGDFromUrl()
  87. * Used when skipping the discovery process.
  88. * return value :
  89. * 0 - Not ok
  90. * 1 - OK */
  91. LIBSPEC int
  92. UPNP_GetIGDFromUrl(const char * rootdescurl,
  93. struct UPNPUrls * urls,
  94. struct IGDdatas * data,
  95. char * lanaddr, int lanaddrlen);
  96. LIBSPEC void GetUPNPUrls(struct UPNPUrls *, struct IGDdatas *, const char *);
  97. LIBSPEC void FreeUPNPUrls(struct UPNPUrls *);
  98. /* return 0 or 1 */
  99. LIBSPEC int UPNPIGD_IsConnected(struct UPNPUrls *, struct IGDdatas *);
  100. #ifdef __cplusplus
  101. }
  102. #endif
  103. #endif