[svn-commits] kmoore: branch kmoore/pjsip_commands r395106 - in /team/kmoore/pjsip_commands...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Tue Jul 23 07:54:42 CDT 2013
Author: kmoore
Date: Tue Jul 23 07:54:40 2013
New Revision: 395106
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=395106
Log:
Add PJSIPQualify AMI action
Modified:
team/kmoore/pjsip_commands/res/res_sip.c
team/kmoore/pjsip_commands/res/res_sip/include/res_sip_private.h
team/kmoore/pjsip_commands/res/res_sip/sip_options.c
Modified: team/kmoore/pjsip_commands/res/res_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_commands/res/res_sip.c?view=diff&rev=395106&r1=395105&r2=395106
==============================================================================
--- team/kmoore/pjsip_commands/res/res_sip.c (original)
+++ team/kmoore/pjsip_commands/res/res_sip.c Tue Jul 23 07:54:40 2013
@@ -1734,6 +1734,7 @@
static int unload_module(void)
{
+ ast_res_sip_cleanup_options_handling();
ast_sip_destroy_distributor();
ast_res_sip_destroy_configuration();
ast_sip_destroy_global_headers();
Modified: team/kmoore/pjsip_commands/res/res_sip/include/res_sip_private.h
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_commands/res/res_sip/include/res_sip_private.h?view=diff&rev=395106&r1=395105&r2=395106
==============================================================================
--- team/kmoore/pjsip_commands/res/res_sip/include/res_sip_private.h (original)
+++ team/kmoore/pjsip_commands/res/res_sip/include/res_sip_private.h Tue Jul 23 07:54:40 2013
@@ -71,4 +71,9 @@
*/
int ast_sip_initialize_global(void);
+/*!
+ * \brief Clean up res_sip options handling
+ */
+void ast_res_sip_cleanup_options_handling(void);
+
#endif /* RES_SIP_PRIVATE_H_ */
Modified: team/kmoore/pjsip_commands/res/res_sip/sip_options.c
URL: http://svnview.digium.com/svn/asterisk/team/kmoore/pjsip_commands/res/res_sip/sip_options.c?view=diff&rev=395106&r1=395105&r2=395106
==============================================================================
--- team/kmoore/pjsip_commands/res/res_sip/sip_options.c (original)
+++ team/kmoore/pjsip_commands/res/res_sip/sip_options.c Tue Jul 23 07:54:40 2013
@@ -653,6 +653,64 @@
return CLI_SUCCESS;
}
+/*!
+ * \internal
+ * \brief Send qualify request to the given contact.
+ */
+static int ami_contact_cb(void *obj, void *arg, int flags)
+{
+ struct ast_sip_contact *contact = obj;
+ ao2_ref(contact, +1);
+ if (ast_sip_push_task(NULL, qualify_contact_task, contact)) {
+ ao2_cleanup(contact);
+ }
+ return 0;
+}
+
+static int ami_sip_qualify(struct mansession *s, const struct message *m)
+{
+ const char *endpoint_name = astman_get_header(m, "Endpoint");
+ RAII_VAR(struct ast_sip_endpoint *, endpoint, NULL, ao2_cleanup);
+ char *aor_name, *aors;
+
+ if (ast_strlen_zero(endpoint_name)) {
+ astman_send_error(s, m, "Endpoint parameter missing.");
+ return 0;
+ }
+
+ endpoint = ast_sorcery_retrieve_by_id(
+ ast_sip_get_sorcery(),
+ "endpoint",
+ endpoint_name);
+ if (!endpoint) {
+ astman_send_error(s, m, "Unable to retrieve endpoint\n");
+ return 0;
+ }
+
+ /* send a qualify for all contacts registered with the endpoint */
+ if (ast_strlen_zero(endpoint->aors)) {
+ astman_send_error(s, m, "No AoRs configured for endpoint\n");
+ return 0;
+ }
+
+ aors = ast_strdupa(endpoint->aors);
+
+ while ((aor_name = strsep(&aors, ","))) {
+ RAII_VAR(struct ast_sip_aor *, aor,
+ ast_sip_location_retrieve_aor(aor_name), ao2_cleanup);
+ RAII_VAR(struct ao2_container *, contacts, NULL, ao2_cleanup);
+
+ if (!aor || !(contacts = ast_sip_location_retrieve_aor_contacts(aor))) {
+ continue;
+ }
+
+ ao2_callback(contacts, OBJ_NODATA, ami_contact_cb, NULL);
+ }
+
+ astman_send_ack(s, m, "Endpoint found, will qualify");
+ return 0;
+}
+
static struct ast_cli_entry cli_options[] = {
AST_CLI_DEFINE(cli_qualify, "Send an OPTIONS request to a SIP endpoint")
};
@@ -779,6 +837,13 @@
qualify_and_schedule_permanent();
ast_cli_register_multiple(cli_options, ARRAY_LEN(cli_options));
+ ast_manager_register2("PJSIPQualify", EVENT_FLAG_SYSTEM | EVENT_FLAG_REPORTING, ami_sip_qualify, NULL, NULL, NULL);
return 0;
}
+
+void ast_res_sip_cleanup_options_handling(void)
+{
+ ast_cli_unregister_multiple(cli_options, ARRAY_LEN(cli_options));
+ ast_manager_unregister("PJSIPQualify");
+}
More information about the svn-commits
mailing list