[asterisk-commits] mmichelson: branch group/CCSS r213834 - /team/group/CCSS/apps/app_dial.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Aug 24 11:45:06 CDT 2009


Author: mmichelson
Date: Mon Aug 24 11:45:02 2009
New Revision: 213834

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=213834
Log:
Add logic for adding device interface information when AST_CONTROL_CC is received.


Modified:
    team/group/CCSS/apps/app_dial.c

Modified: team/group/CCSS/apps/app_dial.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/CCSS/apps/app_dial.c?view=diff&rev=213834&r1=213833&r2=213834
==============================================================================
--- team/group/CCSS/apps/app_dial.c (original)
+++ team/group/CCSS/apps/app_dial.c Mon Aug 24 11:45:02 2009
@@ -582,6 +582,7 @@
 
 static int detect_disconnect(struct ast_channel *chan, char code, struct ast_str *featurecode);
 static void cc_set_done_flag(struct ast_channel *chan);
+static void handle_cc_control_frame(struct ast_channel *chan, void *frame_data);
 
 static void hanguptree(struct chanlist *outgoing, struct ast_channel *exception, int answered_elsewhere)
 {
@@ -1129,12 +1130,14 @@
 					break;
 				case AST_CONTROL_CC:
 					if (!ignore_cc) {
+						handle_cc_control_frame(in, f->data.ptr);
 						/* Oh snap! We need to create a new ast_cc_interface
 						 * and add it to the datastore on chan. This one will
 						 * be a "device" type, so it will have stats like:
 						 * - name: Tech/device
 						 * - id: atomic add of the dial_cc_interface_counter
 						 * - parent_id: chan's datastore's dial_parent_id
+static struct ast_cc_interface *cc_extension_interface_init(const char * const exten, const char * const context, const unsigned int parent_id)
 						 */
 					}
 					break;
@@ -1769,6 +1772,50 @@
 	return 0;
 }
 
+static struct ast_cc_interface *cc_device_interface_init(const char * const name, const size_t name_len, const int parent_id)
+{
+	struct ast_cc_interface *cc_interface = ast_calloc(1, sizeof(*cc_interface) + name_len);
+
+	if (!cc_interface) {
+		return NULL;
+	}
+
+	strcpy(cc_interface->name, name);
+	cc_interface->id = ast_atomic_fetchadd_int(&dial_cc_interface_counter, +1);
+	cc_interface->parent_id = parent_id;
+	return cc_interface;
+}
+
+static void handle_cc_control_frame(struct ast_channel *chan, void *frame_data)
+{
+	char device_name[AST_CHANNEL_NAME];
+	char *dash;
+	struct ast_cc_interface *cc_interface;
+	struct ast_datastore *cc_datastore;
+	struct dial_cc_interfaces *cc_interfaces;
+
+	ast_copy_string(device_name, chan->name, sizeof(device_name));
+	if ((dash = strrchr(device_name, '-'))) {
+		*dash = '\0';
+	}
+
+	if (!(cc_datastore = ast_channel_datastore_find(chan, &dial_cc_interfaces_info, NULL))) {
+		ast_log(LOG_WARNING, "Unable to retrieve CC datastore while processing CC frame from '%s'. CC services will be unavailable.\n", device_name);
+		return;
+	}
+
+	cc_interfaces = cc_datastore->data;
+
+	if (!(cc_interface = cc_device_interface_init(device_name, strlen(device_name), cc_interfaces->dial_parent_id))) {
+		ast_log(LOG_WARNING, "Unable to create CC device interface for '%s'. CC services will be unavailable on this interface.\n", device_name);
+		return;
+	}
+
+	AST_LIST_LOCK(cc_interfaces->interface_tree);
+	AST_LIST_INSERT_TAIL(cc_interfaces->interface_tree, cc_interface, next);
+	AST_LIST_UNLOCK(cc_interfaces->interface_tree);
+}
+
 static int create_root_cc_interface(struct ast_channel *chan, int *ignore_cc)
 {
 	/* All right. So here's the deal. There are three things




More information about the asterisk-commits mailing list