[svn-commits] twilson: branch group/srtp_reboot r268811 - in /team/group/srtp_reboot: ./ ch...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Mon Jun 7 15:51:18 CDT 2010


Author: twilson
Date: Mon Jun  7 15:51:12 2010
New Revision: 268811

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=268811
Log:
Merged revisions 268205,268281,268321,268395,268417,268454,268456,268495,268534,268578,268653,268690,268731,268734,268773-268774 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
  r268205 | dvossel | 2010-06-04 16:55:14 -0500 (Fri, 04 Jun 2010) | 27 lines
  
  RFC3261 compliant sip unreliable retransmit timing + 'registerattempts' option tweak
  
  Changes.
  1. RFC 3261 states in section 17.1.2.2 and 17.1.1.2 that retransmission
  timers should initially be set to timer T1.   T1 by default is 500ms.
  Asterisk was starting the retransmission timers at T1*2 which shouldn't
  cause any problems, but is not RFC compliant.
  
  2. RFC 3261 states in section 17.1.2.2 that for a non-INVITE client transaction,
  if the retransmit timer fires while in the proceeding state that
  the request must be retransmitted.  Asterisk currently ack's
  requests for both INVITE and non-INVITE transactions when a
  1XX response is received, this patch changes this for non-INVITE requests.
  
  3. The 'registerattempts' option in sip.conf is supposed to set
  how many registry attempts will be made before giving up.  When
  this option is set to 1, I would expect only one registry attempt
  to be made before stopping because of a failure, but instead two are
  made.  In my opinion this is not expected behavior.  This option does
  not indicate that these are re-attempts.  The logic behind this option
  has been changed to only attempt registers the exact number of times
  this option is set to.  If this option is 0, it still continues to
  re-attempt the registration forever.
  
  Review: https://reviewboard.asterisk.org/r/687/
................
  r268281 | dvossel | 2010-06-04 17:37:13 -0500 (Fri, 04 Jun 2010) | 2 lines
  
  fixes compile error from uninitialized variable
................
  r268321 | tilghman | 2010-06-04 21:51:34 -0500 (Fri, 04 Jun 2010) | 10 lines
  
  Merged revisions 268320 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.4
  
  ........
    r268320 | tilghman | 2010-06-04 21:49:52 -0500 (Fri, 04 Jun 2010) | 3 lines
    
    Rest In Peace
    http://www.outandaboutnewspaper.com/article/4061
  ........
................
  r268395 | kpfleming | 2010-06-05 00:12:34 -0500 (Sat, 05 Jun 2010) | 1 line
  
  Grammatical error fix.
................
  r268417 | kpfleming | 2010-06-05 00:23:02 -0500 (Sat, 05 Jun 2010) | 1 line
  
  Typo fix.
................
  r268454 | tilghman | 2010-06-05 12:27:12 -0500 (Sat, 05 Jun 2010) | 5 lines
  
  Verify event is not NULL before attempting to lower its usecount.
  
  (closes issue #17234)
   Reported by: mav3rick
................
  r268456 | tilghman | 2010-06-05 12:55:28 -0500 (Sat, 05 Jun 2010) | 14 lines
  
  Fix crash in DTMF detection.
  
  What I did not originally see in my previous commit was that even though the
  next digit could be detected before the previous was considered ended, the
  detection of the next digit effectively ends the detection of the previous.
  Therefore, the length moves in lockstep with the digit, and no separate counter
  is needed for the length alone.
  
  (closes issue #17371)
   Reported by: alecdavis
  
  (closes issue #17474)
   Reported by: kenner
................
  r268495 | tilghman | 2010-06-05 19:37:30 -0500 (Sat, 05 Jun 2010) | 2 lines
  
  Finally track down and eliminate the "FRACK! warnings from chan_iax2".
................
  r268534 | tilghman | 2010-06-06 00:29:50 -0500 (Sun, 06 Jun 2010) | 8 lines
  
  Take advantage of variable substitution already in the Makefile to specify the correct location for files in init.d.
  
  (closes issue #16979)
   Reported by: jw-asterisk
   
  (issue #15691)
   Reported by: itamarjp
................
  r268578 | rmudgett | 2010-06-07 10:51:39 -0500 (Mon, 07 Jun 2010) | 6 lines
  
  Suppress warning in waitstream_core().
  
  Suppress the warning about unexpected control subclass frames for
  AST_CONTROL_CONNECTED_LINE, AST_CONTROL_REDIRECTING, and AST_CONTROL_AOC
  in file.c:waitstream_core().
................
  r268653 | tilghman | 2010-06-07 12:14:40 -0500 (Mon, 07 Jun 2010) | 2 lines
  
  Avoid unloading res_smdi twice.
................
  r268690 | pabelanger | 2010-06-07 12:34:45 -0500 (Mon, 07 Jun 2010) | 11 lines
  
  Set threshold for silence detection defaults to 256
  
  (closes issue #15685)
  Reported by: david_s5
  Patches:
        dsp-silence-threshold-init.diff uploaded by dant (license 670)
        issue15685.patch.v5 uploaded by pabelanger (license 224)
  Tested by: danti
  
  Review: https://reviewboard.asterisk.org/r/670/
................
  r268731 | tilghman | 2010-06-07 13:59:27 -0500 (Mon, 07 Jun 2010) | 4 lines
  
  Event well was going dry.
  
  (issue #17234)
................
  r268734 | rmudgett | 2010-06-07 14:06:55 -0500 (Mon, 07 Jun 2010) | 2 lines
  
  Moved AOC request code out of the middle of code parsing the dialed number.
................
  r268773 | tilghman | 2010-06-07 14:52:39 -0500 (Mon, 07 Jun 2010) | 5 lines
  
  Seems strange (and the code backs up) that if the max and min of a statistic is expressed as a double, the last value would not also need to be a double.
  
  (closes issue #15807)
   Reported by: klaus3000
................
  r268774 | rmudgett | 2010-06-07 15:04:42 -0500 (Mon, 07 Jun 2010) | 20 lines
  
  Extract sig_ss7 out of chan_dahdi.
  
  Extract the SS7 specific code out of chan_dahdi like what was done to
  ISDN/PRI and analog signaling.  The new SS7 structures were modeled on
  sig_pri.
  
  The changes to sig_pri are an enhancement and a bug fix made possible
  because SS7 was extracted.
  
  1) The sig_pri TRANSFERCAPABILITY channel variable should have been set
  unconditionally in sig_pri_new_ast_channel().
  
  2) SS7/PRI transfer capability interaction in dahdi_new() fixed because of
  SS7 extraction.
  
  3) Module ref count error in dahdi_new() if startpbx failed to start the
  PBX for some reason.
  
  Review:	https://reviewboard.asterisk.org/r/661/
................

Added:
    team/group/srtp_reboot/channels/sig_ss7.c
      - copied unchanged from r268774, trunk/channels/sig_ss7.c
    team/group/srtp_reboot/channels/sig_ss7.h
      - copied unchanged from r268774, trunk/channels/sig_ss7.h
Modified:
    team/group/srtp_reboot/   (props changed)
    team/group/srtp_reboot/CHANGES
    team/group/srtp_reboot/channels/Makefile
    team/group/srtp_reboot/channels/chan_dahdi.c
    team/group/srtp_reboot/channels/chan_iax2.c
    team/group/srtp_reboot/channels/chan_sip.c
    team/group/srtp_reboot/channels/sig_pri.c
    team/group/srtp_reboot/channels/sig_pri.h
    team/group/srtp_reboot/channels/sip/dialplan_functions.c
    team/group/srtp_reboot/configs/voicemail.conf.sample
    team/group/srtp_reboot/contrib/init.d/rc.redhat.asterisk
    team/group/srtp_reboot/include/asterisk/rtp_engine.h
    team/group/srtp_reboot/main/dsp.c
    team/group/srtp_reboot/main/file.c
    team/group/srtp_reboot/main/manager.c
    team/group/srtp_reboot/main/rtp_engine.c
    team/group/srtp_reboot/res/res_smdi.c

Propchange: team/group/srtp_reboot/
------------------------------------------------------------------------------
    automerge = *

Propchange: team/group/srtp_reboot/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Propchange: team/group/srtp_reboot/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Jun  7 15:51:12 2010
@@ -1,1 +1,1 @@
-/trunk:1-268128
+/trunk:1-268810

Modified: team/group/srtp_reboot/CHANGES
URL: http://svnview.digium.com/svn/asterisk/team/group/srtp_reboot/CHANGES?view=diff&rev=268811&r1=268810&r2=268811
==============================================================================
--- team/group/srtp_reboot/CHANGES (original)
+++ team/group/srtp_reboot/CHANGES Mon Jun  7 15:51:12 2010
@@ -89,7 +89,7 @@
 ------------
  * Added 'p' option to PickupChan() to allow for picking up channel by the first
    match to a partial channel name.
- * Added "ready" option to QUEUE_MEMBER counting to count free agents who's wrap-up
+ * Added "ready" option to QUEUE_MEMBER counting to count free agents whose wrap-up
    timeout has expired.
  * Added 'R' option to app_queue.  This option stops moh and indicates ringing
    to the caller when an Agent's phone is ringing.  This can be used to indicate
@@ -408,7 +408,7 @@
 ---
  * 'linkedid' and 'peeraccount' are new CDR fields available to CDR aficionados.
    linkedid is based on uniqueID, but spreads to other channels as transfers, dials,
-   etc are performed. Thus the peices of CDR can be grouped into multilegged sets.
+   etc are performed. Thus the pieces of CDR can be grouped into multilegged sets.
  * Multiple files and formats can now be specified in cdr_custom.conf.
  * cdr_syslog has been added which allows CDRs to be written directly to syslog.
    See configs/cdr_syslog.conf.sample for more information.

Modified: team/group/srtp_reboot/channels/Makefile
URL: http://svnview.digium.com/svn/asterisk/team/group/srtp_reboot/channels/Makefile?view=diff&rev=268811&r1=268810&r2=268811
==============================================================================
--- team/group/srtp_reboot/channels/Makefile (original)
+++ team/group/srtp_reboot/channels/Makefile Mon Jun  7 15:51:12 2010
@@ -73,8 +73,8 @@
 iax2-parser.o iax2-provision.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,chan_iax2)
 $(if $(filter chan_sip,$(EMBEDDED_MODS)),modules.link,chan_sip.so): $(subst .c,.o,$(wildcard sip/*.c))
 $(subst .c,.o,$(wildcard sip/*.c)): _ASTCFLAGS+=$(call MOD_ASTCFLAGS,chan_sip)
-$(if $(filter chan_dahdi,$(EMBEDDED_MODS)),modules.link,chan_dahdi.so): sig_analog.o sig_pri.o
-sig_analog.o sig_pri.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,chan_dahdi)
+$(if $(filter chan_dahdi,$(EMBEDDED_MODS)),modules.link,chan_dahdi.so): sig_analog.o sig_pri.o sig_ss7.o
+sig_analog.o sig_pri.o sig_ss7.o: _ASTCFLAGS+=$(call MOD_ASTCFLAGS,chan_dahdi)
 
 ifneq ($(filter chan_h323,$(EMBEDDED_MODS)),)
 modules.link: h323/libchanh323.a

Modified: team/group/srtp_reboot/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/group/srtp_reboot/channels/chan_dahdi.c?view=diff&rev=268811&r1=268810&r2=268811
==============================================================================
--- team/group/srtp_reboot/channels/chan_dahdi.c (original)
+++ team/group/srtp_reboot/channels/chan_dahdi.c Mon Jun  7 15:51:12 2010
@@ -73,12 +73,9 @@
 #include "sig_pri.h"
 #endif
 
-#ifdef HAVE_SS7
-/* put this here until sig_ss7 comes along */
-#define SIG_SS7_NUM_DCHANS		4		/*!< No more than 4 d-channels */
-#define SIG_SS7_MAX_CHANNELS	672		/*!< No more than a DS3 per trunk group */
-#include <libss7.h>
-#endif
+#if defined(HAVE_SS7)
+#include "sig_ss7.h"
+#endif	/* defined(HAVE_SS7) */
 
 #ifdef HAVE_OPENR2
 /* put this here until sig_mfcr2 comes along */
@@ -306,24 +303,22 @@
 static const char tdesc[] = "DAHDI Telephony Driver"
 #if defined(HAVE_PRI) || defined(HAVE_SS7) || defined(HAVE_OPENR2)
 	" w/"
-#endif
-#ifdef HAVE_PRI
-	"PRI"
-#endif
-#ifdef HAVE_SS7
-	#ifdef HAVE_PRI
-	" & SS7"
-	#else
-	"SS7"
-	#endif
-#endif
-#ifdef HAVE_OPENR2
-	#if defined(HAVE_PRI) || defined(HAVE_SS7)
-	" & MFC/R2"
-	#else
-	"MFC/R2"
-	#endif
-#endif
+	#if defined(HAVE_PRI)
+		"PRI"
+	#endif	/* defined(HAVE_PRI) */
+	#if defined(HAVE_SS7)
+		#if defined(HAVE_PRI)
+		" & "
+		#endif	/* defined(HAVE_PRI) */
+		"SS7"
+	#endif	/* defined(HAVE_SS7) */
+	#if defined(HAVE_OPENR2)
+		#if defined(HAVE_PRI) || defined(HAVE_SS7)
+		" & "
+		#endif	/* defined(HAVE_PRI) || defined(HAVE_SS7) */
+		"MFC/R2"
+	#endif	/* defined(HAVE_OPENR2) */
+#endif	/* defined(HAVE_PRI) || defined(HAVE_SS7) || defined(HAVE_OPENR2) */
 ;
 
 static const char config[] = "chan_dahdi.conf";
@@ -516,38 +511,10 @@
  */
 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)
+#if defined(HAVE_SS7)
 
 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];
@@ -559,7 +526,7 @@
 static int cur_adjpointcode = -1;
 static int cur_networkindicator = -1;
 static int cur_defaultdpc = -1;
-#endif /* HAVE_SS7 */
+#endif	/* defined(HAVE_SS7) */
 
 #ifdef HAVE_OPENR2
 struct dahdi_mfcr2 {
@@ -987,24 +954,6 @@
 	struct sig_pri_pri *pri;
 	int logicalspan;
 #endif
-#if defined(HAVE_PRI) || defined(HAVE_SS7)
-	/*!
-	 * \brief XXX BOOLEAN Purpose???
-	 * \note Applies to SS7 channels.
-	 */
-	unsigned int rlt:1;
-	/*! \brief TRUE if channel is alerting/ringing */
-	unsigned int alerting:1;
-	/*! \brief TRUE if the call has already gone/hungup */
-	unsigned int alreadyhungup:1;
-	/*!
-	 * \brief TRUE if call is in a proceeding state.
-	 * The call has started working its way through the network.
-	 */
-	unsigned int proceeding:1;
-	/*! \brief TRUE if the call has seen progress through the network. */
-	unsigned int progress:1;
-#endif
 	/*!
 	 * \brief TRUE if SMDI (Simplified Message Desk Interface) is enabled
 	 * \note Set from the "usesmdi" value read in from chan_dahdi.conf
@@ -1044,10 +993,10 @@
 	 */
 	char mohsuggest[MAX_MUSICCLASS];
 	char parkinglot[AST_MAX_EXTENSION]; /*!< Parking lot for this channel */
-#if defined(PRI_ANI) || defined(HAVE_SS7)
+#if defined(HAVE_PRI) || defined(HAVE_SS7)
 	/*! \brief Automatic Number Identification number (Alternate PRI caller ID number) */
 	char cid_ani[AST_MAX_EXTENSION];
-#endif
+#endif	/* defined(HAVE_PRI) || defined(HAVE_SS7) */
 	/*! \brief Automatic Number Identification code from PRI */
 	int cid_ani2;
 	/*! \brief Caller ID number from an incoming call. */
@@ -1219,36 +1168,10 @@
 	int polarity;
 	/*! \brief DSP feature flags: DSP_FEATURE_xxx */
 	int dsp_features;
-#ifdef HAVE_SS7
+#if defined(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;
-#endif
+	struct sig_ss7_linkset *ss7;
+#endif	/* defined(HAVE_SS7) */
 #ifdef HAVE_OPENR2
 	struct dahdi_mfcr2 *mfcr2;
 	openr2_chan_t *r2chan;
@@ -1308,9 +1231,9 @@
 	struct dahdi_pri pri;
 #endif
 
-#ifdef HAVE_SS7
+#if defined(HAVE_SS7)
 	struct dahdi_ss7 ss7;
-#endif
+#endif	/* defined(HAVE_SS7) */
 
 #ifdef HAVE_OPENR2
 	struct dahdi_mfcr2_conf mfcr2;
@@ -1358,8 +1281,8 @@
 			.resetinterval = -1,
 		},
 #endif
-#ifdef HAVE_SS7
-		.ss7 = {
+#if defined(HAVE_SS7)
+		.ss7.ss7 = {
 			.called_nai = SS7_NAI_NATIONAL,
 			.calling_nai = SS7_NAI_NATIONAL,
 			.internationalprefix = "",
@@ -1367,7 +1290,7 @@
 			.subscriberprefix = "",
 			.unknownprefix = ""
 		},
-#endif
+#endif	/* defined(HAVE_SS7) */
 #ifdef HAVE_OPENR2
 		.mfcr2 = {
 			.variant = OR2_VAR_ITU,
@@ -2128,14 +2051,41 @@
 	p->dialing = is_dialing;
 }
 
-#if defined(HAVE_PRI)
+#if defined(HAVE_PRI) || defined(HAVE_SS7)
 static void my_set_digital(void *pvt, int is_digital)
 {
 	struct dahdi_pvt *p = pvt;
 
 	p->digital = is_digital;
 }
-#endif	/* defined(HAVE_PRI) */
+#endif	/* defined(HAVE_PRI) || defined(HAVE_SS7) */
+
+#if defined(HAVE_SS7)
+static void my_set_inservice(void *pvt, int is_inservice)
+{
+	struct dahdi_pvt *p = pvt;
+
+	p->inservice = is_inservice;
+}
+#endif	/* defined(HAVE_SS7) */
+
+#if defined(HAVE_SS7)
+static void my_set_locallyblocked(void *pvt, int is_blocked)
+{
+	struct dahdi_pvt *p = pvt;
+
+	p->locallyblocked = is_blocked;
+}
+#endif	/* defined(HAVE_SS7) */
+
+#if defined(HAVE_SS7)
+static void my_set_remotelyblocked(void *pvt, int is_blocked)
+{
+	struct dahdi_pvt *p = pvt;
+
+	p->remotelyblocked = is_blocked;
+}
+#endif	/* defined(HAVE_SS7) */
 
 static void my_set_ringtimeout(void *pvt, int ringt)
 {
@@ -2369,14 +2319,14 @@
 	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, 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)
 {
 	struct dahdi_pvt *p = pvt;
 	int dsub = analogsub_to_dahdisub(sub);
 
-	return dahdi_new(p, state, startpbx, dsub, 0, 0, requestor ? requestor->linkedid : "");
+	return dahdi_new(p, state, startpbx, dsub, 0, requestor ? requestor->linkedid : "");
 }
 
 #if defined(HAVE_PRI) || defined(HAVE_SS7)
@@ -2388,10 +2338,10 @@
 		return res;
 	return 0;
 }
-#endif
+#endif	/* defined(HAVE_PRI) || defined(HAVE_SS7) */
 
 #if defined(HAVE_PRI)
-static struct ast_channel *my_new_pri_ast_channel(void *pvt, int state, int startpbx, enum sig_pri_law law, int transfercapability, char *exten, const struct ast_channel *requestor)
+static struct ast_channel *my_new_pri_ast_channel(void *pvt, int state, enum sig_pri_law law, char *exten, const struct ast_channel *requestor)
 {
 	struct dahdi_pvt *p = pvt;
 	int audio;
@@ -2431,7 +2381,7 @@
 			newlaw = DAHDI_LAW_MULAW;
 			break;
 	}
-	return dahdi_new(p, state, startpbx, SUB_REAL, newlaw, transfercapability, requestor ? requestor->linkedid : "");
+	return dahdi_new(p, state, 0, SUB_REAL, newlaw, requestor ? requestor->linkedid : "");
 }
 #endif	/* defined(HAVE_PRI) */
 
@@ -2812,7 +2762,9 @@
 	/* More stuff to transfer to the new channel. */
 	new_chan->law = old_chan->law;
 }
-
+#endif	/* defined(HAVE_PRI) */
+
+#if defined(HAVE_PRI)
 static int sig_pri_tone_to_dahditone(enum sig_pri_tone tone)
 {
 	switch (tone) {
@@ -2834,7 +2786,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;
@@ -2844,20 +2798,29 @@
 		ast_log(LOG_NOTICE, "PRI got event: %s (%d) on D-channel of span %d\n", event2str(x), x, pri->span);
 	}
 	/* Keep track of alarm state */
-	if (x == DAHDI_EVENT_ALARM) {
+	switch (x) {
+	case DAHDI_EVENT_ALARM:
 		pri_event_alarm(pri, index, 0);
-	} else if (x == DAHDI_EVENT_NOALARM) {
+		break;
+	case DAHDI_EVENT_NOALARM:
 		pri_event_noalarm(pri, index, 0);
-	}
-}
-
+		break;
+	default:
+		break;
+	}
+}
+#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.
@@ -2868,7 +2831,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;
 
@@ -2885,7 +2848,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.
@@ -2896,13 +2861,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)
 /*!
  * \internal
  * \brief Set the Redirecting Directory Number Information Service (RDNIS).
@@ -2913,13 +2880,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) */
+
+#if defined(HAVE_PRI)
 /*!
  * \internal
  * \brief Make a dialstring for native ISDN CC to recall properly.
@@ -2978,7 +2947,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.
@@ -3049,7 +3020,9 @@
 	}
 #endif	/* defined(THRESHOLD_DEVSTATE_PLACEHOLDER) */
 }
-
+#endif	/* defined(HAVE_PRI) */
+
+#if defined(HAVE_PRI)
 /*!
  * \internal
  * \brief Reference this module.
@@ -3061,7 +3034,9 @@
 {
 	ast_module_ref(ast_module_info->self);
 }
-
+#endif	/* defined(HAVE_PRI) */
+
+#if defined(HAVE_PRI)
 /*!
  * \internal
  * \brief Unreference this module.
@@ -3073,7 +3048,9 @@
 {
 	ast_module_unref(ast_module_info->self);
 }
-
+#endif	/* defined(HAVE_PRI) */
+
+#if defined(HAVE_PRI)
 #if defined(HAVE_PRI_CALL_WAITING)
 static void my_pri_init_config(void *priv, struct sig_pri_pri *pri);
 #endif	/* defined(HAVE_PRI_CALL_WAITING) */
@@ -3092,9 +3069,9 @@
 	.set_alarm = my_set_alarm,
 	.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,
 #if defined(HAVE_PRI_CALL_WAITING)
 	.init_config = my_pri_init_config,
@@ -3107,6 +3084,166 @@
 	.open_media = my_pri_open_media,
 };
 #endif	/* defined(HAVE_PRI) */
+
+#if defined(HAVE_SS7)
+/*!
+ * \internal
+ * \brief Handle the SS7 link exception.
+ * \since 1.8
+ *
+ * \param linkset Controlling linkset for the channel.
+ * \param which Link index of the signaling channel.
+ *
+ * \return Nothing
+ */
+static void my_handle_link_exception(struct sig_ss7_linkset *linkset, int which)
+{
+	int event;
+
+	if (ioctl(linkset->fds[which], DAHDI_GETEVENT, &event)) {
+		ast_log(LOG_ERROR, "SS7: Error in exception retrieval on span %d/%d!\n",
+			linkset->span, which);
+		return;
+	}
+	switch (event) {
+	case DAHDI_EVENT_NONE:
+		break;
+	case DAHDI_EVENT_ALARM:
+		ast_log(LOG_ERROR, "SS7 got event: %s(%d) on span %d/%d\n",
+			event2str(event), event, linkset->span, which);
+		sig_ss7_link_alarm(linkset, which);
+		break;
+	case DAHDI_EVENT_NOALARM:
+		ast_log(LOG_ERROR, "SS7 got event: %s(%d) on span %d/%d\n",
+			event2str(event), event, linkset->span, which);
+		sig_ss7_link_noalarm(linkset, which);
+		break;
+	default:
+		ast_log(LOG_NOTICE, "SS7 got event: %s(%d) on span %d/%d\n",
+			event2str(event), event, linkset->span, which);
+		break;
+	}
+}
+#endif	/* defined(HAVE_SS7) */
+
+#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 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, enum sig_ss7_law law, char *exten, const struct ast_channel *requestor)
+{
+	struct dahdi_pvt *p = pvt;
+	int audio;
+	int newlaw;
+
+	/* 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));
+
+	newlaw = -1;
+	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, 0, SUB_REAL, newlaw, requestor ? requestor->linkedid : "");
+}
+#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,
+
+	.handle_link_exception = my_handle_link_exception,
+	.set_alarm = my_set_alarm,
+	.set_dialing = my_set_dialing,
+	.set_digital = my_set_digital,
+	.set_inservice = my_set_inservice,
+	.set_locallyblocked = my_set_locallyblocked,
+	.set_remotelyblocked = my_set_remotelyblocked,
+	.set_callerid = my_set_callerid,
+	.set_dnid = my_set_dnid,
+};
+#endif	/* defined(HAVE_SS7) */
 
 /*!
  * \brief Send MWI state change
@@ -3242,31 +3379,6 @@
 /*! Round robin search locations. */
 static struct dahdi_pvt *round_robin[32];
 
-#if defined(HAVE_SS7)
-static inline void ss7_rel(struct dahdi_ss7 *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)
-{
-	int res;
-	/* Grab the lock first */
-	do {
-		res = ast_mutex_trylock(&pri->lock);
-		if (res) {
-			DEADLOCK_AVOIDANCE(&pvt->lock);
-		}
-	} while (res);
-	/* Then break the poll */
-	if (pri->master != AST_PTHREADT_NULL)
-		pthread_kill(pri->master, SIGURG);
-	return 0;
-}
-#endif	/* defined(HAVE_SS7) */
-
 static int dahdi_get_index(struct ast_channel *ast, struct dahdi_pvt *p, int nullok)
 {
 	int res;
@@ -3300,21 +3412,8 @@
 	}
 }
 
-static void dahdi_queue_frame(struct dahdi_pvt *p, struct ast_frame *f, void *data)
-{
-#ifdef HAVE_SS7
-	struct dahdi_ss7 *ss7 = (struct dahdi_ss7*) data;
-
-	if (data) {
-		switch (p->sig) {
-		case SIG_SS7:
-			ast_mutex_unlock(&ss7->lock);
-			break;
-		default:
-			break;
-		}
-	}
-#endif
+static void dahdi_queue_frame(struct dahdi_pvt *p, struct ast_frame *f)
+{
 	for (;;) {
 		if (p->owner) {
 			if (ast_channel_trylock(p->owner)) {
@@ -3327,17 +3426,6 @@
 		} else
 			break;
 	}
-#if defined(HAVE_SS7)
-	if (data) {
-		switch (p->sig) {
-		case SIG_SS7:
-			ast_mutex_lock(&ss7->lock);
-			break;
-		default:
-			break;
-		}
-	}
-#endif
 }
 
 static void handle_clear_alarms(struct dahdi_pvt *p)
@@ -3513,7 +3601,7 @@
 	}
 	if (!p->mfcr2_accept_on_offer) {
 		/* The user wants us to start the PBX thread right away without accepting the call first */
-		c = dahdi_new(p, AST_STATE_RING, 1, SUB_REAL, DAHDI_LAW_ALAW, 0, NULL);
+		c = dahdi_new(p, AST_STATE_RING, 1, SUB_REAL, DAHDI_LAW_ALAW, NULL);
 		if (c) {
 			/* Done here, don't disable reading now since we still need to generate MF tones to accept
 			   the call or reject it and detect the tone off condition of the other end, all of this
@@ -3563,7 +3651,7 @@
 			}
 			return;
 		}
-		c = dahdi_new(p, AST_STATE_RING, 1, SUB_REAL, DAHDI_LAW_ALAW, 0, NULL);
+		c = dahdi_new(p, AST_STATE_RING, 1, SUB_REAL, DAHDI_LAW_ALAW, NULL);
 		if (c) {
 			/* chan_dahdi will take care of reading from now on in the PBX thread, tell the
 			   library to forget about it */
@@ -3900,8 +3988,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) */
 
@@ -4877,28 +4965,12 @@
 	return 0;
 }
 
-#if defined(HAVE_SS7)
-static unsigned char cid_pres2ss7pres(int cid_pres)
-{
-	 return (cid_pres >> 5) & 0x03;
-}
-#endif	/* defined(HAVE_SS7) */
-
-#if defined(HAVE_SS7)
-static unsigned char cid_pres2ss7screen(int cid_pres)
-{
-	return cid_pres & 0x03;
-}
-#endif	/* defined(HAVE_SS7) */
-
 static int dahdi_call(struct ast_channel *ast, char *rdest, int timeout)
 {
 	struct dahdi_pvt *p = ast->tech_pvt;
 	int x, res, mysig;
 	char dest[256]; /* must be same length as p->dialdest */
-#ifdef HAVE_SS7
-	char *c, *l;
-#endif
+
 	ast_mutex_lock(&p->lock);
 	ast_copy_string(dest, rdest, sizeof(dest));
 	ast_copy_string(p->dialdest, rdest, sizeof(p->dialdest));
@@ -4942,6 +5014,14 @@
 	}
 #endif
 
+#if defined(HAVE_SS7)
+	if (p->sig == SIG_SS7) {
+		res = sig_ss7_call(p->sig_pvt, ast, rdest);
+		ast_mutex_unlock(&p->lock);
+		return res;
+	}
+#endif	/* defined(HAVE_SS7) */
+
 	/* If this is analog signalling we can exit here */
 	if (analog_lib_handles(p->sig, p->radio, p->oprmode)) {
 		p->callwaitrings = 0;
@@ -4956,11 +5036,7 @@
 		/* Special pseudo -- automatically up*/
 		ast_setstate(ast, AST_STATE_UP);
 		break;
-	case SIG_SS7:
 	case SIG_MFCR2:
-		/* We'll get it in a moment -- but use dialdest to store pre-setup_ack digits */
-		p->dialdest[0] = '\0';
-		p->dialing = 1;
 		break;
 	default:
 		ast_debug(1, "not yet implemented\n");
@@ -4968,24 +5044,14 @@
 		return -1;
 	}
 
-#if defined(HAVE_SS7)
-	if (p->ss7) {
-		char ss7_called_nai;
-		int called_nai_strip;
-		char ss7_calling_nai;
-		int calling_nai_strip;
-		const char *charge_str = NULL;
-		const char *gen_address = NULL;
-		const char *gen_digits = NULL;
-		const char *gen_dig_type = NULL;
-		const char *gen_dig_scheme = NULL;
-		const char *gen_name = NULL;
-		const char *jip_digits = NULL;
-		const char *lspi_ident = NULL;
-		const char *rlt_flag = NULL;
-		const char *call_ref_id = NULL;
-		const char *call_ref_pc = NULL;
-		const char *send_far = NULL;
+#ifdef HAVE_OPENR2
+	if (p->mfcr2) {
+		openr2_calling_party_category_t chancat;
+		int callres = 0;
+		char *c, *l;
+
+		/* We'll get it in a moment -- but use dialdest to store pre-setup_ack digits */
+		p->dialdest[0] = '\0';
 
 		c = strchr(dest, '/');
 		if (c) {
@@ -4993,146 +5059,18 @@
 		} else {
 			c = "";
 		}
+		if (!p->hidecallerid) {
+			l = ast->cid.cid_num;
+		} else {
+			l = NULL;
+		}
 		if (strlen(c) < p->stripmsd) {
 			ast_log(LOG_WARNING, "Number '%s' is shorter than stripmsd (%d)\n", c, p->stripmsd);
 			ast_mutex_unlock(&p->lock);
 			return -1;
 		}
-
-		if (!p->hidecallerid) {
-			l = ast->connected.id.number;
-		} else {
-			l = NULL;
-		}
-
-		if (ss7_grab(p, p->ss7)) {
-			ast_log(LOG_WARNING, "Failed to grab SS7!\n");
-			ast_mutex_unlock(&p->lock);
-			return -1;
-		}
-		p->digital = IS_DIGITAL(ast->transfercapability);
-		p->ss7call = isup_new_call(p->ss7->ss7);
-
-		if (!p->ss7call) {
-			ss7_rel(p->ss7);
-			ast_mutex_unlock(&p->lock);
-			ast_log(LOG_ERROR, "Unable to allocate new SS7 call!\n");
-			return -1;
-		}
-
-		called_nai_strip = 0;
- 		ss7_called_nai = p->ss7->called_nai;
-		if (ss7_called_nai == SS7_NAI_DYNAMIC) { /* compute dynamically */
- 			if (strncmp(c + p->stripmsd, p->ss7->internationalprefix, strlen(p->ss7->internationalprefix)) == 0) {
- 				called_nai_strip = strlen(p->ss7->internationalprefix);
- 				ss7_called_nai = SS7_NAI_INTERNATIONAL;
- 			} else if (strncmp(c + p->stripmsd, p->ss7->nationalprefix, strlen(p->ss7->nationalprefix)) == 0) {
-				called_nai_strip = strlen(p->ss7->nationalprefix);
- 				ss7_called_nai = SS7_NAI_NATIONAL;
- 			} else {
-				ss7_called_nai = SS7_NAI_SUBSCRIBER;
- 			}
- 		}
- 		isup_set_called(p->ss7call, c + p->stripmsd + called_nai_strip, ss7_called_nai, p->ss7->ss7);
-
-		calling_nai_strip = 0;
-		ss7_calling_nai = p->ss7->calling_nai;
-		if ((l != NULL) && (ss7_calling_nai == SS7_NAI_DYNAMIC)) { /* compute dynamically */
-			if (strncmp(l, p->ss7->internationalprefix, strlen(p->ss7->internationalprefix)) == 0) {
-				calling_nai_strip = strlen(p->ss7->internationalprefix);
-				ss7_calling_nai = SS7_NAI_INTERNATIONAL;
-			} else if (strncmp(l, p->ss7->nationalprefix, strlen(p->ss7->nationalprefix)) == 0) {
-				calling_nai_strip = strlen(p->ss7->nationalprefix);
-				ss7_calling_nai = SS7_NAI_NATIONAL;
-			} else {
-				ss7_calling_nai = SS7_NAI_SUBSCRIBER;
-			}
-		}
-		isup_set_calling(p->ss7call, l ? (l + calling_nai_strip) : NULL, ss7_calling_nai,
-			p->use_callingpres ? cid_pres2ss7pres(ast->connected.id.number_presentation) : (l ? SS7_PRESENTATION_ALLOWED : SS7_PRESENTATION_RESTRICTED),
-			p->use_callingpres ? cid_pres2ss7screen(ast->connected.id.number_presentation) : SS7_SCREENING_USER_PROVIDED );
-
-		isup_set_oli(p->ss7call, ast->connected.ani2);
-		isup_init_call(p->ss7->ss7, p->ss7call, p->cic, p->dpc);
-
-		ast_channel_lock(ast);
-		/* Set the charge number if it is set */
-		charge_str = pbx_builtin_getvar_helper(ast, "SS7_CHARGE_NUMBER");
-		if (charge_str)
-			isup_set_charge(p->ss7call, charge_str, SS7_ANI_CALLING_PARTY_SUB_NUMBER, 0x10);
-
-		gen_address = pbx_builtin_getvar_helper(ast, "SS7_GENERIC_ADDRESS");
-		if (gen_address)
-			isup_set_gen_address(p->ss7call, gen_address, p->gen_add_nai,p->gen_add_pres_ind, p->gen_add_num_plan,p->gen_add_type); /* need to add some types here for NAI,PRES,TYPE */
-
-		gen_digits = pbx_builtin_getvar_helper(ast, "SS7_GENERIC_DIGITS");
-		gen_dig_type = pbx_builtin_getvar_helper(ast, "SS7_GENERIC_DIGTYPE");
-		gen_dig_scheme = pbx_builtin_getvar_helper(ast, "SS7_GENERIC_DIGSCHEME");
-		if (gen_digits)
-			isup_set_gen_digits(p->ss7call, gen_digits, atoi(gen_dig_type), atoi(gen_dig_scheme));
-
-		gen_name = pbx_builtin_getvar_helper(ast, "SS7_GENERIC_NAME");
-		if (gen_name)
-			isup_set_generic_name(p->ss7call, gen_name, GEN_NAME_TYPE_CALLING_NAME, GEN_NAME_AVAIL_AVAILABLE, GEN_NAME_PRES_ALLOWED);
-
-		jip_digits = pbx_builtin_getvar_helper(ast, "SS7_JIP");
-		if (jip_digits)
-			isup_set_jip_digits(p->ss7call, jip_digits);
-
-		lspi_ident = pbx_builtin_getvar_helper(ast, "SS7_LSPI_IDENT");
-		if (lspi_ident)
-			isup_set_lspi(p->ss7call, lspi_ident, 0x18, 0x7, 0x00);
-
-		rlt_flag = pbx_builtin_getvar_helper(ast, "SS7_RLT_ON");
-		if ((rlt_flag) && ((strncmp("NO", rlt_flag, strlen(rlt_flag))) != 0 )) {
-			isup_set_lspi(p->ss7call, rlt_flag, 0x18, 0x7, 0x00); /* Setting for Nortel DMS-250/500 */
-		}
-
-		call_ref_id = pbx_builtin_getvar_helper(ast, "SS7_CALLREF_IDENT");
-		call_ref_pc = pbx_builtin_getvar_helper(ast, "SS7_CALLREF_PC");
-		if (call_ref_id && call_ref_pc) {
-			isup_set_callref(p->ss7call, atoi(call_ref_id),
-					 call_ref_pc ? atoi(call_ref_pc) : 0);
-		}
-
-		send_far = pbx_builtin_getvar_helper(ast, "SS7_SEND_FAR");
-		if ((send_far) && ((strncmp("NO", send_far, strlen(send_far))) != 0 ))
-			(isup_far(p->ss7->ss7, p->ss7call));
-
-		ast_channel_unlock(ast);
-
-		isup_iam(p->ss7->ss7, p->ss7call);
-		ast_setstate(ast, AST_STATE_DIALING);
-		ss7_rel(p->ss7);
-	}
-#endif	/* defined(HAVE_SS7) */
-
-#ifdef HAVE_OPENR2
-	if (p->mfcr2) {
-		openr2_calling_party_category_t chancat;
-		int callres = 0;
-		char *c, *l;
-
-		c = strchr(dest, '/');
-		if (c) {
-			c++;
-		} else {
-			c = "";
-		}
-		if (!p->hidecallerid) {
-			l = ast->cid.cid_num;
-		} else {
-			l = NULL;
-		}
-		if (strlen(c) < p->stripmsd) {
-			ast_log(LOG_WARNING, "Number '%s' is shorter than stripmsd (%d)\n", c, p->stripmsd);
-			ast_mutex_unlock(&p->lock);
-			return -1;
-		}
 		p->dialing = 1;
-		ast_channel_lock(ast);
 		chancat = dahdi_r2_get_channel_category(ast);
-		ast_channel_unlock(ast);
 		callres = openr2_chan_make_call(p->r2chan, l, (c + p->stripmsd), chancat);
 		if (-1 == callres) {
 			ast_mutex_unlock(&p->lock);
@@ -5362,6 +5300,38 @@
 }
 #endif	/* defined(HAVE_PRI) */
 
+#if defined(HAVE_SS7)
+/*!
+ * \internal
+ * \brief Unlink the channel interface from the SS7 private pointer array.
+ * \since 1.8
+ *
+ * \param pvt chan_dahdi private interface structure to unlink.
+ *
+ * \return Nothing
+ */
+static void dahdi_unlink_ss7_pvt(struct dahdi_pvt *pvt)
+{
+	unsigned idx;
+	struct sig_ss7_linkset *ss7;
+
+	ss7 = pvt->ss7;
+	if (!ss7) {
+		/* Not SS7 signaling so cannot be in a SS7 private pointer array. */
+		return;
+	}
+	ast_mutex_lock(&ss7->lock);
+	for (idx = 0; idx < ss7->numchans; ++idx) {
+		if (ss7->pvts[idx] == pvt->sig_pvt) {
+			ss7->pvts[idx] = NULL;
+			ast_mutex_unlock(&ss7->lock);
+			return;
+		}
+	}
+	ast_mutex_unlock(&ss7->lock);
+}
+#endif	/* defined(HAVE_SS7) */
+
 static struct dahdi_pvt *find_next_iface_in_span(struct dahdi_pvt *cur)
 {
 	if (cur->next && cur->next->span == cur->span) {
@@ -5388,6 +5358,9 @@
 #if defined(HAVE_PRI)
 	dahdi_unlink_pri_pvt(p);
 #endif	/* defined(HAVE_PRI) */
+#if defined(HAVE_SS7)
+	dahdi_unlink_ss7_pvt(p);
+#endif	/* defined(HAVE_SS7) */
 	switch (pvt->which_iflist) {
 	case DAHDI_IFLIST_NONE:
 		break;
@@ -5407,11 +5380,20 @@
 		if (analog_lib_handles(p->sig, 0, 0)) {
 			analog_delete(p->sig_pvt);
 		}
+		switch (p->sig) {
 #if defined(HAVE_PRI)
-		if (dahdi_sig_pri_lib_handles(p->sig)) {
+		case SIG_PRI_LIB_HANDLE_CASES:
 			sig_pri_chan_delete(p->sig_pvt);
-		}
+			break;
 #endif	/* defined(HAVE_PRI) */
+#if defined(HAVE_SS7)
+		case SIG_SS7:
+			sig_ss7_chan_delete(p->sig_pvt);
+			break;
+#endif	/* defined(HAVE_SS7) */
+		default:
+			break;
+		}
 	}
 	if (p->cidspill) {
 		ast_free(p->cidspill);
@@ -5780,9 +5762,8 @@
 		return 0;
 	}
 
+	ast_mutex_lock(&p->lock);
 	if (analog_lib_handles(p->sig, p->radio, p->oprmode)) {
-		ast_mutex_lock(&p->lock);
-
 		dahdi_confmute(p, 0);
 		restore_gains(p);

[... 2919 lines stripped ...]



More information about the svn-commits mailing list