[asterisk-commits] mmichelson: branch group/CCSS r235892 - /team/group/CCSS/main/ccss.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Dec 21 11:32:13 CST 2009


Author: mmichelson
Date: Mon Dec 21 11:32:10 2009
New Revision: 235892

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=235892
Log:
Set dialable names for device tree items.

We get this information from the CC frame's payload. Now all devices
have the ability to specify a separate dialable name in case the
device name does not match the dialstring specified when using Dial.

Next step is to update all doxygen to reflect these changes.


Modified:
    team/group/CCSS/main/ccss.c

Modified: team/group/CCSS/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=235892&r1=235891&r2=235892
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Mon Dec 21 11:32:10 2009
@@ -1550,19 +1550,20 @@
  * the dialed_interfaces global datastore will not allow that
  * to happen anyway.
  *
- * \param name The name of the device being added to the tree
+ * \param device_name The name of the device being added to the tree
+ * \param dialable_name The dialstring used to dial the device being added
  * \param parent_id The parent of this new tree node.
  * \retval NULL Memory allocation failure
  * \retval non-NULL The new ast_cc_interface created.
  */
-static struct cc_tree_item *cc_device_tree_item_init(const char * const name, const struct ast_control_cc_payload *cc_data)
+static struct cc_tree_item *cc_device_tree_item_init(const char * const device_name, const char * const dialable_name, const struct ast_control_cc_payload *cc_data)
 {
 	struct ast_cc_interface *cc_interface;
 	struct cc_tree_item *tree_item;
-	size_t name_len = strlen(name);
+	size_t device_name_len = strlen(device_name);
 	int parent_id = cc_data->parent_interface_id;
 
-	if (!(cc_interface = ao2_alloc(sizeof(*cc_interface) + name_len, cc_interface_destroy))) {
+	if (!(cc_interface = ao2_alloc(sizeof(*cc_interface) + device_name_len, cc_interface_destroy))) {
 		return NULL;
 	}
 
@@ -1576,7 +1577,13 @@
 		return NULL;
 	}
 
-	strcpy(cc_interface->name, name);
+	if (!(tree_item->dialable_name = ast_strdup(dialable_name))) {
+		ao2_t_ref(cc_interface, -1, "Failed to copy dialable name");
+		cc_tree_item_destroy(tree_item);
+		return NULL;
+	}
+
+	strcpy(cc_interface->name, device_name);
 	tree_item->id = ast_atomic_fetchadd_int(&dialed_cc_interface_counter, +1);
 	tree_item->parent_id = parent_id;
 	tree_item->service_offered = cc_data->service;
@@ -1614,6 +1621,7 @@
 void ast_handle_cc_control_frame(struct ast_channel *inbound, struct ast_channel *outbound, void *frame_data)
 {
 	char *device_name;
+	char *dialable_name;
 	struct cc_tree_item *tree_item;
 	struct ast_datastore *cc_datastore;
 	struct dialed_cc_interfaces *cc_interfaces;
@@ -1621,6 +1629,7 @@
 	struct cc_core_instance *core_instance;
 
 	device_name = cc_data->device_name;
+	dialable_name = cc_data->dialable_name;
 
 	ast_channel_lock(inbound);
 	if (!(cc_datastore = ast_channel_datastore_find(inbound, &dialed_cc_interfaces_info, NULL))) {
@@ -1674,7 +1683,7 @@
 	AST_LIST_UNLOCK(cc_interfaces->interface_tree);
 
 
-	if (!(tree_item = cc_device_tree_item_init(device_name, cc_data))) {
+	if (!(tree_item = cc_device_tree_item_init(device_name, dialable_name, cc_data))) {
 		ast_log(LOG_WARNING, "Unable to create CC device interface for '%s'. CC services will be unavailable on this interface.\n", device_name);
 		cc_unref(core_instance, "Returning early from ast_handle_cc_control_frame");
 		return;




More information about the asterisk-commits mailing list