[asterisk-commits] rmudgett: branch rmudgett/sig_ss7 r261864 - /team/rmudgett/sig_ss7/channels/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu May 6 20:17:25 CDT 2010
Author: rmudgett
Date: Thu May 6 20:17:21 2010
New Revision: 261864
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=261864
Log:
It compiles! Still have some things to clean up.
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=261864&r1=261863&r2=261864
==============================================================================
--- team/rmudgett/sig_ss7/channels/chan_dahdi.c (original)
+++ team/rmudgett/sig_ss7/channels/chan_dahdi.c Thu May 6 20:17:21 2010
@@ -610,7 +610,6 @@
caller.ani2 = p->cid_ani2;
p->calls->set_callerid(p->chan_pvt, &caller);
}
- /* BUGBUG sig_ss7_set_caller_id() not written */
}
/*!
@@ -627,23 +626,6 @@
{
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);
}
}
@@ -2905,10 +2887,15 @@
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) */
@@ -2971,7 +2958,7 @@
}
#endif /* defined(HAVE_PRI) || defined(HAVE_SS7) */
-#if defined(HAVE_PRI) || defined(HAVE_SS7)
+#if defined(HAVE_PRI)
/*!
* \internal
* \brief Set the Redirecting Directory Number Information Service (RDNIS).
@@ -2988,7 +2975,7 @@
ast_copy_string(p->rdnis, rdnis, sizeof(p->rdnis));
}
-#endif /* defined(HAVE_PRI) || defined(HAVE_SS7) */
+#endif /* defined(HAVE_PRI) */
#if defined(HAVE_PRI)
/*!
@@ -3295,7 +3282,6 @@
.set_remotelyblocked = my_set_remotelyblocked,
.set_callerid = my_set_callerid,
.set_dnid = my_set_dnid,
- .set_rdnis = my_set_rdnis,
};
#endif /* defined(HAVE_SS7) */
@@ -3490,25 +3476,88 @@
}
}
-/* BUGBUG move to sig_ss7.c */
-static void sig_ss7_queue_frame(struct sig_ss7_chan *p, struct ast_frame *f, struct sig_ss7_linkset *ss7)
-{
- /* We must unlock the SS7 to avoid the possibility of a deadlock */
- ast_mutex_unlock(&ss7->lock);
+/* BUGBUG move to sig_ss7.c ----v */
+/*!
+ * \internal
+ * \brief Obtain the sig_ss7 owner channel lock if the owner exists.
+ * \since 1.8
+ *
+ * \param ss7 sig_ss7 SS7 control structure.
+ * \param chanpos Channel position in the span.
+ *
+ * \note Assumes the ss7->lock is already obtained.
+ * \note Assumes the sig_ss7_lock_private(ss7->pvts[chanpos]) is already obtained.
+ *
+ * \return Nothing
+ */
+static void sig_ss7_lock_owner(struct sig_ss7_linkset *ss7, int chanpos)
+{
for (;;) {
- if (p->owner) {
- if (ast_channel_trylock(p->owner)) {
- SIG_SS7_DEADLOCK_AVOIDANCE(p);
- } else {
- ast_queue_frame(p->owner, f);
- ast_channel_unlock(p->owner);
- break;
- }
- } else
+ if (!ss7->pvts[chanpos]->owner) {
+ /* There is no owner lock to get. */
break;
- }
- ast_mutex_lock(&ss7->lock);
-}
+ }
+ if (!ast_channel_trylock(ss7->pvts[chanpos]->owner)) {
+ /* We got the lock */
+ break;
+ }
+ /* We must unlock the SS7 to avoid the possibility of a deadlock */
+ ast_mutex_unlock(&ss7->lock);
+ SIG_SS7_DEADLOCK_AVOIDANCE(ss7->pvts[chanpos]);
+ ast_mutex_lock(&ss7->lock);
+ }
+}
+
+/*!
+ * \internal
+ * \brief Queue the given frame onto the owner channel.
+ * \since 1.8
+ *
+ * \param ss7 sig_ss7 SS7 control structure.
+ * \param chanpos Channel position in the span.
+ * \param frame Frame to queue onto the owner channel.
+ *
+ * \note Assumes the ss7->lock is already obtained.
+ * \note Assumes the sig_ss7_lock_private(ss7->pvts[chanpos]) is already obtained.
+ *
+ * \return Nothing
+ */
+static void sig_ss7_queue_frame(struct sig_ss7_linkset *ss7, int chanpos, struct ast_frame *frame)
+{
+ sig_ss7_lock_owner(ss7, chanpos);
+ if (ss7->pvts[chanpos]->owner) {
+ ast_queue_frame(ss7->pvts[chanpos]->owner, frame);
+ ast_channel_unlock(ss7->pvts[chanpos]->owner);
+ }
+}
+
+/*!
+ * \internal
+ * \brief Queue a control frame of the specified subclass onto the owner channel.
+ * \since 1.8
+ *
+ * \param ss7 sig_ss7 SS7 control structure.
+ * \param chanpos Channel position in the span.
+ * \param subclass Control frame subclass to queue onto the owner channel.
+ *
+ * \note Assumes the ss7->lock is already obtained.
+ * \note Assumes the sig_ss7_lock_private(ss7->pvts[chanpos]) is already obtained.
+ *
+ * \return Nothing
+ */
+static void sig_ss7_queue_control(struct sig_ss7_linkset *ss7, int chanpos, int subclass)
+{
+ struct ast_frame f = {AST_FRAME_CONTROL, };
+ struct sig_ss7_chan *p = ss7->pvts[chanpos];
+
+ if (p->calls->queue_control) {
+ p->calls->queue_control(p->chan_pvt, subclass);
+ }
+
+ f.subclass.integer = subclass;
+ sig_ss7_queue_frame(ss7, chanpos, &f);
+}
+/* BUGBUG move to sig_ss7.c ----^ */
static void dahdi_queue_frame(struct dahdi_pvt *p, struct ast_frame *f)
{
@@ -5917,6 +5966,7 @@
reset_conf(p);
sig_pri_hangup(p->sig_pvt, ast);
p->subs[SUB_REAL].owner = NULL;
+ p->subs[SUB_REAL].needbusy = 0;
p->owner = NULL;
p->ringt = 0;/* Probably not used in this mode. Reset anyway. */
p->distinctivering = 0;/* Probably not used in this mode. Reset anyway. */
@@ -5945,8 +5995,6 @@
/* Real channel, do some fixup */
p->subs[SUB_REAL].owner = NULL;
- p->subs[SUB_REAL].needanswer = 0;
- p->subs[SUB_REAL].needringing = 0;
p->subs[SUB_REAL].needbusy = 0;
p->polarity = POLARITY_IDLE;
dahdi_setlinear(p->subs[SUB_REAL].dfd, 0);
@@ -13234,6 +13282,8 @@
isup_acm(ss7, p->ss7call);
}
+ sig_ss7_set_caller_id(p);
+
if (linkset->type == SS7_ITU) {
law = SIG_SS7_ALAW;
} else {
@@ -13438,6 +13488,8 @@
ast_mutex_lock(&linkset->lock);
for (i = 0; i < linkset->numsigchans; i++) {
if (pollers[i].revents & POLLPRI) {
+#if 1
+/* BUGBUG what to do about this DAHDI exception loop? How did sig_pri handle it? */
int x;
if (ioctl(pollers[i].fd, DAHDI_GETEVENT, &x)) {
ast_log(LOG_ERROR, "Error in exception retrieval!\n");
@@ -13454,20 +13506,39 @@
break;
case DAHDI_EVENT_ALARM:
ast_log(LOG_ERROR, "Alarm on link!\n");
+#if 1
linkset->linkstate[i] |= (LINKSTATE_DOWN | LINKSTATE_INALARM);
linkset->linkstate[i] &= ~LINKSTATE_UP;
ss7_link_alarm(ss7, pollers[i].fd);
+#else
+ /* The other conditional clause should be the contents of this function. */
+ sig_ss7_link_alarm(linkset, fd);
+#endif
break;
case DAHDI_EVENT_NOALARM:
ast_log(LOG_ERROR, "Alarm cleared on link\n");
+#if 1
linkset->linkstate[i] &= ~(LINKSTATE_INALARM | LINKSTATE_DOWN);
linkset->linkstate[i] |= LINKSTATE_STARTING;
ss7_link_noalarm(ss7, pollers[i].fd);
+#else
+ /* The other conditional clause should be the contents of this function. */
+ sig_ss7_link_noalarm(linkset, fd);
+#endif
break;
default:
ast_log(LOG_ERROR, "Got exception %d!\n", x);
break;
}
+#else
+/*
+* sig_pri did callback to sig_pri_handle_dchan_excepton().
+* The callback read DAHDI_GET_EVENT and really only handles link up/down
+* in my_handle_dchan_exception(). my_handle_dchan_exception() in turn calls
+* the equivalent of sig_ss7_link_alarm() and sig_ss7_link_noalarm().
+*/
+ sig_ss7_handle_link_exception(linkset, i);
+#endif
}
if (pollers[i].revents & POLLIN) {
@@ -13518,24 +13589,27 @@
switch (e->cpg.event) {
case CPG_EVENT_ALERTING:
p->alerting = 1;
- p->subs[SUB_REAL].needringing = 1;
+ sig_ss7_queue_control(linkset, chanpos, AST_CONTROL_RINGING);
break;
case CPG_EVENT_PROGRESS:
case CPG_EVENT_INBANDINFO:
{
- struct ast_frame f = { AST_FRAME_CONTROL, { AST_CONTROL_PROGRESS } };
ast_debug(1, "Queuing frame PROGRESS on CIC %d\n", p->cic);
- sig_ss7_queue_frame(p, &f, linkset);
+ sig_ss7_queue_control(linkset, chanpos, AST_CONTROL_PROGRESS);
p->progress = 1;
sig_ss7_set_dialing(p, 0);
+#if 0/* sig_pri seems to have just deleted this code. */
+/* BUGBUG dsp, dsp_features need equivalent. what done in sig_pri? */
if (p->dsp && p->dsp_features) {
ast_dsp_set_features(p->dsp, p->dsp_features);
p->dsp_features = 0;
}
+#endif
}
break;
default:
ast_debug(1, "Do not handle CPG with event type 0x%x\n", e->cpg.event);
+ break;
}
sig_ss7_unlock_private(p);
@@ -13751,8 +13825,6 @@
isup_rel(ss7, e->acm.call, -1);
break;
} else {
- struct ast_frame f = { AST_FRAME_CONTROL, { AST_CONTROL_PROCEEDING } };
-
p = linkset->pvts[chanpos];
ast_debug(1, "Queueing frame from SS7_EVENT_ACM on CIC %d\n", p->cic);
@@ -13762,13 +13834,13 @@
}
sig_ss7_lock_private(p);
- sig_ss7_queue_frame(p, &f, linkset);
+ sig_ss7_queue_control(linkset, chanpos, AST_CONTROL_PROCEEDING);
p->proceeding = 1;
sig_ss7_set_dialing(p, 0);
/* Send alerting if subscriber is free */
if (e->acm.called_party_status_ind == 1) {
p->alerting = 1;
- p->subs[SUB_REAL].needringing = 1;
+ sig_ss7_queue_control(linkset, chanpos, AST_CONTROL_RINGING);
}
sig_ss7_unlock_private(p);
}
@@ -13871,11 +13943,14 @@
} else {
p = linkset->pvts[chanpos];
sig_ss7_lock_private(p);
- p->subs[SUB_REAL].needanswer = 1;
+ sig_ss7_queue_control(linkset, chanpos, AST_CONTROL_ANSWER);
+#if 0/* sig_pri seems to have just deleted this code. */
+/* BUGBUG dsp, dsp_features need equivalent. what done in sig_pri? */
if (p->dsp && p->dsp_features) {
ast_dsp_set_features(p->dsp, p->dsp_features);
p->dsp_features = 0;
}
+#endif
sig_ss7_set_echocanceller(p, 1);
sig_ss7_unlock_private(p);
}
@@ -18419,6 +18494,7 @@
sig_ss7_set_dialing(p, 1);
ast_setstate(ast, AST_STATE_DIALING);
ss7_rel(p->ss7);
+ return 0;
}
Modified: team/rmudgett/sig_ss7/channels/sig_ss7.h
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/sig_ss7/channels/sig_ss7.h?view=diff&rev=261864&r1=261863&r2=261864
==============================================================================
--- team/rmudgett/sig_ss7/channels/sig_ss7.h (original)
+++ team/rmudgett/sig_ss7/channels/sig_ss7.h Thu May 6 20:17:21 2010
@@ -105,7 +105,8 @@
void (* const set_remotelyblocked)(void *pvt, int is_blocked);
void (* const set_callerid)(void *pvt, const struct ast_party_caller *caller);
void (* const set_dnid)(void *pvt, const char *dnid);
- void (* const set_rdnis)(void *pvt, const char *rdnis);
+
+ void (* const queue_control)(void *pvt, int subclass);
};
struct sig_ss7_chan {
More information about the asterisk-commits
mailing list