[asterisk-commits] mmichelson: branch group/CCSS r240228 - in /team/group/CCSS: include/asterisk...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Jan 14 14:58:19 CST 2010


Author: mmichelson
Date: Thu Jan 14 14:58:17 2010
New Revision: 240228

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=240228
Log:
Allow for channels who define multiple CC agent types to actually work.

There were two faulty assumptions in the CC core
1. Channel drivers will only define a single agent type
2. The type of this single agent type will be the same as the channel technology

chan_dahdi defines several agent types since it deals with several differing protocols.
This commit adds a new function, ast_channel_get_cc_agent_type. Channel drivers can
add to their queryoption callback a handler for AST_OPTION_CC_AGENT_TYPE. In this,
the channel can examine the channel for which an agent will be defined and return
an appropriate string for the agent type.

ast_channel_get_cc_agent_type will fall back to the old default behavior if either
the queryoption callback is not defined for the channel technology in use or if
the queryoption callback does not handle the AST_OPTION_CC_AGENT_TYPE flag.


Modified:
    team/group/CCSS/include/asterisk/channel.h
    team/group/CCSS/include/asterisk/frame.h
    team/group/CCSS/main/ccss.c
    team/group/CCSS/main/channel.c

Modified: team/group/CCSS/include/asterisk/channel.h
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/include/asterisk/channel.h?view=diff&rev=240228&r1=240227&r2=240228
==============================================================================
--- team/group/CCSS/include/asterisk/channel.h (original)
+++ team/group/CCSS/include/asterisk/channel.h Thu Jan 14 14:58:17 2010
@@ -2832,6 +2832,32 @@
  */
 int ast_channel_get_device_name(struct ast_channel *chan, char *device_name, size_t name_buffer_length);
 
+/*!
+ * \since 1.8
+ * \brief Find the appropriate CC agent type to use given a channel
+ * 
+ * \details
+ * During call completion, we will need to create a call completion agent structure. To
+ * figure out the type of agent to construct, we need to ask the channel driver for the
+ * appropriate type.
+ *
+ * Prior to adding this function, the call completion core attempted to figure this
+ * out for itself by stripping the technology off the channel's name. However, in the
+ * case of chan_dahdi, there are multiple agent types registered, and so simply searching
+ * for an agent type called "DAHDI" is not possible. In a case where multiple agent types
+ * are defined, the channel driver must have a queryoption callback defined in its
+ * channel_tech, and the queryoption callback must handle AST_OPTION_CC_AGENT_TYPE
+ *
+ * If a channel driver does not have a queryoption callback or if the queryoption callback
+ * does not handle AST_OPTION_CC_AGENT_TYPE, then the old behavior of using the technology
+ * portion of the channel name is used instead. This is perfectly suitable for channel drivers
+ * whose channel technologies are a one-to-one match with the agent types defined within.
+ *
+ * \param chan The channel for which we wish to retrieve the agent type
+ * \param[out] agent_type The type of agent the channel driver wants us to use
+ * \param size The size of the buffer to write to
+ */
+int ast_channel_get_cc_agent_type(struct ast_channel *chan, char *agent_type, size_t size);
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif

Modified: team/group/CCSS/include/asterisk/frame.h
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/include/asterisk/frame.h?view=diff&rev=240228&r1=240227&r2=240228
==============================================================================
--- team/group/CCSS/include/asterisk/frame.h (original)
+++ team/group/CCSS/include/asterisk/frame.h Thu Jan 14 14:58:17 2010
@@ -432,6 +432,9 @@
 /*! Get the device name from the channel */
 #define AST_OPTION_DEVICE_NAME		16
 
+/*! Get the CC agent type from the channel */
+#define AST_OPTION_CC_AGENT_TYPE    17
+
 struct oprmode {
 	struct ast_channel *peer;
 	int mode;

Modified: team/group/CCSS/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=240228&r1=240227&r2=240228
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Thu Jan 14 14:58:17 2010
@@ -780,20 +780,14 @@
 	struct cc_agent_backend *backend;
 	const struct ast_cc_agent_callbacks *callbacks = NULL;
 	enum ast_cc_agent_policies agent_policy;
-	const char *type;
+	char type[32];
 
 	agent_policy = ast_get_cc_agent_policy(ast_channel_get_cc_config_params(chan));
 
 	if (agent_policy == AST_CC_AGENT_GENERIC) {
-		type = "generic";
+		ast_copy_string(type, "generic", sizeof(type));
 	} else if (agent_policy == AST_CC_AGENT_NATIVE) {
-		char chan_name[AST_CHANNEL_NAME];
-		char *slash;
-		ast_copy_string(chan_name, chan->name, sizeof(chan_name));
-		if ((slash = strchr(chan_name, '/'))) {
-			*slash = '\0';
-		}
-		type = chan_name;
+		ast_channel_get_cc_agent_type(chan, type, sizeof(type));
 	} else {
 		ast_log_dynamic_level(cc_logger_level, "Not returning agent callbacks since this channel is configured not to have a CC agent\n");
 		return NULL;

Modified: team/group/CCSS/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/main/channel.c?view=diff&rev=240228&r1=240227&r2=240228
==============================================================================
--- team/group/CCSS/main/channel.c (original)
+++ team/group/CCSS/main/channel.c Thu Jan 14 14:58:17 2010
@@ -7527,6 +7527,22 @@
 	return 0;
 }
 
+int ast_channel_get_cc_agent_type(struct ast_channel *chan, char *agent_type, size_t size)
+{
+	int len = size;
+	char *slash;
+
+	if (!ast_channel_queryoption(chan, AST_OPTION_CC_AGENT_TYPE, agent_type, &len, 0)) {
+		return 0;
+	}
+
+	ast_copy_string(agent_type, chan->name, size);
+	if ((slash = strchr(agent_type, '/'))) {
+		*slash = '\0';
+	}
+	return 0;
+}
+
 /* DO NOT PUT ADDITIONAL FUNCTIONS BELOW THIS BOUNDARY
  *
  * ONLY FUNCTIONS FOR PROVIDING BACKWARDS ABI COMPATIBILITY BELONG HERE




More information about the asterisk-commits mailing list