summaryrefslogtreecommitdiff
path: root/include/asterisk
diff options
context:
space:
mode:
authorKevin Harwell <kharwell@digium.com>2013-09-27 18:28:41 +0000
committerKevin Harwell <kharwell@digium.com>2013-09-27 18:28:41 +0000
commitd6bceb035019a3df16a3b71da6e855ea249c94a5 (patch)
tree026f75862cd4ef54733b72018d6ac587037e4330 /include/asterisk
parent7e2a72771dbd538d8c72865406ca5aabb883d9d9 (diff)
res_pjsip: crash when using localnet and external_signaling_address options
There was a collision of mod_data use on the transaction between using a nat hook and an session response callback. During state change it was assumed what was in the mod_data was nothing or the response callback. However, it was possible for it to also contain a nat hook thus resulting in a bad cast and a crash. Added the ability to store multiple data elements in mod_data via a hash table. In this instance, mod_data now stores a hash table of the two values that can be retrieved using an associated string key. (closes issue ASTERISK-22394) Reported by: Rusty Newton Review: https://reviewboard.asterisk.org/r/2843/ ........ Merged revisions 399990 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@399991 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include/asterisk')
-rw-r--r--include/asterisk/res_pjsip.h56
1 files changed, 56 insertions, 0 deletions
diff --git a/include/asterisk/res_pjsip.h b/include/asterisk/res_pjsip.h
index 9ba2e90c7..8c7872084 100644
--- a/include/asterisk/res_pjsip.h
+++ b/include/asterisk/res_pjsip.h
@@ -1504,4 +1504,60 @@ int ast_sip_add_global_response_header(const char *name, const char *value, int
int ast_sip_initialize_sorcery_global(struct ast_sorcery *sorcery);
+/*!
+ * \brief Retrieves the value associated with the given key.
+ *
+ * \param ht the hash table/dictionary to search
+ * \param key the key to find
+ *
+ * \retval the value associated with the key, NULL otherwise.
+ */
+void *ast_sip_dict_get(void *ht, const char *key);
+
+/*!
+ * \brief Using the dictionary stored in mod_data array at a given id,
+ * retrieve the value associated with the given key.
+ *
+ * \param mod_data a module data array
+ * \param id the mod_data array index
+ * \param key the key to find
+ *
+ * \retval the value associated with the key, NULL otherwise.
+ */
+#define ast_sip_mod_data_get(mod_data, id, key) \
+ ast_sip_dict_get(mod_data[id], key)
+
+/*!
+ * \brief Set the value for the given key.
+ *
+ * Note - if the hash table does not exist one is created first, the key/value
+ * pair is set, and the hash table returned.
+ *
+ * \param pool the pool to allocate memory in
+ * \param ht the hash table/dictionary in which to store the key/value pair
+ * \param key the key to associate a value with
+ * \param val the value to associate with a key
+ *
+ * \retval the given, or newly created, hash table.
+ */
+void *ast_sip_dict_set(pj_pool_t* pool, void *ht,
+ const char *key, void *val);
+
+/*!
+ * \brief Utilizing a mod_data array for a given id, set the value
+ * associated with the given key.
+ *
+ * For a given structure's mod_data array set the element indexed by id to
+ * be a dictionary containing the key/val pair.
+ *
+ * \param pool a memory allocation pool
+ * \param mod_data a module data array
+ * \param id the mod_data array index
+ * \param key the key to find
+ * \param val the value to associate with a key
+ */
+#define ast_sip_mod_data_set(pool, mod_data, id, key, val) \
+ mod_data[id] = ast_sip_dict_set(pool, mod_data[id], key, val)
+
+
#endif /* _RES_PJSIP_H */