summaryrefslogtreecommitdiff
path: root/include/asterisk
diff options
context:
space:
mode:
authorMatthew Jordan <mjordan@digium.com>2013-01-02 18:11:59 +0000
committerMatthew Jordan <mjordan@digium.com>2013-01-02 18:11:59 +0000
commit8fb5bdce9ab9f7f3758545753cbc787653920753 (patch)
tree65809194af8a4fa757fef26a30a2cc9c3ed02182 /include/asterisk
parent1fb06fde957fb466388c764384c2e14698e2dc15 (diff)
Prevent exhaustion of system resources through exploitation of event cache
Asterisk maintains an internal cache for devices in the event subsystem. The device state cache holds the state of each device known to Asterisk, such that consumers of device state information can query for the last known state for a particular device, even if it is not part of an active call. The concept of a device in Asterisk can include entities that do not have a physical representation. One way that this occurred was when anonymous calls are allowed in Asterisk. A device was automatically created and stored in the cache for each anonymous call that occurred; this was possible in the SIP and IAX2 channel drivers and through channel drivers that utilized the res_jabber/res_xmpp resource modules (Gtalk, Jingle, and Motif). These devices are never removed from the system, allowing anonymous calls to potentially exhaust a system's resources. This patch changes the event cache subsystem and device state management to no longer cache devices that are not associated with a physical entity. (issue ASTERISK-20175) Reported by: Russell Bryant, Leif Madsen, Joshua Colp Tested by: kmoore patches: event-cachability-3.diff uploaded by jcolp (license 5000) ........ Merged revisions 378303 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 378320 from http://svn.asterisk.org/svn/asterisk/branches/10 ........ Merged revisions 378321 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@378322 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include/asterisk')
-rw-r--r--include/asterisk/channel.h6
-rw-r--r--include/asterisk/devicestate.h16
-rw-r--r--include/asterisk/event_defs.h8
3 files changed, 26 insertions, 4 deletions
diff --git a/include/asterisk/channel.h b/include/asterisk/channel.h
index 0157d761e..9b408660b 100644
--- a/include/asterisk/channel.h
+++ b/include/asterisk/channel.h
@@ -903,6 +903,12 @@ enum {
* some non-traditional dialplans (like AGI) to continue to function.
*/
AST_FLAG_DISABLE_WORKAROUNDS = (1 << 20),
+ /*! Disable device state event caching. This allows allows channel
+ * drivers to selectively prevent device state events from being cached
+ * by certain channels such as anonymous calls which have no persistent
+ * represenatation that can be tracked.
+ */
+ AST_FLAG_DISABLE_DEVSTATE_CACHE = (1 << 21),
};
/*! \brief ast_bridge_config flags */
diff --git a/include/asterisk/devicestate.h b/include/asterisk/devicestate.h
index 66ca2bd1a..86740bc2f 100644
--- a/include/asterisk/devicestate.h
+++ b/include/asterisk/devicestate.h
@@ -61,6 +61,14 @@ enum ast_device_state {
AST_DEVICE_TOTAL, /*/ Total num of device states, used for testing */
};
+/*! \brief Device State Cachability
+ * \note This is used to define the cachability of a device state when set.
+ */
+enum ast_devstate_cache {
+ AST_DEVSTATE_NOT_CACHABLE, /*!< This device state is not cachable */
+ AST_DEVSTATE_CACHABLE, /*!< This device state is cachable */
+};
+
/*! \brief Devicestate provider call back */
typedef enum ast_device_state (*ast_devstate_prov_cb_type)(const char *data);
@@ -129,6 +137,7 @@ enum ast_device_state ast_device_state(const char *device);
* \brief Tells Asterisk the State for Device is changed
*
* \param state the new state of the device
+ * \param cachable whether this device state is cachable
* \param fmt device name like a dial string with format parameters
*
* The new state of the device will be sent off to any subscribers
@@ -138,13 +147,14 @@ enum ast_device_state ast_device_state(const char *device);
* \retval 0 on success
* \retval -1 on failure
*/
-int ast_devstate_changed(enum ast_device_state state, const char *fmt, ...)
- __attribute__((format(printf, 2, 3)));
+int ast_devstate_changed(enum ast_device_state state, enum ast_devstate_cache cachable, const char *fmt, ...)
+ __attribute__((format(printf, 3, 4)));
/*!
* \brief Tells Asterisk the State for Device is changed
*
* \param state the new state of the device
+ * \param cachable whether this device state is cachable
* \param device device name like a dial string with format parameters
*
* The new state of the device will be sent off to any subscribers
@@ -154,7 +164,7 @@ int ast_devstate_changed(enum ast_device_state state, const char *fmt, ...)
* \retval 0 on success
* \retval -1 on failure
*/
-int ast_devstate_changed_literal(enum ast_device_state state, const char *device);
+int ast_devstate_changed_literal(enum ast_device_state state, enum ast_devstate_cache cachable, const char *device);
/*!
* \brief Tells Asterisk the State for Device is changed.
diff --git a/include/asterisk/event_defs.h b/include/asterisk/event_defs.h
index d3514f59c..10c76d0da 100644
--- a/include/asterisk/event_defs.h
+++ b/include/asterisk/event_defs.h
@@ -298,8 +298,14 @@ enum ast_event_ie_type {
AST_EVENT_IE_PRESENCE_SUBTYPE = 0x003b,
AST_EVENT_IE_PRESENCE_MESSAGE = 0x003c,
+ /*!
+ * \brief Event non-cachability flag
+ * Used by: All events
+ * Payload type: UINT
+ */
+ AST_EVENT_IE_CACHABLE = 0x003d,
/*! \brief Must be the last IE value +1 */
- AST_EVENT_IE_TOTAL = 0x003d,
+ AST_EVENT_IE_TOTAL = 0x003e,
};
/*!