summaryrefslogtreecommitdiff
path: root/include/asterisk
diff options
context:
space:
mode:
authorGeorge Joseph <george.joseph@fairview5.com>2014-03-08 16:50:36 +0000
committerGeorge Joseph <george.joseph@fairview5.com>2014-03-08 16:50:36 +0000
commit3ff60b75b144d70034a768fc7d7da4537bf7cd7a (patch)
tree41509c60312f10e14a72c4f3a6bf37bb85c06cb9 /include/asterisk
parent5ca081e05369e2611048ac942f6c48e4814e4fe2 (diff)
pjsip_cli: Create pjsip show channel and contact, and general cli code cleanup.
Created the 'pjsip show channel' and 'pjsip show contact' commands. Refactored out the hated ast_hashtab. Replaced with ao2_container. Cleaned up function naming. Internal only, no public name changes. Cleaned up whitespace and brace formatting in cli code. Changed some NULL checking from "if"s to ast_asserts. Fixed some register/unregister ordering to reduce deadlock potential. Fixed ast_sip_location_add_contact where the 'name' buffer was too short. Fixed some self-assignment issues in res_pjsip_outbound_registration. (closes issue ASTERISK-23276) Review: http://reviewboard.asterisk.org/r/3283/ ........ Merged revisions 410287 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@410288 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'include/asterisk')
-rw-r--r--include/asterisk/res_pjsip.h16
-rw-r--r--include/asterisk/res_pjsip_cli.h33
-rw-r--r--include/asterisk/sorcery.h14
3 files changed, 48 insertions, 15 deletions
diff --git a/include/asterisk/res_pjsip.h b/include/asterisk/res_pjsip.h
index 80919c7d8..181a26ef7 100644
--- a/include/asterisk/res_pjsip.h
+++ b/include/asterisk/res_pjsip.h
@@ -223,6 +223,19 @@ struct ast_sip_aor {
};
/*!
+ * \brief A wrapper for contact that adds the aor_id and
+ * a consistent contact id. Used by ast_sip_for_each_contact.
+ */
+struct ast_sip_contact_wrapper {
+ /*! The id of the parent aor. */
+ char *aor_id;
+ /*! The id of contact in form of aor_id/contact_uri. */
+ char *contact_id;
+ /*! Pointer to the actual contact. */
+ struct ast_sip_contact *contact;
+};
+
+/*!
* \brief DTMF modes for SIP endpoints
*/
enum ast_sip_dtmf_mode {
@@ -1620,7 +1633,8 @@ void *ast_sip_dict_set(pj_pool_t* pool, void *ht,
* \brief For every contact on an AOR call the given 'on_contact' handler.
*
* \param aor the aor containing a list of contacts to iterate
- * \param on_contact callback on each contact on an AOR
+ * \param on_contact callback on each contact on an AOR. The object
+ * received by the callback will be a ast_sip_contact_wrapper structure.
* \param arg user data passed to handler
* \retval 0 Success, non-zero on failure
*/
diff --git a/include/asterisk/res_pjsip_cli.h b/include/asterisk/res_pjsip_cli.h
index fa832cadc..44979b701 100644
--- a/include/asterisk/res_pjsip_cli.h
+++ b/include/asterisk/res_pjsip_cli.h
@@ -29,23 +29,20 @@
#define CLI_INDENT_TO_SPACES(x) ((x * 2) + 1 + CLI_MAX_TITLE_NAME)
/*
- * \brief CLI Formatter Context
+ * \brief CLI Formatter Context passed to all formatters.
*/
struct ast_sip_cli_context {
- int peers_mon_online;
- int peers_mon_offline;
- int peers_unmon_offline;
- int peers_unmon_online;
+ /*! Buffer used to accumulate cli output. */
struct ast_str *output_buffer;
- const struct ast_cli_args *a;
- const struct ast_sip_endpoint *current_endpoint;
- const struct ast_sip_auth *current_auth;
- const struct ast_sip_aor *current_aor;
+ /*! Used to indicate which direction an auth is used for. "I" or "O" */
char *auth_direction;
- unsigned int print_flags;
+ /*! Allows formatters to know how far to indent their output. */
int indent_level;
+ /*! Tells a formatter to dump its object_set. */
unsigned show_details : 1;
+ /*! Tells a formatter to descend into child objects. */
unsigned recurse : 1;
+ /*! Tells a formatter to dump it's object_set only if it's the root object. */
unsigned show_details_only_level_0 : 1;
};
@@ -53,12 +50,24 @@ struct ast_sip_cli_context {
* \brief CLI Formatter Registry Entry
*/
struct ast_sip_cli_formatter_entry {
+ /*! A globally unique name for this formatter. If this formatter entry
+ * is for an existing sorcery object type, then this name must match
+ * the sorcery object type. Otherwise it can be any string as long as
+ * it's globally unique.
+ */
const char *name;
+ /*! The callback used to print the object's column headers. */
ao2_callback_fn *print_header;
+ /*! The callback used to print the details of the object. */
ao2_callback_fn *print_body;
+ /*! The function used to retrieve a container of all objects of this type. */
struct ao2_container *(* get_container)(void);
- int (* iterator)(const void *container, ao2_callback_fn callback, void *args);
- ao2_sort_fn *comparator;
+ /*! The function used to iterate over a container of objects. */
+ int (* iterate)(void *container, ao2_callback_fn callback, void *args);
+ /*! The function used to retrieve a specific object from it's container. */
+ void *(* retrieve_by_id)(const char *id);
+ /*! The function used to retrieve an id string from an object. */
+ const char *(* get_id)(const void *obj);
};
/*!
diff --git a/include/asterisk/sorcery.h b/include/asterisk/sorcery.h
index 98e8ee012..026fb4074 100644
--- a/include/asterisk/sorcery.h
+++ b/include/asterisk/sorcery.h
@@ -924,9 +924,19 @@ const char *ast_sorcery_object_get_extended(const void *object, const char *name
int ast_sorcery_object_set_extended(const void *object, const char *name, const char *value);
/*!
- * \brief Sorcery object comparator based on id.
+ * \brief ao2 object comparator based on sorcery id.
*/
-int ast_sorcery_object_id_compare(const void *obj_left, const void *obj_right, int flags);
+int ast_sorcery_object_id_compare(void *obj, void *arg, int flags);
+
+/*!
+ * \brief ao2 object sorter based on sorcery id.
+ */
+int ast_sorcery_object_id_sort(const void *obj, const void *arg, int flags);
+
+/*!
+ * \brief ao2 object hasher based on sorcery id.
+ */
+int ast_sorcery_object_id_hash(const void *obj, int flags);
/*!
* \brief Get the sorcery object type given a type name.