diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/asterisk.h | 11 | ||||
-rw-r--r-- | include/asterisk/_private.h | 2 | ||||
-rw-r--r-- | include/asterisk/ari.h | 3 | ||||
-rw-r--r-- | include/asterisk/astmm.h | 26 | ||||
-rw-r--r-- | include/asterisk/autoconfig.h.in | 16 | ||||
-rw-r--r-- | include/asterisk/channel.h | 6 | ||||
-rw-r--r-- | include/asterisk/chanvars.h | 2 | ||||
-rw-r--r-- | include/asterisk/compiler.h | 6 | ||||
-rw-r--r-- | include/asterisk/config.h | 2 | ||||
-rw-r--r-- | include/asterisk/hashtab.h | 14 | ||||
-rw-r--r-- | include/asterisk/heap.h | 4 | ||||
-rw-r--r-- | include/asterisk/http.h | 1 | ||||
-rw-r--r-- | include/asterisk/ilbc.h | 8 | ||||
-rw-r--r-- | include/asterisk/pbx.h | 35 | ||||
-rw-r--r-- | include/asterisk/res_fax.h | 26 | ||||
-rw-r--r-- | include/asterisk/res_pjsip.h | 34 | ||||
-rw-r--r-- | include/asterisk/res_pjsip_session.h | 2 | ||||
-rw-r--r-- | include/asterisk/res_srtp.h | 14 | ||||
-rw-r--r-- | include/asterisk/sdp_srtp.h | 113 | ||||
-rw-r--r-- | include/asterisk/strings.h | 6 | ||||
-rw-r--r-- | include/asterisk/taskprocessor.h | 32 | ||||
-rw-r--r-- | include/asterisk/utils.h | 217 |
22 files changed, 403 insertions, 177 deletions
diff --git a/include/asterisk.h b/include/asterisk.h index ab2a3ddef..93c7cfb28 100644 --- a/include/asterisk.h +++ b/include/asterisk.h @@ -286,6 +286,17 @@ struct ast_module; /* Internal/forward declaration, AST_MODULE_SELF should be used instead. */ struct ast_module *AST_MODULE_SELF_SYM(void); +#else + +#error "Externally compiled modules must declare AST_MODULE_SELF_SYM." + #endif +/*! + * \brief Retrieve the PBX UUID + * \param pbx_uuid A buffer of at least AST_UUID_STR_LEN (36 + 1) size to receive the UUID + * \param length The buffer length + */ +int ast_pbx_uuid_get(char *pbx_uuid, int length); + #endif /* _ASTERISK_H */ diff --git a/include/asterisk/_private.h b/include/asterisk/_private.h index 6dbf24f4d..36b316f2a 100644 --- a/include/asterisk/_private.h +++ b/include/asterisk/_private.h @@ -29,7 +29,7 @@ void logger_queue_start(void); /*!< Provided by logger.c */ void clean_time_zones(void); /*!< Provided by localtime.c */ int ast_term_init(void); /*!< Provided by term.c */ int astdb_init(void); /*!< Provided by db.c */ -void ast_channels_init(void); /*!< Provided by channel.c */ +int ast_channels_init(void); /*!< Provided by channel.c */ void ast_builtins_init(void); /*!< Provided by cli.c */ int ast_cli_perms_init(int reload); /*!< Provided by cli.c */ int dnsmgr_init(void); /*!< Provided by dnsmgr.c */ diff --git a/include/asterisk/ari.h b/include/asterisk/ari.h index 79b9516eb..4019e94e3 100644 --- a/include/asterisk/ari.h +++ b/include/asterisk/ari.h @@ -146,10 +146,11 @@ void ast_ari_invoke(struct ast_tcptls_session_instance *ser, * for unit testing. * * \param uri Requested URI, relative to the docs path. + * \param prefix prefix that prefixes all http requests * \param headers HTTP headers. * \param[out] response RESTful HTTP response. */ -void ast_ari_get_docs(const char *uri, struct ast_variable *headers, struct ast_ari_response *response); +void ast_ari_get_docs(const char *uri, const char *prefix, struct ast_variable *headers, struct ast_ari_response *response); /*! \brief Abstraction for reading/writing JSON to a WebSocket */ struct ast_ari_websocket_session; diff --git a/include/asterisk/astmm.h b/include/asterisk/astmm.h index 83c34bed3..e129dc034 100644 --- a/include/asterisk/astmm.h +++ b/include/asterisk/astmm.h @@ -174,35 +174,11 @@ void __ast_mm_init_phase_2(void); #endif -/* Provide our own definitions */ - -#define ast_calloc(a,b) \ - __ast_calloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__) - -#define ast_calloc_cache(a,b) \ - __ast_calloc_cache(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__) - -#define ast_malloc(a) \ - __ast_malloc(a,__FILE__, __LINE__, __PRETTY_FUNCTION__) +/* Provide our own definition for ast_free */ #define ast_free(a) \ __ast_free(a,__FILE__, __LINE__, __PRETTY_FUNCTION__) -#define ast_realloc(a,b) \ - __ast_realloc(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__) - -#define ast_strdup(a) \ - __ast_strdup(a,__FILE__, __LINE__, __PRETTY_FUNCTION__) - -#define ast_strndup(a,b) \ - __ast_strndup(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__) - -#define ast_asprintf(a, b, c...) \ - __ast_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, a, b, c) - -#define ast_vasprintf(a,b,c) \ - __ast_vasprintf(a,b,c,__FILE__, __LINE__, __PRETTY_FUNCTION__) - #endif /* !STANDALONE */ #else diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in index 7d2a08c8a..f9a6b46e4 100644 --- a/include/asterisk/autoconfig.h.in +++ b/include/asterisk/autoconfig.h.in @@ -102,6 +102,9 @@ /* Define to 1 if your GCC C compiler supports the 'may_alias' attribute. */ #undef HAVE_ATTRIBUTE_may_alias +/* Define to 1 if your GCC C compiler supports the 'noreturn' attribute. */ +#undef HAVE_ATTRIBUTE_noreturn + /* Define to 1 if your GCC C compiler supports the 'pure' attribute. */ #undef HAVE_ATTRIBUTE_pure @@ -841,6 +844,16 @@ /* Define to 1 if you have the Secure RTP library. */ #undef HAVE_SRTP +/* Define to 1 if SRTP has the SRTP Library AES-192 (ICM) feature. */ +#undef HAVE_SRTP_192 + +/* Define to 1 if SRTP has the SRTP Library AES-256 (ICM) feature. */ +#undef HAVE_SRTP_256 + +/* Define to 1 if SRTP has the SRTP Library AES-128 (GCM) and AES-256 (GCM) + feature. */ +#undef HAVE_SRTP_GCM + /* Define to 1 if SRTP has the SRTP Library Shutdown Function feature. */ #undef HAVE_SRTP_SHUTDOWN @@ -1098,6 +1111,9 @@ /* Define to 1 if you have the unbound library. */ #undef HAVE_UNBOUND +/* Define if your system has UNBOUND_VERSION_MAJOR declared. */ +#undef HAVE_UNBOUND_CONST_PARAMS + /* Define to 1 if you have the <unistd.h> header file. */ #undef HAVE_UNISTD_H diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h index 14bd32c07..3293dd77b 100644 --- a/include/asterisk/channel.h +++ b/include/asterisk/channel.h @@ -2549,7 +2549,11 @@ static inline int ast_fdisset(struct pollfd *pfds, int fd, int maximum, int *sta return 0; } -/*! \brief Retrieves the current T38 state of a channel */ +/*! + * \brief Retrieves the current T38 state of a channel + * + * \note Absolutely _NO_ channel locks should be held before calling this function. + */ static inline enum ast_t38_state ast_channel_get_t38_state(struct ast_channel *chan) { enum ast_t38_state state = T38_STATE_UNAVAILABLE; diff --git a/include/asterisk/chanvars.h b/include/asterisk/chanvars.h index 3693e2a3a..2040c7b65 100644 --- a/include/asterisk/chanvars.h +++ b/include/asterisk/chanvars.h @@ -35,7 +35,7 @@ AST_LIST_HEAD_NOLOCK(varshead, ast_var_t); struct varshead *ast_var_list_create(void); void ast_var_list_destroy(struct varshead *head); -#ifdef MALLOC_DEBUG +#ifdef __AST_DEBUG_MALLOC struct ast_var_t *_ast_var_assign(const char *name, const char *value, const char *file, int lineno, const char *function); #define ast_var_assign(a,b) _ast_var_assign(a,b,__FILE__,__LINE__,__PRETTY_FUNCTION__) #else diff --git a/include/asterisk/compiler.h b/include/asterisk/compiler.h index 77b5de40e..6ceaa5f77 100644 --- a/include/asterisk/compiler.h +++ b/include/asterisk/compiler.h @@ -77,6 +77,12 @@ #define attribute_may_alias #endif +#ifdef HAVE_ATTRIBUTE_noreturn +#define attribute_noreturn __attribute__((noreturn)) +#else +#define attribute_noreturn +#endif + /* Some older version of GNU gcc (3.3.5 on OpenBSD 4.3 for example) dont like 'NULL' as sentinel */ #define SENTINEL ((char *)NULL) diff --git a/include/asterisk/config.h b/include/asterisk/config.h index 287635a8e..4944a3af2 100644 --- a/include/asterisk/config.h +++ b/include/asterisk/config.h @@ -907,7 +907,7 @@ void ast_category_destroy(struct ast_category *cat); struct ast_variable *ast_category_detach_variables(struct ast_category *cat); void ast_category_rename(struct ast_category *cat, const char *name); -#ifdef MALLOC_DEBUG +#ifdef __AST_DEBUG_MALLOC struct ast_variable *_ast_variable_new(const char *name, const char *value, const char *filename, const char *file, const char *function, int lineno); #define ast_variable_new(name, value, filename) _ast_variable_new(name, value, filename, __FILE__, __PRETTY_FUNCTION__, __LINE__) #else diff --git a/include/asterisk/hashtab.h b/include/asterisk/hashtab.h index 17eff7048..cfe035b28 100644 --- a/include/asterisk/hashtab.h +++ b/include/asterisk/hashtab.h @@ -251,7 +251,7 @@ unsigned int ast_hashtab_hash_short(const short num); * \param hash a func ptr to do the hashing * \param do_locking use locks to guarantee safety of iterators/insertion/deletion -- real simpleminded right now */ -#if (defined(MALLOC_DEBUG) && !defined(STANDALONE)) +#ifdef __AST_DEBUG_MALLOC struct ast_hashtab * _ast_hashtab_create(int initial_buckets, int (*compare)(const void *a, const void *b), int (*resize)(struct ast_hashtab *), @@ -294,7 +294,7 @@ void ast_hashtab_destroy( struct ast_hashtab *tab, void (*objdestroyfunc)(void * * \retval 1 on success * \retval 0 if there's a problem */ -#if (defined(MALLOC_DEBUG) && !defined(STANDALONE)) +#ifdef __AST_DEBUG_MALLOC int _ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj, const char *file, int lineno, const char *func); #define ast_hashtab_insert_immediate(a,b) _ast_hashtab_insert_immediate(a, b, __FILE__, __LINE__, __PRETTY_FUNCTION__) #else @@ -311,7 +311,7 @@ int ast_hashtab_insert_immediate(struct ast_hashtab *tab, const void *obj); * \retval 1 on success * \retval 0 if there's a problem */ -#if (defined(MALLOC_DEBUG) && !defined(STANDALONE)) +#ifdef __AST_DEBUG_MALLOC int _ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj, unsigned int h, const char *file, int lineno, const char *func); #define ast_hashtab_insert_immediate_bucket(a,b,c) _ast_hashtab_insert_immediate_bucket(a, b, c, __FILE__, __LINE__, __PRETTY_FUNCTION__) #else @@ -324,7 +324,7 @@ int ast_hashtab_insert_immediate_bucket(struct ast_hashtab *tab, const void *obj * \retval 1 on success * \retval 0 if there's a problem, or it's already there. */ -#if (defined(MALLOC_DEBUG) && !defined(STANDALONE)) +#ifdef __AST_DEBUG_MALLOC int _ast_hashtab_insert_safe(struct ast_hashtab *tab, const void *obj, const char *file, int lineno, const char *func); #define ast_hashtab_insert_safe(a,b) _ast_hashtab_insert_safe(a,b,__FILE__, __LINE__, __PRETTY_FUNCTION__) #else @@ -362,7 +362,7 @@ int ast_hashtab_size( struct ast_hashtab *tab); int ast_hashtab_capacity( struct ast_hashtab *tab); /*! \brief Return a copy of the hash table */ -#if (defined(MALLOC_DEBUG) && !defined(STANDALONE)) +#ifdef __AST_DEBUG_MALLOC struct ast_hashtab *_ast_hashtab_dup(struct ast_hashtab *tab, void *(*obj_dup_func)(const void *obj), const char *file, int lineno, const char *func); #define ast_hashtab_dup(a,b) _ast_hashtab_dup(a,b,__FILE__,__LINE__,__PRETTY_FUNCTION__) #else @@ -370,7 +370,7 @@ struct ast_hashtab *ast_hashtab_dup(struct ast_hashtab *tab, void *(*obj_dup_fun #endif /*! \brief Gives an iterator to hastable */ -#if (defined(MALLOC_DEBUG) && !defined(STANDALONE)) +#ifdef __AST_DEBUG_MALLOC struct ast_hashtab_iter *_ast_hashtab_start_traversal(struct ast_hashtab *tab, const char *file, int lineno, const char *func); #define ast_hashtab_start_traversal(a) _ast_hashtab_start_traversal(a,__FILE__,__LINE__,__PRETTY_FUNCTION__) #else @@ -395,7 +395,7 @@ void *ast_hashtab_remove_this_object(struct ast_hashtab *tab, void *obj); /* ------------------ */ /*! \brief Gives an iterator to hastable */ -#if (defined(MALLOC_DEBUG) && !defined(STANDALONE)) +#ifdef __AST_DEBUG_MALLOC struct ast_hashtab_iter *_ast_hashtab_start_write_traversal(struct ast_hashtab *tab, const char *file, int lineno, const char *func); #define ast_hashtab_start_write_traversal(a) _ast_hashtab_start_write_traversal(a,__FILE__,__LINE__,__PRETTY_FUNCTION__) #else diff --git a/include/asterisk/heap.h b/include/asterisk/heap.h index a868ac589..728327936 100644 --- a/include/asterisk/heap.h +++ b/include/asterisk/heap.h @@ -97,7 +97,7 @@ typedef int (*ast_heap_cmp_fn)(void *elm1, void *elm2); * \return An instance of a max heap * \since 1.6.1 */ -#ifdef MALLOC_DEBUG +#ifdef __AST_DEBUG_MALLOC struct ast_heap *_ast_heap_create(unsigned int init_height, ast_heap_cmp_fn cmp_fn, ssize_t index_offset, const char *file, int lineno, const char *func); #define ast_heap_create(a,b,c) _ast_heap_create(a,b,c,__FILE__,__LINE__,__PRETTY_FUNCTION__) @@ -126,7 +126,7 @@ struct ast_heap *ast_heap_destroy(struct ast_heap *h); * \retval non-zero failure * \since 1.6.1 */ -#ifdef MALLOC_DEBUG +#ifdef __AST_DEBUG_MALLOC int _ast_heap_push(struct ast_heap *h, void *elm, const char *file, int lineno, const char *func); #define ast_heap_push(a,b) _ast_heap_push(a,b,__FILE__,__LINE__,__PRETTY_FUNCTION__) #else diff --git a/include/asterisk/http.h b/include/asterisk/http.h index bb8973dce..d5f54cc65 100644 --- a/include/asterisk/http.h +++ b/include/asterisk/http.h @@ -101,6 +101,7 @@ struct ast_http_uri { AST_LIST_ENTRY(ast_http_uri) entry; const char *description; const char *uri; + const char *prefix; ast_http_callback callback; unsigned int has_subtree:1; /*! Structure is malloc'd */ diff --git a/include/asterisk/ilbc.h b/include/asterisk/ilbc.h new file mode 100644 index 000000000..2534367cd --- /dev/null +++ b/include/asterisk/ilbc.h @@ -0,0 +1,8 @@ +#ifndef _AST_FORMAT_ILBC_H_ +#define _AST_FORMAT_ILBC_H_ + +struct ilbc_attr { + unsigned int mode; +}; + +#endif /* _AST_FORMAT_ILBC_H */
\ No newline at end of file diff --git a/include/asterisk/pbx.h b/include/asterisk/pbx.h index 378bb556d..6da447034 100644 --- a/include/asterisk/pbx.h +++ b/include/asterisk/pbx.h @@ -1228,10 +1228,10 @@ const char *ast_get_context_name(struct ast_context *con); const char *ast_get_extension_name(struct ast_exten *exten); struct ast_context *ast_get_extension_context(struct ast_exten *exten); const char *ast_get_include_name(const struct ast_include *include); -const char *ast_get_ignorepat_name(struct ast_ignorepat *ip); -const char *ast_get_switch_name(struct ast_sw *sw); -const char *ast_get_switch_data(struct ast_sw *sw); -int ast_get_switch_eval(struct ast_sw *sw); +const char *ast_get_ignorepat_name(const struct ast_ignorepat *ip); +const char *ast_get_switch_name(const struct ast_sw *sw); +const char *ast_get_switch_data(const struct ast_sw *sw); +int ast_get_switch_eval(const struct ast_sw *sw); /*! @} */ @@ -1250,8 +1250,8 @@ void *ast_get_extension_app_data(struct ast_exten *e); const char *ast_get_context_registrar(struct ast_context *c); const char *ast_get_extension_registrar(struct ast_exten *e); const char *ast_get_include_registrar(const struct ast_include *i); -const char *ast_get_ignorepat_registrar(struct ast_ignorepat *ip); -const char *ast_get_switch_registrar(struct ast_sw *sw); +const char *ast_get_ignorepat_registrar(const struct ast_ignorepat *ip); +const char *ast_get_switch_registrar(const struct ast_sw *sw); /*! @} */ /*! @name Walking functions ... */ @@ -1263,15 +1263,20 @@ struct ast_exten *ast_walk_extension_priorities(struct ast_exten *exten, struct ast_exten *priority); const struct ast_include *ast_walk_context_includes(const struct ast_context *con, const struct ast_include *inc); -struct ast_ignorepat *ast_walk_context_ignorepats(struct ast_context *con, - struct ast_ignorepat *ip); -struct ast_sw *ast_walk_context_switches(struct ast_context *con, struct ast_sw *sw); +const struct ast_ignorepat *ast_walk_context_ignorepats(const struct ast_context *con, + const struct ast_ignorepat *ip); +const struct ast_sw *ast_walk_context_switches(const struct ast_context *con, + const struct ast_sw *sw); /*! @} */ /*! @name Iterator functions ... */ /*! @{ */ int ast_context_includes_count(const struct ast_context *con); const struct ast_include *ast_context_includes_get(const struct ast_context *con, int idx); +int ast_context_ignorepats_count(const struct ast_context *con); +const struct ast_ignorepat *ast_context_ignorepats_get(const struct ast_context *con, int idx); +int ast_context_switches_count(const struct ast_context *con); +const struct ast_sw *ast_context_switches_get(const struct ast_context *con, int idx); /*! @} */ /*! @@ -1613,6 +1618,18 @@ void pbx_live_dangerously(int new_live_dangerously); */ int ast_thread_inhibit_escalations(void); +/*! + * \brief Swap the current thread escalation inhibit setting. + * \since 11.24.0 + * + * \param inhibit New setting. Non-zero to inhibit. + * + * \retval 1 if dangerous function execution was inhibited. + * \retval 0 if dangerous function execution was allowed. + * \retval -1 on error. + */ +int ast_thread_inhibit_escalations_swap(int inhibit); + #if defined(__cplusplus) || defined(c_plusplus) } #endif diff --git a/include/asterisk/res_fax.h b/include/asterisk/res_fax.h index 2304da734..e88d8002f 100644 --- a/include/asterisk/res_fax.h +++ b/include/asterisk/res_fax.h @@ -20,16 +20,16 @@ #ifndef _ASTERISK_RES_FAX_H #define _ASTERISK_RES_FAX_H -#include <asterisk.h> -#include <asterisk/lock.h> -#include <asterisk/linkedlists.h> -#include <asterisk/module.h> -#include <asterisk/utils.h> -#include <asterisk/options.h> -#include <asterisk/frame.h> -#include <asterisk/cli.h> -#include <asterisk/stringfields.h> -#include <asterisk/manager.h> +#include "asterisk.h" +#include "asterisk/lock.h" +#include "asterisk/linkedlists.h" +#include "asterisk/module.h" +#include "asterisk/utils.h" +#include "asterisk/options.h" +#include "asterisk/frame.h" +#include "asterisk/cli.h" +#include "asterisk/stringfields.h" +#include "asterisk/manager.h" /*! \brief capabilities for res_fax to locate a fax technology module */ enum ast_fax_capabilities { @@ -179,14 +179,16 @@ struct ast_fax_session_details { unsigned int t38timeout; /*! the id of the t.38 gateway framehook for this channel */ int gateway_id; - /*! the timeout for this gateway in seconds */ + /*! The timeout for this gateway in ms */ int gateway_timeout; /*! the id of the faxdetect framehook for this channel */ int faxdetect_id; - /*! The timeout for this fax detect in seconds */ + /*! The timeout for this fax detect in ms */ int faxdetect_timeout; /*! flags used for fax detection */ int faxdetect_flags; + /*! Non-zero if T.38 is negotiated */ + int is_t38_negotiated; }; struct ast_fax_tech; diff --git a/include/asterisk/res_pjsip.h b/include/asterisk/res_pjsip.h index 6f5928365..4cede4391 100644 --- a/include/asterisk/res_pjsip.h +++ b/include/asterisk/res_pjsip.h @@ -749,10 +749,14 @@ struct ast_sip_endpoint { unsigned int usereqphone; /*! Whether to pass through hold and unhold using re-invites with recvonly and sendrecv */ unsigned int moh_passthrough; - /* Access control list */ + /*! Access control list */ struct ast_acl_list *acl; - /* Restrict what IPs are allowed in the Contact header (for registration) */ + /*! Restrict what IPs are allowed in the Contact header (for registration) */ struct ast_acl_list *contact_acl; + /*! The number of seconds into call to disable fax detection. (0 = disabled) */ + unsigned int faxdetect_timeout; + /*! Override the user on the outgoing Contact header with this value. */ + char *contact_user; }; /*! @@ -2415,6 +2419,32 @@ int ast_sip_register_supplement(struct ast_sip_supplement *supplement); void ast_sip_unregister_supplement(struct ast_sip_supplement *supplement); /*! + * \brief Retrieve the global MWI taskprocessor high water alert trigger level. + * + * \since 13.12.0 + * + * \retval the system MWI taskprocessor high water alert trigger level + */ +unsigned int ast_sip_get_mwi_tps_queue_high(void); + +/*! + * \brief Retrieve the global MWI taskprocessor low water clear alert level. + * + * \since 13.12.0 + * + * \retval the system MWI taskprocessor low water clear alert level + */ +int ast_sip_get_mwi_tps_queue_low(void); + +/*! + * \brief Retrieve the global setting 'disable sending unsolicited mwi on startup'. + * \since 13.12.0 + * + * \retval non zero if disable. + */ +unsigned int ast_sip_get_mwi_disable_initial_unsolicited(void); + +/*! * \brief Retrieve the system debug setting (yes|no|host). * * \note returned string needs to be de-allocated by caller. diff --git a/include/asterisk/res_pjsip_session.h b/include/asterisk/res_pjsip_session.h index 5ca2c99a5..26dd451a7 100644 --- a/include/asterisk/res_pjsip_session.h +++ b/include/asterisk/res_pjsip_session.h @@ -139,7 +139,7 @@ struct ast_sip_session { struct ast_party_id id; /*! Requested capabilities */ struct ast_format_cap *req_caps; - /*! Optional DSP, used only for inband DTMF detection if configured */ + /*! Optional DSP, used only for inband DTMF/Fax-CNG detection if configured */ struct ast_dsp *dsp; /*! Whether the termination of the session should be deferred */ unsigned int defer_terminate:1; diff --git a/include/asterisk/res_srtp.h b/include/asterisk/res_srtp.h index c7fdc40b7..741d4f9ac 100644 --- a/include/asterisk/res_srtp.h +++ b/include/asterisk/res_srtp.h @@ -21,6 +21,8 @@ #ifndef _ASTERISK_RES_SRTP_H #define _ASTERISK_RES_SRTP_H +#include "asterisk.h" /* for size_t */ + struct ast_srtp; struct ast_srtp_policy; struct ast_rtp_instance; @@ -52,9 +54,17 @@ struct ast_srtp_res { /* Crypto suites */ enum ast_srtp_suite { + /* https://www.iana.org/assignments/srtp-protection/srtp-protection.xhtml */ AST_AES_CM_128_HMAC_SHA1_80 = 1, - AST_AES_CM_128_HMAC_SHA1_32 = 2, - AST_F8_128_HMAC_SHA1_80 = 3 + AST_AES_CM_128_HMAC_SHA1_32, + AST_AES_CM_256_HMAC_SHA1_80, + AST_AES_CM_256_HMAC_SHA1_32, + AST_AES_GCM_128 = 7, + AST_AES_GCM_256, + AST_AES_GCM_128_8, + AST_AES_GCM_256_8, + AST_AES_CM_192_HMAC_SHA1_80, + AST_AES_CM_192_HMAC_SHA1_32, }; struct ast_srtp_policy_res { diff --git a/include/asterisk/sdp_srtp.h b/include/asterisk/sdp_srtp.h index 772c3c38d..cf89fa9e0 100644 --- a/include/asterisk/sdp_srtp.h +++ b/include/asterisk/sdp_srtp.h @@ -20,8 +20,7 @@ * * \brief SRTP and SDP Security descriptions * - * Specified in RFC 4568 - * Specified in RFC 3711 + * Specified in RFC 3711, 6188, 7714, and 4568 * * \author Mikael Magnusson <mikma@users.sourceforge.net> */ @@ -29,7 +28,8 @@ #ifndef _SDP_SRTP_H #define _SDP_SRTP_H -#include <asterisk/rtp_engine.h> +#include "asterisk/linkedlists.h" /* for AST_LIST_ENTRY */ +#include "asterisk/rtp_engine.h" /* for ast_rtp_instance */ struct ast_sdp_crypto; @@ -37,12 +37,18 @@ struct ast_sdp_crypto; struct ast_sdp_srtp { unsigned int flags; struct ast_sdp_crypto *crypto; + AST_LIST_ENTRY(ast_sdp_srtp) sdp_srtp_list; }; /* SRTP flags */ -#define AST_SRTP_CRYPTO_OFFER_OK (1 << 1) -#define AST_SRTP_CRYPTO_TAG_32 (1 << 2) -#define AST_SRTP_CRYPTO_TAG_80 (1 << 3) +#define AST_SRTP_CRYPTO_OFFER_OK (1 << 1) +#define AST_SRTP_CRYPTO_TAG_32 (1 << 2) +#define AST_SRTP_CRYPTO_TAG_80 (1 << 3) +#define AST_SRTP_CRYPTO_TAG_16 (1 << 4) +#define AST_SRTP_CRYPTO_TAG_8 (1 << 5) +#define AST_SRTP_CRYPTO_AES_192 (1 << 6) +#define AST_SRTP_CRYPTO_AES_256 (1 << 7) +#define AST_SRTP_CRYPTO_OLD_NAME (1 << 8) /*! * \brief allocate a ast_sdp_srtp structure @@ -57,6 +63,100 @@ struct ast_sdp_srtp *ast_sdp_srtp_alloc(void); */ void ast_sdp_srtp_destroy(struct ast_sdp_srtp *srtp); +/*! \brief Destroy a previously allocated ast_sdp_crypto struct */ +typedef void (*sdp_crypto_destroy_cb)(struct ast_sdp_crypto *crypto); + +/*! + * \brief Initialize and return an ast_sdp_crypto struct + * + * \details + * This function allocates a new ast_sdp_crypto struct and initializes its values + * + * \retval NULL on failure + * \retval a pointer to a new ast_sdp_crypto structure + */ +typedef struct ast_sdp_crypto *(*sdp_crypto_alloc_cb)(void); + +/*! + * \brief Generate an SRTP a=crypto offer + * + * \details + * The offer is stored on the ast_sdp_crypto struct in a_crypto + * + * \param crypto A valid ast_sdp_crypto struct + * \param taglen Length + * + * \retval 0 success + * \retval nonzero failure + */ +typedef int (*sdp_crypto_build_offer_cb)(struct ast_sdp_crypto *crypto, int taglen); + +/*! + * \brief Parse the a=crypto line from SDP and set appropriate values on the + * ast_sdp_crypto struct. + * + * The attribute line should already have "a=crypto:" removed. + * + * \param p A valid ast_sdp_crypto struct + * \param attr the a:crypto line from SDP + * \param rtp The rtp instance associated with the SDP being parsed + * \param srtp SRTP structure + * + * \retval 0 success + * \retval nonzero failure + */ +typedef int (*sdp_crypto_parse_offer_cb)(struct ast_rtp_instance *rtp, struct ast_sdp_srtp *srtp, const char *attr); + +/*! + * \brief Get the crypto attribute line for the srtp structure + * + * \details + * The attribute line does not contain the initial "a=crypto:" and does + * not terminate with "\r\n". + * + * \param srtp The ast_sdp_srtp structure for which to get an attribute line + * \param dtls_enabled Whether this connection is encrypted with datagram TLS + * \param default_taglen_32 Whether to default to a tag length of 32 instead of 80 + * + * \retval An attribute line containing cryptographic information + * \retval NULL if the srtp structure does not require an attribute line containing crypto information + */ +typedef const char *(*sdp_srtp_get_attr_cb)(struct ast_sdp_srtp *srtp, int dtls_enabled, int default_taglen_32); + +struct ast_sdp_crypto_api { + /*! Destroy a crypto struct */ + sdp_crypto_destroy_cb dtor; + /*! Allocate a crypto struct */ + sdp_crypto_alloc_cb alloc; + /*! Build a SDP a=crypto offer line parameter string */ + sdp_crypto_build_offer_cb build_offer; + /*! Parse a SDP a=crypto offer line parameter string */ + sdp_crypto_parse_offer_cb parse_offer; + /*! Get the SDP a=crypto offer line parameter string */ + sdp_srtp_get_attr_cb get_attr; +}; + +/*! + * \brief Register SDP SRTP crypto processing routines. + * \since 14.0.0 + * + * \param api Callbacks to register. + * + * \retval 0 on success. + * \retval -1 on error. + */ +int ast_sdp_crypto_register(struct ast_sdp_crypto_api *api); + +/*! + * \brief Unregister SDP SRTP crypto processing routines. + * \since 14.0.0 + * + * \param api Callbacks to unregister. + * + * \return Nothing + */ +void ast_sdp_crypto_unregister(struct ast_sdp_crypto_api *api); + /*! \brief Initialize an return an ast_sdp_crypto struct * * \details @@ -98,7 +198,6 @@ int ast_sdp_crypto_process(struct ast_rtp_instance *rtp, struct ast_sdp_srtp *sr */ int ast_sdp_crypto_build_offer(struct ast_sdp_crypto *p, int taglen); - /*! \brief Get the crypto attribute line for the srtp structure * * The attribute line does not contain the initial "a=crypto:" and does diff --git a/include/asterisk/strings.h b/include/asterisk/strings.h index 2ca75a69c..eb5b4e43c 100644 --- a/include/asterisk/strings.h +++ b/include/asterisk/strings.h @@ -616,7 +616,7 @@ int ast_regex_string_to_regex_pattern(const char *regex_string, struct ast_str * * \note The result of this function is dynamically allocated memory, and must * be free()'d after it is no longer needed. */ -#if (defined(MALLOC_DEBUG) && !defined(STANDALONE)) +#ifdef __AST_DEBUG_MALLOC #define ast_str_create(a) _ast_str_create(a,__FILE__,__LINE__,__PRETTY_FUNCTION__) AST_INLINE_API( struct ast_str * attribute_malloc _ast_str_create(size_t init_len, @@ -771,7 +771,7 @@ char *ast_str_truncate(struct ast_str *buf, ssize_t len), /*! * Make space in a new string (e.g. to read in data from a file) */ -#if (defined(MALLOC_DEBUG) && !defined(STANDALONE)) +#ifdef __AST_DEBUG_MALLOC AST_INLINE_API( int _ast_str_make_space(struct ast_str **buf, size_t new_len, const char *file, int lineno, const char *function), { @@ -964,7 +964,7 @@ enum { * through calling one of the other functions or macros defined in this * file. */ -#if (defined(MALLOC_DEBUG) && !defined(STANDALONE)) +#ifdef __AST_DEBUG_MALLOC int __attribute__((format(printf, 4, 0))) __ast_debug_str_helper(struct ast_str **buf, ssize_t max_len, int append, const char *fmt, va_list ap, const char *file, int lineno, const char *func); #define __ast_str_helper(a,b,c,d,e) __ast_debug_str_helper(a,b,c,d,e,__FILE__,__LINE__,__PRETTY_FUNCTION__) diff --git a/include/asterisk/taskprocessor.h b/include/asterisk/taskprocessor.h index e51122269..7c79036b3 100644 --- a/include/asterisk/taskprocessor.h +++ b/include/asterisk/taskprocessor.h @@ -242,6 +242,38 @@ int ast_taskprocessor_push_local(struct ast_taskprocessor *tps, int (*task_exe)(struct ast_taskprocessor_local *local), void *datap); /*! + * \brief Indicate the taskprocessor is suspended. + * + * \since 13.12.0 + * + * \param tps Task processor. + * \retval 0 success + * \retval -1 failure + */ +int ast_taskprocessor_suspend(struct ast_taskprocessor *tps); + +/*! + * \brief Indicate the taskprocessor is unsuspended. + * + * \since 13.12.0 + * + * \param tps Task processor. + * \retval 0 success + * \retval -1 failure + */ +int ast_taskprocessor_unsuspend(struct ast_taskprocessor *tps); + +/*! + * \brief Get the task processor suspend status + * + * \since 13.12.0 + * + * \param tps Task processor. + * \retval non-zero if the task processor is suspended + */ +int ast_taskprocessor_is_suspended(struct ast_taskprocessor *tps); + +/*! * \brief Pop a task off the taskprocessor and execute it. * * \since 12.0.0 diff --git a/include/asterisk/utils.h b/include/asterisk/utils.h index c7a473732..9789d34ee 100644 --- a/include/asterisk/utils.h +++ b/include/asterisk/utils.h @@ -533,19 +533,8 @@ long int ast_random(void); ast_log(LOG_ERROR, "Memory Allocation Failure in function %s at line %d of %s\n", func, lineno, file) #endif -/*! - * \brief A wrapper for malloc() - * - * ast_malloc() is a wrapper for malloc() that will generate an Asterisk log - * message in the case that the allocation fails. - * - * The argument and return value are the same as malloc() - */ -#define ast_malloc(len) \ - _ast_malloc((len), __FILE__, __LINE__, __PRETTY_FUNCTION__) - AST_INLINE_API( -void * attribute_malloc _ast_malloc(size_t len, const char *file, int lineno, const char *func), +void * attribute_malloc __ast_malloc(size_t len, const char *file, int lineno, const char *func), { void *p; @@ -559,19 +548,8 @@ void * attribute_malloc _ast_malloc(size_t len, const char *file, int lineno, co } ) -/*! - * \brief A wrapper for calloc() - * - * ast_calloc() is a wrapper for calloc() that will generate an Asterisk log - * message in the case that the allocation fails. - * - * The arguments and return value are the same as calloc() - */ -#define ast_calloc(num, len) \ - _ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) - AST_INLINE_API( -void * attribute_malloc _ast_calloc(size_t num, size_t len, const char *file, int lineno, const char *func), +void * attribute_malloc __ast_calloc(size_t num, size_t len, const char *file, int lineno, const char *func), { void *p; @@ -585,6 +563,98 @@ void * attribute_malloc _ast_calloc(size_t num, size_t len, const char *file, in } ) +AST_INLINE_API( +void * attribute_malloc __ast_realloc(void *p, size_t len, const char *file, int lineno, const char *func), +{ + void *newp; + + DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL); + + if (!(newp = realloc(p, len))) { + MALLOC_FAILURE_MSG; + } + + return newp; +} +) + +AST_INLINE_API( +char * attribute_malloc __ast_strdup(const char *str, const char *file, int lineno, const char *func), +{ + char *newstr = NULL; + + DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL); + + if (str) { + if (!(newstr = strdup(str))) { + MALLOC_FAILURE_MSG; + } + } + + return newstr; +} +) + +AST_INLINE_API( +char * attribute_malloc __ast_strndup(const char *str, size_t len, const char *file, int lineno, const char *func), +{ + char *newstr = NULL; + + DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL); + + if (str) { + if (!(newstr = strndup(str, len))) { + MALLOC_FAILURE_MSG; + } + } + + return newstr; +} +) + +int __attribute__((format(printf, 5, 6))) + __ast_asprintf(const char *file, int lineno, const char *func, char **ret, const char *fmt, ...); + +AST_INLINE_API( +__attribute__((format(printf, 2, 0))) +int __ast_vasprintf(char **ret, const char *fmt, va_list ap, const char *file, int lineno, const char *func), +{ + int res; + + DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, -1); + + if ((res = vasprintf(ret, fmt, ap)) == -1) { + MALLOC_FAILURE_MSG; + } + + return res; +} +) + +#endif /* AST_DEBUG_MALLOC */ + +/*! + * \brief A wrapper for malloc() + * + * ast_malloc() is a wrapper for malloc() that will generate an Asterisk log + * message in the case that the allocation fails. + * + * The argument and return value are the same as malloc() + */ +#define ast_malloc(len) \ + __ast_malloc((len), __FILE__, __LINE__, __PRETTY_FUNCTION__) + +/*! + * \brief A wrapper for calloc() + * + * ast_calloc() is a wrapper for calloc() that will generate an Asterisk log + * message in the case that the allocation fails. + * + * The arguments and return value are the same as calloc() + */ +#define ast_calloc(num, len) \ + __ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) + /*! * \brief A wrapper for calloc() for use in cache pools * @@ -596,7 +666,7 @@ void * attribute_malloc _ast_calloc(size_t num, size_t len, const char *file, in * The arguments and return value are the same as calloc() */ #define ast_calloc_cache(num, len) \ - _ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) + __ast_calloc((num), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) /*! * \brief A wrapper for realloc() @@ -607,22 +677,7 @@ void * attribute_malloc _ast_calloc(size_t num, size_t len, const char *file, in * The arguments and return value are the same as realloc() */ #define ast_realloc(p, len) \ - _ast_realloc((p), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) - -AST_INLINE_API( -void * attribute_malloc _ast_realloc(void *p, size_t len, const char *file, int lineno, const char *func), -{ - void *newp; - - DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL); - - if (!(newp = realloc(p, len))) { - MALLOC_FAILURE_MSG; - } - - return newp; -} -) + __ast_realloc((p), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) /*! * \brief A wrapper for strdup() @@ -637,24 +692,7 @@ void * attribute_malloc _ast_realloc(void *p, size_t len, const char *file, int * The argument and return value are the same as strdup() */ #define ast_strdup(str) \ - _ast_strdup((str), __FILE__, __LINE__, __PRETTY_FUNCTION__) - -AST_INLINE_API( -char * attribute_malloc _ast_strdup(const char *str, const char *file, int lineno, const char *func), -{ - char *newstr = NULL; - - DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL); - - if (str) { - if (!(newstr = strdup(str))) { - MALLOC_FAILURE_MSG; - } - } - - return newstr; -} -) + __ast_strdup((str), __FILE__, __LINE__, __PRETTY_FUNCTION__) /*! * \brief A wrapper for strndup() @@ -669,24 +707,7 @@ char * attribute_malloc _ast_strdup(const char *str, const char *file, int linen * The arguments and return value are the same as strndup() */ #define ast_strndup(str, len) \ - _ast_strndup((str), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) - -AST_INLINE_API( -char * attribute_malloc _ast_strndup(const char *str, size_t len, const char *file, int lineno, const char *func), -{ - char *newstr = NULL; - - DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL); - - if (str) { - if (!(newstr = strndup(str, len))) { - MALLOC_FAILURE_MSG; - } - } - - return newstr; -} -) + __ast_strndup((str), (len), __FILE__, __LINE__, __PRETTY_FUNCTION__) /*! * \brief A wrapper for asprintf() @@ -697,10 +718,7 @@ char * attribute_malloc _ast_strndup(const char *str, size_t len, const char *fi * The arguments and return value are the same as asprintf() */ #define ast_asprintf(ret, fmt, ...) \ - _ast_asprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, fmt, __VA_ARGS__) - -int __attribute__((format(printf, 5, 6))) - _ast_asprintf(char **ret, const char *file, int lineno, const char *func, const char *fmt, ...); + __ast_asprintf(__FILE__, __LINE__, __PRETTY_FUNCTION__, (ret), (fmt), __VA_ARGS__) /*! * \brief A wrapper for vasprintf() @@ -711,25 +729,7 @@ int __attribute__((format(printf, 5, 6))) * The arguments and return value are the same as vasprintf() */ #define ast_vasprintf(ret, fmt, ap) \ - _ast_vasprintf((ret), __FILE__, __LINE__, __PRETTY_FUNCTION__, (fmt), (ap)) - -AST_INLINE_API( -__attribute__((format(printf, 5, 0))) -int _ast_vasprintf(char **ret, const char *file, int lineno, const char *func, const char *fmt, va_list ap), -{ - int res; - - DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, -1); - - if ((res = vasprintf(ret, fmt, ap)) == -1) { - MALLOC_FAILURE_MSG; - } - - return res; -} -) - -#endif /* AST_DEBUG_MALLOC */ + __ast_vasprintf((ret), (fmt), (ap), __FILE__, __LINE__, __PRETTY_FUNCTION__) /*! \brief call __builtin_alloca to ensure we get gcc builtin semantics @@ -843,9 +843,14 @@ struct ast_http_digest { */ int ast_parse_digest(const char *digest, struct ast_http_digest *d, int request, int pedantic); +#ifdef DO_CRASH +#define DO_CRASH_NORETURN attribute_noreturn +#else +#define DO_CRASH_NORETURN +#endif #ifdef AST_DEVMODE -void __ast_assert_failed(int condition, const char *condition_str, const char *file, int line, const char *function); +void DO_CRASH_NORETURN __ast_assert_failed(int condition, const char *condition_str, const char *file, int line, const char *function); #define ast_assert(a) _ast_assert(a, # a, __FILE__, __LINE__, __PRETTY_FUNCTION__) static void force_inline _ast_assert(int condition, const char *condition_str, const char *file, int line, const char *function) { @@ -864,7 +869,7 @@ static void force_inline _ast_assert(int condition, const char *condition_str, c * * \return Nothing */ -void ast_do_crash(void); +void DO_CRASH_NORETURN ast_do_crash(void); #include "asterisk/strings.h" @@ -968,6 +973,14 @@ int ast_str_to_eid(struct ast_eid *eid, const char *s); int ast_eid_cmp(const struct ast_eid *eid1, const struct ast_eid *eid2); /*! + * \brief Check if EID is empty + * + * \return 1 if the EID is empty, zero otherwise + * \since 13.12.0 + */ +int ast_eid_is_empty(const struct ast_eid *eid); + +/*! * \brief Get current thread ID * \return the ID if platform is supported, else -1 */ |