Fix sending of interface identifier unconditionally in sig_pri
authorJeff Peeler <jpeeler@digium.com>
Thu, 23 Jul 2009 15:59:44 +0000 (15:59 +0000)
committerJeff Peeler <jpeeler@digium.com>
Thu, 23 Jul 2009 15:59:44 +0000 (15:59 +0000)
The wrong logic was being used in chan_dahdi to convert a sig_pri_chan
to the proper libpri channel number. The most significant bit must only
be set only when trunk groups are being used.

(closes issue #15452)
Reported by: alecdavis
Patches:
      bug15452.patch uploaded by jpeeler (license 325)
Tested by: alecdavis

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@208267 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_dahdi.c
channels/sig_pri.c
channels/sig_pri.h

index 5065043..37aabc5 100644 (file)
@@ -10655,7 +10655,7 @@ static struct dahdi_pvt *mkintf(int channel, const struct dahdi_chan_conf *conf,
                                                }
 
                                                ast_debug(4, "Adding callbacks %p to chan %d\n", &dahdi_pri_callbacks, tmp->channel);
-                                               pchan = sig_pri_chan_new(tmp, &dahdi_pri_callbacks, &pris[span].pri, tmp->logicalspan, p.chanpos);
+                                               pchan = sig_pri_chan_new(tmp, &dahdi_pri_callbacks, &pris[span].pri, tmp->logicalspan, p.chanpos, pris[span].mastertrunkgroup);
                                                if (!pchan) {
                                                        destroy_dahdi_pvt(&tmp);
                                                        return NULL;
index 8d73327..e0d4097 100644 (file)
@@ -78,14 +78,11 @@ static inline void pri_rel(struct sig_pri_pri *pri)
 
 static unsigned int PVT_TO_CHANNEL(struct sig_pri_chan *p)
 {
-       int explicit;
+       int res = (((p)->prioffset) | ((p)->logicalspan << 8) | (p->mastertrunkgroup ? 0x10000 : 0));
+       ast_debug(5, "prioffset: %d mastertrunkgroup: %d logicalspan: %d result: %d\n",
+               p->prioffset, p->mastertrunkgroup, p->logicalspan, res);
 
-       if (p->pri->dchan_logical_span[pri_active_dchan_index(p->pri)] == p->logicalspan)
-               explicit = 1;
-       else
-               explicit = 0;
-
-       return (((p)->prioffset) | ((p)->logicalspan << 8) | (explicit ? 0x10000 : 0));
+       return res;
 }
 
 static void sig_pri_handle_dchan_exception(struct sig_pri_pri *pri, int index)
@@ -202,14 +199,15 @@ static char *pri_order(int level)
 /* Returns index of the active dchan */
 static int pri_active_dchan_index(struct sig_pri_pri *pri)
 {
-       int x = -1;
+       int x;
 
        for (x = 0; x < NUM_DCHANS; x++) {
                if ((pri->dchans[x] == pri->pri))
-                       break;
+                       return x;
        }
 
-       return x;
+       ast_log(LOG_WARNING, "No active dchan found!\n");
+       return -1;
 }
 
 static int pri_find_dchan(struct sig_pri_pri *pri)
@@ -2330,7 +2328,7 @@ void sig_pri_chan_alarm_notify(struct sig_pri_chan *p, int noalarm)
        }
 }
 
-struct sig_pri_chan *sig_pri_chan_new(void *pvt_data, struct sig_pri_callback *callback, struct sig_pri_pri *pri, int logicalspan, int channo)
+struct sig_pri_chan *sig_pri_chan_new(void *pvt_data, struct sig_pri_callback *callback, struct sig_pri_pri *pri, int logicalspan, int channo, int trunkgroup)
 {
        struct sig_pri_chan *p;
 
@@ -2341,6 +2339,7 @@ struct sig_pri_chan *sig_pri_chan_new(void *pvt_data, struct sig_pri_callback *c
 
        p->logicalspan = logicalspan;
        p->prioffset = channo;
+       p->mastertrunkgroup = trunkgroup;
 
        p->calls = callback;
        p->chan_pvt = pvt_data;
index 89d598b..7cb3888 100644 (file)
@@ -139,7 +139,6 @@ struct sig_pri_chan {
        /* Internal variables -- Don't touch */
        /* Probably will need DS0 number, DS1 number, and a few other things */
        char dialdest[256];                             /* Queued up digits for overlap dialing.  They will be sent out as information messages when setup ACK is received */
-       int mastertrunkgroup;
 
        unsigned int alerting:1;                /*!< TRUE if channel is alerting/ringing */
        unsigned int alreadyhungup:1;   /*!< TRUE if the call has already gone/hungup */
@@ -159,6 +158,7 @@ struct sig_pri_chan {
 
        int prioffset;                                  /*!< channel number in span */
        int logicalspan;                                /*!< logical span number within trunk group */
+       int mastertrunkgroup;                   /*!< what trunk group is our master */
 
        struct sig_pri_callback *calls;
        void *chan_pvt;
@@ -245,7 +245,7 @@ void pri_event_noalarm(struct sig_pri_pri *pri, int index, int before_start_pri)
 
 struct ast_channel *sig_pri_request(struct sig_pri_chan *p, enum sig_pri_law law, const struct ast_channel *requestor);
 
-struct sig_pri_chan *sig_pri_chan_new(void *pvt_data, struct sig_pri_callback *callback, struct sig_pri_pri *pri, int logicalspan, int channo);
+struct sig_pri_chan *sig_pri_chan_new(void *pvt_data, struct sig_pri_callback *callback, struct sig_pri_pri *pri, int logicalspan, int channo, int trunkgroup);
 
 int pri_is_up(struct sig_pri_pri *pri);