func_hangupcause.c: Add access to Reason headers via HANGUPCAUSE()

As soon as SIP call may end with several Reason headers, we
want to make all of them available through the HAGUPCAUSE() function.
This implementation uses the same ao2 hash for cause codes storage
and adds a flag to make difference between last processed sip
message and content of reason headers.

UserNote: Added a new option to HANGUPCAUSE to access additional
information about hangup reason. Reason headers from pjsip
could be read using 'tech_extended' cause type.
This commit is contained in:
Igor Goncharovsky
2025-09-04 10:54:27 +06:00
parent e6bb467b4a
commit 3486a5d569
5 changed files with 125 additions and 15 deletions

View File

@@ -4532,6 +4532,24 @@ struct ast_str *ast_channel_dialed_causes_channels(const struct ast_channel *cha
*/
struct ast_control_pvt_cause_code *ast_channel_dialed_causes_find(const struct ast_channel *chan, const char *chan_name);
/*!
* \since 20.17.0, 22.8.0, 23.1.0
* \brief Retrieve a ref-counted cause code information structure iterator
*
* \details
* This function makes use of datastore operations on the channel, so
* it is important to lock the channel before calling this function.
* This function increases the ref count of the returned object, so the
* calling function must decrease the reference count when it is finished
* with the object.
*
* \param chan The channel from which to retrieve information
* \param chan_name The name of the channel about which to retrieve information
* \retval NULL on search failure
* \retval Pointer to a ao2_iterator object containing the desired information
*/
struct ao2_iterator *ast_channel_dialed_causes_find_multiple(const struct ast_channel *chan, const char *chan_name);
/*!
* \since 11
* \brief Add cause code information to the channel

View File

@@ -417,6 +417,7 @@ enum ast_control_transfer {
struct ast_control_pvt_cause_code {
char chan_name[AST_CHANNEL_NAME]; /*!< Name of the channel that originated the cause information */
unsigned int emulate_sip_cause:1; /*!< Indicates whether this should be used to emulate SIP_CAUSE support */
unsigned int cause_extended:1; /*!< Indicates whether this cause code was retrieved from supplementary sources */
int ast_cause; /*!< Asterisk cause code associated with this message */
char code[1]; /*!< Tech-specific cause code information, beginning with the name of the tech */
};