config.h 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  1. /*
  2. * Copyright (C) 2008-2011 Teluu Inc. (http://www.teluu.com)
  3. * Copyright (C) 2003-2008 Benny Prijono <benny@prijono.org>
  4. *
  5. * This program is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * This program is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this program; if not, write to the Free Software
  17. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. */
  19. #ifndef __PJNATH_CONFIG_H__
  20. #define __PJNATH_CONFIG_H__
  21. /**
  22. * @file config.h
  23. * @brief Compile time settings
  24. */
  25. #include <pj/types.h>
  26. /**
  27. * @defgroup PJNATH_CONFIG Compile-time configurations
  28. * @brief Various compile time settings
  29. * @ingroup PJNATH_STUN_BASE
  30. * @{
  31. */
  32. /* **************************************************************************
  33. * GENERAL
  34. */
  35. /**
  36. * The log level for PJNATH error display.
  37. *
  38. * default 1
  39. */
  40. #ifndef PJNATH_ERROR_LEVEL
  41. # define PJNATH_ERROR_LEVEL 1
  42. #endif
  43. /* **************************************************************************
  44. * STUN CONFIGURATION
  45. */
  46. /**
  47. * Maximum number of attributes in the STUN packet (for the new STUN
  48. * library).
  49. *
  50. * Default: 16
  51. */
  52. #ifndef PJ_STUN_MAX_ATTR
  53. # define PJ_STUN_MAX_ATTR 16
  54. #endif
  55. /**
  56. * The default initial STUN round-trip time estimation (the RTO value
  57. * in RFC 3489-bis), in miliseconds.
  58. * This value is used to control the STUN request
  59. * retransmit time. The initial value of retransmission interval
  60. * would be set to this value, and will be doubled after each
  61. * retransmission.
  62. */
  63. #ifndef PJ_STUN_RTO_VALUE
  64. # define PJ_STUN_RTO_VALUE 100
  65. #endif
  66. /**
  67. * The STUN transaction timeout value, in miliseconds.
  68. * After the last retransmission is sent and if no response is received
  69. * after this time, the STUN transaction will be considered to have failed.
  70. *
  71. * The default value is 16x RTO (as per RFC 3489-bis).
  72. */
  73. #ifndef PJ_STUN_TIMEOUT_VALUE
  74. # define PJ_STUN_TIMEOUT_VALUE (16 * PJ_STUN_RTO_VALUE)
  75. #endif
  76. /**
  77. * Maximum number of STUN transmission count.
  78. *
  79. * Default: 7 (as per RFC 3489-bis)
  80. */
  81. #ifndef PJ_STUN_MAX_TRANSMIT_COUNT
  82. # define PJ_STUN_MAX_TRANSMIT_COUNT 7
  83. #endif
  84. /**
  85. * Duration to keep response in the cache, in msec.
  86. *
  87. * Default: 10000 (as per RFC 3489-bis)
  88. */
  89. #ifndef PJ_STUN_RES_CACHE_DURATION
  90. # define PJ_STUN_RES_CACHE_DURATION 10000
  91. #endif
  92. /**
  93. * Maximum size of STUN message.
  94. */
  95. #ifndef PJ_STUN_MAX_PKT_LEN
  96. # define PJ_STUN_MAX_PKT_LEN 800
  97. #endif
  98. /**
  99. * Default STUN port as defined by RFC 3489.
  100. */
  101. #define PJ_STUN_PORT 3478
  102. /**
  103. * Padding character for string attributes.
  104. *
  105. * Default: ASCII 0
  106. */
  107. #ifndef PJ_STUN_STRING_ATTR_PAD_CHR
  108. # define PJ_STUN_STRING_ATTR_PAD_CHR 0
  109. #endif
  110. /**
  111. * Enable pre-RFC3489bis-07 style of STUN MESSAGE-INTEGRITY and FINGERPRINT
  112. * calculation. By default this should be disabled since the calculation is
  113. * not backward compatible with current STUN specification.
  114. */
  115. #ifndef PJ_STUN_OLD_STYLE_MI_FINGERPRINT
  116. # define PJ_STUN_OLD_STYLE_MI_FINGERPRINT 0
  117. #endif
  118. /* **************************************************************************
  119. * STUN TRANSPORT CONFIGURATION
  120. */
  121. /**
  122. * The packet buffer size for the STUN transport.
  123. */
  124. #ifndef PJ_STUN_SOCK_PKT_LEN
  125. # define PJ_STUN_SOCK_PKT_LEN 2000
  126. #endif
  127. /**
  128. * The duration of the STUN keep-alive period, in seconds.
  129. */
  130. #ifndef PJ_STUN_KEEP_ALIVE_SEC
  131. # define PJ_STUN_KEEP_ALIVE_SEC 15
  132. #endif
  133. /* **************************************************************************
  134. * TURN CONFIGURATION
  135. */
  136. /**
  137. * Maximum DNS SRV entries to be processed in the DNS SRV response
  138. */
  139. #ifndef PJ_TURN_MAX_DNS_SRV_CNT
  140. # define PJ_TURN_MAX_DNS_SRV_CNT 4
  141. #endif
  142. /**
  143. * Maximum TURN packet size to be supported.
  144. */
  145. #ifndef PJ_TURN_MAX_PKT_LEN
  146. # define PJ_TURN_MAX_PKT_LEN 3000
  147. #endif
  148. /**
  149. * The TURN permission lifetime setting. This value should be taken from the
  150. * TURN protocol specification.
  151. */
  152. #ifndef PJ_TURN_PERM_TIMEOUT
  153. # define PJ_TURN_PERM_TIMEOUT 300
  154. #endif
  155. /**
  156. * The TURN channel binding lifetime. This value should be taken from the
  157. * TURN protocol specification.
  158. */
  159. #ifndef PJ_TURN_CHANNEL_TIMEOUT
  160. # define PJ_TURN_CHANNEL_TIMEOUT 600
  161. #endif
  162. /**
  163. * Number of seconds to refresh the permission/channel binding before the
  164. * permission/channel binding expires. This value should be greater than
  165. * PJ_TURN_PERM_TIMEOUT setting.
  166. */
  167. #ifndef PJ_TURN_REFRESH_SEC_BEFORE
  168. # define PJ_TURN_REFRESH_SEC_BEFORE 60
  169. #endif
  170. /**
  171. * The TURN session timer heart beat interval. When this timer occurs, the
  172. * TURN session will scan all the permissions/channel bindings to see which
  173. * need to be refreshed.
  174. */
  175. #ifndef PJ_TURN_KEEP_ALIVE_SEC
  176. # define PJ_TURN_KEEP_ALIVE_SEC 15
  177. #endif
  178. /**
  179. * Maximum number of TCP data connection to peer(s) that a TURN client can
  180. * open/accept for each TURN allocation (or TURN control connection).
  181. */
  182. #ifndef PJ_TURN_MAX_TCP_CONN_CNT
  183. # define PJ_TURN_MAX_TCP_CONN_CNT 8
  184. #endif
  185. /* **************************************************************************
  186. * ICE CONFIGURATION
  187. */
  188. /**
  189. * Maximum number of ICE candidates.
  190. *
  191. * Default: 16
  192. */
  193. #ifndef PJ_ICE_MAX_CAND
  194. # define PJ_ICE_MAX_CAND 16
  195. #endif
  196. /**
  197. * Maximum number of candidates for each ICE stream transport component.
  198. *
  199. * Default: 8
  200. */
  201. #ifndef PJ_ICE_ST_MAX_CAND
  202. # define PJ_ICE_ST_MAX_CAND 8
  203. #endif
  204. /**
  205. * Maximum number of STUN transports for each ICE stream transport component.
  206. * Valid values are 1 - 64.
  207. *
  208. * Default: 2
  209. */
  210. #ifndef PJ_ICE_MAX_STUN
  211. # define PJ_ICE_MAX_STUN 2
  212. #endif
  213. /**
  214. * Maximum number of TURN transports for each ICE stream transport component.
  215. * Valid values are 1 - 64.
  216. *
  217. * Default: 2
  218. */
  219. #ifndef PJ_ICE_MAX_TURN
  220. # define PJ_ICE_MAX_TURN 3
  221. #endif
  222. /**
  223. * The number of bits to represent component IDs. This will affect
  224. * the maximum number of components (PJ_ICE_MAX_COMP) value.
  225. */
  226. #ifndef PJ_ICE_COMP_BITS
  227. # define PJ_ICE_COMP_BITS 1
  228. #endif
  229. /**
  230. * Maximum number of ICE components.
  231. */
  232. #define PJ_ICE_MAX_COMP (1<<PJ_ICE_COMP_BITS)
  233. /**
  234. * Use the priority value according to the ice-draft.
  235. */
  236. #ifndef PJNATH_ICE_PRIO_STD
  237. # define PJNATH_ICE_PRIO_STD 1
  238. #endif
  239. /**
  240. * The number of bits to represent candidate type preference.
  241. */
  242. #ifndef PJ_ICE_CAND_TYPE_PREF_BITS
  243. # if PJNATH_ICE_PRIO_STD
  244. # define PJ_ICE_CAND_TYPE_PREF_BITS 8
  245. # else
  246. # define PJ_ICE_CAND_TYPE_PREF_BITS 2
  247. # endif
  248. #endif
  249. /**
  250. * The number of bits to represent ICE candidate's local preference. The
  251. * local preference is used to specify preference among candidates with
  252. * the same type, and ICE draft suggests 65535 as the default local
  253. * preference, which means we need 16 bits to represent the value. But
  254. * since we don't have the facility to specify local preference, we'll
  255. * just disable this feature and let the preference sorted by the
  256. * type only.
  257. *
  258. * Default: 0
  259. */
  260. #ifndef PJ_ICE_LOCAL_PREF_BITS
  261. # define PJ_ICE_LOCAL_PREF_BITS 0
  262. #endif
  263. /**
  264. * Maximum number of ICE checks.
  265. *
  266. * Default: 32
  267. */
  268. #ifndef PJ_ICE_MAX_CHECKS
  269. # define PJ_ICE_MAX_CHECKS 32
  270. #endif
  271. /**
  272. * Default timer interval (in miliseconds) for starting ICE periodic checks.
  273. *
  274. * Default: 20
  275. */
  276. #ifndef PJ_ICE_TA_VAL
  277. # define PJ_ICE_TA_VAL 20
  278. #endif
  279. /**
  280. * According to ICE Section 8.2. Updating States, if an In-Progress pair in
  281. * the check list is for the same component as a nominated pair, the agent
  282. * SHOULD cease retransmissions for its check if its pair priority is lower
  283. * than the lowest priority nominated pair for that component.
  284. *
  285. * If a higher priority check is In Progress, this rule would cause that
  286. * check to be performed even when it most likely will fail.
  287. *
  288. * The macro here controls if ICE session should cancel all In Progress
  289. * checks for the same component regardless of its priority.
  290. *
  291. * Default: 1 (yes, cancel all)
  292. */
  293. #ifndef PJ_ICE_CANCEL_ALL
  294. # define PJ_ICE_CANCEL_ALL 1
  295. #endif
  296. /**
  297. * For a controlled agent, specify how long it wants to wait (in milliseconds)
  298. * for the controlling agent to complete sending connectivity check with
  299. * nominated flag set to true for all components after the controlled agent
  300. * has found that all connectivity checks in its checklist have been completed
  301. * and there is at least one successful (but not nominated) check for every
  302. * component.
  303. *
  304. * When selecting the value, bear in mind that the connectivity check from
  305. * controlling agent may be delayed because of delay in receiving SDP answer
  306. * from the controlled agent.
  307. *
  308. * Application may set this value to -1 to disable this timer.
  309. *
  310. * Default: 10000 (milliseconds)
  311. */
  312. #ifndef ICE_CONTROLLED_AGENT_WAIT_NOMINATION_TIMEOUT
  313. # define ICE_CONTROLLED_AGENT_WAIT_NOMINATION_TIMEOUT 10000
  314. #endif
  315. /**
  316. * For controlling agent if it uses regular nomination, specify the delay to
  317. * perform nominated check (connectivity check with USE-CANDIDATE attribute)
  318. * after all components have a valid pair.
  319. *
  320. * Default: 4*PJ_STUN_RTO_VALUE (milliseconds)
  321. */
  322. #ifndef PJ_ICE_NOMINATED_CHECK_DELAY
  323. # define PJ_ICE_NOMINATED_CHECK_DELAY (4*PJ_STUN_RTO_VALUE)
  324. #endif
  325. /**
  326. * Minimum interval value to be used for sending STUN keep-alive on the ICE
  327. * session, in seconds. This minimum interval, plus a random value
  328. * which maximum is PJ_ICE_SESS_KEEP_ALIVE_MAX_RAND, specify the actual interval
  329. * of the STUN keep-alive.
  330. *
  331. * Default: 15 seconds
  332. *
  333. * @see PJ_ICE_SESS_KEEP_ALIVE_MAX_RAND
  334. */
  335. #ifndef PJ_ICE_SESS_KEEP_ALIVE_MIN
  336. # define PJ_ICE_SESS_KEEP_ALIVE_MIN 20
  337. #endif
  338. /* Warn about deprecated macro */
  339. #ifdef PJ_ICE_ST_KEEP_ALIVE_MIN
  340. # error PJ_ICE_ST_KEEP_ALIVE_MIN is deprecated
  341. #endif
  342. /**
  343. * To prevent STUN keep-alives to be sent simultaneously, application should
  344. * add random interval to minimum interval (PJ_ICE_SESS_KEEP_ALIVE_MIN). This
  345. * setting specifies the maximum random value to be added to the minimum
  346. * interval, in seconds.
  347. *
  348. * Default: 5 seconds
  349. *
  350. * @see PJ_ICE_SESS_KEEP_ALIVE_MIN
  351. */
  352. #ifndef PJ_ICE_SESS_KEEP_ALIVE_MAX_RAND
  353. # define PJ_ICE_SESS_KEEP_ALIVE_MAX_RAND 5
  354. #endif
  355. /* Warn about deprecated macro */
  356. #ifdef PJ_ICE_ST_KEEP_ALIVE_MAX_RAND
  357. # error PJ_ICE_ST_KEEP_ALIVE_MAX_RAND is deprecated
  358. #endif
  359. /**
  360. * This constant specifies the length of random string generated for ICE
  361. * ufrag.
  362. *
  363. * Default: 8 (characters)
  364. */
  365. #ifndef PJ_ICE_UFRAG_LEN
  366. # define PJ_ICE_UFRAG_LEN 8
  367. #endif
  368. /**
  369. * This constant specifies the length of random string generated for ICE
  370. * password.
  371. *
  372. * Default: 24 (characters)
  373. */
  374. #ifndef PJ_ICE_PWD_LEN
  375. # define PJ_ICE_PWD_LEN 24
  376. #endif
  377. /**
  378. * This constant specifies whether ICE stream transport should allow TURN
  379. * client session to automatically renew permission for all remote candidates.
  380. *
  381. * Default: PJ_FALSE
  382. */
  383. #ifndef PJ_ICE_ST_USE_TURN_PERMANENT_PERM
  384. # define PJ_ICE_ST_USE_TURN_PERMANENT_PERM PJ_FALSE
  385. #endif
  386. /**
  387. * For trickle ICE, this macro specifies the maximum time of waiting for
  388. * end-of-candidates indication from remote once ICE connectivity checks
  389. * is started, in seconds. When the timer expires, ICE will assume that
  390. * end-of-candidates indication is received so any further remote candidate
  391. * update will be ignored.
  392. *
  393. * Note that without remote end-of-candidates indication, ICE will not be
  394. * able to conclude that the ICE negotiation has failed when all pair checks
  395. * are completed but there is no valid pair (on the other hand, the ICE
  396. * negotiation may be completed as successful before the end-of-candidates
  397. * indication is received when valid pairs are found very quickly).
  398. *
  399. * Also note that the ICE connectivity checks should only be started after
  400. * both agents have started trickling ICE candidates (e.g: both have sent
  401. * their SDPs, either via normal SDP offer/answer or SIP INFO).
  402. *
  403. * Default: 40 seconds.
  404. */
  405. #ifndef PJ_TRICKLE_ICE_END_OF_CAND_TIMEOUT
  406. # define PJ_TRICKLE_ICE_END_OF_CAND_TIMEOUT 40
  407. #endif
  408. /** ICE session pool initial size. */
  409. #ifndef PJNATH_POOL_LEN_ICE_SESS
  410. # define PJNATH_POOL_LEN_ICE_SESS 512
  411. #endif
  412. /** ICE session pool increment size */
  413. #ifndef PJNATH_POOL_INC_ICE_SESS
  414. # define PJNATH_POOL_INC_ICE_SESS 512
  415. #endif
  416. /** ICE stream transport pool initial size. */
  417. #ifndef PJNATH_POOL_LEN_ICE_STRANS
  418. # define PJNATH_POOL_LEN_ICE_STRANS 1000
  419. #endif
  420. /** ICE stream transport pool increment size */
  421. #ifndef PJNATH_POOL_INC_ICE_STRANS
  422. # define PJNATH_POOL_INC_ICE_STRANS 512
  423. #endif
  424. /** NAT detect pool initial size */
  425. #ifndef PJNATH_POOL_LEN_NATCK
  426. # define PJNATH_POOL_LEN_NATCK 512
  427. #endif
  428. /** NAT detect pool increment size */
  429. #ifndef PJNATH_POOL_INC_NATCK
  430. # define PJNATH_POOL_INC_NATCK 512
  431. #endif
  432. /** STUN session pool initial size */
  433. #ifndef PJNATH_POOL_LEN_STUN_SESS
  434. # define PJNATH_POOL_LEN_STUN_SESS 1000
  435. #endif
  436. /** STUN session pool increment size */
  437. #ifndef PJNATH_POOL_INC_STUN_SESS
  438. # define PJNATH_POOL_INC_STUN_SESS 1000
  439. #endif
  440. /** STUN session transmit data pool initial size */
  441. #ifndef PJNATH_POOL_LEN_STUN_TDATA
  442. # define PJNATH_POOL_LEN_STUN_TDATA 1000
  443. #endif
  444. /** STUN session transmit data pool increment size */
  445. #ifndef PJNATH_POOL_INC_STUN_TDATA
  446. # define PJNATH_POOL_INC_STUN_TDATA 1000
  447. #endif
  448. /** TURN session initial pool size */
  449. #ifndef PJNATH_POOL_LEN_TURN_SESS
  450. # define PJNATH_POOL_LEN_TURN_SESS 1000
  451. #endif
  452. /** TURN session pool increment size */
  453. #ifndef PJNATH_POOL_INC_TURN_SESS
  454. # define PJNATH_POOL_INC_TURN_SESS 1000
  455. #endif
  456. /** TURN socket initial pool size */
  457. #ifndef PJNATH_POOL_LEN_TURN_SOCK
  458. # define PJNATH_POOL_LEN_TURN_SOCK 1000
  459. #endif
  460. /** TURN socket pool increment size */
  461. #ifndef PJNATH_POOL_INC_TURN_SOCK
  462. # define PJNATH_POOL_INC_TURN_SOCK 1000
  463. #endif
  464. /** Default STUN software name */
  465. #ifndef PJNATH_STUN_SOFTWARE_NAME
  466. /** Create STUN software name */
  467. # define PJNATH_MAKE_SW_NAME(a,b,c,d) "pjnath-" #a "." #b "." #c d
  468. /** Create STUN software name */
  469. # define PJNATH_MAKE_SW_NAME2(a,b,c,d) PJNATH_MAKE_SW_NAME(a,b,c,d)
  470. /** Default STUN software name */
  471. # define PJNATH_STUN_SOFTWARE_NAME PJNATH_MAKE_SW_NAME2( \
  472. PJ_VERSION_NUM_MAJOR, \
  473. PJ_VERSION_NUM_MINOR, \
  474. PJ_VERSION_NUM_REV, \
  475. PJ_VERSION_NUM_EXTRA)
  476. #endif
  477. /* **************************************************************************
  478. * UPnP
  479. */
  480. /** Default duration for searching UPnP Internet Gateway Devices (in seconds).
  481. * Default: 5 seconds
  482. */
  483. #ifndef PJ_UPNP_DEFAULT_SEARCH_TIME
  484. # define PJ_UPNP_DEFAULT_SEARCH_TIME 5
  485. #endif
  486. /**
  487. * @}
  488. */
  489. #endif /* __PJNATH_CONFIG_H__ */