[svn-commits] rmudgett: branch rmudgett/sig_ss7 r260799 - /team/rmudgett/sig_ss7/channels/

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon May 3 18:26:13 CDT 2010


Author: rmudgett
Date: Mon May  3 18:26:09 2010
New Revision: 260799

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=260799
Log:
SS7 extraction work in progress.

Modified:
    team/rmudgett/sig_ss7/channels/chan_dahdi.c
    team/rmudgett/sig_ss7/channels/sig_ss7.h

Modified: team/rmudgett/sig_ss7/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/sig_ss7/channels/chan_dahdi.c?view=diff&rev=260799&r1=260798&r2=260799
==============================================================================
--- team/rmudgett/sig_ss7/channels/chan_dahdi.c (original)
+++ team/rmudgett/sig_ss7/channels/chan_dahdi.c Mon May  3 18:26:09 2010
@@ -514,37 +514,102 @@
 static int ringt_base = DEFAULT_RINGT;
 
 #ifdef HAVE_SS7
-
-#define LINKSTATE_INALARM	(1 << 0)
-#define LINKSTATE_STARTING	(1 << 1)
-#define LINKSTATE_UP		(1 << 2)
-#define LINKSTATE_DOWN		(1 << 3)
-
-#define SS7_NAI_DYNAMIC		-1
-
-#define LINKSET_FLAG_EXPLICITACM (1 << 0)
+/* BUGBUG sig_ss7 callback functions ----v*/
+/*!
+ * \internal
+ * \brief Set the caller id information in the parent module.
+ * \since 1.8
+ *
+ * \param p sig_ss7 channel structure.
+ *
+ * \return Nothing
+ */
+static void sig_ss7_set_caller_id(struct sig_ss7_chan *p)
+{
+#if 0
+	struct ast_party_caller caller;
+
+	if (p->calls->set_callerid) {
+		ast_party_caller_init(&caller);
+		caller.id.number = p->cid_num;
+		caller.id.name = p->cid_name;
+		if (!ast_strlen_zero(p->cid_subaddr)) {
+			caller.id.subaddress.valid = 1;
+			//caller.id.subaddress.type = 0;/* nsap */
+			//caller.id.subaddress.odd_even_indicator = 0;
+			caller.id.subaddress.str = p->cid_subaddr;
+		}
+		caller.id.number_type = p->cid_ton;
+		caller.id.number_presentation = p->callingpres;
+		caller.ani = p->cid_ani;
+		caller.ani2 = p->cid_ani2;
+		p->calls->set_callerid(p->chan_pvt, &caller);
+	}
+#endif
+	/* BUGBUG sig_ss7_set_caller_id() not written */
+}
+
+/*!
+ * \internal
+ * \brief Set the Dialed Number Identifier.
+ * \since 1.8
+ *
+ * \param p sig_ss7 channel structure.
+ * \param dnid Dialed Number Identifier string.
+ *
+ * \return Nothing
+ */
+static void sig_ss7_set_dnid(struct sig_ss7_chan *p, const char *dnid)
+{
+	if (p->calls->set_dnid) {
+		p->calls->set_dnid(p->chan_pvt, dnid);
+	}
+}
+
+/*!
+ * \internal
+ * \brief Set the Redirecting Directory Number Information Service (RDNIS).
+ * \since 1.8
+ *
+ * \param p sig_ss7 channel structure.
+ * \param rdnis Redirecting Directory Number Information Service (RDNIS) string.
+ *
+ * \return Nothing
+ */
+static void sig_ss7_set_rdnis(struct sig_ss7_chan *p, const char *rdnis)
+{
+	if (p->calls->set_rdnis) {
+		p->calls->set_rdnis(p->chan_pvt, rdnis);
+	}
+}
+
+static void sig_ss7_unlock_private(struct sig_ss7_chan *p)
+{
+	if (p->calls->unlock_private) {
+		p->calls->unlock_private(p->chan_pvt);
+	}
+}
+
+static void sig_ss7_lock_private(struct sig_ss7_chan *p)
+{
+	if (p->calls->lock_private) {
+		p->calls->lock_private(p->chan_pvt);
+	}
+}
+
+static void sig_ss7_loopback(struct sig_ss7_chan *p, int enable)
+{
+	if (p->loopedback != enable) {
+		p->loopedback = enable;
+		if (p->calls->set_loopback) {
+			p->calls->set_loopback(p->chan_pvt, enable);
+		}
+	}
+}
+/* BUGBUG sig_ss7 callback functions ----^*/
 
 struct dahdi_ss7 {
-	pthread_t master;						/*!< Thread of master */
-	ast_mutex_t lock;
-	int fds[SIG_SS7_NUM_DCHANS];
-	int numsigchans;
-	int linkstate[SIG_SS7_NUM_DCHANS];
-	int numchans;
-	int type;
-	enum {
-		LINKSET_STATE_DOWN = 0,
-		LINKSET_STATE_UP
-	} state;
-	char called_nai;						/*!< Called Nature of Address Indicator */
-	char calling_nai;						/*!< Calling Nature of Address Indicator */
-	char internationalprefix[10];					/*!< country access code ('00' for european dialplans) */
-	char nationalprefix[10];					/*!< area access code ('0' for european dialplans) */
-	char subscriberprefix[20];					/*!< area access code + area code ('0'+area code for european dialplans) */
-	char unknownprefix[20];						/*!< for unknown dialplans */
-	struct ss7 *ss7;
-	struct dahdi_pvt *pvts[SIG_SS7_MAX_CHANNELS];	/*!< Member channel pvt structs */
-	int flags;							/*!< Linkset flags */
+	struct sig_ss7_linkset ss7;
 };
 
 static struct dahdi_ss7 linksets[NUM_SPANS];
@@ -1208,33 +1273,7 @@
 	int dsp_features;
 #ifdef HAVE_SS7
 	/*! \brief SS7 control parameters */
-	struct dahdi_ss7 *ss7;
-	/*! \brief Opaque libss7 call control structure */
-	struct isup_call *ss7call;
-	char charge_number[50];
-	char gen_add_number[50];
-	char gen_dig_number[50];
-	char orig_called_num[50];
-	char redirecting_num[50];
-	char generic_name[50];
-	unsigned char gen_add_num_plan;
-	unsigned char gen_add_nai;
-	unsigned char gen_add_pres_ind;
-	unsigned char gen_add_type;
-	unsigned char gen_dig_type;
-	unsigned char gen_dig_scheme;
-	char jip_number[50];
-	unsigned char lspi_type;
-	unsigned char lspi_scheme;
-	unsigned char lspi_context;
-	char lspi_ident[50];
-	unsigned int call_ref_ident;
-	unsigned int call_ref_pc;
-	unsigned char calling_party_cat;
-	int transcap;
-	int cic;							/*!< CIC associated with channel */
-	unsigned int dpc;						/*!< CIC's DPC */
-	unsigned int loopedback:1;
+	struct sig_ss7_linkset *ss7;
 #endif
 #ifdef HAVE_OPENR2
 	struct dahdi_mfcr2 *mfcr2;
@@ -1346,7 +1385,7 @@
 		},
 #endif
 #ifdef HAVE_SS7
-		.ss7 = {
+		.ss7.ss7 = {
 			.called_nai = SS7_NAI_NATIONAL,
 			.calling_nai = SS7_NAI_NATIONAL,
 			.internationalprefix = "",
@@ -2345,7 +2384,7 @@
 	return;
 }
 
-static struct ast_channel *dahdi_new(struct dahdi_pvt *, int, int, int, int, int, const char *);
+static struct ast_channel *dahdi_new(struct dahdi_pvt *i, int state, int startpbx, int idx, int law, int transfercapability, const char *linkedid);
 
 static struct ast_channel *my_new_analog_ast_channel(void *pvt, int state, int startpbx, enum analog_sub sub, const struct ast_channel *requestor)
 {
@@ -2717,7 +2756,9 @@
 	old_chan->dsp = NULL;
 	old_chan->dsp_features = 0;
 }
-
+#endif	/* defined(HAVE_PRI) */
+
+#if defined(HAVE_PRI)
 static int sig_pri_tone_to_dahditone(enum sig_pri_tone tone)
 {
 	switch (tone) {
@@ -2739,7 +2780,9 @@
 		return -1;
 	}
 }
-
+#endif	/* defined(HAVE_PRI) */
+
+#if defined(HAVE_PRI)
 static void my_handle_dchan_exception(struct sig_pri_pri *pri, int index)
 {
 	int x, res;
@@ -2755,14 +2798,18 @@
 		pri_event_noalarm(pri, index, 0);
 	}
 }
-
+#endif	/* defined(HAVE_PRI) */
+
+#if defined(HAVE_PRI)
 static int my_pri_play_tone(void *pvt, enum sig_pri_tone tone)
 {
 	struct dahdi_pvt *p = pvt;
 
 	return tone_zone_play_tone(p->subs[SUB_REAL].dfd, sig_pri_tone_to_dahditone(tone));
 }
-
+#endif	/* defined(HAVE_PRI) */
+
+#if defined(HAVE_PRI) || defined(HAVE_SS7)
 /*!
  * \internal
  * \brief Set the caller id information.
@@ -2773,7 +2820,7 @@
  *
  * \return Nothing
  */
-static void my_pri_set_callerid(void *pvt, const struct ast_party_caller *caller)
+static void my_set_callerid(void *pvt, const struct ast_party_caller *caller)
 {
 	struct dahdi_pvt *p = pvt;
 
@@ -2790,7 +2837,9 @@
 	ast_copy_string(p->cid_ani, S_OR(caller->ani, ""), sizeof(p->cid_ani));
 	p->cid_ani2 = caller->ani2;
 }
-
+#endif	/* defined(HAVE_PRI) || defined(HAVE_SS7) */
+
+#if defined(HAVE_PRI) || defined(HAVE_SS7)
 /*!
  * \internal
  * \brief Set the Dialed Number Identifier.
@@ -2801,13 +2850,15 @@
  *
  * \return Nothing
  */
-static void my_pri_set_dnid(void *pvt, const char *dnid)
+static void my_set_dnid(void *pvt, const char *dnid)
 {
 	struct dahdi_pvt *p = pvt;
 
 	ast_copy_string(p->dnid, dnid, sizeof(p->dnid));
 }
-
+#endif	/* defined(HAVE_PRI) || defined(HAVE_SS7) */
+
+#if defined(HAVE_PRI) || defined(HAVE_SS7)
 /*!
  * \internal
  * \brief Set the Redirecting Directory Number Information Service (RDNIS).
@@ -2818,13 +2869,15 @@
  *
  * \return Nothing
  */
-static void my_pri_set_rdnis(void *pvt, const char *rdnis)
+static void my_set_rdnis(void *pvt, const char *rdnis)
 {
 	struct dahdi_pvt *p = pvt;
 
 	ast_copy_string(p->rdnis, rdnis, sizeof(p->rdnis));
 }
-
+#endif	/* defined(HAVE_PRI) || defined(HAVE_SS7) */
+
+#if defined(HAVE_PRI)
 /*!
  * \internal
  * \brief Make a dialstring for native ISDN CC to recall properly.
@@ -2883,7 +2936,9 @@
 	/* Insert the ISDN span channel restriction into the dialstring. */
 	snprintf(buf, buf_size, "%s/i%d-%s", args.tech, pvt->pri->span, args.group);
 }
-
+#endif	/* defined(HAVE_PRI) */
+
+#if defined(HAVE_PRI)
 /*!
  * \internal
  * \brief Reevaluate the PRI span device state.
@@ -2954,7 +3009,9 @@
 	}
 #endif	/* defined(THRESHOLD_DEVSTATE_PLACEHOLDER) */
 }
-
+#endif	/* defined(HAVE_PRI) */
+
+#if defined(HAVE_PRI)
 /*!
  * \internal
  * \brief Reference this module.
@@ -2966,7 +3023,9 @@
 {
 	ast_module_ref(ast_module_info->self);
 }
-
+#endif	/* defined(HAVE_PRI) */
+
+#if defined(HAVE_PRI)
 /*!
  * \internal
  * \brief Unreference this module.
@@ -2978,7 +3037,9 @@
 {
 	ast_module_unref(ast_module_info->self);
 }
-
+#endif	/* defined(HAVE_PRI) */
+
+#if defined(HAVE_PRI)
 static int dahdi_new_pri_nobch_channel(struct sig_pri_pri *pri);
 
 static struct sig_pri_callback dahdi_pri_callbacks =
@@ -2993,9 +3054,9 @@
 	.fixup_chans = my_pri_fixup_chans,
 	.set_dialing = my_set_dialing,
 	.set_digital = my_set_digital,
-	.set_callerid = my_pri_set_callerid,
-	.set_dnid = my_pri_set_dnid,
-	.set_rdnis = my_pri_set_rdnis,
+	.set_callerid = my_set_callerid,
+	.set_dnid = my_set_dnid,
+	.set_rdnis = my_set_rdnis,
 	.new_nobch_intf = dahdi_new_pri_nobch_channel,
 	.get_orig_dialstring = my_get_orig_dialstring,
 	.make_cc_dialstring = my_pri_make_cc_dialstring,
@@ -3004,6 +3065,123 @@
 	.module_unref = my_module_unref,
 };
 #endif	/* defined(HAVE_PRI) */
+
+#if defined(HAVE_SS7)
+static void my_ss7_set_loopback(void *pvt, int enable)
+{
+	struct dahdi_pvt *p = pvt;
+
+	if (ioctl(p->subs[SUB_REAL].dfd, DAHDI_LOOPBACK, &enable)) {
+		ast_log(LOG_WARNING, "Unable to set loopback on channel %d: %s\n", p->channel,
+			strerror(errno));
+	}
+}
+#endif	/* defined(HAVE_SS7) */
+
+#if defined(HAVE_SS7)
+/*!
+ * \internal
+ * \brief Create a new asterisk channel structure for SS7.
+ * \since 1.8
+ *
+ * \param pvt Private channel structure.
+ * \param state Initial state of new channel.
+ * \param startpbx TRUE if PBS is started
+ * \param law Combanding law to use.
+ * \param exten Dialplan extension for incoming call.
+ * \param requestor Channel requesting this new channel.
+ *
+ * \retval ast_channel on success.
+ * \retval NULL on error.
+ */
+static struct ast_channel *my_new_ss7_ast_channel(void *pvt, int state, int startpbx, enum sig_ss7_law law, char *exten, const struct ast_channel *requestor)
+{
+	struct dahdi_pvt *p = pvt;
+	int audio;
+	int newlaw = -1;
+
+	/* Set to audio mode at this point */
+	audio = 1;
+	if (ioctl(p->subs[SUB_REAL].dfd, DAHDI_AUDIOMODE, &audio) == -1)
+		ast_log(LOG_WARNING, "Unable to set audio mode on channel %d to %d: %s\n",
+			p->channel, audio, strerror(errno));
+
+	if (law != SIG_SS7_DEFLAW) {
+		dahdi_setlaw(p->subs[SUB_REAL].dfd,
+			(law == SIG_SS7_ULAW) ? DAHDI_LAW_MULAW : DAHDI_LAW_ALAW);
+	}
+
+	ast_copy_string(p->exten, exten, sizeof(p->exten));
+
+	switch (law) {
+	case SIG_SS7_DEFLAW:
+		newlaw = 0;
+		break;
+	case SIG_SS7_ALAW:
+		newlaw = DAHDI_LAW_ALAW;
+		break;
+	case SIG_SS7_ULAW:
+		newlaw = DAHDI_LAW_MULAW;
+		break;
+	}
+	return dahdi_new(p, state, startpbx, SUB_REAL, newlaw, 0,
+		requestor ? requestor->linkedid : "");
+
+	/*! \todo BUGBUG my_new_ss7_ast_channel() not written */
+}
+#endif	/* defined(HAVE_SS7) */
+
+#if defined(HAVE_SS7)
+static int sig_ss7_tone_to_dahditone(enum sig_ss7_tone tone)
+{
+	switch (tone) {
+	case SIG_SS7_TONE_RINGTONE:
+		return DAHDI_TONE_RINGTONE;
+	case SIG_SS7_TONE_STUTTER:
+		return DAHDI_TONE_STUTTER;
+	case SIG_SS7_TONE_CONGESTION:
+		return DAHDI_TONE_CONGESTION;
+	case SIG_SS7_TONE_DIALTONE:
+		return DAHDI_TONE_DIALTONE;
+	case SIG_SS7_TONE_DIALRECALL:
+		return DAHDI_TONE_DIALRECALL;
+	case SIG_SS7_TONE_INFO:
+		return DAHDI_TONE_INFO;
+	case SIG_SS7_TONE_BUSY:
+		return DAHDI_TONE_BUSY;
+	default:
+		return -1;
+	}
+}
+#endif	/* defined(HAVE_SS7) */
+
+#if defined(HAVE_SS7)
+static int my_ss7_play_tone(void *pvt, enum sig_ss7_tone tone)
+{
+	struct dahdi_pvt *p = pvt;
+
+	return tone_zone_play_tone(p->subs[SUB_REAL].dfd, sig_ss7_tone_to_dahditone(tone));
+}
+#endif	/* defined(HAVE_SS7) */
+
+#if defined(HAVE_SS7)
+static struct sig_ss7_callback dahdi_ss7_callbacks =
+{
+	.lock_private = my_lock_private,
+	.unlock_private = my_unlock_private,
+
+	.set_echocanceller = my_set_echocanceller,
+	.set_loopback = my_ss7_set_loopback,
+
+	.new_ast_channel = my_new_ss7_ast_channel,
+	.play_tone = my_ss7_play_tone,
+
+	.set_dialing = my_set_dialing,
+	.set_callerid = my_set_callerid,
+	.set_dnid = my_set_dnid,
+	.set_rdnis = my_set_rdnis,
+};
+#endif	/* defined(HAVE_SS7) */
 
 /*!
  * \brief Send MWI state change
@@ -3138,26 +3316,26 @@
 static struct dahdi_pvt *round_robin[32];
 
 #if defined(HAVE_SS7)
-static inline void ss7_rel(struct dahdi_ss7 *ss7)
+static inline void ss7_rel(struct sig_ss7_linkset *ss7)
 {
 	ast_mutex_unlock(&ss7->lock);
 }
 #endif	/* defined(HAVE_SS7) */
 
 #if defined(HAVE_SS7)
-static inline int ss7_grab(struct dahdi_pvt *pvt, struct dahdi_ss7 *pri)
+static inline int ss7_grab(struct dahdi_pvt *pvt, struct sig_ss7_linkset *ss7)
 {
 	int res;
 	/* Grab the lock first */
 	do {
-		res = ast_mutex_trylock(&pri->lock);
+		res = ast_mutex_trylock(&ss7->lock);
 		if (res) {
 			DEADLOCK_AVOIDANCE(&pvt->lock);
 		}
 	} while (res);
 	/* Then break the poll */
-	if (pri->master != AST_PTHREADT_NULL)
-		pthread_kill(pri->master, SIGURG);
+	if (ss7->master != AST_PTHREADT_NULL)
+		pthread_kill(ss7->master, SIGURG);
 	return 0;
 }
 #endif	/* defined(HAVE_SS7) */
@@ -3203,7 +3381,7 @@
 	if (data) {
 		switch (p->sig) {
 		case SIG_SS7:
-			ast_mutex_unlock(&ss7->lock);
+			ast_mutex_unlock(&ss7->ss7.lock);
 			break;
 		default:
 			break;
@@ -3226,7 +3404,7 @@
 	if (data) {
 		switch (p->sig) {
 		case SIG_SS7:
-			ast_mutex_lock(&ss7->lock);
+			ast_mutex_lock(&ss7->ss7.lock);
 			break;
 		default:
 			break;
@@ -3795,8 +3973,8 @@
 #if defined(HAVE_SS7)
 static void dahdi_close_ss7_fd(struct dahdi_ss7 *ss7, int fd_num)
 {
-	dahdi_close(ss7->fds[fd_num]);
-	ss7->fds[fd_num] = -1;
+	dahdi_close(ss7->ss7.fds[fd_num]);
+	ss7->ss7.fds[fd_num] = -1;
 }
 #endif	/* defined(HAVE_SS7) */
 
@@ -11532,17 +11710,17 @@
 				/* DB: Add CIC's DPC information */
 				tmp->dpc = cur_defaultdpc;
 
-				tmp->ss7 = ss7;
+				tmp->ss7 = &ss7->ss7;
 				tmp->ss7call = NULL;
-				ss7->pvts[ss7->numchans++] = tmp;
-
-				ast_copy_string(ss7->internationalprefix, conf->ss7.internationalprefix, sizeof(ss7->internationalprefix));
-				ast_copy_string(ss7->nationalprefix, conf->ss7.nationalprefix, sizeof(ss7->nationalprefix));
-				ast_copy_string(ss7->subscriberprefix, conf->ss7.subscriberprefix, sizeof(ss7->subscriberprefix));
-				ast_copy_string(ss7->unknownprefix, conf->ss7.unknownprefix, sizeof(ss7->unknownprefix));
-
-				ss7->called_nai = conf->ss7.called_nai;
-				ss7->calling_nai = conf->ss7.calling_nai;
+				ss7->ss7.pvts[ss7->ss7.numchans++] = tmp;
+
+				ast_copy_string(ss7->ss7.internationalprefix, conf->ss7.ss7.internationalprefix, sizeof(ss7->ss7.internationalprefix));
+				ast_copy_string(ss7->ss7.nationalprefix, conf->ss7.ss7.nationalprefix, sizeof(ss7->ss7.nationalprefix));
+				ast_copy_string(ss7->ss7.subscriberprefix, conf->ss7.ss7.subscriberprefix, sizeof(ss7->ss7.subscriberprefix));
+				ast_copy_string(ss7->ss7.unknownprefix, conf->ss7.ss7.unknownprefix, sizeof(ss7->ss7.unknownprefix));
+
+				ss7->ss7.called_nai = conf->ss7.ss7.called_nai;
+				ss7->ss7.calling_nai = conf->ss7.ss7.calling_nai;
 			}
 #endif
 #ifdef HAVE_OPENR2
@@ -12834,7 +13012,7 @@
 }
 
 #if defined(HAVE_SS7)
-static int ss7_find_cic(struct dahdi_ss7 *linkset, int cic, unsigned int dpc)
+static int ss7_find_cic(struct sig_ss7_linkset *linkset, int cic, unsigned int dpc)
 {
 	int i;
 	int winner = -1;
@@ -12849,10 +13027,10 @@
 #endif	/* defined(HAVE_SS7) */
 
 #if defined(HAVE_SS7)
-static void ss7_handle_cqm(struct dahdi_ss7 *linkset, int startcic, int endcic, unsigned int dpc)
+static void ss7_handle_cqm(struct sig_ss7_linkset *linkset, int startcic, int endcic, unsigned int dpc)
 {
 	unsigned char status[32];
-	struct dahdi_pvt *p = NULL;
+	struct sig_ss7_chan *p = NULL;
 	int i, offset;
 
 	for (i = 0; i < linkset->numchans; i++) {
@@ -12883,23 +13061,23 @@
 #endif	/* defined(HAVE_SS7) */
 
 #if defined(HAVE_SS7)
-static inline void ss7_hangup_cics(struct dahdi_ss7 *linkset, int startcic, int endcic, unsigned int dpc)
+static inline void ss7_hangup_cics(struct sig_ss7_linkset *linkset, int startcic, int endcic, unsigned int dpc)
 {
 	int i;
 
 	for (i = 0; i < linkset->numchans; i++) {
 		if (linkset->pvts[i] && (linkset->pvts[i]->dpc == dpc && ((linkset->pvts[i]->cic >= startcic) && (linkset->pvts[i]->cic <= endcic)))) {
-			ast_mutex_lock(&linkset->pvts[i]->lock);
+			sig_ss7_lock_private(linkset->pvts[i]);
 			if (linkset->pvts[i]->owner)
 				linkset->pvts[i]->owner->_softhangup |= AST_SOFTHANGUP_DEV;
-			ast_mutex_unlock(&linkset->pvts[i]->lock);
+			sig_ss7_unlock_private(linkset->pvts[i]);
 		}
 	}
 }
 #endif	/* defined(HAVE_SS7) */
 
 #if defined(HAVE_SS7)
-static inline void ss7_block_cics(struct dahdi_ss7 *linkset, int startcic, int endcic, unsigned int dpc, unsigned char state[], int block)
+static inline void ss7_block_cics(struct sig_ss7_linkset *linkset, int startcic, int endcic, unsigned int dpc, unsigned char state[], int block)
 {
 	int i;
 
@@ -12916,7 +13094,7 @@
 #endif	/* defined(HAVE_SS7) */
 
 #if defined(HAVE_SS7)
-static void ss7_inservice(struct dahdi_ss7 *linkset, int startcic, int endcic, unsigned int dpc)
+static void ss7_inservice(struct sig_ss7_linkset *linkset, int startcic, int endcic, unsigned int dpc)
 {
 	int i;
 
@@ -12928,7 +13106,7 @@
 #endif	/* defined(HAVE_SS7) */
 
 #if defined(HAVE_SS7)
-static void ss7_reset_linkset(struct dahdi_ss7 *linkset)
+static void ss7_reset_linkset(struct sig_ss7_linkset *linkset)
 {
 	int i, startcic = -1, endcic, dpc;
 
@@ -12958,21 +13136,8 @@
 #endif	/* defined(HAVE_SS7) */
 
 #if defined(HAVE_SS7)
-static void dahdi_loopback(struct dahdi_pvt *p, int enable)
-{
-	if (p->loopedback != enable) {
-		if (ioctl(p->subs[SUB_REAL].dfd, DAHDI_LOOPBACK, &enable)) {
-			ast_log(LOG_WARNING, "Unable to set loopback on channel %d: %s\n", p->channel, strerror(errno));
-			return;
-		}
-		p->loopedback = enable;
-	}
-}
-#endif	/* defined(HAVE_SS7) */
-
-#if defined(HAVE_SS7)
 /* XXX: This function is assumed to be called with the private channel lock and linkset lock held */
-static void ss7_start_call(struct dahdi_pvt *p, struct dahdi_ss7 *linkset)
+static void ss7_start_call(struct sig_ss7_chan *p, struct sig_ss7_linkset *linkset)
 {
 	struct ss7 *ss7 = linkset->ss7;
 	int res;
@@ -12999,7 +13164,6 @@
 
 	ast_mutex_unlock(&linkset->lock);
 	c = dahdi_new(p, AST_STATE_RING, 1, SUB_REAL, law, 0, NULL);
-
 	if (!c) {
 		ast_log(LOG_WARNING, "Unable to start PBX on CIC %d\n", p->cic);
 		/* Holding this lock is assumed entering the function */
@@ -13014,8 +13178,9 @@
 	 * when receiving either and IAM or a COT message.  Since they are only accessed
 	 * from this context, we should be safe to unlock around them */
 
-	ast_mutex_unlock(&p->lock);
-
+	sig_ss7_unlock_private(p);
+
+	/*! \todo XXX SS7 Crash possible because we are setting channel variables after starting the PBX! */
 	if (!ast_strlen_zero(p->charge_number)) {
 		pbx_builtin_setvar_helper(c, "SS7_CHARGE_NUMBER", p->charge_number);
 		/* Clear this after we set it */
@@ -13084,13 +13249,13 @@
 		p->generic_name[0] = 0;
 	}
 
-	ast_mutex_lock(&p->lock);
+	sig_ss7_lock_private(p);
 	ast_mutex_lock(&linkset->lock);
 }
 #endif	/* defined(HAVE_SS7) */
 
 #if defined(HAVE_SS7)
-static void ss7_apply_plan_to_number(char *buf, size_t size, const struct dahdi_ss7 *ss7, const char *number, const unsigned nai)
+static void ss7_apply_plan_to_number(char *buf, size_t size, const struct sig_ss7_linkset *ss7, const char *number, const unsigned nai)
 {
 	if (ast_strlen_zero(number)) { /* make sure a number exists so prefix isn't placed on an empty string */
 		if (size) {
@@ -13130,16 +13295,17 @@
 {
 	int res, i;
 	struct timeval *next = NULL, tv;
-	struct dahdi_ss7 *linkset = (struct dahdi_ss7 *) data;
+	struct sig_ss7_linkset *linkset = (struct sig_ss7_linkset *) data;
 	struct ss7 *ss7 = linkset->ss7;
 	ss7_event *e = NULL;
-	struct dahdi_pvt *p;
+	struct sig_ss7_chan *p;
 	int chanpos;
 	struct pollfd pollers[SIG_SS7_NUM_DCHANS];
 	int cic;
 	unsigned int dpc;
 	int nextms = 0;
 
+	ss7_set_debug(ss7, SIG_SS7_DEBUG_DEFAULT);
 	ss7_start(ss7);
 
 	while(1) {
@@ -13255,7 +13421,7 @@
 					break;
 				}
 				p = linkset->pvts[chanpos];
-				ast_mutex_lock(&p->lock);
+				sig_ss7_lock_private(p);
 				switch (e->cpg.event) {
 				case CPG_EVENT_ALERTING:
 					p->alerting = 1;
@@ -13279,7 +13445,7 @@
 					ast_debug(1, "Do not handle CPG with event type 0x%x\n", e->cpg.event);
 				}
 
-				ast_mutex_unlock(&p->lock);
+				sig_ss7_unlock_private(p);
 				break;
 			case ISUP_EVENT_RSC:
 				ast_verbose("Resetting CIC %d\n", e->rsc.cic);
@@ -13289,7 +13455,7 @@
 					break;
 				}
 				p = linkset->pvts[chanpos];
-				ast_mutex_lock(&p->lock);
+				sig_ss7_lock_private(p);
 				p->inservice = 1;
 				p->remotelyblocked = 0;
 				dpc = p->dpc;
@@ -13298,7 +13464,7 @@
 					p->ss7call = NULL;
 				if (p->owner)
 					p->owner->_softhangup |= AST_SOFTHANGUP_DEV;
-				ast_mutex_unlock(&p->lock);
+				sig_ss7_unlock_private(p);
 				isup_rlc(ss7, e->rsc.call);
 				break;
 			case ISUP_EVENT_GRS:
@@ -13331,14 +13497,14 @@
 					break;
 				}
 				p = linkset->pvts[chanpos];
-				ast_mutex_lock(&p->lock);
+				sig_ss7_lock_private(p);
 				if (p->owner) {
 					if (p->ss7call == e->iam.call) {
-						ast_mutex_unlock(&p->lock);
+						sig_ss7_unlock_private(p);
 						ast_log(LOG_WARNING, "Duplicate IAM requested on CIC %d\n", e->iam.cic);
 						break;
 					} else {
-						ast_mutex_unlock(&p->lock);
+						sig_ss7_unlock_private(p);
 						ast_log(LOG_WARNING, "Ring requested on CIC %d already in use!\n", e->iam.cic);
 						break;
 					}
@@ -13396,7 +13562,7 @@
 				if (ast_exists_extension(NULL, p->context, p->exten, 1, p->cid_num)) {
 
 					if (e->iam.cot_check_required) {
-						dahdi_loopback(p, 1);
+						sig_ss7_loopback(p, 1);
 					} else
 						ss7_start_call(p, linkset);
 				} else {
@@ -13404,7 +13570,7 @@
 					p->alreadyhungup = 1;
 					isup_rel(ss7, e->iam.call, AST_CAUSE_UNALLOCATED);
 				}
-				ast_mutex_unlock(&p->lock);
+				sig_ss7_unlock_private(p);
 				break;
 			case ISUP_EVENT_COT:
 				chanpos = ss7_find_cic(linkset, e->cot.cic, e->cot.opc);
@@ -13415,14 +13581,14 @@
 				}
 				p = linkset->pvts[chanpos];
 
-				ast_mutex_lock(&p->lock);
+				sig_ss7_lock_private(p);
 
 				if (p->loopedback) {
-					dahdi_loopback(p, 0);
+					sig_ss7_loopback(p, 0);
 					ss7_start_call(p, linkset);
 				}
 
-				ast_mutex_unlock(&p->lock);
+				sig_ss7_unlock_private(p);
 
 				break;
 			case ISUP_EVENT_CCR:
@@ -13435,9 +13601,9 @@
 
 				p = linkset->pvts[chanpos];
 
-				ast_mutex_lock(&p->lock);
-				dahdi_loopback(p, 1);
-				ast_mutex_unlock(&p->lock);
+				sig_ss7_lock_private(p);
+				sig_ss7_loopback(p, 1);
+				sig_ss7_unlock_private(p);
 
 				isup_lpa(linkset->ss7, e->ccr.cic, p->dpc);
 				break;
@@ -13451,9 +13617,9 @@
 
 				p = linkset->pvts[chanpos];
 
-				ast_mutex_lock(&p->lock);
-				dahdi_loopback(p, 1);
-				ast_mutex_unlock(&p->lock);
+				sig_ss7_lock_private(p);
+				sig_ss7_loopback(p, 1);
+				sig_ss7_unlock_private(p);
 
 				isup_cvr(linkset->ss7, e->cvt.cic, p->dpc);
 				break;
@@ -13464,7 +13630,7 @@
 					break;
 				}
 				p = linkset->pvts[chanpos];
-				ast_mutex_lock(&p->lock);
+				sig_ss7_lock_private(p);
 				if (p->owner) {
 					p->owner->hangupcause = e->rel.cause;
 					p->owner->_softhangup |= AST_SOFTHANGUP_DEV;
@@ -13472,12 +13638,12 @@
 					ast_log(LOG_WARNING, "REL on channel (CIC %d) without owner!\n", p->cic);
 
 				/* End the loopback if we have one */
-				dahdi_loopback(p, 0);
+				sig_ss7_loopback(p, 0);
 
 				isup_rlc(ss7, e->rel.call);
 				p->ss7call = NULL;
 
-				ast_mutex_unlock(&p->lock);
+				sig_ss7_unlock_private(p);
 				break;
 			case ISUP_EVENT_ACM:
 				chanpos = ss7_find_cic(linkset, e->acm.cic, e->acm.opc);
@@ -13496,7 +13662,7 @@
 						p->rlt = 1; /* Setting it but not using it here*/
 					}
 
-					ast_mutex_lock(&p->lock);
+					sig_ss7_lock_private(p);
 					dahdi_queue_frame(p, &f, linkset);
 					p->proceeding = 1;
 					p->dialing = 0;
@@ -13505,7 +13671,7 @@
 						p->alerting = 1;
 						p->subs[SUB_REAL].needringing = 1;
 					}
-					ast_mutex_unlock(&p->lock);
+					sig_ss7_unlock_private(p);
 				}
 				break;
 			case ISUP_EVENT_CGB:
@@ -13536,10 +13702,10 @@
 				}
 				p = linkset->pvts[chanpos];
 				ast_debug(1, "Unequiped Circuit Id Code on CIC %d\n", e->ucic.cic);
-				ast_mutex_lock(&p->lock);
+				sig_ss7_lock_private(p);
 				p->remotelyblocked = 1;
 				p->inservice = 0;
-				ast_mutex_unlock(&p->lock);			/* doesn't require a SS7 acknowledgement */
+				sig_ss7_unlock_private(p);/* doesn't require a SS7 acknowledgement */
 				break;
 			case ISUP_EVENT_BLO:
 				chanpos = ss7_find_cic(linkset, e->blo.cic, e->blo.opc);
@@ -13549,9 +13715,9 @@
 				}
 				p = linkset->pvts[chanpos];
 				ast_debug(1, "Blocking CIC %d\n", e->blo.cic);
-				ast_mutex_lock(&p->lock);
+				sig_ss7_lock_private(p);
 				p->remotelyblocked = 1;
-				ast_mutex_unlock(&p->lock);
+				sig_ss7_unlock_private(p);
 				isup_bla(linkset->ss7, e->blo.cic, p->dpc);
 				break;
 			case ISUP_EVENT_BLA:
@@ -13562,9 +13728,9 @@
 				}
 				ast_debug(1, "Blocking CIC %d\n", e->bla.cic);
 				p = linkset->pvts[chanpos];
-				ast_mutex_lock(&p->lock);
+				sig_ss7_lock_private(p);
 				p->locallyblocked = 1;
-				ast_mutex_unlock(&p->lock);
+				sig_ss7_unlock_private(p);
 				break;
 			case ISUP_EVENT_UBL:
 				chanpos = ss7_find_cic(linkset, e->ubl.cic, e->ubl.opc);
@@ -13574,9 +13740,9 @@
 				}
 				p = linkset->pvts[chanpos];
 				ast_debug(1, "Unblocking CIC %d\n", e->ubl.cic);
-				ast_mutex_lock(&p->lock);
+				sig_ss7_lock_private(p);
 				p->remotelyblocked = 0;
-				ast_mutex_unlock(&p->lock);
+				sig_ss7_unlock_private(p);
 				isup_uba(linkset->ss7, e->ubl.cic, p->dpc);
 				break;
 			case ISUP_EVENT_UBA:
@@ -13587,9 +13753,9 @@
 				}
 				p = linkset->pvts[chanpos];
 				ast_debug(1, "Unblocking CIC %d\n", e->uba.cic);
-				ast_mutex_lock(&p->lock);
+				sig_ss7_lock_private(p);
 				p->locallyblocked = 0;
-				ast_mutex_unlock(&p->lock);
+				sig_ss7_unlock_private(p);
 				break;
 			case ISUP_EVENT_CON:
 			case ISUP_EVENT_ANM:
@@ -13605,14 +13771,14 @@
 					break;
 				} else {
 					p = linkset->pvts[chanpos];
-					ast_mutex_lock(&p->lock);
+					sig_ss7_lock_private(p);
 					p->subs[SUB_REAL].needanswer = 1;
 					if (p->dsp && p->dsp_features) {
 						ast_dsp_set_features(p->dsp, p->dsp_features);
 						p->dsp_features = 0;
 					}
 					dahdi_enable_ec(p);
-					ast_mutex_unlock(&p->lock);
+					sig_ss7_unlock_private(p);
 				}
 				break;
 			case ISUP_EVENT_RLC:
@@ -13622,12 +13788,12 @@
 					break;
 				} else {
 					p = linkset->pvts[chanpos];
-					ast_mutex_lock(&p->lock);
+					sig_ss7_lock_private(p);
 					if (p->alreadyhungup)
 						p->ss7call = NULL;
 					else
 						ast_log(LOG_NOTICE, "Received RLC out and we haven't sent REL.  Ignoring.\n");
-					ast_mutex_unlock(&p->lock);
+					sig_ss7_unlock_private(p);
 					}
 					break;
 			case ISUP_EVENT_FAA:
@@ -13638,12 +13804,12 @@
 				} else {
 					p = linkset->pvts[chanpos];
 					ast_debug(1, "FAA received on CIC %d\n", e->faa.cic);
-					ast_mutex_lock(&p->lock);
+					sig_ss7_lock_private(p);
 					if (p->alreadyhungup){
 						p->ss7call = NULL;
 						ast_log(LOG_NOTICE, "Received FAA and we haven't sent FAR.  Ignoring.\n");
 					}
-					ast_mutex_unlock(&p->lock);
+					sig_ss7_unlock_private(p);
 				}
 				break;
 			default:
@@ -13661,33 +13827,34 @@
 #if defined(HAVE_SS7)
 static void dahdi_ss7_message(struct ss7 *ss7, char *s)
 {
-#if 0
 	int i;
 
-	for (i = 0; i < NUM_SPANS; i++)
-		if (linksets[i].ss7 == ss7)
-			break;
-
-	ast_verbose("[%d] %s", i+1, s);
-#else
+	if (ss7) {
+		for (i = 0; i < NUM_SPANS; i++) {
+			if (linksets[i].ss7.ss7 == ss7) {
+				ast_verbose("[%d] %s", i + 1, s);
+				return;
+			}
+		}
+	}
 	ast_verbose("%s", s);
-#endif
 }
 #endif	/* defined(HAVE_SS7) */
 
 #if defined(HAVE_SS7)
 static void dahdi_ss7_error(struct ss7 *ss7, char *s)
 {
-#if 0
 	int i;
 
-	for (i = 0; i < NUM_SPANS; i++)
-		if (linksets[i].ss7 == ss7)
-			break;
-
-#else
+	if (ss7) {
+		for (i = 0; i < NUM_SPANS; i++) {
+			if (linksets[i].ss7.ss7 == ss7) {
+				ast_log(LOG_ERROR, "[%d] %s", i + 1, s);
+				return;
+			}
+		}
+	}
 	ast_log(LOG_ERROR, "%s", s);
-#endif
 }
 #endif	/* defined(HAVE_SS7) */
 
@@ -14738,11 +14905,11 @@
 
 #if defined(HAVE_SS7)
 	for (i = 0; i < NUM_SPANS; i++) {
-		if (linksets[i].master && (linksets[i].master != AST_PTHREADT_NULL)) {
-			cancel_code = pthread_cancel(linksets[i].master);
-			pthread_kill(linksets[i].master, SIGURG);
-			ast_debug(4, "Waiting to join thread of span %d with pid=%p, cancel_code=%d\n", i, (void *) linksets[i].master, cancel_code);
-			pthread_join(linksets[i].master, NULL);
+		if (linksets[i].ss7.master && (linksets[i].ss7.master != AST_PTHREADT_NULL)) {
+			cancel_code = pthread_cancel(linksets[i].ss7.master);
+			pthread_kill(linksets[i].ss7.master, SIGURG);
+			ast_debug(4, "Waiting to join thread of span %d with pid=%p, cancel_code=%d\n", i, (void *) linksets[i].ss7.master, cancel_code);
+			pthread_join(linksets[i].ss7.master, NULL);
 			ast_debug(4, "Joined thread of span %d\n", i);
 		}
 	}
@@ -14806,10 +14973,10 @@
 
 	memset(linksets, 0, sizeof(linksets));
 	for (i = 0; i < NUM_SPANS; i++) {
-		ast_mutex_init(&linksets[i].lock);
-		linksets[i].master = AST_PTHREADT_NULL;
+		ast_mutex_init(&linksets[i].ss7.lock);
+		linksets[i].ss7.master = AST_PTHREADT_NULL;
 		for (j = 0; j < SIG_SS7_NUM_DCHANS; j++)
-			linksets[i].fds[j] = -1;
+			linksets[i].ss7.fds[j] = -1;
 	}
 	ss7_set_error(dahdi_ss7_error);
 	ss7_set_message(dahdi_ss7_message);
@@ -15077,12 +15244,15 @@
 #endif
 #ifdef HAVE_SS7
 			if (tmp->ss7) {
-				ast_cli(a->fd, "CIC: %d\n", tmp->cic);
+				struct sig_ss7_chan *chan = tmp->sig_pvt;
+
+				ast_cli(a->fd, "CIC: %d\n", chan->cic);
 			}
 #endif
 #ifdef HAVE_PRI
 			if (tmp->pri) {
 				struct sig_pri_chan *chan = tmp->sig_pvt;
+
 				ast_cli(a->fd, "PRI Flags: ");
 				if (chan->resetting)
 					ast_cli(a->fd, "Resetting ");
@@ -15730,39 +15900,40 @@
 		return -1;
 	}
 
-	if (!link->ss7)
-		link->ss7 = ss7_new(cur_ss7type);
-
-	if (!link->ss7) {
+	if (!link->ss7.ss7) {
+		link->ss7.ss7 = ss7_new(cur_ss7type);
+	}
+
+	if (!link->ss7.ss7) {
 		ast_log(LOG_ERROR, "Can't create new SS7!\n");
 		return -1;
 	}
 
-	link->type = cur_ss7type;
+	link->ss7.type = cur_ss7type;
 
 	if (cur_pointcode < 0) {
 		ast_log(LOG_ERROR, "Unspecified pointcode!\n");
 		return -1;
 	} else
-		ss7_set_pc(link->ss7, cur_pointcode);
+		ss7_set_pc(link->ss7.ss7, cur_pointcode);
 
 	if (sigchan < 0) {
 		ast_log(LOG_ERROR, "Invalid sigchan!\n");
 		return -1;
 	} else {
-		if (link->numsigchans >= SIG_SS7_NUM_DCHANS) {
+		if (link->ss7.numsigchans >= SIG_SS7_NUM_DCHANS) {
 			ast_log(LOG_ERROR, "Too many sigchans on linkset %d\n", cur_linkset);
 			return -1;
 		}
-		curfd = link->numsigchans;
-
-		link->fds[curfd] = open("/dev/dahdi/channel", O_RDWR, 0600);
-		if ((link->fds[curfd] < 0) || (ioctl(link->fds[curfd],DAHDI_SPECIFY,&sigchan) == -1)) {
+		curfd = link->ss7.numsigchans;
+
+		link->ss7.fds[curfd] = open("/dev/dahdi/channel", O_RDWR, 0600);
+		if ((link->ss7.fds[curfd] < 0) || (ioctl(link->ss7.fds[curfd],DAHDI_SPECIFY,&sigchan) == -1)) {
 			ast_log(LOG_ERROR, "Unable to open SS7 sigchan %d (%s)\n", sigchan, strerror(errno));
 			return -1;
 		}
 		memset(&p, 0, sizeof(p));
-		res = ioctl(link->fds[curfd], DAHDI_GET_PARAMS, &p);
+		res = ioctl(link->ss7.fds[curfd], DAHDI_GET_PARAMS, &p);
 		if (res) {
 			dahdi_close_ss7_fd(link, curfd);
 			ast_log(LOG_ERROR, "Unable to get parameters for sigchan %d (%s)\n", sigchan, strerror(errno));
@@ -15780,32 +15951,32 @@
 		bi.numbufs = 32;
 		bi.bufsize = 512;
 
-		if (ioctl(link->fds[curfd], DAHDI_SET_BUFINFO, &bi)) {
+		if (ioctl(link->ss7.fds[curfd], DAHDI_SET_BUFINFO, &bi)) {
 			ast_log(LOG_ERROR, "Unable to set appropriate buffering on channel %d: %s\n", sigchan, strerror(errno));
 			dahdi_close_ss7_fd(link, curfd);
 			return -1;
 		}
 
 		if (p.sigtype == DAHDI_SIG_MTP2)
-			ss7_add_link(link->ss7, SS7_TRANSPORT_DAHDIMTP2, link->fds[curfd]);
+			ss7_add_link(link->ss7.ss7, SS7_TRANSPORT_DAHDIMTP2, link->ss7.fds[curfd]);
 		else
-			ss7_add_link(link->ss7, SS7_TRANSPORT_DAHDIDCHAN, link->fds[curfd]);
-
-		link->numsigchans++;
+			ss7_add_link(link->ss7.ss7, SS7_TRANSPORT_DAHDIDCHAN, link->ss7.fds[curfd]);
+
+		link->ss7.numsigchans++;
 
 		memset(&si, 0, sizeof(si));
-		res = ioctl(link->fds[curfd], DAHDI_SPANSTAT, &si);
+		res = ioctl(link->ss7.fds[curfd], DAHDI_SPANSTAT, &si);
 		if (res) {
 			dahdi_close_ss7_fd(link, curfd);
 			ast_log(LOG_ERROR, "Unable to get span state for sigchan %d (%s)\n", sigchan, strerror(errno));
 		}
 
 		if (!si.alarms) {
-			link->linkstate[curfd] = LINKSTATE_DOWN;
-			ss7_link_noalarm(link->ss7, link->fds[curfd]);
+			link->ss7.linkstate[curfd] = LINKSTATE_DOWN;
+			ss7_link_noalarm(link->ss7.ss7, link->ss7.fds[curfd]);
 		} else {
-			link->linkstate[curfd] = LINKSTATE_DOWN | LINKSTATE_INALARM;
-			ss7_link_alarm(link->ss7, link->fds[curfd]);
+			link->ss7.linkstate[curfd] = LINKSTATE_DOWN | LINKSTATE_INALARM;
+			ss7_link_alarm(link->ss7.ss7, link->ss7.fds[curfd]);
 		}
 	}
 
@@ -15813,7 +15984,7 @@
 		ast_log(LOG_ERROR, "Unspecified adjpointcode!\n");
 		return -1;
 	} else {
-		ss7_set_adjpc(link->ss7, link->fds[curfd], cur_adjpointcode);
+		ss7_set_adjpc(link->ss7.ss7, link->ss7.fds[curfd], cur_adjpointcode);
 	}
 
 	if (cur_defaultdpc < 0) {
@@ -15825,7 +15996,7 @@
 		ast_log(LOG_ERROR, "Invalid networkindicator!\n");
 		return -1;
 	} else
-		ss7_set_network_ind(link->ss7, cur_networkindicator);
+		ss7_set_network_ind(link->ss7.ss7, cur_networkindicator);
 
 	return 0;
 }
@@ -15852,16 +16023,14 @@
 		ast_cli(a->fd, "Invalid linkset %s.  Should be a number from %d to %d\n", a->argv[5], 1, NUM_SPANS);
 		return CLI_SUCCESS;
 	}
-	if (!linksets[span-1].ss7) {
+	if (!linksets[span-1].ss7.ss7) {
 		ast_cli(a->fd, "No SS7 running on linkset %d\n", span);
-		return CLI_SUCCESS;
-	}
-	if (linksets[span-1].ss7) {
+	} else {
 		if (strcasecmp(a->argv[3], "on")) {
-			ss7_set_debug(linksets[span-1].ss7, SS7_DEBUG_MTP2 | SS7_DEBUG_MTP3 | SS7_DEBUG_ISUP);
+			ss7_set_debug(linksets[span-1].ss7.ss7, SIG_SS7_DEBUG);
 			ast_cli(a->fd, "Enabled debugging on linkset %d\n", span);
 		} else {
-			ss7_set_debug(linksets[span-1].ss7, 0);
+			ss7_set_debug(linksets[span-1].ss7.ss7, 0);
 			ast_cli(a->fd, "Disabled debugging on linkset %d\n", span);
 		}
 	}
@@ -15895,7 +16064,7 @@
 		return CLI_SUCCESS;
 	}
 
-	if (!linksets[linkset-1].ss7) {
+	if (!linksets[linkset-1].ss7.ss7) {
 		ast_cli(a->fd, "No SS7 running on linkset %d\n", linkset);
 		return CLI_SUCCESS;
 	}
@@ -15907,13 +16076,13 @@
 		return CLI_SUCCESS;
 	}
 
-	for (i = 0; i < linksets[linkset-1].numchans; i++) {
-		if (linksets[linkset-1].pvts[i]->cic == cic) {
-			blocked = linksets[linkset-1].pvts[i]->locallyblocked;
+	for (i = 0; i < linksets[linkset-1].ss7.numchans; i++) {
+		if (linksets[linkset-1].ss7.pvts[i]->cic == cic) {
+			blocked = linksets[linkset-1].ss7.pvts[i]->locallyblocked;
 			if (!blocked) {
-				ast_mutex_lock(&linksets[linkset-1].lock);
-				isup_blo(linksets[linkset-1].ss7, cic, linksets[linkset-1].pvts[i]->dpc);
-				ast_mutex_unlock(&linksets[linkset-1].lock);
+				ast_mutex_lock(&linksets[linkset-1].ss7.lock);
+				isup_blo(linksets[linkset-1].ss7.ss7, cic, linksets[linkset-1].ss7.pvts[i]->dpc);
+				ast_mutex_unlock(&linksets[linkset-1].ss7.lock);
 			}
 		}
 	}
@@ -15929,7 +16098,7 @@
 		ast_cli(a->fd, "CIC %d already locally blocked\n", cic);
 
 	/* Break poll on the linkset so it sends our messages */
-	pthread_kill(linksets[linkset-1].master, SIGURG);
+	pthread_kill(linksets[linkset-1].ss7.master, SIGURG);
 
 	return CLI_SUCCESS;
 }
@@ -15960,20 +16129,20 @@
 		return CLI_SUCCESS;
 	}
 
-	if (!linksets[linkset-1].ss7) {
+	if (!linksets[linkset-1].ss7.ss7) {
 		ast_cli(a->fd, "No SS7 running on linkset %d\n", linkset);
 		return CLI_SUCCESS;
 	}
 
-	for (i = 0; i < linksets[linkset-1].numchans; i++) {
-		ast_cli(a->fd, "Sending remote blocking request on CIC %d\n", linksets[linkset-1].pvts[i]->cic);
-		ast_mutex_lock(&linksets[linkset-1].lock);
-		isup_blo(linksets[linkset-1].ss7, linksets[linkset-1].pvts[i]->cic, linksets[linkset-1].pvts[i]->dpc);
-		ast_mutex_unlock(&linksets[linkset-1].lock);
+	for (i = 0; i < linksets[linkset-1].ss7.numchans; i++) {
+		ast_cli(a->fd, "Sending remote blocking request on CIC %d\n", linksets[linkset-1].ss7.pvts[i]->cic);
+		ast_mutex_lock(&linksets[linkset-1].ss7.lock);
+		isup_blo(linksets[linkset-1].ss7.ss7, linksets[linkset-1].ss7.pvts[i]->cic, linksets[linkset-1].ss7.pvts[i]->dpc);
+		ast_mutex_unlock(&linksets[linkset-1].ss7.lock);
 	}
 
 	/* Break poll on the linkset so it sends our messages */
-	pthread_kill(linksets[linkset-1].master, SIGURG);
+	pthread_kill(linksets[linkset-1].ss7.master, SIGURG);
 
 	return CLI_SUCCESS;
 }
@@ -16005,7 +16174,7 @@
 		return CLI_SUCCESS;
 	}
 
-	if (!linksets[linkset-1].ss7) {
+	if (!linksets[linkset-1].ss7.ss7) {
 		ast_cli(a->fd, "No SS7 running on linkset %d\n", linkset);
 		return CLI_SUCCESS;
 	}
@@ -16017,13 +16186,13 @@
 		return CLI_SUCCESS;
 	}
 
-	for (i = 0; i < linksets[linkset-1].numchans; i++) {
-		if (linksets[linkset-1].pvts[i]->cic == cic) {
-			blocked = linksets[linkset-1].pvts[i]->locallyblocked;
+	for (i = 0; i < linksets[linkset-1].ss7.numchans; i++) {
+		if (linksets[linkset-1].ss7.pvts[i]->cic == cic) {
+			blocked = linksets[linkset-1].ss7.pvts[i]->locallyblocked;
 			if (blocked) {
-				ast_mutex_lock(&linksets[linkset-1].lock);
-				isup_ubl(linksets[linkset-1].ss7, cic, linksets[linkset-1].pvts[i]->dpc);
-				ast_mutex_unlock(&linksets[linkset-1].lock);
+				ast_mutex_lock(&linksets[linkset-1].ss7.lock);
+				isup_ubl(linksets[linkset-1].ss7.ss7, cic, linksets[linkset-1].ss7.pvts[i]->dpc);
+				ast_mutex_unlock(&linksets[linkset-1].ss7.lock);
 			}
 		}
 	}
@@ -16032,7 +16201,7 @@
 		ast_cli(a->fd, "Sent unblocking request for linkset %d on CIC %d\n", linkset, cic);
 
 	/* Break poll on the linkset so it sends our messages */
-	pthread_kill(linksets[linkset-1].master, SIGURG);
+	pthread_kill(linksets[linkset-1].ss7.master, SIGURG);
 
 	return CLI_SUCCESS;
 }
@@ -16064,20 +16233,20 @@
 		return CLI_SUCCESS;
 	}
 
-	if (!linksets[linkset-1].ss7) {
+	if (!linksets[linkset-1].ss7.ss7) {
 		ast_cli(a->fd, "No SS7 running on linkset %d\n", linkset);
 		return CLI_SUCCESS;
 	}
 
-	for (i = 0; i < linksets[linkset-1].numchans; i++) {
-		ast_cli(a->fd, "Sending remote unblock request on CIC %d\n", linksets[linkset-1].pvts[i]->cic);
-		ast_mutex_lock(&linksets[linkset-1].lock);
-		isup_ubl(linksets[linkset-1].ss7, linksets[linkset-1].pvts[i]->cic, linksets[linkset-1].pvts[i]->dpc);
-		ast_mutex_unlock(&linksets[linkset-1].lock);
+	for (i = 0; i < linksets[linkset-1].ss7.numchans; i++) {
+		ast_cli(a->fd, "Sending remote unblock request on CIC %d\n", linksets[linkset-1].ss7.pvts[i]->cic);
+		ast_mutex_lock(&linksets[linkset-1].ss7.lock);
+		isup_ubl(linksets[linkset-1].ss7.ss7, linksets[linkset-1].ss7.pvts[i]->cic, linksets[linkset-1].ss7.pvts[i]->dpc);
+		ast_mutex_unlock(&linksets[linkset-1].ss7.lock);
 	}
 

[... 322 lines stripped ...]



More information about the svn-commits mailing list