config.h 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  1. /**************************************************************************
  2. *
  3. * Copyright (c) 2000-2003 Intel Corporation
  4. * All rights reserved.
  5. * Copyright (c) 2012 France Telecom All rights reserved.
  6. *
  7. * Redistribution and use in source and binary forms, with or without
  8. * modification, are permitted provided that the following conditions are met:
  9. *
  10. * - Redistributions of source code must retain the above copyright notice,
  11. * this list of conditions and the following disclaimer.
  12. * - Redistributions in binary form must reproduce the above copyright notice,
  13. * this list of conditions and the following disclaimer in the documentation
  14. * and/or other materials provided with the distribution.
  15. * - Neither name of Intel Corporation nor the names of its contributors
  16. * may be used to endorse or promote products derived from this software
  17. * without specific prior written permission.
  18. *
  19. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  20. * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  21. * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  22. * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL INTEL OR
  23. * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  24. * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  25. * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  26. * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  27. * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  28. * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  29. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  30. *
  31. **************************************************************************/
  32. #ifndef INTERNAL_CONFIG_H
  33. #define INTERNAL_CONFIG_H
  34. #include "autoconfig.h"
  35. /*!
  36. * \name Compile time configuration options
  37. *
  38. * The Linux SDK for UPnP Devices contains some compile-time parameters
  39. * that effect the behavior of the SDK. All configuration options are
  40. * located in {\tt src/inc/config.h}.
  41. *
  42. * @{
  43. */
  44. /*!
  45. * \name THREAD_IDLE_TIME
  46. *
  47. * The {\tt THREAD_IDLE_TIME} constant determines when a thread will be
  48. * removed from the thread pool and returned to the operating system. When
  49. * a thread in the thread pool has been idle for this number of milliseconds
  50. * the thread will be released from the thread pool. The default value is
  51. * 5000 milliseconds (5 seconds).
  52. *
  53. * @{
  54. */
  55. #define THREAD_IDLE_TIME 5000
  56. /* @} */
  57. /*!
  58. * \name JOBS_PER_THREAD
  59. *
  60. * The {\tt JOBS_PER_THREAD} constant determines when a new thread will be
  61. * allocated to the thread pool inside the SDK. The thread pool will
  62. * try and maintain this jobs/thread ratio. When the jobs/thread ratio
  63. * becomes greater than this, then a new thread (up to the max) will be
  64. * allocated to the thread pool. The default ratio is 10 jobs/thread.
  65. *
  66. * @{
  67. */
  68. #define JOBS_PER_THREAD 10
  69. /* @} */
  70. /*!
  71. * \name MIN_THREADS
  72. *
  73. * The {\tt MIN_THREADS} constant defines the minimum number of threads the
  74. * thread pool inside the SDK will create. The thread pool will
  75. * always have this number of threads. These threads are used
  76. * for both callbacks into applications built on top of the SDK and also
  77. * for making connections to other control points and devices. This number
  78. * includes persistent threads. The default value is two threads.
  79. *
  80. * @{
  81. */
  82. #define MIN_THREADS 2
  83. /* @} */
  84. /*!
  85. * \name MAX_THREADS
  86. *
  87. * The {\tt MAX_THREADS} constant defines the maximum number of threads the
  88. * thread pool inside the SDK will create. These threads are used
  89. * for both callbacks into applications built on top of the library and also
  90. * for making connections to other control points and devices. It is not
  91. * recommended that this value be below 10, since the threads are
  92. * necessary for correct operation. This value can be increased for greater
  93. * performance in operation at the expense of greater memory overhead. The
  94. * default value is 12.
  95. *
  96. * @{
  97. */
  98. #define MAX_THREADS 12
  99. /* @} */
  100. /*!
  101. * \name THREAD_STACK_SIZE
  102. *
  103. * The {\tt THREAD_STACK_SIZE} constant defines the minimum stack size (in
  104. * bytes) allocated for the stack of each thread the thread pool inside the
  105. * SDK will create. These threads are used for both callbacks into
  106. * applications built on top of the library and also for making connections
  107. * to other control points and devices. This value will not be used if it
  108. * is lower than ITHREAD_STACK_MIN or greater than a system-imposed limit.
  109. * This value can be used to lower memory overhead in embedded systems.
  110. * The default value is 0 (so it is not used by default).
  111. *
  112. * @{
  113. */
  114. #define THREAD_STACK_SIZE (size_t)0
  115. /* @} */
  116. /*! \name MAX_JOBS_TOTAL
  117. *
  118. * The {\tt MAX_JOBS_TOTAL} constant determines the maximum number of jobs
  119. * that can be queued. If this limit is reached further jobs will be thrown
  120. * to avoid memory exhaustion. The default value 100.
  121. * (Added by Axis.)
  122. *
  123. * @{
  124. */
  125. #define MAX_JOBS_TOTAL 100
  126. /* @} */
  127. /*! \name MAX_SUBSCRIPTION_QUEUED_EVENTS
  128. *
  129. * The {\tt MAX_SUBSCRIPTION_QUEUED_EVENTS} determines the maximum number of
  130. * events which can be queued for a given subscription before events begin
  131. * to be discarded. This limits the amount of memory used for a
  132. * non-responding subscribed entity.
  133. *
  134. * @{
  135. */
  136. #define MAX_SUBSCRIPTION_QUEUED_EVENTS 10
  137. /* @} */
  138. /*! \name MAX_SUBSCRIPTION_EVENT_AGE
  139. *
  140. * The {\tt MAX_SUBSCRIPTION__EVENT_AGE} determines the maximum number of
  141. * seconds which an event can spend on a subscription queue (waiting for the
  142. * event at the head of the queue to be communicated). This parameter will
  143. * have no effect in most situations with the default (low) value of
  144. * MAX_SUBSCRIPTION_QUEUED_EVENTS. However, if MAX_SUBSCRIPTION_QUEUED_EVENTS
  145. * is set to a high value, the AGE parameter will allow pruning the queue in
  146. * good conformance with the UPnP Device Architecture standard, at the
  147. * price of higher potential memory use.
  148. *
  149. * @{
  150. */
  151. #define MAX_SUBSCRIPTION_EVENT_AGE 30
  152. /* @} */
  153. /*!
  154. * \name DEFAULT_SOAP_CONTENT_LENGTH
  155. *
  156. * SOAP messages will read at most {\tt DEFAULT_SOAP_CONTENT_LENGTH} bytes.
  157. * This prevents devices that have a misbehaving web server to send
  158. * a large amount of data to the control point causing it to crash.
  159. * This can be adjusted dynamically with {\tt UpnpSetMaxContentLength}.
  160. *
  161. * @{
  162. */
  163. #define DEFAULT_SOAP_CONTENT_LENGTH 16000
  164. /* @} */
  165. /*!
  166. * \name NUM_SSDP_COPY
  167. *
  168. * This configuration parameter determines how many copies of each SSDP
  169. * advertisement and search packets will be sent. By default it will send two
  170. * copies of every packet.
  171. *
  172. * @{
  173. */
  174. #define NUM_SSDP_COPY 2
  175. /* @} */
  176. /*!
  177. * \name SSDP_PAUSE
  178. *
  179. * This configuration parameter determines the pause between identical SSDP
  180. * advertisement and search packets. The pause is measured in milliseconds
  181. * and defaults to 100.
  182. *
  183. * @{
  184. */
  185. #define SSDP_PAUSE 100u
  186. /* @} */
  187. /*!
  188. * \name WEB_SERVER_BUF_SIZE
  189. *
  190. * This configuration parameter sets the maximum buffer size for the
  191. * webserver. The default value is 1MB.
  192. *
  193. * @{
  194. */
  195. #define WEB_SERVER_BUF_SIZE (size_t)(1024*1024)
  196. /* @} */
  197. /*!
  198. * \name WEB_SERVER_CONTENT_LANGUAGE
  199. *
  200. * This configuration parameter sets the value of the Content-Language
  201. * header for the webserver. Thanks to this parameter, the use can advertize
  202. * the language used by the device in the description (friendlyName) and
  203. * presentation steps of UPnP. The default value is empty string so no
  204. * Content-Language header is added.
  205. *
  206. * @{
  207. */
  208. #define WEB_SERVER_CONTENT_LANGUAGE ""
  209. /* @} */
  210. /*!
  211. * \name AUTO_RENEW_TIME
  212. *
  213. * The {\tt AUTO_RENEW_TIME} is the time, in seconds, before a subscription
  214. * expires that the SDK automatically resubscribes. The default
  215. * value is 10 seconds. Setting this value too low can result in the
  216. * subscription renewal not making it to the device in time, causing the
  217. * subscription to timeout. In order to avoid continually resubscribing
  218. * the minimum subscription time is five seconds more than the auto renew
  219. * time.
  220. *
  221. * @{
  222. */
  223. #define AUTO_RENEW_TIME 10
  224. /* @} */
  225. /*!
  226. * \name CP_MINIMUM_SUBSCRIPTION_TIME
  227. *
  228. * The {\tt CP_MINIMUM_SUBSCRIPTION_TIME} is the minimum subscription time
  229. * allowed for a control point using the SDK. Subscribing for less than
  230. * this time automatically results in a subscription for this amount. The
  231. * default value is 5 seconds more than the {\tt AUTO_RENEW_TIME}, or 15
  232. * seconds.
  233. *
  234. * @{
  235. */
  236. #define CP_MINIMUM_SUBSCRIPTION_TIME (AUTO_RENEW_TIME + 5)
  237. /* @} */
  238. /*!
  239. * \name MAX_SEARCH_TIME
  240. *
  241. * The {\tt MAX_SEARCH_TIME} is the maximum time
  242. * allowed for an SSDP search by a control point. Searching for greater than
  243. * this time automatically results in a search for this amount. The default
  244. * value is 80 seconds.
  245. *
  246. * @{
  247. */
  248. #define MAX_SEARCH_TIME 80
  249. /* @} */
  250. /*!
  251. * \name MIN_SEARCH_TIME
  252. *
  253. * The {\tt MIN_SEARCH_TIME} is the minimumm time
  254. * allowed for an SSDP search by a control point. Searching for less than
  255. * this time automatically results in a search for this amount. The default
  256. * value is 2 seconds.
  257. *
  258. * @{
  259. */
  260. #define MIN_SEARCH_TIME 2
  261. /* @} */
  262. /*!
  263. * \name AUTO_ADVERTISEMENT_TIME
  264. *
  265. * The {\tt AUTO_ADVERTISEMENT_TIME} is the time, in seconds, before an
  266. * device advertisements expires before a renewed advertisement is sent.
  267. * The default time is 30 seconds.
  268. *
  269. * @{
  270. */
  271. #define AUTO_ADVERTISEMENT_TIME 30
  272. /* @} */
  273. /*!
  274. * \name SSDP_PACKET_DISTRIBUTE
  275. *
  276. * The {\tt SSDP_PACKET_DISTRIBUTE} enables the SSDP packets to be sent
  277. * at an interval equal to half of the expiration time of SSDP packets
  278. * minus the AUTO_ADVERTISEMENT_TIME. This is used to increase
  279. * the probability of SSDP packets reaching to control points.
  280. * It is recommended that this flag be turned on for embedded wireless
  281. * devices.
  282. *
  283. * @{
  284. */
  285. #define SSDP_PACKET_DISTRIBUTE 1
  286. /* @} */
  287. /*!
  288. * \name GENA_NOTIFICATION_SENDING_TIMEOUT
  289. *
  290. * The {\tt GENA_NOTIFICATION_SENDING_TIMEOUT} specifies the number of seconds
  291. * to wait for sending GENA notifications to the Control Point.
  292. *
  293. * This timeout will be used to know how many seconds GENA notification threads
  294. * will wait to write on the socket to send the notification. By putting a
  295. * lower value than HTTP_DEFAULT_TIMEOUT, the thread will not wait too long and
  296. * will return quickly if writing is impossible. This is very useful as some
  297. * Control Points disconnect from the network without unsubscribing as a result
  298. * if HTTP_DEFAULT_TIMEOUT is used, all the GENA threads will be blocked to send
  299. * notifications to those disconnected Control Points until the subscription
  300. * expires.
  301. *
  302. * @{
  303. */
  304. #define GENA_NOTIFICATION_SENDING_TIMEOUT HTTP_DEFAULT_TIMEOUT
  305. /* @} */
  306. /*!
  307. * \name GENA_NOTIFICATION_ANSWERING_TIMEOUT
  308. *
  309. * The {\tt GENA_NOTIFICATION_ANSWERING_TIMEOUT} specifies the number of seconds
  310. * to wait for receiving the answer to a GENA notification from the Control
  311. * Point.
  312. *
  313. * This timeout will be used to know how many seconds GENA notification threads
  314. * will wait on the socket to read for an answer from the CP. By putting a
  315. * lower value than HTTP_DEFAULT_TIMEOUT, the thread will not wait too long and
  316. * will return quickly if there is no answer from the CP. This is very useful as
  317. * some Control Points disconnect from the network without unsubscribing and if
  318. * HTTP_DEFAULT_TIMEOUT is used, all the GENA threads will be blocked to wait
  319. * for an answer from those disconnected Control Points until the subscription
  320. * expires. However, it should be noted that UDA specifies a value of 30s for
  321. * waiting the CP's answer.
  322. *
  323. * @{
  324. */
  325. #define GENA_NOTIFICATION_ANSWERING_TIMEOUT HTTP_DEFAULT_TIMEOUT
  326. /* @} */
  327. /*!
  328. * \name Module Exclusion
  329. *
  330. * Depending on the requirements, the user can selectively discard any of
  331. * the major modules like SOAP, GENA, SSDP or the Internal web server. By
  332. * default everything is included inside the SDK. By setting any of
  333. * the values below to 0, that component will not be included in the final
  334. * SDK.
  335. * \begin{itemize}
  336. * \item {\tt EXCLUDE_SOAP[0,1]}
  337. * \item {\tt EXCLUDE_GENA[0,1]}
  338. * \item {\tt EXCLUDE_SSDP[0,1]}
  339. * \item {\tt EXCLUDE_DOM [0,1]}
  340. * \item {\tt EXCLUDE_MINISERVER[0,1]}
  341. * \item {\tt EXCLUDE_WEB_SERVER[0,1]}
  342. * \item {\tt EXCLUDE_JNI[0,1]}
  343. * \end{itemize}
  344. *
  345. * @{
  346. */
  347. #define EXCLUDE_SSDP 0
  348. #define EXCLUDE_SOAP 0
  349. #define EXCLUDE_GENA 0
  350. #define EXCLUDE_DOM 0
  351. #define EXCLUDE_MINISERVER 0
  352. #define EXCLUDE_WEB_SERVER 0
  353. #ifdef USE_JNI
  354. # define EXCLUDE_JNI 0
  355. #else
  356. # define EXCLUDE_JNI 1
  357. #endif
  358. /* @} */
  359. /*!
  360. * \name DEBUG_TARGET
  361. *
  362. * The user has the option to redirect the library output debug messages
  363. * to either the screen or to a log file. All the output messages with
  364. * debug level 0 will go to {\tt upnp.err} and messages with debug level
  365. * greater than zero will be redirected to {\tt upnp.out}.
  366. *
  367. * @{
  368. */
  369. #define DEBUG_TARGET 1
  370. /* @} */
  371. /*!
  372. * \name Other debugging features
  373. *
  374. * The UPnP SDK contains other features to aid in debugging:
  375. * see <upnp/inc/upnpdebug.h>
  376. */
  377. #define DEBUG_ALL 1
  378. #define DEBUG_SSDP 0
  379. #define DEBUG_SOAP 0
  380. #define DEBUG_GENA 0
  381. #define DEBUG_TPOOL 0
  382. #define DEBUG_MSERV 0
  383. #define DEBUG_DOM 0
  384. #define DEBUG_HTTP 0
  385. #define DEBUG_API 0
  386. /*
  387. * @} Compile time configuration options
  388. */
  389. /***************************************************************************
  390. * Do not change, Internal purpose only!!!
  391. ***************************************************************************/
  392. /*!
  393. * @{
  394. */
  395. /*
  396. * Set additional defines based on requested configuration
  397. */
  398. /* configure --enable-client */
  399. #if UPNP_HAVE_CLIENT
  400. # define INCLUDE_CLIENT_APIS 1
  401. #endif
  402. /* configure --enable-device */
  403. #if UPNP_HAVE_DEVICE
  404. # define INCLUDE_DEVICE_APIS 1
  405. #endif
  406. /* configure --enable-webserver */
  407. #if UPNP_HAVE_WEBSERVER
  408. # define INTERNAL_WEB_SERVER 1
  409. #endif
  410. /* configure --enable-ssdp */
  411. #undef EXCLUDE_SSDP
  412. #if UPNP_HAVE_SSDP
  413. # define EXCLUDE_SSDP 0
  414. #else
  415. # define EXCLUDE_SSDP 1
  416. #endif
  417. /* configure --enable-soap */
  418. #undef EXCLUDE_SOAP
  419. #if UPNP_HAVE_SOAP
  420. # define EXCLUDE_SOAP 0
  421. #else
  422. # define EXCLUDE_SOAP 1
  423. #endif
  424. /* configure --enable-gena */
  425. #undef EXCLUDE_GENA
  426. #if UPNP_HAVE_GENA
  427. # define EXCLUDE_GENA 0
  428. #else
  429. # define EXCLUDE_GENA 1
  430. #endif
  431. #undef EXCLUDE_WEB_SERVER
  432. #undef EXCLUDE_MINISERVER
  433. #ifdef INTERNAL_WEB_SERVER
  434. # define EXCLUDE_WEB_SERVER 0
  435. # define EXCLUDE_MINISERVER 0
  436. #else
  437. # define EXCLUDE_WEB_SERVER 1
  438. # define EXCLUDE_MINISERVER 1
  439. #endif
  440. #if EXCLUDE_SSDP == 1 && EXCLUDE_GENA == 1 && EXCLUDE_SOAP == 1 && EXCLUDE_WEB_SERVER == 1
  441. # undef EXCLUDE_MINISERVER
  442. # define EXCLUDE_MINISERVER 1
  443. # if INTERNAL_WEB_SERVER
  444. # error "conflicting settings: use configure --disable-webserver"
  445. # endif
  446. #endif
  447. #if EXCLUDE_SSDP == 0 || EXCLUDE_GENA == 0 || EXCLUDE_SOAP == 0 || EXCLUDE_WEB_SERVER == 0
  448. # undef EXCLUDE_MINISERVER
  449. # define EXCLUDE_MINISERVER 0
  450. # if EXCLUDE_WEB_SERVER == 0 && !defined INTERNAL_WEB_SERVER
  451. # error "conflicting settings : use configure --enable-webserver"
  452. # endif
  453. #endif
  454. /*
  455. * @}
  456. */
  457. #endif /* INTERNAL_CONFIG_H */