options.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /*
  2. * Asterisk -- An open source telephony toolkit.
  3. *
  4. * Copyright (C) 1999 - 2005, Digium, Inc.
  5. *
  6. * Mark Spencer <markster@digium.com>
  7. *
  8. * See http://www.asterisk.org for more information about
  9. * the Asterisk project. Please do not directly contact
  10. * any of the maintainers of this project for assistance;
  11. * the project provides a web site, mailing lists and IRC
  12. * channels for your use.
  13. *
  14. * This program is free software, distributed under the terms of
  15. * the GNU General Public License Version 2. See the LICENSE file
  16. * at the top of the source tree.
  17. */
  18. /*! \file
  19. * \brief Options provided by main asterisk program
  20. */
  21. #ifndef _ASTERISK_OPTIONS_H
  22. #define _ASTERISK_OPTIONS_H
  23. #include "asterisk/autoconfig.h"
  24. #if defined(__cplusplus) || defined(c_plusplus)
  25. extern "C" {
  26. #endif
  27. #define AST_CACHE_DIR_LEN 512
  28. #define AST_FILENAME_MAX 80
  29. #define AST_CHANNEL_NAME 80 /*!< Max length of an ast_channel name */
  30. /*! \ingroup main_options */
  31. enum ast_option_flags {
  32. /*! Allow \#exec in config files */
  33. AST_OPT_FLAG_EXEC_INCLUDES = (1 << 0),
  34. /*! Do not fork() */
  35. AST_OPT_FLAG_NO_FORK = (1 << 1),
  36. /*! Keep quiet */
  37. AST_OPT_FLAG_QUIET = (1 << 2),
  38. /*! Console mode */
  39. AST_OPT_FLAG_CONSOLE = (1 << 3),
  40. /*! Run in realtime Linux priority */
  41. AST_OPT_FLAG_HIGH_PRIORITY = (1 << 4),
  42. /*! Initialize keys for RSA authentication */
  43. AST_OPT_FLAG_INIT_KEYS = (1 << 5),
  44. /*! Remote console */
  45. AST_OPT_FLAG_REMOTE = (1 << 6),
  46. /*! Execute an asterisk CLI command upon startup */
  47. AST_OPT_FLAG_EXEC = (1 << 7),
  48. /*! Don't use termcap colors */
  49. AST_OPT_FLAG_NO_COLOR = (1 << 8),
  50. /*! Are we fully started yet? */
  51. AST_OPT_FLAG_FULLY_BOOTED = (1 << 9),
  52. /*! Trascode via signed linear */
  53. AST_OPT_FLAG_TRANSCODE_VIA_SLIN = (1 << 10),
  54. /*! Invoke the stdexten using the legacy macro method. */
  55. AST_OPT_FLAG_STDEXTEN_MACRO = (1 << 11),
  56. /*! Dump core on a seg fault */
  57. AST_OPT_FLAG_DUMP_CORE = (1 << 12),
  58. /*! Cache sound files */
  59. AST_OPT_FLAG_CACHE_RECORD_FILES = (1 << 13),
  60. /*! Display timestamp in CLI verbose output */
  61. AST_OPT_FLAG_TIMESTAMP = (1 << 14),
  62. /*! Override config */
  63. AST_OPT_FLAG_OVERRIDE_CONFIG = (1 << 15),
  64. /*! Reconnect */
  65. AST_OPT_FLAG_RECONNECT = (1 << 16),
  66. /*! Transmit Silence during Record() and DTMF Generation */
  67. AST_OPT_FLAG_TRANSMIT_SILENCE = (1 << 17),
  68. /*! Suppress some warnings */
  69. AST_OPT_FLAG_DONT_WARN = (1 << 18),
  70. /*! End CDRs before the 'h' extension */
  71. AST_OPT_FLAG_END_CDR_BEFORE_H_EXTEN = (1 << 19),
  72. /*! Cache media frames for performance */
  73. AST_OPT_FLAG_CACHE_MEDIA_FRAMES = (1 << 20),
  74. /*! Always fork, even if verbose or debug settings are non-zero */
  75. AST_OPT_FLAG_ALWAYS_FORK = (1 << 21),
  76. /*! Disable log/verbose output to remote consoles */
  77. AST_OPT_FLAG_MUTE = (1 << 22),
  78. /*! There is a per-module debug setting */
  79. AST_OPT_FLAG_DEBUG_MODULE = (1 << 23),
  80. /*! There is a per-module verbose setting */
  81. AST_OPT_FLAG_VERBOSE_MODULE = (1 << 24),
  82. /*! Terminal colors should be adjusted for a light-colored background */
  83. AST_OPT_FLAG_LIGHT_BACKGROUND = (1 << 25),
  84. /*! Count Initiated seconds in CDR's */
  85. AST_OPT_FLAG_INITIATED_SECONDS = (1 << 26),
  86. /*! Force black background */
  87. AST_OPT_FLAG_FORCE_BLACK_BACKGROUND = (1 << 27),
  88. /*! Hide remote console connect messages on console */
  89. AST_OPT_FLAG_HIDE_CONSOLE_CONNECT = (1 << 28),
  90. /*! Protect the configuration file path with a lock */
  91. AST_OPT_FLAG_LOCK_CONFIG_DIR = (1 << 29),
  92. /*! Generic PLC */
  93. AST_OPT_FLAG_GENERIC_PLC = (1 << 30),
  94. /*! Generic PLC onm equal codecs */
  95. AST_OPT_FLAG_GENERIC_PLC_ON_EQUAL_CODECS = (1 << 31),
  96. };
  97. /*! These are the options that set by default when Asterisk starts */
  98. #define AST_DEFAULT_OPTIONS (AST_OPT_FLAG_TRANSCODE_VIA_SLIN | AST_OPT_FLAG_CACHE_MEDIA_FRAMES)
  99. #define ast_opt_exec_includes ast_test_flag(&ast_options, AST_OPT_FLAG_EXEC_INCLUDES)
  100. #define ast_opt_no_fork ast_test_flag(&ast_options, AST_OPT_FLAG_NO_FORK)
  101. #define ast_opt_quiet ast_test_flag(&ast_options, AST_OPT_FLAG_QUIET)
  102. #define ast_opt_console ast_test_flag(&ast_options, AST_OPT_FLAG_CONSOLE)
  103. #define ast_opt_high_priority ast_test_flag(&ast_options, AST_OPT_FLAG_HIGH_PRIORITY)
  104. #define ast_opt_init_keys ast_test_flag(&ast_options, AST_OPT_FLAG_INIT_KEYS)
  105. #define ast_opt_remote ast_test_flag(&ast_options, AST_OPT_FLAG_REMOTE)
  106. #define ast_opt_exec ast_test_flag(&ast_options, AST_OPT_FLAG_EXEC)
  107. #define ast_opt_no_color ast_test_flag(&ast_options, AST_OPT_FLAG_NO_COLOR)
  108. #define ast_fully_booted ast_test_flag(&ast_options, AST_OPT_FLAG_FULLY_BOOTED)
  109. #define ast_opt_transcode_via_slin ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSCODE_VIA_SLIN)
  110. /*! Invoke the stdexten using the legacy macro method. */
  111. #define ast_opt_stdexten_macro ast_test_flag(&ast_options, AST_OPT_FLAG_STDEXTEN_MACRO)
  112. #define ast_opt_dump_core ast_test_flag(&ast_options, AST_OPT_FLAG_DUMP_CORE)
  113. #define ast_opt_cache_record_files ast_test_flag(&ast_options, AST_OPT_FLAG_CACHE_RECORD_FILES)
  114. #define ast_opt_cache_media_frames ast_test_flag(&ast_options, AST_OPT_FLAG_CACHE_MEDIA_FRAMES)
  115. #define ast_opt_timestamp ast_test_flag(&ast_options, AST_OPT_FLAG_TIMESTAMP)
  116. #define ast_opt_override_config ast_test_flag(&ast_options, AST_OPT_FLAG_OVERRIDE_CONFIG)
  117. #define ast_opt_reconnect ast_test_flag(&ast_options, AST_OPT_FLAG_RECONNECT)
  118. #define ast_opt_transmit_silence ast_test_flag(&ast_options, AST_OPT_FLAG_TRANSMIT_SILENCE)
  119. #define ast_opt_dont_warn ast_test_flag(&ast_options, AST_OPT_FLAG_DONT_WARN)
  120. #define ast_opt_end_cdr_before_h_exten ast_test_flag(&ast_options, AST_OPT_FLAG_END_CDR_BEFORE_H_EXTEN)
  121. #define ast_opt_always_fork ast_test_flag(&ast_options, AST_OPT_FLAG_ALWAYS_FORK)
  122. #define ast_opt_mute ast_test_flag(&ast_options, AST_OPT_FLAG_MUTE)
  123. #define ast_opt_dbg_module ast_test_flag(&ast_options, AST_OPT_FLAG_DEBUG_MODULE)
  124. #define ast_opt_verb_module ast_test_flag(&ast_options, AST_OPT_FLAG_VERBOSE_MODULE)
  125. #define ast_opt_light_background ast_test_flag(&ast_options, AST_OPT_FLAG_LIGHT_BACKGROUND)
  126. #define ast_opt_force_black_background ast_test_flag(&ast_options, AST_OPT_FLAG_FORCE_BLACK_BACKGROUND)
  127. #define ast_opt_hide_connect ast_test_flag(&ast_options, AST_OPT_FLAG_HIDE_CONSOLE_CONNECT)
  128. #define ast_opt_lock_confdir ast_test_flag(&ast_options, AST_OPT_FLAG_LOCK_CONFIG_DIR)
  129. #define ast_opt_generic_plc ast_test_flag(&ast_options, AST_OPT_FLAG_GENERIC_PLC)
  130. #define ast_opt_generic_plc_on_equal_codecs ast_test_flag(&ast_options, AST_OPT_FLAG_GENERIC_PLC_ON_EQUAL_CODECS)
  131. /*! Maximum log level defined by PJPROJECT. */
  132. #define MAX_PJ_LOG_MAX_LEVEL 6
  133. /*!
  134. * Normal PJPROJECT active log level used by Asterisk.
  135. *
  136. * These levels are usually mapped to Error and
  137. * Warning Asterisk log levels which shouldn't
  138. * normally be suppressed.
  139. */
  140. #define DEFAULT_PJ_LOG_MAX_LEVEL 2
  141. /*!
  142. * \brief Get maximum log level pjproject was compiled with.
  143. *
  144. * \details
  145. * Determine the maximum log level the pjproject we are running
  146. * with supports.
  147. *
  148. * When pjproject is initially loaded the default log level in
  149. * effect is the maximum log level the library was compiled to
  150. * generate. We must save this value off somewhere before we
  151. * change it to what we want to use as the default level.
  152. *
  153. * \note This must be done before calling pj_init() so the level
  154. * we want to use as the default level is in effect while the
  155. * library initializes.
  156. */
  157. #define AST_PJPROJECT_INIT_LOG_LEVEL() \
  158. do { \
  159. if (ast_pjproject_max_log_level < 0) { \
  160. ast_pjproject_max_log_level = pj_log_get_level(); \
  161. } \
  162. pj_log_set_level(ast_option_pjproject_log_level); \
  163. } while (0)
  164. /*! Current linked pjproject maximum logging level */
  165. extern int ast_pjproject_max_log_level;
  166. #define DEFAULT_PJPROJECT_CACHE_POOLS 1
  167. /*! Current pjproject pool caching enable */
  168. extern int ast_option_pjproject_cache_pools;
  169. /*! Current pjproject logging level */
  170. extern int ast_option_pjproject_log_level;
  171. extern struct ast_flags ast_options;
  172. extern int option_verbose;
  173. extern int ast_option_maxfiles; /*!< Max number of open file handles (files, sockets) */
  174. extern int option_debug; /*!< Debugging */
  175. extern int ast_option_maxcalls; /*!< Maximum number of simultaneous channels */
  176. extern unsigned int option_dtmfminduration; /*!< Minimum duration of DTMF (channel.c) in ms */
  177. extern double ast_option_maxload;
  178. #if defined(HAVE_SYSINFO)
  179. extern long option_minmemfree; /*!< Minimum amount of free system memory - stop accepting calls if free memory falls below this watermark */
  180. #endif
  181. extern char ast_defaultlanguage[];
  182. extern struct timeval ast_startuptime;
  183. extern struct timeval ast_lastreloadtime;
  184. extern pid_t ast_mainpid;
  185. extern char record_cache_dir[AST_CACHE_DIR_LEN];
  186. extern int ast_language_is_prefix;
  187. extern unsigned int ast_option_rtpptdynamic;
  188. #if defined(__cplusplus) || defined(c_plusplus)
  189. }
  190. #endif
  191. #endif /* _ASTERISK_OPTIONS_H */