Corrected error print, if mISDN_dsp.ko module cannot be loaded.
[lcr.git] / bchannel.c
index c5dcc4b..c25d770 100644 (file)
 #include <sys/socket.h>
 #include <mISDNif.h>
 
+#define AF_COMPATIBILITY_FUNC 1
+#define MISDN_OLD_AF_COMPATIBILITY 1
+#include <compat_af_isdn.h>
+
 #include <asterisk/frame.h>
 
 
@@ -53,6 +57,8 @@ enum {
 
 int bchannel_initialize(void)
 {
+       init_af_isdn();
+
        return(0);
 }
 
@@ -142,7 +148,7 @@ int bchannel_create(struct bchannel *bchannel, int mode)
        }
        if (bchannel->b_sock < 0)
        {
-               CERROR(bchannel->call, NULL, "Failed to open bchannel-socket for handle 0x%x with mISDN-DSP layer. Did you load mISDNdsp.ko?\n", bchannel->handle);
+               CERROR(bchannel->call, NULL, "Failed to open bchannel-socket for handle 0x%x with mISDN-DSP layer. Did you load mISDN_dsp.ko?\n", bchannel->handle);
                return(0);
        }
        
@@ -158,12 +164,12 @@ int bchannel_create(struct bchannel *bchannel, int mode)
 
        /* bind socket to bchannel */
        addr.family = AF_ISDN;
-       addr.dev = (bchannel->handle>>8)-1;
+       addr.dev = (bchannel->handle>>8);
        addr.channel = bchannel->handle & 0xff;
        ret = bind(bchannel->b_sock, (struct sockaddr *)&addr, sizeof(addr));
        if (ret < 0)
        {
-               CERROR(bchannel->call, NULL, "Failed to bind bchannel-socket for handle 0x%x with mISDN-DSP layer. (port %d, channel %d) Did you load mISDNdsp.ko?\n", bchannel->handle, addr.dev + 1, addr.channel);
+               CERROR(bchannel->call, NULL, "Failed to bind bchannel-socket for handle 0x%x with mISDN-DSP layer. (port %d, channel %d) Did you load mISDN_dsp.ko?\n", bchannel->handle, addr.dev, addr.channel);
                close(bchannel->b_sock);
                bchannel->b_sock = -1;
                return(0);
@@ -445,20 +451,22 @@ void bchannel_transmit(struct bchannel *bchannel, unsigned char *data, int len)
                return;
        switch(bchannel->b_mode)
        {
-               case 0:
+       case 0:
                for (i = 0; i < len; i++)
                        *p++ = flip_bits[*data++];
                frm->prim = DL_DATA_REQ;
                break;
-               case 1:
+       case 1:
                for (i = 0; i < len; i++)
                        *p++ = flip_bits[*data++];
                frm->prim = PH_DATA_REQ;
                break;
-               case 2:
+       case 2:
+               memcpy(p, data, len);
                frm->prim = DL_DATA_REQ;
                break;
-               case 3:
+       case 3:
+               memcpy(p, data, len);
                frm->prim = PH_DATA_REQ;
                break;
        }