summaryrefslogtreecommitdiff
path: root/include/asterisk/channel.h
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2016-10-17 14:18:57 -0500
committerMark Michelson <mmichelson@digium.com>2016-10-20 12:59:06 -0500
commite459b8dadf42a3a015b312dfa9aadf507b4c85d9 (patch)
tree283ece75c7142c563e26a85e616a7cb50a91d5ca /include/asterisk/channel.h
parente03364c40aa073b69ca8c6652fd17a91908b9aaf (diff)
ARI: Detect duplicate channel IDs
ARI and AMI allow for an explicit channel ID to be specified when originating channels. Unfortunately, there is nothing in place to prevent someone from using the same ID for multiple channels. Further complicating things, adding ID validation to channel allocation makes it impossible for ARI to discern why channel allocation failed, resulting in a vague error code being returned. The fix for this is to institute a new method for channel errors to be discerned. The method mirrors errno, in that when an error occurs, the caller can consult the channel errno value to determine what the error was. This initial iteration of the feature only introduces "unknown" and "channel ID exists" errors. However, it's possible to add more errors as needed. ARI uses this feature to determine why channel allocation failed and can return a 409 error during origination to show that a channel with the given ID already exists. ASTERISK-26421 Change-Id: Ibba7ae68842dab6df0c2e9c45559208bc89d3d06
Diffstat (limited to 'include/asterisk/channel.h')
-rw-r--r--include/asterisk/channel.h12
1 files changed, 12 insertions, 0 deletions
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index df752c902..ff92cc878 100644
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -4659,4 +4659,16 @@ int ast_channel_feature_hooks_append(struct ast_channel *chan, struct ast_bridge
*/
int ast_channel_feature_hooks_replace(struct ast_channel *chan, struct ast_bridge_features *features);
+enum ast_channel_error {
+ /* Unable to determine what error occurred. */
+ AST_CHANNEL_ERROR_UNKNOWN,
+ /* Channel with this ID already exists */
+ AST_CHANNEL_ERROR_ID_EXISTS,
+};
+
+/*!
+ * \brief Get error code for latest channel operation.
+ */
+enum ast_channel_error ast_channel_errno(void);
+
#endif /* _ASTERISK_CHANNEL_H */