[asterisk-commits] jpeeler: branch jpeeler/bug14877 r221767 - /team/jpeeler/bug14877/channels/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Thu Oct 1 17:47:53 CDT 2009
Author: jpeeler
Date: Thu Oct 1 17:47:48 2009
New Revision: 221767
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=221767
Log:
Change pri_resolve_span to search for a dchan only if it hasn't been found yet.
This makes all this new dchan searching much more efficient as the traversal is
only done once per span, but really had to be this way due to the need for
channel specification to query the channel's signaling. Tested over PRI and is
working. Next need to enhance the trunkgroup dchan assignment.
Modified:
team/jpeeler/bug14877/channels/chan_dahdi.c
Modified: team/jpeeler/bug14877/channels/chan_dahdi.c
URL: http://svnview.digium.com/svn/asterisk/team/jpeeler/bug14877/channels/chan_dahdi.c?view=diff&rev=221767&r1=221766&r2=221767
==============================================================================
--- team/jpeeler/bug14877/channels/chan_dahdi.c (original)
+++ team/jpeeler/bug14877/channels/chan_dahdi.c Thu Oct 1 17:47:48 2009
@@ -2805,7 +2805,6 @@
int fd;
int myfd;
int dchannelno;
-int res;
*offset = -1;
if (p->subs[SUB_REAL].dfd < 0) {
@@ -2816,7 +2815,6 @@
}
if (ioctl(fd, DAHDI_SPECIFY, &chan)) {
ast_log(LOG_WARNING, "Failed to specify channel %d: %s %d\n", chan, strerror(errno), errno);
- //do { *((int *)(0)) = 1; } while(0);
close(fd);
return -1;
}
@@ -2828,16 +2826,15 @@
return -1;
}
memset(&si, 0, sizeof(si));
- if ((res = ioctl(fd, DAHDI_SPANSTAT, &si))) {
+ if ((ioctl(fd, DAHDI_SPANSTAT, &si))) {
ast_log(LOG_WARNING, "Failed to get span information on channel %d (span %d): %s\n", chan, par.spanno, strerror(errno));
-ast_log(LOG_WARNING, "jpeeler: res = %d\n", res);
close(fd);
return -1;
}
for (dchannelno = chan - par.chanpos + 1; dchannelno < si.totalchans + (chan - par.chanpos + 1); dchannelno++) {
ast_log(LOG_WARNING, "jpeeler: in loop with dchannelno = %d, totalchans = %d\n", dchannelno, si.totalchans);
- if (chan >= dchannelno) {
+ if (chan == dchannelno) {
myfd = fd;
} else {
myfd = open(DAHDI_FILE_CHANNEL, O_RDWR);
@@ -2854,13 +2851,15 @@
}
if ((dchan_check.sigtype == DAHDI_SIG_HDLCFCS) || (dchan_check.sigtype == DAHDI_SIG_HARDHDLC)) {
*offset = dchannelno - (chan - par.chanpos + 1);
- if (chan < dchannelno) {
+ if (chan != dchannelno) {
+ast_log(LOG_WARNING, "closing %d because chan %d != dchannelno %d\n", myfd, chan, dchannelno);
close(myfd);
}
+ast_log(LOG_WARNING, "jpeeler: found dchan on channel %d\n", dchannelno);
return dchannelno;
}
- if (chan < dchannelno) {
-ast_log(LOG_WARNING, "closing %d because chan %d < dchannelno %d\n", myfd, chan, dchannelno);
+ if (chan != dchannelno) {
+ast_log(LOG_WARNING, "closing %d because chan %d != dchannelno %d\n", myfd, chan, dchannelno);
close(myfd);
}
}
@@ -7584,15 +7583,26 @@
} else if (pris[*span].mastertrunkgroup) {
ast_log(LOG_WARNING, "Unable to use span %d implicitly since it is already part of trunk group %d\n", *span, pris[*span].mastertrunkgroup);
*span = -1;
- } else {
+ } else if (pris[*span].dchannels[0] == 0) { /* check if dchan has been found for this span yet */
dchanno = pri_find_dchan_by_channel(channel, offset, p);
- /* bri must stay the same, E1 needs to be chan 16 */
+ if (si->totalchans == 31) {
+ /* E1 */
+ if (dchanno != 16 + *offset) {
+ ast_log(LOG_WARNING, "E1 should probably have dchan set to the 16th channel of the span, but continuing anyway.\n");
+ }
+ } else if (si->totalchans == 3) {
+ /* BRI */
+ if (dchanno != 3 + *offset) {
+ ast_log(LOG_WARNING, "Unable to use BRI on span %d, since dchan must be assigned to the end of the span\n", *span);
+ *span = -1;
+ return 0;
+ }
+ }
if (dchanno < 1) {
ast_log(LOG_WARNING, "Unable to use span %d, since the D-channel cannot be located\n", *span);
*span = -1;
return 0;
}
-//ast_log(LOG_WARNING, "jpeeler: dchannel set to %d, how about %d, dchan fd = %d\n", 24 + offset, pri_find_dchan(&pris[*span]), pri_active_dchan_fd(&pris[*span]));
pris[*span].dchannels[0] = dchanno;
pris[*span].dchanavail[0] |= DCHAN_PROVISIONED;
pris[*span].offset = *offset;
@@ -7806,6 +7816,7 @@
/* Store the logical span first based upon the real span */
tmp->logicalspan = pris[span].prilogicalspan;
pri_resolve_span(&span, channel, &offset, &si, tmp);
+
if (span < 0) {
ast_log(LOG_WARNING, "Channel %d: Unable to find locate channel/trunk group!\n", channel);
destroy_dahdi_pvt(&tmp);
More information about the asterisk-commits
mailing list