[asterisk-commits] rmudgett: branch rmudgett/dahdi_ccss r240038 - /team/rmudgett/dahdi_ccss/chan...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Jan 13 18:54:54 CST 2010


Author: rmudgett
Date: Wed Jan 13 18:54:52 2010
New Revision: 240038

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=240038
Log:
Filled in PRI CCSS monitor callbacks.

Modified:
    team/rmudgett/dahdi_ccss/channels/sig_pri.c

Modified: team/rmudgett/dahdi_ccss/channels/sig_pri.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/dahdi_ccss/channels/sig_pri.c?view=diff&rev=240038&r1=240037&r2=240038
==============================================================================
--- team/rmudgett/dahdi_ccss/channels/sig_pri.c (original)
+++ team/rmudgett/dahdi_ccss/channels/sig_pri.c Wed Jan 13 18:54:52 2010
@@ -91,7 +91,9 @@
 	char name[1];
 };
 
+/*! Upper level agent/monitor type name. */
 static const char *sig_pri_cc_type_name;
+/*! Container of sig_pri monitor instances. */
 static struct ao2_container *sig_pri_cc_monitors;
 #endif	/* defined(HAVE_PRI_CCSS) */
 
@@ -2005,7 +2007,7 @@
 			switch (subcmd->u.cc_request_rsp.status) {
 			case 0:/* success */
 				ast_cc_monitor_request_acked(monitor->core_id,
-					"Far end accepted CC request");
+					"ISDN far end accepted CC request");
 				break;
 			case 1:/* timeout */
 				ast_verb(2, "%s CC request timeout\n", sig_pri_cc_type_name);
@@ -5368,8 +5370,7 @@
  */
 int sig_pri_cc_monitor_init(struct ast_cc_monitor *monitor, const int core_id)
 {
-	/*! \todo BUGBUG sig_pri_cc_monitor_init() not written */
-	return -1;
+	return 0;
 }
 #endif	/* defined(HAVE_PRI_CCSS) */
 
@@ -5395,8 +5396,37 @@
  */
 int sig_pri_cc_monitor_req_cc(struct ast_cc_monitor *monitor, const int core_id, struct ast_cc_monitor_link *parent_link)
 {
-	/*! \todo BUGBUG sig_pri_cc_monitor_req_cc() not written */
-	return -1;
+	struct sig_pri_cc_monitor_instance *instance;
+	int cc_mode;
+	int res;
+
+	switch (parent_link->service) {
+	case AST_CC_CCBS:
+		cc_mode = 0;/* CCBS */
+		break;
+	case AST_CC_CCNR:
+		cc_mode = 1;/* CCNR */
+		break;
+	default:
+		/* CC service not supported by ISDN. */
+		return -1;
+	}
+
+	instance = sig_pri_find_cc_monitor_by_core_id(core_id);
+	if (!instance) {
+		return -1;
+	}
+	if (instance->pri) {
+		/* libpri handles it's own available timer. */
+		ast_mutex_lock(&instance->pri->lock);
+		res = pri_cc_req(instance->pri->pri, instance->cc_id, cc_mode);
+		ast_mutex_unlock(&instance->pri->lock);
+	} else {
+		res = -1;
+	}
+
+	ao2_ref(instance, -1);
+	return res;
 }
 #endif	/* defined(HAVE_PRI_CCSS) */
 
@@ -5417,8 +5447,24 @@
  */
 int sig_pri_cc_monitor_suspend(struct ast_cc_monitor *monitor, const int core_id)
 {
-	/*! \todo BUGBUG sig_pri_cc_monitor_suspend() not written */
-	return -1;
+	struct sig_pri_cc_monitor_instance *instance;
+	int res;
+
+	instance = sig_pri_find_cc_monitor_by_core_id(core_id);
+	if (!instance) {
+		return -1;
+	}
+	if (instance->pri) {
+		ast_mutex_lock(&instance->pri->lock);
+		pri_cc_status(instance->pri->pri, instance->cc_id, 1/* busy */);
+		ast_mutex_unlock(&instance->pri->lock);
+		res = 0;
+	} else {
+		res = -1;
+	}
+
+	ao2_ref(instance, -1);
+	return res;
 }
 #endif	/* defined(HAVE_PRI_CCSS) */
 
@@ -5438,8 +5484,24 @@
  */
 int sig_pri_cc_monitor_unsuspend(struct ast_cc_monitor *monitor, const int core_id)
 {
-	/*! \todo BUGBUG sig_pri_cc_monitor_unsuspend() not written */
-	return -1;
+	struct sig_pri_cc_monitor_instance *instance;
+	int res;
+
+	instance = sig_pri_find_cc_monitor_by_core_id(core_id);
+	if (!instance) {
+		return -1;
+	}
+	if (instance->pri) {
+		ast_mutex_lock(&instance->pri->lock);
+		pri_cc_status(instance->pri->pri, instance->cc_id, 0/* free */);
+		ast_mutex_unlock(&instance->pri->lock);
+		res = 0;
+	} else {
+		res = -1;
+	}
+
+	ao2_ref(instance, -1);
+	return res;
 }
 #endif	/* defined(HAVE_PRI_CCSS) */
 
@@ -5463,8 +5525,38 @@
  */
 int sig_pri_cc_monitor_status_rsp(struct ast_cc_monitor *monitor, const int core_id, enum ast_device_state devstate)
 {
-	/*! \todo BUGBUG sig_pri_cc_monitor_status_rsp() not written */
-	return -1;
+	struct sig_pri_cc_monitor_instance *instance;
+	int cc_status;
+	int res;
+
+	switch (devstate) {
+	case AST_DEVICE_UNKNOWN:
+	case AST_DEVICE_NOT_INUSE:
+		cc_status = 0;/* free */
+		break;
+	case AST_DEVICE_BUSY:
+	case AST_DEVICE_INUSE:
+		cc_status = 1;/* busy */
+		break;
+	default:
+		/* Don't know how to interpret this device state into free/busy status. */
+		return 0;
+	}
+	instance = sig_pri_find_cc_monitor_by_core_id(core_id);
+	if (!instance) {
+		return -1;
+	}
+	if (instance->pri) {
+		ast_mutex_lock(&instance->pri->lock);
+		pri_cc_status_req_rsp(instance->pri->pri, instance->cc_id, cc_status);
+		ast_mutex_unlock(&instance->pri->lock);
+		res = 0;
+	} else {
+		res = -1;
+	}
+
+	ao2_ref(instance, -1);
+	return res;
 }
 #endif	/* defined(HAVE_PRI_CCSS) */
 
@@ -5512,7 +5604,7 @@
  */
 void sig_pri_cc_monitor_destructor(struct ast_cc_monitor *monitor)
 {
-	/*! \todo BUGBUG sig_pri_cc_monitor_destructor() not written */
+	/* Move along.  Move along.  Nothing to do here. */
 }
 #endif	/* defined(HAVE_PRI_CCSS) */
 
@@ -5533,7 +5625,14 @@
  */
 void sig_pri_cc_monitor_instance_destructor(const int core_id)
 {
-	/*! \todo BUGBUG sig_pri_cc_monitor_instance_destructor() not written */
+	struct sig_pri_cc_monitor_instance *instance;
+
+	instance = sig_pri_find_cc_monitor_by_core_id(core_id);
+	if (!instance) {
+		return;
+	}
+	ao2_unlink(sig_pri_cc_monitors, instance);
+	ao2_ref(instance, -1);
 }
 #endif	/* defined(HAVE_PRI_CCSS) */
 




More information about the asterisk-commits mailing list