]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Mods for IMPLICIT/EXPLICIT channel id selection support
authorMatthew Fredrickson <creslin@digium.com>
Fri, 20 May 2005 19:09:21 +0000 (19:09 +0000)
committerMatthew Fredrickson <creslin@digium.com>
Fri, 20 May 2005 19:09:21 +0000 (19:09 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5751 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_zap.c

index 496c9f0695932fdc524297ddbca67fc9ff34d2d3..8f439a062aa2b95a50f04d6aa15e7a1d664a0fd1 100755 (executable)
@@ -360,6 +360,7 @@ static int r2prot = -1;
 #define PVT_TO_CHANNEL(p) (((p)->prioffset) | ((p)->logicalspan << 8))
 #define PRI_CHANNEL(p) ((p) & 0xff)
 #define PRI_SPAN(p) (((p) >> 8) & 0xff)
+#define PRI_EXPLICIT(p) (((p) >> 16) & 0x01)
 
 struct zt_pri {
        pthread_t master;                                               /* Thread of master */
@@ -2077,6 +2078,18 @@ static char *pri_order(int level)
        }               
 }
 
+/* Returns fd of the active dchan */
+int pri_active_dchan_fd(struct zt_pri *pri)
+{
+       int x = -1;
+
+       for (x = 0; x < NUM_DCHANS; x++)
+               if ((pri->dchans[x] == pri->pri))
+                       break;
+
+       return pri->fds[x];
+}
+
 int pri_find_dchan(struct zt_pri *pri)
 {
        int oldslot = -1;
@@ -7316,10 +7329,17 @@ static int pri_find_principle(struct zt_pri *pri, int channel)
 {
        int x;
        int span;
+       int spanfd;
+       struct zt_params param;
        int principle = -1;
        span = PRI_SPAN(channel);
        channel = PRI_CHANNEL(channel);
        
+       if (!PRI_EXPLICIT(channel)) {
+               spanfd = pri_active_dchan_fd(pri);
+               span = ioctl(spanfd, ZT_GET_PARAMS, &param);
+       }
+
        for (x=0;x<pri->numchans;x++) {
                if (pri->pvts[x] && (pri->pvts[x]->prioffset == channel) && (pri->pvts[x]->logicalspan == span)) {
                        principle = x;