miniserver.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. #ifndef MINISERVER_H
  2. #define MINISERVER_H
  3. /**************************************************************************
  4. *
  5. * Copyright (c) 2000-2003 Intel Corporation
  6. * All rights reserved.
  7. *
  8. * Redistribution and use in source and binary forms, with or without
  9. * modification, are permitted provided that the following conditions are met:
  10. *
  11. * - Redistributions of source code must retain the above copyright notice,
  12. * this list of conditions and the following disclaimer.
  13. * - Redistributions in binary form must reproduce the above copyright notice,
  14. * this list of conditions and the following disclaimer in the documentation
  15. * and/or other materials provided with the distribution.
  16. * - Neither name of Intel Corporation nor the names of its contributors
  17. * may be used to endorse or promote products derived from this software
  18. * without specific prior written permission.
  19. *
  20. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  21. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  22. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  23. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
  24. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  25. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  26. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  27. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  28. * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  29. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  30. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  31. *
  32. **************************************************************************/
  33. /*!
  34. * \file
  35. */
  36. #include "sock.h"
  37. #include "httpparser.h"
  38. #include "UpnpStdInt.h"
  39. extern SOCKET gMiniServerStopSock;
  40. typedef struct MServerSockArray {
  41. /*! IPv4 socket for listening for miniserver requests. */
  42. SOCKET miniServerSock4;
  43. /*! IPv6 Socket for listening for miniserver requests. */
  44. SOCKET miniServerSock6;
  45. /*! Socket for stopping miniserver */
  46. SOCKET miniServerStopSock;
  47. /*! IPv4 SSDP Socket for incoming advertisments and search requests. */
  48. SOCKET ssdpSock4;
  49. /*! IPv6 SSDP Socket for incoming advertisments and search requests. */
  50. SOCKET ssdpSock6;
  51. /*! IPv6 SSDP Socket for incoming advertisments and search requests. */
  52. SOCKET ssdpSock6UlaGua;
  53. /* ! . */
  54. uint16_t stopPort;
  55. /* ! . */
  56. uint16_t miniServerPort4;
  57. /* ! . */
  58. uint16_t miniServerPort6;
  59. #ifdef INCLUDE_CLIENT_APIS
  60. /*! IPv4 SSDP socket for sending search requests and receiving search
  61. * replies */
  62. SOCKET ssdpReqSock4;
  63. /*! IPv6 SSDP socket for sending search requests and receiving search
  64. * replies */
  65. SOCKET ssdpReqSock6;
  66. #endif /* INCLUDE_CLIENT_APIS */
  67. } MiniServerSockArray;
  68. /*! . */
  69. typedef void (*MiniServerCallback) (
  70. /* ! . */
  71. IN http_parser_t * parser,
  72. /* ! . */
  73. IN http_message_t * request,
  74. /* ! . */
  75. IN SOCKINFO * info);
  76. #ifdef __cplusplus
  77. extern "C" {
  78. #endif
  79. /*!
  80. * \brief Set HTTP Get Callback.
  81. */
  82. void SetHTTPGetCallback(
  83. /*! [in] HTTP Callback to be invoked . */
  84. MiniServerCallback callback);
  85. /*!
  86. * \brief Set SOAP Callback.
  87. */
  88. #ifdef INCLUDE_DEVICE_APIS
  89. void SetSoapCallback(
  90. /*! [in] SOAP Callback to be invoked . */
  91. MiniServerCallback callback);
  92. #else /* INCLUDE_DEVICE_APIS */
  93. static UPNP_INLINE void SetSoapCallback(MiniServerCallback callback) {}
  94. #endif /* INCLUDE_DEVICE_APIS */
  95. /*!
  96. * \brief Set GENA Callback.
  97. */
  98. void SetGenaCallback(
  99. /*! [in] GENA Callback to be invoked. */
  100. MiniServerCallback callback);
  101. /*!
  102. * \brief Initialize the sockets functionality for the Miniserver.
  103. *
  104. * Initialize a thread pool job to run the MiniServer and the job to the
  105. * thread pool.
  106. *
  107. * If listen port is 0, port is dynamically picked.
  108. *
  109. * Use timer mechanism to start the MiniServer, failure to meet the
  110. * allowed delay aborts the attempt to launch the MiniServer.
  111. *
  112. * \return
  113. * \li On success: UPNP_E_SUCCESS.
  114. * \li On error: UPNP_E_XXX.
  115. */
  116. int StartMiniServer(
  117. /*! [in,out] Port on which the server listens for incoming IPv4
  118. * connections. */
  119. uint16_t *listen_port4,
  120. /*! [in,out] Port on which the server listens for incoming IPv6
  121. * connections. */
  122. uint16_t *listen_port6);
  123. /*!
  124. * \brief Stop and Shutdown the MiniServer and free socket resources.
  125. *
  126. * \return Always returns 0.
  127. */
  128. int StopMiniServer();
  129. #ifdef __cplusplus
  130. } /* extern C */
  131. #endif
  132. #endif /* MINISERVER_H */