summaryrefslogtreecommitdiff
path: root/include/asterisk
diff options
context:
space:
mode:
Diffstat (limited to 'include/asterisk')
-rw-r--r--include/asterisk/stasis.h40
-rw-r--r--include/asterisk/stasis_app.h7
-rw-r--r--include/asterisk/stasis_bridges.h7
-rw-r--r--include/asterisk/stasis_channels.h7
-rw-r--r--include/asterisk/stasis_endpoints.h5
5 files changed, 60 insertions, 6 deletions
diff --git a/include/asterisk/stasis.h b/include/asterisk/stasis.h
index 955bdc3fc..6bc5171e0 100644
--- a/include/asterisk/stasis.h
+++ b/include/asterisk/stasis.h
@@ -187,6 +187,36 @@ struct stasis_message_type;
struct stasis_message;
/*!
+ * \brief Structure containing callbacks for Stasis message sanitization
+ *
+ * \note If either callback is implemented, both should be implemented since
+ * not all callers may have access to the full snapshot.
+ */
+struct stasis_message_sanitizer {
+ /*!
+ * \brief Callback which determines whether a channel should be sanitized from
+ * a message based on the channel's unique ID
+ *
+ * \param channel_id The unique ID of the channel
+ *
+ * \retval non-zero if the channel should be left out of the message
+ * \retval zero if the channel should remain in the message
+ */
+ int (*channel_id)(const char *channel_id);
+
+ /*!
+ * \brief Callback which determines whether a channel should be sanitized from
+ * a message based on the channel's snapshot
+ *
+ * \param snapshot A snapshot generated from the channel
+ *
+ * \retval non-zero if the channel should be left out of the message
+ * \retval zero if the channel should remain in the message
+ */
+ int (*channel_snapshot)(const struct ast_channel_snapshot *snapshot);
+};
+
+/*!
* \brief Virtual table providing methods for messages.
* \since 12
*/
@@ -198,17 +228,19 @@ struct stasis_message_vtable {
* The returned object should be ast_json_unref()'ed.
*
* \param message Message to convert to JSON string.
+ * \param sanitize Snapshot sanitization callback.
+ *
* \return Newly allocated JSON message.
* \return \c NULL on error.
* \return \c NULL if JSON format is not supported.
*/
- struct ast_json *(*to_json)(struct stasis_message *message);
+ struct ast_json *(*to_json)(struct stasis_message *message, const struct stasis_message_sanitizer *sanitize);
/*!
* \brief Build the AMI representation of the message.
*
* May be \c NULL, or may return \c NULL, to indicate no representation.
- * The returned object should be ao2_cleankup()'ed.
+ * The returned object should be ao2_cleanup()'ed.
*
* \param message Message to convert to AMI string.
* \return Newly allocated \ref ast_manager_event_blob.
@@ -292,11 +324,13 @@ const struct timeval *stasis_message_timestamp(const struct stasis_message *msg)
* be ast_json_unref()'ed.
*
* \param message Message to convert to JSON string.
+ * \param sanitize Snapshot sanitization callback.
+ *
* \return Newly allocated string with JSON message.
* \return \c NULL on error.
* \return \c NULL if JSON format is not supported.
*/
-struct ast_json *stasis_message_to_json(struct stasis_message *message);
+struct ast_json *stasis_message_to_json(struct stasis_message *message, struct stasis_message_sanitizer *sanitize);
/*!
* \brief Build the AMI representation of the message.
diff --git a/include/asterisk/stasis_app.h b/include/asterisk/stasis_app.h
index 801b7adb2..4ef55b193 100644
--- a/include/asterisk/stasis_app.h
+++ b/include/asterisk/stasis_app.h
@@ -532,6 +532,13 @@ void stasis_app_ref(void);
*/
void stasis_app_unref(void);
+/*!
+ * \brief Get the Stasis message sanitizer for app_stasis applications
+ *
+ * \retval The stasis message sanitizer
+ */
+struct stasis_message_sanitizer *stasis_app_get_sanitizer(void);
+
/*! @} */
#endif /* _ASTERISK_STASIS_APP_H */
diff --git a/include/asterisk/stasis_bridges.h b/include/asterisk/stasis_bridges.h
index d82bcffaf..9412bf0b7 100644
--- a/include/asterisk/stasis_bridges.h
+++ b/include/asterisk/stasis_bridges.h
@@ -231,10 +231,15 @@ void ast_bridge_publish_leave(struct ast_bridge *bridge, struct ast_channel *cha
/*!
* \brief Build a JSON object from a \ref ast_bridge_snapshot.
+ *
+ * \param snapshot The bridge snapshot to convert to JSON
+ * \param sanitize The message sanitizer to use on the snapshot
+ *
* \return JSON object representing bridge snapshot.
* \return \c NULL on error
*/
-struct ast_json *ast_bridge_snapshot_to_json(const struct ast_bridge_snapshot *snapshot);
+struct ast_json *ast_bridge_snapshot_to_json(const struct ast_bridge_snapshot *snapshot,
+ const struct stasis_message_sanitizer *sanitize);
/*!
* \brief Pair showing a bridge snapshot and a specific channel snapshot belonging to the bridge
diff --git a/include/asterisk/stasis_channels.h b/include/asterisk/stasis_channels.h
index 7d9c3efdc..519a4b676 100644
--- a/include/asterisk/stasis_channels.h
+++ b/include/asterisk/stasis_channels.h
@@ -541,10 +541,15 @@ void ast_publish_channel_state(struct ast_channel *chan);
/*!
* \brief Build a JSON object from a \ref ast_channel_snapshot.
+ *
+ * \param snapshot The snapshot to convert to JSON
+ * \param sanitize The message sanitizer to use on the snapshot
+ *
* \return JSON object representing channel snapshot.
* \return \c NULL on error
*/
-struct ast_json *ast_channel_snapshot_to_json(const struct ast_channel_snapshot *snapshot);
+struct ast_json *ast_channel_snapshot_to_json(const struct ast_channel_snapshot *snapshot,
+ const struct stasis_message_sanitizer *sanitize);
/*!
* \brief Compares the context, exten and priority of two snapshots.
diff --git a/include/asterisk/stasis_endpoints.h b/include/asterisk/stasis_endpoints.h
index 0ba233bf8..1d56a8fea 100644
--- a/include/asterisk/stasis_endpoints.h
+++ b/include/asterisk/stasis_endpoints.h
@@ -208,11 +208,14 @@ struct ast_endpoint_snapshot *ast_endpoint_latest_snapshot(const char *tech,
* \brief Build a JSON object from a \ref ast_endpoint_snapshot.
*
* \param snapshot Endpoint snapshot.
+ * \param sanitize The message sanitizer to use on the snapshot
+ *
* \return JSON object representing endpoint snapshot.
* \return \c NULL on error
*/
struct ast_json *ast_endpoint_snapshot_to_json(
- const struct ast_endpoint_snapshot *snapshot);
+ const struct ast_endpoint_snapshot *snapshot,
+ const struct stasis_message_sanitizer *sanitize);
/*!
* \brief Initialization function for endpoint stasis support.