[svn-commits] qwell: trunk r393804 - in /trunk: channels/ include/ include/asterisk/ main/ ...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Jul 8 09:43:01 CDT 2013


Author: qwell
Date: Mon Jul  8 09:42:57 2013
New Revision: 393804

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=393804
Log:
Move channel driver Registry manager events to core.

This also shuffles the stasis system topic and related handling.

(closes issue ASTERISK-21488)

Review: https://reviewboard.asterisk.org/r/2631/

Added:
    trunk/include/asterisk/stasis_system.h
      - copied unchanged from r393802, team/qwell/system_registry/include/asterisk/stasis_system.h
    trunk/main/manager_system.c
      - copied unchanged from r393802, team/qwell/system_registry/main/manager_system.c
    trunk/main/stasis_system.c
      - copied unchanged from r393802, team/qwell/system_registry/main/stasis_system.c
Modified:
    trunk/channels/chan_iax2.c
    trunk/channels/chan_sip.c
    trunk/include/asterisk.h
    trunk/include/asterisk/manager.h
    trunk/main/asterisk.c
    trunk/main/file.c
    trunk/main/manager.c
    trunk/main/sounds_index.c
    trunk/res/res_stun_monitor.c

Modified: trunk/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_iax2.c?view=diff&rev=393804&r1=393803&r2=393804
==============================================================================
--- trunk/channels/chan_iax2.c (original)
+++ trunk/channels/chan_iax2.c Mon Jul  8 09:42:57 2013
@@ -103,6 +103,8 @@
 #include "asterisk/security_events.h"
 #include "asterisk/stasis_endpoints.h"
 #include "asterisk/bridging.h"
+#include "asterisk/stasis.h"
+#include "asterisk/stasis_system.h"
 
 #include "iax2/include/iax2.h"
 #include "iax2/include/firmware.h"
@@ -8376,6 +8378,11 @@
 	return 0;
 }
 
+static void iax2_publish_registry(const char *username, const char *domain, const char *status, const char *cause)
+{
+	ast_system_publish_registry("IAX2", username, domain, status, cause);
+}
+
 /*! \brief Acknowledgment received for OUR registration */
 static int iax2_ack_registry(struct iax_ies *ies, struct sockaddr_in *sin, int callno)
 {
@@ -8437,7 +8444,7 @@
 		}
 		snprintf(ourip, sizeof(ourip), "%s:%d", ast_inet_ntoa(reg->us.sin_addr), ntohs(reg->us.sin_port));
 		ast_verb(3, "Registered IAX2 to '%s', who sees us as %s%s\n", ast_inet_ntoa(sin->sin_addr), ourip, msgstatus);
-		manager_event(EVENT_FLAG_SYSTEM, "Registry", "ChannelType: IAX2\r\nDomain: %s\r\nStatus: Registered\r\n", ast_inet_ntoa(sin->sin_addr));
+		iax2_publish_registry(reg->username, ast_inet_ntoa(sin->sin_addr), "Registered", NULL);
 	}
 	reg->regstate = REG_STATE_REGISTERED;
 	return 0;
@@ -11179,8 +11186,8 @@
 				if (iaxs[fr->callno]->reg) {
 					if (authdebug) {
 						ast_log(LOG_NOTICE, "Registration of '%s' rejected: '%s' from: '%s'\n", iaxs[fr->callno]->reg->username, ies.cause ? ies.cause : "<unknown>", ast_inet_ntoa(sin.sin_addr));
-						manager_event(EVENT_FLAG_SYSTEM, "Registry", "ChannelType: IAX2\r\nUsername: %s\r\nStatus: Rejected\r\nCause: %s\r\n", iaxs[fr->callno]->reg->username, ies.cause ? ies.cause : "<unknown>");
 					}
+					iax2_publish_registry(iaxs[fr->callno]->reg->username, ast_inet_ntoa(sin.sin_addr), "Rejected", S_OR(ies.cause, "<unknown>"));
 					iaxs[fr->callno]->reg->regstate = REG_STATE_REJECTED;
 				}
 				/* Send ack immediately, before we destroy */

Modified: trunk/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/trunk/channels/chan_sip.c?view=diff&rev=393804&r1=393803&r2=393804
==============================================================================
--- trunk/channels/chan_sip.c (original)
+++ trunk/channels/chan_sip.c Mon Jul  8 09:42:57 2013
@@ -294,7 +294,9 @@
 #include "asterisk/sip_api.h"
 #include "asterisk/app.h"
 #include "asterisk/bridging.h"
+#include "asterisk/stasis.h"
 #include "asterisk/stasis_endpoints.h"
+#include "asterisk/stasis_system.h"
 #include "asterisk/stasis_channels.h"
 #include "asterisk/features_config.h"
 
@@ -15076,6 +15078,11 @@
 	return map_x_s(regstatestrings, regstate, "Unknown");
 }
 
+static void sip_publish_registry(const char *username, const char *domain, const char *status)
+{
+	ast_system_publish_registry("SIP", username, domain, status, NULL);
+}
+
 /*! \brief Update registration with SIP Proxy.
  * Called from the scheduler when the previous registration expires,
  * so we don't have to cancel the pending event.
@@ -15176,7 +15183,7 @@
 		transmit_register(r, SIP_REGISTER, NULL, NULL);
 		ast_log(LOG_NOTICE, "   -- Registration for '%s@%s' timed out, trying again (Attempt #%d)\n", r->username, r->hostname, r->regattempts);
 	}
-	manager_event(EVENT_FLAG_SYSTEM, "Registry", "ChannelType: SIP\r\nUsername: %s\r\nDomain: %s\r\nStatus: %s\r\n", r->username, r->hostname, regstate2str(r->regstate));
+	sip_publish_registry(r->username, r->hostname, regstate2str(r->regstate));
 	registry_unref(r, "unreffing registry_unref r");
 	return 0;
 }
@@ -23692,7 +23699,7 @@
 			r->regstate = REG_STATE_UNREGISTERED;
 			transmit_register(r, SIP_REGISTER, NULL, NULL);
 		}
-		manager_event(EVENT_FLAG_SYSTEM, "Registry", "ChannelType: SIP\r\nUsername: %s\r\nDomain: %s\r\nStatus: %s\r\n", r->username, r->hostname, regstate2str(r->regstate));
+		sip_publish_registry(r->username, r->hostname, regstate2str(r->regstate));
 		break;
 	case 479:	/* SER: Not able to process the URI - address is wrong in register*/
 		ast_log(LOG_WARNING, "Got error 479 on register to %s@%s, giving up (check config)\n", p->registry->username, p->registry->hostname);
@@ -23711,7 +23718,7 @@
 
 		r->regstate = REG_STATE_REGISTERED;
 		r->regtime = ast_tvnow();		/* Reset time of last successful registration */
-		manager_event(EVENT_FLAG_SYSTEM, "Registry", "ChannelType: SIP\r\nUsername: %s\r\nDomain: %s\r\nStatus: %s\r\n", r->username, r->hostname, regstate2str(r->regstate));
+		sip_publish_registry(r->username, r->hostname, regstate2str(r->regstate));
 		r->regattempts = 0;
 		ast_debug(1, "Registration successful\n");
 		if (r->timeout > -1) {

Modified: trunk/include/asterisk.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk.h?view=diff&rev=393804&r1=393803&r2=393804
==============================================================================
--- trunk/include/asterisk.h (original)
+++ trunk/include/asterisk.h Mon Jul  8 09:42:57 2013
@@ -216,27 +216,6 @@
 #define ast_mark(a, b) do { } while (0)
 #endif /* LOW_MEMORY */
 
-/*!
- * \since 12
- * \brief A \ref stasis topic which publishes messages regarding system changes
- *
- * \retval \ref stasis_topic for system level changes
- * \retval NULL on error
- */
-struct stasis_topic *ast_system_topic(void);
-
-/*!
- * \since 12
- * \brief A \ref stasis_message_type for network changes
- *
- * \retval NULL on error
- * \retval \ref stasis_message_type for network changes
- *
- * \note Messages of this type should always be issued on and expected from
- *       the \ref ast_system_topic \ref stasis topic
- */
-struct stasis_message_type *ast_network_change_type(void);
-
 /*! \brief
  * Definition of various structures that many asterisk files need,
  * but only because they need to know that the type exists.

Modified: trunk/include/asterisk/manager.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/manager.h?view=diff&rev=393804&r1=393803&r2=393804
==============================================================================
--- trunk/include/asterisk/manager.h (original)
+++ trunk/include/asterisk/manager.h Mon Jul  8 09:42:57 2013
@@ -440,6 +440,14 @@
 #define NO_EXTRA_FIELDS "%s", ""
 
 /*!
+ * \since 12
+ * \brief Initialize support for AMI system events.
+ * \retval 0 on success
+ * \retval non-zero on error
+ */
+int manager_system_init(void);
+
+/*!
  * \brief Initialize support for AMI channel events.
  * \retval 0 on success.
  * \retval non-zero on error.

Modified: trunk/main/asterisk.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/asterisk.c?view=diff&rev=393804&r1=393803&r2=393804
==============================================================================
--- trunk/main/asterisk.c (original)
+++ trunk/main/asterisk.c Mon Jul  8 09:42:57 2013
@@ -243,6 +243,7 @@
 #include "asterisk/stasis.h"
 #include "asterisk/json.h"
 #include "asterisk/stasis_endpoints.h"
+#include "asterisk/stasis_system.h"
 #include "asterisk/security_events.h"
 
 #include "../defaults.h"
@@ -448,21 +449,12 @@
 	 unsigned int need_quit_handler:1;
 } sig_flags;
 
-/*! \brief The \ref stasis topic for system level changes */
-static struct stasis_topic *system_topic;
-
-/*!\ brief The \ref stasis_message_type for network changes */
-STASIS_MESSAGE_TYPE_DEFN(ast_network_change_type);
-
 #if !defined(LOW_MEMORY)
 struct file_version {
 	AST_RWLIST_ENTRY(file_version) list;
 	const char *file;
 	char *version;
 };
-
-/*! \brief The \ref stasis topic for system level changes */
-static struct stasis_topic *system_topic;
 
 static AST_RWLIST_HEAD_STATIC(file_versions, file_version);
 
@@ -1097,36 +1089,6 @@
 }
 
 #endif /* ! LOW_MEMORY */
-
-struct stasis_topic *ast_system_topic(void)
-{
-	return system_topic;
-}
-
-/*! \brief Cleanup the \ref stasis system level items */
-static void stasis_system_topic_cleanup(void)
-{
-	ao2_cleanup(system_topic);
-	system_topic = NULL;
-	STASIS_MESSAGE_TYPE_CLEANUP(ast_network_change_type);
-}
-
-/*! \brief Initialize the system level items for \ref stasis */
-static int stasis_system_topic_init(void)
-{
-	ast_register_cleanup(stasis_system_topic_cleanup);
-
-	system_topic = stasis_topic_create("ast_system");
-	if (!system_topic) {
-		return 1;
-	}
-
-	if (STASIS_MESSAGE_TYPE_INIT(ast_network_change_type) != 0) {
-		return -1;
-	}
-
-	return 0;
-}
 
 static void publish_fully_booted(void)
 {
@@ -4218,7 +4180,7 @@
 		exit(1);
 	}
 
-	if (stasis_system_topic_init()) {
+	if (ast_stasis_system_init()) {
 		printf("Stasis system-level information initialization failed.\n%s", term_quit());
 		exit(1);
 	}

Modified: trunk/main/file.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/file.c?view=diff&rev=393804&r1=393803&r2=393804
==============================================================================
--- trunk/main/file.c (original)
+++ trunk/main/file.c Mon Jul  8 09:42:57 2013
@@ -53,6 +53,7 @@
 #include "asterisk/test.h"
 #include "asterisk/stasis.h"
 #include "asterisk/json.h"
+#include "asterisk/stasis_system.h"
 
 /*! \brief
  * The following variable controls the layout of localized sound files.

Modified: trunk/main/manager.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/manager.c?view=diff&rev=393804&r1=393803&r2=393804
==============================================================================
--- trunk/main/manager.c (original)
+++ trunk/main/manager.c Mon Jul  8 09:42:57 2013
@@ -7827,6 +7827,10 @@
 			ast_log(AST_LOG_ERROR, "Failed to initialize manager subscriptions\n");
 			return -1;
 		}
+		if (manager_system_init()) {
+			ast_log(AST_LOG_ERROR, "Failed to initialize manager system handling\n");
+			return -1;
+		}
 		if (manager_channels_init()) {
 			ast_log(AST_LOG_ERROR, "Failed to initialize manager channel handling\n");
 			return -1;

Modified: trunk/main/sounds_index.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/sounds_index.c?view=diff&rev=393804&r1=393803&r2=393804
==============================================================================
--- trunk/main/sounds_index.c (original)
+++ trunk/main/sounds_index.c Mon Jul  8 09:42:57 2013
@@ -36,6 +36,7 @@
 #include "asterisk/cli.h"
 #include "asterisk/_private.h"
 #include "asterisk/stasis_message_router.h"
+#include "asterisk/stasis_system.h"
 
 /*** MODULEINFO
 	<support_level>core</support_level>

Modified: trunk/res/res_stun_monitor.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_stun_monitor.c?view=diff&rev=393804&r1=393803&r2=393804
==============================================================================
--- trunk/res/res_stun_monitor.c (original)
+++ trunk/res/res_stun_monitor.c Mon Jul  8 09:42:57 2013
@@ -39,8 +39,9 @@
 #include "asterisk/lock.h"
 #include "asterisk/acl.h"
 #include "asterisk/cli.h"
+#include "asterisk/json.h"
 #include "asterisk/stasis.h"
-#include "asterisk/json.h"
+#include "asterisk/stasis_system.h"
 #include "asterisk/astobj2.h"
 
 #include <fcntl.h>




More information about the svn-commits mailing list