[svn-commits] mmichelson: branch group/CCSS r234392 - in /team/group/CCSS: apps/ channels/ ...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Fri Dec 11 17:20:11 CST 2009


Author: mmichelson
Date: Fri Dec 11 17:20:06 2009
New Revision: 234392

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=234392
Log:
Write a big function to simulate a CC frame for 
channel types that fail ast_request when busy.

Tested with an analog phone. It works great! The other thing
I had to change was for the monitor devstate callback to accept
AST_DEVICE_UNKNOWN as a state meaning that the phone had
become available.


Modified:
    team/group/CCSS/apps/app_dial.c
    team/group/CCSS/channels/chan_dahdi.c
    team/group/CCSS/include/asterisk/ccss.h
    team/group/CCSS/include/asterisk/channel.h
    team/group/CCSS/main/ccss.c
    team/group/CCSS/main/channel.c

Modified: team/group/CCSS/apps/app_dial.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/apps/app_dial.c?view=diff&rev=234392&r1=234391&r2=234392
==============================================================================
--- team/group/CCSS/apps/app_dial.c (original)
+++ team/group/CCSS/apps/app_dial.c Fri Dec 11 17:20:06 2009
@@ -1891,7 +1891,7 @@
 			if (!rest) /* we are on the last destination */
 				chan->hangupcause = cause;
 			chanlist_free(tmp);
-			ast_cc_callback(tech, numsubst, ast_cc_busy_interface);
+			ast_cc_callback(chan, tech, numsubst, ast_cc_busy_interface);
 			continue;
 		}
 		pbx_builtin_setvar_helper(tc, "DIALEDPEERNUMBER", numsubst);

Modified: team/group/CCSS/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/channels/chan_dahdi.c?view=diff&rev=234392&r1=234391&r2=234392
==============================================================================
--- team/group/CCSS/channels/chan_dahdi.c (original)
+++ team/group/CCSS/channels/chan_dahdi.c Fri Dec 11 17:20:06 2009
@@ -1429,7 +1429,8 @@
 static int dahdi_queryoption(struct ast_channel *chan, int option, void *data, int *datalen);
 static int dahdi_func_read(struct ast_channel *chan, const char *function, char *data, char *buf, size_t len);
 static int dahdi_func_write(struct ast_channel *chan, const char *function, char *data, const char *value);
-static int dahdi_cc_callback(const char *dest, void (*callback)(struct ast_cc_config_params *cc_params, const char * const interface_name));
+static int dahdi_cc_callback(struct ast_channel *inbound, const char *dest, 
+		void (*callback)(struct ast_channel *inbound, struct ast_cc_config_params *cc_params, const char * const interface_name));
 
 static const struct ast_channel_tech dahdi_tech = {
 	.type = "DAHDI",
@@ -12232,7 +12233,8 @@
 	return tmp;
 }
 
-static int dahdi_cc_callback(const char *dest, void (*callback)(struct ast_cc_config_params *cc_params, const char * const interface_name))
+static int dahdi_cc_callback(struct ast_channel *inbound, const char *dest, 
+		void (*callback)(struct ast_channel *inbound, struct ast_cc_config_params *cc_params, const char * const interface_name))
 {
 	struct dahdi_pvt *p, *exitpvt;
 	ast_group_t groupmatch = 0;
@@ -12249,7 +12251,7 @@
 			/* We found a potential match. call the callback */
 			char interface_name[128];
 			snprintf(interface_name, sizeof(interface_name) - 1, "DAHDI/%s", dest);
-			callback(p->cc_params, interface_name);
+			callback(inbound, p->cc_params, interface_name);
 		}
 		p = backwards ? p->prev : p->next;
 		if (!p) {

Modified: team/group/CCSS/include/asterisk/ccss.h
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/include/asterisk/ccss.h?view=diff&rev=234392&r1=234391&r2=234392
==============================================================================
--- team/group/CCSS/include/asterisk/ccss.h (original)
+++ team/group/CCSS/include/asterisk/ccss.h Fri Dec 11 17:20:06 2009
@@ -1123,7 +1123,7 @@
  */
 int ast_set_cc_interfaces_chanvar(struct ast_channel *chan, const char * const extension);
 
-void ast_cc_busy_interface(struct ast_cc_config_params *cc_params, const char * const interface_name);
+void ast_cc_busy_interface(struct ast_channel *inbound, struct ast_cc_config_params *cc_params, const char * const interface_name);
 
 /*!
  * \since 1.6.4

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=234392&r1=234391&r2=234392
==============================================================================
--- team/group/CCSS/include/asterisk/channel.h (original)
+++ team/group/CCSS/include/asterisk/channel.h Fri Dec 11 17:20:06 2009
@@ -536,7 +536,8 @@
 	 * match the input and return call the designated callback with the device's call completion
 	 * parameters as a parameter.
 	 */
-	int (* cc_callback)(const char *dest, void (*callback_fn)(struct ast_cc_config_params *cc_params, const char * const interface_name));
+	int (* cc_callback)(struct ast_channel *inbound, const char *dest,
+			void (*callback_fn)(struct ast_channel *inbound, struct ast_cc_config_params *cc_params, const char * const interface_name));
 };
 
 struct ast_epoll_data;
@@ -2840,7 +2841,8 @@
  * \param callback Function to call when a target is reached
  * \retval Always 0, I guess.
  */
-int ast_cc_callback(const char * const tech, const char * const dest, void (*callback)(struct ast_cc_config_params *cc_params, const char * const interace_name));
+int ast_cc_callback(struct ast_channel *inbound, const char * const tech, const char * const dest, 
+		void (*callback)(struct ast_channel *inbound, struct ast_cc_config_params *cc_params, const char * const interace_name));
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }

Modified: team/group/CCSS/main/ccss.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=234392&r1=234391&r2=234392
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Fri Dec 11 17:20:06 2009
@@ -1040,7 +1040,7 @@
 
 	gen_mon_pvt->current_state = new_state;
 
-	if (new_state == AST_DEVICE_NOT_INUSE) {
+	if (new_state == AST_DEVICE_NOT_INUSE || new_state == AST_DEVICE_UNKNOWN) {
 		ast_cc_monitor_callee_available(monitor);
 	}
 	cc_unref(monitor, "Kill reference from generic_monitor_devstate_cb");
@@ -3168,10 +3168,45 @@
 	return ast_queue_frame(chan, &frame);
 }
 
-void ast_cc_busy_interface(struct ast_cc_config_params *cc_params, const char * const interface_name)
-{
-	/* STUB */
-	ast_log(LOG_NOTICE, "Called with interface %s\n", interface_name);
+void ast_cc_busy_interface(struct ast_channel *inbound, struct ast_cc_config_params *cc_params, const char * const interface_name)
+{
+	struct ast_control_cc_payload payload;
+	struct ast_datastore *datastore;
+	struct dialed_cc_interfaces *cc_interfaces;
+	enum ast_cc_monitor_policies monitor_policy = ast_get_cc_monitor_policy(cc_params);
+	const char *interface_name_copy = ast_strdupa(interface_name);
+
+	if (!(datastore = ast_channel_datastore_find(inbound, &dialed_cc_interfaces_info, NULL))) {
+		return;
+	}
+
+	cc_interfaces = datastore->data;
+
+	payload.service = AST_CC_CCBS;
+	if (monitor_policy == AST_CC_MONITOR_GENERIC || monitor_policy == AST_CC_MONITOR_ALWAYS) {
+		payload.monitor_type = "generic";
+	} else if (monitor_policy == AST_CC_MONITOR_NATIVE) {
+		char *slash = strchr(interface_name_copy, '/');
+		const struct ast_cc_monitor_callbacks *callbacks;
+		if (!slash) {
+			ast_log_dynamic_level(cc_logger_level, "Unable to determine proper CC monitor type.\n");
+			return;
+		}
+		*slash = '\0';
+		if (!(callbacks = find_monitor_callbacks(interface_name_copy))) {
+			ast_log_dynamic_level(cc_logger_level, "No monitor type corresponds to %s\n", interface_name_copy);
+			return;
+		}
+		payload.monitor_type = callbacks->type;
+	} else { /* AST_CC_MONITOR_NEVER */
+		ast_log_dynamic_level(cc_logger_level, "Interface %s does not allow CC\n", interface_name);
+		return;
+	}
+	ast_cc_copy_config_params(&payload.config_params, cc_params);
+	payload.parent_interface_id =  cc_interfaces->dial_parent_id;
+	ast_copy_string(payload.device_name, interface_name, sizeof(payload.device_name));
+	/* Now we can simulate a frame! I love it! */
+	ast_handle_cc_control_frame(inbound, NULL, &payload);
 }
 
 static char *ccreq_app = "CallCompletionRequest";

Modified: team/group/CCSS/main/channel.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/main/channel.c?view=diff&rev=234392&r1=234391&r2=234392
==============================================================================
--- team/group/CCSS/main/channel.c (original)
+++ team/group/CCSS/main/channel.c Fri Dec 11 17:20:06 2009
@@ -7511,14 +7511,15 @@
 	return 0;
 }
 
-int ast_cc_callback(const char * const tech, const char * const dest, void (*callback)(struct ast_cc_config_params *cc_params, const char * const interface_name))
+int ast_cc_callback(struct ast_channel *inbound, const char * const tech, const char * const dest,
+		void (*callback)(struct ast_channel *inbound, struct ast_cc_config_params *cc_params, const char * const interface_name))
 {
 	struct chanlist *cl;
 
 	AST_RWLIST_RDLOCK(&backends);
 	AST_RWLIST_TRAVERSE(&backends, cl, list) {
 		if (!strcasecmp(cl->tech->type, tech) && cl->tech->cc_callback) {
-			cl->tech->cc_callback(dest, callback);
+			cl->tech->cc_callback(inbound, dest, callback);
 		}
 	}
 	AST_RWLIST_UNLOCK(&backends);




More information about the svn-commits mailing list