work on asterisk channel driver
authorSuper User <root@isdn.jolly.ten>
Sat, 19 Jan 2008 17:44:26 +0000 (18:44 +0100)
committerSuper User <root@isdn.jolly.ten>
Sat, 19 Jan 2008 17:44:26 +0000 (18:44 +0100)
modified:   Makefile
modified:   bchannel.c
modified:   bchannel.h
modified:   chan_lcr.c
modified:   extension.h

Makefile
bchannel.c
bchannel.h
chan_lcr.c
extension.h

index acf1dbf..fd73542 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -11,7 +11,7 @@
 
 WITH-CRYPTO = 42 # comment this out, if no libcrypto should be used
 #WITH-ASTERISK = 42 # comment this out, if you don't require built-in Asterisk channel driver.
 
 WITH-CRYPTO = 42 # comment this out, if no libcrypto should be used
 #WITH-ASTERISK = 42 # comment this out, if you don't require built-in Asterisk channel driver.
-#WITH-SOCKET = 42 # compile for socket based mISDN (
+#WITH-SOCKET = 42 # compile for socket based mISDN (this options is far unfinished !!!)
 # note: check your location and the names of libraries.
 
 # select location to install
 # note: check your location and the names of libraries.
 
 # select location to install
@@ -19,12 +19,13 @@ INSTALL_BIN = /usr/local/bin
 INSTALL_DATA = /usr/local/lcr
 
 LIBS += -lisdnnet -lmISDN -lpthread
 INSTALL_DATA = /usr/local/lcr
 
 LIBS += -lisdnnet -lmISDN -lpthread
+CHANLIBS += -lmISDN
 
 # give location of the curses or ncurses library
 CURSES = -lncurses
 
 
 # give location of the curses or ncurses library
 CURSES = -lncurses
 
-CC = g++
-LD = $(CC)
+CC = gcc
+PP = g++
 WIZZARD = ./wizzard
 LCR = ./lcr
 LCRADMIN = ./lcradmin
 WIZZARD = ./wizzard
 LCR = ./lcr
 LCRADMIN = ./lcradmin
@@ -68,88 +69,88 @@ all: $(CHAN_LCR) $(LCR) $(LCRADMIN) $(GEN) $(GENW) $(GENRC) $(GENEXT)
        @exit
 
 main.o: main.c *.h Makefile
        @exit
 
 main.o: main.c *.h Makefile
-       $(CC) -c $(CFLAGS) main.c -o main.o
+       $(PP) -c $(CFLAGS) main.c -o main.o
 
 message.o: message.c *.h Makefile
 
 message.o: message.c *.h Makefile
-       $(CC) -c $(CFLAGS) message.c -o message.o
+       $(PP) -c $(CFLAGS) message.c -o message.o
 
 options.o: options.c *.h Makefile
 
 options.o: options.c *.h Makefile
-       $(CC) -c $(CFLAGS) options.c -o options.o
+       $(PP) -c $(CFLAGS) options.c -o options.o
 
 interface.o: interface.c *.h Makefile
 
 interface.o: interface.c *.h Makefile
-       $(CC) -c $(CFLAGS) interface.c -o interface.o
+       $(PP) -c $(CFLAGS) interface.c -o interface.o
 
 extension.o: extension.c *.h Makefile
 
 extension.o: extension.c *.h Makefile
-       $(CC) -c $(CFLAGS) extension.c -o extension.o
+       $(PP) -c $(CFLAGS) extension.c -o extension.o
 
 route.o: route.c *.h Makefile
 
 route.o: route.c *.h Makefile
-       $(CC) -c $(CFLAGS) route.c -o route.o
+       $(PP) -c $(CFLAGS) route.c -o route.o
 
 port.o: port.cpp *.h Makefile
 
 port.o: port.cpp *.h Makefile
-       $(CC) -c $(CFLAGS) port.cpp -o port.o
+       $(PP) -c $(CFLAGS) port.cpp -o port.o
 
 mISDN.o: mISDN.cpp *.h Makefile
 
 mISDN.o: mISDN.cpp *.h Makefile
-       $(CC) -c $(CFLAGS) mISDN.cpp -o mISDN.o
+       $(PP) -c $(CFLAGS) mISDN.cpp -o mISDN.o
 
 dss1.o: dss1.cpp ie.cpp *.h Makefile
 
 dss1.o: dss1.cpp ie.cpp *.h Makefile
-       $(CC) -c $(CFLAGS) dss1.cpp -o dss1.o
+       $(PP) -c $(CFLAGS) dss1.cpp -o dss1.o
 
 #knock.o: knock.cpp *.h Makefile
 
 #knock.o: knock.cpp *.h Makefile
-#      $(CC) -c $(CFLAGS) knock.cpp -o knock.o
+#      $(PP) -c $(CFLAGS) knock.cpp -o knock.o
 #
 vbox.o: vbox.cpp *.h Makefile
 #
 vbox.o: vbox.cpp *.h Makefile
-       $(CC) -c $(CFLAGS) vbox.cpp -o vbox.o
+       $(PP) -c $(CFLAGS) vbox.cpp -o vbox.o
 
 mail.o: mail.c *.h Makefile
 
 mail.o: mail.c *.h Makefile
-       $(CC) -c $(CFLAGS) mail.c -o mail.o
+       $(PP) -c $(CFLAGS) mail.c -o mail.o
 
 action.o: action.cpp *.h Makefile
 
 action.o: action.cpp *.h Makefile
-       $(CC) -c $(CFLAGS) action.cpp -o action.o
+       $(PP) -c $(CFLAGS) action.cpp -o action.o
 
 action_vbox.o: action_vbox.cpp *.h Makefile
 
 action_vbox.o: action_vbox.cpp *.h Makefile
-       $(CC) -c $(CFLAGS) action_vbox.cpp -o action_vbox.o
+       $(PP) -c $(CFLAGS) action_vbox.cpp -o action_vbox.o
 
 action_efi.o: action_efi.cpp *.h Makefile
 
 action_efi.o: action_efi.cpp *.h Makefile
-       $(CC) -c $(CFLAGS) action_efi.cpp -o action_efi.o
+       $(PP) -c $(CFLAGS) action_efi.cpp -o action_efi.o
 
 endpoint.o: endpoint.cpp *.h Makefile
 
 endpoint.o: endpoint.cpp *.h Makefile
-       $(CC) -c $(CFLAGS) endpoint.cpp -o endpoint.o
+       $(PP) -c $(CFLAGS) endpoint.cpp -o endpoint.o
 
 endpointapp.o: endpointapp.cpp *.h Makefile
 
 endpointapp.o: endpointapp.cpp *.h Makefile
-       $(CC) -c $(CFLAGS) endpointapp.cpp -o endpointapp.o
+       $(PP) -c $(CFLAGS) endpointapp.cpp -o endpointapp.o
 
 apppbx.o: apppbx.cpp *.h Makefile
 
 apppbx.o: apppbx.cpp *.h Makefile
-       $(CC) -c $(CFLAGS) apppbx.cpp -o apppbx.o
+       $(PP) -c $(CFLAGS) apppbx.cpp -o apppbx.o
 
 join.o: join.cpp *.h Makefile
 
 join.o: join.cpp *.h Makefile
-       $(CC) -c $(CFLAGS) join.cpp -o join.o
+       $(PP) -c $(CFLAGS) join.cpp -o join.o
 
 joinpbx.o: joinpbx.cpp *.h Makefile
 
 joinpbx.o: joinpbx.cpp *.h Makefile
-       $(CC) -c $(CFLAGS) joinpbx.cpp -o joinpbx.o
+       $(PP) -c $(CFLAGS) joinpbx.cpp -o joinpbx.o
 
 joinremote.o: joinremote.cpp *.h Makefile
 
 joinremote.o: joinremote.cpp *.h Makefile
-       $(CC) -c $(CFLAGS) joinremote.cpp -o joinremote.o
+       $(PP) -c $(CFLAGS) joinremote.cpp -o joinremote.o
 
 cause.o: cause.c *.h Makefile
 
 cause.o: cause.c *.h Makefile
-       $(CC) -c $(CFLAGS) cause.c -o cause.o
+       $(PP) -c $(CFLAGS) cause.c -o cause.o
 
 alawulaw.o: alawulaw.c *.h Makefile
 
 alawulaw.o: alawulaw.c *.h Makefile
-       $(CC) -c $(CFLAGS) alawulaw.c -o alawulaw.o
+       $(PP) -c $(CFLAGS) alawulaw.c -o alawulaw.o
 
 tones.o: tones.c *.h Makefile
 
 tones.o: tones.c *.h Makefile
-       $(CC) -c $(CFLAGS) tones.c -o tones.o
+       $(PP) -c $(CFLAGS) tones.c -o tones.o
 
 crypt.o: crypt.cpp *.h Makefile
 
 crypt.o: crypt.cpp *.h Makefile
-       $(CC) -c $(CFLAGS) crypt.cpp -o crypt.o
+       $(PP) -c $(CFLAGS) crypt.cpp -o crypt.o
 
 genext.o: genext.c *.h Makefile
 
 genext.o: genext.c *.h Makefile
-       $(CC) -c $(CFLAGS) genext.c -o genext.o
+       $(PP) -c $(CFLAGS) genext.c -o genext.o
 
 admin_server.o: admin_server.c *.h Makefile
 
 admin_server.o: admin_server.c *.h Makefile
-       $(CC) -c $(CFLAGS) admin_server.c -o admin_server.o
+       $(PP) -c $(CFLAGS) admin_server.c -o admin_server.o
 
 trace.o: trace.c *.h Makefile
 
 trace.o: trace.c *.h Makefile
-       $(CC) -c $(CFLAGS) trace.c -o trace.o
+       $(PP) -c $(CFLAGS) trace.c -o trace.o
 
 chan_lcr.o: chan_lcr.c *.h Makefile
        $(CC) -c $(CFLAGS) chan_lcr.c -o chan_lcr.o
 
 chan_lcr.o: chan_lcr.c *.h Makefile
        $(CC) -c $(CFLAGS) chan_lcr.c -o chan_lcr.o
@@ -159,7 +160,7 @@ bchannel.o: bchannel.c *.h Makefile
 
 
 #$(WIZZARD): wizzard.c Makefile
 
 
 #$(WIZZARD): wizzard.c Makefile
-#      $(CC) $(LIBDIR) $(CFLAGS) -lm wizzard.c \
+#      $(PP) $(LIBDIR) $(CFLAGS) -lm wizzard.c \
 #      -o $(WIZZARD) 
 
 $(LCR): main.o \
 #      -o $(WIZZARD) 
 
 $(LCR): main.o \
@@ -188,7 +189,7 @@ $(LCR): main.o \
        joinremote.o \
        admin_server.o \
        trace.o
        joinremote.o \
        admin_server.o \
        trace.o
-       $(LD) $(LIBDIR) \
+       $(PP) $(LIBDIR) \
                main.o \
        options.o \
        interface.o \
                main.o \
        options.o \
        interface.o \
@@ -218,31 +219,31 @@ $(LCR): main.o \
        $(LIBS) -o $(LCR) 
 
 $(LCRADMIN): admin_client.c cause.c *.h Makefile
        $(LIBS) -o $(LCR) 
 
 $(LCRADMIN): admin_client.c cause.c *.h Makefile
-       $(CC) $(LIBDIR) $(CFLAGS) $(CURSES) -lm admin_client.c cause.c \
+       $(PP) $(LIBDIR) $(CFLAGS) $(CURSES) -lm admin_client.c cause.c \
        -o $(LCRADMIN) 
 
 $(CHAN_LCR): chan_lcr.o bchannel.o
        -o $(LCRADMIN) 
 
 $(CHAN_LCR): chan_lcr.o bchannel.o
-       $(CD) $(LIBDIR) chan_lcr.o bchannel.o \
-       $(LIBS) -o $(CHAN_LCR) 
+       $(CC) $(LIBDIR) chan_lcr.o bchannel.o \
+       $(CHANLIBS) -o $(CHAN_LCR) 
 
 $(LCRWATCH): watch.c *.h Makefile
 
 $(LCRWATCH): watch.c *.h Makefile
-       $(CC) $(LIBDIR) $(CFLAGS) -lm watch.c \
+       $(PP) $(LIBDIR) $(CFLAGS) -lm watch.c \
        -o $(LCRWATCH) 
 
 $(GEN):        gentones.c *.h Makefile 
        -o $(LCRWATCH) 
 
 $(GEN):        gentones.c *.h Makefile 
-       $(CC) $(LIBDIR) $(CFLAGS) -lm gentones.c \
+       $(PP) $(LIBDIR) $(CFLAGS) -lm gentones.c \
        -o $(GEN) 
 
 $(GENW):genwave.c *.h Makefile 
        -o $(GEN) 
 
 $(GENW):genwave.c *.h Makefile 
-       $(CC) $(LIBDIR) $(CFLAGS) -lm genwave.c \
+       $(PP) $(LIBDIR) $(CFLAGS) -lm genwave.c \
        -o $(GENW) 
 
 $(GENRC): genrc.c *.h Makefile
        -o $(GENW) 
 
 $(GENRC): genrc.c *.h Makefile
-       $(CC) $(LIBDIR) $(CFLAGS) -lm genrc.c \
+       $(PP) $(LIBDIR) $(CFLAGS) -lm genrc.c \
        -o $(GENRC) 
 
 $(GENEXT): options.o extension.o genext.o
        -o $(GENRC) 
 
 $(GENEXT): options.o extension.o genext.o
-       $(CC) $(CFLAGS) options.o extension.o genext.o -o $(GENEXT) 
+       $(PP) $(CFLAGS) options.o extension.o genext.o -o $(GENEXT) 
 
 #install:
 #      @echo Remember, this is a beta release. To overwrite your current installed
 
 #install:
 #      @echo Remember, this is a beta release. To overwrite your current installed
index 6d504bd..ea8e8e1 100644 (file)
@@ -694,38 +694,32 @@ int bchannel_handle(void)
 #else
 int bchannel_handle(void)
 {
 #else
 int bchannel_handle(void)
 {
-       int ret;
        int i;
        struct bchannel *channel;
        int i;
        struct bchannel *channel;
-       msg_t *msg;
        iframe_t *frm;
        iframe_t *frm;
-       msg_t *dmsg;
-       mISDNuser_head_t *hh;
-       net_stack_t *nst;
+       unsigned char buffer[2048];
+       struct mISDNhead *hh = (struct mISDNhead *)buffer;
+       int len;
 
        /* no device, no read */
        if (bchannel_device < 0)
                return(0);
 
        /* get message from kernel */
 
        /* no device, no read */
        if (bchannel_device < 0)
                return(0);
 
        /* get message from kernel */
-       if (!(msg = alloc_msg(MAX_MSG_SIZE)))
-               return(1);
-       ret = mISDN_read(bchannel_device, msg->data, MAX_MSG_SIZE, 0);
-       if (ret < 0)
+       len = mISDN_read(bchannel_device, buffer, sizeof(buffer), 0);
+       if (len < 0)
        {
        {
-               free_msg(msg);
                if (errno == EAGAIN)
                        return(0);
                if (errno == EAGAIN)
                        return(0);
-               FATAL("Failed to do mISDN_read()\n");
+               PERROR("Failed to do mISDN_read()\n");
+               return(0);
        }
        }
-       if (!ret)
+       if (!len)
        {
        {
-               free_msg(msg);
 //             printf("%s: ERROR: mISDN_read() returns nothing\n");
                return(0);
        }
 //             printf("%s: ERROR: mISDN_read() returns nothing\n");
                return(0);
        }
-       msg->len = ret;
-       frm = (iframe_t *)msg->data;
+       frm = (iframe_t *)buffer;
 
        /* global prim */
        switch(frm->prim)
 
        /* global prim */
        switch(frm->prim)
@@ -735,7 +729,6 @@ int bchannel_handle(void)
                case MGR_ADDTIMER | CONFIRM:
                case MGR_DELTIMER | CONFIRM:
                case MGR_REMOVETIMER | CONFIRM:
                case MGR_ADDTIMER | CONFIRM:
                case MGR_DELTIMER | CONFIRM:
                case MGR_REMOVETIMER | CONFIRM:
-               free_msg(msg);
                return(1);
        }
 
                return(1);
        }
 
@@ -749,7 +742,7 @@ int bchannel_handle(void)
        } 
        if (!channel)
        {
        } 
        if (!channel)
        {
-               PERROR("message belongs to no channel: prim(0x%x) addr(0x%x) msg->len(%d)\n", frm->prim, frm->addr, msg->len);
+               PERROR("message belongs to no channel: prim(0x%x) addr(0x%x) msg->len(%d)\n", frm->prim, frm->addr, len);
                goto out;
        }
 
                goto out;
        }
 
@@ -766,7 +759,7 @@ int bchannel_handle(void)
                case DL_DATA | INDICATION:
                case PH_CONTROL | INDICATION:
                case PH_SIGNAL | INDICATION:
                case DL_DATA | INDICATION:
                case PH_CONTROL | INDICATION:
                case PH_SIGNAL | INDICATION:
-               bchannel_receive(channel, frm->prim, frm->dinfo, frm->data.p, frm->len);
+               bchannel_receive(channel, frm->prim, frm->dinfo, (unsigned char *)frm->data.p, frm->len);
                break;
 
                case PH_ACTIVATE | INDICATION:
                break;
 
                case PH_ACTIVATE | INDICATION:
@@ -786,11 +779,10 @@ int bchannel_handle(void)
                break;
 
                default:
                break;
 
                default:
-               PERROR("message not handled: prim(0x%x) addr(0x%x) msg->len(%d)\n", frm->prim, frm->addr, msg->len);
+               PERROR("message not handled: prim(0x%x) addr(0x%x) msg->len(%d)\n", frm->prim, frm->addr, len);
        }
 
        out:
        }
 
        out:
-       free_msg(msg);
        return(1);
 }
 #endif
        return(1);
 }
 #endif
@@ -828,16 +820,16 @@ struct bchannel *find_bchannel_ref(unsigned long ref)
 
 struct bchannel *alloc_bchannel(unsigned long handle)
 {
 
 struct bchannel *alloc_bchannel(unsigned long handle)
 {
-       struct chan_bchannel **channelp = &bchannel_first;
+       struct bchannel **channelp = &bchannel_first;
 
        while(*channelp)
                channelp = &((*channelp)->next);
 
 
        while(*channelp)
                channelp = &((*channelp)->next);
 
-       *channelp = (struct chan_bchannel *)malloc(sizeof(struct chan_bchannel));
+       *channelp = (struct bchannel *)malloc(sizeof(struct bchannel));
        if (!*channelp)
                return(NULL);
        if (!*channelp)
                return(NULL);
-       channel->handle = handle;
-       channel->b_state = BSTATE_IDLE;
+       (*channelp)->handle = handle;
+       (*channelp)->b_state = BSTATE_IDLE;
                
        return(*channelp);
 }
                
        return(*channelp);
 }
index dc22763..002cdd0 100644 (file)
@@ -50,7 +50,6 @@ void bchannel_activate(struct bchannel *channel, int activate);
 void bchannel_transmit(struct bchannel *channel, unsigned char *data, int len);
 void bchannel_join(struct bchannel *channel, unsigned short id);
 int bchannel_handle(void);
 void bchannel_transmit(struct bchannel *channel, unsigned char *data, int len);
 void bchannel_join(struct bchannel *channel, unsigned short id);
 int bchannel_handle(void);
-struct bchannel *bchannel_first = NULL;
 struct bchannel *find_bchannel_handle(unsigned long handle);
 struct bchannel *find_bchannel_ref(unsigned long ref);
 struct bchannel *alloc_bchannel(unsigned long handle);
 struct bchannel *find_bchannel_handle(unsigned long handle);
 struct bchannel *find_bchannel_ref(unsigned long ref);
 struct bchannel *alloc_bchannel(unsigned long handle);
index 47c41b6..4abb766 100644 (file)
@@ -40,7 +40,6 @@ with that reference.
 #include <sys/ioctl.h>
 #include <sys/socket.h>
 #include <sys/un.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
 #include <sys/un.h>
-#include "macro.h"
 #include "extension.h"
 #include "message.h"
 #include "admin.h"
 #include "extension.h"
 #include "message.h"
 #include "admin.h"
@@ -93,7 +92,7 @@ struct chan_call *alloc_call(void)
        while(*callp)
                callp = &((*callp)->next);
 
        while(*callp)
                callp = &((*callp)->next);
 
-       *callp = (struct chan_call *)MALLOC(sizeof(struct chan_call));
+       *callp = (struct chan_call *)malloc(sizeof(struct chan_call));
        return(*callp);
 }
 
        return(*callp);
 }
 
@@ -135,7 +134,7 @@ int send_message(int message_type, unsigned long ref, union parameter *param)
        adminp = &admin_first;
        while(*adminp)
                adminp = &((*adminp)->next);
        adminp = &admin_first;
        while(*adminp)
                adminp = &((*adminp)->next);
-       admin = (struct admin_list *)MALLOC(sizeof(struct admin_list));
+       admin = (struct admin_list *)malloc(sizeof(struct admin_list));
        *adminp = admin;
 
        admin->msg.type = message_type;
        *adminp = admin;
 
        admin->msg.type = message_type;
@@ -355,7 +354,7 @@ int handle_socket(void)
                }
                /* free head */
                admin_first = admin->next;
                }
                /* free head */
                admin_first = admin->next;
-               FREE(admin, 0);
+               free(admin);
 
                work = 1;
        } else
 
                work = 1;
        } else
@@ -393,7 +392,7 @@ int main(int argc, char *argv[])
        /* set socket address and name */
        memset(&sock_address, 0, sizeof(sock_address));
        sock_address.sun_family = PF_UNIX;
        /* set socket address and name */
        memset(&sock_address, 0, sizeof(sock_address));
        sock_address.sun_family = PF_UNIX;
-       UCPY(sock_address.sun_path, socket_name);
+       strcpy(sock_address.sun_path, socket_name);
 
        /* connect socket */
        if ((conn = connect(sock, (struct sockaddr *)&sock_address, SUN_LEN(&sock_address))) < 0)
 
        /* connect socket */
        if ((conn = connect(sock, (struct sockaddr *)&sock_address, SUN_LEN(&sock_address))) < 0)
@@ -413,7 +412,7 @@ int main(int argc, char *argv[])
 
        /* enque hello message */
        memset(&param, 0, sizeof(param));
 
        /* enque hello message */
        memset(&param, 0, sizeof(param));
-       SCPY(param.hello.application, "asterisk");
+       strcpy(param.hello.application, "asterisk");
        send_message(MESSAGE_HELLO, 0, &param);
 
        /* bchannel */
        send_message(MESSAGE_HELLO, 0, &param);
 
        /* bchannel */
index e24ff31..4672637 100644 (file)
@@ -178,6 +178,7 @@ int write_log(char *number, char *callerid, char *calledid, time_t start, time_t
 int parse_phonebook(char *number, char **abbrev_pointer, char **phone_pointer, char **name_pointer);
 int parse_secrets(char *number, char *remote_id, char **auth_pointer, char **crypt_pointer, char **key_pointer);
 char *parse_directory(char *number, int type);
 int parse_phonebook(char *number, char **abbrev_pointer, char **phone_pointer, char **name_pointer);
 int parse_secrets(char *number, char *remote_id, char **auth_pointer, char **crypt_pointer, char **key_pointer);
 char *parse_directory(char *number, int type);
+struct caller_info;
 int parse_callbackauth(char *number, struct caller_info *callerinfo);
 void append_callbackauth(char *number, struct caller_info *callerinfo);
 
 int parse_callbackauth(char *number, struct caller_info *callerinfo);
 void append_callbackauth(char *number, struct caller_info *callerinfo);