[asterisk-commits] mmichelson: branch group/CCSS r228266 - /team/group/CCSS/main/ccss.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Nov 5 18:50:09 CST 2009
Author: mmichelson
Date: Thu Nov 5 18:50:05 2009
New Revision: 228266
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=228266
Log:
Fix logic for passing device info across a local channel.
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=228266&r1=228265&r2=228266
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Thu Nov 5 18:50:05 2009
@@ -1475,6 +1475,8 @@
enum ast_cc_service_type service;
const char *monitor_type;
struct ast_cc_config_params config_params;
+ int parent_interface_id;
+ char device_name[AST_CHANNEL_NAME];
};
/*!
@@ -1500,11 +1502,12 @@
* \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 int parent_id, const struct ast_control_cc_payload *cc_data)
+static struct cc_tree_item *cc_device_tree_item_init(const char * const 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);
+ int parent_id = cc_data->parent_interface_id;
if (!(cc_interface = ao2_alloc(sizeof(*cc_interface) + name_len, cc_interface_destroy))) {
return NULL;
@@ -1556,14 +1559,14 @@
*/
void ast_handle_cc_control_frame(struct ast_channel *inbound, struct ast_channel *outbound, void *frame_data)
{
- char device_name[AST_CHANNEL_NAME];
+ char *device_name;
struct cc_tree_item *tree_item;
struct ast_datastore *cc_datastore;
struct dialed_cc_interfaces *cc_interfaces;
struct ast_control_cc_payload *cc_data = frame_data;
struct cc_core_instance *core_instance;
- ast_channel_get_device_name(outbound, device_name, sizeof(device_name));
+ device_name = cc_data->device_name;
ast_channel_lock(inbound);
if (!(cc_datastore = ast_channel_datastore_find(inbound, &dialed_cc_interfaces_info, NULL))) {
@@ -1586,7 +1589,7 @@
* other side of the local channel so that the original caller can benefit.
*/
ast_channel_unlock(inbound);
- ast_indicate_data(inbound, AST_CONTROL_CC, frame_data, sizeof(*frame_data));
+ ast_indicate_data(inbound, AST_CONTROL_CC, cc_data, sizeof(*cc_data));
return;
}
@@ -1617,7 +1620,7 @@
AST_LIST_UNLOCK(cc_interfaces->interface_tree);
- if (!(tree_item = cc_device_tree_item_init(device_name, cc_interfaces->dial_parent_id, cc_data))) {
+ if (!(tree_item = cc_device_tree_item_init(device_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;
@@ -3065,17 +3068,30 @@
{
struct ast_frame frame = {.frametype = AST_FRAME_CONTROL, .subclass.integer = AST_CONTROL_CC };
struct ast_control_cc_payload payload;
+ struct ast_datastore *datastore;
+ struct dialed_cc_interfaces *dialed_interfaces;
char chan_name[AST_CHANNEL_NAME];
ast_channel_get_device_name(chan, chan_name, sizeof(chan_name));
if (ast_cc_monitor_count(chan_name, monitor_type) >= ast_get_cc_max_monitors(ast_channel_get_cc_config_params(chan))) {
ast_log(LOG_NOTICE, "Not queuing a CC frame for channel %s since it already has its maximum monitors allocated\n", chan_name);
- return 0;
- }
+ return -1;
+ }
+
+ if (!(datastore = ast_channel_datastore_find(chan, &dialed_cc_interfaces_info, NULL))) {
+ /* If the channel doesn't have the proper datastore on it, we can't properly queue a
+ * frame. Sorry bud.
+ */
+ return -1;
+ }
+
+ dialed_interfaces = datastore->data;
payload.monitor_type = monitor_type;
payload.service = service;
+ payload.parent_interface_id = dialed_interfaces->dial_parent_id;
+ ast_copy_string(payload.device_name, chan_name, sizeof(payload.device_name));
ast_cc_copy_config_params(&payload.config_params, ast_channel_get_cc_config_params(chan));
frame.data.ptr = &payload;
frame.datalen = sizeof(payload);
More information about the asterisk-commits
mailing list