[asterisk-commits] branch mattf/asterisk-ss7 r37882 -
/team/mattf/asterisk-ss7/channels/chan_zap.c
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Tue Jul 18 09:30:46 MST 2006
Author: mattf
Date: Tue Jul 18 11:30:46 2006
New Revision: 37882
URL: http://svn.digium.com/view/asterisk?rev=37882&view=rev
Log:
More fleshing out of libss7 chan_zap integration
Modified:
team/mattf/asterisk-ss7/channels/chan_zap.c
Modified: team/mattf/asterisk-ss7/channels/chan_zap.c
URL: http://svn.digium.com/view/asterisk/team/mattf/asterisk-ss7/channels/chan_zap.c?rev=37882&r1=37881&r2=37882&view=diff
==============================================================================
--- team/mattf/asterisk-ss7/channels/chan_zap.c (original)
+++ team/mattf/asterisk-ss7/channels/chan_zap.c Tue Jul 18 11:30:46 2006
@@ -789,6 +789,30 @@
}
#endif
+#ifdef HAVE_SS7
+static inline void ss7_rel(struct zt_ss7 *ss7)
+{
+ ast_mutex_unlock(&ss7->lock);
+}
+
+static inline int ss7_grab(struct zt_pvt *pvt, struct zt_ss7 *pri)
+{
+ int res;
+ /* Grab the lock first */
+ do {
+ res = ast_mutex_trylock(&pri->lock);
+ if (res) {
+ ast_mutex_unlock(&pvt->lock);
+ /* Release the lock and try again */
+ usleep(1);
+ ast_mutex_lock(&pvt->lock);
+ }
+ } while (res);
+ /* Then break the poll */
+ pthread_kill(pri->master, SIGURG);
+ return 0;
+}
+#endif
#define NUM_CADENCE_MAX 25
static int num_cadence = 4;
static int user_has_defined_cadences = 0;
@@ -1408,7 +1432,7 @@
return;
}
if (p->echocancel) {
- if (p->sig == SIG_PRI) {
+ if ((p->sig == SIG_PRI) || (p->sig == SIG_SS7)) {
x = 1;
res = ioctl(p->subs[SUB_REAL].zfd, ZT_AUDIOMODE, &x);
if (res)
@@ -1610,7 +1634,7 @@
{
int x, y, res;
x = muted;
- if (p->sig == SIG_PRI) {
+ if ((p->sig == SIG_PRI) || (p->sig == SIG_SS7)) {
y = 1;
res = ioctl(p->subs[SUB_REAL].zfd, ZT_AUDIOMODE, &y);
if (res)
@@ -2388,7 +2412,7 @@
index = zt_get_index(ast, p, 1);
- if (p->sig == SIG_PRI) {
+ if ((p->sig == SIG_PRI) || (p->sig == SIG_SS7)) {
x = 1;
ast_channel_setoption(ast,AST_OPTION_AUDIO_MODE,&x,sizeof(char),0);
}
@@ -2536,6 +2560,24 @@
if (res < 0)
ast_log(LOG_WARNING, "Unable to set law on channel %d to default\n", p->channel);
/* Perform low level hangup if no owner left */
+#ifdef HAVE_SS7
+ if (p->ss7) {
+ if (p->ss7call) {
+ if (!ss7_grab(p, p->ss7)) {
+ if (p->alreadyhungup) {
+ ast_log(LOG_DEBUG, "Already hungup... Calling hangup once, and clearing call\n");
+ isup_rlc(p->ss7->ss7, p->ss7call);
+ p->ss7call = NULL;
+ } else {
+ isup_rel(p->ss7->ss7, p->ss7call, 16);
+ }
+ } else {
+ ast_log(LOG_WARNING, "Unable to grab SS7 on CIC %d\n", p->cic);
+ res = -1;
+ }
+ }
+ }
+#endif
#ifdef HAVE_PRI
if (p->pri) {
#ifdef SUPPORT_USERUSER
@@ -2763,6 +2805,18 @@
pri_rel(p->pri);
} else {
ast_log(LOG_WARNING, "Unable to grab PRI on span %d\n", p->span);
+ res = -1;
+ }
+ break;
+#endif
+#ifdef HAVE_SS7
+ case SIG_SS7:
+ if (!ss7_grab(p, p->ss7)) {
+ p->proceeding = 1;
+ res = isup_anm(p->ss7->ss7, p->ss7call);
+ ss7_rel(p->ss7);
+ } else {
+ ast_log(LOG_WARNING, "Unable to grab SS7 on span %d\n", p->span);
res = -1;
}
break;
@@ -5242,7 +5296,7 @@
#endif
tmp->cid.cid_pres = i->callingpres;
tmp->cid.cid_ton = i->cid_ton;
-#ifdef HAVE_PRI
+#if defined(HAVE_PRI) || defined(HAVE_SS7)
tmp->transfercapability = transfercapability;
pbx_builtin_setvar_helper(tmp, "TRANSFERCAPABILITY", ast_transfercapability2str(transfercapability));
if (transfercapability & PRI_TRANS_CAP_DIGITAL)
@@ -7397,7 +7451,7 @@
ast_dsp_digitmode(tmp->dsp, DSP_DIGITMODE_DTMF | tmp->dtmfrelax);
update_conf(tmp);
if (!here) {
- if (signalling != SIG_PRI)
+ if ((signalling != SIG_PRI) && (signalling != SIG_SS7))
/* Hang it up to be sure it's good */
zt_set_hook(tmp->subs[SUB_REAL].zfd, ZT_ONHOOK);
}
@@ -8041,8 +8095,12 @@
ast_copy_string(p->dnid, e->iam.called_party_num, sizeof(p->exten));
if (ast_exists_extension(NULL, p->context, p->exten, 1, p->cid_num)) {
- int law = ZT_LAW_ALAW;
+ int law = 1;
+
+ if (ioctl(p->subs[SUB_REAL].zfd, ZT_AUDIOMODE, &law) == -1)
+ ast_log(LOG_WARNING, "Unable to set audio mode on channel %d to %d\n", p->channel, law);
+ law = ZT_LAW_ALAW;
res = zt_setlaw(p->subs[SUB_REAL].zfd, law);
if (res < 0)
ast_log(LOG_WARNING, "Unable to set law on channel %d\n", p->channel);
@@ -8064,8 +8122,25 @@
ast_mutex_unlock(&p->lock);
break;
case SS7_EVENT_REL:
- ast_log(LOG_DEBUG, "Got REL for cic %d\n", e->rel.cic);
- isup_rlc(ss7, e->rel.call);
+ chanpos = ss7_find_cic(linkset, e->rel.cic);
+ if (chanpos < 0) {
+ ast_log(LOG_WARNING, "REL on unconfigured CIC %d\n", e->rel.cic);
+ isup_rlc(ss7, e->iam.call);
+ break;
+ }
+ p = linkset->pvts[chanpos];
+ ast_mutex_lock(&p->lock);
+ if (!p->alreadyhungup) {
+ p->alreadyhungup = 1;
+ p->owner->_softhangup |= AST_SOFTHANGUP_DEV;
+
+ if (option_verbose > 2)
+ ast_verbose(VERBOSE_PREFIX_3 "Got REL for cic %d\n", e->rel.cic);
+ } else {
+ isup_rlc(ss7, e->rel.call);
+ p->ss7call = NULL;
+ }
+ ast_mutex_unlock(&p->lock);
break;
case SS7_EVENT_ACM:
ast_log(LOG_DEBUG, "Got ACM for cic %d\n", e->acm.cic);
More information about the asterisk-commits
mailing list