LCR is now uses socket based mISDN V2 API
authorSuper User <root@isdn.jolly.ten>
Sun, 1 Jun 2008 16:52:10 +0000 (18:52 +0200)
committerSuper User <root@isdn.jolly.ten>
Sun, 1 Jun 2008 16:52:10 +0000 (18:52 +0200)
*** chan_lcr, the Asterisk interface works (not complete yet).
-> LCR can be used as Asterisk channel driver.

modified:   Makefile
modified:   Makefile.am
modified:   README
modified:   action.cpp
modified:   apppbx.cpp
modified:   bchannel.c
modified:   bchannel.h
modified:   callerid.c
modified:   cause.c
modified:   chan_lcr.c
modified:   chan_lcr.h
modified:   configure.ac
modified:   default/routing.conf
modified:   dss1.cpp
modified:   dss1.h
modified:   genrc.c
modified:   ie.cpp
modified:   interface.c
modified:   lcradmin.c
modified:   mISDN.cpp
modified:   mISDN.h
modified:   main.c
modified:   main.h
modified:   message.h
modified:   myisdn.h
modified:   route.c
modified:   socket_server.c
modified:   trace.h

28 files changed:
Makefile
Makefile.am
README
action.cpp
apppbx.cpp
bchannel.c
bchannel.h
callerid.c
cause.c
chan_lcr.c
chan_lcr.h
configure.ac
default/routing.conf
dss1.cpp
dss1.h
genrc.c
ie.cpp
interface.c
lcradmin.c
mISDN.cpp
mISDN.h
main.c
main.h
message.h
myisdn.h
route.c
socket_server.c
trace.h

index 5c43a9a..1acde7a 100644 (file)
--- a/Makefile
+++ b/Makefile
 #*****************************************************************************/ 
 
 WITH-CRYPTO = 42 # comment this out, if no libcrypto should be used
 #*****************************************************************************/ 
 
 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 (this options is far unfinished !!!)
+WITH-ASTERISK = 42 # comment this out, if you don't require built-in Asterisk channel driver.
 # note: check your location and the names of libraries.
 
 # select location to install
 INSTALL_BIN = /usr/local/bin
 # note: check your location and the names of libraries.
 
 # select location to install
 INSTALL_BIN = /usr/local/bin
+INSTALL_CHAN = /usr/lib/asterisk/modules
 INSTALL_DATA = /usr/local/lcr
 
 INSTALL_DATA = /usr/local/lcr
 
-ifdef WITH-SOCKET
 LIBS += -lmisdn -lpthread
 LIBS += -lmisdn -lpthread
-else
-LIBS += -lisdnnet -lmISDN -lpthread
-endif
 CHANLIBS += -lmISDN
 
 # give location of the curses or ncurses library
 CHANLIBS += -lmISDN
 
 # give location of the curses or ncurses library
@@ -43,13 +39,11 @@ GENW = ./genwave
 GENRC = ./genrc
 GENEXT = ./genextension
 CFLAGS = -Wall -g -DINSTALL_DATA=\"$(INSTALL_DATA)\"
 GENRC = ./genrc
 GENEXT = ./genextension
 CFLAGS = -Wall -g -DINSTALL_DATA=\"$(INSTALL_DATA)\"
+CFLAGS += -I/usr/include/mISDNuser
 #CFLAGS = -Wall -g -DINSTALL_DATA=\"$(INSTALL_DATA)\"
 ifdef WITH-CRYPTO
 CFLAGS += -DCRYPTO
 endif
 #CFLAGS = -Wall -g -DINSTALL_DATA=\"$(INSTALL_DATA)\"
 ifdef WITH-CRYPTO
 CFLAGS += -DCRYPTO
 endif
-ifdef WITH-SOCKET
-CFLAGS += -DSOCKET_MISDN -I/usr/include/mISDNuser
-endif
 ifdef WITH-CRYPTO
 LIBDIR += -L/usr/local/ssl/lib
 CFLAGS += -I/usr/local/ssl/include
 ifdef WITH-CRYPTO
 LIBDIR += -L/usr/local/ssl/lib
 CFLAGS += -I/usr/local/ssl/include
@@ -63,12 +57,12 @@ endif
 #      @exit
 
 all: $(CHAN_LCR) $(LCR) $(LCRADMIN) $(GEN) $(GENW) $(GENRC) $(GENEXT)
 #      @exit
 
 all: $(CHAN_LCR) $(LCR) $(LCRADMIN) $(GEN) $(GENW) $(GENRC) $(GENEXT)
-       @sh -c 'grep -n strcpy *.c* --exclude chan_lcr.c --exclude bchannel.c ; if test $$''? = 0 ; then echo "dont use strcpy, use makro instead." ; exit -1 ; fi'
-       @sh -c 'grep -n strncpy *.c* --exclude chan_lcr.c --exclude bchannel.c ; if test $$''? = 0 ; then echo "dont use strncpy, use makro instead." ; exit -1 ; fi'
-       @sh -c 'grep -n strcat *.c* --exclude chan_lcr.c --exclude bchannel.c ; if test $$''? = 0 ; then echo "dont use strcat, use makro instead." ; exit -1 ; fi'
-       @sh -c 'grep -n strncat *.c* --exclude chan_lcr.c --exclude bchannel.c ; if test $$''? = 0 ; then echo "dont use strncat, use makro instead." ; exit -1 ; fi'
-       @sh -c 'grep -n sprintf *.c* --exclude chan_lcr.c --exclude bchannel.c ; if test $$''? = 0 ; then echo "dont use sprintf, use makro instead." ; exit -1 ; fi'
-       @sh -c 'grep -n snprintf *.c* --exclude chan_lcr.c --exclude bchannel.c ; if test $$''? = 0 ; then echo "dont use snprintf, use makro instead." ; exit -1 ; fi'
+       @sh -c 'grep -n strcpy *.c* --exclude chan_lcr.c --exclude bchannel.c --exclude callerid.c ; if test $$''? = 0 ; then echo "dont use strcpy, use makro instead." ; exit -1 ; fi'
+       @sh -c 'grep -n strncpy *.c* --exclude chan_lcr.c --exclude bchannel.c --exclude callerid.c ; if test $$''? = 0 ; then echo "dont use strncpy, use makro instead." ; exit -1 ; fi'
+       @sh -c 'grep -n strcat *.c* --exclude chan_lcr.c --exclude bchannel.c --exclude callerid.c ; if test $$''? = 0 ; then echo "dont use strcat, use makro instead." ; exit -1 ; fi'
+       @sh -c 'grep -n strncat *.c* --exclude chan_lcr.c --exclude bchannel.c --exclude callerid.c ; if test $$''? = 0 ; then echo "dont use strncat, use makro instead." ; exit -1 ; fi'
+       @sh -c 'grep -n sprintf *.c* --exclude chan_lcr.c --exclude bchannel.c --exclude callerid.c ; if test $$''? = 0 ; then echo "dont use sprintf, use makro instead." ; exit -1 ; fi'
+       @sh -c 'grep -n snprintf *.c* --exclude chan_lcr.c --exclude bchannel.c --exclude callerid.c ; if test $$''? = 0 ; then echo "dont use snprintf, use makro instead." ; exit -1 ; fi'
        @echo "All LCR binaries done"
        @sync
        @exit
        @echo "All LCR binaries done"
        @sync
        @exit
@@ -128,7 +122,9 @@ apppbx.o: apppbx.cpp *.h Makefile
        $(PP) -c $(CFLAGS) apppbx.cpp -o apppbx.o
 
 callerid.o: callerid.c *.h Makefile
        $(PP) -c $(CFLAGS) apppbx.cpp -o apppbx.o
 
 callerid.o: callerid.c *.h Makefile
-       $(PP) -c $(CFLAGS) callerid.c -o callerid.o
+       $(CC) -c $(CFLAGS) callerid.c -o callerid.o
+callerid.ooo: callerid.c *.h Makefile
+       $(PP) -c $(CFLAGS) callerid.c -o callerid.ooo
 
 join.o: join.cpp *.h Makefile
        $(PP) -c $(CFLAGS) join.cpp -o join.o
 
 join.o: join.cpp *.h Makefile
        $(PP) -c $(CFLAGS) join.cpp -o join.o
@@ -187,7 +183,7 @@ $(LCR): main.o \
        endpoint.o \
        endpointapp.o \
        apppbx.o \
        endpoint.o \
        endpointapp.o \
        apppbx.o \
-       callerid.o \
+       callerid.ooo \
        crypt.o \
        action.o \
        action_vbox.o \
        crypt.o \
        action.o \
        action_vbox.o \
@@ -215,7 +211,7 @@ $(LCR): main.o \
        endpoint.o \
        endpointapp.o \
        apppbx.o \
        endpoint.o \
        endpointapp.o \
        apppbx.o \
-       callerid.o \
+       callerid.ooo \
        crypt.o \
        action.o \
        action_vbox.o \
        crypt.o \
        action.o \
        action_vbox.o \
@@ -232,8 +228,8 @@ $(LCRADMIN): lcradmin.c cause.c *.h Makefile
        $(PP) $(LIBDIR) $(CFLAGS_LCRADMIN) $(CURSES) -lm lcradmin.c cause.c \
        -o $(LCRADMIN) 
 
        $(PP) $(LIBDIR) $(CFLAGS_LCRADMIN) $(CURSES) -lm lcradmin.c cause.c \
        -o $(LCRADMIN) 
 
-$(CHAN_LCR): chan_lcr.o bchannel.o *.h Makefile
-       gcc -shared -Xlinker -x $(LDFLAGS) -o $(CHAN_LCR) chan_lcr.o bchannel.o
+$(CHAN_LCR): chan_lcr.o bchannel.o callerid.o *.h Makefile
+       $(CC) -shared -Xlinker -x $(LDFLAGS) -o $(CHAN_LCR) chan_lcr.o bchannel.o callerid.o
 
 
 $(LCRWATCH): watch.c *.h Makefile
 
 
 $(LCRWATCH): watch.c *.h Makefile
@@ -264,9 +260,9 @@ install:
        -killall -9 -w -q lcr # the following error must be ignored
        cp $(LCR) $(INSTALL_BIN)
        cp $(LCRADMIN) $(INSTALL_BIN)
        -killall -9 -w -q lcr # the following error must be ignored
        cp $(LCR) $(INSTALL_BIN)
        cp $(LCRADMIN) $(INSTALL_BIN)
-#ifdef WITH-ASTERISK
-#      cp $(CHAN_LCR) $(INSTALL_CHAN)
-#endif
+ifdef WITH-ASTERISK
+       cp $(CHAN_LCR) $(INSTALL_CHAN)
+endif
 #      cp $(LCRWATCH) $(INSTALL_BIN)
        cp $(GEN) $(INSTALL_BIN)
        cp $(GENW) $(INSTALL_BIN)
 #      cp $(LCRWATCH) $(INSTALL_BIN)
        cp $(GEN) $(INSTALL_BIN)
        cp $(GENW) $(INSTALL_BIN)
index 84037b1..b38f4f8 100644 (file)
@@ -1,3 +1,5 @@
+OUTDATED!!!! must be rewritten! see Makefile
+
 ## Makefile.am -- Process this file with automake to produce Makefile.in
 
 
 ## Makefile.am -- Process this file with automake to produce Makefile.in
 
 
diff --git a/README b/README
index a16ea7c..94fd65b 100644 (file)
--- a/README
+++ b/README
@@ -421,3 +421,13 @@ Changes in Version 0.5
 - Errors in information elements are now reported inside log/trace.
 - Recover bchannel (de-)activation if message from mISDN got lost
 
 - Errors in information elements are now reported inside log/trace.
 - Recover bchannel (de-)activation if message from mISDN got lost
 
+Changes in Version 1.0
+- Bugfixes
+- Complete port to new mISDN V2 API (socket based).
+  -> Old mISDN will not work anymore.
+- Interfaces mode (NT/TE PTP/PTMP) can now be changed at runtime.
+  -> No more module parameters must be given for cards.
+- First Alpha release of chan_lcr - the Asterisk PBX channel link driver.
+  -> Use LCR in conjunction with Asterisk, or simply as ISDN frontend.
+
+
index e98193b..ce741c6 100644 (file)
@@ -48,9 +48,9 @@ void EndpointAppPBX::_action_init_call(char *remote)
                        trace_header("ACTION remote (not available)", DIRECTION_NONE);
                        add_trace("application", NULL, "%s", remote);
                        end_trace();
                        trace_header("ACTION remote (not available)", DIRECTION_NONE);
                        add_trace("application", NULL, "%s", remote);
                        end_trace();
-                       message_disconnect_port(portlist, CAUSE_RESSOURCEUNAVAIL, LOCATION_PRIVATE_LOCAL, "");
+                       message_disconnect_port(portlist, CAUSE_OUTOFORDER, LOCATION_PRIVATE_LOCAL, "");
                        new_state(EPOINT_STATE_OUT_DISCONNECT);
                        new_state(EPOINT_STATE_OUT_DISCONNECT);
-                       set_tone(portlist,"cause_22");
+                       set_tone(portlist,"cause_1b");
                        return;
                }
                join = new JoinRemote(ea_endpoint->ep_serial, remote, admin->sock);
                        return;
                }
                join = new JoinRemote(ea_endpoint->ep_serial, remote, admin->sock);
@@ -67,57 +67,6 @@ void EndpointAppPBX::action_init_call(void)
 }
 void EndpointAppPBX::action_init_remote(void)
 {
 }
 void EndpointAppPBX::action_init_remote(void)
 {
-       struct route_param      *rparam;
-       struct port_list        *portlist = ea_endpoint->ep_portlist;
-       struct lcr_msg          *message;
-       struct capa_info        capainfo;
-       struct caller_info      callerinfo;
-       struct redir_info       redirinfo;
-       struct dialing_info     dialinginfo;
-       char                    context[128] = "";
-       char                    remote[32];
-
-       if (!(rparam = routeparam(e_action, PARAM_APPLICATION)))
-       {
-               trace_header("ACTION remote (no application given)", DIRECTION_NONE);
-               end_trace();
-               new_state(EPOINT_STATE_OUT_DISCONNECT);
-               message_disconnect_port(portlist, CAUSE_SERVICEUNAVAIL, LOCATION_PRIVATE_LOCAL, "");
-               set_tone(portlist, "cause_3f");
-               return;
-       }
-       SCPY(remote, rparam->string_value);
-       _action_init_call(remote);
-
-       /* create bearer/caller/dialinginfo */
-       memcpy(&capainfo, &e_capainfo, sizeof(capainfo));
-       memcpy(&callerinfo, &e_callerinfo, sizeof(callerinfo));
-       memcpy(&redirinfo, &e_redirinfo, sizeof(redirinfo));
-       memset(&dialinginfo, 0, sizeof(dialinginfo));
-
-       if ((rparam = routeparam(e_action, PARAM_CONTEXT)))
-       {
-               SCPY(context, rparam->string_value);
-       }
-       if ((rparam = routeparam(e_action, PARAM_EXTEN)))
-       {
-               SCPY(dialinginfo.id, rparam->string_value);
-               dialinginfo.ntype = INFO_NTYPE_UNKNOWN;
-       }
-       /* send setup to remote */
-       trace_header("ACTION remote (setup)", DIRECTION_NONE);
-       add_trace("number", NULL, dialinginfo.id);
-       add_trace("remote", NULL, remote);
-       if (context[0])
-               add_trace("context", NULL, context);
-       end_trace();
-       message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_join_id, EPOINT_TO_JOIN, MESSAGE_SETUP);
-       memcpy(&message->param.setup.dialinginfo, &dialinginfo, sizeof(struct dialing_info));
-       memcpy(&message->param.setup.redirinfo, &redirinfo, sizeof(struct redir_info));
-       memcpy(&message->param.setup.callerinfo, &callerinfo, sizeof(struct caller_info));
-       memcpy(&message->param.setup.capainfo, &capainfo, sizeof(struct capa_info));
-       SCPY(message->param.setup.context, context);
-       message_put(message);
 }
 
 /*
 }
 
 /*
@@ -399,22 +348,77 @@ void EndpointAppPBX::action_dialing_external(void)
 
 void EndpointAppPBX::action_dialing_remote(void)
 {
 
 void EndpointAppPBX::action_dialing_remote(void)
 {
-       struct lcr_msg *message;
-       struct dialing_info dialinginfo;
-//     struct route_param *rparam;
-
-       /* create bearer/caller/dialinginfo */
-       memset(&dialinginfo, 0, sizeof(dialinginfo));
+       struct route_param      *rparam;
+       struct port_list        *portlist = ea_endpoint->ep_portlist;
+       struct lcr_msg          *message;
+       struct capa_info        capainfo;
+       struct caller_info      callerinfo;
+       struct redir_info       redirinfo;
+       struct dialing_info     dialinginfo;
+       char                    context[128] = "";
+       char                    remote[32];
 
 
-       if (dialinginfo.id[0])
+       if (e_state == EPOINT_STATE_IN_SETUP && !ea_endpoint->ep_join_id)
        {
        {
-               /* add or update outgoing call */
-               trace_header("ACTION remote (dialing)", DIRECTION_NONE);
+               /* no join yet, sending setup */
+               if (!(rparam = routeparam(e_action, PARAM_APPLICATION)))
+               {
+                       trace_header("ACTION remote (no application given)", DIRECTION_NONE);
+                       end_trace();
+                       new_state(EPOINT_STATE_OUT_DISCONNECT);
+                       message_disconnect_port(portlist, CAUSE_SERVICEUNAVAIL, LOCATION_PRIVATE_LOCAL, "");
+                       set_tone(portlist, "cause_3f");
+                       return;
+               }
+               SCPY(remote, rparam->string_value);
+               _action_init_call(remote);
+
+               /* create bearer/caller/dialinginfo */
+               memcpy(&capainfo, &e_capainfo, sizeof(capainfo));
+               memcpy(&callerinfo, &e_callerinfo, sizeof(callerinfo));
+               memcpy(&redirinfo, &e_redirinfo, sizeof(redirinfo));
+               memset(&dialinginfo, 0, sizeof(dialinginfo));
+
+               if ((rparam = routeparam(e_action, PARAM_CONTEXT)))
+               {
+                       SCPY(context, rparam->string_value);
+               }
+               if ((rparam = routeparam(e_action, PARAM_EXTEN)))
+               {
+                       SCPY(dialinginfo.id, rparam->string_value);
+                       dialinginfo.ntype = INFO_NTYPE_UNKNOWN;
+               } else
+               {
+                       SCPY(dialinginfo.id, e_extdialing);
+               }
+               /* send setup to remote */
+               trace_header("ACTION remote (setup)", DIRECTION_NONE);
                add_trace("number", NULL, dialinginfo.id);
                add_trace("number", NULL, dialinginfo.id);
+               add_trace("remote", NULL, remote);
+               if (context[0])
+                       add_trace("context", NULL, context);
                end_trace();
                end_trace();
-               message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_join_id, EPOINT_TO_JOIN, MESSAGE_INFORMATION);
-               memcpy(&message->param.information, &dialinginfo, sizeof(struct dialing_info));
+               message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_join_id, EPOINT_TO_JOIN, MESSAGE_SETUP);
+               memcpy(&message->param.setup.dialinginfo, &dialinginfo, sizeof(struct dialing_info));
+               memcpy(&message->param.setup.redirinfo, &redirinfo, sizeof(struct redir_info));
+               memcpy(&message->param.setup.callerinfo, &callerinfo, sizeof(struct caller_info));
+               memcpy(&message->param.setup.capainfo, &capainfo, sizeof(struct capa_info));
+               SCPY(message->param.setup.context, context);
                message_put(message);
                message_put(message);
+       } else
+       {
+               /* send overlap digits */
+               trace_header("ACTION remote (dialing)", DIRECTION_NONE);
+               add_trace("number", NULL, e_extdialing);
+               end_trace();
+               if (e_extdialing[0])
+               {
+                       message = message_create(ea_endpoint->ep_serial, ea_endpoint->ep_join_id, EPOINT_TO_JOIN, MESSAGE_INFORMATION);
+                       memcpy(&message->param.information, &e_dialinginfo, sizeof(struct dialing_info));
+                       SCPY(message->param.information.id, e_extdialing);
+                       e_extdialing = e_dialinginfo.id + strlen(e_dialinginfo.id);
+                       message_put(message);
+               }
        }
 }
 
        }
 }
 
index b561591..981c867 100644 (file)
@@ -621,7 +621,7 @@ foundif:
        if (!interface->ifport)
        {
                /* no ports */
        if (!interface->ifport)
        {
                /* no ports */
-               trace_header("CHANNEL SELECTION (interface has no active ports, skipping)", DIRECTION_NONE);
+               trace_header("CHANNEL SELECTION (active ports, skipping)", DIRECTION_NONE);
                add_trace("interface", NULL, "%s", interface->name);
                end_trace();
                interface = interface->next;
                add_trace("interface", NULL, "%s", interface->name);
                end_trace();
                interface = interface->next;
@@ -672,7 +672,7 @@ foundif:
        /* see if link is up on PTP*/
        if (mISDNport->l2hold && !mISDNport->l2link)
        {
        /* see if link is up on PTP*/
        if (mISDNport->l2hold && !mISDNport->l2link)
        {
-               trace_header("CHANNEL SELECTION (port holds layer 2, but layer 2 is down, skipping)", DIRECTION_NONE);
+               trace_header("CHANNEL SELECTION (port's layer 2 is down, skipping)", DIRECTION_NONE);
                add_trace("port", NULL, "%d", ifport->portnum);
                add_trace("position", NULL, "%d", index);
                end_trace();
                add_trace("port", NULL, "%d", ifport->portnum);
                add_trace("position", NULL, "%d", index);
                end_trace();
@@ -809,6 +809,11 @@ foundif:
        if (ifport != ifport_start)
                goto nextport;
 
        if (ifport != ifport_start)
                goto nextport;
 
+       if (!ifname) {
+               interface = interface->next;
+               goto checknext;
+       }
+
        return(NULL); /* no port found */
 }
 
        return(NULL); /* no port found */
 }
 
index b866b69..6d28a7c 100644 (file)
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
-#ifdef SOCKET_MISDN
 #include <netinet/udp.h>
 #include <netinet/in.h>
 #include <netdb.h>
 #include <sys/socket.h>
 #include <mISDNif.h>
 #include <netinet/udp.h>
 #include <netinet/in.h>
 #include <netdb.h>
 #include <sys/socket.h>
 #include <mISDNif.h>
-#else
-#include <mISDNuser/isdn_net.h>
-#include <mISDNuser/net_l3.h>
-#endif
 
 #include <asterisk/frame.h>
 
 
 #include <asterisk/frame.h>
 
@@ -52,9 +47,9 @@ enum {
        BSTATE_IDLE,
        BSTATE_ACTIVATING,
        BSTATE_ACTIVE,
        BSTATE_IDLE,
        BSTATE_ACTIVATING,
        BSTATE_ACTIVE,
+       BSTATE_DEACTIVATING,
 };
 
 };
 
-#ifdef SOCKET_MISDN
 
 int bchannel_initialize(void)
 {
 
 int bchannel_initialize(void)
 {
@@ -64,90 +59,25 @@ int bchannel_initialize(void)
 void bchannel_deinitialize(void)
 {
 }
 void bchannel_deinitialize(void)
 {
 }
-#else
-int bchannel_entity = 0; /* used for udevice */
-int bchannel_device = -1; /* the device handler and port list */
-
-int bchannel_initialize(void)
-{
-       unsigned char buff[1025];
-       iframe_t *frm = (iframe_t *)buff;
-       int ret;
-
-       /* open mISDNdevice if not already open */
-       if (bchannel_device < 0)
-       {
-               ret = mISDN_open();
-               if (ret < 0)
-               {
-                       CERROR(NULL, NULL, "cannot open mISDN device ret=%d errno=%d (%s) Check for mISDN modules!\nAlso did you create \"/dev/mISDN\"? Do: \"mknod /dev/mISDN c 46 0\"\n", ret, errno, strerror(errno));
-                       return(-1);
-               }
-               bchannel_device = ret;
-               CDEBUG(NULL, NULL, "mISDN device opened.\n");
-
-               /* create entity for layer 3 TE-mode */
-               mISDN_write_frame(bchannel_device, buff, 0, MGR_NEWENTITY | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
-               ret = mISDN_read_frame(bchannel_device, frm, sizeof(iframe_t), 0, MGR_NEWENTITY | CONFIRM, TIMEOUT_1SEC);
-               if (ret < (int)mISDN_HEADER_LEN)
-               {
-                       noentity:
-                       CERROR(NULL, NULL, "Cannot request MGR_NEWENTITY from mISDN. Exitting due to software bug.");
-                       return(-1);
-               }
-               bchannel_entity = frm->dinfo & 0xffff;
-               if (!bchannel_entity)
-                       goto noentity;
-       }
-       return(0);
-}
-
-void bchannel_deinitialize(void)
-{
-       unsigned char buff[1025];
-
-       if (bchannel_device >= 0)
-       {
-               /* free entity */
-               mISDN_write_frame(bchannel_device, buff, 0, MGR_DELENTITY | REQUEST, bchannel_entity, 0, NULL, TIMEOUT_1SEC);
-               /* close device */
-               mISDN_close(bchannel_device);
-               bchannel_device = -1;
-       }
-}
-#endif
 
 /*
  * send control information to the channel (dsp-module)
  */
 static void ph_control(unsigned long handle, unsigned long c1, unsigned long c2, char *trace_name, int trace_value)
 {
 
 /*
  * send control information to the channel (dsp-module)
  */
 static void ph_control(unsigned long handle, unsigned long c1, unsigned long c2, char *trace_name, int trace_value)
 {
-#ifdef SOCKET_MISDN
        unsigned char buffer[MISDN_HEADER_LEN+sizeof(int)+sizeof(int)];
        struct mISDNhead *ctrl = (struct mISDNhead *)buffer;
        unsigned long *d = (unsigned long *)(buffer+MISDN_HEADER_LEN);
        int ret;
 
        unsigned char buffer[MISDN_HEADER_LEN+sizeof(int)+sizeof(int)];
        struct mISDNhead *ctrl = (struct mISDNhead *)buffer;
        unsigned long *d = (unsigned long *)(buffer+MISDN_HEADER_LEN);
        int ret;
 
+       CDEBUG(NULL, NULL, "Sending PH_CONTROL %d,%d\n", c1, c2);
        ctrl->prim = PH_CONTROL_REQ;
        ctrl->id = 0;
        *d++ = c1;
        *d++ = c2;
        ret = sendto(handle, buffer, MISDN_HEADER_LEN+sizeof(int)*2, 0, NULL, 0);
        ctrl->prim = PH_CONTROL_REQ;
        ctrl->id = 0;
        *d++ = c1;
        *d++ = c2;
        ret = sendto(handle, buffer, MISDN_HEADER_LEN+sizeof(int)*2, 0, NULL, 0);
-       if (!ret)
+       if (ret < 0)
                CERROR(NULL, NULL, "Failed to send to socket %d\n", handle);
                CERROR(NULL, NULL, "Failed to send to socket %d\n", handle);
-#else
-       unsigned char buffer[mISDN_HEADER_LEN+sizeof(int)+sizeof(int)];
-       iframe_t *ctrl = (iframe_t *)buffer; 
-       unsigned long *d = (unsigned long *)&ctrl->data.p;
-
-       ctrl->prim = PH_CONTROL | REQUEST;
-       ctrl->addr = handle | FLG_MSG_DOWN;
-       ctrl->dinfo = 0;
-       ctrl->len = sizeof(int)*2;
-       *d++ = c1;
-       *d++ = c2;
-       mISDN_write(bchannel_device, ctrl, mISDN_HEADER_LEN+ctrl->len, TIMEOUT_1SEC);
-#endif
 #if 0
        chan_trace_header(mISDNport, isdnport, "BCHANNEL control", DIRECTION_OUT);
        if (c1 == CMX_CONF_JOIN)
 #if 0
        chan_trace_header(mISDNport, isdnport, "BCHANNEL control", DIRECTION_OUT);
        if (c1 == CMX_CONF_JOIN)
@@ -160,32 +90,19 @@ static void ph_control(unsigned long handle, unsigned long c1, unsigned long c2,
 
 static void ph_control_block(unsigned long handle, unsigned long c1, void *c2, int c2_len, char *trace_name, int trace_value)
 {
 
 static void ph_control_block(unsigned long handle, unsigned long c1, void *c2, int c2_len, char *trace_name, int trace_value)
 {
-#ifdef SOCKET_MISDN
        unsigned char buffer[MISDN_HEADER_LEN+sizeof(int)+c2_len];
        struct mISDNhead *ctrl = (struct mISDNhead *)buffer;
        unsigned long *d = (unsigned long *)(buffer+MISDN_HEADER_LEN);
        int ret;
 
        unsigned char buffer[MISDN_HEADER_LEN+sizeof(int)+c2_len];
        struct mISDNhead *ctrl = (struct mISDNhead *)buffer;
        unsigned long *d = (unsigned long *)(buffer+MISDN_HEADER_LEN);
        int ret;
 
+       CDEBUG(NULL, NULL, "Sending PH_CONTROL (block) %d\n", c1);
        ctrl->prim = PH_CONTROL_REQ;
        ctrl->id = 0;
        *d++ = c1;
        memcpy(d, c2, c2_len);
        ret = sendto(handle, buffer, MISDN_HEADER_LEN+sizeof(int)+c2_len, 0, NULL, 0);
        ctrl->prim = PH_CONTROL_REQ;
        ctrl->id = 0;
        *d++ = c1;
        memcpy(d, c2, c2_len);
        ret = sendto(handle, buffer, MISDN_HEADER_LEN+sizeof(int)+c2_len, 0, NULL, 0);
-       if (!ret)
+       if (ret < 0)
                CERROR(NULL, NULL, "Failed to send to socket %d\n", handle);
                CERROR(NULL, NULL, "Failed to send to socket %d\n", handle);
-#else
-       unsigned char buffer[mISDN_HEADER_LEN+sizeof(int)+c2_len];
-       iframe_t *ctrl = (iframe_t *)buffer;
-       unsigned long *d = (unsigned long *)&ctrl->data.p;
-
-       ctrl->prim = PH_CONTROL | REQUEST;
-       ctrl->addr = handle | FLG_MSG_DOWN;
-       ctrl->dinfo = 0;
-       ctrl->len = sizeof(int)+c2_len;
-       *d++ = c1;
-       memcpy(d, c2, c2_len);
-       mISDN_write(bchannel_device, ctrl, mISDN_HEADER_LEN+ctrl->len, TIMEOUT_1SEC);
-#endif
 #if 0
        chan_trace_header(mISDNport, isdnport, "BCHANNEL control", DIRECTION_OUT);
        add_trace(trace_name, NULL, "%d", trace_value);
 #if 0
        chan_trace_header(mISDNport, isdnport, "BCHANNEL control", DIRECTION_OUT);
        add_trace(trace_name, NULL, "%d", trace_value);
@@ -200,7 +117,6 @@ static void ph_control_block(unsigned long handle, unsigned long c1, void *c2, i
 int bchannel_create(struct bchannel *bchannel)
 {
        int ret;
 int bchannel_create(struct bchannel *bchannel)
 {
        int ret;
-#ifdef SOCKET_MISDN
        unsigned long on = 1;
        struct sockaddr_mISDN addr;
 
        unsigned long on = 1;
        struct sockaddr_mISDN addr;
 
@@ -225,6 +141,7 @@ int bchannel_create(struct bchannel *bchannel)
                CERROR(NULL, NULL, "Failed to set bchannel-socket handle 0x%x into nonblocking IO\n", bchannel->handle);
                close(bchannel->b_sock);
                bchannel->b_sock = -1;
                CERROR(NULL, NULL, "Failed to set bchannel-socket handle 0x%x into nonblocking IO\n", bchannel->handle);
                close(bchannel->b_sock);
                bchannel->b_sock = -1;
+               bchannel->handle = 0;
                return(0);
        }
 
                return(0);
        }
 
@@ -249,86 +166,6 @@ int bchannel_create(struct bchannel *bchannel)
 #endif
        return(1);
 }
 #endif
        return(1);
 }
-#else
-       unsigned char buff[1024];
-       layer_info_t li;
-       mISDN_pid_t pid;
-
-       if (bchannel->b_stid)
-       {
-               CERROR(NULL, NULL, "Stack already created for address 0x%lx\n", bchannel->b_stid);
-               return(0);
-       }
-
-       if (bchannel->b_addr)
-       {
-               CERROR(NULL, NULL, "Stack already created for address 0x%lx\n", bchannel->b_addr);
-               return(0);
-       }
-
-       /* create new layer */
-       CDEBUG(NULL, NULL, "creating new layer for stid 0x%lx.\n" , bchannel->handle);
-       memset(&li, 0, sizeof(li));
-       memset(&pid, 0, sizeof(pid));
-       li.object_id = -1;
-       li.extentions = 0;
-       li.st = bchannel->handle;
-       strcpy(li.name, "B L4");
-       li.pid.layermask = ISDN_LAYER((4));
-       li.pid.protocol[4] = ISDN_PID_L4_B_USER;
-       ret = mISDN_new_layer(bchannel_device, &li);
-       if (ret)
-       {
-               failed_new_layer:
-               CERROR(NULL, NULL, "mISDN_new_layer() failed to add bchannel for stid 0x%lx.\n", bchannel->handle);
-               goto failed;
-       }
-       if (!li.id)
-       {
-               goto failed_new_layer;
-       }
-       bchannel->b_stid = bchannel->handle;
-       bchannel->b_addr = li.id;
-       CDEBUG(NULL, NULL, "new layer (b_addr=0x%x)\n", bchannel->b_addr);
-
-       /* create new stack */
-       pid.protocol[1] = ISDN_PID_L1_B_64TRANS;
-       pid.protocol[2] = ISDN_PID_L2_B_TRANS;
-       pid.protocol[3] = ISDN_PID_L3_B_DSP;
-       pid.protocol[4] = ISDN_PID_L4_B_USER;
-       pid.layermask = ISDN_LAYER((1)) | ISDN_LAYER((2)) | ISDN_LAYER((3)) | ISDN_LAYER((4));
-       ret = mISDN_set_stack(bchannel_device, bchannel->b_stid, &pid);
-       if (ret)
-       {
-               stack_error:
-               CERROR(NULL, NULL, "mISDN_set_stack() failed (ret=%d) to add bchannel stid=0x%lx\n", ret, bchannel->b_stid);
-               mISDN_write_frame(bchannel_device, buff, bchannel->b_addr, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
-               goto failed;
-       }
-       ret = mISDN_get_setstack_ind(bchannel_device, bchannel->b_addr);
-       if (ret)
-               goto stack_error;
-
-       /* get layer id */
-       bchannel->b_addr = mISDN_get_layerid(bchannel_device, bchannel->b_stid, 4);
-       if (!bchannel->b_addr)
-               goto stack_error;
-#if 0
-       chan_trace_header(mISDNport, mISDNport->b_port[i], "BCHANNEL create stack", DIRECTION_OUT);
-       add_trace("channel", NULL, "%d", i+1+(i>=15));
-       add_trace("stack", "id", "0x%08x", mISDNport->b_stid[i]);
-       add_trace("stack", "address", "0x%08x", mISDNport->b_addr[i]);
-       end_trace();
-#endif
-
-       return(1);
-
-failed:
-       bchannel->b_stid = 0;
-       bchannel->b_addr = 0;
-       return(0);
-}
-#endif
 
 
 /*
 
 
 /*
@@ -336,27 +173,18 @@ failed:
  */
 void bchannel_activate(struct bchannel *bchannel, int activate)
 {
  */
 void bchannel_activate(struct bchannel *bchannel, int activate)
 {
-#ifdef SOCKET_MISDN
        struct mISDNhead act;
        int ret;
 
        struct mISDNhead act;
        int ret;
 
+       /* activate bchannel */
+       CDEBUG(NULL, NULL, "%sActivating B-channel.\n", activate?"":"De-");
        act.prim = (activate)?DL_ESTABLISH_REQ:DL_RELEASE_REQ; 
        act.id = 0;
        ret = sendto(bchannel->b_sock, &act, MISDN_HEADER_LEN, 0, NULL, 0);
        act.prim = (activate)?DL_ESTABLISH_REQ:DL_RELEASE_REQ; 
        act.id = 0;
        ret = sendto(bchannel->b_sock, &act, MISDN_HEADER_LEN, 0, NULL, 0);
-       if (!ret)
+       if (ret < 0)
                CERROR(NULL, NULL, "Failed to send to socket %d\n", bchannel->b_sock);
                CERROR(NULL, NULL, "Failed to send to socket %d\n", bchannel->b_sock);
-#else
-       iframe_t act;
-
-       /* activate bchannel */
-       act.prim = (activate?DL_ESTABLISH:DL_RELEASE) | REQUEST; 
-       act.addr = bchannel->b_addr | FLG_MSG_DOWN;
-       act.dinfo = 0;
-       act.len = 0;
-       mISDN_write(bchannel_device, &act, mISDN_HEADER_LEN+act.len, TIMEOUT_1SEC);
-#endif
 
 
-       bchannel->b_state = BSTATE_ACTIVATING;
+       bchannel->b_state = (activate)?BSTATE_ACTIVATING:BSTATE_DEACTIVATING;
 #if 0
        /* trace */
        chan_trace_header(mISDNport, mISDNport->b_port[i], activate?(char*)"BCHANNEL activate":(char*)"BCHANNEL deactivate", DIRECTION_OUT);
 #if 0
        /* trace */
        chan_trace_header(mISDNport, mISDNport->b_port[i], activate?(char*)"BCHANNEL activate":(char*)"BCHANNEL deactivate", DIRECTION_OUT);
@@ -371,15 +199,9 @@ void bchannel_activate(struct bchannel *bchannel, int activate)
  */
 static void bchannel_activated(struct bchannel *bchannel)
 {
  */
 static void bchannel_activated(struct bchannel *bchannel)
 {
-#ifdef SOCKET_MISDN
        int handle;
 
        handle = bchannel->b_sock;
        int handle;
 
        handle = bchannel->b_sock;
-#else
-       unsigned long handle;
-
-       handle = bchannel->b_addr;
-#endif
 
        /* set dsp features */
        if (bchannel->b_txdata)
 
        /* set dsp features */
        if (bchannel->b_txdata)
@@ -393,11 +215,7 @@ static void bchannel_activated(struct bchannel *bchannel)
        if (bchannel->b_rx_gain)
                ph_control(handle, DSP_VOL_CHANGE_RX, bchannel->b_rx_gain, "DSP-RX_GAIN", bchannel->b_rx_gain);
        if (bchannel->b_pipeline[0])
        if (bchannel->b_rx_gain)
                ph_control(handle, DSP_VOL_CHANGE_RX, bchannel->b_rx_gain, "DSP-RX_GAIN", bchannel->b_rx_gain);
        if (bchannel->b_pipeline[0])
-#ifdef SOCKET_MISDN
                ph_control_block(handle, DSP_PIPELINE_CFG, bchannel->b_pipeline, strlen(bchannel->b_pipeline)+1, "DSP-PIPELINE", 0);
                ph_control_block(handle, DSP_PIPELINE_CFG, bchannel->b_pipeline, strlen(bchannel->b_pipeline)+1, "DSP-PIPELINE", 0);
-#else
-               ph_control_block(handle, PIPELINE_CFG, bchannel->b_pipeline, strlen(bchannel->b_pipeline)+1, "DSP-PIPELINE", 0);
-#endif
        if (bchannel->b_conf)
                ph_control(handle, DSP_CONF_JOIN, bchannel->b_conf, "DSP-CONF", bchannel->b_conf);
        if (bchannel->b_echo)
        if (bchannel->b_conf)
                ph_control(handle, DSP_CONF_JOIN, bchannel->b_conf, "DSP-CONF", bchannel->b_conf);
        if (bchannel->b_echo)
@@ -423,7 +241,6 @@ static void bchannel_activated(struct bchannel *bchannel)
  */
 static void bchannel_destroy(struct bchannel *bchannel)
 {
  */
 static void bchannel_destroy(struct bchannel *bchannel)
 {
-#ifdef SOCKET_MISDN
 #if 0
        chan_trace_header(mISDNport, mISDNport->b_port[i], "BCHANNEL remove socket", DIRECTION_OUT);
        add_trace("channel", NULL, "%d", i+1+(i>=15));
 #if 0
        chan_trace_header(mISDNport, mISDNport->b_port[i], "BCHANNEL remove socket", DIRECTION_OUT);
        add_trace("channel", NULL, "%d", i+1+(i>=15));
@@ -435,26 +252,6 @@ static void bchannel_destroy(struct bchannel *bchannel)
                close(bchannel->b_sock);
                bchannel->b_sock = -1;
        }
                close(bchannel->b_sock);
                bchannel->b_sock = -1;
        }
-#else
-       unsigned char buff[1024];
-
-#if 0
-       chan_trace_header(mISDNport, mISDNport->b_port[i], "BCHANNEL remove stack", DIRECTION_OUT);
-       add_trace("channel", NULL, "%d", i+1+(i>=15));
-       add_trace("stack", "id", "0x%08x", mISDNport->b_stid[i]);
-       add_trace("stack", "address", "0x%08x", mISDNport->b_addr[i]);
-       end_trace();
-#endif
-       /* remove our stack only if set */
-       if (bchannel->b_addr)
-       {
-               CDEBUG(NULL, NULL, "free stack (b_addr=0x%x)\n", bchannel->b_addr);
-               mISDN_clear_stack(bchannel_device, bchannel->b_stid);
-               mISDN_write_frame(bchannel_device, buff, bchannel->b_addr | FLG_MSG_DOWN, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
-               bchannel->b_stid = 0;
-               bchannel->b_addr = 0;
-       }
-#endif
        bchannel->b_state = BSTATE_IDLE;
 }
 
        bchannel->b_state = BSTATE_IDLE;
 }
 
@@ -470,11 +267,7 @@ static void bchannel_receive(struct bchannel *bchannel, unsigned long prim, unsi
 //     unsigned char *p;
 //     int l;
 
 //     unsigned char *p;
 //     int l;
 
-#ifdef SOCKET_MISDN
        if (prim == PH_CONTROL_IND)
        if (prim == PH_CONTROL_IND)
-#else
-       if (prim == (PH_CONTROL | INDICATION))
-#endif
        {
                if (len < 4)
                {
        {
                if (len < 4)
                {
@@ -494,11 +287,7 @@ static void bchannel_receive(struct bchannel *bchannel, unsigned long prim, unsi
                }
                switch(cont)
                {
                }
                switch(cont)
                {
-#ifdef SOCKET_MISDN
                        case DSP_BF_REJECT:
                        case DSP_BF_REJECT:
-#else
-                       case BF_REJECT:
-#endif
 #if 0
                        chan_trace_header(p_m_mISDNport, this, "BCHANNEL control", DIRECTION_IN);
                        add_trace("DSP-CRYPT", NULL, "error");
 #if 0
                        chan_trace_header(p_m_mISDNport, this, "BCHANNEL control", DIRECTION_IN);
                        add_trace("DSP-CRYPT", NULL, "error");
@@ -506,11 +295,7 @@ static void bchannel_receive(struct bchannel *bchannel, unsigned long prim, unsi
 #endif
                        break;
 
 #endif
                        break;
 
-#ifdef SOCKET_MISDN
                        case DSP_BF_ACCEPT:
                        case DSP_BF_ACCEPT:
-#else
-                       case BF_ACCEPT:
-#endif
 #if 0
                        chan_trace_header(p_m_mISDNport, this, "BCHANNEL control", DIRECTION_IN);
                        add_trace("DSP-CRYPT", NULL, "ok");
 #if 0
                        chan_trace_header(p_m_mISDNport, this, "BCHANNEL control", DIRECTION_IN);
                        add_trace("DSP-CRYPT", NULL, "ok");
@@ -529,7 +314,6 @@ static void bchannel_receive(struct bchannel *bchannel, unsigned long prim, unsi
                }
                return;
        }
                }
                return;
        }
-#ifdef SOCKET_MISDN
        if (prim == PH_DATA_REQ)
        {
                if (!bchannel->b_txdata)
        if (prim == PH_DATA_REQ)
        {
                if (!bchannel->b_txdata)
@@ -540,32 +324,6 @@ static void bchannel_receive(struct bchannel *bchannel, unsigned long prim, unsi
                }
                return;
        }
                }
                return;
        }
-#else
-       if (prim == (PH_SIGNAL | INDICATION))
-       {
-               switch(dinfo)
-               {
-                       case CMX_TX_DATA:
-                       if (!bchannel->b_txdata)
-                       {
-                               /* if tx is off, it may happen that fifos send us pending informations, we just ignore them */
-                               CDEBUG(NULL, NULL, "ignoring tx data, because 'txdata' is turned off\n");
-                               return;
-                       }
-                       break;
-
-                       default:
-#if 0
-                       chan_trace_header(p_m_mISDNport, this, "BCHANNEL signal", DIRECTION_IN);
-                       add_trace("unknown", NULL, "0x%x", frm->dinfo);
-                       end_trace();
-#else
-                       ;
-#endif
-               }
-               return;
-       }
-#endif
        if (prim != PH_DATA_IND && prim != DL_DATA_IND)
        {
                CERROR(NULL, NULL, "Bchannel received unknown primitve: 0x%lx\n", prim);
        if (prim != PH_DATA_IND && prim != DL_DATA_IND)
        {
                CERROR(NULL, NULL, "Bchannel received unknown primitve: 0x%lx\n", prim);
@@ -592,11 +350,16 @@ static void bchannel_receive(struct bchannel *bchannel, unsigned long prim, unsi
                /* return, because we have no audio from port */
                return;
        }
                /* return, because we have no audio from port */
                return;
        }
-       len = write(bchannel->call->pipe[1], data, len);
-       if (len < 0)
+       if (bchannel->call->pipe[1] > -1)
        {
        {
-               CDEBUG(NULL, NULL, "broken pipe on bchannel pipe\n");
-               return;
+               len = write(bchannel->call->pipe[1], data, len);
+               if (len < 0)
+               {
+                       close(bchannel->call->pipe[1]);
+                       bchannel->call->pipe[1] = -1;
+                       CDEBUG(NULL, NULL, "broken pipe on bchannel pipe\n");
+                       return;
+               }
        }
 }
 
        }
 }
 
@@ -606,30 +369,22 @@ static void bchannel_receive(struct bchannel *bchannel, unsigned long prim, unsi
  */
 void bchannel_transmit(struct bchannel *bchannel, unsigned char *data, int len)
 {
  */
 void bchannel_transmit(struct bchannel *bchannel, unsigned char *data, int len)
 {
-       unsigned char buff[1025];
-#ifdef SOCKET_MISDN
+       unsigned char buff[1024 + MISDN_HEADER_LEN], *p = buff + MISDN_HEADER_LEN;
        struct mISDNhead *frm = (struct mISDNhead *)buff;
        struct mISDNhead *frm = (struct mISDNhead *)buff;
-#else
-       iframe_t *frm = (iframe_t *)buff;
-#endif
        int ret;
        int ret;
+       int i;
 
        if (bchannel->b_state != BSTATE_ACTIVE)
                return;
 
        if (bchannel->b_state != BSTATE_ACTIVE)
                return;
-#ifdef SOCKET_MISDN
+       if (len > 1024 || len < 1)
+               return;
+       for (i = 0; i < len; i++)
+               *p++ = flip_bits[*data++];
        frm->prim = DL_DATA_REQ;
        frm->id = 0;
        frm->prim = DL_DATA_REQ;
        frm->id = 0;
-       ret = sendto(bchannel->b_sock, data, len, 0, NULL, 0);
-       if (!ret)
+       ret = sendto(bchannel->b_sock, buff, MISDN_HEADER_LEN+len, 0, NULL, 0);
+       if (ret < 0)
                CERROR(NULL, NULL, "Failed to send to socket %d\n", bchannel->b_sock);
                CERROR(NULL, NULL, "Failed to send to socket %d\n", bchannel->b_sock);
-#else
-       frm->prim = DL_DATA | REQUEST; 
-       frm->addr = bchannel->b_addr | FLG_MSG_DOWN;
-       frm->dinfo = 0;
-       frm->len = len;
-       if (frm->len)
-               mISDN_write(bchannel_device, frm, mISDN_HEADER_LEN+frm->len, TIMEOUT_1SEC);
-#endif
 }
 
 
 }
 
 
@@ -638,15 +393,9 @@ void bchannel_transmit(struct bchannel *bchannel, unsigned char *data, int len)
  */
 void bchannel_join(struct bchannel *bchannel, unsigned short id)
 {
  */
 void bchannel_join(struct bchannel *bchannel, unsigned short id)
 {
-#ifdef SOCKET_MISDN
        int handle;
 
        handle = bchannel->b_sock;
        int handle;
 
        handle = bchannel->b_sock;
-#else
-       unsigned long handle;
-
-       handle = bchannel->b_addr;
-#endif
        if (id) {
                bchannel->b_conf = (id<<16) + bchannel_pid;
                bchannel->b_rxoff = 1;
        if (id) {
                bchannel->b_conf = (id<<16) + bchannel_pid;
                bchannel->b_rxoff = 1;
@@ -665,7 +414,6 @@ void bchannel_join(struct bchannel *bchannel, unsigned short id)
 /*
  * main loop for processing messages from mISDN
  */
 /*
  * main loop for processing messages from mISDN
  */
-#ifdef SOCKET_MISDN
 int bchannel_handle(void)
 {
        int ret, work = 0;
 int bchannel_handle(void)
 {
        int ret, work = 0;
@@ -681,7 +429,7 @@ int bchannel_handle(void)
                if (bchannel->b_sock > -1)
                {
                        ret = recv(bchannel->b_sock, buffer, sizeof(buffer), 0);
                if (bchannel->b_sock > -1)
                {
                        ret = recv(bchannel->b_sock, buffer, sizeof(buffer), 0);
-                       if (ret >= MISDN_HEADER_LEN)
+                       if (ret >= (int)MISDN_HEADER_LEN)
                        {
                                work = 1;
                                switch(hh->prim)
                        {
                                work = 1;
                                switch(hh->prim)
@@ -729,99 +477,6 @@ int bchannel_handle(void)
        /* if we received at least one b-frame, we will return 1 */
        return(work);
 }
        /* if we received at least one b-frame, we will return 1 */
        return(work);
 }
-#else
-int bchannel_handle(void)
-{
-       struct bchannel *bchannel;
-       iframe_t *frm;
-       unsigned char buffer[2048];
-       int len;
-
-       /* no device, no read */
-       if (bchannel_device < 0)
-               return(0);
-
-       /* get message from kernel */
-       len = mISDN_read(bchannel_device, buffer, sizeof(buffer), 0);
-       if (len < 0)
-       {
-               if (errno == EAGAIN)
-                       return(0);
-               CERROR(NULL, NULL, "Failed to do mISDN_read()\n");
-               return(0);
-       }
-       if (!len)
-       {
-//             printf("%s: ERROR: mISDN_read() returns nothing\n");
-               return(0);
-       }
-       frm = (iframe_t *)buffer;
-
-       /* global prim */
-       switch(frm->prim)
-       {
-               case MGR_DELLAYER | CONFIRM:
-               case MGR_INITTIMER | CONFIRM:
-               case MGR_ADDTIMER | CONFIRM:
-               case MGR_DELTIMER | CONFIRM:
-               case MGR_REMOVETIMER | CONFIRM:
-               return(1);
-       }
-
-       /* find the mISDNport that belongs to the stack */
-       bchannel = bchannel_first;
-       while(bchannel)
-       {
-               if (frm->addr == bchannel->b_addr)
-                       break;
-               bchannel = bchannel->next;
-       } 
-       if (!bchannel)
-       {
-               CERROR(NULL, NULL, "message belongs to no bchannel: prim(0x%x) addr(0x%x) msg->len(%d)\n", frm->prim, frm->addr, len);
-               goto out;
-       }
-
-       /* b-message */
-       switch(frm->prim)
-       {
-               /* we don't care about confirms, we use rx data to sync tx */
-               case PH_DATA | CONFIRM:
-               case DL_DATA | CONFIRM:
-               break;
-
-               /* we receive audio data, we respond to it AND we send tones */
-               case PH_DATA | INDICATION:
-               case DL_DATA | INDICATION:
-               case PH_CONTROL | INDICATION:
-               case PH_SIGNAL | INDICATION:
-               bchannel_receive(bchannel, frm->prim, frm->dinfo, (unsigned char *)frm->data.p, frm->len);
-               break;
-
-               case PH_ACTIVATE | INDICATION:
-               case DL_ESTABLISH | INDICATION:
-               case PH_ACTIVATE | CONFIRM:
-               case DL_ESTABLISH | CONFIRM:
-               CDEBUG(NULL, NULL, "DL_ESTABLISH confirm: bchannel is now activated (address 0x%x).\n", frm->addr);
-               bchannel_activated(bchannel);
-               break;
-
-               case PH_DEACTIVATE | INDICATION:
-               case DL_RELEASE | INDICATION:
-               case PH_DEACTIVATE | CONFIRM:
-               case DL_RELEASE | CONFIRM:
-               CDEBUG(NULL, NULL, "DL_RELEASE confirm: bchannel is now de-activated (address 0x%x).\n", frm->addr);
-//             bchannel_deactivated(bchannel);
-               break;
-
-               default:
-               CERROR(NULL, NULL, "message not handled: prim(0x%x) addr(0x%x) msg->len(%d)\n", frm->prim, frm->addr, len);
-       }
-
-       out:
-       return(1);
-}
-#endif
 
 
 /*
 
 
 /*
@@ -863,7 +518,7 @@ struct bchannel *alloc_bchannel(unsigned long handle)
        while(*bchannelp)
                bchannelp = &((*bchannelp)->next);
 
        while(*bchannelp)
                bchannelp = &((*bchannelp)->next);
 
-       *bchannelp = (struct bchannel *)malloc(sizeof(struct bchannel));
+       *bchannelp = (struct bchannel *)calloc(1, sizeof(struct bchannel));
        if (!*bchannelp)
                return(NULL);
        (*bchannelp)->handle = handle;
        if (!*bchannelp)
                return(NULL);
        (*bchannelp)->handle = handle;
@@ -881,11 +536,7 @@ void free_bchannel(struct bchannel *bchannel)
                if (*temp == bchannel)
                {
                        *temp = (*temp)->next;
                if (*temp == bchannel)
                {
                        *temp = (*temp)->next;
-#ifdef SOCKET_MISDN
                        if (bchannel->b_sock > -1)
                        if (bchannel->b_sock > -1)
-#else
-                       if (bchannel->b_stid)
-#endif
                                bchannel_destroy(bchannel);
                        if (bchannel->call)
                        {
                                bchannel_destroy(bchannel);
                        if (bchannel->call)
                        {
index 9511afe..b3d950d 100644 (file)
@@ -14,12 +14,7 @@ struct bchannel {
        struct bchannel *next;
        struct chan_call *call;         /* link to call process */
        unsigned long handle;           /* handle for stack id */
        struct bchannel *next;
        struct chan_call *call;         /* link to call process */
        unsigned long handle;           /* handle for stack id */
-#ifdef SOCKET_MISDN
        int b_sock;                     /* socket for b-channel */
        int b_sock;                     /* socket for b-channel */
-#else
-       unsigned long b_stid;           /* stack id */
-       unsigned long b_addr;           /* channel address */
-#endif
        int b_state;
        int b_txdata;
        int b_delay;
        int b_state;
        int b_txdata;
        int b_delay;
index 47b51da..7d13f16 100644 (file)
@@ -9,19 +9,23 @@
 **                                                                           **
 \*****************************************************************************/ 
 
 **                                                                           **
 \*****************************************************************************/ 
 
-#include "main.h"
+#include <string.h>
+#include <time.h>
+#include "extension.h"
+#include "message.h"
+#include "callerid.h"
 
 /* create caller id from digits by comparing with national and international
  * prefixes.
  */
 char *nationalize_callerinfo(char *string, int *ntype, char *national, char *international)
 {
 
 /* create caller id from digits by comparing with national and international
  * prefixes.
  */
 char *nationalize_callerinfo(char *string, int *ntype, char *national, char *international)
 {
-       if (!strncmp(options.international, string, strlen(options.international)))
+       if (!strncmp(international, string, strlen(international)))
        {
                *ntype = INFO_NTYPE_INTERNATIONAL;
                return(string+strlen(international)); 
        }
        {
                *ntype = INFO_NTYPE_INTERNATIONAL;
                return(string+strlen(international)); 
        }
-       if (!strncmp(options.national, string, strlen(options.national)))
+       if (!strncmp(national, string, strlen(national)))
        {
                *ntype = INFO_NTYPE_NATIONAL;
                return(string+strlen(national)); 
        {
                *ntype = INFO_NTYPE_NATIONAL;
                return(string+strlen(national)); 
@@ -40,14 +44,16 @@ char *numberrize_callerinfo(char *string, int ntype, char *national, char *inter
        switch(ntype)
        {
                case INFO_NTYPE_INTERNATIONAL:
        switch(ntype)
        {
                case INFO_NTYPE_INTERNATIONAL:
-               UCPY(result, international);
-               SCAT(result, string);
+               strcpy(result, international);
+               strncat(result, string, sizeof(result));
+               result[sizeof(result)-1] = '\0';
                return(result);
                break;
 
                case INFO_NTYPE_NATIONAL:
                return(result);
                break;
 
                case INFO_NTYPE_NATIONAL:
-               UCPY(result, national);
-               SCAT(result, string);
+               strcpy(result, national);
+               strncat(result, string, sizeof(result));
+               result[sizeof(result)-1] = '\0';
                return(result);
                break;
 
                return(result);
                break;
 
diff --git a/cause.c b/cause.c
index 46b870b..c021f21 100644 (file)
--- a/cause.c
+++ b/cause.c
@@ -9,7 +9,13 @@
 **                                                                           **
 \*****************************************************************************/ 
 
 **                                                                           **
 \*****************************************************************************/ 
 
-#include "main.h"
+#include <stdio.h>
+#include <stdarg.h>
+#include <string.h>
+#include <stdlib.h>
+#include "macro.h"
+#include "cause.h"
+#include "extension.h"
 
 struct isdn_cause isdn_cause[128] = {
                        /********************************* - **/ /*38*/
 
 struct isdn_cause isdn_cause[128] = {
                        /********************************* - **/ /*38*/
index fa37ef6..2a26a7f 100644 (file)
@@ -86,6 +86,7 @@ If the ref is 0 and the state is CHAN_LCR_STATE_RELEASE, see the proceedure
 #include <errno.h>
 #include <sys/types.h>
 #include <time.h>
 #include <errno.h>
 #include <sys/types.h>
 #include <time.h>
+//#include <signal.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/ioctl.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/ioctl.h>
@@ -116,15 +117,16 @@ If the ref is 0 and the state is CHAN_LCR_STATE_RELEASE, see the proceedure
 
 #include "extension.h"
 #include "message.h"
 
 #include "extension.h"
 #include "message.h"
+#include "callerid.h"
 #include "lcrsocket.h"
 #include "cause.h"
 #include "bchannel.h"
 #include "chan_lcr.h"
 #include "lcrsocket.h"
 #include "cause.h"
 #include "bchannel.h"
 #include "chan_lcr.h"
-#include "callerid.h"
 
 CHAN_LCR_STATE // state description structure
 
 CHAN_LCR_STATE // state description structure
+MESSAGES // message text
 
 
-u_char flip_bits[256];
+unsigned char flip_bits[256];
 
 int lcr_debug=1;
 int mISDN_created=1;
 
 int lcr_debug=1;
 int mISDN_created=1;
@@ -142,7 +144,7 @@ int lcr_sock = -1;
 
 struct admin_list {
        struct admin_list *next;
 
 struct admin_list {
        struct admin_list *next;
-       struct admin_msg msg;
+       struct admin_message msg;
 } *admin_first = NULL;
 
 static struct ast_channel_tech lcr_tech;
 } *admin_first = NULL;
 
 static struct ast_channel_tech lcr_tech;
@@ -150,7 +152,7 @@ static struct ast_channel_tech lcr_tech;
 /*
  * logging
  */
 /*
  * logging
  */
-void chan_lcr_log(int type, const char *file, int line, struct chan_call *call, struct ast_channel *ast, const char *fmt, ...)
+void chan_lcr_log(int type, const char *file, int line, const char *function, struct chan_call *call, struct ast_channel *ast, const char *fmt, ...)
 {
        char buffer[1024];
        char call_text[128] = "NULL";
 {
        char buffer[1024];
        char call_text[128] = "NULL";
@@ -170,7 +172,7 @@ void chan_lcr_log(int type, const char *file, int line, struct chan_call *call,
                strncpy(ast_text, ast->name, sizeof(ast_text)-1);
        ast_text[sizeof(ast_text)-1] = '\0';
        
                strncpy(ast_text, ast->name, sizeof(ast_text)-1);
        ast_text[sizeof(ast_text)-1] = '\0';
        
-       ast_log(type, file, line, "[call=%s ast=%s] %s", call_text, ast_text, buffer);
+       ast_log(type, file, line, function, "[call=%s ast=%s] %s", call_text, ast_text, buffer);
 
        ast_mutex_unlock(&log_lock);
 }
 
        ast_mutex_unlock(&log_lock);
 }
@@ -230,9 +232,9 @@ void free_call(struct chan_call *call)
                if (*temp == call)
                {
                        *temp = (*temp)->next;
                if (*temp == call)
                {
                        *temp = (*temp)->next;
-                       if (call->pipe[0])
+                       if (call->pipe[0] > -1)
                                close(call->pipe[0]);
                                close(call->pipe[0]);
-                       if (call->pipe[1])
+                       if (call->pipe[1] > -1)
                                close(call->pipe[1]);
                        if (call->bchannel)
                        {
                                close(call->pipe[1]);
                        if (call->bchannel)
                        {
@@ -262,7 +264,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 *)calloc(1, sizeof(struct chan_call));
        if (*callp)
                memset(*callp, 0, sizeof(struct chan_call));
        if (pipe((*callp)->pipe) < 0) {
        if (*callp)
                memset(*callp, 0, sizeof(struct chan_call));
        if (pipe((*callp)->pipe) < 0) {
@@ -310,17 +312,22 @@ int send_message(int message_type, unsigned long ref, union parameter *param)
                CDEBUG(NULL, NULL, "Ignoring message %d, because socket is closed.\n", message_type);
                return -1;
        }
                CDEBUG(NULL, NULL, "Ignoring message %d, because socket is closed.\n", message_type);
                return -1;
        }
-       CDEBUG(NULL, NULL, "Sending message %d to socket.\n", message_type);
+       CDEBUG(NULL, NULL, "Sending %s to socket.\n", messages_txt[message_type]);
 
        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 *)calloc(1, sizeof(struct admin_list));
+       if (!admin) {
+               CERROR(NULL, NULL, "No memory for message to LCR.\n");
+               return -1;
+       }
        *adminp = admin;
 
        *adminp = admin;
 
-       admin->msg.type = message_type;
-       admin->msg.ref = ref;
-       memcpy(&admin->msg.param, param, sizeof(union parameter));
+       admin->msg.message = ADMIN_MESSAGE;
+       admin->msg.u.msg.type = message_type;
+       admin->msg.u.msg.ref = ref;
+       memcpy(&admin->msg.u.msg.param, param, sizeof(union parameter));
 
        return(0);
 }
 
        return(0);
 }
@@ -341,8 +348,9 @@ static void send_setup_to_lcr(struct chan_call *call)
 
        /* send setup message to LCR */
        memset(&newparam, 0, sizeof(union parameter));
 
        /* send setup message to LCR */
        memset(&newparam, 0, sizeof(union parameter));
+       strncpy(newparam.setup.dialinginfo.id, ast->exten, sizeof(newparam.setup.dialinginfo.id)-1);
                newparam.setup.callerinfo.itype = INFO_ITYPE_CHAN;      
                newparam.setup.callerinfo.itype = INFO_ITYPE_CHAN;      
-               newparam.setup.callerinfo.ntype = INFO_NTYPE_UNKNOWN;   
+               newparam.setup.callerinfo.ntype = INFO_NTYPE_UNKNOWN;
        if (ast->cid.cid_num) if (ast->cid.cid_num[0])
                strncpy(newparam.setup.callerinfo.id, ast->cid.cid_num, sizeof(newparam.setup.callerinfo.id)-1);
        if (ast->cid.cid_name) if (ast->cid.cid_name[0])
        if (ast->cid.cid_num) if (ast->cid.cid_num[0])
                strncpy(newparam.setup.callerinfo.id, ast->cid.cid_num, sizeof(newparam.setup.callerinfo.id)-1);
        if (ast->cid.cid_name) if (ast->cid.cid_name[0])
@@ -404,10 +412,10 @@ static void send_dialque_to_lcr(struct chan_call *call)
 {
        union parameter newparam;
 
 {
        union parameter newparam;
 
-       if (!call->ast || !call->ref || !call->dialque)
+       if (!call->ast || !call->ref || !call->dialque[0])
                return;
        
                return;
        
-       CDEBUG(call, call->ast, "Sending dial queue to LCR.\n");
+       CDEBUG(call, call->ast, "Sending dial queue to LCR. (dialing=%s)\n", call->dialque);
 
        /* send setup message to LCR */
        memset(&newparam, 0, sizeof(union parameter));
 
        /* send setup message to LCR */
        memset(&newparam, 0, sizeof(union parameter));
@@ -430,6 +438,27 @@ static void bridge_message_if_bridged(struct chan_call *call, int message_type,
 }
 
 /*
 }
 
 /*
+ * send release message to LCR and import bchannel if exported
+ */
+static void send_release_and_import(struct chan_call *call, int cause, int location)
+{
+       union parameter newparam;
+
+       /* importing channel */
+       if (call->bchannel && call->bchannel->handle) {
+               memset(&newparam, 0, sizeof(union parameter));
+               newparam.bchannel.type = BCHANNEL_RELEASE;
+               newparam.bchannel.handle = call->bchannel->handle;
+               send_message(MESSAGE_BCHANNEL, call->ref, &newparam);
+       }
+       /* sending release */
+       memset(&newparam, 0, sizeof(union parameter));
+       newparam.disconnectinfo.cause = cause;
+       newparam.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
+       send_message(MESSAGE_RELEASE, call->ref, &newparam);
+}
+
+/*
  * check if extension matches and start asterisk
  * if it can match, proceed
  * if not, release
  * check if extension matches and start asterisk
  * if it can match, proceed
  * if not, release
@@ -439,6 +468,8 @@ static void lcr_start_pbx(struct chan_call *call, struct ast_channel *ast, int c
        int cause, ret;
        union parameter newparam;
 
        int cause, ret;
        union parameter newparam;
 
+       CDEBUG(call, ast, "Try to start pbx. (exten=%s context=%s complete=%s)\n", ast->exten, ast->context, complete?"yes":"no");
+       
        if (complete)
        {
                /* if not match */
        if (complete)
        {
                /* if not match */
@@ -468,8 +499,10 @@ static void lcr_start_pbx(struct chan_call *call, struct ast_channel *ast, int c
        if (ast_canmatch_extension(ast, ast->context, ast->exten, 1, call->oad))
        {
                /* send setup acknowledge to lcr */
        if (ast_canmatch_extension(ast, ast->context, ast->exten, 1, call->oad))
        {
                /* send setup acknowledge to lcr */
-               memset(&newparam, 0, sizeof(union parameter));
-               send_message(MESSAGE_OVERLAP, call->ref, &newparam);
+               if (call->state != CHAN_LCR_STATE_IN_DIALING) {
+                       memset(&newparam, 0, sizeof(union parameter));
+                       send_message(MESSAGE_OVERLAP, call->ref, &newparam);
+               }
 
                /* change state */
                call->state = CHAN_LCR_STATE_IN_DIALING;
 
                /* change state */
                call->state = CHAN_LCR_STATE_IN_DIALING;
@@ -490,10 +523,7 @@ static void lcr_start_pbx(struct chan_call *call, struct ast_channel *ast, int c
        release:
        /* release lcr */
        CDEBUG(call, ast, "Releasing due to extension missmatch.\n");
        release:
        /* release lcr */
        CDEBUG(call, ast, "Releasing due to extension missmatch.\n");
-       memset(&newparam, 0, sizeof(union parameter));
-       newparam.disconnectinfo.cause = cause;
-       newparam.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
-       send_message(MESSAGE_RELEASE, call->ref, &newparam);
+       send_release_and_import(call, cause, LOCATION_PRIVATE_LOCAL);
        call->ref = 0;
        /* release asterisk */
        ast->hangupcause = call->cause;
        call->ref = 0;
        /* release asterisk */
        ast->hangupcause = call->cause;
@@ -521,9 +551,8 @@ static void lcr_start_pbx(struct chan_call *call, struct ast_channel *ast, int c
 static void lcr_in_setup(struct chan_call *call, int message_type, union parameter *param)
 {
        struct ast_channel *ast;
 static void lcr_in_setup(struct chan_call *call, int message_type, union parameter *param)
 {
        struct ast_channel *ast;
-       union parameter newparam;
 
 
-       CDEBUG(call, NULL, "Incomming setup from LCR. (callerid %d, dialing %d)\n", param->setup.callerinfo.id, param->setup.dialinginfo.id);
+       CDEBUG(call, NULL, "Incomming setup from LCR. (callerid %s, dialing %s)\n", param->setup.callerinfo.id, param->setup.dialinginfo.id);
 
        /* create asterisk channel instrance */
        ast = ast_channel_alloc(1, AST_STATE_RESERVED, NULL, NULL, "", NULL, "", 0, "%s/%d", lcr_type, ++glob_channel);
 
        /* create asterisk channel instrance */
        ast = ast_channel_alloc(1, AST_STATE_RESERVED, NULL, NULL, "", NULL, "", 0, "%s/%d", lcr_type, ++glob_channel);
@@ -531,15 +560,12 @@ static void lcr_in_setup(struct chan_call *call, int message_type, union paramet
        {
                /* release */
                CERROR(call, NULL, "Failed to create Asterisk channel - releasing.\n");
        {
                /* release */
                CERROR(call, NULL, "Failed to create Asterisk channel - releasing.\n");
-               memset(&newparam, 0, sizeof(union parameter));
-               newparam.disconnectinfo.cause = CAUSE_RESSOURCEUNAVAIL;
-               newparam.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
-               send_message(MESSAGE_RELEASE, call->ref, &newparam);
+               send_release_and_import(call, CAUSE_RESSOURCEUNAVAIL, LOCATION_PRIVATE_LOCAL);
                /* remove call */
                free_call(call);
                return;
        }
                /* remove call */
                free_call(call);
                return;
        }
-       /* set ast pointer */
+       /* link together */
        call->ast = ast;
        ast->tech_pvt = call;
        ast->tech = &lcr_tech;
        call->ast = ast;
        ast->tech_pvt = call;
        ast->tech = &lcr_tech;
@@ -550,6 +576,8 @@ static void lcr_in_setup(struct chan_call *call, int message_type, union paramet
                strncpy(ast->exten, param->setup.dialinginfo.id, AST_MAX_EXTENSION-1);
        if (param->setup.context[0])
                strncpy(ast->context, param->setup.context, AST_MAX_CONTEXT-1);
                strncpy(ast->exten, param->setup.dialinginfo.id, AST_MAX_EXTENSION-1);
        if (param->setup.context[0])
                strncpy(ast->context, param->setup.context, AST_MAX_CONTEXT-1);
+       else
+               strncpy(ast->context, param->setup.callerinfo.interface, AST_MAX_CONTEXT-1);
        if (param->setup.callerinfo.id[0])
                ast->cid.cid_num = strdup(param->setup.callerinfo.id);
        if (param->setup.callerinfo.name[0])
        if (param->setup.callerinfo.id[0])
                ast->cid.cid_num = strdup(param->setup.callerinfo.id);
        if (param->setup.callerinfo.name[0])
@@ -600,6 +628,7 @@ static void lcr_in_setup(struct chan_call *call, int message_type, union paramet
        ast->readformat = ast->rawreadformat = AST_FORMAT_ALAW;
        ast->writeformat = ast->rawwriteformat = AST_FORMAT_ALAW;
 #endif
        ast->readformat = ast->rawreadformat = AST_FORMAT_ALAW;
        ast->writeformat = ast->rawwriteformat = AST_FORMAT_ALAW;
 #endif
+       ast->priority = 1;
        ast->hangupcause = 0;
 
        /* change state */
        ast->hangupcause = 0;
 
        /* change state */
@@ -618,7 +647,7 @@ static void lcr_in_overlap(struct chan_call *call, int message_type, union param
        CDEBUG(call, call->ast, "Incomming setup acknowledge from LCR.\n");
 
        /* send pending digits in dialque */
        CDEBUG(call, call->ast, "Incomming setup acknowledge from LCR.\n");
 
        /* send pending digits in dialque */
-       if (call->dialque)
+       if (call->dialque[0])
                send_dialque_to_lcr(call);
        /* change to overlap state */
        call->state = CHAN_LCR_STATE_OUT_DIALING;
                send_dialque_to_lcr(call);
        /* change to overlap state */
        call->state = CHAN_LCR_STATE_OUT_DIALING;
@@ -657,10 +686,19 @@ static void lcr_in_alerting(struct chan_call *call, int message_type, union para
  */
 static void lcr_in_connect(struct chan_call *call, int message_type, union parameter *param)
 {
  */
 static void lcr_in_connect(struct chan_call *call, int message_type, union parameter *param)
 {
+       union parameter newparam;
+
        CDEBUG(call, call->ast, "Incomming connect (answer) from LCR.\n");
 
        /* change state */
        call->state = CHAN_LCR_STATE_CONNECT;
        CDEBUG(call, call->ast, "Incomming connect (answer) from LCR.\n");
 
        /* change state */
        call->state = CHAN_LCR_STATE_CONNECT;
+       /* request bchannel */
+       if (!call->bchannel) {
+               CDEBUG(call, call->ast, "Requesting B-channel.\n");
+               memset(&newparam, 0, sizeof(union parameter));
+               newparam.bchannel.type = BCHANNEL_REQUEST;
+               send_message(MESSAGE_BCHANNEL, call->ref, &newparam);
+       }
        /* copy connectinfo */
        memcpy(&call->connectinfo, &param->connectinfo, sizeof(struct connect_info));
        /* send event to asterisk */
        /* copy connectinfo */
        memcpy(&call->connectinfo, &param->connectinfo, sizeof(struct connect_info));
        /* send event to asterisk */
@@ -693,7 +731,7 @@ static void lcr_in_disconnect(struct chan_call *call, int message_type, union pa
        }
 #endif
        /* release lcr with same cause */
        }
 #endif
        /* release lcr with same cause */
-       send_message(MESSAGE_RELEASE, call->ref, param);
+       send_release_and_import(call, call->cause, call->location);
        call->ref = 0;
        /* change to release state */
        call->state = CHAN_LCR_STATE_RELEASE;
        call->ref = 0;
        /* change to release state */
        call->state = CHAN_LCR_STATE_RELEASE;
@@ -716,7 +754,7 @@ static void lcr_in_release(struct chan_call *call, int message_type, union param
 {
        struct ast_channel *ast = call->ast;
 
 {
        struct ast_channel *ast = call->ast;
 
-       CDEBUG(call, call->ast, "Incomming release from LCR. (cause=%d)\n", param->disconnectinfo.cause);
+       CDEBUG(call, call->ast, "Incomming release from LCR, releasing ref. (cause=%d)\n", param->disconnectinfo.cause);
 
        /* release ref */
        call->ref = 0;
 
        /* release ref */
        call->ref = 0;
@@ -753,7 +791,7 @@ static void lcr_in_information(struct chan_call *call, int message_type, union p
        struct ast_frame fr;
        char *p;
 
        struct ast_frame fr;
        char *p;
 
-       CDEBUG(call, call->ast, "Incomming information from LCR. (dialing=%d)\n", param->information.id);
+       CDEBUG(call, call->ast, "Incoming information from LCR. (dialing=%s)\n", param->information.id);
        
        if (!ast) return;
 
        
        if (!ast) return;
 
@@ -913,7 +951,7 @@ hier muesen alle bchannel-features gesetzt werden (pipeline...) falls sie vor de
                if (param->direction)
                {
                        /* new ref from lcr */
                if (param->direction)
                {
                        /* new ref from lcr */
-                       CDEBUG(NULL, NULL, "Received new ref by LCR, of call from LCR. (ref=%ld)\n", ref);
+                       CDEBUG(NULL, NULL, "Received new ref by LCR, due to incomming call. (ref=%ld)\n", ref);
                        if (!ref || find_call_ref(ref))
                        {
                                CERROR(NULL, NULL, "Illegal new ref %ld received.\n", ref);
                        if (!ref || find_call_ref(ref))
                        {
                                CERROR(NULL, NULL, "Illegal new ref %ld received.\n", ref);
@@ -935,9 +973,7 @@ hier muesen alle bchannel-features gesetzt werden (pipeline...) falls sie vor de
                        {
                                /* send release, if ref does not exist */
                                CDEBUG(NULL, NULL, "No call found, that requests a ref.\n");
                        {
                                /* send release, if ref does not exist */
                                CDEBUG(NULL, NULL, "No call found, that requests a ref.\n");
-                               newparam.disconnectinfo.cause = CAUSE_NORMAL;
-                               newparam.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
-                               send_message(MESSAGE_RELEASE, ref, &newparam);
+                               send_release_and_import(call, CAUSE_NORMAL, LOCATION_PRIVATE_LOCAL);
                                return(0);
                        }
                        /* store new ref */
                                return(0);
                        }
                        /* store new ref */
@@ -950,15 +986,9 @@ hier muesen alle bchannel-features gesetzt werden (pipeline...) falls sie vor de
                        {
                                /* send release */
                                if (call->cause)
                        {
                                /* send release */
                                if (call->cause)
-                               {
-                                       newparam.disconnectinfo.cause = call->cause;
-                                       newparam.disconnectinfo.location = call->location;
-                               } else
-                               {
-                                       newparam.disconnectinfo.cause = 16;
-                                       newparam.disconnectinfo.location = 5;
-                               }
-                               send_message(MESSAGE_RELEASE, ref, &newparam);
+                                       send_release_and_import(call, call->cause, call->location);
+                               else
+                                       send_release_and_import(call, CAUSE_NORMAL, LOCATION_PRIVATE_LOCAL);
                                /* free call */
                                free_call(call);
                                return(0);
                                /* free call */
                                free_call(call);
                                return(0);
@@ -1050,8 +1080,7 @@ static void release_all_calls(void)
 
 again:
        call = call_first;
 
 again:
        call = call_first;
-       while(call)
-       {
+       while(call) {
                /* no ast, so we may directly free call */
                if (!call->ast) {
                        CDEBUG(call, NULL, "Freeing call, because no Asterisk channel is linked.\n");
                /* no ast, so we may directly free call */
                if (!call->ast) {
                        CDEBUG(call, NULL, "Freeing call, because no Asterisk channel is linked.\n");
@@ -1066,8 +1095,7 @@ again:
                /* release or queue release */
                call->ref = 0;
                call->state = CHAN_LCR_STATE_RELEASE;
                /* release or queue release */
                call->ref = 0;
                call->state = CHAN_LCR_STATE_RELEASE;
-               if (!call->pbx_started)
-               {
+               if (!call->pbx_started) {
                        CDEBUG(call, call->ast, "Releasing call, because no Asterisk channel is not started.\n");
                        ast_hangup(call->ast); // call will be destroyed here
                        goto again;
                        CDEBUG(call, call->ast, "Releasing call, because no Asterisk channel is not started.\n");
                        ast_hangup(call->ast); // call will be destroyed here
                        goto again;
@@ -1076,6 +1104,10 @@ again:
                ast_queue_hangup(call->ast);
                call = call->next;
        }
                ast_queue_hangup(call->ast);
                call = call->next;
        }
+
+       /* release all bchannels */
+       while(bchannel_first)
+               free_bchannel(bchannel_first);
 }
 
 
 }
 
 
@@ -1087,13 +1119,11 @@ int handle_socket(void)
 {
        int work = 0;
        int len;
 {
        int work = 0;
        int len;
-       struct admin_message msg;
        struct admin_list *admin;
        struct admin_list *admin;
-
-       int sock;
+       struct admin_message msg;
 
        /* read from socket */
 
        /* read from socket */
-       len = read(sock, &msg, sizeof(msg));
+       len = read(lcr_sock, &msg, sizeof(msg));
        if (len == 0)
        {
                CERROR(NULL, NULL, "Socket closed.\n");
        if (len == 0)
        {
                CERROR(NULL, NULL, "Socket closed.\n");
@@ -1109,7 +1139,7 @@ int handle_socket(void)
                if (msg.message != ADMIN_MESSAGE)
                {
                        CERROR(NULL, NULL, "Socket received illegal message %d.\n", msg.message);
                if (msg.message != ADMIN_MESSAGE)
                {
                        CERROR(NULL, NULL, "Socket received illegal message %d.\n", msg.message);
-                       return(-1); // socket error
+                       return(-1);
                }
                receive_message(msg.u.msg.type, msg.u.msg.ref, &msg.u.msg.param);
                work = 1;
                }
                receive_message(msg.u.msg.type, msg.u.msg.ref, &msg.u.msg.param);
                work = 1;
@@ -1126,7 +1156,7 @@ int handle_socket(void)
        if (!admin_first)
                return(work);
        admin = admin_first;
        if (!admin_first)
                return(work);
        admin = admin_first;
-       len = write(sock, &admin->msg, sizeof(msg));
+       len = write(lcr_sock, &admin->msg, sizeof(msg));
        if (len == 0)
        {
                CERROR(NULL, NULL, "Socket closed.\n");
        if (len == 0)
        {
                CERROR(NULL, NULL, "Socket closed.\n");
@@ -1162,7 +1192,6 @@ int handle_socket(void)
 int open_socket(void)
 {
        int ret;
 int open_socket(void)
 {
        int ret;
-       int sock;
        char *socket_name = SOCKET_NAME;
        int conn;
        struct sockaddr_un sock_address;
        char *socket_name = SOCKET_NAME;
        int conn;
        struct sockaddr_un sock_address;
@@ -1170,10 +1199,10 @@ int open_socket(void)
        union parameter param;
 
        /* open socket */
        union parameter param;
 
        /* open socket */
-       if ((sock = socket(PF_UNIX, SOCK_STREAM, 0)) < 0)
+       if ((lcr_sock = socket(PF_UNIX, SOCK_STREAM, 0)) < 0)
        {
                CERROR(NULL, NULL, "Failed to create socket.\n");
        {
                CERROR(NULL, NULL, "Failed to create socket.\n");
-               return(sock);
+               return(lcr_sock);
        }
 
        /* set socket address and name */
        }
 
        /* set socket address and name */
@@ -1182,17 +1211,19 @@ int open_socket(void)
        strcpy(sock_address.sun_path, socket_name);
 
        /* connect socket */
        strcpy(sock_address.sun_path, socket_name);
 
        /* connect socket */
-       if ((conn = connect(sock, (struct sockaddr *)&sock_address, SUN_LEN(&sock_address))) < 0)
+       if ((conn = connect(lcr_sock, (struct sockaddr *)&sock_address, SUN_LEN(&sock_address))) < 0)
        {
        {
-               close(sock);
-               CERROR(NULL, NULL, "Failed to connect to socket '%s'. Is LCR running?\n", sock_address.sun_path);
+               close(lcr_sock);
+               lcr_sock = -1;
+               CDEBUG(NULL, NULL, "Failed to connect to socket '%s'. Is LCR running?\n", sock_address.sun_path);
                return(conn);
        }
 
        /* set non-blocking io */
                return(conn);
        }
 
        /* set non-blocking io */
-       if ((ret = ioctl(sock, FIONBIO, (unsigned char *)(&on))) < 0)
+       if ((ret = ioctl(lcr_sock, FIONBIO, (unsigned char *)(&on))) < 0)
        {
        {
-               close(sock);
+               close(lcr_sock);
+               lcr_sock = -1;
                CERROR(NULL, NULL, "Failed to set socket into non-blocking IO.\n");
                return(ret);
        }
                CERROR(NULL, NULL, "Failed to set socket into non-blocking IO.\n");
                return(ret);
        }
@@ -1202,14 +1233,30 @@ int open_socket(void)
        strcpy(param.hello.application, "asterisk");
        send_message(MESSAGE_HELLO, 0, &param);
 
        strcpy(param.hello.application, "asterisk");
        send_message(MESSAGE_HELLO, 0, &param);
 
-       return(sock);
+       return(lcr_sock);
 }
 
 }
 
-void close_socket(int sock)
+void close_socket(void)
 {
 {
+       struct admin_list *admin, *temp;
+       
+       /* flush pending messages */
+       admin = admin_first;
+       while(admin) {
+               temp = admin;
+               admin = admin->next;
+               free(temp);
+       }
+       admin_first = NULL;
+
        /* close socket */
        /* close socket */
-       if (socket >= 0)        
-               close(sock);
+       if (lcr_sock >= 0)      
+               close(lcr_sock);
+       lcr_sock = -1;
+}
+
+void sighandler(int sigset)
+{
 }
 
 static void *chan_thread(void *arg)
 }
 
 static void *chan_thread(void *arg)
@@ -1220,9 +1267,11 @@ static void *chan_thread(void *arg)
        time_t retry = 0, now;
 
        bchannel_pid = getpid();
        time_t retry = 0, now;
 
        bchannel_pid = getpid();
+
+//     signal(SIGPIPE, sighandler);
        
        memset(&param, 0, sizeof(union parameter));
        
        memset(&param, 0, sizeof(union parameter));
-       if (lcr_sock > 0)
+       if (lcr_sock < 0)
                time(&retry);
 
        ast_mutex_lock(&chan_lock);
                time(&retry);
 
        ast_mutex_lock(&chan_lock);
@@ -1235,8 +1284,7 @@ static void *chan_thread(void *arg)
                        ret = handle_socket();
                        if (ret < 0) {
                                CERROR(NULL, NULL, "Handling of socket failed - closing for some seconds.\n");
                        ret = handle_socket();
                        if (ret < 0) {
                                CERROR(NULL, NULL, "Handling of socket failed - closing for some seconds.\n");
-                               close_socket(lcr_sock);
-                               lcr_sock = -1;
+                               close_socket();
                                release_all_calls();
                                time(&retry);
                        }
                                release_all_calls();
                                time(&retry);
                        }
@@ -1245,9 +1293,9 @@ static void *chan_thread(void *arg)
                } else {
                        time(&now);
                        if (retry && now-retry > 5) {
                } else {
                        time(&now);
                        if (retry && now-retry > 5) {
-                               CERROR(NULL, NULL, "Retry to open socket.\n");
+                               CDEBUG(NULL, NULL, "Retry to open socket.\n");
                                retry = 0;
                                retry = 0;
-                               if (!(lcr_sock = open_socket())) {
+                               if (open_socket() < 0) {
                                        time(&retry);
                                }
                                work = 1;
                                        time(&retry);
                                }
                                work = 1;
@@ -1267,10 +1315,14 @@ static void *chan_thread(void *arg)
                }
        }
 
                }
        }
 
+       close_socket();
+
        CERROR(NULL, NULL, "Thread exit.\n");
        
        ast_mutex_unlock(&chan_lock);
 
        CERROR(NULL, NULL, "Thread exit.\n");
        
        ast_mutex_unlock(&chan_lock);
 
+//     signal(SIGPIPE, SIG_DFL);
+
        return NULL;
 }
 
        return NULL;
 }
 
@@ -1312,9 +1364,10 @@ struct ast_channel *lcr_request(const char *type, int format, void *data, int *c
                return NULL;
        }
        /* link together */
                return NULL;
        }
        /* link together */
-       ast->tech_pvt = call;
        call->ast = ast;
        call->ast = ast;
+       ast->tech_pvt = call;
        ast->tech = &lcr_tech;
        ast->tech = &lcr_tech;
+       ast->fds[0] = call->pipe[0];
        /* configure channel */
 #ifdef TODO
        snprintf(ast->name, sizeof(ast->name), "%s/%d", lcr_type, ++glob_channel);
        /* configure channel */
 #ifdef TODO
        snprintf(ast->name, sizeof(ast->name), "%s/%d", lcr_type, ++glob_channel);
@@ -1329,6 +1382,7 @@ struct ast_channel *lcr_request(const char *type, int format, void *data, int *c
        ast->readformat = ast->rawreadformat = AST_FORMAT_ALAW;
        ast->writeformat = ast->rawwriteformat = AST_FORMAT_ALAW;
 #endif
        ast->readformat = ast->rawreadformat = AST_FORMAT_ALAW;
        ast->writeformat = ast->rawwriteformat = AST_FORMAT_ALAW;
 #endif
+       ast->priority = 1;
        ast->hangupcause = 0;
        /* send MESSAGE_NEWREF */
        memset(&newparam, 0, sizeof(union parameter));
        ast->hangupcause = 0;
        /* send MESSAGE_NEWREF */
        memset(&newparam, 0, sizeof(union parameter));
@@ -1359,6 +1413,7 @@ static int lcr_call(struct ast_channel *ast, char *dest, int timeout)
 
        CDEBUG(call, ast, "Received call from Asterisk.\n");
 
 
        CDEBUG(call, ast, "Received call from Asterisk.\n");
 
+#warning was passiert zwischen lcr_request und lcr_call ?
        call->pbx_started = 1;
 
        /* send setup message, if we already have a callref */
        call->pbx_started = 1;
 
        /* send setup message, if we already have a callref */
@@ -1435,6 +1490,13 @@ static int lcr_answer(struct ast_channel *ast)
        send_message(MESSAGE_CONNECT, call->ref, &newparam);
        /* change state */
        call->state = CHAN_LCR_STATE_CONNECT;
        send_message(MESSAGE_CONNECT, call->ref, &newparam);
        /* change state */
        call->state = CHAN_LCR_STATE_CONNECT;
+       /* request bchannel */
+       if (!call->bchannel) {
+               CDEBUG(call, ast, "Requesting B-channel.\n");
+               memset(&newparam, 0, sizeof(union parameter));
+               newparam.bchannel.type = BCHANNEL_REQUEST;
+               send_message(MESSAGE_BCHANNEL, call->ref, &newparam);
+       }
        
        ast_mutex_unlock(&chan_lock);
         return 0;
        
        ast_mutex_unlock(&chan_lock);
         return 0;
@@ -1442,7 +1504,6 @@ static int lcr_answer(struct ast_channel *ast)
 
 static int lcr_hangup(struct ast_channel *ast)
 {
 
 static int lcr_hangup(struct ast_channel *ast)
 {
-       union parameter newparam;
         struct chan_call *call;
        pthread_t tid = pthread_self();
 
         struct chan_call *call;
        pthread_t tid = pthread_self();
 
@@ -1468,10 +1529,10 @@ static int lcr_hangup(struct ast_channel *ast)
        {
                /* release */
                CDEBUG(call, ast, "Releasing ref and freeing call instance.\n");
        {
                /* release */
                CDEBUG(call, ast, "Releasing ref and freeing call instance.\n");
-               memset(&newparam, 0, sizeof(union parameter));
-               newparam.disconnectinfo.cause = CAUSE_RESSOURCEUNAVAIL;
-               newparam.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
-               send_message(MESSAGE_RELEASE, call->ref, &newparam);
+               if (ast->hangupcause > 0)
+                       send_release_and_import(call, ast->hangupcause, LOCATION_PRIVATE_LOCAL);
+               else
+                       send_release_and_import(call, CAUSE_RESSOURCEUNAVAIL, LOCATION_PRIVATE_LOCAL);
                /* remove call */
                free_call(call);
                if (!pthread_equal(tid, chan_tid))
                /* remove call */
                free_call(call);
                if (!pthread_equal(tid, chan_tid))
@@ -1500,24 +1561,24 @@ static int lcr_hangup(struct ast_channel *ast)
 static int lcr_write(struct ast_channel *ast, struct ast_frame *f)
 {
         struct chan_call *call;
 static int lcr_write(struct ast_channel *ast, struct ast_frame *f)
 {
         struct chan_call *call;
-       unsigned char buffer[1024], *s, *d = buffer;
-       int i, ii;
 
 
+       if (!f->subclass)
+               CDEBUG(NULL, ast, "No subclass\n");
+#ifdef TODO
+       config
+#else
+       if (!(f->subclass & AST_FORMAT_ALAW))
+#endif
+               CDEBUG(NULL, ast, "Unexpected format.\n");
+       
        ast_mutex_lock(&chan_lock);
         call = ast->tech_pvt;
         if (!call) {
                ast_mutex_unlock(&chan_lock);
                return -1;
        }
        ast_mutex_lock(&chan_lock);
         call = ast->tech_pvt;
         if (!call) {
                ast_mutex_unlock(&chan_lock);
                return -1;
        }
-       if (call->bchannel && ((ii = f->samples)))
-       {
-               if (ii > sizeof(buffer))
-                       ii = sizeof(buffer);
-               s = f->data;
-               for (i = 0; i < ii; i++)
-                       *d++ = flip_bits[*s++];
-               bchannel_transmit(call->bchannel, buffer, ii);
-       }
+       if (call->bchannel && f->samples)
+               bchannel_transmit(call->bchannel, f->data, f->samples);
        ast_mutex_unlock(&chan_lock);
        return 0;
 }
        ast_mutex_unlock(&chan_lock);
        return 0;
 }
@@ -1535,9 +1596,14 @@ static struct ast_frame *lcr_read(struct ast_channel *ast)
                ast_mutex_unlock(&chan_lock);
                return NULL;
        }
                ast_mutex_unlock(&chan_lock);
                return NULL;
        }
-       len = read(call->pipe[0], call->read_buff, sizeof(call->read_buff));
-       if (len <= 0)
-               return NULL;
+       if (call->pipe[0] > -1) {
+               len = read(call->pipe[0], call->read_buff, sizeof(call->read_buff));
+               if (len <= 0) {
+                       close(call->pipe[0]);
+                       call->pipe[0] = -1;
+                       return NULL;
+               }
+       }
 
        p = call->read_buff;
        for (i = 0; i < len; i++) {
 
        p = call->read_buff;
        for (i = 0; i < len; i++) {
@@ -1548,8 +1614,9 @@ static struct ast_frame *lcr_read(struct ast_channel *ast)
        call->read_fr.frametype = AST_FRAME_VOICE;
 #ifdef TODO
        format aus config
        call->read_fr.frametype = AST_FRAME_VOICE;
 #ifdef TODO
        format aus config
-#endif
+#else
        call->read_fr.subclass = AST_FORMAT_ALAW;
        call->read_fr.subclass = AST_FORMAT_ALAW;
+#endif
        call->read_fr.datalen = len;
        call->read_fr.samples = len;
        call->read_fr.delivery = ast_tv(0,0);
        call->read_fr.datalen = len;
        call->read_fr.samples = len;
        call->read_fr.delivery = ast_tv(0,0);
@@ -1562,7 +1629,7 @@ static struct ast_frame *lcr_read(struct ast_channel *ast)
 static int lcr_indicate(struct ast_channel *ast, int cond, const void *data, size_t datalen)
 {
        union parameter newparam;
 static int lcr_indicate(struct ast_channel *ast, int cond, const void *data, size_t datalen)
 {
        union parameter newparam;
-        int res = -1;
+        int res = 0;
         struct chan_call *call;
 
        ast_mutex_lock(&chan_lock);
         struct chan_call *call;
 
        ast_mutex_lock(&chan_lock);
@@ -1576,37 +1643,60 @@ static int lcr_indicate(struct ast_channel *ast, int cond, const void *data, siz
         switch (cond) {
                 case AST_CONTROL_BUSY:
                        CDEBUG(call, ast, "Received indicate AST_CONTROL_BUSY from Asterisk.\n");
         switch (cond) {
                 case AST_CONTROL_BUSY:
                        CDEBUG(call, ast, "Received indicate AST_CONTROL_BUSY from Asterisk.\n");
-                       /* send message to lcr */
-                       memset(&newparam, 0, sizeof(union parameter));
-                       newparam.disconnectinfo.cause = 17;
-                       newparam.disconnectinfo.location = 5;
-                       send_message(MESSAGE_DISCONNECT, call->ref, &newparam);
-                       /* change state */
-                       call->state = CHAN_LCR_STATE_OUT_DISCONNECT;
-                       /* return */
-                       ast_mutex_unlock(&chan_lock);
-                        return 0;
+                       ast_setstate(ast, AST_STATE_BUSY);
+                       if (call->state != CHAN_LCR_STATE_OUT_DISCONNECT) {
+                               /* send message to lcr */
+                               memset(&newparam, 0, sizeof(union parameter));
+                               newparam.disconnectinfo.cause = 17;
+                               newparam.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
+                               send_message(MESSAGE_DISCONNECT, call->ref, &newparam);
+                               /* change state */
+                               call->state = CHAN_LCR_STATE_OUT_DISCONNECT;
+                       }
+                       break;
                 case AST_CONTROL_CONGESTION:
                 case AST_CONTROL_CONGESTION:
-                       CDEBUG(call, ast, "Received indicate AST_CONTROL_CONGESTION from Asterisk.\n");
-                       /* return */
-                       ast_mutex_unlock(&chan_lock);
-                        return -1;
+                       CDEBUG(call, ast, "Received indicate AST_CONTROL_CONGESTION from Asterisk. (cause %d)\n", ast->hangupcause);
+                       if (call->state != CHAN_LCR_STATE_OUT_DISCONNECT) {
+                               /* send message to lcr */
+                               memset(&newparam, 0, sizeof(union parameter));
+                               newparam.disconnectinfo.cause = ast->hangupcause;
+                               newparam.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
+                               send_message(MESSAGE_DISCONNECT, call->ref, &newparam);
+                               /* change state */
+                               call->state = CHAN_LCR_STATE_OUT_DISCONNECT;
+                       }
+                       break;
+                case AST_CONTROL_PROCEEDING:
+                       CDEBUG(call, ast, "Received indicate AST_CONTROL_PROCEEDING from Asterisk.\n");
+                       if (call->state == CHAN_LCR_STATE_IN_SETUP
+                        || call->state == CHAN_LCR_STATE_IN_DIALING) {
+                               /* send message to lcr */
+                               memset(&newparam, 0, sizeof(union parameter));
+                               send_message(MESSAGE_PROCEEDING, call->ref, &newparam);
+                               /* change state */
+                               call->state = CHAN_LCR_STATE_IN_PROCEEDING;
+                       }
+                       break;
                 case AST_CONTROL_RINGING:
                        CDEBUG(call, ast, "Received indicate AST_CONTROL_RINGING from Asterisk.\n");
                 case AST_CONTROL_RINGING:
                        CDEBUG(call, ast, "Received indicate AST_CONTROL_RINGING from Asterisk.\n");
-                       /* send message to lcr */
-                       memset(&newparam, 0, sizeof(union parameter));
-                       send_message(MESSAGE_ALERTING, call->ref, &newparam);
-                       /* change state */
-                       call->state = CHAN_LCR_STATE_OUT_ALERTING;
-                       /* return */
-                       ast_mutex_unlock(&chan_lock);
-                        return 0;
+                       ast_setstate(ast, AST_STATE_RINGING);
+                       if (call->state == CHAN_LCR_STATE_IN_SETUP
+                        || call->state == CHAN_LCR_STATE_IN_DIALING
+                        || call->state == CHAN_LCR_STATE_IN_PROCEEDING) {
+                               /* send message to lcr */
+                               memset(&newparam, 0, sizeof(union parameter));
+                               send_message(MESSAGE_ALERTING, call->ref, &newparam);
+                               /* change state */
+                               call->state = CHAN_LCR_STATE_IN_ALERTING;
+                       }
+                       break;
                 case -1:
                 case -1:
-                       /* return */
-                       ast_mutex_unlock(&chan_lock);
-                        return 0;
+                       CDEBUG(call, ast, "Received indicate -1.\n");
+                        res = -1;
+                       break;
 
                 case AST_CONTROL_VIDUPDATE:
 
                 case AST_CONTROL_VIDUPDATE:
+                       CDEBUG(call, ast, "Received indicate AST_CONTROL_VIDUPDATE.\n");
                         res = -1;
                         break;
                 case AST_CONTROL_HOLD:
                         res = -1;
                         break;
                 case AST_CONTROL_HOLD:
@@ -1626,14 +1716,58 @@ static int lcr_indicate(struct ast_channel *ast, int cond, const void *data, siz
 
                 default:
                        CERROR(call, ast, "Received indicate from Asterisk with unknown condition %d.\n", cond);
 
                 default:
                        CERROR(call, ast, "Received indicate from Asterisk with unknown condition %d.\n", cond);
-                       /* return */
-                       ast_mutex_unlock(&chan_lock);
-                        return -1;
+                        res = -1;
+                       break;
         }
 
        /* return */
        ast_mutex_unlock(&chan_lock);
         }
 
        /* return */
        ast_mutex_unlock(&chan_lock);
-        return 0;
+        return res;
+}
+
+/*
+ * fixup asterisk
+ */
+static int lcr_fixup(struct ast_channel *oldast, struct ast_channel *newast)
+{
+        struct chan_call *call;
+
+       ast_mutex_lock(&chan_lock);
+       call = oldast->tech_pvt;
+        if (!call) {
+               CERROR(NULL, oldast, "Received fixup from Asterisk, but no call instance exists.\n");
+               ast_mutex_unlock(&chan_lock);
+               return -1;
+       }
+
+       CDEBUG(call, oldast, "Received fixup from Asterisk.\n");
+       call->ast = newast;
+       ast_mutex_lock(&chan_lock);
+       return 0;
+}
+
+/*
+ * send_text asterisk
+ */
+static int lcr_send_text(struct ast_channel *ast, const char *text)
+{
+        struct chan_call *call;
+       union parameter newparam;
+
+       ast_mutex_lock(&chan_lock);
+       call = ast->tech_pvt;
+        if (!call) {
+               CERROR(NULL, ast, "Received send_text from Asterisk, but no call instance exists.\n");
+               ast_mutex_unlock(&chan_lock);
+               return -1;
+       }
+
+       CDEBUG(call, ast, "Received send_text from Asterisk. (text=%s)\n", text);
+       memset(&newparam, 0, sizeof(union parameter));
+       strncpy(newparam.notifyinfo.display, text, sizeof(newparam.notifyinfo.display)-1);
+       send_message(MESSAGE_NOTIFY, call->ref, &newparam);
+       ast_mutex_lock(&chan_lock);
+       return 0;
 }
 
 /*
 }
 
 /*
@@ -1752,8 +1886,8 @@ static struct ast_channel_tech lcr_tech = {
        .read=lcr_read,
        .write=lcr_write,
        .indicate=lcr_indicate,
        .read=lcr_read,
        .write=lcr_write,
        .indicate=lcr_indicate,
-//     .fixup=lcr_fixup,
-//     .send_text=lcr_send_text,
+       .fixup=lcr_fixup,
+       .send_text=lcr_send_text,
        .properties=0
 };
 
        .properties=0
 };
 
@@ -1851,31 +1985,32 @@ static struct ast_cli_entry cli_port_unload =
  */
 int load_module(void)
 {
  */
 int load_module(void)
 {
-       int i;
+       u_short i;
 
 
-       for (i = 0; i < 256; i++)
+       for (i = 0; i < 256; i++) {
                flip_bits[i] = (i>>7) | ((i>>5)&2) | ((i>>3)&4) | ((i>>1)&8)
                flip_bits[i] = (i>>7) | ((i>>5)&2) | ((i>>3)&4) | ((i>>1)&8)
-                           || (i<<7) | ((i&2)<<5) | ((i&4)<<3) | ((i&8)<<1);
+                            | (i<<7) | ((i&2)<<5) | ((i&4)<<3) | ((i&8)<<1);
+       }
 
        ast_mutex_init(&chan_lock);
        ast_mutex_init(&log_lock);
 
        ast_mutex_init(&chan_lock);
        ast_mutex_init(&log_lock);
-       
-       if (!(lcr_sock = open_socket())) {
+
+       if (open_socket() < 0) {
                /* continue with closed socket */
        }
 
                /* continue with closed socket */
        }
 
-       if (!bchannel_initialize()) {
+       if (bchannel_initialize()) {
                CERROR(NULL, NULL, "Unable to open mISDN device\n");
                CERROR(NULL, NULL, "Unable to open mISDN device\n");
-               close_socket(lcr_sock);
-               return -1;
+               close_socket();
+               return AST_MODULE_LOAD_DECLINE;
        }
        mISDN_created = 1;
 
        if (ast_channel_register(&lcr_tech)) {
                CERROR(NULL, NULL, "Unable to register channel class\n");
                bchannel_deinitialize();
        }
        mISDN_created = 1;
 
        if (ast_channel_register(&lcr_tech)) {
                CERROR(NULL, NULL, "Unable to register channel class\n");
                bchannel_deinitialize();
-               close_socket(lcr_sock);
-               return -1;
+               close_socket();
+               return AST_MODULE_LOAD_DECLINE;
        }
  
 #if 0  
        }
  
 #if 0  
@@ -1916,9 +2051,9 @@ int load_module(void)
        {
                /* failed to create thread */
                bchannel_deinitialize();
        {
                /* failed to create thread */
                bchannel_deinitialize();
-               close_socket(lcr_sock);
+               close_socket();
                ast_channel_unregister(&lcr_tech);
                ast_channel_unregister(&lcr_tech);
-               return -1;
+               return AST_MODULE_LOAD_DECLINE;
        }
        return 0;
 }
        }
        return 0;
 }
@@ -1953,9 +2088,10 @@ int reload_module(void)
 }
 
 #ifdef TODO
 }
 
 #ifdef TODO
-mutex init fehlt noch
-ast_mutex_t usecnt_lock;
+wech damit
+
 int usecnt;
 int usecnt;
+ast_mutex_t usecnt_lock;
 
 int usecount(void)
 {
 
 int usecount(void)
 {
@@ -1965,7 +2101,6 @@ int usecount(void)
        ast_mutex_unlock(&usecnt_lock);
        return res;
 }
        ast_mutex_unlock(&usecnt_lock);
        return res;
 }
-#endif
 
 
 char *desc="Channel driver for lcr";
 
 
 char *desc="Channel driver for lcr";
@@ -1979,5 +2114,13 @@ char *key(void)
 {
        return ASTERISK_GPL_KEY;
 }
 {
        return ASTERISK_GPL_KEY;
 }
+#endif
+
+#define AST_MODULE "chan_lcr"
 
 
+AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_DEFAULT, "Channel driver for Linux-Call-Router Support (ISDN BRI/PRI)",
+               .load = load_module,
+               .unload = unload_module,
+               .reload = reload_module,
+              );
 
 
index 75ad693..8265c26 100644 (file)
@@ -93,7 +93,7 @@ enum {
 };
 
 
 };
 
 
-#define CERROR(call, ast, arg...) chan_lcr_log(__LOG_ERROR, __FILE__, __LINE__, call, ast, ##arg)
-#define CDEBUG(call, ast, arg...) chan_lcr_log(__LOG_DEBUG, __FILE__, __LINE__, call, ast, ##arg)
-void chan_lcr_log(int type, const char *file, int line, struct chan_call *call, struct ast_channel *ast, const char *fmt, ...);
-
+#define CERROR(call, ast, arg...) chan_lcr_log(__LOG_ERROR, __FILE__, __LINE__,  __FUNCTION__, call, ast, ##arg)
+#define CDEBUG(call, ast, arg...) chan_lcr_log(__LOG_NOTICE, __FILE__, __LINE__,  __FUNCTION__, call, ast, ##arg)
+void chan_lcr_log(int type, const char *file, int line, const char *function,  struct chan_call *call, struct ast_channel *ast, const char *fmt, ...);
+extern unsigned char flip_bits[256];
index 18031b0..fa3101f 100644 (file)
@@ -1,3 +1,5 @@
+OUTDATED, please update
+
 ##   -*- autoconf -*-
 
 dnl    This file is part of linux-call-router
 ##   -*- autoconf -*-
 
 dnl    This file is part of linux-call-router
index 4fbd4ab..e7adcc9 100644 (file)
@@ -1,4 +1,4 @@
-# PBX4Linux routing configuration "routing.conf"
+# Linux-Call-Router routing configuration "routing.conf"
 
 
 # Ruleset: MAIN
 
 
 # Ruleset: MAIN
index d99954b..8e0ffc7 100644 (file)
--- a/dss1.cpp
+++ b/dss1.cpp
 
 #include "main.h"
 #include "myisdn.h"
 
 #include "main.h"
 #include "myisdn.h"
-#ifndef SOCKET_MISDN
-// old mISDN
-extern "C" {
-#include <mISDNuser/net_l2.h>
-}
-#else
 // socket mISDN
 #include <sys/socket.h>
 extern "C" {
 }
 #include <q931.h>
 extern unsigned long mt_assign_pid;
 // socket mISDN
 #include <sys/socket.h>
 extern "C" {
 }
 #include <q931.h>
 extern unsigned long mt_assign_pid;
-#endif
 
 #include "ie.cpp"
 
 
 #include "ie.cpp"
 
@@ -56,81 +49,23 @@ Pdss1::~Pdss1()
 
        if (p_m_d_notify_pending)
                message_free(p_m_d_notify_pending);
 
        if (p_m_d_notify_pending)
                message_free(p_m_d_notify_pending);
-
-#ifndef SOCKET_MISDN
-       /* check how many processes are left */
-       if (p_m_d_ntmode == 1)
-       {
-               if (p_m_mISDNport->nst.layer3->proc)
-                       PDEBUG(DEBUG_ISDN, "destroyed mISDNPort(%s). WARNING: There is still a layer 3 process left. Ignore this, if currently are other calls. This message is not an error!\n", p_name);
-       }
-#endif
 }
 
 
 /*
  * create layer 3 message
  */
 }
 
 
 /*
  * create layer 3 message
  */
-#ifdef SOCKET_MISDN
 static struct l3_msg *create_l3msg(void)
 static struct l3_msg *create_l3msg(void)
-#else
-static msg_t *create_l3msg(int prim, int mt, int dinfo, int size, int ntmode)
-#endif
 {
 {
-#ifdef SOCKET_MISDN
        struct l3_msg *l3m;
 
        l3m = alloc_l3_msg();
        if (l3m)
                return(l3m);
        struct l3_msg *l3m;
 
        l3m = alloc_l3_msg();
        if (l3m)
                return(l3m);
-#else
-       msg_t *dmsg;
-       Q931_info_t *qi;
-       iframe_t *frm;
-
-       if (!ntmode)
-               size = sizeof(Q931_info_t)+2;
-
-       if (ntmode)
-       {
-               dmsg = prep_l3data_msg(prim, dinfo, size, 256, NULL);
-               if (dmsg)
-               {
-                       return(dmsg);
-               }
-       } else
-       {
-               dmsg = alloc_msg(size+256+mISDN_HEADER_LEN+DEFAULT_HEADROOM);
-               if (dmsg)
-               {
-                       memset(msg_put(dmsg,size+mISDN_HEADER_LEN), 0, size+mISDN_HEADER_LEN);
-                       frm = (iframe_t *)dmsg->data;
-                       frm->prim = prim;
-                       frm->dinfo = dinfo;
-                       qi = (Q931_info_t *)(dmsg->data + mISDN_HEADER_LEN);
-                       qi->type = mt;
-                       return(dmsg);
-               }
-       }
-#endif
-
-       FATAL("Cannot allocate memory, system overloaded.\n");
-       exit(0); // make gcc happy
-}
-
-#ifndef SOCKET_MISDN
-msg_t *create_l2msg(int prim, int dinfo, int size) /* NT only */
-{
-       msg_t *dmsg;
-
-       dmsg = prep_l3data_msg(prim, dinfo, size, 256, NULL);
-       if (dmsg)
-               return(dmsg);
 
        FATAL("Cannot allocate memory, system overloaded.\n");
        exit(0); // make gcc happy
 }
 
        FATAL("Cannot allocate memory, system overloaded.\n");
        exit(0); // make gcc happy
 }
-#endif
 
 /*
  * if we received a first reply to the setup message,
 
 /*
  * if we received a first reply to the setup message,
@@ -138,20 +73,10 @@ msg_t *create_l2msg(int prim, int dinfo, int size) /* NT only */
  * return: <0: error, call is released, -cause is given
  *         0: ok, nothing to do
  */
  * return: <0: error, call is released, -cause is given
  *         0: ok, nothing to do
  */
-#ifdef SOCKET_MISDN
 int Pdss1::received_first_reply_to_setup(unsigned long cmd, int channel, int exclusive)
 int Pdss1::received_first_reply_to_setup(unsigned long cmd, int channel, int exclusive)
-#else
-int Pdss1::received_first_reply_to_setup(unsigned long prim, int channel, int exclusive)
-#endif
 {
        int ret;
 {
        int ret;
-#ifdef SOCKET_MISDN
        l3_msg *l3m;
        l3_msg *l3m;
-#else
-       int headerlen = (p_m_d_ntmode)?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
-       RELEASE_COMPLETE_t *release_complete;
-       msg_t *dmsg;
-#endif
 
        /* correct exclusive to 0, if no explicit channel was given */
        if (exclusive<0 || channel<=0)
 
        /* correct exclusive to 0, if no explicit channel was given */
        if (exclusive<0 || channel<=0)
@@ -274,11 +199,7 @@ int Pdss1::received_first_reply_to_setup(unsigned long prim, int channel, int ex
                /*** we sent 'no channel available' ***/
 
                /* if not the first reply, but a connect, we are forced */
                /*** we sent 'no channel available' ***/
 
                /* if not the first reply, but a connect, we are forced */
-#ifdef SOCKET_MISDN
                if (cmd==MT_CONNECT && p_state!=PORT_STATE_OUT_SETUP)
                if (cmd==MT_CONNECT && p_state!=PORT_STATE_OUT_SETUP)
-#else
-               if (prim==(CC_CONNECT | INDICATION) && p_state!=PORT_STATE_OUT_SETUP)
-#endif
                {
                        chan_trace_header(p_m_mISDNport, this, "CHANNEL SELECTION (connect)", DIRECTION_NONE);
                        add_trace("channel", "request", "no-channel");
                {
                        chan_trace_header(p_m_mISDNport, this, "CHANNEL SELECTION (connect)", DIRECTION_NONE);
                        add_trace("channel", "request", "no-channel");
@@ -345,24 +266,11 @@ int Pdss1::received_first_reply_to_setup(unsigned long prim, int channel, int ex
         * NOTE: we send MT_RELEASE_COMPLETE to "REJECT" the channel
         * in response to the setup reply
         */
         * NOTE: we send MT_RELEASE_COMPLETE to "REJECT" the channel
         * in response to the setup reply
         */
-#ifdef SOCKET_MISDN
        l3m = create_l3msg();
        l3m = create_l3msg();
-#else
-       dmsg = create_l3msg(CC_RELEASE_COMPLETE | REQUEST, MT_RELEASE_COMPLETE, p_m_d_l3id, sizeof(RELEASE_COMPLETE_t), p_m_d_ntmode);
-       release_complete = (RELEASE_COMPLETE_t *)(dmsg->data + headerlen);
-#endif
        l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
        l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
-#ifdef SOCKET_MISDN
        enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
        enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
-#else
-       enc_ie_cause(&release_complete->CAUSE, dmsg, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
-#endif
        end_trace();
        end_trace();
-#ifdef SOCKET_MISDN
        p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
        p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
-#else
-       msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
        new_state(PORT_STATE_RELEASE);
        p_m_delete = 1;
        return(-34); /* to epoint: no channel available */
        new_state(PORT_STATE_RELEASE);
        p_m_delete = 1;
        return(-34); /* to epoint: no channel available */
@@ -502,16 +410,8 @@ use_channel:
  * handles all indications
  */
 /* CC_SETUP INDICATION */
  * handles all indications
  */
 /* CC_SETUP INDICATION */
-#ifdef SOCKET_MISDN
 void Pdss1::setup_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
 void Pdss1::setup_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
-#else
-void Pdss1::setup_ind(unsigned long prim, unsigned long dinfo, void *data)
-{
-       int headerlen = (p_m_d_ntmode)?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
-       msg_t *dmsg;
-       SETUP_t *setup = (SETUP_t *)((unsigned long)data + headerlen);
-#endif
        int calling_type, calling_plan, calling_present, calling_screen;
        int called_type, called_plan;
        int redir_type, redir_plan, redir_present, redir_screen, redir_reason;
        int calling_type, calling_plan, calling_present, calling_screen;
        int called_type, called_plan;
        int redir_type, redir_plan, redir_present, redir_screen, redir_reason;
@@ -525,7 +425,6 @@ void Pdss1::setup_ind(unsigned long prim, unsigned long dinfo, void *data)
        class Endpoint *epoint;
        struct lcr_msg *message;
 
        class Endpoint *epoint;
        struct lcr_msg *message;
 
-#ifdef SOCKET_MISDN
        /* process given callref */
        l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_IND, DIRECTION_IN);
        add_trace("callref", "new", "0x%x", pid);
        /* process given callref */
        l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_IND, DIRECTION_IN);
        add_trace("callref", "new", "0x%x", pid);
@@ -547,27 +446,8 @@ void Pdss1::setup_ind(unsigned long prim, unsigned long dinfo, void *data)
        p_m_d_l3id = pid;
        p_m_d_ces = pid >> 16;
        end_trace();
        p_m_d_l3id = pid;
        p_m_d_ces = pid >> 16;
        end_trace();
-#else
-       /* callref from nt-lib */
-       if (p_m_d_ntmode)
-       {
-               /* nt-library now gives us the id via CC_SETUP */
-               if (dinfo&(~0xff) == 0xff00)
-                       FATAL("l3-stack gives us a process id 0xff00-0xffff\n");
-               l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_CR_IND, DIRECTION_IN);
-               if (p_m_d_l3id)
-                       add_trace("callref", "old", "0x%x", p_m_d_l3id);
-               add_trace("callref", "new", "0x%x", dinfo);
-               end_trace();
-               if (p_m_d_l3id&(~0xff) == 0xff00)
-                       p_m_mISDNport->procids[p_m_d_l3id&0xff] = 0;
-               p_m_d_l3id = dinfo;
-               p_m_d_ces = setup->ces;
-       }
-#endif
 
        l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_IND, DIRECTION_IN);
 
        l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_IND, DIRECTION_IN);
-#ifdef SOCKET_MISDN
        dec_ie_calling_pn(l3m, &calling_type, &calling_plan, &calling_present, &calling_screen, (unsigned char *)p_callerinfo.id, sizeof(p_callerinfo.id));
        dec_ie_called_pn(l3m, &called_type, &called_plan, (unsigned char *)p_dialinginfo.id, sizeof(p_dialinginfo.id));
        dec_ie_keypad(l3m, (unsigned char *)keypad, sizeof(keypad));
        dec_ie_calling_pn(l3m, &calling_type, &calling_plan, &calling_present, &calling_screen, (unsigned char *)p_callerinfo.id, sizeof(p_callerinfo.id));
        dec_ie_called_pn(l3m, &called_type, &called_plan, (unsigned char *)p_dialinginfo.id, sizeof(p_dialinginfo.id));
        dec_ie_keypad(l3m, (unsigned char *)keypad, sizeof(keypad));
@@ -580,45 +460,17 @@ void Pdss1::setup_ind(unsigned long prim, unsigned long dinfo, void *data)
        dec_ie_channel_id(l3m, &exclusive, &channel);
        dec_ie_hlc(l3m, &hlc_coding, &hlc_interpretation, &hlc_presentation, &hlc_hlc, &hlc_exthlc);
        dec_ie_bearer(l3m, &bearer_coding, &bearer_capability, &bearer_mode, &bearer_rate, &bearer_multi, &bearer_user);
        dec_ie_channel_id(l3m, &exclusive, &channel);
        dec_ie_hlc(l3m, &hlc_coding, &hlc_interpretation, &hlc_presentation, &hlc_hlc, &hlc_exthlc);
        dec_ie_bearer(l3m, &bearer_coding, &bearer_capability, &bearer_mode, &bearer_rate, &bearer_multi, &bearer_user);
-#else
-       dec_ie_calling_pn(setup->CALLING_PN, (Q931_info_t *)((unsigned long)data+headerlen), &calling_type, &calling_plan, &calling_present, &calling_screen, (unsigned char *)p_callerinfo.id, sizeof(p_callerinfo.id));
-       dec_ie_called_pn(setup->CALLED_PN, (Q931_info_t *)((unsigned long)data+headerlen), &called_type, &called_plan, (unsigned char *)p_dialinginfo.id, sizeof(p_dialinginfo.id));
-       dec_ie_keypad(setup->KEYPAD, (Q931_info_t *)((unsigned long)data+headerlen), (unsigned char *)keypad, sizeof(keypad));
-       /* te-mode: CNIP (calling name identification presentation) */
-       if (!p_m_d_ntmode)
-               dec_facility_centrex(setup->FACILITY, (Q931_info_t *)((unsigned long)data+headerlen), (unsigned char *)p_callerinfo.name, sizeof(p_callerinfo.name));
-       dec_ie_useruser(setup->USER_USER, (Q931_info_t *)((unsigned long)data+headerlen), &useruser_protocol, useruser, &useruser_len);
-       dec_ie_complete(setup->COMPLETE, (Q931_info_t *)((unsigned long)data+headerlen), &p_dialinginfo.sending_complete);
-       dec_ie_redir_nr(setup->REDIR_NR, (Q931_info_t *)((unsigned long)data+headerlen), &redir_type, &redir_plan, &redir_present, &redir_screen, &redir_reason, (unsigned char *)p_redirinfo.id, sizeof(p_redirinfo.id));
-       dec_ie_channel_id(setup->CHANNEL_ID, (Q931_info_t *)((unsigned long)data+headerlen), &exclusive, &channel);
-       dec_ie_hlc(setup->HLC, (Q931_info_t *)((unsigned long)data+headerlen), &hlc_coding, &hlc_interpretation, &hlc_presentation, &hlc_hlc, &hlc_exthlc);
-       dec_ie_bearer(setup->BEARER, (Q931_info_t *)((unsigned long)data+headerlen), &bearer_coding, &bearer_capability, &bearer_mode, &bearer_rate, &bearer_multi, &bearer_user);
-#endif
        end_trace();
 
        /* if blocked, release call with MT_RELEASE_COMPLETE */
        if (p_m_mISDNport->ifport->block)
        {
        end_trace();
 
        /* if blocked, release call with MT_RELEASE_COMPLETE */
        if (p_m_mISDNport->ifport->block)
        {
-#ifdef SOCKET_MISDN
                l3m = create_l3msg();
                l3m = create_l3msg();
-#else
-               RELEASE_COMPLETE_t *release_complete;
-               dmsg = create_l3msg(CC_RELEASE_COMPLETE | REQUEST, MT_RELEASE_COMPLETE, dinfo, sizeof(RELEASE_COMPLETE_t), p_m_d_ntmode);
-               release_complete = (RELEASE_COMPLETE_t *)(dmsg->data + headerlen);
-#endif
                l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
                l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
-#ifdef SOCKET_MISDN
                enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 27); /* temporary unavailable */
                enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 27); /* temporary unavailable */
-#else
-               enc_ie_cause(&release_complete->CAUSE, dmsg, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, 27); /* temporary unavailable */
-#endif
                add_trace("reason", NULL, "port blocked");
                end_trace();
                add_trace("reason", NULL, "port blocked");
                end_trace();
-#ifdef SOCKET_MISDN
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
-#else
-               msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
                new_state(PORT_STATE_RELEASE);
                p_m_delete = 1;
                return;
                new_state(PORT_STATE_RELEASE);
                p_m_delete = 1;
                return;
@@ -816,25 +668,11 @@ void Pdss1::setup_ind(unsigned long prim, unsigned long dinfo, void *data)
                 * NOTE: we send MT_RELEASE_COMPLETE to "REJECT" the channel
                 * in response to the setup
                 */
                 * NOTE: we send MT_RELEASE_COMPLETE to "REJECT" the channel
                 * in response to the setup
                 */
-#ifdef SOCKET_MISDN
                l3m = create_l3msg();
                l3m = create_l3msg();
-#else
-               RELEASE_COMPLETE_t *release_complete;
-               dmsg = create_l3msg(CC_RELEASE_COMPLETE | REQUEST, MT_RELEASE_COMPLETE, dinfo, sizeof(RELEASE_COMPLETE_t), p_m_d_ntmode);
-               release_complete = (RELEASE_COMPLETE_t *)(dmsg->data + headerlen);
-#endif
                l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
                l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
-#ifdef SOCKET_MISDN
                enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
                enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
-#else
-               enc_ie_cause(&release_complete->CAUSE, dmsg, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
-#endif
                end_trace();
                end_trace();
-#ifdef SOCKET_MISDN
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
-#else
-               msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
                new_state(PORT_STATE_RELEASE);
                p_m_delete = 1;
                return;
                new_state(PORT_STATE_RELEASE);
                p_m_delete = 1;
                return;
@@ -868,29 +706,16 @@ void Pdss1::setup_ind(unsigned long prim, unsigned long dinfo, void *data)
 }
 
 /* CC_INFORMATION INDICATION */
 }
 
 /* CC_INFORMATION INDICATION */
-#ifdef SOCKET_MISDN
 void Pdss1::information_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
 void Pdss1::information_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
-#else
-void Pdss1::information_ind(unsigned long prim, unsigned long dinfo, void *data)
-{
-       int headerlen = (p_m_d_ntmode)?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
-       INFORMATION_t *information = (INFORMATION_t *)((unsigned long)data + headerlen);
-#endif
        int type, plan;
        unsigned char keypad[32] = "";
        struct lcr_msg *message;
 
        l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_IND, DIRECTION_IN);
        int type, plan;
        unsigned char keypad[32] = "";
        struct lcr_msg *message;
 
        l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_IND, DIRECTION_IN);
-#ifdef SOCKET_MISDN
        dec_ie_called_pn(l3m, &type, &plan, (unsigned char *)p_dialinginfo.id, sizeof(p_dialinginfo.id));
        dec_ie_keypad(l3m, (unsigned char *)keypad, sizeof(keypad));
        dec_ie_complete(l3m, &p_dialinginfo.sending_complete);
        dec_ie_called_pn(l3m, &type, &plan, (unsigned char *)p_dialinginfo.id, sizeof(p_dialinginfo.id));
        dec_ie_keypad(l3m, (unsigned char *)keypad, sizeof(keypad));
        dec_ie_complete(l3m, &p_dialinginfo.sending_complete);
-#else
-       dec_ie_called_pn(information->CALLED_PN, (Q931_info_t *)((unsigned long)data+headerlen), &type, &plan, (unsigned char *)p_dialinginfo.id, sizeof(p_dialinginfo.id));
-       dec_ie_keypad(information->KEYPAD, (Q931_info_t *)((unsigned long)data+headerlen), (unsigned char *)keypad, sizeof(keypad));
-       dec_ie_complete(information->COMPLETE, (Q931_info_t *)((unsigned long)data+headerlen), &p_dialinginfo.sending_complete);
-#endif
        end_trace();
 
        SCAT(p_dialinginfo.id, (char *)keypad);
        end_trace();
 
        SCAT(p_dialinginfo.id, (char *)keypad);
@@ -917,36 +742,20 @@ void Pdss1::information_ind(unsigned long prim, unsigned long dinfo, void *data)
 }
 
 /* CC_SETUP_ACCNOWLEDGE INDICATION */
 }
 
 /* CC_SETUP_ACCNOWLEDGE INDICATION */
-#ifdef SOCKET_MISDN
 void Pdss1::setup_acknowledge_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
 void Pdss1::setup_acknowledge_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
-#else
-void Pdss1::setup_acknowledge_ind(unsigned long prim, unsigned long dinfo, void *data)
-{
-       int headerlen = (p_m_d_ntmode)?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
-       SETUP_ACKNOWLEDGE_t *setup_acknowledge = (SETUP_ACKNOWLEDGE_t *)((unsigned long)data + headerlen);
-#endif
        int exclusive, channel;
        int coding, location, progress;
        int ret;
        struct lcr_msg *message;
 
        l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_ACKNOWLEDGE_IND, DIRECTION_IN);
        int exclusive, channel;
        int coding, location, progress;
        int ret;
        struct lcr_msg *message;
 
        l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_ACKNOWLEDGE_IND, DIRECTION_IN);
-#ifdef SOCKET_MISDN
        dec_ie_channel_id(l3m, &exclusive, &channel);
        dec_ie_progress(l3m, &coding, &location, &progress);
        dec_ie_channel_id(l3m, &exclusive, &channel);
        dec_ie_progress(l3m, &coding, &location, &progress);
-#else
-       dec_ie_channel_id(setup_acknowledge->CHANNEL_ID, (Q931_info_t *)((unsigned long)data+headerlen), &exclusive, &channel);
-       dec_ie_progress(setup_acknowledge->PROGRESS, (Q931_info_t *)((unsigned long)data+headerlen), &coding, &location, &progress);
-#endif
        end_trace();
 
        /* process channel */
        end_trace();
 
        /* process channel */
-#ifdef SOCKET_MISDN
        ret = received_first_reply_to_setup(cmd, channel, exclusive);
        ret = received_first_reply_to_setup(cmd, channel, exclusive);
-#else
-       ret = received_first_reply_to_setup(prim, channel, exclusive);
-#endif
        if (ret < 0)
        {
                message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
        if (ret < 0)
        {
                message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
@@ -965,15 +774,8 @@ void Pdss1::setup_acknowledge_ind(unsigned long prim, unsigned long dinfo, void
 }
 
 /* CC_PROCEEDING INDICATION */
 }
 
 /* CC_PROCEEDING INDICATION */
-#ifdef SOCKET_MISDN
 void Pdss1::proceeding_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
 void Pdss1::proceeding_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
-#else
-void Pdss1::proceeding_ind(unsigned long prim, unsigned long dinfo, void *data)
-{
-       int headerlen = (p_m_d_ntmode)?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
-       CALL_PROCEEDING_t *proceeding = (CALL_PROCEEDING_t *)((unsigned long)data + headerlen);
-#endif
        int exclusive, channel;
        int coding, location, progress;
        int ret;
        int exclusive, channel;
        int coding, location, progress;
        int ret;
@@ -982,24 +784,13 @@ void Pdss1::proceeding_ind(unsigned long prim, unsigned long dinfo, void *data)
        char redir[32];
 
        l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_IND, DIRECTION_IN);
        char redir[32];
 
        l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_IND, DIRECTION_IN);
-#ifdef SOCKET_MISDN
        dec_ie_channel_id(l3m, &exclusive, &channel);
        dec_ie_progress(l3m, &coding, &location, &progress);
        dec_ie_notify(l3m, &notify);
        dec_ie_redir_dn(l3m, &type, &plan, &present, (unsigned char *)redir, sizeof(redir));
        dec_ie_channel_id(l3m, &exclusive, &channel);
        dec_ie_progress(l3m, &coding, &location, &progress);
        dec_ie_notify(l3m, &notify);
        dec_ie_redir_dn(l3m, &type, &plan, &present, (unsigned char *)redir, sizeof(redir));
-#else
-       dec_ie_channel_id(proceeding->CHANNEL_ID, (Q931_info_t *)((unsigned long)data+headerlen), &exclusive, &channel);
-       dec_ie_progress(proceeding->PROGRESS, (Q931_info_t *)((unsigned long)data+headerlen), &coding, &location, &progress);
-       dec_ie_notify(NULL/*proceeding->NOTIFY*/, (Q931_info_t *)((unsigned long)data+headerlen), &notify);
-       dec_ie_redir_dn(proceeding->REDIR_DN, (Q931_info_t *)((unsigned long)data+headerlen), &type, &plan, &present, (unsigned char *)redir, sizeof(redir));
-#endif
        end_trace();
 
        end_trace();
 
-#ifdef SOCKET_MISDN
        ret = received_first_reply_to_setup(cmd, channel, exclusive);
        ret = received_first_reply_to_setup(cmd, channel, exclusive);
-#else
-       ret = received_first_reply_to_setup(prim, channel, exclusive);
-#endif
        if (ret < 0)
        {
                message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
        if (ret < 0)
        {
                message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
@@ -1064,15 +855,8 @@ void Pdss1::proceeding_ind(unsigned long prim, unsigned long dinfo, void *data)
 }
 
 /* CC_ALERTING INDICATION */
 }
 
 /* CC_ALERTING INDICATION */
-#ifdef SOCKET_MISDN
 void Pdss1::alerting_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
 void Pdss1::alerting_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
-#else
-void Pdss1::alerting_ind(unsigned long prim, unsigned long dinfo, void *data)
-{
-       int headerlen = (p_m_d_ntmode)?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
-       ALERTING_t *alerting = (ALERTING_t *)((unsigned long)data + headerlen);
-#endif
        int exclusive, channel;
        int coding, location, progress;
        int ret;
        int exclusive, channel;
        int coding, location, progress;
        int ret;
@@ -1081,25 +865,14 @@ void Pdss1::alerting_ind(unsigned long prim, unsigned long dinfo, void *data)
        char redir[32];
 
        l1l2l3_trace_header(p_m_mISDNport, this, L3_ALERTING_IND, DIRECTION_IN);
        char redir[32];
 
        l1l2l3_trace_header(p_m_mISDNport, this, L3_ALERTING_IND, DIRECTION_IN);
-#ifdef SOCKET_MISDN
        dec_ie_channel_id(l3m, &exclusive, &channel);
        dec_ie_progress(l3m, &coding, &location, &progress);
        dec_ie_notify(l3m, &notify);
        dec_ie_redir_dn(l3m, &type, &plan, &present, (unsigned char *)redir, sizeof(redir));
        dec_ie_channel_id(l3m, &exclusive, &channel);
        dec_ie_progress(l3m, &coding, &location, &progress);
        dec_ie_notify(l3m, &notify);
        dec_ie_redir_dn(l3m, &type, &plan, &present, (unsigned char *)redir, sizeof(redir));
-#else
-       dec_ie_channel_id(alerting->CHANNEL_ID, (Q931_info_t *)((unsigned long)data+headerlen), &exclusive, &channel);
-       dec_ie_progress(alerting->PROGRESS, (Q931_info_t *)((unsigned long)data+headerlen), &coding, &location, &progress);
-       dec_ie_notify(NULL/*alerting->NOTIFY*/, (Q931_info_t *)((unsigned long)data+headerlen), &notify);
-       dec_ie_redir_dn(alerting->REDIR_DN, (Q931_info_t *)((unsigned long)data+headerlen), &type, &plan, &present, (unsigned char *)redir, sizeof(redir));
-#endif
        end_trace();
 
        /* process channel */
        end_trace();
 
        /* process channel */
-#ifdef SOCKET_MISDN
        ret = received_first_reply_to_setup(cmd, channel, exclusive);
        ret = received_first_reply_to_setup(cmd, channel, exclusive);
-#else
-       ret = received_first_reply_to_setup(prim, channel, exclusive);
-#endif
        if (ret < 0)
        {
                message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
        if (ret < 0)
        {
                message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
@@ -1163,51 +936,25 @@ void Pdss1::alerting_ind(unsigned long prim, unsigned long dinfo, void *data)
 }
 
 /* CC_CONNECT INDICATION */
 }
 
 /* CC_CONNECT INDICATION */
-#ifdef SOCKET_MISDN
 void Pdss1::connect_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
 void Pdss1::connect_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
-#else
-void Pdss1::connect_ind(unsigned long prim, unsigned long dinfo, void *data)
-{
-       int headerlen = (p_m_d_ntmode)?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
-       msg_t *dmsg;
-       CONNECT_t *connect = (CONNECT_t *)((unsigned long)data + headerlen);
-       CONNECT_ACKNOWLEDGE_t *connect_acknowledge;
-#endif
        int exclusive, channel;
        int type, plan, present, screen;
        int ret;
        struct lcr_msg *message;
        int bchannel_before;
 
        int exclusive, channel;
        int type, plan, present, screen;
        int ret;
        struct lcr_msg *message;
        int bchannel_before;
 
-#ifndef SOCKET_MISDN
-       if (p_m_d_ntmode)
-               p_m_d_ces = connect->ces;
-#endif
-
        l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_IND, DIRECTION_IN);
        l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_IND, DIRECTION_IN);
-#ifdef SOCKET_MISDN
        dec_ie_channel_id(l3m, &exclusive, &channel);
        dec_ie_connected_pn(l3m, &type, &plan, &present, &screen, (unsigned char *)p_connectinfo.id, sizeof(p_connectinfo.id));
        /* te-mode: CONP (connected name identification presentation) */
        if (!p_m_d_ntmode)
                dec_facility_centrex(l3m, (unsigned char *)p_connectinfo.name, sizeof(p_connectinfo.name));
        dec_ie_channel_id(l3m, &exclusive, &channel);
        dec_ie_connected_pn(l3m, &type, &plan, &present, &screen, (unsigned char *)p_connectinfo.id, sizeof(p_connectinfo.id));
        /* te-mode: CONP (connected name identification presentation) */
        if (!p_m_d_ntmode)
                dec_facility_centrex(l3m, (unsigned char *)p_connectinfo.name, sizeof(p_connectinfo.name));
-#else
-       dec_ie_channel_id(connect->CHANNEL_ID, (Q931_info_t *)((unsigned long)data+headerlen), &exclusive, &channel);
-       dec_ie_connected_pn(connect->CONNECT_PN, (Q931_info_t *)((unsigned long)data+headerlen), &type, &plan, &present, &screen, (unsigned char *)p_connectinfo.id, sizeof(p_connectinfo.id));
-       /* te-mode: CONP (connected name identification presentation) */
-       if (!p_m_d_ntmode)
-               dec_facility_centrex(connect->FACILITY, (Q931_info_t *)((unsigned long)data+headerlen), (unsigned char *)p_connectinfo.name, sizeof(p_connectinfo.name));
-#endif
        end_trace();
 
        /* select channel */
        bchannel_before = p_m_b_channel;
        end_trace();
 
        /* select channel */
        bchannel_before = p_m_b_channel;
-#ifdef SOCKET_MISDN
        ret = received_first_reply_to_setup(cmd, channel, exclusive);
        ret = received_first_reply_to_setup(cmd, channel, exclusive);
-#else
-       ret = received_first_reply_to_setup(prim, channel, exclusive);
-#endif
        if (ret < 0)
        {
                message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
        if (ret < 0)
        {
                message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
@@ -1267,26 +1014,13 @@ void Pdss1::connect_ind(unsigned long prim, unsigned long dinfo, void *data)
        if (p_m_d_ntmode)
        {
                /* send connect acknowledge */
        if (p_m_d_ntmode)
        {
                /* send connect acknowledge */
-#ifdef SOCKET_MISDN
                l3m = create_l3msg();
                l3m = create_l3msg();
-#else
-               dmsg = create_l3msg(CC_CONNECT | RESPONSE, MT_CONNECT, dinfo, sizeof(CONNECT_ACKNOWLEDGE_t), p_m_d_ntmode);
-               connect_acknowledge = (CONNECT_ACKNOWLEDGE_t *)(dmsg->data + headerlen);
-#endif
                l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_RES, DIRECTION_OUT);
                /* if we had no bchannel before, we send it now */
                if (!bchannel_before && p_m_b_channel)
                l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_RES, DIRECTION_OUT);
                /* if we had no bchannel before, we send it now */
                if (!bchannel_before && p_m_b_channel)
-#ifdef SOCKET_MISDN
                        enc_ie_channel_id(l3m, 1, p_m_b_channel);
                        enc_ie_channel_id(l3m, 1, p_m_b_channel);
-#else
-                       enc_ie_channel_id(&connect_acknowledge->CHANNEL_ID, dmsg, 1, p_m_b_channel);
-#endif
                end_trace();
                end_trace();
-#ifdef SOCKET_MISDN
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CONNECT_ACKNOWLEDGE, p_m_d_l3id, l3m);
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CONNECT_ACKNOWLEDGE, p_m_d_l3id, l3m);
-#else
-               msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
        }
        
        message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_CONNECT);
        }
        
        message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_CONNECT);
@@ -1297,27 +1031,15 @@ void Pdss1::connect_ind(unsigned long prim, unsigned long dinfo, void *data)
 }
 
 /* CC_DISCONNECT INDICATION */
 }
 
 /* CC_DISCONNECT INDICATION */
-#ifdef SOCKET_MISDN
 void Pdss1::disconnect_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
 void Pdss1::disconnect_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
-#else
-void Pdss1::disconnect_ind(unsigned long prim, unsigned long dinfo, void *data)
-{
-       int headerlen = (p_m_d_ntmode)?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
-       DISCONNECT_t *disconnect = (DISCONNECT_t *)((unsigned long)data + headerlen);
-#endif
        int location, cause;
        int coding, proglocation, progress;
        struct lcr_msg *message;
 
        l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_IND, DIRECTION_IN);
        int location, cause;
        int coding, proglocation, progress;
        struct lcr_msg *message;
 
        l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_IND, DIRECTION_IN);
-#ifdef SOCKET_MISDN
        dec_ie_progress(l3m, &coding, &proglocation, &progress);
        dec_ie_cause(l3m, &location, &cause);
        dec_ie_progress(l3m, &coding, &proglocation, &progress);
        dec_ie_cause(l3m, &location, &cause);
-#else
-       dec_ie_progress(disconnect->PROGRESS, (Q931_info_t *)((unsigned long)data+headerlen), &coding, &proglocation, &progress);
-       dec_ie_cause(disconnect->CAUSE, (Q931_info_t *)((unsigned long)data+headerlen), &location, &cause);
-#endif
        end_trace();
 
        if (cause < 0)
        end_trace();
 
        if (cause < 0)
@@ -1326,32 +1048,14 @@ void Pdss1::disconnect_ind(unsigned long prim, unsigned long dinfo, void *data)
        /* release if remote sends us no tones */
        if (!p_m_mISDNport->earlyb)
        {
        /* release if remote sends us no tones */
        if (!p_m_mISDNport->earlyb)
        {
-#ifdef SOCKET_MISDN
                l3_msg *l3m;
                l3_msg *l3m;
-#else
-               msg_t *dmsg;
-               RELEASE_t *release;
-#endif
 
 
-#ifdef SOCKET_MISDN
                l3m = create_l3msg();
                l3m = create_l3msg();
-#else
-               dmsg = create_l3msg(CC_RELEASE | REQUEST, MT_RELEASE, dinfo, sizeof(RELEASE_t), p_m_d_ntmode);
-               release = (RELEASE_t *)(dmsg->data + headerlen);
-#endif
                l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
                l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
-#ifdef SOCKET_MISDN
                enc_ie_cause(l3m, location, cause); /* normal */
                enc_ie_cause(l3m, location, cause); /* normal */
-#else
-               enc_ie_cause(&release->CAUSE, dmsg, location, cause); /* normal */
-#endif
                add_trace("reason", NULL, "no remote patterns");
                end_trace();
                add_trace("reason", NULL, "no remote patterns");
                end_trace();
-#ifdef SOCKET_MISDN
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE, p_m_d_l3id, l3m);
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE, p_m_d_l3id, l3m);
-#else
-               msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
 
                /* sending release to endpoint */
                if (location == LOCATION_PRIVATE_LOCAL)
 
                /* sending release to endpoint */
                if (location == LOCATION_PRIVATE_LOCAL)
@@ -1393,15 +1097,8 @@ void Pdss1::disconnect_ind(unsigned long prim, unsigned long dinfo, void *data)
 }
 
 /* CC_DISCONNECT INDICATION */
 }
 
 /* CC_DISCONNECT INDICATION */
-#ifdef SOCKET_MISDN
 void Pdss1::disconnect_ind_i(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
 void Pdss1::disconnect_ind_i(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
-#else
-void Pdss1::disconnect_ind_i(unsigned long prim, unsigned long dinfo, void *data)
-{
-       int headerlen = (p_m_d_ntmode)?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
-       DISCONNECT_t *disconnect = (DISCONNECT_t *)((unsigned long)data + headerlen);
-#endif
        int location, cause;
 
        /* cause */
        int location, cause;
 
        /* cause */
@@ -1411,11 +1108,7 @@ void Pdss1::disconnect_ind_i(unsigned long prim, unsigned long dinfo, void *data
                add_trace("old-cause", "location", "%d", p_m_d_collect_location);
                add_trace("old-cause", "value", "%d", p_m_d_collect_cause);
        }
                add_trace("old-cause", "location", "%d", p_m_d_collect_location);
                add_trace("old-cause", "value", "%d", p_m_d_collect_cause);
        }
-#ifdef SOCKET_MISDN
        dec_ie_cause(l3m, &location, &cause);
        dec_ie_cause(l3m, &location, &cause);
-#else
-       dec_ie_cause(disconnect->CAUSE, (Q931_info_t *)((unsigned long)data+headerlen), &location, &cause);
-#endif
        if (location == LOCATION_PRIVATE_LOCAL)
                location = LOCATION_PRIVATE_REMOTE;
 
        if (location == LOCATION_PRIVATE_LOCAL)
                location = LOCATION_PRIVATE_REMOTE;
 
@@ -1428,45 +1121,18 @@ void Pdss1::disconnect_ind_i(unsigned long prim, unsigned long dinfo, void *data
 }
 
 /* CC_RELEASE INDICATION */
 }
 
 /* CC_RELEASE INDICATION */
-#ifdef SOCKET_MISDN
 void Pdss1::release_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
 void Pdss1::release_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
-#else
-void Pdss1::release_ind(unsigned long prim, unsigned long dinfo, void *data)
-{
-       int headerlen = (p_m_d_ntmode)?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
-       msg_t *dmsg;
-       RELEASE_t *release = (RELEASE_t *)((unsigned long)data + headerlen);
-#endif
        int location, cause;
        struct lcr_msg *message;
 
        l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_IND, DIRECTION_IN);
        int location, cause;
        struct lcr_msg *message;
 
        l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_IND, DIRECTION_IN);
-#ifdef SOCKET_MISDN
        dec_ie_cause(l3m, &location, &cause);
        dec_ie_cause(l3m, &location, &cause);
-#else
-       dec_ie_cause(release->CAUSE, (Q931_info_t *)((unsigned long)data+headerlen), &location, &cause);
-#endif
        end_trace();
 
        if (cause < 0)
                cause = 16;
 
        end_trace();
 
        if (cause < 0)
                cause = 16;
 
-#ifndef SOCKET_MISDN
-       /* only in NT mode we must send release_complete, if we got a release confirm */
-       if (prim == (CC_RELEASE | CONFIRM))
-       {
-               /* sending release complete */
-               RELEASE_COMPLETE_t *release_complete;
-               dmsg = create_l3msg(CC_RELEASE_COMPLETE | REQUEST, MT_RELEASE_COMPLETE, dinfo, sizeof(RELEASE_COMPLETE_t), p_m_d_ntmode);
-               release_complete = (RELEASE_COMPLETE_t *)(dmsg->data + headerlen);
-               l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
-               enc_ie_cause(&release_complete->CAUSE, dmsg, location, cause);
-               end_trace();
-               msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-       }
-#endif
-
        /* sending release to endpoint */
        if (location == LOCATION_PRIVATE_LOCAL)
                location = LOCATION_PRIVATE_REMOTE;
        /* sending release to endpoint */
        if (location == LOCATION_PRIVATE_LOCAL)
                location = LOCATION_PRIVATE_REMOTE;
@@ -1485,15 +1151,8 @@ void Pdss1::release_ind(unsigned long prim, unsigned long dinfo, void *data)
 }
 
 /* CC_RELEASE_COMPLETE INDICATION (a reject) */
 }
 
 /* CC_RELEASE_COMPLETE INDICATION (a reject) */
-#ifdef SOCKET_MISDN
 void Pdss1::release_complete_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
 void Pdss1::release_complete_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
-#else
-void Pdss1::release_complete_ind(unsigned long prim, unsigned long dinfo, void *data)
-{
-       int headerlen = (p_m_d_ntmode)?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
-       RELEASE_COMPLETE_t *release_complete = (RELEASE_COMPLETE_t *)((unsigned long)data + headerlen);
-#endif
        int location, cause;
        struct lcr_msg *message;
        
        int location, cause;
        struct lcr_msg *message;
        
@@ -1505,11 +1164,7 @@ void Pdss1::release_complete_ind(unsigned long prim, unsigned long dinfo, void *
                location = 5;
        } else
        {
                location = 5;
        } else
        {
-#ifdef SOCKET_MISDN
                dec_ie_cause(l3m, &location, &cause);
                dec_ie_cause(l3m, &location, &cause);
-#else
-               dec_ie_cause(release_complete->CAUSE, (Q931_info_t *)((unsigned long)data+headerlen), &location, &cause);
-#endif
                add_trace("layer 1", NULL, (p_m_mISDNport->l1link)?"up":"down");
        }
        end_trace();
                add_trace("layer 1", NULL, (p_m_mISDNport->l1link)?"up":"down");
        }
        end_trace();
@@ -1535,62 +1190,21 @@ void Pdss1::release_complete_ind(unsigned long prim, unsigned long dinfo, void *
 }
 
 /* T312 timeout  */
 }
 
 /* T312 timeout  */
-#ifdef SOCKET_MISDN
 void Pdss1::t312_timeout_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
        // not required, release is performed with MT_FREE
 }
 void Pdss1::t312_timeout_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
        // not required, release is performed with MT_FREE
 }
-#else
-void Pdss1::t312_timeout_ind(unsigned long prim, unsigned long dinfo, void *data)
-{
-       struct lcr_msg *message;
-       // trace is done at message_isdn()
-       
-       /* sending release to endpoint */
-       while(p_epointlist)
-       {
-               message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
-               if (p_m_d_collect_cause)
-               {
-                       message->param.disconnectinfo.cause = p_m_d_collect_cause;
-                       message->param.disconnectinfo.location = p_m_d_collect_location;
-               } else
-               {
-                       message->param.disconnectinfo.cause = CAUSE_NOUSER;
-                       message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
-               }
-               message_put(message);
-               /* remove epoint */
-               free_epointlist(p_epointlist);
-       }
-
-       new_state(PORT_STATE_RELEASE);
-       p_m_delete = 1;
-}
-#endif
 
 /* CC_NOTIFY INDICATION */
 
 /* CC_NOTIFY INDICATION */
-#ifdef SOCKET_MISDN
 void Pdss1::notify_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
 void Pdss1::notify_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
-#else
-void Pdss1::notify_ind(unsigned long prim, unsigned long dinfo, void *data)
-{
-       int headerlen = (p_m_d_ntmode)?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
-       NOTIFY_t *notifying = (NOTIFY_t *)((unsigned long)data + headerlen);
-#endif
        struct lcr_msg *message;
        int notify, type, plan, present;
        unsigned char notifyid[sizeof(message->param.notifyinfo.id)];
 
        l1l2l3_trace_header(p_m_mISDNport, this, L3_NOTIFY_IND, DIRECTION_IN);
        struct lcr_msg *message;
        int notify, type, plan, present;
        unsigned char notifyid[sizeof(message->param.notifyinfo.id)];
 
        l1l2l3_trace_header(p_m_mISDNport, this, L3_NOTIFY_IND, DIRECTION_IN);
-#ifdef SOCKET_MISDN
        dec_ie_notify(l3m, &notify);
        dec_ie_redir_dn(l3m, &type, &plan, &present, notifyid, sizeof(notifyid));
        dec_ie_notify(l3m, &notify);
        dec_ie_redir_dn(l3m, &type, &plan, &present, notifyid, sizeof(notifyid));
-#else
-       dec_ie_notify(notifying->NOTIFY, (Q931_info_t *)((unsigned long)data+headerlen), &notify);
-       dec_ie_redir_dn(notifying->REDIR_DN, (Q931_info_t *)((unsigned long)data+headerlen), &type, &plan, &present, notifyid, sizeof(notifyid));
-#endif
        end_trace();
 
        if (!ACTIVE_EPOINT(p_epointlist))
        end_trace();
 
        if (!ACTIVE_EPOINT(p_epointlist))
@@ -1641,18 +1255,8 @@ void Pdss1::notify_ind(unsigned long prim, unsigned long dinfo, void *data)
 
 /* CC_HOLD INDICATION */
        struct lcr_msg *message;
 
 /* CC_HOLD INDICATION */
        struct lcr_msg *message;
-#ifdef SOCKET_MISDN
 void Pdss1::hold_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
 void Pdss1::hold_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
-#else
-void Pdss1::hold_ind(unsigned long prim, unsigned long dinfo, void *data)
-{
-       int headerlen = (p_m_d_ntmode)?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
-       msg_t *dmsg;
-//     HOLD_t *hold = (HOLD_t *)((unsigned long)data + headerlen);
-       HOLD_REJECT_t *hold_reject;
-       HOLD_ACKNOWLEDGE_t *hold_acknowledge;
-#endif
 //     class Endpoint *epoint;
 
        l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_IND, DIRECTION_IN);
 //     class Endpoint *epoint;
 
        l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_IND, DIRECTION_IN);
@@ -1660,25 +1264,12 @@ void Pdss1::hold_ind(unsigned long prim, unsigned long dinfo, void *data)
 
        if (!ACTIVE_EPOINT(p_epointlist) || p_m_hold)
        {
 
        if (!ACTIVE_EPOINT(p_epointlist) || p_m_hold)
        {
-#ifdef SOCKET_MISDN
                l3m = create_l3msg();
                l3m = create_l3msg();
-#else
-               dmsg = create_l3msg(CC_HOLD_REJECT | REQUEST, MT_HOLD_REJECT, dinfo, sizeof(HOLD_REJECT_t), p_m_d_ntmode);
-               hold_reject = (HOLD_REJECT_t *)(dmsg->data + headerlen);
-#endif
                l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_REJECT_REQ, DIRECTION_OUT);
                l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_REJECT_REQ, DIRECTION_OUT);
-#ifdef SOCKET_MISDN
                enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, p_m_hold?101:31); /* normal unspecified / incompatible state */
                enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, p_m_hold?101:31); /* normal unspecified / incompatible state */
-#else
-               enc_ie_cause(&hold_reject->CAUSE, dmsg, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, p_m_hold?101:31); /* normal unspecified / incompatible state */
-#endif
                add_trace("reason", NULL, "no endpoint");
                end_trace();
                add_trace("reason", NULL, "no endpoint");
                end_trace();
-#ifdef SOCKET_MISDN
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_HOLD_REJECT, p_m_d_l3id, l3m);
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_HOLD_REJECT, p_m_d_l3id, l3m);
-#else
-               msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
 
                return;
        }
 
                return;
        }
@@ -1707,45 +1298,22 @@ void Pdss1::hold_ind(unsigned long prim, unsigned long dinfo, void *data)
 #endif
 
        /* acknowledge hold */
 #endif
 
        /* acknowledge hold */
-#ifdef SOCKET_MISDN
        l3m = create_l3msg();
        l3m = create_l3msg();
-#else
-       dmsg = create_l3msg(CC_HOLD_ACKNOWLEDGE | REQUEST, MT_HOLD_ACKNOWLEDGE, dinfo, sizeof(HOLD_ACKNOWLEDGE_t), p_m_d_ntmode);
-       hold_acknowledge = (HOLD_ACKNOWLEDGE_t *)(dmsg->data + headerlen);
-#endif
        l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_ACKNOWLEDGE_REQ, DIRECTION_OUT);
        end_trace();
        l1l2l3_trace_header(p_m_mISDNport, this, L3_HOLD_ACKNOWLEDGE_REQ, DIRECTION_OUT);
        end_trace();
-#ifdef SOCKET_MISDN
        p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_HOLD_ACKNOWLEDGE, p_m_d_l3id, l3m);
        p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_HOLD_ACKNOWLEDGE, p_m_d_l3id, l3m);
-#else
-       msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
 }
 
 
 /* CC_RETRIEVE INDICATION */
 }
 
 
 /* CC_RETRIEVE INDICATION */
-#ifdef SOCKET_MISDN
 void Pdss1::retrieve_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
 void Pdss1::retrieve_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
-#else
-void Pdss1::retrieve_ind(unsigned long prim, unsigned long dinfo, void *data)
-{
-       int headerlen = (p_m_d_ntmode)?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
-       msg_t *dmsg;
-       RETRIEVE_t *retrieve = (RETRIEVE_t *)((unsigned long)data + headerlen);
-       RETRIEVE_REJECT_t *retrieve_reject;
-       RETRIEVE_ACKNOWLEDGE_t *retrieve_acknowledge;
-#endif
        struct lcr_msg *message;
        int channel, exclusive, cause;
        int ret;
 
        l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_IND, DIRECTION_IN);
        struct lcr_msg *message;
        int channel, exclusive, cause;
        int ret;
 
        l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_IND, DIRECTION_IN);
-#ifdef SOCKET_MISDN
        dec_ie_channel_id(l3m, &exclusive, &channel);
        dec_ie_channel_id(l3m, &exclusive, &channel);
-#else
-       dec_ie_channel_id(retrieve->CHANNEL_ID, (Q931_info_t *)((unsigned long)data+headerlen), &exclusive, &channel);
-#endif
        end_trace();
 
        if (!p_m_hold)
        end_trace();
 
        if (!p_m_hold)
@@ -1753,24 +1321,11 @@ void Pdss1::retrieve_ind(unsigned long prim, unsigned long dinfo, void *data)
                cause = 101; /* incompatible state */
                reject:
 
                cause = 101; /* incompatible state */
                reject:
 
-#ifdef SOCKET_MISDN
                l3m = create_l3msg();
                l3m = create_l3msg();
-#else
-               dmsg = create_l3msg(CC_RETRIEVE_REJECT | REQUEST, MT_RETRIEVE_REJECT, dinfo, sizeof(RETRIEVE_REJECT_t), p_m_d_ntmode);
-               retrieve_reject = (RETRIEVE_REJECT_t *)(dmsg->data + headerlen);
-#endif
                l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_REJECT_REQ, DIRECTION_OUT);
                l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_REJECT_REQ, DIRECTION_OUT);
-#ifdef SOCKET_MISDN
                enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, cause);
                enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, cause);
-#else
-               enc_ie_cause(&retrieve_reject->CAUSE, dmsg, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, cause);
-#endif
                end_trace();
                end_trace();
-#ifdef SOCKET_MISDN
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RETRIEVE_REJECT, p_m_d_l3id, l3m);
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RETRIEVE_REJECT, p_m_d_l3id, l3m);
-#else
-               msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
 
                return;
        }
 
                return;
        }
@@ -1801,39 +1356,16 @@ void Pdss1::retrieve_ind(unsigned long prim, unsigned long dinfo, void *data)
        p_m_timeout = 0;
 
        /* acknowledge retrieve */
        p_m_timeout = 0;
 
        /* acknowledge retrieve */
-#ifdef SOCKET_MISDN
        l3m = create_l3msg();
        l3m = create_l3msg();
-#else
-       dmsg = create_l3msg(CC_RETRIEVE_ACKNOWLEDGE | REQUEST, MT_RETRIEVE_ACKNOWLEDGE, dinfo, sizeof(RETRIEVE_ACKNOWLEDGE_t), p_m_d_ntmode);
-       retrieve_acknowledge = (RETRIEVE_ACKNOWLEDGE_t *)(dmsg->data + headerlen);
-#endif
        l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_ACKNOWLEDGE_REQ, DIRECTION_OUT);
        l1l2l3_trace_header(p_m_mISDNport, this, L3_RETRIEVE_ACKNOWLEDGE_REQ, DIRECTION_OUT);
-#ifdef SOCKET_MISDN
        enc_ie_channel_id(l3m, 1, p_m_b_channel);
        enc_ie_channel_id(l3m, 1, p_m_b_channel);
-#else
-       enc_ie_channel_id(&retrieve_acknowledge->CHANNEL_ID, dmsg, 1, p_m_b_channel);
-#endif
        end_trace();
        end_trace();
-#ifdef SOCKET_MISDN
        p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RETRIEVE_ACKNOWLEDGE, p_m_d_l3id, l3m);
        p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RETRIEVE_ACKNOWLEDGE, p_m_d_l3id, l3m);
-#else
-       msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
 }
 
 /* CC_SUSPEND INDICATION */
 }
 
 /* CC_SUSPEND INDICATION */
-#ifdef SOCKET_MISDN
 void Pdss1::suspend_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
 void Pdss1::suspend_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
-#else
-void Pdss1::suspend_ind(unsigned long prim, unsigned long dinfo, void *data)
-{
-       int headerlen = (p_m_d_ntmode)?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
-       msg_t *dmsg;
-       SUSPEND_t *suspend = (SUSPEND_t *)((unsigned long)data + headerlen);
-       SUSPEND_ACKNOWLEDGE_t *suspend_acknowledge;
-       SUSPEND_REJECT_t *suspend_reject;
-#endif
        struct lcr_msg *message;
        class Endpoint *epoint;
        unsigned char callid[8];
        struct lcr_msg *message;
        class Endpoint *epoint;
        unsigned char callid[8];
@@ -1841,35 +1373,17 @@ void Pdss1::suspend_ind(unsigned long prim, unsigned long dinfo, void *data)
        int ret = -31; /* normal, unspecified */
 
        l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_IND, DIRECTION_IN);
        int ret = -31; /* normal, unspecified */
 
        l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_IND, DIRECTION_IN);
-#ifdef SOCKET_MISDN
        dec_ie_call_id(l3m, callid, &len);
        dec_ie_call_id(l3m, callid, &len);
-#else
-       dec_ie_call_id(suspend->CALL_ID, (Q931_info_t *)((unsigned long)data+headerlen), callid, &len);
-#endif
        end_trace();
 
        if (!ACTIVE_EPOINT(p_epointlist))
        {
                reject:
        end_trace();
 
        if (!ACTIVE_EPOINT(p_epointlist))
        {
                reject:
-#ifdef SOCKET_MISDN
                l3m = create_l3msg();
                l3m = create_l3msg();
-#else
-               dmsg = create_l3msg(CC_SUSPEND_REJECT | REQUEST, MT_SUSPEND_REJECT, dinfo, sizeof(SUSPEND_REJECT_t), p_m_d_ntmode);
-               suspend_reject = (SUSPEND_REJECT_t *)(dmsg->data + headerlen);
-#endif
                l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_REJECT_REQ, DIRECTION_OUT);
                l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_REJECT_REQ, DIRECTION_OUT);
-#ifdef SOCKET_MISDN
                enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
                enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
-#else
-               enc_ie_cause(&suspend_reject->CAUSE, dmsg, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
-#endif
                end_trace();
                end_trace();
-#ifdef SOCKET_MISDN
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SUSPEND_REJECT, p_m_d_l3id, l3m);
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SUSPEND_REJECT, p_m_d_l3id, l3m);
-#else
-               msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
-
                return;
        }
 
                return;
        }
 
@@ -1916,37 +1430,18 @@ void Pdss1::suspend_ind(unsigned long prim, unsigned long dinfo, void *data)
        }
 
        /* sending SUSPEND_ACKNOWLEDGE */
        }
 
        /* sending SUSPEND_ACKNOWLEDGE */
-#ifdef SOCKET_MISDN
        l3m = create_l3msg();
        l3m = create_l3msg();
-#else
-       dmsg = create_l3msg(CC_SUSPEND_ACKNOWLEDGE | REQUEST, MT_SUSPEND_ACKNOWLEDGE, dinfo, sizeof(SUSPEND_ACKNOWLEDGE_t), p_m_d_ntmode);
-       suspend_acknowledge = (SUSPEND_ACKNOWLEDGE_t *)(dmsg->data + headerlen);
-#endif
        l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_ACKNOWLEDGE_REQ, DIRECTION_OUT);
        end_trace();
        l1l2l3_trace_header(p_m_mISDNport, this, L3_SUSPEND_ACKNOWLEDGE_REQ, DIRECTION_OUT);
        end_trace();
-#ifdef SOCKET_MISDN
        p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SUSPEND_ACKNOWLEDGE, p_m_d_l3id, l3m);
        p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SUSPEND_ACKNOWLEDGE, p_m_d_l3id, l3m);
-#else
-       msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
 
        new_state(PORT_STATE_RELEASE);
        p_m_delete = 1;
 }
 
 /* CC_RESUME INDICATION */
 
        new_state(PORT_STATE_RELEASE);
        p_m_delete = 1;
 }
 
 /* CC_RESUME INDICATION */
-#ifdef SOCKET_MISDN
 void Pdss1::resume_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
 void Pdss1::resume_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
-#else
-void Pdss1::resume_ind(unsigned long prim, unsigned long dinfo, void *data)
-{
-       int headerlen = (p_m_d_ntmode)?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
-       msg_t *dmsg;
-       RESUME_t *resume = (RESUME_t *)((unsigned long)data + headerlen);
-       RESUME_REJECT_t *resume_reject;
-       RESUME_ACKNOWLEDGE_t *resume_acknowledge;
-#endif
        unsigned char callid[8];
        int len;
        int channel, exclusive;
        unsigned char callid[8];
        int len;
        int channel, exclusive;
@@ -1954,7 +1449,6 @@ void Pdss1::resume_ind(unsigned long prim, unsigned long dinfo, void *data)
        struct lcr_msg *message;
        int ret;
 
        struct lcr_msg *message;
        int ret;
 
-#ifdef SOCKET_MISDN
        /* process given callref */
        l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_IND, DIRECTION_IN);
        add_trace("callref", "new", "0x%x", pid);
        /* process given callref */
        l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_IND, DIRECTION_IN);
        add_trace("callref", "new", "0x%x", pid);
@@ -1976,31 +1470,9 @@ void Pdss1::resume_ind(unsigned long prim, unsigned long dinfo, void *data)
        p_m_d_l3id = pid;
        p_m_d_ces = pid >> 16;
        end_trace();
        p_m_d_l3id = pid;
        p_m_d_ces = pid >> 16;
        end_trace();
-#else
-       /* callref from nt-lib */
-       if (p_m_d_ntmode)
-       {
-               /* nt-library now gives us the id via CC_RESUME */
-               if (dinfo&(~0xff) == 0xff00)
-                       FATAL("l3-stack gives us a process id 0xff00-0xffff\n");
-               l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_CR_IND, DIRECTION_IN);
-               if (p_m_d_l3id)
-                       add_trace("callref", "old", "0x%x", p_m_d_l3id);
-               add_trace("callref", "new", "0x%x", dinfo);
-               end_trace();
-               if (p_m_d_l3id&(~0xff) == 0xff00)
-                       p_m_mISDNport->procids[p_m_d_l3id&0xff] = 0;
-               p_m_d_l3id = dinfo;
-               p_m_d_ces = resume->ces;
-       }
-#endif
 
        l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_IND, DIRECTION_IN);
 
        l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_IND, DIRECTION_IN);
-#ifdef SOCKET_MISDN
        dec_ie_call_id(l3m, callid, &len);
        dec_ie_call_id(l3m, callid, &len);
-#else
-       dec_ie_call_id(resume->CALL_ID, (Q931_info_t *)((unsigned long)data+headerlen), callid, &len);
-#endif
        end_trace();
 
        /* if blocked, release call */
        end_trace();
 
        /* if blocked, release call */
@@ -2028,26 +1500,13 @@ void Pdss1::resume_ind(unsigned long prim, unsigned long dinfo, void *data)
        {
                no_channel:
                reject:
        {
                no_channel:
                reject:
-#ifdef SOCKET_MISDN
                l3m = create_l3msg();
                l3m = create_l3msg();
-#else
-               dmsg = create_l3msg(CC_RESUME_REJECT | REQUEST, MT_RESUME_REJECT, dinfo, sizeof(RESUME_REJECT_t), p_m_d_ntmode);
-               resume_reject = (RESUME_REJECT_t *)(dmsg->data + headerlen);
-#endif
                l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_REJECT_REQ, DIRECTION_OUT);
                l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_REJECT_REQ, DIRECTION_OUT);
-#ifdef SOCKET_MISDN
                enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
                enc_ie_cause(l3m, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
-#else
-               enc_ie_cause(&resume_reject->CAUSE, dmsg, (p_m_mISDNport->locally)?LOCATION_PRIVATE_LOCAL:LOCATION_PRIVATE_REMOTE, -ret);
-#endif
                if (ret == -27)
                        add_trace("reason", NULL, "port blocked");
                end_trace();
                if (ret == -27)
                        add_trace("reason", NULL, "port blocked");
                end_trace();
-#ifdef SOCKET_MISDN
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_REJECT, p_m_d_l3id, l3m);
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_REJECT, p_m_d_l3id, l3m);
-#else
-               msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
                new_state(PORT_STATE_RELEASE);
                p_m_delete = 1;
                return;
                new_state(PORT_STATE_RELEASE);
                p_m_delete = 1;
                return;
@@ -2086,49 +1545,25 @@ void Pdss1::resume_ind(unsigned long prim, unsigned long dinfo, void *data)
        message_put(message);
 
        /* sending RESUME_ACKNOWLEDGE */
        message_put(message);
 
        /* sending RESUME_ACKNOWLEDGE */
-#ifdef SOCKET_MISDN
        l3m = create_l3msg();
        l3m = create_l3msg();
-#else
-       dmsg = create_l3msg(CC_RESUME_ACKNOWLEDGE | REQUEST, MT_RESUME_ACKNOWLEDGE, dinfo, sizeof(RESUME_ACKNOWLEDGE_t), p_m_d_ntmode);
-       resume_acknowledge = (RESUME_ACKNOWLEDGE_t *)(dmsg->data + headerlen);
-#endif
        l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_ACKNOWLEDGE_REQ, DIRECTION_OUT);
        l1l2l3_trace_header(p_m_mISDNport, this, L3_RESUME_ACKNOWLEDGE_REQ, DIRECTION_OUT);
-#ifdef SOCKET_MISDN
        enc_ie_channel_id(l3m, 1, p_m_b_channel);
        enc_ie_channel_id(l3m, 1, p_m_b_channel);
-#else
-       enc_ie_channel_id(&resume_acknowledge->CHANNEL_ID, dmsg, 1, p_m_b_channel);
-#endif
        end_trace();
        end_trace();
-#ifdef SOCKET_MISDN
        p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_ACKNOWLEDGE, p_m_d_l3id, l3m);
        p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RESUME_ACKNOWLEDGE, p_m_d_l3id, l3m);
-#else
-       msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
 
        new_state(PORT_STATE_CONNECT);
 }
 
 
 /* CC_FACILITY INDICATION */
 
        new_state(PORT_STATE_CONNECT);
 }
 
 
 /* CC_FACILITY INDICATION */
-#ifdef SOCKET_MISDN
 void Pdss1::facility_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
 void Pdss1::facility_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
-#else
-void Pdss1::facility_ind(unsigned long prim, unsigned long dinfo, void *data)
-{
-       int headerlen = (p_m_d_ntmode)?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
-       FACILITY_t *facility = (FACILITY_t *)((unsigned long)data + headerlen);
-#endif
        unsigned char facil[256];
        int facil_len;
        struct lcr_msg *message;
 
        l1l2l3_trace_header(p_m_mISDNport, this, L3_FACILITY_IND, DIRECTION_IN);
        unsigned char facil[256];
        int facil_len;
        struct lcr_msg *message;
 
        l1l2l3_trace_header(p_m_mISDNport, this, L3_FACILITY_IND, DIRECTION_IN);
-#ifdef SOCKET_MISDN
        dec_ie_facility(l3m, facil, &facil_len);
        dec_ie_facility(l3m, facil, &facil_len);
-#else
-       dec_ie_facility(facility->FACILITY, (Q931_info_t *)((unsigned long)data+headerlen), facil, &facil_len);
-#endif
        end_trace();
 
        /* facility */
        end_trace();
 
        /* facility */
@@ -2146,7 +1581,6 @@ void Pdss1::facility_ind(unsigned long prim, unsigned long dinfo, void *data)
  * handler for isdn connections
  * incoming information are parsed and sent via message to the endpoint
  */
  * handler for isdn connections
  * incoming information are parsed and sent via message to the endpoint
  */
-#ifdef SOCKET_MISDN
 void Pdss1::message_isdn(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
        int timer = 0;
 void Pdss1::message_isdn(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
        int timer = 0;
@@ -2318,267 +1752,62 @@ void Pdss1::message_isdn(unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
                end_trace();
        }
 }
                end_trace();
        }
 }
-#else
-void Pdss1::message_isdn(unsigned long prim, unsigned long dinfo, void *data)
+
+void Pdss1::new_state(int state)
 {
 {
-       int new_l3id;
-       int timer_hex=0;
+//     class Endpoint *epoint;
 
 
-       switch (prim)
+       /* set timeout */
+       if (state == PORT_STATE_IN_OVERLAP)
        {
        {
-               case CC_TIMEOUT | INDICATION:
-               if (p_m_d_ntmode)
+               p_m_timeout = p_m_mISDNport->ifport->tout_dialing;
+               time(&p_m_timer);
+       }
+       if (state != p_state)
+       {
+               if (state == PORT_STATE_IN_SETUP
+                || state == PORT_STATE_OUT_SETUP
+                || state == PORT_STATE_IN_OVERLAP
+                || state == PORT_STATE_OUT_OVERLAP)
                {
                {
-                       int headerlen = (p_m_d_ntmode)?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
-                       timer_hex = *((int *)(((char *)data)+headerlen));
+                       p_m_timeout = p_m_mISDNport->ifport->tout_setup;
+                       time(&p_m_timer);
                }
                }
-               if (timer_hex==0x312 && p_m_d_ntmode)
+               if (state == PORT_STATE_IN_PROCEEDING
+                || state == PORT_STATE_OUT_PROCEEDING)
                {
                {
-                       l1l2l3_trace_header(p_m_mISDNport, this, L3_TIMEOUT_IND, DIRECTION_IN);
-                       add_trace("timer", NULL, "%x", timer_hex);
-                       end_trace();
-                       t312_timeout_ind(prim, dinfo, data);
+                       p_m_timeout = p_m_mISDNport->ifport->tout_proceeding;
+                       time(&p_m_timer);
                }
                }
-               break;
-
-               case CC_SETUP | INDICATION:
-               if (p_state != PORT_STATE_IDLE)
-                       break;
-               setup_ind(prim, dinfo, data);
-               break;
-
-               case CC_SETUP | CONFIRM:
-               if (p_m_d_ntmode)
+               if (state == PORT_STATE_IN_ALERTING
+                || state == PORT_STATE_OUT_ALERTING)
                {
                {
-                       l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_CR_IND, DIRECTION_IN);
-                       add_trace("callref", "old", "0x%x", p_m_d_l3id);
-                       /* nt-library now gives us a new id via CC_SETUP_CONFIRM */
-                       if ((p_m_d_l3id&0xff00) != 0xff00)
-                               PERROR("    strange setup-procid 0x%x\n", p_m_d_l3id);
-                       p_m_d_l3id = *((int *)(((u_char *)data)+ mISDNUSER_HEAD_SIZE));
-                       add_trace("callref", "new", "0x%x", p_m_d_l3id);
-                       end_trace();
+                       p_m_timeout = p_m_mISDNport->ifport->tout_alerting;
+                       time(&p_m_timer);
                }
                }
-               break;
-
-               case CC_INFORMATION | INDICATION:
-               information_ind(prim, dinfo, data);
-               break;
-
-               case CC_SETUP_ACKNOWLEDGE | INDICATION:
-               if (p_state != PORT_STATE_OUT_SETUP)
+               if (state == PORT_STATE_CONNECT
+                || state == PORT_STATE_CONNECT_WAITING)
                {
                {
-                       PERROR("Pdss1(%s) received setup_acknowledge, but we are not in outgoing setup state, IGNORING.\n", p_name);
-                       break;
+                       p_m_timeout = 0;
                }
                }
-               setup_acknowledge_ind(prim, dinfo, data);
-               break;
-
-               case CC_PROCEEDING | INDICATION:
-               if (p_state != PORT_STATE_OUT_SETUP
-                && p_state != PORT_STATE_OUT_OVERLAP)
+               if (state == PORT_STATE_IN_DISCONNECT
+                || state == PORT_STATE_OUT_DISCONNECT)
                {
                {
-                       PERROR("Pdss1(%s) received proceeding, but we are not in outgoing setup OR overlap state, IGNORING.\n", p_name);
-                       break;
+                       p_m_timeout = p_m_mISDNport->ifport->tout_disconnect;
+                       time(&p_m_timer);
                }
                }
-               proceeding_ind(prim, dinfo, data);
-               break;
+       }
+       
+       Port::new_state(state);
+}
 
 
-               case CC_ALERTING | INDICATION:
-               if (p_state != PORT_STATE_OUT_SETUP
-                && p_state != PORT_STATE_OUT_OVERLAP
-                && p_state != PORT_STATE_OUT_PROCEEDING)
-               {
-                       PERROR("Pdss1(%s) received alerting, but we are not in outgoing setup OR overlap OR proceeding state, IGNORING.\n", p_name);
-                       break;
-               }
-               alerting_ind(prim, dinfo, data);
-               break;
 
 
-               case CC_CONNECT | INDICATION:
-               if (p_state != PORT_STATE_OUT_SETUP
-                && p_state != PORT_STATE_OUT_OVERLAP
-                && p_state != PORT_STATE_OUT_PROCEEDING
-                && p_state != PORT_STATE_OUT_ALERTING)
-               {
-                       PERROR("Pdss1(%s) received alerting, but we are not in outgoing setup OR overlap OR proceeding OR ALERTING state, IGNORING.\n", p_name);
-                       break;
-               }
-               connect_ind(prim, dinfo, data);
-               if (p_m_d_notify_pending)
-               {
-                       /* send pending notify message during connect */
-                       message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
-                       message_free(p_m_d_notify_pending);
-                       p_m_d_notify_pending = NULL;
-               }
-               break;
-
-               case CC_CONNECT_ACKNOWLEDGE | INDICATION:
-               case CC_CONNECT | CONFIRM:
-               if (p_state == PORT_STATE_CONNECT_WAITING)
-                       new_state(PORT_STATE_CONNECT);
-               if (p_m_d_notify_pending)
-               {
-                       /* send pending notify message during connect-ack */
-                       message_notify(ACTIVE_EPOINT(p_epointlist), p_m_d_notify_pending->type, &p_m_d_notify_pending->param);
-                       message_free(p_m_d_notify_pending);
-                       p_m_d_notify_pending = NULL;
-               }
-               break;
-
-               case CC_DISCONNECT | INDICATION:
-               disconnect_ind(prim, dinfo, data);
-               break;
-
-               case CC_RELEASE | CONFIRM:
-               case CC_RELEASE | INDICATION:
-               release_ind(prim, dinfo, data);
-               break;
-
-               case CC_RELEASE_COMPLETE | INDICATION:
-               release_complete_ind(prim, dinfo, data);
-               break;
-
-               case CC_RELEASE_COMPLETE | CONFIRM:
-               break;
-
-               case CC_NOTIFY | INDICATION:
-               notify_ind(prim, dinfo, data);
-               break;
-
-               case CC_HOLD | INDICATION:
-               hold_ind(prim, dinfo, data);
-               break;
-
-               case CC_RETRIEVE | INDICATION:
-               retrieve_ind(prim, dinfo, data);
-               break;
-
-               case CC_SUSPEND | INDICATION:
-               suspend_ind(prim, dinfo, data);
-               break;
-
-               case CC_RESUME | INDICATION:
-               resume_ind(prim, dinfo, data);
-               break;
-
-               case CC_FACILITY | INDICATION:
-               facility_ind(prim, dinfo, data);
-               break;
-
-               case CC_RELEASE_CR | INDICATION:
-               l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_CR_IND, DIRECTION_IN);
-               add_trace("callref", NULL, "0x%x", p_m_d_l3id);
-               end_trace();
-               if (p_m_d_ntmode)
-               {
-                       if ((p_m_d_l3id&0xff00) == 0xff00)
-                               p_m_mISDNport->procids[p_m_d_l3id&0xff] = 0;
-               }
-               p_m_d_l3id = 0;
-               p_m_d_ces = -1;
-               p_m_delete = 1;
-//#warning remove me
-//PDEBUG(DEBUG_LOG, "JOLLY release cr %d\n", p_serial);
-               /* sending release to endpoint in case we still have an endpoint
-                * this is because we don't get any response if a release_complete is received (or a release in release state)
-                */
-               while(p_epointlist)
-               {
-                       struct lcr_msg *message;
-                       message = message_create(p_serial, p_epointlist->epoint_id, PORT_TO_EPOINT, MESSAGE_RELEASE);
-                       message->param.disconnectinfo.cause = (p_m_d_collect_cause!=CAUSE_NOUSER)?p_m_d_collect_cause:CAUSE_UNSPECIFIED;
-                       message->param.disconnectinfo.location = (p_m_d_collect_cause!=CAUSE_NOUSER)?p_m_d_collect_location:LOCATION_PRIVATE_LOCAL;
-                       message_put(message);
-                       /* remove epoint */
-                       free_epointlist(p_epointlist);
-
-                       new_state(PORT_STATE_RELEASE);
-               }
-               break;
-
-               case CC_NEW_CR | INDICATION:
-               l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_CR_IND, DIRECTION_IN);
-               if (p_m_d_l3id)
-                       add_trace("callref", "old", "0x%x", p_m_d_l3id);
-               if (p_m_d_ntmode)
-               {
-                       new_l3id = *((int *)(((u_char *)data+mISDNUSER_HEAD_SIZE)));
-                       if (((new_l3id&0xff00)!=0xff00) && ((p_m_d_l3id&0xff00)==0xff00))
-                               p_m_mISDNport->procids[p_m_d_l3id&0xff] = 0;
-               } else
-               {
-                       new_l3id = dinfo;
-               }
-               p_m_d_l3id = new_l3id;
-               add_trace("callref", "new", "0x%x", p_m_d_l3id);
-               end_trace();
-               break;
-
-               default:
-               l1l2l3_trace_header(p_m_mISDNport, this, L3_UNKNOWN, DIRECTION_IN);
-               add_trace("unhandled", "prim", "0x%x", prim);
-               end_trace();
-       }
-}
-#endif
-
-void Pdss1::new_state(int state)
-{
-//     class Endpoint *epoint;
-
-       /* set timeout */
-       if (state == PORT_STATE_IN_OVERLAP)
-       {
-               p_m_timeout = p_m_mISDNport->ifport->tout_dialing;
-               time(&p_m_timer);
-       }
-       if (state != p_state)
-       {
-               if (state == PORT_STATE_IN_SETUP
-                || state == PORT_STATE_OUT_SETUP
-                || state == PORT_STATE_IN_OVERLAP
-                || state == PORT_STATE_OUT_OVERLAP)
-               {
-                       p_m_timeout = p_m_mISDNport->ifport->tout_setup;
-                       time(&p_m_timer);
-               }
-               if (state == PORT_STATE_IN_PROCEEDING
-                || state == PORT_STATE_OUT_PROCEEDING)
-               {
-                       p_m_timeout = p_m_mISDNport->ifport->tout_proceeding;
-                       time(&p_m_timer);
-               }
-               if (state == PORT_STATE_IN_ALERTING
-                || state == PORT_STATE_OUT_ALERTING)
-               {
-                       p_m_timeout = p_m_mISDNport->ifport->tout_alerting;
-                       time(&p_m_timer);
-               }
-               if (state == PORT_STATE_CONNECT
-                || state == PORT_STATE_CONNECT_WAITING)
-               {
-                       p_m_timeout = 0;
-               }
-               if (state == PORT_STATE_IN_DISCONNECT
-                || state == PORT_STATE_OUT_DISCONNECT)
-               {
-                       p_m_timeout = p_m_mISDNport->ifport->tout_disconnect;
-                       time(&p_m_timer);
-               }
-       }
-       
-       Port::new_state(state);
-}
-
-
-/*
- * handler
- */
-int Pdss1::handler(void)
-{
-       int ret;
+/*
+ * handler
+ */
+int Pdss1::handler(void)
+{
+       int ret;
 
        if ((ret = PmISDN::handler()))
                return(ret);
 
        if ((ret = PmISDN::handler()))
                return(ret);
@@ -2600,34 +1829,15 @@ int Pdss1::handler(void)
 /* MESSAGE_INFORMATION */
 void Pdss1::message_information(unsigned long epoint_id, int message_id, union parameter *param)
 {
 /* MESSAGE_INFORMATION */
 void Pdss1::message_information(unsigned long epoint_id, int message_id, union parameter *param)
 {
-#ifdef SOCKET_MISDN
        l3_msg *l3m;
        l3_msg *l3m;
-#else
-       int headerlen = (p_m_d_ntmode)?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
-       msg_t *dmsg;
-       INFORMATION_t *information;
-#endif
 
        if (param->information.id[0]) /* only if we have something to dial */
        {
 
        if (param->information.id[0]) /* only if we have something to dial */
        {
-#ifdef SOCKET_MISDN
                l3m = create_l3msg();
                l3m = create_l3msg();
-#else
-               dmsg = create_l3msg(CC_INFORMATION | REQUEST, MT_INFORMATION, p_m_d_l3id, sizeof(INFORMATION_t), p_m_d_ntmode);
-               information = (INFORMATION_t *)(dmsg->data + headerlen);
-#endif
                l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
                l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
-#ifdef SOCKET_MISDN
                enc_ie_called_pn(l3m, 0, 1, (unsigned char *)param->information.id);
                enc_ie_called_pn(l3m, 0, 1, (unsigned char *)param->information.id);
-#else
-               enc_ie_called_pn(&information->CALLED_PN, dmsg, 0, 1, (unsigned char *)param->information.id);
-#endif
                end_trace();
                end_trace();
-#ifdef SOCKET_MISDN
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
-#else
-               msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
        }
        new_state(p_state);
 }
        }
        new_state(p_state);
 }
@@ -2638,16 +1848,8 @@ int newteid = 0;
 /* MESSAGE_SETUP */
 void Pdss1::message_setup(unsigned long epoint_id, int message_id, union parameter *param)
 {
 /* MESSAGE_SETUP */
 void Pdss1::message_setup(unsigned long epoint_id, int message_id, union parameter *param)
 {
-#ifdef SOCKET_MISDN
        l3_msg *l3m;
        int ret;
        l3_msg *l3m;
        int ret;
-#else
-       int headerlen = (p_m_d_ntmode)?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
-       msg_t *dmsg;
-       INFORMATION_t *information;
-       SETUP_t *setup;
-       int i;
-#endif
        int plan, type, screen, present, reason;
        int capability, mode, rate, coding, user, presentation, interpretation, hlc, exthlc;
        int channel, exclusive;
        int plan, type, screen, present, reason;
        int capability, mode, rate, coding, user, presentation, interpretation, hlc, exthlc;
        int channel, exclusive;
@@ -2685,25 +1887,12 @@ void Pdss1::message_setup(unsigned long epoint_id, int message_id, union paramet
                if (p_callerinfo.display[0])
                {
                        /* sending information */
                if (p_callerinfo.display[0])
                {
                        /* sending information */
-#ifdef SOCKET_MISDN
                        l3m = create_l3msg();
                        l3m = create_l3msg();
-#else
-                       dmsg = create_l3msg(CC_INFORMATION | REQUEST, MT_INFORMATION, p_m_d_l3id, sizeof(INFORMATION_t), p_m_d_ntmode);
-                       information = (INFORMATION_t *)(dmsg->data + headerlen);
-#endif
                        l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
                        if (p_m_d_ntmode)
                        l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
                        if (p_m_d_ntmode)
-#ifdef SOCKET_MISDN
                                enc_ie_display(l3m, (unsigned char *)p_callerinfo.display);
                                enc_ie_display(l3m, (unsigned char *)p_callerinfo.display);
-#else
-                               enc_ie_display(&information->DISPLAY, dmsg, (unsigned char *)p_callerinfo.display);
-#endif
                        end_trace();
                        end_trace();
-#ifdef SOCKET_MISDN
                        p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
                        p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
-#else
-                       msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
                        return;
                }
        }
                        return;
                }
        }
@@ -2731,7 +1920,6 @@ void Pdss1::message_setup(unsigned long epoint_id, int message_id, union paramet
        if (!p_m_b_channel && !p_m_b_reserve && p_type==PORT_TYPE_DSS1_NT_OUT)
                channel = CHANNEL_NO;
 
        if (!p_m_b_channel && !p_m_b_reserve && p_type==PORT_TYPE_DSS1_NT_OUT)
                channel = CHANNEL_NO;
 
-#ifdef SOCKET_MISDN
        /* creating l3id */
        l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_REQ, DIRECTION_OUT);
        /* see MT_ASSIGN notes at do_layer3() */
        /* creating l3id */
        l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_L3ID_REQ, DIRECTION_OUT);
        /* see MT_ASSIGN notes at do_layer3() */
@@ -2753,69 +1941,16 @@ void Pdss1::message_setup(unsigned long epoint_id, int message_id, union paramet
        }
        p_m_d_l3id = mt_assign_pid;
        mt_assign_pid = ~0;
        }
        p_m_d_l3id = mt_assign_pid;
        mt_assign_pid = ~0;
-#else
-       /* creating l3id */
-       l1l2l3_trace_header(p_m_mISDNport, this, L3_NEW_CR_REQ, DIRECTION_OUT);
-       if (p_m_d_ntmode)
-       {
-               i = 0;
-               while(i < 0x100)
-               {
-                       if (p_m_mISDNport->procids[i] == 0)
-                               break;
-                       i++;
-               }
-               if (i == 0x100)
-               {
-                       struct lcr_msg *message;
-
-                       add_trace("callref", NULL, "no free id");
-                       end_trace();
-                       message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_RELEASE);
-                       message->param.disconnectinfo.cause = 47;
-                       message->param.disconnectinfo.location = LOCATION_PRIVATE_LOCAL;
-                       message_put(message);
-                       new_state(PORT_STATE_RELEASE);
-                       p_m_delete = 1;
-                       return;
-               }
-               p_m_mISDNport->procids[i] = 1;
-               p_m_d_l3id = 0xff00 | i;
-       } else
-       {
-               iframe_t ncr;
-               /* if we are in te-mode, we need to create a process first */
-               if (newteid++ > 0x7fff)
-                       newteid = 0x0001;
-               p_m_d_l3id = (entity<<16) | newteid;
-               /* preparing message */
-               ncr.prim = CC_NEW_CR | REQUEST; 
-               ncr.addr = p_m_mISDNport->upper_id | FLG_MSG_DOWN;
-               ncr.dinfo = p_m_d_l3id;
-               ncr.len = 0;
-               /* send message */
-               mISDN_write(mISDNdevice, &ncr, mISDN_HEADER_LEN+ncr.len, TIMEOUT_1SEC);
-       }
-#endif
        add_trace("callref", "new", "0x%x", p_m_d_l3id);
        end_trace();
 
        /* preparing setup message */
        add_trace("callref", "new", "0x%x", p_m_d_l3id);
        end_trace();
 
        /* preparing setup message */
-#ifdef SOCKET_MISDN
        l3m = create_l3msg();
        l3m = create_l3msg();
-#else
-       dmsg = create_l3msg(CC_SETUP | REQUEST, MT_SETUP, p_m_d_l3id, sizeof(SETUP_t), p_m_d_ntmode);
-       setup = (SETUP_t *)(dmsg->data + headerlen);
-#endif
        l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_REQ, DIRECTION_OUT);
        /* channel information */
        if (channel >= 0) /* it should */
        {
        l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_REQ, DIRECTION_OUT);
        /* channel information */
        if (channel >= 0) /* it should */
        {
-#ifdef SOCKET_MISDN
                enc_ie_channel_id(l3m, exclusive, channel);
                enc_ie_channel_id(l3m, exclusive, channel);
-#else
-               enc_ie_channel_id(&setup->CHANNEL_ID, dmsg, exclusive, channel);
-#endif
        }
        /* caller information */
        plan = 1;
        }
        /* caller information */
        plan = 1;
@@ -2856,35 +1991,19 @@ void Pdss1::message_setup(unsigned long epoint_id, int message_id, union paramet
                break;
        }
        if (type >= 0)
                break;
        }
        if (type >= 0)
-#ifdef SOCKET_MISDN
                enc_ie_calling_pn(l3m, type, plan, present, screen, (unsigned char *)p_callerinfo.id);
                enc_ie_calling_pn(l3m, type, plan, present, screen, (unsigned char *)p_callerinfo.id);
-#else
-               enc_ie_calling_pn(&setup->CALLING_PN, dmsg, type, plan, present, screen, (unsigned char *)p_callerinfo.id);
-#endif
        /* dialing information */
        if (p_dialinginfo.id[0]) /* only if we have something to dial */
        {
        /* dialing information */
        if (p_dialinginfo.id[0]) /* only if we have something to dial */
        {
-#ifdef SOCKET_MISDN
                enc_ie_called_pn(l3m, 0, 1, (unsigned char *)p_dialinginfo.id);
                enc_ie_called_pn(l3m, 0, 1, (unsigned char *)p_dialinginfo.id);
-#else
-               enc_ie_called_pn(&setup->CALLED_PN, dmsg, 0, 1, (unsigned char *)p_dialinginfo.id);
-#endif
        }
        /* sending complete */
        if (p_dialinginfo.sending_complete)
        }
        /* sending complete */
        if (p_dialinginfo.sending_complete)
-#ifdef SOCKET_MISDN
                enc_ie_complete(l3m, 1);
                enc_ie_complete(l3m, 1);
-#else
-               enc_ie_complete(&setup->COMPLETE, dmsg, 1);
-#endif
        /* sending user-user */
        if (param->setup.useruser.len)
        {
        /* sending user-user */
        if (param->setup.useruser.len)
        {
-#ifdef SOCKET_MISDN
                enc_ie_useruser(l3m, param->setup.useruser.protocol, param->setup.useruser.data, param->setup.useruser.len);
                enc_ie_useruser(l3m, param->setup.useruser.protocol, param->setup.useruser.data, param->setup.useruser.len);
-#else
-               enc_ie_useruser(&setup->USER_USER, dmsg, param->setup.useruser.protocol, param->setup.useruser.data, param->setup.useruser.len);
-#endif
        }
        /* redirecting number */
        plan = 1;
        }
        /* redirecting number */
        plan = 1;
@@ -2954,11 +2073,7 @@ void Pdss1::message_setup(unsigned long epoint_id, int message_id, union paramet
        }
        /* sending redirecting number only in ntmode */
        if (type >= 0 && p_m_d_ntmode)
        }
        /* sending redirecting number only in ntmode */
        if (type >= 0 && p_m_d_ntmode)
-#ifdef SOCKET_MISDN
                enc_ie_redir_nr(l3m, type, plan, present, screen, reason, (unsigned char *)p_redirinfo.id);
                enc_ie_redir_nr(l3m, type, plan, present, screen, reason, (unsigned char *)p_redirinfo.id);
-#else
-               enc_ie_redir_nr(&setup->REDIR_NR, dmsg, type, plan, present, screen, reason, (unsigned char *)p_redirinfo.id);
-#endif
        /* bearer capability */
 //printf("hlc=%d\n",p_capainfo.hlc);
        coding = 0;
        /* bearer capability */
 //printf("hlc=%d\n",p_capainfo.hlc);
        coding = 0;
@@ -2974,11 +2089,7 @@ void Pdss1::message_setup(unsigned long epoint_id, int message_id, union paramet
                user = p_capainfo.bearer_info1 & 0x7f;
                break;
        }
                user = p_capainfo.bearer_info1 & 0x7f;
                break;
        }
-#ifdef SOCKET_MISDN
        enc_ie_bearer(l3m, coding, capability, mode, rate, -1, user);
        enc_ie_bearer(l3m, coding, capability, mode, rate, -1, user);
-#else
-       enc_ie_bearer(&setup->BEARER, dmsg, coding, capability, mode, rate, -1, user);
-#endif
        /* hlc */
        if (p_capainfo.hlc)
        {
        /* hlc */
        if (p_capainfo.hlc)
        {
@@ -2989,31 +2100,19 @@ void Pdss1::message_setup(unsigned long epoint_id, int message_id, union paramet
                exthlc = -1;
                if (p_capainfo.exthlc)
                        exthlc = p_capainfo.exthlc & 0x7f;
                exthlc = -1;
                if (p_capainfo.exthlc)
                        exthlc = p_capainfo.exthlc & 0x7f;
-#ifdef SOCKET_MISDN
                enc_ie_hlc(l3m, coding, interpretation, presentation, hlc, exthlc);
                enc_ie_hlc(l3m, coding, interpretation, presentation, hlc, exthlc);
-#else
-               enc_ie_hlc(&setup->HLC, dmsg, coding, interpretation, presentation, hlc, exthlc);
-#endif
        }
 
        /* display */
        if (p_callerinfo.display[0] && p_m_d_ntmode)
        }
 
        /* display */
        if (p_callerinfo.display[0] && p_m_d_ntmode)
-#ifdef SOCKET_MISDN
                enc_ie_display(l3m, (unsigned char *)p_callerinfo.display);
                enc_ie_display(l3m, (unsigned char *)p_callerinfo.display);
-#else
-               enc_ie_display(&setup->DISPLAY, dmsg, (unsigned char *)p_callerinfo.display);
-#endif
        /* nt-mode: CNIP (calling name identification presentation) */
 //     if (p_callerinfo.name[0] && p_m_d_ntmode)
 //             enc_facility_centrex(&setup->FACILITY, dmsg, (unsigned char *)p_callerinfo.name, 1);
        end_trace();
 
        /* send setup message now */
        /* nt-mode: CNIP (calling name identification presentation) */
 //     if (p_callerinfo.name[0] && p_m_d_ntmode)
 //             enc_facility_centrex(&setup->FACILITY, dmsg, (unsigned char *)p_callerinfo.name, 1);
        end_trace();
 
        /* send setup message now */
-#ifdef SOCKET_MISDN
        p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SETUP, p_m_d_l3id, l3m);
        p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SETUP, p_m_d_l3id, l3m);
-#else
-       msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
 
        new_state(PORT_STATE_OUT_SETUP);
 }
 
        new_state(PORT_STATE_OUT_SETUP);
 }
@@ -3021,50 +2120,24 @@ void Pdss1::message_setup(unsigned long epoint_id, int message_id, union paramet
 /* MESSAGE_FACILITY */
 void Pdss1::message_facility(unsigned long epoint_id, int message_id, union parameter *param)
 {
 /* MESSAGE_FACILITY */
 void Pdss1::message_facility(unsigned long epoint_id, int message_id, union parameter *param)
 {
-#ifdef SOCKET_MISDN
        l3_msg *l3m;
        l3_msg *l3m;
-#else
-       int headerlen = (p_m_d_ntmode)?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
-       msg_t *dmsg;
-       FACILITY_t *facility;
-#endif
 
        /* facility will not be sent to external lines */
        if (!p_m_d_ntmode)
                return;
 
        /* sending facility */
 
        /* facility will not be sent to external lines */
        if (!p_m_d_ntmode)
                return;
 
        /* sending facility */
-#ifdef SOCKET_MISDN
        l3m = create_l3msg();
        l3m = create_l3msg();
-#else
-       dmsg = create_l3msg(CC_FACILITY | REQUEST, MT_FACILITY, p_m_d_l3id, sizeof(FACILITY_t), p_m_d_ntmode);
-       facility = (FACILITY_t *)(dmsg->data + headerlen);
-#endif
        l1l2l3_trace_header(p_m_mISDNport, this, L3_FACILITY_REQ, DIRECTION_OUT);
        l1l2l3_trace_header(p_m_mISDNport, this, L3_FACILITY_REQ, DIRECTION_OUT);
-#ifdef SOCKET_MISDN
        enc_ie_facility(l3m, (unsigned char *)param->facilityinfo.data, param->facilityinfo.len);
        enc_ie_facility(l3m, (unsigned char *)param->facilityinfo.data, param->facilityinfo.len);
-#else
-       enc_ie_facility(&facility->FACILITY, dmsg, (unsigned char *)param->facilityinfo.data, param->facilityinfo.len);
-#endif
        end_trace();
        end_trace();
-#ifdef SOCKET_MISDN
        p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_FACILITY, p_m_d_l3id, l3m);
        p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_FACILITY, p_m_d_l3id, l3m);
-#else
-       msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
 }
 
 /* MESSAGE_NOTIFY */
 void Pdss1::message_notify(unsigned long epoint_id, int message_id, union parameter *param)
 {
 }
 
 /* MESSAGE_NOTIFY */
 void Pdss1::message_notify(unsigned long epoint_id, int message_id, union parameter *param)
 {
-#ifdef SOCKET_MISDN
        l3_msg *l3m;
        l3_msg *l3m;
-#else
-       int headerlen = (p_m_d_ntmode)?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
-       msg_t *dmsg;
-       INFORMATION_t *information;
-       NOTIFY_t *notification;
-#endif
        int notify;
        int plan, type = -1, present;
 
        int notify;
        int plan, type = -1, present;
 
@@ -3132,104 +2205,47 @@ void Pdss1::message_notify(unsigned long epoint_id, int message_id, union parame
                } else
                {
                        /* sending notification */
                } else
                {
                        /* sending notification */
-#ifdef SOCKET_MISDN
                        l3m = create_l3msg();
                        l3m = create_l3msg();
-#else
-                       dmsg = create_l3msg(CC_NOTIFY | REQUEST, MT_NOTIFY, p_m_d_l3id, sizeof(NOTIFY_t), p_m_d_ntmode);
-                       notification = (NOTIFY_t *)(dmsg->data + headerlen);
-#endif
                        l1l2l3_trace_header(p_m_mISDNport, this, L3_NOTIFY_REQ, DIRECTION_OUT);
                        l1l2l3_trace_header(p_m_mISDNport, this, L3_NOTIFY_REQ, DIRECTION_OUT);
-#ifdef SOCKET_MISDN
                        enc_ie_notify(l3m, notify);
                        enc_ie_notify(l3m, notify);
-#else
-                       enc_ie_notify(&notification->NOTIFY, dmsg, notify);
-#endif
                        /* sending redirection number only in ntmode */
                        if (type >= 0 && p_m_d_ntmode)
                        /* sending redirection number only in ntmode */
                        if (type >= 0 && p_m_d_ntmode)
-#ifdef SOCKET_MISDN
                                enc_ie_redir_dn(l3m, type, plan, present, (unsigned char *)param->notifyinfo.id);
                                enc_ie_redir_dn(l3m, type, plan, present, (unsigned char *)param->notifyinfo.id);
-#else
-                               enc_ie_redir_dn(&notification->REDIR_DN, dmsg, type, plan, present, (unsigned char *)param->notifyinfo.id);
-#endif
                        if (param->notifyinfo.display[0] && p_m_d_ntmode)
                        if (param->notifyinfo.display[0] && p_m_d_ntmode)
-#ifdef SOCKET_MISDN
                                enc_ie_display(l3m, (unsigned char *)param->notifyinfo.display);
                                enc_ie_display(l3m, (unsigned char *)param->notifyinfo.display);
-#else
-                               enc_ie_display(&notification->DISPLAY, dmsg, (unsigned char *)param->notifyinfo.display);
-#endif
                        end_trace();
                        end_trace();
-#ifdef SOCKET_MISDN
                        p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_NOTIFY, p_m_d_l3id, l3m);
                        p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_NOTIFY, p_m_d_l3id, l3m);
-#else
-                       msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
                }
        } else if (p_m_d_ntmode)
        {
                /* sending information */
                }
        } else if (p_m_d_ntmode)
        {
                /* sending information */
-#ifdef SOCKET_MISDN
                l3m = create_l3msg();
                l3m = create_l3msg();
-#else
-               dmsg = create_l3msg(CC_INFORMATION | REQUEST, MT_INFORMATION, p_m_d_l3id, sizeof(INFORMATION_t), p_m_d_ntmode);
-               information = (INFORMATION_t *)(dmsg->data + headerlen);
-#endif
                l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
                l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
-#ifdef SOCKET_MISDN
                enc_ie_display(l3m, (unsigned char *)param->notifyinfo.display);
                enc_ie_display(l3m, (unsigned char *)param->notifyinfo.display);
-#else
-               enc_ie_display(&information->DISPLAY, dmsg, (unsigned char *)param->notifyinfo.display);
-#endif
                end_trace();
                end_trace();
-#ifdef SOCKET_MISDN
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
-#else
-               msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
        }
 }
 
 /* MESSAGE_OVERLAP */
 void Pdss1::message_overlap(unsigned long epoint_id, int message_id, union parameter *param)
 {
        }
 }
 
 /* MESSAGE_OVERLAP */
 void Pdss1::message_overlap(unsigned long epoint_id, int message_id, union parameter *param)
 {
-#ifdef SOCKET_MISDN
        l3_msg *l3m;
        l3_msg *l3m;
-#else
-       int headerlen = (p_m_d_ntmode)?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
-       msg_t *dmsg;
-       SETUP_ACKNOWLEDGE_t *setup_acknowledge;
-#endif
 
        /* sending setup_acknowledge */
 
        /* sending setup_acknowledge */
-#ifdef SOCKET_MISDN
        l3m = create_l3msg();
        l3m = create_l3msg();
-#else
-       dmsg = create_l3msg(CC_SETUP_ACKNOWLEDGE | REQUEST, MT_SETUP_ACKNOWLEDGE, p_m_d_l3id, sizeof(SETUP_ACKNOWLEDGE_t), p_m_d_ntmode);
-       setup_acknowledge = (SETUP_ACKNOWLEDGE_t *)(dmsg->data + headerlen);
-#endif
        l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_ACKNOWLEDGE_REQ, DIRECTION_OUT);
        /* channel information */
        if (p_state == PORT_STATE_IN_SETUP)
        l1l2l3_trace_header(p_m_mISDNport, this, L3_SETUP_ACKNOWLEDGE_REQ, DIRECTION_OUT);
        /* channel information */
        if (p_state == PORT_STATE_IN_SETUP)
-#ifdef SOCKET_MISDN
                enc_ie_channel_id(l3m, 1, p_m_b_channel);
                enc_ie_channel_id(l3m, 1, p_m_b_channel);
-#else
-               enc_ie_channel_id(&setup_acknowledge->CHANNEL_ID, dmsg, 1, p_m_b_channel);
-#endif
        /* progress information */
        if (p_capainfo.bearer_capa==INFO_BC_SPEECH
         || p_capainfo.bearer_capa==INFO_BC_AUDIO
         || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
        if (p_m_mISDNport->tones)
        /* progress information */
        if (p_capainfo.bearer_capa==INFO_BC_SPEECH
         || p_capainfo.bearer_capa==INFO_BC_AUDIO
         || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
        if (p_m_mISDNport->tones)
-#ifdef SOCKET_MISDN
                enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
                enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
-#else
-               enc_ie_progress(&setup_acknowledge->PROGRESS, dmsg, 0, p_m_d_ntmode?1:5, 8);
-#endif
        end_trace();
        end_trace();
-#ifdef SOCKET_MISDN
        p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SETUP_ACKNOWLEDGE, p_m_d_l3id, l3m);
        p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_SETUP_ACKNOWLEDGE, p_m_d_l3id, l3m);
-#else
-       msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
 
        new_state(PORT_STATE_IN_OVERLAP);
 }
 
        new_state(PORT_STATE_IN_OVERLAP);
 }
@@ -3237,45 +2253,22 @@ void Pdss1::message_overlap(unsigned long epoint_id, int message_id, union param
 /* MESSAGE_PROCEEDING */
 void Pdss1::message_proceeding(unsigned long epoint_id, int message_id, union parameter *param)
 {
 /* MESSAGE_PROCEEDING */
 void Pdss1::message_proceeding(unsigned long epoint_id, int message_id, union parameter *param)
 {
-#ifdef SOCKET_MISDN
        l3_msg *l3m;
        l3_msg *l3m;
-#else
-       int headerlen = (p_m_d_ntmode)?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
-       msg_t *dmsg;
-       CALL_PROCEEDING_t *proceeding;
-#endif
 
        /* sending proceeding */
 
        /* sending proceeding */
-#ifdef SOCKET_MISDN
        l3m = create_l3msg();
        l3m = create_l3msg();
-#else
-       dmsg = create_l3msg(CC_PROCEEDING | REQUEST, MT_CALL_PROCEEDING, p_m_d_l3id, sizeof(CALL_PROCEEDING_t), p_m_d_ntmode);
-       proceeding = (CALL_PROCEEDING_t *)(dmsg->data + headerlen);
-#endif
        l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
        /* channel information */
        if (p_state == PORT_STATE_IN_SETUP)
        l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
        /* channel information */
        if (p_state == PORT_STATE_IN_SETUP)
-#ifdef SOCKET_MISDN
                enc_ie_channel_id(l3m, 1, p_m_b_channel);
                enc_ie_channel_id(l3m, 1, p_m_b_channel);
-#else
-               enc_ie_channel_id(&proceeding->CHANNEL_ID, dmsg, 1, p_m_b_channel);
-#endif
        /* progress information */
        if (p_capainfo.bearer_capa==INFO_BC_SPEECH
         || p_capainfo.bearer_capa==INFO_BC_AUDIO
         || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
        if (p_m_mISDNport->tones)
        /* progress information */
        if (p_capainfo.bearer_capa==INFO_BC_SPEECH
         || p_capainfo.bearer_capa==INFO_BC_AUDIO
         || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
        if (p_m_mISDNport->tones)
-#ifdef SOCKET_MISDN
                enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
                enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
-#else
-               enc_ie_progress(&proceeding->PROGRESS, dmsg, 0, p_m_d_ntmode?1:5, 8);
-#endif
        end_trace();
        end_trace();
-#ifdef SOCKET_MISDN
        p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
        p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
-#else
-       msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
 
        new_state(PORT_STATE_IN_PROCEEDING);
 }
 
        new_state(PORT_STATE_IN_PROCEEDING);
 }
@@ -3283,81 +2276,40 @@ void Pdss1::message_proceeding(unsigned long epoint_id, int message_id, union pa
 /* MESSAGE_ALERTING */
 void Pdss1::message_alerting(unsigned long epoint_id, int message_id, union parameter *param)
 {
 /* MESSAGE_ALERTING */
 void Pdss1::message_alerting(unsigned long epoint_id, int message_id, union parameter *param)
 {
-#ifdef SOCKET_MISDN
        l3_msg *l3m;
        l3_msg *l3m;
-#else
-       int headerlen = (p_m_d_ntmode)?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
-       msg_t *dmsg;
-       ALERTING_t *alerting;
-#endif
 
        /* NT-MODE in setup state we must send PROCEEDING first */
        if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP)
        {
                /* sending proceeding */
 
        /* NT-MODE in setup state we must send PROCEEDING first */
        if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP)
        {
                /* sending proceeding */
-#ifdef SOCKET_MISDN
                l3m = create_l3msg();
                l3m = create_l3msg();
-#else
-               CALL_PROCEEDING_t *proceeding;
-               dmsg = create_l3msg(CC_PROCEEDING | REQUEST, MT_CALL_PROCEEDING, p_m_d_l3id, sizeof(CALL_PROCEEDING_t), p_m_d_ntmode);
-               proceeding = (CALL_PROCEEDING_t *)(dmsg->data + headerlen);
-#endif
                l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
                /* channel information */
                l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
                /* channel information */
-#ifdef SOCKET_MISDN
                enc_ie_channel_id(l3m, 1, p_m_b_channel);
                enc_ie_channel_id(l3m, 1, p_m_b_channel);
-#else
-               enc_ie_channel_id(&proceeding->CHANNEL_ID, dmsg, 1, p_m_b_channel);
-#endif
                /* progress information */
                if (p_capainfo.bearer_capa==INFO_BC_SPEECH
                 || p_capainfo.bearer_capa==INFO_BC_AUDIO
                 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
                /* progress information */
                if (p_capainfo.bearer_capa==INFO_BC_SPEECH
                 || p_capainfo.bearer_capa==INFO_BC_AUDIO
                 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
-#ifdef SOCKET_MISDN
                enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
                enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
-#else
-               enc_ie_progress(&proceeding->PROGRESS, dmsg, 0, p_m_d_ntmode?1:5, 8);
-#endif
                end_trace();
                end_trace();
-#ifdef SOCKET_MISDN
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
-#else
-               msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
                new_state(PORT_STATE_IN_PROCEEDING);
        }
 
        /* sending alerting */
                new_state(PORT_STATE_IN_PROCEEDING);
        }
 
        /* sending alerting */
-#ifdef SOCKET_MISDN
        l3m = create_l3msg();
        l3m = create_l3msg();
-#else
-       dmsg = create_l3msg(CC_ALERTING | REQUEST, MT_ALERTING, p_m_d_l3id, sizeof(ALERTING_t), p_m_d_ntmode);
-       alerting = (ALERTING_t *)(dmsg->data + headerlen);
-#endif
        l1l2l3_trace_header(p_m_mISDNport, this, L3_ALERTING_REQ, DIRECTION_OUT);
        /* channel information */
        if (p_state == PORT_STATE_IN_SETUP)
        l1l2l3_trace_header(p_m_mISDNport, this, L3_ALERTING_REQ, DIRECTION_OUT);
        /* channel information */
        if (p_state == PORT_STATE_IN_SETUP)
-#ifdef SOCKET_MISDN
                enc_ie_channel_id(l3m, 1, p_m_b_channel);
                enc_ie_channel_id(l3m, 1, p_m_b_channel);
-#else
-               enc_ie_channel_id(&alerting->CHANNEL_ID, dmsg, 1, p_m_b_channel);
-#endif
        /* progress information */
        if (p_capainfo.bearer_capa==INFO_BC_SPEECH
         || p_capainfo.bearer_capa==INFO_BC_AUDIO
         || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
        if (p_m_mISDNport->tones)
        /* progress information */
        if (p_capainfo.bearer_capa==INFO_BC_SPEECH
         || p_capainfo.bearer_capa==INFO_BC_AUDIO
         || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
        if (p_m_mISDNport->tones)
-#ifdef SOCKET_MISDN
                enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
                enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
-#else
-               enc_ie_progress(&alerting->PROGRESS, dmsg, 0, p_m_d_ntmode?1:5, 8);
-#endif
        end_trace();
        end_trace();
-#ifdef SOCKET_MISDN
        p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_ALERTING, p_m_d_l3id, l3m);
        p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_ALERTING, p_m_d_l3id, l3m);
-#else
-       msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
 
        new_state(PORT_STATE_IN_ALERTING);
 }
 
        new_state(PORT_STATE_IN_ALERTING);
 }
@@ -3365,14 +2317,7 @@ void Pdss1::message_alerting(unsigned long epoint_id, int message_id, union para
 /* MESSAGE_CONNECT */
 void Pdss1::message_connect(unsigned long epoint_id, int message_id, union parameter *param)
 {
 /* MESSAGE_CONNECT */
 void Pdss1::message_connect(unsigned long epoint_id, int message_id, union parameter *param)
 {
-#ifdef SOCKET_MISDN
        l3_msg *l3m;
        l3_msg *l3m;
-#else
-       int headerlen = (p_m_d_ntmode)?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
-       msg_t *dmsg;
-       INFORMATION_t *information;
-       CONNECT_t *connect;
-#endif
        int type, plan, present, screen;
        class Endpoint *epoint;
 
        int type, plan, present, screen;
        class Endpoint *epoint;
 
@@ -3380,35 +2325,17 @@ void Pdss1::message_connect(unsigned long epoint_id, int message_id, union param
        if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP)
        {
                /* sending proceeding */
        if (p_m_d_ntmode && p_state==PORT_STATE_IN_SETUP)
        {
                /* sending proceeding */
-#ifdef SOCKET_MISDN
                l3m = create_l3msg();
                l3m = create_l3msg();
-#else
-               CALL_PROCEEDING_t *proceeding;
-               dmsg = create_l3msg(CC_PROCEEDING | REQUEST, MT_CALL_PROCEEDING, p_m_d_l3id, sizeof(CALL_PROCEEDING_t), p_m_d_ntmode);
-               proceeding = (CALL_PROCEEDING_t *)(dmsg->data + headerlen);
-#endif
                l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
                /* channel information */
                l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
                /* channel information */
-#ifdef SOCKET_MISDN
                enc_ie_channel_id(l3m, 1, p_m_b_channel);
                enc_ie_channel_id(l3m, 1, p_m_b_channel);
-#else
-               enc_ie_channel_id(&proceeding->CHANNEL_ID, dmsg, 1, p_m_b_channel);
-#endif
 //             /* progress information */
 //             if (p_capainfo.bearer_capa==INFO_BC_SPEECH
 //              || p_capainfo.bearer_capa==INFO_BC_AUDIO
 //              || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
 //             /* progress information */
 //             if (p_capainfo.bearer_capa==INFO_BC_SPEECH
 //              || p_capainfo.bearer_capa==INFO_BC_AUDIO
 //              || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
-#ifdef SOCKET_MISDN
 //             enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
 //             enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
-#else
-//             enc_ie_progress(&proceeding->PROGRESS, dmsg, 0, p_m_d_ntmode?1:5, 8);
-#endif
                end_trace();
                end_trace();
-#ifdef SOCKET_MISDN
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
-#else
-               msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
                new_state(PORT_STATE_IN_PROCEEDING);
        }
 
                new_state(PORT_STATE_IN_PROCEEDING);
        }
 
@@ -3422,25 +2349,12 @@ void Pdss1::message_connect(unsigned long epoint_id, int message_id, union param
        if (p_connectinfo.display[0])
        {
                /* sending information */
        if (p_connectinfo.display[0])
        {
                /* sending information */
-#ifdef SOCKET_MISDN
                l3m = create_l3msg();
                l3m = create_l3msg();
-#else
-               dmsg = create_l3msg(CC_INFORMATION | REQUEST, MT_INFORMATION, p_m_d_l3id, sizeof(INFORMATION_t), p_m_d_ntmode);
-               information = (INFORMATION_t *)(dmsg->data + headerlen);
-#endif
                l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
                if (p_m_d_ntmode)
                l1l2l3_trace_header(p_m_mISDNport, this, L3_INFORMATION_REQ, DIRECTION_OUT);
                if (p_m_d_ntmode)
-#ifdef SOCKET_MISDN
                        enc_ie_display(l3m, (unsigned char *)p_connectinfo.display);
                        enc_ie_display(l3m, (unsigned char *)p_connectinfo.display);
-#else
-                       enc_ie_display(&information->DISPLAY, dmsg, (unsigned char *)p_connectinfo.display);
-#endif
                end_trace();
                end_trace();
-#ifdef SOCKET_MISDN
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_INFORMATION, p_m_d_l3id, l3m);
-#else
-               msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
                return;
        }
 
                return;
        }
 
@@ -3451,12 +2365,7 @@ void Pdss1::message_connect(unsigned long epoint_id, int message_id, union param
        }
 
        /* preparing connect message */
        }
 
        /* preparing connect message */
-#ifdef SOCKET_MISDN
        l3m = create_l3msg();
        l3m = create_l3msg();
-#else
-       dmsg = create_l3msg(CC_CONNECT | REQUEST, MT_CONNECT, p_m_d_l3id, sizeof(CONNECT_t), p_m_d_ntmode);
-       connect = (CONNECT_t *)(dmsg->data + headerlen);
-#endif
        l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_REQ, DIRECTION_OUT);
        /* connect information */
        plan = 1;
        l1l2l3_trace_header(p_m_mISDNport, this, L3_CONNECT_REQ, DIRECTION_OUT);
        /* connect information */
        plan = 1;
@@ -3503,18 +2412,10 @@ void Pdss1::message_connect(unsigned long epoint_id, int message_id, union param
                break;
        }
        if (type >= 0)
                break;
        }
        if (type >= 0)
-#ifdef SOCKET_MISDN
                enc_ie_connected_pn(l3m, type, plan, present, screen, (unsigned char *)p_connectinfo.id);
                enc_ie_connected_pn(l3m, type, plan, present, screen, (unsigned char *)p_connectinfo.id);
-#else
-               enc_ie_connected_pn(&connect->CONNECT_PN, dmsg, type, plan, present, screen, (unsigned char *)p_connectinfo.id);
-#endif
        /* display */
        if (p_connectinfo.display[0] && p_m_d_ntmode)
        /* display */
        if (p_connectinfo.display[0] && p_m_d_ntmode)
-#ifdef SOCKET_MISDN
                enc_ie_display(l3m, (unsigned char *)p_connectinfo.display);
                enc_ie_display(l3m, (unsigned char *)p_connectinfo.display);
-#else
-               enc_ie_display(&connect->DISPLAY, dmsg, (unsigned char *)p_connectinfo.display);
-#endif
        /* nt-mode: CONP (connected name identification presentation) */
 //     if (p_connectinfo.name[0] && p_m_d_ntmode)
 //             enc_facility_centrex(&connect->FACILITY, dmsg, (unsigned char *)p_connectinfo.name, 0);
        /* nt-mode: CONP (connected name identification presentation) */
 //     if (p_connectinfo.name[0] && p_m_d_ntmode)
 //             enc_facility_centrex(&connect->FACILITY, dmsg, (unsigned char *)p_connectinfo.name, 0);
@@ -3522,19 +2423,11 @@ void Pdss1::message_connect(unsigned long epoint_id, int message_id, union param
        if (p_m_d_ntmode)
        {
                epoint = find_epoint_id(epoint_id);
        if (p_m_d_ntmode)
        {
                epoint = find_epoint_id(epoint_id);
-#ifdef SOCKET_MISDN
                enc_ie_date(l3m, now, p_settings.no_seconds);
                enc_ie_date(l3m, now, p_settings.no_seconds);
-#else
-               enc_ie_date(&connect->DATE, dmsg, now, p_settings.no_seconds);
-#endif
        }
        end_trace();
        /* finally send message */
        }
        end_trace();
        /* finally send message */
-#ifdef SOCKET_MISDN
        p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CONNECT, p_m_d_l3id, l3m);
        p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CONNECT, p_m_d_l3id, l3m);
-#else
-       msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
 
        if (p_m_d_ntmode)
                new_state(PORT_STATE_CONNECT);
 
        if (p_m_d_ntmode)
                new_state(PORT_STATE_CONNECT);
@@ -3546,14 +2439,7 @@ void Pdss1::message_connect(unsigned long epoint_id, int message_id, union param
 /* MESSAGE_DISCONNECT */
 void Pdss1::message_disconnect(unsigned long epoint_id, int message_id, union parameter *param)
 {
 /* MESSAGE_DISCONNECT */
 void Pdss1::message_disconnect(unsigned long epoint_id, int message_id, union parameter *param)
 {
-#ifdef SOCKET_MISDN
        l3_msg *l3m;
        l3_msg *l3m;
-#else
-       int headerlen = (p_m_d_ntmode)?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
-       msg_t *dmsg;
-       DISCONNECT_t *disconnect;
-       RELEASE_COMPLETE_t *release_complete;
-#endif
        struct lcr_msg *message;
        char *p = NULL;
 
        struct lcr_msg *message;
        char *p = NULL;
 
@@ -3571,25 +2457,12 @@ if (/*   ||*/ p_state==PORT_STATE_OUT_SETUP)
                        free_epointlist(p_epointlist);
                }
                /* sending release */
                        free_epointlist(p_epointlist);
                }
                /* sending release */
-#ifdef SOCKET_MISDN
                l3m = create_l3msg();
                l3m = create_l3msg();
-#else
-               dmsg = create_l3msg(CC_RELEASE_COMPLETE | REQUEST, MT_RELEASE_COMPLETE, p_m_d_l3id, sizeof(RELEASE_COMPLETE_t), p_m_d_ntmode);
-               release_complete = (RELEASE_COMPLETE_t *)(dmsg->data + headerlen);
-#endif
                l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
                /* send cause */
                l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_COMPLETE_REQ, DIRECTION_OUT);
                /* send cause */
-#ifdef SOCKET_MISDN
                enc_ie_cause(l3m, (!p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_REMOTE:param->disconnectinfo.location, param->disconnectinfo.cause);
                enc_ie_cause(l3m, (!p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_REMOTE:param->disconnectinfo.location, param->disconnectinfo.cause);
-#else
-               enc_ie_cause(&release_complete->CAUSE, dmsg, (!p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_REMOTE:param->disconnectinfo.location, param->disconnectinfo.cause);
-#endif
                end_trace();
                end_trace();
-#ifdef SOCKET_MISDN
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
-#else
-               msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
                new_state(PORT_STATE_RELEASE);
                p_m_delete = 1;
                return;
                new_state(PORT_STATE_RELEASE);
                p_m_delete = 1;
                return;
@@ -3599,92 +2472,45 @@ if (/*   ||*/ p_state==PORT_STATE_OUT_SETUP)
        if (p_state==PORT_STATE_IN_SETUP)
        {
                /* sending proceeding */
        if (p_state==PORT_STATE_IN_SETUP)
        {
                /* sending proceeding */
-#ifdef SOCKET_MISDN
                l3m = create_l3msg();
                l3m = create_l3msg();
-#else
-               CALL_PROCEEDING_t *proceeding;
-               dmsg = create_l3msg(CC_PROCEEDING | REQUEST, MT_CALL_PROCEEDING, p_m_d_l3id, sizeof(CALL_PROCEEDING_t), p_m_d_ntmode);
-               proceeding = (CALL_PROCEEDING_t *)(dmsg->data + headerlen);
-#endif
                l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
                /* channel information */
                l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
                /* channel information */
-#ifdef SOCKET_MISDN
                enc_ie_channel_id(l3m, 1, p_m_b_channel);
                enc_ie_channel_id(l3m, 1, p_m_b_channel);
-#else
-               enc_ie_channel_id(&proceeding->CHANNEL_ID, dmsg, 1, p_m_b_channel);
-#endif
                /* progress information */
                if (p_capainfo.bearer_capa==INFO_BC_SPEECH
                 || p_capainfo.bearer_capa==INFO_BC_AUDIO
                 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
                /* progress information */
                if (p_capainfo.bearer_capa==INFO_BC_SPEECH
                 || p_capainfo.bearer_capa==INFO_BC_AUDIO
                 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
-#ifdef SOCKET_MISDN
                        enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
                        enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
-#else
-                       enc_ie_progress(&proceeding->PROGRESS, dmsg, 0, p_m_d_ntmode?1:5, 8);
-#endif
                end_trace();
                end_trace();
-#ifdef SOCKET_MISDN
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
-#else
-               msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
                new_state(PORT_STATE_IN_PROCEEDING);
        }
 
        /* sending disconnect */
                new_state(PORT_STATE_IN_PROCEEDING);
        }
 
        /* sending disconnect */
-#ifdef SOCKET_MISDN
        l3m = create_l3msg();
        l3m = create_l3msg();
-#else
-       dmsg = create_l3msg(CC_DISCONNECT | REQUEST, MT_DISCONNECT, p_m_d_l3id, sizeof(DISCONNECT_t), p_m_d_ntmode);
-       disconnect = (DISCONNECT_t *)(dmsg->data + headerlen);
-#endif
        l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_REQ, DIRECTION_OUT);
        /* progress information */
        if (p_capainfo.bearer_capa==INFO_BC_SPEECH
         || p_capainfo.bearer_capa==INFO_BC_AUDIO
         || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
        if (p_m_mISDNport->tones)
        l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_REQ, DIRECTION_OUT);
        /* progress information */
        if (p_capainfo.bearer_capa==INFO_BC_SPEECH
         || p_capainfo.bearer_capa==INFO_BC_AUDIO
         || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
        if (p_m_mISDNport->tones)
-#ifdef SOCKET_MISDN
                enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
                enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
-#else
-               enc_ie_progress(&disconnect->PROGRESS, dmsg, 0, p_m_d_ntmode?1:5, 8);
-#endif
        /* send cause */
        /* send cause */
-#ifdef SOCKET_MISDN
        enc_ie_cause(l3m, (!p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_REMOTE:param->disconnectinfo.location, param->disconnectinfo.cause);
        enc_ie_cause(l3m, (!p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_REMOTE:param->disconnectinfo.location, param->disconnectinfo.cause);
-#else
-       enc_ie_cause(&disconnect->CAUSE, dmsg, (!p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_REMOTE:param->disconnectinfo.location, param->disconnectinfo.cause);
-#endif
        /* send display */
        if (param->disconnectinfo.display[0])
                p = param->disconnectinfo.display;
        if (p) if (*p && p_m_d_ntmode)
        /* send display */
        if (param->disconnectinfo.display[0])
                p = param->disconnectinfo.display;
        if (p) if (*p && p_m_d_ntmode)
-#ifdef SOCKET_MISDN
                enc_ie_display(l3m, (unsigned char *)p);
                enc_ie_display(l3m, (unsigned char *)p);
-#else
-               enc_ie_display(&disconnect->DISPLAY, dmsg, (unsigned char *)p);
-#endif
        end_trace();
        end_trace();
-#ifdef SOCKET_MISDN
        p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_DISCONNECT, p_m_d_l3id, l3m);
        p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_DISCONNECT, p_m_d_l3id, l3m);
-#else
-       msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
        new_state(PORT_STATE_OUT_DISCONNECT);
 }
 
 /* MESSAGE_RELEASE */
 void Pdss1::message_release(unsigned long epoint_id, int message_id, union parameter *param)
 {
        new_state(PORT_STATE_OUT_DISCONNECT);
 }
 
 /* MESSAGE_RELEASE */
 void Pdss1::message_release(unsigned long epoint_id, int message_id, union parameter *param)
 {
-#ifdef SOCKET_MISDN
        l3_msg *l3m;
        l3_msg *l3m;
-#else
-       int headerlen = (p_m_d_ntmode)?mISDNUSER_HEAD_SIZE:mISDN_HEADER_LEN;
-       msg_t *dmsg;
-       RELEASE_t *release;
-       RELEASE_COMPLETE_t *release_complete;
-       DISCONNECT_t *disconnect;
-#endif
        class Endpoint *epoint;
        char *p = NULL;
 
        class Endpoint *epoint;
        char *p = NULL;
 
@@ -3696,25 +2522,12 @@ void Pdss1::message_release(unsigned long epoint_id, int message_id, union param
         || p_state == PORT_STATE_OUT_DISCONNECT)
        {
                /* sending release */
         || p_state == PORT_STATE_OUT_DISCONNECT)
        {
                /* sending release */
-#ifdef SOCKET_MISDN
                l3m = create_l3msg();
                l3m = create_l3msg();
-#else
-               dmsg = create_l3msg(CC_RELEASE | REQUEST, MT_RELEASE, p_m_d_l3id, sizeof(RELEASE_t), p_m_d_ntmode);
-               release = (RELEASE_t *)(dmsg->data + headerlen);
-#endif
                l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
                /* send cause */
                l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
                /* send cause */
-#ifdef SOCKET_MISDN
                enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
                enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
-#else
-               enc_ie_cause(&release->CAUSE, dmsg, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
-#endif
                end_trace();
                end_trace();
-#ifdef SOCKET_MISDN
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE, p_m_d_l3id, l3m);
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE, p_m_d_l3id, l3m);
-#else
-               msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
                new_state(PORT_STATE_RELEASE);
                /* remove epoint */
                free_epointid(epoint_id);
                new_state(PORT_STATE_RELEASE);
                /* remove epoint */
                free_epointid(epoint_id);
@@ -3734,25 +2547,12 @@ void Pdss1::message_release(unsigned long epoint_id, int message_id, union param
 //#warning remove me
 //PDEBUG(DEBUG_LOG, "JOLLY sending release complete %d\n", p_serial);
                /* sending release complete */
 //#warning remove me
 //PDEBUG(DEBUG_LOG, "JOLLY sending release complete %d\n", p_serial);
                /* sending release complete */
-#ifdef SOCKET_MISDN
                l3m = create_l3msg();
                l3m = create_l3msg();
-#else
-               dmsg = create_l3msg(CC_RELEASE_COMPLETE | REQUEST, MT_RELEASE_COMPLETE, p_m_d_l3id, sizeof(RELEASE_COMPLETE_t), p_m_d_ntmode);
-               release_complete = (RELEASE_COMPLETE_t *)(dmsg->data + headerlen);
-#endif
                l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
                /* send cause */
                l1l2l3_trace_header(p_m_mISDNport, this, L3_RELEASE_REQ, DIRECTION_OUT);
                /* send cause */
-#ifdef SOCKET_MISDN
                enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
                enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
-#else
-               enc_ie_cause(&release_complete->CAUSE, dmsg, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
-#endif
                end_trace();
                end_trace();
-#ifdef SOCKET_MISDN
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_RELEASE_COMPLETE, p_m_d_l3id, l3m);
-#else
-               msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
                new_state(PORT_STATE_RELEASE);
                /* remove epoint */
                free_epointid(epoint_id);
                new_state(PORT_STATE_RELEASE);
                /* remove epoint */
                free_epointid(epoint_id);
@@ -3768,77 +2568,39 @@ wirklich erst proceeding?:
                CALL_PROCEEDING_t *proceeding;
 
                /* sending proceeding */
                CALL_PROCEEDING_t *proceeding;
 
                /* sending proceeding */
-#ifdef SOCKET_MISDN
                l3m = create_l3msg();
                l3m = create_l3msg();
-#else
-               dmsg = create_l3msg(CC_PROCEEDING | REQUEST, MT_CALL_PROCEEDING, p_m_d_l3id, sizeof(CALL_PROCEEDING_t), p_m_d_ntmode);
-               proceeding = (CALL_PROCEEDING_t *)(dmsg->data + headerlen);
-#endif
                l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
                /* channel information */
                l1l2l3_trace_header(p_m_mISDNport, this, L3_PROCEEDING_REQ, DIRECTION_OUT);
                /* channel information */
-#ifdef SOCKET_MISDN
                enc_ie_channel_id(l3m, 1, p_m_b_channel);
                enc_ie_channel_id(l3m, 1, p_m_b_channel);
-#else
-               enc_ie_channel_id(&proceeding->CHANNEL_ID, dmsg, 1, p_m_b_channel);
-#endif
                /* progress information */
                if (p_capainfo.bearer_capa==INFO_BC_SPEECH
                 || p_capainfo.bearer_capa==INFO_BC_AUDIO
                 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
                /* progress information */
                if (p_capainfo.bearer_capa==INFO_BC_SPEECH
                 || p_capainfo.bearer_capa==INFO_BC_AUDIO
                 || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
-#ifdef SOCKET_MISDN
                        enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
                        enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
-#else
-                       enc_ie_progress(&proceeding->PROGRESS, dmsg, 0, p_m_d_ntmode?1:5, 8);
-#endif
                end_trace();
                end_trace();
-#ifdef SOCKET_MISDN
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
                p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_CALL_PROCEEDING, p_m_d_l3id, l3m);
-#else
-               msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
        }
 #endif
 
        /* sending disconnect */
        }
 #endif
 
        /* sending disconnect */
-#ifdef SOCKET_MISDN
        l3m = create_l3msg();
        l3m = create_l3msg();
-#else
-       dmsg = create_l3msg(CC_DISCONNECT | REQUEST, MT_DISCONNECT, p_m_d_l3id, sizeof(DISCONNECT_t), p_m_d_ntmode);
-       disconnect = (DISCONNECT_t *)(dmsg->data + headerlen);
-#endif
        l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_REQ, DIRECTION_OUT);
        /* progress information */
        if (p_capainfo.bearer_capa==INFO_BC_SPEECH
         || p_capainfo.bearer_capa==INFO_BC_AUDIO
         || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
        if (p_m_mISDNport->tones)
        l1l2l3_trace_header(p_m_mISDNport, this, L3_DISCONNECT_REQ, DIRECTION_OUT);
        /* progress information */
        if (p_capainfo.bearer_capa==INFO_BC_SPEECH
         || p_capainfo.bearer_capa==INFO_BC_AUDIO
         || p_capainfo.bearer_capa==INFO_BC_DATAUNRESTRICTED_TONES)
        if (p_m_mISDNport->tones)
-#ifdef SOCKET_MISDN
                enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
                enc_ie_progress(l3m, 0, p_m_d_ntmode?1:5, 8);
-#else
-               enc_ie_progress(&disconnect->PROGRESS, dmsg, 0, p_m_d_ntmode?1:5, 8);
-#endif
        /* send cause */
        /* send cause */
-#ifdef SOCKET_MISDN
        enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
        enc_ie_cause(l3m, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
-#else
-       enc_ie_cause(&disconnect->CAUSE, dmsg, (p_m_mISDNport->locally && param->disconnectinfo.location==LOCATION_PRIVATE_LOCAL)?LOCATION_PRIVATE_LOCAL:param->disconnectinfo.location, param->disconnectinfo.cause);
-#endif
        /* send display */
        epoint = find_epoint_id(epoint_id);
        if (param->disconnectinfo.display[0])
                p = param->disconnectinfo.display;
        if (p) if (*p && p_m_d_ntmode)
        /* send display */
        epoint = find_epoint_id(epoint_id);
        if (param->disconnectinfo.display[0])
                p = param->disconnectinfo.display;
        if (p) if (*p && p_m_d_ntmode)
-#ifdef SOCKET_MISDN
                enc_ie_display(l3m, (unsigned char *)p);
                enc_ie_display(l3m, (unsigned char *)p);
-#else
-               enc_ie_display(&disconnect->DISPLAY, dmsg, (unsigned char *)p);
-#endif
        end_trace();
        end_trace();
-#ifdef SOCKET_MISDN
        p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_DISCONNECT, p_m_d_l3id, l3m);
        p_m_mISDNport->ml3->to_layer3(p_m_mISDNport->ml3, MT_DISCONNECT, p_m_d_l3id, l3m);
-#else
-       msg_queue_tail(&p_m_mISDNport->downqueue, dmsg);
-#endif
        new_state(PORT_STATE_OUT_DISCONNECT);
        /* remove epoint */
        free_epointid(epoint_id);
        new_state(PORT_STATE_OUT_DISCONNECT);
        /* remove epoint */
        free_epointid(epoint_id);
@@ -3902,35 +2664,7 @@ int Pdss1::message_epoint(unsigned long epoint_id, int message_id, union paramet
                }
                if (p_epointlist && p_state==PORT_STATE_IDLE)
                        FATAL("Pdss1(%s): epoint pointer is set in idle state, how bad!!\n", p_name);
                }
                if (p_epointlist && p_state==PORT_STATE_IDLE)
                        FATAL("Pdss1(%s): epoint pointer is set in idle state, how bad!!\n", p_name);
-#ifdef SOCKET_MISDN
                message_setup(epoint_id, message_id, param);
                message_setup(epoint_id, message_id, param);
-#else
-               /* note: pri is a special case, because links must be up for pri */ 
-               if (p_m_mISDNport->l1link || p_m_mISDNport->pri || !p_m_mISDNport->ntmode || p_state!=PORT_STATE_IDLE)
-               {
-                       /* LAYER 1 is up, or we may send */
-                       message_setup(epoint_id, message_id, param);
-               } else {
-                       iframe_t act;
-                       /* LAYER 1 id down, so we queue */
-                       p_m_d_queue = message_create(epoint_id, p_serial, EPOINT_TO_PORT, message_id);
-                       memcpy(&p_m_d_queue->param, param, sizeof(union parameter));
-                       /* attach us */
-                       if (!(epointlist_new(epoint_id)))
-                               FATAL("No memory for epointlist\n");
-                       /* activate link */
-                       PDEBUG(DEBUG_ISDN, "the L1 is down, we try to establish the link NT portnum=%d (%s).\n", p_m_mISDNport->portnum, p_name);
-                       act.prim = PH_ACTIVATE | REQUEST; 
-                       act.addr = p_m_mISDNport->upper_id | FLG_MSG_DOWN;
-                       act.dinfo = 0;
-                       act.len = 0;
-                       mISDN_write(mISDNdevice, &act, mISDN_HEADER_LEN+act.len, TIMEOUT_1SEC);
-                       l1l2l3_trace_header(p_m_mISDNport, this, L1_ACTIVATE_REQ, DIRECTION_OUT);
-                       end_trace();
-//                     /* set timeout */
-//                     p_m_mISDNport->l1timeout = now+3;
-               }
-#endif
                break;
 
                case MESSAGE_NOTIFY: /* display and notifications */
                break;
 
                case MESSAGE_NOTIFY: /* display and notifications */
@@ -4017,7 +2751,6 @@ int Pdss1::message_epoint(unsigned long epoint_id, int message_id, union paramet
 /*
  * data from isdn-stack (layer-3) to pbx (port class)
  */
 /*
  * data from isdn-stack (layer-3) to pbx (port class)
  */
-#ifdef SOCKET_MISDN
 int stack2manager(struct mISDNport *mISDNport, unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
        class Port *port;
 int stack2manager(struct mISDNport *mISDNport, unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
        class Port *port;
@@ -4155,250 +2888,9 @@ int stack2manager(struct mISDNport *mISDNport, unsigned int cmd, unsigned int pi
        }
        return(0);
 }
        }
        return(0);
 }
-#else
-/* NOTE: nt mode use mISDNuser_head_t as header */
-int stack2manager_nt(void *dat, void *arg)
-{
-       class Port *port;
-       class Pdss1 *pdss1;
-       manager_t *mgr = (manager_t *)dat;
-       msg_t *msg = (msg_t *)arg;
-       mISDNuser_head_t *hh;
-       struct mISDNport *mISDNport;
-       char name[32];
-
-       if (!msg || !mgr)
-               return(-EINVAL);
-
-       /* note: nst is the first data feld of mISDNport */
-       mISDNport = (struct mISDNport *)mgr->nst;
-
-       hh = (mISDNuser_head_t *)msg->data;
-       PDEBUG(DEBUG_ISDN, "prim(0x%x) dinfo(0x%x) msg->len(%d)\n", hh->prim, hh->dinfo, msg->len);
-
-       /* find Port object of type ISDN */
-       port = port_first;
-       while(port)
-       {
-               if (port->p_type == PORT_TYPE_DSS1_NT_IN || port->p_type == PORT_TYPE_DSS1_NT_OUT)
-               {
-                       pdss1 = (class Pdss1 *)port;
-//PDEBUG(DEBUG_ISDN, "comparing dinfo = 0x%x with l3id 0x%x\n", hh->dinfo, pdss1->p_m_d_l3id);
-                       /* check out correct stack */
-                       if (pdss1->p_m_mISDNport == mISDNport)
-                       /* check out correct id */
-                       if ((pdss1->p_m_d_l3id&0x0000ff00) != 0x000ff00)
-                       {
-                               /* a single process */
-                               if (hh->dinfo == pdss1->p_m_d_l3id)
-                               {
-                                       /* found port, the message belongs to */
-                                       break;
-                               }
-                       } else
-                       {
-                               /* a broadcast process */
-                               if ((hh->dinfo&0xffff0000) == (pdss1->p_m_d_l3id&0xffff0000))
-                               {
-                                       /* found port, the message belongs to */
-                                       break;
-                               }
-                       }
-               }
-               port = port->next;
-       }
-       if (port)
-       {
-//printf("%x %x\n", hh->dinfo, pdss1->p_m_d_l3id);
-               /* if process id is master process, but a child disconnects */
-               if ((hh->dinfo&0x0000ff00)!=0x0000ff00 && (pdss1->p_m_d_l3id&0x0000ff00)==0x0000ff00)
-               {
-                       if (hh->prim == (CC_DISCONNECT|INDICATION))
-                       {
-                               /* send special indication for child disconnect */
-                               pdss1->disconnect_ind_i(hh->prim, hh->dinfo, msg->data);
-                               free_msg(msg);
-                               return(0);
-                       }
-                       // ignoring other messages from child processes
-                       free_msg(msg);
-                       return(0);
-               }
-               /* if process id and layer 3 id matches */
-               if (hh->dinfo == pdss1->p_m_d_l3id)
-               {
-                       pdss1->message_isdn(hh->prim, hh->dinfo, msg->data);
-                       free_msg(msg);
-                       return(0);
-               }
-       }
-
-       /* d-message */
-       switch(hh->prim)
-       {
-               case MGR_SHORTSTATUS | INDICATION:
-               case MGR_SHORTSTATUS | CONFIRM:
-               switch(hh->dinfo) {
-                       case SSTATUS_L2_ESTABLISHED:
-                       goto ss_estab;
-                       case SSTATUS_L2_RELEASED:
-                       goto ss_rel;
-               }
-               break;
-
-               case DL_ESTABLISH | INDICATION:
-               l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_IND, DIRECTION_IN);
-               goto ss_estab;
-               case DL_ESTABLISH | CONFIRM:
-               l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_CON, DIRECTION_IN);
-               ss_estab:
-               add_trace("tei", NULL, "%d", hh->dinfo);
-               end_trace();
-               if (mISDNport->ptp && hh->dinfo == 0)
-               {
-                       if (mISDNport->l2establish)
-                       {
-                               mISDNport->l2establish = 0;
-                               PDEBUG(DEBUG_ISDN, "the link became active before l2establish timer expiry.\n");
-                       }
-                       mISDNport->l2link = 1;
-                       if (mISDNport->pri);
-                               mISDNport->l1link = 1; /* this is a hack, we also assume L1 to be active */
-               }
-               break;
-
-               case DL_RELEASE | INDICATION:
-               l1l2l3_trace_header(mISDNport, NULL, L2_RELEASE_IND, DIRECTION_IN);
-               goto ss_rel;
-               case DL_RELEASE | CONFIRM:
-               l1l2l3_trace_header(mISDNport, NULL, L2_RELEASE_CON, DIRECTION_IN);
-               ss_rel:
-               add_trace("tei", NULL, "%d", hh->dinfo);
-               end_trace();
-               if (mISDNport->ptp && hh->dinfo == 0)
-               {
-                       mISDNport->l2link = 0;
-                       time(&mISDNport->l2establish);
-                       PDEBUG(DEBUG_ISDN, "because we are ptp, we set a l2establish timer.\n");
-               }
-               break;
-
-               case CC_SETUP | INDICATION:
-               /* creating port object */
-               SPRINT(name, "%s-%d-in", mISDNport->ifport->interface->name, mISDNport->portnum);
-               if (!(pdss1 = new Pdss1(PORT_TYPE_DSS1_NT_IN, mISDNport, name, NULL, 0, 0)))
-
-                       FATAL("Cannot create Port instance.\n");
-               pdss1->message_isdn(hh->prim, hh->dinfo, msg->data);
-               break;
-
-               case CC_RESUME | INDICATION:
-               /* creating port object */
-               SPRINT(name, "%s-%d-in", mISDNport->ifport->interface->name, mISDNport->portnum);
-               if (!(pdss1 = new Pdss1(PORT_TYPE_DSS1_NT_IN, mISDNport, name, NULL, 0, 0)))
-                       FATAL("Cannot create Port instance.\n");
-               pdss1->message_isdn(hh->prim, hh->dinfo, msg->data);
-               break;
-
-               case CC_RELEASE_CR | INDICATION:
-               PERROR("unhandled message from stack: call ref released (l3id=0x%x)\n", hh->dinfo);
-               break;
-
-               case CC_RELEASE_COMPLETE | INDICATION:
-               break;
-
-               case CC_FACILITY | INDICATION:
-               break;
-
-               default:
-               PERROR("unhandled message: prim(0x%x) dinfo(0x%x) msg->len(%d)\n", hh->prim, hh->dinfo, msg->len);
-               port = port_first;
-               while(port)
-               {
-                       if (port->p_type == PORT_TYPE_DSS1_NT_IN || port->p_type == PORT_TYPE_DSS1_NT_OUT)
-                       {
-                               pdss1 = (class Pdss1 *)port;
-       //PDEBUG(DEBUG_ISDN, "comparing dinfo = 0x%x with l3id 0x%x\n", hh->dinfo, pdss1->p_m_d_l3id);
-                               /* check out correct stack */
-                               if (pdss1->p_m_mISDNport == mISDNport)
-                               /* check out correct id */
-                               PERROR("unhandled message: dinfo=%x is not associated with port-dinfo=%x\n",hh->dinfo,pdss1->p_m_d_l3id);
-                       }
-                       port = port->next;
-               }
-               return(-EINVAL);
-       }
-       free_msg(msg);
-       return(0);
-}
-
-/* NOTE: te mode use iframe_t as header */
-int stack2manager_te(struct mISDNport *mISDNport, msg_t *msg)
-{
-       class Port *port;
-       class Pdss1 *pdss1;
-       iframe_t *frm;
-       char name[32];
 
 
-       if (!msg || !mISDNport)
-               return(-EINVAL);
-       frm = (iframe_t *)msg->data;
-       PDEBUG(DEBUG_ISDN, "prim(0x%x) dinfo(0x%x) msg->len(%d)\n", frm->prim, frm->dinfo, msg->len);
 
 
-       /* find Port object of type ISDN */
-       port = port_first;
-       while(port)
-       {
-               if (port->p_type == PORT_TYPE_DSS1_TE_IN || port->p_type == PORT_TYPE_DSS1_TE_OUT)
-               {
-                       pdss1 = (class Pdss1 *)port;
-                       /* check out correct stack */
-                       if (pdss1->p_m_mISDNport == mISDNport)
-                       /* check out correct id */
-                       if (frm->dinfo == pdss1->p_m_d_l3id)
-                       {
-                               /* found port, the message belongs to */
-                               break;
-                       }
-               }
-               port = port->next;
-       }
-       if (port)
-       {
-               pdss1->message_isdn(frm->prim, frm->dinfo, msg->data);
-               free_msg(msg);
-               return(0);
-       }
-
-       /* process new cr (before setup indication) */
-//printf("prim = 0x%x, looking for 0x%x\n",frm->prim, (CC_NEW_CR | INDICATION));
-       if (frm->prim == (CC_NEW_CR | INDICATION))
-       {
-
-               /* creating port object */
-               SPRINT(name, "%s-%d-in", mISDNport->ifport->interface->name, mISDNport->portnum);
-               if (!(pdss1 = new Pdss1(PORT_TYPE_DSS1_TE_IN, mISDNport, name, NULL, 0, 0)))
-                       FATAL("Cannot create Port instance.\n");
-               /* l3id will be set from dinfo at message_isdn */
-               pdss1->message_isdn(frm->prim, frm->dinfo, msg->data);
-               free_msg(msg);
-               return(0);
-       }
-
-       if (frm->prim == (CC_RELEASE_CR | INDICATION))
-       {
-               PDEBUG(DEBUG_ISDN, "unhandled message from stack: call ref released (l3id=0x%x)\n", frm->dinfo);
-               free_msg(msg);
-               return(0);
-       }
-       PERROR("unhandled message: prim(0x%x) dinfo(0x%x) msg->len(%d)\n", frm->prim, frm->dinfo, msg->len);
-       return(-EINVAL);
-}
-
-#endif // stacktomanager
-
-
-#ifndef SOCKET_MISDN
+#if 0
 /*
  * sending message that were queued during L1 activation
  * or releasing port if link is down
 /*
  * sending message that were queued during L1 activation
  * or releasing port if link is down
diff --git a/dss1.h b/dss1.h
index ead3c27..f552547 100644 (file)
--- a/dss1.h
+++ b/dss1.h
@@ -15,13 +15,8 @@ class Pdss1 : public PmISDN
        public:
        Pdss1(int type, struct mISDNport *mISDNport, char *portname, struct port_settings *settings, int channel, int exclusive);
        ~Pdss1();
        public:
        Pdss1(int type, struct mISDNport *mISDNport, char *portname, struct port_settings *settings, int channel, int exclusive);
        ~Pdss1();
-#ifdef SOCKET_MISDN
        unsigned int p_m_d_l3id;                /* current l3 process id */
        void message_isdn(unsigned int cmd, unsigned int pid, struct l3_msg *l3m);
        unsigned int p_m_d_l3id;                /* current l3 process id */
        void message_isdn(unsigned int cmd, unsigned int pid, struct l3_msg *l3m);
-#else
-       int p_m_d_l3id;                         /* current l3 process id */
-       void message_isdn(unsigned long prim, unsigned long dinfo, void *data);
-#endif
        int p_m_d_ces;                          /* ntmode: tei&sapi */
        int handler(void);
        int message_epoint(unsigned long epoint_id, int message, union parameter *param);
        int p_m_d_ces;                          /* ntmode: tei&sapi */
        int handler(void);
        int message_epoint(unsigned long epoint_id, int message, union parameter *param);
@@ -36,7 +31,6 @@ class Pdss1 : public PmISDN
        void new_state(int state);              /* set new state */
 //     void isdn_show_send_message(unsigned long prim, msg_t *msg);
        int hunt_bchannel(int exclusive, int channel);
        void new_state(int state);              /* set new state */
 //     void isdn_show_send_message(unsigned long prim, msg_t *msg);
        int hunt_bchannel(int exclusive, int channel);
-#ifdef SOCKET_MISDN
        int received_first_reply_to_setup(unsigned long cmd, int channel, int exclusive);
        void information_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m);
        void setup_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m);
        int received_first_reply_to_setup(unsigned long cmd, int channel, int exclusive);
        void information_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m);
        void setup_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m);
@@ -55,26 +49,6 @@ class Pdss1 : public PmISDN
        void retrieve_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m);
        void suspend_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m);
        void resume_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m);
        void retrieve_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m);
        void suspend_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m);
        void resume_ind(unsigned int cmd, unsigned int pid, struct l3_msg *l3m);
-#else
-       int received_first_reply_to_setup(unsigned long prim, int channel, int exclusive);
-       void information_ind(unsigned long prim, unsigned long dinfo, void *data);
-       void setup_ind(unsigned long prim, unsigned long dinfo, void *data);
-       void setup_acknowledge_ind(unsigned long prim, unsigned long dinfo, void *data);
-       void proceeding_ind(unsigned long prim, unsigned long dinfo, void *data);
-       void alerting_ind(unsigned long prim, unsigned long dinfo, void *data);
-       void connect_ind(unsigned long prim, unsigned long dinfo, void *data);
-       void disconnect_ind(unsigned long prim, unsigned long dinfo, void *data);
-       void release_ind(unsigned long prim, unsigned long dinfo, void *data);
-       void release_complete_ind(unsigned long prim, unsigned long dinfo, void *data);
-       void disconnect_ind_i(unsigned long prim, unsigned long dinfo, void *data);
-       void t312_timeout_ind(unsigned long prim, unsigned long dinfo, void *data);
-       void notify_ind(unsigned long prim, unsigned long dinfo, void *data);
-       void facility_ind(unsigned long prim, unsigned long dinfo, void *data);
-       void hold_ind(unsigned long prim, unsigned long dinfo, void *data);
-       void retrieve_ind(unsigned long prim, unsigned long dinfo, void *data);
-       void suspend_ind(unsigned long prim, unsigned long dinfo, void *data);
-       void resume_ind(unsigned long prim, unsigned long dinfo, void *data);
-#endif
        void message_information(unsigned long epoint_id, int message_id, union parameter *param);
        void message_setup(unsigned long epoint_id, int message_id, union parameter *param);
        void message_notify(unsigned long epoint_id, int message_id, union parameter *param);
        void message_information(unsigned long epoint_id, int message_id, union parameter *param);
        void message_setup(unsigned long epoint_id, int message_id, union parameter *param);
        void message_notify(unsigned long epoint_id, int message_id, union parameter *param);
@@ -87,7 +61,6 @@ class Pdss1 : public PmISDN
        void message_release(unsigned long epoint_id, int message_id, union parameter *param);
 
        /* IE conversion */
        void message_release(unsigned long epoint_id, int message_id, union parameter *param);
 
        /* IE conversion */
-#ifdef SOCKET_MISDN
        void enc_ie_complete(struct l3_msg *l3m, int complete);
        void dec_ie_complete(struct l3_msg *l3m, int *complete);
        void enc_ie_bearer(struct l3_msg *l3m, int coding, int capability, int mode, int rate, int multi, int user);
        void enc_ie_complete(struct l3_msg *l3m, int complete);
        void dec_ie_complete(struct l3_msg *l3m, int *complete);
        void enc_ie_bearer(struct l3_msg *l3m, int coding, int capability, int mode, int rate, int multi, int user);
@@ -124,44 +97,6 @@ class Pdss1 : public PmISDN
        void dec_facility_centrex(struct l3_msg *l3m, unsigned char *cnip, int cnip_len);
        void enc_ie_useruser(struct l3_msg *l3m, int protocol, unsigned char *user, int user_len);
        void dec_ie_useruser(struct l3_msg *l3m, int *protocol, unsigned char *user, int *user_len);
        void dec_facility_centrex(struct l3_msg *l3m, unsigned char *cnip, int cnip_len);
        void enc_ie_useruser(struct l3_msg *l3m, int protocol, unsigned char *user, int user_len);
        void dec_ie_useruser(struct l3_msg *l3m, int *protocol, unsigned char *user, int *user_len);
-#else
-       void enc_ie_complete(unsigned char **ntmode, msg_t *msg, int complete);
-       void dec_ie_complete(unsigned char *p, Q931_info_t *qi, int *complete);
-       void enc_ie_bearer(unsigned char **ntmode, msg_t *msg, int coding, int capability, int mode, int rate, int multi, int user);
-       void dec_ie_bearer(unsigned char *p, Q931_info_t *qi, int *coding, int *capability, int *mode, int *rate, int *multi, int *user);
-       void enc_ie_call_id(unsigned char **ntmode, msg_t *msg, unsigned char *callid, int callid_len);
-       void dec_ie_call_id(unsigned char *p, Q931_info_t *qi, unsigned char *callid, int *callid_len);
-       void enc_ie_called_pn(unsigned char **ntmode, msg_t *msg, int type, int plan, unsigned char *number);
-       void dec_ie_called_pn(unsigned char *p, Q931_info_t *qi, int *type, int *plan, unsigned char *number, int number_len);
-       void enc_ie_calling_pn(unsigned char **ntmode, msg_t *msg, int type, int plan, int present, int screen, unsigned char *number);
-       void dec_ie_calling_pn(unsigned char *p, Q931_info_t *qi, int *type, int *plan, int *present, int *screen, unsigned char *number, int number_len);
-       void enc_ie_connected_pn(unsigned char **ntmode, msg_t *msg, int type, int plan, int present, int screen, unsigned char *number);
-       void dec_ie_connected_pn(unsigned char *p, Q931_info_t *qi, int *type, int *plan, int *present, int *screen, unsigned char *number, int number_len);
-       void enc_ie_cause(unsigned char **ntmode, msg_t *msg, int location, int cause);
-       void dec_ie_cause(unsigned char *p, Q931_info_t *qi, int *location, int *cause);
-       void enc_ie_channel_id(unsigned char **ntmode, msg_t *msg, int exclusive, int channel);
-       void dec_ie_channel_id(unsigned char *p, Q931_info_t *qi, int *exclusive, int *channel);
-       void enc_ie_date(unsigned char **ntmode, msg_t *msg, time_t ti, int seconds);
-       void enc_ie_display(unsigned char **ntmode, msg_t *msg, unsigned char *display);
-       void dec_ie_display(unsigned char *p, Q931_info_t *qi, unsigned char *display, int display_len);
-       void enc_ie_keypad(unsigned char **ntmode, msg_t *msg, unsigned char *keypad);
-       void dec_ie_keypad(unsigned char *p, Q931_info_t *qi, unsigned char *keypad, int keypad_len);
-       void enc_ie_notify(unsigned char **ntmode, msg_t *msg, int notify);
-       void dec_ie_notify(unsigned char *p, Q931_info_t *qi, int *notify);
-       void enc_ie_progress(unsigned char **ntmode, msg_t *msg, int coding, int location, int progress);
-       void dec_ie_progress(unsigned char *p, Q931_info_t *qi, int *coding, int *location, int *progress);
-       void enc_ie_hlc(unsigned char **ntmode, msg_t *msg, int coding, int interpretation, int presentation, int hlc, int exthlc);
-       void dec_ie_hlc(unsigned char *p, Q931_info_t *qi, int *coding, int *interpretation, int *presentation, int *hlc, int *exthlc);
-       void enc_ie_redir_nr(unsigned char **ntmode, msg_t *msg, int type, int plan, int present, int screen, int reason, unsigned char *number);
-       void dec_ie_redir_nr(unsigned char *p, Q931_info_t *qi, int *type, int *plan, int *present, int *screen, int *reason, unsigned char *number, int number_len);
-       void enc_ie_redir_dn(unsigned char **ntmode, msg_t *msg, int type, int plan, int present, unsigned char *number);
-       void dec_ie_redir_dn(unsigned char *p, Q931_info_t *qi, int *type, int *plan, int *present, unsigned char *number, int number_len);
-       void enc_ie_facility(unsigned char **ntmode, msg_t *msg, unsigned char *facility, int facility_len);
-       void dec_ie_facility(unsigned char *p, Q931_info_t *qi, unsigned char *facility, int *facility_len);
-       void dec_facility_centrex(unsigned char *p, Q931_info_t *qi, unsigned char *cnip, int cnip_len);
-       void enc_ie_useruser(unsigned char **ntmode, msg_t *msg, int protocol, unsigned char *user, int user_len);
-       void dec_ie_useruser(unsigned char *p, Q931_info_t *qi, int *protocol, unsigned char *user, int *user_len);
-#endif
 
 };
 
 
 };
 
diff --git a/genrc.c b/genrc.c
index e42abb2..5dabfc1 100644 (file)
--- a/genrc.c
+++ b/genrc.c
@@ -30,16 +30,16 @@ static struct cards {
        int isac;
        int ports;
 } cards[] = {
        int isac;
        int ports;
 } cards[] = {
-       { "AVM Fritz PCI (PNP)", "avmfritz", 0, 1, 1},
+//     { "AVM Fritz PCI (PNP)", "avmfritz", 0, 1, 1},
        { "HFC PCI (Cologne Chip)", "hfcpci", 1, 0, 1},
        { "HFC-4S 4 S/T Ports (Cologne Chip)", "hfcmulti", 1, 0, 4},
        { "HFC-8S 8 S/T Ports (Cologne Chip)", "hfcmulti", 1, 0, 8},
        { "HFC-E1 1 E1 Port (Cologne Chip)", "hfcmulti", 1, 0, 1},
        { "HFC-S USB (Cologne Chip)", "hfcsusb", 1, 0, 1},
        { "HFC PCI (Cologne Chip)", "hfcpci", 1, 0, 1},
        { "HFC-4S 4 S/T Ports (Cologne Chip)", "hfcmulti", 1, 0, 4},
        { "HFC-8S 8 S/T Ports (Cologne Chip)", "hfcmulti", 1, 0, 8},
        { "HFC-E1 1 E1 Port (Cologne Chip)", "hfcmulti", 1, 0, 1},
        { "HFC-S USB (Cologne Chip)", "hfcsusb", 1, 0, 1},
-       { "HFC-S MINI (Cologne Chip)", "hfcsmini", 1, 0, 1},
-       { "XHFC (Cologne Chip)", "xhfc", 1, 0, 1},
-       { "Sedlbaur FAX", "sedlfax", 0, 1, 1},
-       { "Winbond 6692 PCI", "w6692pci", 0, 0, 1},
+//     { "HFC-S MINI (Cologne Chip)", "hfcsmini", 1, 0, 1},
+//     { "XHFC (Cologne Chip)", "xhfc", 1, 0, 1},
+//     { "Sedlbaur FAX", "sedlfax", 0, 1, 1},
+//     { "Winbond 6692 PCI", "w6692pci", 0, 0, 1},
        { NULL, NULL, 0, 0},
 };
 
        { NULL, NULL, 0, 0},
 };
 
@@ -50,6 +50,9 @@ int main(void)
        char input[256];
        char protocol[1024], layermask[1024], types[256];
 
        char input[256];
        char protocol[1024], layermask[1024], types[256];
 
+       printf("This program is outdated and requires update to mISDN V2 API\n");
+       return (0);
+
        printf("\n\nThis program generates a script, which is used to start/stop/restart mISDN\n");
        printf("driver. All configuration of cards is done for using with the LCR.\n");
 
        printf("\n\nThis program generates a script, which is used to start/stop/restart mISDN\n");
        printf("driver. All configuration of cards is done for using with the LCR.\n");
 
diff --git a/ie.cpp b/ie.cpp
index a216703..c44c166 100644 (file)
--- a/ie.cpp
+++ b/ie.cpp
@@ -26,16 +26,8 @@ static void strnncpy(unsigned char *dest, unsigned char *src, int len, int dst_l
 
 
 /* IE_COMPLETE */
 
 
 /* IE_COMPLETE */
-#ifdef SOCKET_MISDN
 void Pdss1::enc_ie_complete(struct l3_msg *l3m, int complete)
 void Pdss1::enc_ie_complete(struct l3_msg *l3m, int complete)
-#else
-void Pdss1::enc_ie_complete(unsigned char **ntmode, msg_t *msg, int complete)
-#endif
 {
 {
-#ifndef SOCKET_MISDN
-       unsigned char *p;
-       Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
-#endif
 
        if (complete<0 || complete>1)
        {
 
        if (complete<0 || complete>1)
        {
@@ -46,37 +38,15 @@ void Pdss1::enc_ie_complete(unsigned char **ntmode, msg_t *msg, int complete)
        if (complete)
        {
                add_trace("complete", NULL, NULL);
        if (complete)
        {
                add_trace("complete", NULL, NULL);
-#ifndef SOCKET_MISDN
-               p = msg_put(msg, 1);
-               if (p_m_d_ntmode)
-               {
-                       *ntmode = p;
-               } else
-                       qi->sending_complete.off = p - (unsigned char *)qi - sizeof(Q931_info_t);
-               p[0] = IE_COMPLETE;
-#else
                l3m->sending_complete++;
                l3m->sending_complete++;
-#endif
        }
 }
 
        }
 }
 
-#ifdef SOCKET_MISDN
 void Pdss1::dec_ie_complete(struct l3_msg *l3m, int *complete)
 void Pdss1::dec_ie_complete(struct l3_msg *l3m, int *complete)
-#else
-void Pdss1::dec_ie_complete(unsigned char *p, Q931_info_t *qi, int *complete)
-#endif
 {
        *complete = 0;
 {
        *complete = 0;
-#ifndef SOCKET_MISDN
-       if (!p_m_d_ntmode)
-       {
-               if (qi->sending_complete.off)
-                       *complete = 1;
-       } else
-#else
        // special case: p is not a pointer, it's a value
        unsigned char p = l3m->sending_complete;
        // special case: p is not a pointer, it's a value
        unsigned char p = l3m->sending_complete;
-#endif
        if (p)
                *complete = 1;
 
        if (p)
                *complete = 1;
 
@@ -86,18 +56,9 @@ void Pdss1::dec_ie_complete(unsigned char *p, Q931_info_t *qi, int *complete)
 
 
 /* IE_BEARER */
 
 
 /* IE_BEARER */
-#ifdef SOCKET_MISDN
 void Pdss1::enc_ie_bearer(struct l3_msg *l3m, int coding, int capability, int mode, int rate, int multi, int user)
 void Pdss1::enc_ie_bearer(struct l3_msg *l3m, int coding, int capability, int mode, int rate, int multi, int user)
-#else
-void Pdss1::enc_ie_bearer(unsigned char **ntmode, msg_t *msg, int coding, int capability, int mode, int rate, int multi, int user)
-#endif
 {
 {
-#ifdef SOCKET_MISDN
        unsigned char p[256];
        unsigned char p[256];
-#else
-       unsigned char *p;
-       Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
-#endif
        int l;
 
        if (coding<0 || coding>3)
        int l;
 
        if (coding<0 || coding>3)
@@ -144,13 +105,6 @@ void Pdss1::enc_ie_bearer(unsigned char **ntmode, msg_t *msg, int coding, int ca
        add_trace("bearer", "user", "%d", user);
 
        l = 2 + (multi>=0) + (user>=0);
        add_trace("bearer", "user", "%d", user);
 
        l = 2 + (multi>=0) + (user>=0);
-#ifndef SOCKET_MISDN
-       p = msg_put(msg, l+2);
-       if (p_m_d_ntmode)
-               *ntmode = p+1;
-       else
-               qi->bearer_capability.off = p - (unsigned char *)qi - sizeof(Q931_info_t);
-#endif
        p[0] = IE_BEARER;
        p[1] = l;
        p[2] = 0x80 + (coding<<5) + capability;
        p[0] = IE_BEARER;
        p[1] = l;
        p[2] = 0x80 + (coding<<5) + capability;
@@ -159,16 +113,10 @@ void Pdss1::enc_ie_bearer(unsigned char **ntmode, msg_t *msg, int coding, int ca
                p[4] = 0x80 + multi;
        if (user >= 0)
                p[4+(multi>=0)] = 0xa0 + user;
                p[4] = 0x80 + multi;
        if (user >= 0)
                p[4+(multi>=0)] = 0xa0 + user;
-#ifdef SOCKET_MISDN
        add_layer3_ie(l3m, p[0], p[1], p+2);
        add_layer3_ie(l3m, p[0], p[1], p+2);
-#endif
 }
 
 }
 
-#ifdef SOCKET_MISDN
 void Pdss1::dec_ie_bearer(struct l3_msg *l3m, int *coding, int *capability, int *mode, int *rate, int *multi, int *user)
 void Pdss1::dec_ie_bearer(struct l3_msg *l3m, int *coding, int *capability, int *mode, int *rate, int *multi, int *user)
-#else
-void Pdss1::dec_ie_bearer(unsigned char *p, Q931_info_t *qi, int *coding, int *capability, int *mode, int *rate, int *multi, int *user)
-#endif
 {
        *coding = -1;
        *capability = -1;
 {
        *coding = -1;
        *capability = -1;
@@ -177,16 +125,7 @@ void Pdss1::dec_ie_bearer(unsigned char *p, Q931_info_t *qi, int *coding, int *c
        *multi = -1;
        *user = -1;
 
        *multi = -1;
        *user = -1;
 
-#ifndef SOCKET_MISDN
-       if (!p_m_d_ntmode)
-       {
-               p = NULL;
-               if (qi->bearer_capability.off)
-                       p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->bearer_capability.off + 1;
-       }
-#else
        unsigned char *p = l3m->bearer_capability;
        unsigned char *p = l3m->bearer_capability;
-#endif
        if (!p)
                return;
        if (p[0] < 2)
        if (!p)
                return;
        if (p[0] < 2)
@@ -223,18 +162,9 @@ void Pdss1::dec_ie_bearer(unsigned char *p, Q931_info_t *qi, int *coding, int *c
 
 
 /* IE_HLC */
 
 
 /* IE_HLC */
-#ifdef SOCKET_MISDN
 void Pdss1::enc_ie_hlc(struct l3_msg *l3m, int coding, int interpretation, int presentation, int hlc, int exthlc)
 void Pdss1::enc_ie_hlc(struct l3_msg *l3m, int coding, int interpretation, int presentation, int hlc, int exthlc)
-#else
-void Pdss1::enc_ie_hlc(unsigned char **ntmode, msg_t *msg, int coding, int interpretation, int presentation, int hlc, int exthlc)
-#endif
 {
 {
-#ifdef SOCKET_MISDN
        unsigned char p[256];
        unsigned char p[256];
-#else
-       unsigned char *p;
-       Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
-#endif
        int l;
 
        if (coding<0 || coding>3)
        int l;
 
        if (coding<0 || coding>3)
@@ -271,13 +201,6 @@ void Pdss1::enc_ie_hlc(unsigned char **ntmode, msg_t *msg, int coding, int inter
                add_trace("hlc", "exthlc", "%d", exthlc);
 
        l = 2 + (exthlc>=0);
                add_trace("hlc", "exthlc", "%d", exthlc);
 
        l = 2 + (exthlc>=0);
-#ifndef SOCKET_MISDN
-       p = msg_put(msg, l+2);
-       if (p_m_d_ntmode)
-               *ntmode = p+1;
-       else
-               qi->hlc.off = p - (unsigned char *)qi - sizeof(Q931_info_t);
-#endif
        p[0] = IE_HLC;
        p[1] = l;
        p[2] = 0x80 + (coding<<5) + (interpretation<<2) + presentation;
        p[0] = IE_HLC;
        p[1] = l;
        p[2] = 0x80 + (coding<<5) + (interpretation<<2) + presentation;
@@ -287,16 +210,10 @@ void Pdss1::enc_ie_hlc(unsigned char **ntmode, msg_t *msg, int coding, int inter
                p[4] = 0x80 + exthlc;
        } else
                p[3] = 0x80 + hlc;
                p[4] = 0x80 + exthlc;
        } else
                p[3] = 0x80 + hlc;
-#ifdef SOCKET_MISDN
        add_layer3_ie(l3m, p[0], p[1], p+2);
        add_layer3_ie(l3m, p[0], p[1], p+2);
-#endif
 }
 
 }
 
-#ifdef SOCKET_MISDN
 void Pdss1::dec_ie_hlc(struct l3_msg *l3m, int *coding, int *interpretation, int *presentation, int *hlc, int *exthlc)
 void Pdss1::dec_ie_hlc(struct l3_msg *l3m, int *coding, int *interpretation, int *presentation, int *hlc, int *exthlc)
-#else
-void Pdss1::dec_ie_hlc(unsigned char *p, Q931_info_t *qi, int *coding, int *interpretation, int *presentation, int *hlc, int *exthlc)
-#endif
 {
        *coding = -1;
        *interpretation = -1;
 {
        *coding = -1;
        *interpretation = -1;
@@ -304,16 +221,7 @@ void Pdss1::dec_ie_hlc(unsigned char *p, Q931_info_t *qi, int *coding, int *inte
        *hlc = -1;
        *exthlc = -1;
 
        *hlc = -1;
        *exthlc = -1;
 
-#ifndef SOCKET_MISDN
-       if (!p_m_d_ntmode)
-       {
-               p = NULL;
-               if (qi->hlc.off)
-                       p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->hlc.off + 1;
-       }
-#else
        unsigned char *p = l3m->hlc;
        unsigned char *p = l3m->hlc;
-#endif
        if (!p)
                return;
        if (p[0] < 2)
        if (!p)
                return;
        if (p[0] < 2)
@@ -341,18 +249,9 @@ void Pdss1::dec_ie_hlc(unsigned char *p, Q931_info_t *qi, int *coding, int *inte
 
 
 /* IE_CALL_ID */
 
 
 /* IE_CALL_ID */
-#ifdef SOCKET_MISDN
 void Pdss1::enc_ie_call_id(struct l3_msg *l3m, unsigned char *callid, int callid_len)
 void Pdss1::enc_ie_call_id(struct l3_msg *l3m, unsigned char *callid, int callid_len)
-#else
-void Pdss1::enc_ie_call_id(unsigned char **ntmode, msg_t *msg, unsigned char *callid, int callid_len)
-#endif
 {
 {
-#ifdef SOCKET_MISDN
        unsigned char p[256];
        unsigned char p[256];
-#else
-       unsigned char *p;
-       Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
-#endif
        int l;
 
        char buffer[25];
        int l;
 
        char buffer[25];
@@ -378,42 +277,20 @@ void Pdss1::enc_ie_call_id(unsigned char **ntmode, msg_t *msg, unsigned char *ca
        add_trace("callid", NULL, "%s", buffer[0]?buffer+1:"<none>");
 
        l = callid_len;
        add_trace("callid", NULL, "%s", buffer[0]?buffer+1:"<none>");
 
        l = callid_len;
-#ifndef SOCKET_MISDN
-       p = msg_put(msg, l+2);
-       if (p_m_d_ntmode)
-               *ntmode = p+1;
-       else
-               qi->call_id.off = p - (unsigned char *)qi - sizeof(Q931_info_t);
-#endif
        p[0] = IE_CALL_ID;
        p[1] = l;
        memcpy(p+2, callid, callid_len);
        p[0] = IE_CALL_ID;
        p[1] = l;
        memcpy(p+2, callid, callid_len);
-#ifdef SOCKET_MISDN
        add_layer3_ie(l3m, p[0], p[1], p+2);
        add_layer3_ie(l3m, p[0], p[1], p+2);
-#endif
 }
 
 }
 
-#ifdef SOCKET_MISDN
 void Pdss1::dec_ie_call_id(struct l3_msg *l3m, unsigned char *callid, int *callid_len)
 void Pdss1::dec_ie_call_id(struct l3_msg *l3m, unsigned char *callid, int *callid_len)
-#else
-void Pdss1::dec_ie_call_id(unsigned char *p, Q931_info_t *qi, unsigned char *callid, int *callid_len)
-#endif
 {
        char buffer[25];
        int i;
 
        *callid_len = -1;
 
 {
        char buffer[25];
        int i;
 
        *callid_len = -1;
 
-#ifndef SOCKET_MISDN
-       if (!p_m_d_ntmode)
-       {
-               p = NULL;
-               if (qi->call_id.off)
-                       p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->call_id.off + 1;
-       }
-#else
        unsigned char *p = l3m->call_id;
        unsigned char *p = l3m->call_id;
-#endif
        if (!p)
                return;
        if (p[0] > 8)
        if (!p)
                return;
        if (p[0] > 8)
@@ -437,18 +314,9 @@ void Pdss1::dec_ie_call_id(unsigned char *p, Q931_info_t *qi, unsigned char *cal
 
 
 /* IE_CALLED_PN */
 
 
 /* IE_CALLED_PN */
-#ifdef SOCKET_MISDN
 void Pdss1::enc_ie_called_pn(struct l3_msg *l3m, int type, int plan, unsigned char *number)
 void Pdss1::enc_ie_called_pn(struct l3_msg *l3m, int type, int plan, unsigned char *number)
-#else
-void Pdss1::enc_ie_called_pn(unsigned char **ntmode, msg_t *msg, int type, int plan, unsigned char *number)
-#endif
 {
 {
-#ifdef SOCKET_MISDN
        unsigned char p[256];
        unsigned char p[256];
-#else
-       unsigned char *p;
-       Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
-#endif
        int l;
 
        if (type<0 || type>7)
        int l;
 
        if (type<0 || type>7)
@@ -472,42 +340,20 @@ void Pdss1::enc_ie_called_pn(unsigned char **ntmode, msg_t *msg, int type, int p
        add_trace("called_pn", "number", "%s", number);
 
        l = 1+strlen((char *)number);
        add_trace("called_pn", "number", "%s", number);
 
        l = 1+strlen((char *)number);
-#ifndef SOCKET_MISDN
-       p = msg_put(msg, l+2);
-       if (p_m_d_ntmode)
-               *ntmode = p+1;
-       else
-               qi->called_nr.off = p - (unsigned char *)qi - sizeof(Q931_info_t);
-#endif
        p[0] = IE_CALLED_PN;
        p[1] = l;
        p[2] = 0x80 + (type<<4) + plan;
        UNCPY((char *)p+3, (char *)number, strlen((char *)number));
        p[0] = IE_CALLED_PN;
        p[1] = l;
        p[2] = 0x80 + (type<<4) + plan;
        UNCPY((char *)p+3, (char *)number, strlen((char *)number));
-#ifdef SOCKET_MISDN
        add_layer3_ie(l3m, p[0], p[1], p+2);
        add_layer3_ie(l3m, p[0], p[1], p+2);
-#endif
 }
 
 }
 
-#ifdef SOCKET_MISDN
 void Pdss1::dec_ie_called_pn(struct l3_msg *l3m, int *type, int *plan, unsigned char *number, int number_len)
 void Pdss1::dec_ie_called_pn(struct l3_msg *l3m, int *type, int *plan, unsigned char *number, int number_len)
-#else
-void Pdss1::dec_ie_called_pn(unsigned char *p, Q931_info_t *qi, int *type, int *plan, unsigned char *number, int number_len)
-#endif
 {
        *type = -1;
        *plan = -1;
        *number = '\0';
 
 {
        *type = -1;
        *plan = -1;
        *number = '\0';
 
-#ifndef SOCKET_MISDN
-       if (!p_m_d_ntmode)
-       {
-               p = NULL;
-               if (qi->called_nr.off)
-                       p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->called_nr.off + 1;
-       }
-#else
        unsigned char *p = l3m->called_nr;
        unsigned char *p = l3m->called_nr;
-#endif
        if (!p)
                return;
        if (p[0] < 2)
        if (!p)
                return;
        if (p[0] < 2)
@@ -527,18 +373,9 @@ void Pdss1::dec_ie_called_pn(unsigned char *p, Q931_info_t *qi, int *type, int *
 
 
 /* IE_CALLING_PN */
 
 
 /* IE_CALLING_PN */
-#ifdef SOCKET_MISDN
 void Pdss1::enc_ie_calling_pn(struct l3_msg *l3m, int type, int plan, int present, int screen, unsigned char *number)
 void Pdss1::enc_ie_calling_pn(struct l3_msg *l3m, int type, int plan, int present, int screen, unsigned char *number)
-#else
-void Pdss1::enc_ie_calling_pn(unsigned char **ntmode, msg_t *msg, int type, int plan, int present, int screen, unsigned char *number)
-#endif
 {
 {
-#ifdef SOCKET_MISDN
        unsigned char p[256];
        unsigned char p[256];
-#else
-       unsigned char *p;
-       Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
-#endif
        int l;
 
        if (type<0 || type>7)
        int l;
 
        if (type<0 || type>7)
@@ -573,13 +410,6 @@ void Pdss1::enc_ie_calling_pn(unsigned char **ntmode, msg_t *msg, int type, int
                l += strlen((char *)number);
        if (present >= 0)
                l += 1;
                l += strlen((char *)number);
        if (present >= 0)
                l += 1;
-#ifndef SOCKET_MISDN
-       p = msg_put(msg, l+2);
-       if (p_m_d_ntmode)
-               *ntmode = p+1;
-       else
-               qi->calling_nr.off = p - (unsigned char *)qi - sizeof(Q931_info_t);
-#endif
        p[0] = IE_CALLING_PN;
        p[1] = l;
        if (present >= 0)
        p[0] = IE_CALLING_PN;
        p[1] = l;
        if (present >= 0)
@@ -594,16 +424,10 @@ void Pdss1::enc_ie_calling_pn(unsigned char **ntmode, msg_t *msg, int type, int
                if (number) if (number[0])
                        UNCPY((char *)p+3, (char *)number, strlen((char *)number));
        }
                if (number) if (number[0])
                        UNCPY((char *)p+3, (char *)number, strlen((char *)number));
        }
-#ifdef SOCKET_MISDN
        add_layer3_ie(l3m, p[0], p[1], p+2);
        add_layer3_ie(l3m, p[0], p[1], p+2);
-#endif
 }
 
 }
 
-#ifdef SOCKET_MISDN
 void Pdss1::dec_ie_calling_pn(struct l3_msg *l3m, int *type, int *plan, int *present, int *screen, unsigned char *number, int number_len)
 void Pdss1::dec_ie_calling_pn(struct l3_msg *l3m, int *type, int *plan, int *present, int *screen, unsigned char *number, int number_len)
-#else
-void Pdss1::dec_ie_calling_pn(unsigned char *p, Q931_info_t *qi, int *type, int *plan, int *present, int *screen, unsigned char *number, int number_len)
-#endif
 {
        *type = -1;
        *plan = -1;
 {
        *type = -1;
        *plan = -1;
@@ -611,16 +435,7 @@ void Pdss1::dec_ie_calling_pn(unsigned char *p, Q931_info_t *qi, int *type, int
        *screen = -1;
        *number = '\0';
 
        *screen = -1;
        *number = '\0';
 
-#ifndef SOCKET_MISDN
-       if (!p_m_d_ntmode)
-       {
-               p = NULL;
-               if (qi->calling_nr.off)
-                       p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->calling_nr.off + 1;
-       }
-#else
        unsigned char *p = l3m->calling_nr;
        unsigned char *p = l3m->calling_nr;
-#endif
        if (!p)
                return;
        if (p[0] < 1)
        if (!p)
                return;
        if (p[0] < 1)
@@ -655,18 +470,9 @@ void Pdss1::dec_ie_calling_pn(unsigned char *p, Q931_info_t *qi, int *type, int
 
 
 /* IE_CONNECTED_PN */
 
 
 /* IE_CONNECTED_PN */
-#ifdef SOCKET_MISDN
 void Pdss1::enc_ie_connected_pn(struct l3_msg *l3m, int type, int plan, int present, int screen, unsigned char *number)
 void Pdss1::enc_ie_connected_pn(struct l3_msg *l3m, int type, int plan, int present, int screen, unsigned char *number)
-#else
-void Pdss1::enc_ie_connected_pn(unsigned char **ntmode, msg_t *msg, int type, int plan, int present, int screen, unsigned char *number)
-#endif
 {
 {
-#ifdef SOCKET_MISDN
        unsigned char p[256];
        unsigned char p[256];
-#else
-       unsigned char *p;
-       Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
-#endif
        int l;
 
        if (type<0 || type>7)
        int l;
 
        if (type<0 || type>7)
@@ -701,13 +507,6 @@ void Pdss1::enc_ie_connected_pn(unsigned char **ntmode, msg_t *msg, int type, in
                l += strlen((char *)number);
        if (present >= 0)
                l += 1;
                l += strlen((char *)number);
        if (present >= 0)
                l += 1;
-#ifndef SOCKET_MISDN
-       p = msg_put(msg, l+2);
-       if (p_m_d_ntmode)
-               *ntmode = p+1;
-       else
-               qi->connected_nr.off = p - (unsigned char *)qi - sizeof(Q931_info_t);
-#endif
        p[0] = IE_CONNECT_PN;
        p[1] = l;
        if (present >= 0)
        p[0] = IE_CONNECT_PN;
        p[1] = l;
        if (present >= 0)
@@ -722,16 +521,10 @@ void Pdss1::enc_ie_connected_pn(unsigned char **ntmode, msg_t *msg, int type, in
                if (number) if (number[0])
                        UNCPY((char *)p+3, (char *)number, strlen((char *)number));
        }
                if (number) if (number[0])
                        UNCPY((char *)p+3, (char *)number, strlen((char *)number));
        }
-#ifdef SOCKET_MISDN
        add_layer3_ie(l3m, p[0], p[1], p+2);
        add_layer3_ie(l3m, p[0], p[1], p+2);
-#endif
 }
 
 }
 
-#ifdef SOCKET_MISDN
 void Pdss1::dec_ie_connected_pn(struct l3_msg *l3m, int *type, int *plan, int *present, int *screen, unsigned char *number, int number_len)
 void Pdss1::dec_ie_connected_pn(struct l3_msg *l3m, int *type, int *plan, int *present, int *screen, unsigned char *number, int number_len)
-#else
-void Pdss1::dec_ie_connected_pn(unsigned char *p, Q931_info_t *qi, int *type, int *plan, int *present, int *screen, unsigned char *number, int number_len)
-#endif
 {
        *type = -1;
        *plan = -1;
 {
        *type = -1;
        *plan = -1;
@@ -739,16 +532,7 @@ void Pdss1::dec_ie_connected_pn(unsigned char *p, Q931_info_t *qi, int *type, in
        *screen = -1;
        *number = '\0';
 
        *screen = -1;
        *number = '\0';
 
-#ifndef SOCKET_MISDN
-       if (!p_m_d_ntmode)
-       {
-               p = NULL;
-               if (qi->connected_nr.off)
-                       p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->connected_nr.off + 1;
-       }
-#else
        unsigned char *p = l3m->connected_nr;
        unsigned char *p = l3m->connected_nr;
-#endif
        if (!p)
                return;
        if (p[0] < 1)
        if (!p)
                return;
        if (p[0] < 1)
@@ -783,18 +567,9 @@ void Pdss1::dec_ie_connected_pn(unsigned char *p, Q931_info_t *qi, int *type, in
 
 
 /* IE_CAUSE */
 
 
 /* IE_CAUSE */
-#ifdef SOCKET_MISDN
 void Pdss1::enc_ie_cause(struct l3_msg *l3m, int location, int cause)
 void Pdss1::enc_ie_cause(struct l3_msg *l3m, int location, int cause)
-#else
-void Pdss1::enc_ie_cause(unsigned char **ntmode, msg_t *msg, int location, int cause)
-#endif
 {
 {
-#ifdef SOCKET_MISDN
        unsigned char p[256];
        unsigned char p[256];
-#else
-       unsigned char *p;
-       Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
-#endif
        int l;
 
        if (location<0 || location>7)
        int l;
 
        if (location<0 || location>7)
@@ -812,66 +587,29 @@ void Pdss1::enc_ie_cause(unsigned char **ntmode, msg_t *msg, int location, int c
        add_trace("cause", "value", "%d", cause);
 
        l = 2;
        add_trace("cause", "value", "%d", cause);
 
        l = 2;
-#ifndef SOCKET_MISDN
-       p = msg_put(msg, l+2);
-       if (p_m_d_ntmode)
-               *ntmode = p+1;
-       else
-               qi->cause.off = p - (unsigned char *)qi - sizeof(Q931_info_t);
-#endif
        p[0] = IE_CAUSE;
        p[1] = l;
        p[2] = 0x80 + location;
        p[3] = 0x80 + cause;
        p[0] = IE_CAUSE;
        p[1] = l;
        p[2] = 0x80 + location;
        p[3] = 0x80 + cause;
-#ifdef SOCKET_MISDN
        add_layer3_ie(l3m, p[0], p[1], p+2);
        add_layer3_ie(l3m, p[0], p[1], p+2);
-#endif
 }
 }
-#ifdef SOCKET_MISDN
 void enc_ie_cause_standalone(struct l3_msg *l3m, int location, int cause)
 void enc_ie_cause_standalone(struct l3_msg *l3m, int location, int cause)
-#else
-void enc_ie_cause_standalone(unsigned char **ntmode, msg_t *msg, int location, int cause)
-#endif
 {
 {
-#ifdef SOCKET_MISDN
        unsigned char p[256];
        unsigned char p[256];
-#else
-       unsigned char *p = msg_put(msg, 4);
-       Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
-       if (ntmode)
-               *ntmode = p+1;
-       else
-               qi->cause.off = p - (unsigned char *)qi - sizeof(Q931_info_t);
-#endif
        p[0] = IE_CAUSE;
        p[1] = 2;
        p[2] = 0x80 + location;
        p[3] = 0x80 + cause;
        p[0] = IE_CAUSE;
        p[1] = 2;
        p[2] = 0x80 + location;
        p[3] = 0x80 + cause;
-#ifdef SOCKET_MISDN
        add_layer3_ie(l3m, p[0], p[1], p+2);
        add_layer3_ie(l3m, p[0], p[1], p+2);
-#endif
 }
 
 
 }
 
 
-#ifdef SOCKET_MISDN
 void Pdss1::dec_ie_cause(struct l3_msg *l3m, int *location, int *cause)
 void Pdss1::dec_ie_cause(struct l3_msg *l3m, int *location, int *cause)
-#else
-void Pdss1::dec_ie_cause(unsigned char *p, Q931_info_t *qi, int *location, int *cause)
-#endif
 {
        *location = -1;
        *cause = -1;
 
 {
        *location = -1;
        *cause = -1;
 
-#ifndef SOCKET_MISDN
-       if (!p_m_d_ntmode)
-       {
-               p = NULL;
-               if (qi->cause.off)
-                       p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->cause.off + 1;
-       }
-#else
        unsigned char *p = l3m->cause;
        unsigned char *p = l3m->cause;
-#endif
        if (!p)
                return;
        if (p[0] < 2)
        if (!p)
                return;
        if (p[0] < 2)
@@ -889,18 +627,9 @@ void Pdss1::dec_ie_cause(unsigned char *p, Q931_info_t *qi, int *location, int *
 
 
 /* IE_CHANNEL_ID */
 
 
 /* IE_CHANNEL_ID */
-#ifdef SOCKET_MISDN
 void Pdss1::enc_ie_channel_id(struct l3_msg *l3m, int exclusive, int channel)
 void Pdss1::enc_ie_channel_id(struct l3_msg *l3m, int exclusive, int channel)
-#else
-void Pdss1::enc_ie_channel_id(unsigned char **ntmode, msg_t *msg, int exclusive, int channel)
-#endif
 {
 {
-#ifdef SOCKET_MISDN
        unsigned char p[256];
        unsigned char p[256];
-#else
-       unsigned char *p;
-       Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
-#endif
        int l;
        int pri = p_m_mISDNport->pri;
 
        int l;
        int pri = p_m_mISDNport->pri;
 
@@ -935,13 +664,6 @@ void Pdss1::enc_ie_channel_id(unsigned char **ntmode, msg_t *msg, int exclusive,
        {
                /* BRI */
                l = 1;
        {
                /* BRI */
                l = 1;
-#ifndef SOCKET_MISDN
-               p = msg_put(msg, l+2);
-               if (p_m_d_ntmode)
-                       *ntmode = p+1;
-               else
-                       qi->channel_id.off = p - (unsigned char *)qi - sizeof(Q931_info_t);
-#endif
                p[0] = IE_CHANNEL_ID;
                p[1] = l;
                if (channel == CHANNEL_NO)
                p[0] = IE_CHANNEL_ID;
                p[1] = l;
                if (channel == CHANNEL_NO)
@@ -949,9 +671,7 @@ void Pdss1::enc_ie_channel_id(unsigned char **ntmode, msg_t *msg, int exclusive,
                else if (channel == CHANNEL_ANY)
                        channel = 3;
                p[2] = 0x80 + (exclusive<<3) + channel;
                else if (channel == CHANNEL_ANY)
                        channel = 3;
                p[2] = 0x80 + (exclusive<<3) + channel;
-#ifdef SOCKET_MISDN
                add_layer3_ie(l3m, p[0], p[1], p+2);
                add_layer3_ie(l3m, p[0], p[1], p+2);
-#endif
        } else
        {
                /* PRI */
        } else
        {
                /* PRI */
@@ -960,61 +680,30 @@ void Pdss1::enc_ie_channel_id(unsigned char **ntmode, msg_t *msg, int exclusive,
                if (channel == CHANNEL_ANY) /* any channel */
                {
                        l = 1;
                if (channel == CHANNEL_ANY) /* any channel */
                {
                        l = 1;
-#ifndef SOCKET_MISDN
-                       p = msg_put(msg, l+2);
-                       if (p_m_d_ntmode)
-                               *ntmode = p+1;
-                       else
-                               qi->channel_id.off = p - (unsigned char *)qi - sizeof(Q931_info_t);
-#endif
                        p[0] = IE_CHANNEL_ID;
                        p[1] = l;
                        p[2] = 0x80 + 0x20 + 0x03;
                        p[0] = IE_CHANNEL_ID;
                        p[1] = l;
                        p[2] = 0x80 + 0x20 + 0x03;
-#ifdef SOCKET_MISDN
                        add_layer3_ie(l3m, p[0], p[1], p+2);
                        add_layer3_ie(l3m, p[0], p[1], p+2);
-#endif
                        return; /* end */
                }
                l = 3;
                        return; /* end */
                }
                l = 3;
-#ifndef SOCKET_MISDN
-               p = msg_put(msg, l+2);
-               if (p_m_d_ntmode)
-                       *ntmode = p+1;
-               else
-                       qi->channel_id.off = p - (unsigned char *)qi - sizeof(Q931_info_t);
-#endif
                p[0] = IE_CHANNEL_ID;
                p[1] = l;
                p[2] = 0x80 + 0x20 + (exclusive<<3) + 0x01;
                p[3] = 0x80 + 3; /* CCITT, Number, B-type */
                p[4] = 0x80 + channel;
                p[0] = IE_CHANNEL_ID;
                p[1] = l;
                p[2] = 0x80 + 0x20 + (exclusive<<3) + 0x01;
                p[3] = 0x80 + 3; /* CCITT, Number, B-type */
                p[4] = 0x80 + channel;
-#ifdef SOCKET_MISDN
                add_layer3_ie(l3m, p[0], p[1], p+2);
                add_layer3_ie(l3m, p[0], p[1], p+2);
-#endif
        }
 }
 
        }
 }
 
-#ifdef SOCKET_MISDN
 void Pdss1::dec_ie_channel_id(struct l3_msg *l3m, int *exclusive, int *channel)
 void Pdss1::dec_ie_channel_id(struct l3_msg *l3m, int *exclusive, int *channel)
-#else
-void Pdss1::dec_ie_channel_id(unsigned char *p, Q931_info_t *qi, int *exclusive, int *channel)
-#endif
 {
        int pri = p_m_mISDNport->pri;
 
        *exclusive = -1;
        *channel = -1;
 
 {
        int pri = p_m_mISDNport->pri;
 
        *exclusive = -1;
        *channel = -1;
 
-#ifndef SOCKET_MISDN
-       if (!p_m_d_ntmode)
-       {
-               p = NULL;
-               if (qi->channel_id.off)
-                       p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->channel_id.off + 1;
-       }
-#else
        unsigned char *p = l3m->channel_id;
        unsigned char *p = l3m->channel_id;
-#endif
        if (!p)
                return;
        if (p[0] < 1)
        if (!p)
                return;
        if (p[0] < 1)
@@ -1108,18 +797,9 @@ void Pdss1::dec_ie_channel_id(unsigned char *p, Q931_info_t *qi, int *exclusive,
 
 
 /* IE_DATE */
 
 
 /* IE_DATE */
-#ifdef SOCKET_MISDN
 void Pdss1::enc_ie_date(struct l3_msg *l3m, time_t ti, int no_seconds)
 void Pdss1::enc_ie_date(struct l3_msg *l3m, time_t ti, int no_seconds)
-#else
-void Pdss1::enc_ie_date(unsigned char **ntmode, msg_t *msg, time_t ti, int no_seconds)
-#endif
 {
 {
-#ifdef SOCKET_MISDN
        unsigned char p[256];
        unsigned char p[256];
-#else
-       unsigned char *p;
-       Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
-#endif
        int l;
 
        struct tm *tm;
        int l;
 
        struct tm *tm;
@@ -1135,13 +815,6 @@ void Pdss1::enc_ie_date(unsigned char **ntmode, msg_t *msg, time_t ti, int no_se
        add_trace("date", "time", "%d:%d:%d", tm->tm_hour, tm->tm_min, tm->tm_sec);
 
        l = 5 + (!no_seconds);
        add_trace("date", "time", "%d:%d:%d", tm->tm_hour, tm->tm_min, tm->tm_sec);
 
        l = 5 + (!no_seconds);
-#ifndef SOCKET_MISDN
-       p = msg_put(msg, l+2);
-       if (p_m_d_ntmode)
-               *ntmode = p+1;
-       else
-               qi->date.off = p - (unsigned char *)qi - sizeof(Q931_info_t);
-#endif
        p[0] = IE_DATE;
        p[1] = l;
        p[2] = tm->tm_year % 100;
        p[0] = IE_DATE;
        p[1] = l;
        p[2] = tm->tm_year % 100;
@@ -1151,25 +824,14 @@ void Pdss1::enc_ie_date(unsigned char **ntmode, msg_t *msg, time_t ti, int no_se
        p[6] = tm->tm_min;
        if (!no_seconds)
                p[7] = tm->tm_sec;
        p[6] = tm->tm_min;
        if (!no_seconds)
                p[7] = tm->tm_sec;
-#ifdef SOCKET_MISDN
        add_layer3_ie(l3m, p[0], p[1], p+2);
        add_layer3_ie(l3m, p[0], p[1], p+2);
-#endif
 }
 
 
 /* IE_DISPLAY */
 }
 
 
 /* IE_DISPLAY */
-#ifdef SOCKET_MISDN
 void Pdss1::enc_ie_display(struct l3_msg *l3m, unsigned char *display)
 void Pdss1::enc_ie_display(struct l3_msg *l3m, unsigned char *display)
-#else
-void Pdss1::enc_ie_display(unsigned char **ntmode, msg_t *msg, unsigned char *display)
-#endif
 {
 {
-#ifdef SOCKET_MISDN
        unsigned char p[256];
        unsigned char p[256];
-#else
-       unsigned char *p;
-       Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
-#endif
        int l;
 
        if (!display[0])
        int l;
 
        if (!display[0])
@@ -1187,39 +849,17 @@ void Pdss1::enc_ie_display(unsigned char **ntmode, msg_t *msg, unsigned char *di
        add_trace("display", NULL, "%s", display);
 
        l = strlen((char *)display);
        add_trace("display", NULL, "%s", display);
 
        l = strlen((char *)display);
-#ifndef SOCKET_MISDN
-       p = msg_put(msg, l+2);
-       if (p_m_d_ntmode)
-               *ntmode = p+1;
-       else
-               qi->display.off = p - (unsigned char *)qi - sizeof(Q931_info_t);
-#endif
        p[0] = IE_DISPLAY;
        p[1] = l;
        UNCPY((char *)p+2, (char *)display, strlen((char *)display));
        p[0] = IE_DISPLAY;
        p[1] = l;
        UNCPY((char *)p+2, (char *)display, strlen((char *)display));
-#ifdef SOCKET_MISDN
        add_layer3_ie(l3m, p[0], p[1], p+2);
        add_layer3_ie(l3m, p[0], p[1], p+2);
-#endif
 }
 
 }
 
-#ifdef SOCKET_MISDN
 void Pdss1::dec_ie_display(struct l3_msg *l3m, unsigned char *display, int display_len)
 void Pdss1::dec_ie_display(struct l3_msg *l3m, unsigned char *display, int display_len)
-#else
-void Pdss1::dec_ie_display(unsigned char *p, Q931_info_t *qi, unsigned char *display, int display_len)
-#endif
 {
        *display = '\0';
 
 {
        *display = '\0';
 
-#ifndef SOCKET_MISDN
-       if (!p_m_d_ntmode)
-       {
-               p = NULL;
-               if (qi->display.off)
-                       p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->display.off + 1;
-       }
-#else
        unsigned char *p = l3m->display;
        unsigned char *p = l3m->display;
-#endif
        if (!p)
                return;
        if (p[0] < 1)
        if (!p)
                return;
        if (p[0] < 1)
@@ -1235,18 +875,9 @@ void Pdss1::dec_ie_display(unsigned char *p, Q931_info_t *qi, unsigned char *dis
 
 
 /* IE_KEYPAD */
 
 
 /* IE_KEYPAD */
-#ifdef SOCKET_MISDN
 void Pdss1::enc_ie_keypad(struct l3_msg *l3m, unsigned char *keypad)
 void Pdss1::enc_ie_keypad(struct l3_msg *l3m, unsigned char *keypad)
-#else
-void Pdss1::enc_ie_keypad(unsigned char **ntmode, msg_t *msg, unsigned char *keypad)
-#endif
 {
 {
-#ifdef SOCKET_MISDN
        unsigned char p[256];
        unsigned char p[256];
-#else
-       unsigned char *p;
-       Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
-#endif
        int l;
 
        if (!keypad[0])
        int l;
 
        if (!keypad[0])
@@ -1258,39 +889,17 @@ void Pdss1::enc_ie_keypad(unsigned char **ntmode, msg_t *msg, unsigned char *key
        add_trace("keypad", NULL, "%s", keypad);
 
        l = strlen((char *)keypad);
        add_trace("keypad", NULL, "%s", keypad);
 
        l = strlen((char *)keypad);
-#ifndef SOCKET_MISDN
-       p = msg_put(msg, l+2);
-       if (p_m_d_ntmode)
-               *ntmode = p+1;
-       else
-               qi->keypad.off = p - (unsigned char *)qi - sizeof(Q931_info_t);
-#endif
        p[0] = IE_KEYPAD;
        p[1] = l;
        UNCPY((char *)p+2, (char *)keypad, strlen((char *)keypad));
        p[0] = IE_KEYPAD;
        p[1] = l;
        UNCPY((char *)p+2, (char *)keypad, strlen((char *)keypad));
-#ifdef SOCKET_MISDN
        add_layer3_ie(l3m, p[0], p[1], p+2);
        add_layer3_ie(l3m, p[0], p[1], p+2);
-#endif
 }
 
 }
 
-#ifdef SOCKET_MISDN
 void Pdss1::dec_ie_keypad(struct l3_msg *l3m, unsigned char *keypad, int keypad_len)
 void Pdss1::dec_ie_keypad(struct l3_msg *l3m, unsigned char *keypad, int keypad_len)
-#else
-void Pdss1::dec_ie_keypad(unsigned char *p, Q931_info_t *qi, unsigned char *keypad, int keypad_len)
-#endif
 {
        *keypad = '\0';
 
 {
        *keypad = '\0';
 
-#ifndef SOCKET_MISDN
-       if (!p_m_d_ntmode)
-       {
-               p = NULL;
-               if (qi->keypad.off)
-                       p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->keypad.off + 1;
-       }
-#else
        unsigned char *p = l3m->keypad;
        unsigned char *p = l3m->keypad;
-#endif
        if (!p)
                return;
        if (p[0] < 1)
        if (!p)
                return;
        if (p[0] < 1)
@@ -1306,18 +915,9 @@ void Pdss1::dec_ie_keypad(unsigned char *p, Q931_info_t *qi, unsigned char *keyp
 
 
 /* IE_NOTIFY */
 
 
 /* IE_NOTIFY */
-#ifdef SOCKET_MISDN
 void Pdss1::enc_ie_notify(struct l3_msg *l3m, int notify)
 void Pdss1::enc_ie_notify(struct l3_msg *l3m, int notify)
-#else
-void Pdss1::enc_ie_notify(unsigned char **ntmode, msg_t *msg, int notify)
-#endif
 {
 {
-#ifdef SOCKET_MISDN
        unsigned char p[256];
        unsigned char p[256];
-#else
-       unsigned char *p;
-       Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
-#endif
        int l;
 
        if (notify<0 || notify>0x7f)
        int l;
 
        if (notify<0 || notify>0x7f)
@@ -1329,39 +929,17 @@ void Pdss1::enc_ie_notify(unsigned char **ntmode, msg_t *msg, int notify)
        add_trace("notify", NULL, "%d", notify);
 
        l = 1;
        add_trace("notify", NULL, "%d", notify);
 
        l = 1;
-#ifndef SOCKET_MISDN
-       p = msg_put(msg, l+2);
-       if (p_m_d_ntmode)
-               *ntmode = p+1;
-       else
-               qi->notify.off = p - (unsigned char *)qi - sizeof(Q931_info_t);
-#endif
        p[0] = IE_NOTIFY;
        p[1] = l;
        p[2] = 0x80 + notify;
        p[0] = IE_NOTIFY;
        p[1] = l;
        p[2] = 0x80 + notify;
-#ifdef SOCKET_MISDN
        add_layer3_ie(l3m, p[0], p[1], p+2);
        add_layer3_ie(l3m, p[0], p[1], p+2);
-#endif
 }
 
 }
 
-#ifdef SOCKET_MISDN
 void Pdss1::dec_ie_notify(struct l3_msg *l3m, int *notify)
 void Pdss1::dec_ie_notify(struct l3_msg *l3m, int *notify)
-#else
-void Pdss1::dec_ie_notify(unsigned char *p, Q931_info_t *qi, int *notify)
-#endif
 {
        *notify = -1;
 
 {
        *notify = -1;
 
-#ifndef SOCKET_MISDN
-       if (!p_m_d_ntmode)
-       {
-               p = NULL;
-               if (qi->notify.off)
-                       p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->notify.off + 1;
-       }
-#else
        unsigned char *p = l3m->notify;
        unsigned char *p = l3m->notify;
-#endif
        if (!p)
                return;
        if (p[0] < 1)
        if (!p)
                return;
        if (p[0] < 1)
@@ -1377,18 +955,9 @@ void Pdss1::dec_ie_notify(unsigned char *p, Q931_info_t *qi, int *notify)
 
 
 /* IE_PROGRESS */
 
 
 /* IE_PROGRESS */
-#ifdef SOCKET_MISDN
 void Pdss1::enc_ie_progress(struct l3_msg *l3m, int coding, int location, int progress)
 void Pdss1::enc_ie_progress(struct l3_msg *l3m, int coding, int location, int progress)
-#else
-void Pdss1::enc_ie_progress(unsigned char **ntmode, msg_t *msg, int coding, int location, int progress)
-#endif
 {
 {
-#ifdef SOCKET_MISDN
        unsigned char p[256];
        unsigned char p[256];
-#else
-       unsigned char *p;
-       Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
-#endif
        int l;
 
        if (coding<0 || coding>0x03)
        int l;
 
        if (coding<0 || coding>0x03)
@@ -1412,42 +981,20 @@ void Pdss1::enc_ie_progress(unsigned char **ntmode, msg_t *msg, int coding, int
        add_trace("progress", "indicator", "%d", progress);
 
        l = 2;
        add_trace("progress", "indicator", "%d", progress);
 
        l = 2;
-#ifndef SOCKET_MISDN
-       p = msg_put(msg, l+2);
-       if (p_m_d_ntmode)
-               *ntmode = p+1;
-       else
-               qi->progress.off = p - (unsigned char *)qi - sizeof(Q931_info_t);
-#endif
        p[0] = IE_PROGRESS;
        p[1] = l;
        p[2] = 0x80 + (coding<<5) + location;
        p[3] = 0x80 + progress;
        p[0] = IE_PROGRESS;
        p[1] = l;
        p[2] = 0x80 + (coding<<5) + location;
        p[3] = 0x80 + progress;
-#ifdef SOCKET_MISDN
        add_layer3_ie(l3m, p[0], p[1], p+2);
        add_layer3_ie(l3m, p[0], p[1], p+2);
-#endif
 }
 
 }
 
-#ifdef SOCKET_MISDN
 void Pdss1::dec_ie_progress(struct l3_msg *l3m, int *coding, int *location, int *progress)
 void Pdss1::dec_ie_progress(struct l3_msg *l3m, int *coding, int *location, int *progress)
-#else
-void Pdss1::dec_ie_progress(unsigned char *p, Q931_info_t *qi, int *coding, int *location, int *progress)
-#endif
 {
        *coding = -1;
        *location = -1;
        *progress = -1;
 
 {
        *coding = -1;
        *location = -1;
        *progress = -1;
 
-#ifndef SOCKET_MISDN
-       if (!p_m_d_ntmode)
-       {
-               p = NULL;
-               if (qi->progress.off)
-                       p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->progress.off + 1;
-       }
-#else
        unsigned char *p = l3m->progress;
        unsigned char *p = l3m->progress;
-#endif
        if (!p)
                return;
        if (p[0] < 1)
        if (!p)
                return;
        if (p[0] < 1)
@@ -1467,18 +1014,9 @@ void Pdss1::dec_ie_progress(unsigned char *p, Q931_info_t *qi, int *coding, int
 
 
 /* IE_REDIR_NR (redirecting = during MT_SETUP) */
 
 
 /* IE_REDIR_NR (redirecting = during MT_SETUP) */
-#ifdef SOCKET_MISDN
 void Pdss1::enc_ie_redir_nr(struct l3_msg *l3m, int type, int plan, int present, int screen, int reason, unsigned char *number)
 void Pdss1::enc_ie_redir_nr(struct l3_msg *l3m, int type, int plan, int present, int screen, int reason, unsigned char *number)
-#else
-void Pdss1::enc_ie_redir_nr(unsigned char **ntmode, msg_t *msg, int type, int plan, int present, int screen, int reason, unsigned char *number)
-#endif
 {
 {
-#ifdef SOCKET_MISDN
        unsigned char p[256];
        unsigned char p[256];
-#else
-       unsigned char *p;
-       Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
-#endif
        int l;
 
        if (type<0 || type>7)
        int l;
 
        if (type<0 || type>7)
@@ -1523,13 +1061,6 @@ void Pdss1::enc_ie_redir_nr(unsigned char **ntmode, msg_t *msg, int type, int pl
                if (reason >= 0)
                        l += 1;
        }
                if (reason >= 0)
                        l += 1;
        }
-#ifndef SOCKET_MISDN
-       p = msg_put(msg, l+2);
-       if (p_m_d_ntmode)
-               *ntmode = p+1;
-       else
-               qi->redirect_nr.off = p - (unsigned char *)qi - sizeof(Q931_info_t);
-#endif
        p[0] = IE_REDIR_NR;
        p[1] = l;
        if (present >= 0)
        p[0] = IE_REDIR_NR;
        p[1] = l;
        if (present >= 0)
@@ -1554,16 +1085,10 @@ void Pdss1::enc_ie_redir_nr(unsigned char **ntmode, msg_t *msg, int type, int pl
                if (number) if (number[0])
                        UNCPY((char *)p+3, (char *)number, strlen((char *)number));
        }
                if (number) if (number[0])
                        UNCPY((char *)p+3, (char *)number, strlen((char *)number));
        }
-#ifdef SOCKET_MISDN
        add_layer3_ie(l3m, p[0], p[1], p+2);
        add_layer3_ie(l3m, p[0], p[1], p+2);
-#endif
 }
 
 }
 
-#ifdef SOCKET_MISDN
 void Pdss1::dec_ie_redir_nr(struct l3_msg *l3m, int *type, int *plan, int *present, int *screen, int *reason, unsigned char *number, int number_len)
 void Pdss1::dec_ie_redir_nr(struct l3_msg *l3m, int *type, int *plan, int *present, int *screen, int *reason, unsigned char *number, int number_len)
-#else
-void Pdss1::dec_ie_redir_nr(unsigned char *p, Q931_info_t *qi, int *type, int *plan, int *present, int *screen, int *reason, unsigned char *number, int number_len)
-#endif
 {
        *type = -1;
        *plan = -1;
 {
        *type = -1;
        *plan = -1;
@@ -1572,16 +1097,7 @@ void Pdss1::dec_ie_redir_nr(unsigned char *p, Q931_info_t *qi, int *type, int *p
        *reason = -1;
        *number = '\0';
 
        *reason = -1;
        *number = '\0';
 
-#ifndef SOCKET_MISDN
-       if (!p_m_d_ntmode)
-       {
-               p = NULL;
-               if (qi->redirect_nr.off)
-                       p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->redirect_nr.off + 1;
-       }
-#else
        unsigned char *p = l3m->redirect_nr;
        unsigned char *p = l3m->redirect_nr;
-#endif
        if (!p)
                return;
        if (p[0] < 1)
        if (!p)
                return;
        if (p[0] < 1)
@@ -1619,18 +1135,9 @@ void Pdss1::dec_ie_redir_nr(unsigned char *p, Q931_info_t *qi, int *type, int *p
 
 
 /* IE_REDIR_DN (redirection = during MT_NOTIFY) */
 
 
 /* IE_REDIR_DN (redirection = during MT_NOTIFY) */
-#ifdef SOCKET_MISDN
 void Pdss1::enc_ie_redir_dn(struct l3_msg *l3m, int type, int plan, int present, unsigned char *number)
 void Pdss1::enc_ie_redir_dn(struct l3_msg *l3m, int type, int plan, int present, unsigned char *number)
-#else
-void Pdss1::enc_ie_redir_dn(unsigned char **ntmode, msg_t *msg, int type, int plan, int present, unsigned char *number)
-#endif
 {
 {
-#ifdef SOCKET_MISDN
        unsigned char p[256];
        unsigned char p[256];
-#else
-       unsigned char *p;
-       Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
-#endif
        int l;
 
        if (type<0 || type>7)
        int l;
 
        if (type<0 || type>7)
@@ -1659,13 +1166,6 @@ void Pdss1::enc_ie_redir_dn(unsigned char **ntmode, msg_t *msg, int type, int pl
                l += strlen((char *)number);
        if (present >= 0)
                l += 1;
                l += strlen((char *)number);
        if (present >= 0)
                l += 1;
-#ifndef SOCKET_MISDN
-       p = msg_put(msg, l+2);
-       if (p_m_d_ntmode)
-               *ntmode = p+1;
-       else
-               qi->redirect_dn.off = p - (unsigned char *)qi - sizeof(Q931_info_t);
-#endif
        p[0] = IE_REDIR_DN;
        p[1] = l;
        if (present >= 0)
        p[0] = IE_REDIR_DN;
        p[1] = l;
        if (present >= 0)
@@ -1680,32 +1180,17 @@ void Pdss1::enc_ie_redir_dn(unsigned char **ntmode, msg_t *msg, int type, int pl
                if (number)
                        UNCPY((char *)p+3, (char *)number, strlen((char *)number));
        }
                if (number)
                        UNCPY((char *)p+3, (char *)number, strlen((char *)number));
        }
-#ifdef SOCKET_MISDN
        add_layer3_ie(l3m, p[0], p[1], p+2);
        add_layer3_ie(l3m, p[0], p[1], p+2);
-#endif
 }
 
 }
 
-#ifdef SOCKET_MISDN
 void Pdss1::dec_ie_redir_dn(struct l3_msg *l3m, int *type, int *plan, int *present, unsigned char *number, int number_len)
 void Pdss1::dec_ie_redir_dn(struct l3_msg *l3m, int *type, int *plan, int *present, unsigned char *number, int number_len)
-#else
-void Pdss1::dec_ie_redir_dn(unsigned char *p, Q931_info_t *qi, int *type, int *plan, int *present, unsigned char *number, int number_len)
-#endif
 {
        *type = -1;
        *plan = -1;
        *present = -1;
        *number = '\0';
 
 {
        *type = -1;
        *plan = -1;
        *present = -1;
        *number = '\0';
 
-#ifndef SOCKET_MISDN
-       if (!p_m_d_ntmode)
-       {
-               p = NULL;
-               if (qi->redirect_dn.off)
-                       p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->redirect_dn.off + 1;
-       }
-#else
        unsigned char *p = l3m->redirect_dn;
        unsigned char *p = l3m->redirect_dn;
-#endif
        if (!p)
                return;
        if (p[0] < 1)
        if (!p)
                return;
        if (p[0] < 1)
@@ -1733,18 +1218,9 @@ void Pdss1::dec_ie_redir_dn(unsigned char *p, Q931_info_t *qi, int *type, int *p
 
 
 /* IE_FACILITY */
 
 
 /* IE_FACILITY */
-#ifdef SOCKET_MISDN
 void Pdss1::enc_ie_facility(struct l3_msg *l3m, unsigned char *facility, int facility_len)
 void Pdss1::enc_ie_facility(struct l3_msg *l3m, unsigned char *facility, int facility_len)
-#else
-void Pdss1::enc_ie_facility(unsigned char **ntmode, msg_t *msg, unsigned char *facility, int facility_len)
-#endif
 {
 {
-#ifdef SOCKET_MISDN
        unsigned char p[256];
        unsigned char p[256];
-#else
-       unsigned char *p;
-       Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
-#endif
        int l;
 
        char buffer[768];
        int l;
 
        char buffer[768];
@@ -1765,42 +1241,20 @@ void Pdss1::enc_ie_facility(unsigned char **ntmode, msg_t *msg, unsigned char *f
        add_trace("facility", NULL, "%s", buffer+1);
 
        l = facility_len;
        add_trace("facility", NULL, "%s", buffer+1);
 
        l = facility_len;
-#ifndef SOCKET_MISDN
-       p = msg_put(msg, l+2);
-       if (p_m_d_ntmode)
-               *ntmode = p+1;
-       else
-               qi->facility.off = p - (unsigned char *)qi - sizeof(Q931_info_t);
-#endif
        p[0] = IE_FACILITY;
        p[1] = l;
        memcpy(p+2, facility, facility_len);
        p[0] = IE_FACILITY;
        p[1] = l;
        memcpy(p+2, facility, facility_len);
-#ifdef SOCKET_MISDN
        add_layer3_ie(l3m, p[0], p[1], p+2);
        add_layer3_ie(l3m, p[0], p[1], p+2);
-#endif
 }
 
 }
 
-#ifdef SOCKET_MISDN
 void Pdss1::dec_ie_facility(struct l3_msg *l3m, unsigned char *facility, int *facility_len)
 void Pdss1::dec_ie_facility(struct l3_msg *l3m, unsigned char *facility, int *facility_len)
-#else
-void Pdss1::dec_ie_facility(unsigned char *p, Q931_info_t *qi, unsigned char *facility, int *facility_len)
-#endif
 {
        char debug[768];
        int i;
 
        *facility_len = 0;
 
 {
        char debug[768];
        int i;
 
        *facility_len = 0;
 
-#ifndef SOCKET_MISDN
-       if (!p_m_d_ntmode)
-       {
-               p = NULL;
-               if (qi->facility.off)
-                       p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->facility.off + 1;
-       }
-#else
        unsigned char *p = l3m->facility;
        unsigned char *p = l3m->facility;
-#endif
        if (!p)
                return;
 
        if (!p)
                return;
 
@@ -1819,11 +1273,7 @@ void Pdss1::dec_ie_facility(unsigned char *p, Q931_info_t *qi, unsigned char *fa
 }
 
 
 }
 
 
-#ifdef SOCKET_MISDN
 void Pdss1::dec_facility_centrex(struct l3_msg *l3m, unsigned char *cnip, int cnip_len)
 void Pdss1::dec_facility_centrex(struct l3_msg *l3m, unsigned char *cnip, int cnip_len)
-#else
-void Pdss1::dec_facility_centrex(unsigned char *p, Q931_info_t *qi, unsigned char *cnip, int cnip_len)
-#endif
 {
        unsigned char centrex[256];
        char debug[768];
 {
        unsigned char centrex[256];
        char debug[768];
@@ -1831,11 +1281,7 @@ void Pdss1::dec_facility_centrex(unsigned char *p, Q931_info_t *qi, unsigned cha
        int i = 0, j;
        *cnip = '\0';
 
        int i = 0, j;
        *cnip = '\0';
 
-#ifdef SOCKET_MISDN
        dec_ie_facility(l3m, centrex, &facility_len);
        dec_ie_facility(l3m, centrex, &facility_len);
-#else
-       dec_ie_facility(p, qi, centrex, &facility_len);
-#endif
        if (facility_len >= 2)
        {
                if (centrex[i++] != CENTREX_FAC)
        if (facility_len >= 2)
        {
                if (centrex[i++] != CENTREX_FAC)
@@ -1874,18 +1320,9 @@ void Pdss1::dec_facility_centrex(unsigned char *p, Q931_info_t *qi, unsigned cha
 
 
 /* IE_USERUSER */
 
 
 /* IE_USERUSER */
-#ifdef SOCKET_MISDN
 void Pdss1::enc_ie_useruser(struct l3_msg *l3m, int protocol, unsigned char *user, int user_len)
 void Pdss1::enc_ie_useruser(struct l3_msg *l3m, int protocol, unsigned char *user, int user_len)
-#else
-void Pdss1::enc_ie_useruser(unsigned char **ntmode, msg_t *msg, int protocol, unsigned char *user, int user_len)
-#endif
 {
 {
-#ifdef SOCKET_MISDN
        unsigned char p[256];
        unsigned char p[256];
-#else
-       unsigned char *p;
-       Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
-#endif
        int l;
 
        char buffer[768];
        int l;
 
        char buffer[768];
@@ -1912,27 +1349,14 @@ void Pdss1::enc_ie_useruser(unsigned char **ntmode, msg_t *msg, int protocol, un
        add_trace("useruser", "value", "%s", buffer);
 
        l = user_len;
        add_trace("useruser", "value", "%s", buffer);
 
        l = user_len;
-#ifndef SOCKET_MISDN
-       p = msg_put(msg, l+3);
-       if (p_m_d_ntmode)
-               *ntmode = p+1;
-       else
-               qi->useruser.off = p - (unsigned char *)qi - sizeof(Q931_info_t);
-#endif
        p[0] = IE_USER_USER;
        p[1] = l;
        p[2] = 0x80 + protocol;
        memcpy(p+3, user, user_len);
        p[0] = IE_USER_USER;
        p[1] = l;
        p[2] = 0x80 + protocol;
        memcpy(p+3, user, user_len);
-#ifdef SOCKET_MISDN
        add_layer3_ie(l3m, p[0], p[1], p+2);
        add_layer3_ie(l3m, p[0], p[1], p+2);
-#endif
 }
 
 }
 
-#ifdef SOCKET_MISDN
 void Pdss1::dec_ie_useruser(struct l3_msg *l3m, int *protocol, unsigned char *user, int *user_len)
 void Pdss1::dec_ie_useruser(struct l3_msg *l3m, int *protocol, unsigned char *user, int *user_len)
-#else
-void Pdss1::dec_ie_useruser(unsigned char *p, Q931_info_t *qi, int *protocol, unsigned char *user, int *user_len)
-#endif
 {
        char buffer[768];
        int i;
 {
        char buffer[768];
        int i;
@@ -1940,16 +1364,7 @@ void Pdss1::dec_ie_useruser(unsigned char *p, Q931_info_t *qi, int *protocol, un
        *user_len = 0;
        *protocol = -1;
 
        *user_len = 0;
        *protocol = -1;
 
-#ifndef SOCKET_MISDN
-       if (!p_m_d_ntmode)
-       {
-               p = NULL;
-               if (qi->useruser.off)
-                       p = (unsigned char *)qi + sizeof(Q931_info_t) + qi->useruser.off + 1;
-       }
-#else
        unsigned char *p = l3m->useruser;
        unsigned char *p = l3m->useruser;
-#endif
        if (!p)
                return;
 
        if (!p)
                return;
 
index f8f7bdc..1adc838 100644 (file)
@@ -187,7 +187,6 @@ static int inter_ptmp(struct interface *interface, char *filename, int line, cha
 #endif
 static int inter_nt(struct interface *interface, char *filename, int line, char *parameter, char *value)
 {
 #endif
 static int inter_nt(struct interface *interface, char *filename, int line, char *parameter, char *value)
 {
-#ifdef SOCKET_MISDN
        struct interface_port *ifport;
 
        /* port in chain ? */
        struct interface_port *ifport;
 
        /* port in chain ? */
@@ -207,7 +206,6 @@ static int inter_nt(struct interface *interface, char *filename, int line, char
                return(-1);
        }
        ifport->nt = 1;
                return(-1);
        }
        ifport->nt = 1;
-#endif
        return(0);
 }
 static int inter_tones(struct interface *interface, char *filename, int line, char *parameter, char *value)
        return(0);
 }
 static int inter_tones(struct interface *interface, char *filename, int line, char *parameter, char *value)
@@ -875,11 +873,7 @@ struct interface_param interface_param[] = {
 
        {"nt", &inter_nt, "",
        "The given port above is opened in NT-mode.\n"
 
        {"nt", &inter_nt, "",
        "The given port above is opened in NT-mode.\n"
-#ifdef SOCKET_MISDN
        "This is required on interfaces that support both NT-mode and TE-mode.\n"
        "This is required on interfaces that support both NT-mode and TE-mode.\n"
-#else
-       "This parameter is only required for socket based mISDN driver.\n"
-#endif
        "This parameter must follow a 'port' parameter."},
 
        {"layer2hold", &inter_l2hold, "yes | no",
        "This parameter must follow a 'port' parameter."},
 
        {"layer2hold", &inter_l2hold, "yes | no",
index f771609..188d718 100644 (file)
@@ -359,7 +359,7 @@ int debug_epoint(struct admin_message *msg, struct admin_message *m, int line, i
        }
        /* loop all related ports */
        ltee = 0;
        }
        /* loop all related ports */
        ltee = 0;
-       j = msg->u.s.interfaces+msg->u.s.joins+msg->u.s.epoints;
+       j = msg->u.s.interfaces+msg->u.s.remotes+msg->u.s.joins+msg->u.s.epoints;
        jj = j + msg->u.s.ports;
        while(j < jj)
        {
        jj = j + msg->u.s.ports;
        while(j < jj)
        {
@@ -416,7 +416,7 @@ int debug_join(struct admin_message *msg, struct admin_message *m, int line, int
                addstr(buffer);
        }
        /* find number of epoints */
                addstr(buffer);
        }
        /* find number of epoints */
-       j = msg->u.s.interfaces+msg->u.s.joins;
+       j = msg->u.s.interfaces+msg->u.s.remotes+msg->u.s.joins;
        jj = j + msg->u.s.epoints;
        i = 0;
        while(j < jj)
        jj = j + msg->u.s.epoints;
        i = 0;
        while(j < jj)
@@ -426,7 +426,7 @@ int debug_join(struct admin_message *msg, struct admin_message *m, int line, int
                j++;
        }
        /* loop all related endpoints */
                j++;
        }
        /* loop all related endpoints */
-       j = msg->u.s.interfaces+msg->u.s.joins;
+       j = msg->u.s.interfaces+msg->u.s.remotes+msg->u.s.joins;
        jj = j + msg->u.s.epoints;
        while(j < jj)
        {
        jj = j + msg->u.s.epoints;
        while(j < jj)
        {
@@ -778,7 +778,7 @@ char *admin_state(int sock, char *argv[])
                                                        if (m[i].u.i.port[j])
                                                        {
                                                                /* search for port */
                                                        if (m[i].u.i.port[j])
                                                        {
                                                                /* search for port */
-                                                               l = msg.u.s.interfaces+msg.u.s.joins+msg.u.s.epoints;
+                                                               l = msg.u.s.interfaces+msg.u.s.remotes+msg.u.s.joins+msg.u.s.epoints;
                                                                ll = l+msg.u.s.ports;
                                                                while(l < ll)
                                                                {
                                                                ll = l+msg.u.s.ports;
                                                                while(l < ll)
                                                                {
@@ -834,7 +834,7 @@ char *admin_state(int sock, char *argv[])
                        i++;
                        anything = 1;
                }
                        i++;
                        anything = 1;
                }
-               i = 0;
+               i = msg.u.s.interfaces;
                ii = i + msg.u.s.remotes;
                while(i < ii)
                {
                ii = i + msg.u.s.remotes;
                while(i < ii)
                {
@@ -853,7 +853,7 @@ char *admin_state(int sock, char *argv[])
        if (show_calls == 1)
        {
                anything = 0;
        if (show_calls == 1)
        {
                anything = 0;
-               i = msg.u.s.interfaces+msg.u.s.joins;
+               i = msg.u.s.interfaces+msg.u.s.remotes+msg.u.s.joins;
                ii = i+msg.u.s.epoints;
                while(i < ii)
                {
                ii = i+msg.u.s.epoints;
                while(i < ii)
                {
@@ -892,7 +892,7 @@ char *admin_state(int sock, char *argv[])
                        i++;
                        anything = 1;
                }
                        i++;
                        anything = 1;
                }
-               j = msg.u.s.interfaces;
+               j = msg.u.s.interfaces+msg.u.s.remotes;
                jj = j+msg.u.s.joins;
                while(j < jj)
                {
                jj = j+msg.u.s.joins;
                while(j < jj)
                {
@@ -901,7 +901,7 @@ char *admin_state(int sock, char *argv[])
                        color(white);
                        SPRINT(buffer, "(%d):", m[j].u.j.serial);
                        addstr(buffer);
                        color(white);
                        SPRINT(buffer, "(%d):", m[j].u.j.serial);
                        addstr(buffer);
-                       i = msg.u.s.interfaces+msg.u.s.joins;
+                       i = msg.u.s.interfaces+msg.u.s.remotes+msg.u.s.joins;
                        ii = i+msg.u.s.epoints;
                        while(i < ii)
                        {
                        ii = i+msg.u.s.epoints;
                        while(i < ii)
                        {
@@ -943,7 +943,7 @@ char *admin_state(int sock, char *argv[])
        {
                /* show all ports with no epoint */
                anything = 0;
        {
                /* show all ports with no epoint */
                anything = 0;
-               i = msg.u.s.interfaces+msg.u.s.joins+msg.u.s.epoints;
+               i = msg.u.s.interfaces+msg.u.s.remotes+msg.u.s.joins+msg.u.s.epoints;
                ii = i+msg.u.s.ports;
                while(i < ii)
                {
                ii = i+msg.u.s.ports;
                while(i < ii)
                {
@@ -963,7 +963,7 @@ char *admin_state(int sock, char *argv[])
 
                /* show all epoints with no call */
                anything = 0;
 
                /* show all epoints with no call */
                anything = 0;
-               i = msg.u.s.interfaces+msg.u.s.joins;
+               i = msg.u.s.interfaces+msg.u.s.remotes+msg.u.s.joins;
                ii = i+msg.u.s.epoints;
                while(i < ii)
                {
                ii = i+msg.u.s.epoints;
                while(i < ii)
                {
@@ -983,7 +983,7 @@ char *admin_state(int sock, char *argv[])
 
                /* show all joins */
                anything = 0;
 
                /* show all joins */
                anything = 0;
-               i = msg.u.s.interfaces;
+               i = msg.u.s.interfaces+msg.u.s.remotes;
                ii = i+msg.u.s.joins;
                while(i < ii)
                {
                ii = i+msg.u.s.joins;
                while(i < ii)
                {
index 53cb774..874d2a6 100644 (file)
--- a/mISDN.cpp
+++ b/mISDN.cpp
 
 #include "main.h"
 #include "myisdn.h"
 
 #include "main.h"
 #include "myisdn.h"
-#ifndef SOCKET_MISDN
-// old mISDN
-extern "C" {
-#include <mISDNuser/net_l2.h>
-}
-
-#ifndef CMX_TXDATA_ON
-#define OLD_MISDN
-#endif
-#ifndef CMX_TXDATA_OFF
-#define OLD_MISDN
-#endif
-#ifndef CMX_DELAY
-#define OLD_MISDN
-#endif
-#ifndef PIPELINE_CFG
-#define OLD_MISDN
-#endif
-#ifndef CMX_TX_DATA
-#define OLD_MISDN
-#endif
 
 
-#ifdef OLD_MISDN
-#warning
-#warning *********************************************************
-#warning *
-#warning * It seems that you use an older version of mISDN.
-#warning * Features like voice recording or echo will not work.
-#warning * Also it causes problems with loading modules and may
-#warning * not work at all.
-#warning *
-#warning * Please upgrade to newer version. A working version can
-#warning * be found at www.linux-call-router.de.
-#warning *
-#warning * Do not use the mISDN_1_1 branch, it does not have all
-#warning * the features that are required. Use the master branch
-#warning * instead.
-#warning *
-#warning *********************************************************
-#warning
-#error
-#endif
-
-#ifndef ISDN_PID_L4_B_USER
-#define ISDN_PID_L4_B_USER 0x440000ff
-#endif
-
-#else
-// socket mISDN
 extern "C" {
 }
 #include <q931.h>
 extern "C" {
 }
 #include <q931.h>
@@ -74,7 +26,6 @@ extern "C" {
 #define container_of(ptr, type, member) ({                     \
        const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
        (type *)( (char *)__mptr - offsetof(type,member) );})
 #define container_of(ptr, type, member) ({                     \
        const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
        (type *)( (char *)__mptr - offsetof(type,member) );})
-#endif
 
 // timeouts if activating/deactivating response from mISDN got lost
 #define B_TIMER_ACTIVATING 1 // seconds
 
 // timeouts if activating/deactivating response from mISDN got lost
 #define B_TIMER_ACTIVATING 1 // seconds
@@ -87,7 +38,6 @@ struct mISDNport *mISDNport_first;
 unsigned char mISDN_rand[256];
 int mISDN_rand_count = 0;
 
 unsigned char mISDN_rand[256];
 int mISDN_rand_count = 0;
 
-#ifdef SOCKET_MISDN
 unsigned long mt_assign_pid = ~0;
 
 int mISDNsocket = -1;
 unsigned long mt_assign_pid = ~0;
 
 int mISDNsocket = -1;
@@ -137,77 +87,6 @@ void mISDN_deinitialize(void)
        if (mISDNsocket > -1)
                close(mISDNsocket);
 }
        if (mISDNsocket > -1)
                close(mISDNsocket);
 }
-#else
-int entity = 0; /* used for udevice */
-int mISDNdevice = -1; /* the device handler and port list */
-
-int mISDN_initialize(void)
-{
-       char debug_log[128];
-       unsigned char buff[1025];
-       iframe_t *frm = (iframe_t *)buff;
-       int ret;
-
-       /* initialize stuff of the NT lib */
-       if (options.deb & DEBUG_STACK)
-       {
-               global_debug = 0xffffffff & ~DBGM_MSG;
-//             global_debug = DBGM_L3DATA;
-       } else
-               global_debug = DBGM_MAN;
-       SPRINT(debug_log, "%s/debug.log", INSTALL_DATA);
-       if (options.deb & DEBUG_LOG)
-               debug_init(global_debug, debug_log, debug_log, debug_log);
-       else
-               debug_init(global_debug, NULL, NULL, NULL);
-       msg_init();
-
-       /* open mISDNdevice if not already open */
-       if (mISDNdevice < 0)
-       {
-               ret = mISDN_open();
-               if (ret < 0)
-               {
-                       fprintf(stderr, "cannot open mISDN device ret=%d errno=%d (%s) Check for mISDN modules!\nAlso did you create \"/dev/mISDN\"? Do: \"mknod /dev/mISDN c 46 0\"\n", ret, errno, strerror(errno));
-                       return(-1);
-               }
-               mISDNdevice = ret;
-               PDEBUG(DEBUG_ISDN, "mISDN device opened.\n");
-
-               /* create entity for layer 3 TE-mode */
-               mISDN_write_frame(mISDNdevice, buff, 0, MGR_NEWENTITY | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
-               ret = mISDN_read_frame(mISDNdevice, frm, sizeof(iframe_t), 0, MGR_NEWENTITY | CONFIRM, TIMEOUT_1SEC);
-               if (ret < (int)mISDN_HEADER_LEN)
-               {
-                       noentity:
-                       FATAL("Cannot request MGR_NEWENTITY from mISDN. Exitting due to software bug.");
-               }
-               entity = frm->dinfo & 0xffff;
-               if (!entity)
-                       goto noentity;
-               PDEBUG(DEBUG_ISDN, "our entity for l3-processes is %d.\n", entity);
-       }
-       return(0);
-}
-
-void mISDN_deinitialize(void)
-{
-       unsigned char buff[1025];
-
-       debug_close();
-       global_debug = 0;
-
-       if (mISDNdevice > -1)
-       {
-               /* free entity */
-               mISDN_write_frame(mISDNdevice, buff, 0, MGR_DELENTITY | REQUEST, entity, 0, NULL, TIMEOUT_1SEC);
-               /* close device */
-               mISDN_close(mISDNdevice);
-               mISDNdevice = -1;
-               PDEBUG(DEBUG_ISDN, "mISDN device closed.\n");
-       }
-}
-#endif
 
 /*
  * constructor
 
 /*
  * constructor
@@ -366,14 +245,8 @@ static struct isdn_message {
        {"MT_FACILITY", L3_FACILITY_REQ},
        {"MT_STATUS", L3_STATUS_REQ},
        {"MT_RESTART", L3_RESTART_REQ},
        {"MT_FACILITY", L3_FACILITY_REQ},
        {"MT_STATUS", L3_STATUS_REQ},
        {"MT_RESTART", L3_RESTART_REQ},
-#ifdef SOCKET_MISDN
        {"MT_NEW_L3ID", L3_NEW_L3ID_REQ},
        {"MT_RELEASE_L3ID", L3_RELEASE_L3ID_REQ},
        {"MT_NEW_L3ID", L3_NEW_L3ID_REQ},
        {"MT_RELEASE_L3ID", L3_RELEASE_L3ID_REQ},
-#else
-       {"MT_NEW_CR", L3_NEW_CR_REQ},
-       {"MT_RELEASE_CR", L3_RELEASE_CR_REQ},
-#endif
-
        {NULL, 0},
 };
 static char *isdn_prim[4] = {
        {NULL, 0},
 };
 static char *isdn_prim[4] = {
@@ -401,11 +274,7 @@ void l1l2l3_trace_header(struct mISDNport *mISDNport, class PmISDN *port, unsign
        SCAT(msgtext, isdn_prim[msg&0x00000003]);
 
        /* add direction */
        SCAT(msgtext, isdn_prim[msg&0x00000003]);
 
        /* add direction */
-#ifdef SOCKET_MISDN
        if (direction && (msg&0xffffff00)!=L3_NEW_L3ID_REQ && (msg&0xffffff00)!=L3_RELEASE_L3ID_REQ)
        if (direction && (msg&0xffffff00)!=L3_NEW_L3ID_REQ && (msg&0xffffff00)!=L3_RELEASE_L3ID_REQ)
-#else
-       if (direction && (msg&0xffffff00)!=L3_NEW_CR_REQ && (msg&0xffffff00)!=L3_RELEASE_CR_REQ)
-#endif
        {
                if (mISDNport)
                {
        {
                if (mISDNport)
                {
@@ -440,7 +309,6 @@ void l1l2l3_trace_header(struct mISDNport *mISDNport, class PmISDN *port, unsign
 /*
  * send control information to the channel (dsp-module)
  */
 /*
  * send control information to the channel (dsp-module)
  */
-#ifdef SOCKET_MISDN
 void ph_control(struct mISDNport *mISDNport, class PmISDN *isdnport, unsigned long sock, unsigned long c1, unsigned long c2, char *trace_name, int trace_value)
 {
        unsigned char buffer[MISDN_HEADER_LEN+sizeof(int)+sizeof(int)];
 void ph_control(struct mISDNport *mISDNport, class PmISDN *isdnport, unsigned long sock, unsigned long c1, unsigned long c2, char *trace_name, int trace_value)
 {
        unsigned char buffer[MISDN_HEADER_LEN+sizeof(int)+sizeof(int)];
@@ -458,37 +326,14 @@ void ph_control(struct mISDNport *mISDNport, class PmISDN *isdnport, unsigned lo
        ret = sendto(sock, buffer, MISDN_HEADER_LEN+sizeof(int)*2, 0, NULL, 0);
        if (ret <= 0)
                PERROR("Failed to send to socket %d\n", sock);
        ret = sendto(sock, buffer, MISDN_HEADER_LEN+sizeof(int)*2, 0, NULL, 0);
        if (ret <= 0)
                PERROR("Failed to send to socket %d\n", sock);
-#else
-void ph_control(struct mISDNport *mISDNport, class PmISDN *isdnport, unsigned long addr, unsigned long c1, unsigned long c2, char *trace_name, int trace_value)
-{
-       unsigned char buffer[mISDN_HEADER_LEN+sizeof(int)+sizeof(int)];
-       iframe_t *ctrl = (iframe_t *)buffer; 
-       unsigned long *d = (unsigned long *)&ctrl->data.p;
-
-       if (!addr)
-               return;
-
-       ctrl->prim = PH_CONTROL | REQUEST;
-       ctrl->addr = addr | FLG_MSG_DOWN;
-       ctrl->dinfo = 0;
-       ctrl->len = sizeof(int)*2;
-       *d++ = c1;
-       *d++ = c2;
-       mISDN_write(mISDNdevice, ctrl, mISDN_HEADER_LEN+ctrl->len, TIMEOUT_1SEC);
-#endif
        chan_trace_header(mISDNport, isdnport, "BCHANNEL control", DIRECTION_OUT);
        chan_trace_header(mISDNport, isdnport, "BCHANNEL control", DIRECTION_OUT);
-#ifdef SOCKET_MISDN
        if (c1 == DSP_CONF_JOIN)
        if (c1 == DSP_CONF_JOIN)
-#else
-       if (c1 == CMX_CONF_JOIN)
-#endif
                add_trace(trace_name, NULL, "0x%08x", trace_value);
        else
                add_trace(trace_name, NULL, "%d", trace_value);
        end_trace();
 }
 
                add_trace(trace_name, NULL, "0x%08x", trace_value);
        else
                add_trace(trace_name, NULL, "%d", trace_value);
        end_trace();
 }
 
-#ifdef SOCKET_MISDN
 void ph_control_block(struct mISDNport *mISDNport, class PmISDN *isdnport, int sock, unsigned long c1, void *c2, int c2_len, char *trace_name, int trace_value)
 {
        unsigned char buffer[MISDN_HEADER_LEN+sizeof(int)+c2_len];
 void ph_control_block(struct mISDNport *mISDNport, class PmISDN *isdnport, int sock, unsigned long c1, void *c2, int c2_len, char *trace_name, int trace_value)
 {
        unsigned char buffer[MISDN_HEADER_LEN+sizeof(int)+c2_len];
@@ -506,24 +351,6 @@ void ph_control_block(struct mISDNport *mISDNport, class PmISDN *isdnport, int s
        ret = sendto(sock, buffer, MISDN_HEADER_LEN+sizeof(int)+c2_len, 0, NULL, 0);
        if (ret <= 0)
                PERROR("Failed to send to socket %d\n", sock);
        ret = sendto(sock, buffer, MISDN_HEADER_LEN+sizeof(int)+c2_len, 0, NULL, 0);
        if (ret <= 0)
                PERROR("Failed to send to socket %d\n", sock);
-#else
-void ph_control_block(struct mISDNport *mISDNport, class PmISDN *isdnport, unsigned long addr, unsigned long c1, void *c2, int c2_len, char *trace_name, int trace_value)
-{
-       unsigned char buffer[mISDN_HEADER_LEN+sizeof(int)+c2_len];
-       iframe_t *ctrl = (iframe_t *)buffer;
-       unsigned long *d = (unsigned long *)&ctrl->data.p;
-
-       if (!addr)
-               return;
-
-       ctrl->prim = PH_CONTROL | REQUEST;
-       ctrl->addr = addr | FLG_MSG_DOWN;
-       ctrl->dinfo = 0;
-       ctrl->len = sizeof(int)+c2_len;
-       *d++ = c1;
-       memcpy(d, c2, c2_len);
-       mISDN_write(mISDNdevice, ctrl, mISDN_HEADER_LEN+ctrl->len, TIMEOUT_1SEC);
-#endif
        chan_trace_header(mISDNport, isdnport, "BCHANNEL control", DIRECTION_OUT);
        add_trace(trace_name, NULL, "%d", trace_value);
        end_trace();
        chan_trace_header(mISDNport, isdnport, "BCHANNEL control", DIRECTION_OUT);
        add_trace(trace_name, NULL, "%d", trace_value);
        end_trace();
@@ -537,7 +364,6 @@ void ph_control_block(struct mISDNport *mISDNport, class PmISDN *isdnport, unsig
 static int _bchannel_create(struct mISDNport *mISDNport, int i)
 {
        int ret;
 static int _bchannel_create(struct mISDNport *mISDNport, int i)
 {
        int ret;
-#ifdef SOCKET_MISDN
        unsigned long on = 1;
        struct sockaddr_mISDN addr;
 
        unsigned long on = 1;
        struct sockaddr_mISDN addr;
 
@@ -586,80 +412,6 @@ static int _bchannel_create(struct mISDNport *mISDNport, int i)
        end_trace();
 
        return(1);
        end_trace();
 
        return(1);
-#else
-       unsigned char buff[1024];
-       layer_info_t li;
-       mISDN_pid_t pid;
-
-       if (!mISDNport->b_stid[i])
-       {
-               PERROR("Error: no stack for index %d\n", i);
-               return(0);
-       }
-       if (mISDNport->b_addr[i])
-       {
-               PERROR("Error: stack already created for index %d\n", i);
-               return(0);
-       }
-
-       /* create new layer */
-       PDEBUG(DEBUG_BCHANNEL, "creating new layer for bchannel %d (index %d).\n" , i+1+(i>=15), i);
-       memset(&li, 0, sizeof(li));
-       memset(&pid, 0, sizeof(pid));
-       li.object_id = -1;
-       li.extentions = 0;
-       li.st = mISDNport->b_stid[i];
-       UCPY(li.name, "B L4");
-       li.pid.layermask = ISDN_LAYER((4));
-       li.pid.protocol[4] = ISDN_PID_L4_B_USER;
-       ret = mISDN_new_layer(mISDNdevice, &li);
-       if (ret)
-       {
-               failed_new_layer:
-               PERROR("mISDN_new_layer() failed to add bchannel %d (index %d)\n", i+1+(i>=15), i);
-               goto failed;
-       }
-       mISDNport->b_addr[i] = li.id;
-       if (!li.id)
-       {
-               goto failed_new_layer;
-       }
-       PDEBUG(DEBUG_BCHANNEL, "new layer (b_addr=0x%x)\n", mISDNport->b_addr[i]);
-
-       /* create new stack */
-       pid.protocol[1] = ISDN_PID_L1_B_64TRANS;
-       pid.protocol[2] = ISDN_PID_L2_B_TRANS;
-       pid.protocol[3] = ISDN_PID_L3_B_DSP;
-       pid.protocol[4] = ISDN_PID_L4_B_USER;
-       pid.layermask = ISDN_LAYER((1)) | ISDN_LAYER((2)) | ISDN_LAYER((3)) | ISDN_LAYER((4));
-       ret = mISDN_set_stack(mISDNdevice, mISDNport->b_stid[i], &pid);
-       if (ret)
-       {
-               stack_error:
-               PERROR("mISDN_set_stack() failed (ret=%d) to add bchannel (index %d) stid=0x%x\n", ret, i, mISDNport->b_stid[i]);
-               mISDN_write_frame(mISDNdevice, buff, mISDNport->b_addr[i], MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
-               goto failed;
-       }
-       ret = mISDN_get_setstack_ind(mISDNdevice, mISDNport->b_addr[i]);
-       if (ret)
-               goto stack_error;
-
-       /* get layer id */
-       mISDNport->b_addr[i] = mISDN_get_layerid(mISDNdevice, mISDNport->b_stid[i], 4);
-       if (!mISDNport->b_addr[i])
-               goto stack_error;
-       chan_trace_header(mISDNport, mISDNport->b_port[i], "BCHANNEL create stack", DIRECTION_OUT);
-       add_trace("channel", NULL, "%d", i+1+(i>=15));
-       add_trace("stack", "id", "0x%08x", mISDNport->b_stid[i]);
-       add_trace("stack", "address", "0x%08x", mISDNport->b_addr[i]);
-       end_trace();
-
-       return(1);
-
-failed:
-       mISDNport->b_addr[i] = 0;
-       return(0);
-#endif
 }
 
 
 }
 
 
@@ -669,7 +421,6 @@ failed:
  */
 static void _bchannel_activate(struct mISDNport *mISDNport, int i, int activate)
 {
  */
 static void _bchannel_activate(struct mISDNport *mISDNport, int i, int activate)
 {
-#ifdef SOCKET_MISDN
        struct mISDNhead act;
        int ret;
 
        struct mISDNhead act;
        int ret;
 
@@ -680,16 +431,6 @@ static void _bchannel_activate(struct mISDNport *mISDNport, int i, int activate)
        ret = sendto(mISDNport->b_socket[i], &act, MISDN_HEADER_LEN, 0, NULL, 0);
        if (ret <= 0)
                PERROR("Failed to send to socket %d\n", mISDNport->b_socket[i]);
        ret = sendto(mISDNport->b_socket[i], &act, MISDN_HEADER_LEN, 0, NULL, 0);
        if (ret <= 0)
                PERROR("Failed to send to socket %d\n", mISDNport->b_socket[i]);
-#else
-       iframe_t act;
-
-       /* activate bchannel */
-       act.prim = (activate?DL_ESTABLISH:DL_RELEASE) | REQUEST; 
-       act.addr = mISDNport->b_addr[i] | FLG_MSG_DOWN;
-       act.dinfo = 0;
-       act.len = 0;
-       mISDN_write(mISDNdevice, &act, mISDN_HEADER_LEN+act.len, TIMEOUT_1SEC);
-#endif
 
        /* trace */
        chan_trace_header(mISDNport, mISDNport->b_port[i], activate?(char*)"BCHANNEL activate":(char*)"BCHANNEL deactivate", DIRECTION_OUT);
 
        /* trace */
        chan_trace_header(mISDNport, mISDNport->b_port[i], activate?(char*)"BCHANNEL activate":(char*)"BCHANNEL deactivate", DIRECTION_OUT);
@@ -707,7 +448,6 @@ static void _bchannel_activate(struct mISDNport *mISDNport, int i, int activate)
 static void _bchannel_configure(struct mISDNport *mISDNport, int i)
 {
        struct PmISDN *port;
 static void _bchannel_configure(struct mISDNport *mISDNport, int i)
 {
        struct PmISDN *port;
-#ifdef SOCKET_MISDN
        int handle;
 
        if (mISDNport->b_socket[i] < 0)
        int handle;
 
        if (mISDNport->b_socket[i] < 0)
@@ -745,47 +485,6 @@ static void _bchannel_configure(struct mISDNport *mISDNport, int i)
                ph_control(mISDNport, port, handle, DTMF_TONE_START, 0, "DSP-DTMF", 1);
        if (port->p_m_crypt)
                ph_control_block(mISDNport, port, handle, DSP_BF_ENABLE_KEY, port->p_m_crypt_key, port->p_m_crypt_key_len, "DSP-CRYPT", port->p_m_crypt_key_len);
                ph_control(mISDNport, port, handle, DTMF_TONE_START, 0, "DSP-DTMF", 1);
        if (port->p_m_crypt)
                ph_control_block(mISDNport, port, handle, DSP_BF_ENABLE_KEY, port->p_m_crypt_key, port->p_m_crypt_key_len, "DSP-CRYPT", port->p_m_crypt_key_len);
-#else
-       unsigned long handle;
-
-       handle = mISDNport->b_addr[i];
-       port = mISDNport->b_port[i];
-       if (!port)
-       {
-               PERROR("bchannel index i=%d not associated with a port object\n", i);
-               return;
-       }
-
-       /* set dsp features */
-#ifndef OLD_MISDN
-       if (port->p_m_txdata)
-               ph_control(mISDNport, port, handle, (port->p_m_txdata)?CMX_TXDATA_ON:CMX_TXDATA_OFF, 0, "DSP-TXDATA", port->p_m_txdata);
-       if (port->p_m_delay)
-               ph_control(mISDNport, port, handle, CMX_DELAY, port->p_m_delay, "DSP-DELAY", port->p_m_delay);
-#endif
-       if (port->p_m_tx_gain)
-               ph_control(mISDNport, port, handle, VOL_CHANGE_TX, port->p_m_tx_gain, "DSP-TX_GAIN", port->p_m_tx_gain);
-       if (port->p_m_rx_gain)
-               ph_control(mISDNport, port, handle, VOL_CHANGE_RX, port->p_m_rx_gain, "DSP-RX_GAIN", port->p_m_rx_gain);
-#ifndef OLD_MISDN
-       if (port->p_m_pipeline[0])
-               ph_control_block(mISDNport, port, handle, PIPELINE_CFG, port->p_m_pipeline, strlen(port->p_m_pipeline)+1, "DSP-PIPELINE", 0);
-#endif
-       if (port->p_m_conf)
-               ph_control(mISDNport, port, handle, CMX_CONF_JOIN, port->p_m_conf, "DSP-CONF", port->p_m_conf);
-       if (port->p_m_echo)
-               ph_control(mISDNport, port, handle, CMX_ECHO_ON, 0, "DSP-ECHO", 1);
-       if (port->p_m_tone)
-               ph_control(mISDNport, port, handle, TONE_PATT_ON, port->p_m_tone, "DSP-TONE", port->p_m_tone);
-       if (port->p_m_rxoff)
-               ph_control(mISDNport, port, handle, CMX_RECEIVE_OFF, 0, "DSP-RXOFF", 1);
-//     if (port->p_m_txmix)
-//             ph_control(mISDNport, port, handle, CMX_MIX_ON, 0, "DSP-MIX", 1);
-       if (port->p_m_dtmf)
-               ph_control(mISDNport, port, handle, DTMF_TONE_START, 0, "DSP-DTMF", 1);
-       if (port->p_m_crypt)
-               ph_control_block(mISDNport, port, handle, BF_ENABLE_KEY, port->p_m_crypt_key, port->p_m_crypt_key_len, "DSP-CRYPT", port->p_m_crypt_key_len);
-#endif
 }
 
 /*
 }
 
 /*
@@ -794,7 +493,6 @@ static void _bchannel_configure(struct mISDNport *mISDNport, int i)
  */
 static void _bchannel_destroy(struct mISDNport *mISDNport, int i)
 {
  */
 static void _bchannel_destroy(struct mISDNport *mISDNport, int i)
 {
-#ifdef SOCKET_MISDN
        if (mISDNport->b_socket[i] < 0)
                return;
        chan_trace_header(mISDNport, mISDNport->b_port[i], "BCHANNEL remove socket", DIRECTION_OUT);
        if (mISDNport->b_socket[i] < 0)
                return;
        chan_trace_header(mISDNport, mISDNport->b_port[i], "BCHANNEL remove socket", DIRECTION_OUT);
@@ -803,23 +501,6 @@ static void _bchannel_destroy(struct mISDNport *mISDNport, int i)
        end_trace();
        close(mISDNport->b_socket[i]);
        mISDNport->b_socket[i] = -1;
        end_trace();
        close(mISDNport->b_socket[i]);
        mISDNport->b_socket[i] = -1;
-#else
-       unsigned char buff[1024];
-
-       chan_trace_header(mISDNport, mISDNport->b_port[i], "BCHANNEL remove stack", DIRECTION_OUT);
-       add_trace("channel", NULL, "%d", i+1+(i>=15));
-       add_trace("stack", "id", "0x%08x", mISDNport->b_stid[i]);
-       add_trace("stack", "address", "0x%08x", mISDNport->b_addr[i]);
-       end_trace();
-       /* remove our stack only if set */
-       if (mISDNport->b_addr[i])
-       {
-               PDEBUG(DEBUG_BCHANNEL, "free stack (b_addr=0x%x)\n", mISDNport->b_addr[i]);
-               mISDN_clear_stack(mISDNdevice, mISDNport->b_stid[i]);
-               mISDN_write_frame(mISDNdevice, buff, mISDNport->b_addr[i] | FLG_MSG_DOWN, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
-               mISDNport->b_addr[i] = 0;
-       }
-#endif
 }
 
 
 }
 
 
@@ -869,7 +550,6 @@ A bchannel can have the following events:
 
 - B_EVENT_USE
 A bchannel is required by a Port class.
 
 - B_EVENT_USE
 A bchannel is required by a Port class.
-The bchannel shall be exported to the remote application.
 
 - B_EVENT_ACTIVATED
 The bchannel beomes active.
 
 - B_EVENT_ACTIVATED
 The bchannel beomes active.
@@ -886,6 +566,12 @@ The bchannel is now used by remote application.
 - B_EVENT_IMPORTED
 The bchannel is not used by remote application.
 
 - B_EVENT_IMPORTED
 The bchannel is not used by remote application.
 
+- B_EVENT_EXPORTREQUEST
+The bchannel shall be exported to the remote application.
+
+- B_EVENT_IMPORTREQUEST
+The bchannel is released from the remote application.
+
 All actions taken on these events depend on the current bchannel's state and if it is linked to a Port class.
 
 if an export request is receive by remote application, p_m_remote_* is set.
 All actions taken on these events depend on the current bchannel's state and if it is linked to a Port class.
 
 if an export request is receive by remote application, p_m_remote_* is set.
@@ -923,11 +609,7 @@ void bchannel_event(struct mISDNport *mISDNport, int i, int event)
        unsigned char *p_m_crypt_key = NULL;
        int p_m_crypt_key_len = 0;
        int p_m_crypt_key_type = 0;
        unsigned char *p_m_crypt_key = NULL;
        int p_m_crypt_key_len = 0;
        int p_m_crypt_key_type = 0;
-#ifdef SOCKET_MISDN
        unsigned long portid = (mISDNport->portnum<<8) + i+1+(i>=15);
        unsigned long portid = (mISDNport->portnum<<8) + i+1+(i>=15);
-#else
-       unsigned long portid = mISDNport->b_stid[i];
-#endif
 
        if (b_port)
        {
 
        if (b_port)
        {
@@ -956,11 +638,7 @@ void bchannel_event(struct mISDNport *mISDNport, int i, int event)
                                message_bchannel_to_join(p_m_remote_id, p_m_remote_ref, BCHANNEL_ASSIGN, portid, p_m_tx_gain, p_m_rx_gain, p_m_pipeline, p_m_crypt_key, p_m_crypt_key_len, p_m_crypt_key_type);
                                chan_trace_header(mISDNport, b_port, "MESSAGE_BCHANNEL (to remote application)", DIRECTION_NONE);
                                add_trace("type", NULL, "assign");
                                message_bchannel_to_join(p_m_remote_id, p_m_remote_ref, BCHANNEL_ASSIGN, portid, p_m_tx_gain, p_m_rx_gain, p_m_pipeline, p_m_crypt_key, p_m_crypt_key_len, p_m_crypt_key_type);
                                chan_trace_header(mISDNport, b_port, "MESSAGE_BCHANNEL (to remote application)", DIRECTION_NONE);
                                add_trace("type", NULL, "assign");
-#ifdef SOCKET_MISDN
                                add_trace("channel", NULL, "%d.%d", portid>>8, portid&0xff);
                                add_trace("channel", NULL, "%d.%d", portid>>8, portid&0xff);
-#else
-                               add_trace("socket", "id", "%d", portid);
-#endif
                                end_trace();
                                state = B_STATE_EXPORTING;
                                mISDNport->b_remote_id[i] = p_m_remote_id;
                                end_trace();
                                state = B_STATE_EXPORTING;
                                mISDNport->b_remote_id[i] = p_m_remote_id;
@@ -1012,11 +690,7 @@ void bchannel_event(struct mISDNport *mISDNport, int i, int event)
                        message_bchannel_to_join(p_m_remote_id, p_m_remote_ref, BCHANNEL_ASSIGN, portid, p_m_tx_gain, p_m_rx_gain, p_m_pipeline, p_m_crypt_key, p_m_crypt_key_len, p_m_crypt_key_type);
                        chan_trace_header(mISDNport, b_port, "MESSAGE_BCHANNEL (to remote application)", DIRECTION_NONE);
                        add_trace("type", NULL, "assign");
                        message_bchannel_to_join(p_m_remote_id, p_m_remote_ref, BCHANNEL_ASSIGN, portid, p_m_tx_gain, p_m_rx_gain, p_m_pipeline, p_m_crypt_key, p_m_crypt_key_len, p_m_crypt_key_type);
                        chan_trace_header(mISDNport, b_port, "MESSAGE_BCHANNEL (to remote application)", DIRECTION_NONE);
                        add_trace("type", NULL, "assign");
-#ifdef SOCKET_MISDN
                        add_trace("channel", NULL, "%d.%d", portid>>8, portid&0xff);
                        add_trace("channel", NULL, "%d.%d", portid>>8, portid&0xff);
-#else
-                       add_trace("socket", "id", "%d", portid);
-#endif
                        end_trace();
                        state = B_STATE_EXPORTING;
                        mISDNport->b_remote_id[i] = p_m_remote_id;
                        end_trace();
                        state = B_STATE_EXPORTING;
                        mISDNport->b_remote_id[i] = p_m_remote_id;
@@ -1049,6 +723,45 @@ void bchannel_event(struct mISDNport *mISDNport, int i, int event)
                }
                break;
 
                }
                break;
 
+               case B_EVENT_IMPORTREQUEST:
+               /* special case where the bchannel is released by remote */
+               if (p_m_remote_ref)
+               {
+                       PERROR("import request with remote channel set, please correct.\n");
+                       break;
+               }
+               switch(state)
+               {
+                       case B_STATE_IDLE:
+                       case B_STATE_ACTIVE:
+                       /* bchannel is not exported */
+                       break;
+
+                       case B_STATE_ACTIVATING:
+                       case B_STATE_EXPORTING:
+                       /* do nothing because we must wait until bchanenl is active before deactivating */
+                       break;
+
+                       case B_STATE_REMOTE:
+                       /* bchannel is exported, so we re-import */
+                       message_bchannel_to_join(mISDNport->b_remote_id[i], 0, BCHANNEL_REMOVE, portid, 0,0,0,0,0,0);
+                       chan_trace_header(mISDNport, b_port, "MESSAGE_BCHANNEL (to remote application)", DIRECTION_NONE);
+                       add_trace("type", NULL, "remove");
+                       add_trace("channel", NULL, "%d.%d", portid>>8, portid&0xff);
+                       end_trace();
+                       state = B_STATE_IMPORTING;
+                       break;
+
+                       case B_STATE_DEACTIVATING:
+                       case B_STATE_IMPORTING:
+                       /* we may have taken an already deactivating bchannel, but do not require it anymore, so we do nothing */
+                       break;
+
+                       default:
+                       PERROR("Illegal event %d at state %d, please correct.\n", event, state);
+               }
+               break;
+
                case B_EVENT_ACTIVATED:
                timer = 0;
                switch(state)
                case B_EVENT_ACTIVATED:
                timer = 0;
                switch(state)
@@ -1090,11 +803,7 @@ void bchannel_event(struct mISDNport *mISDNport, int i, int event)
                                message_bchannel_to_join(mISDNport->b_remote_id[i], 0, BCHANNEL_REMOVE, portid, 0,0,0,0,0,0);
                                chan_trace_header(mISDNport, b_port, "MESSAGE_BCHANNEL (to remote application)", DIRECTION_NONE);
                                add_trace("type", NULL, "remove");
                                message_bchannel_to_join(mISDNport->b_remote_id[i], 0, BCHANNEL_REMOVE, portid, 0,0,0,0,0,0);
                                chan_trace_header(mISDNport, b_port, "MESSAGE_BCHANNEL (to remote application)", DIRECTION_NONE);
                                add_trace("type", NULL, "remove");
-#ifdef SOCKET_MISDN
                                add_trace("channel", NULL, "%d.%d", portid>>8, portid&0xff);
                                add_trace("channel", NULL, "%d.%d", portid>>8, portid&0xff);
-#else
-                               add_trace("socket", "id", "%d", portid);
-#endif
                                end_trace();
                                state = B_STATE_IMPORTING;
                        }
                                end_trace();
                                state = B_STATE_IMPORTING;
                        }
@@ -1131,11 +840,7 @@ void bchannel_event(struct mISDNport *mISDNport, int i, int event)
                        message_bchannel_to_join(mISDNport->b_remote_id[i], 0, BCHANNEL_REMOVE, portid, 0,0,0,0,0,0);
                        chan_trace_header(mISDNport, b_port, "MESSAGE_BCHANNEL (to remote application)", DIRECTION_NONE);
                        add_trace("type", NULL, "remove");
                        message_bchannel_to_join(mISDNport->b_remote_id[i], 0, BCHANNEL_REMOVE, portid, 0,0,0,0,0,0);
                        chan_trace_header(mISDNport, b_port, "MESSAGE_BCHANNEL (to remote application)", DIRECTION_NONE);
                        add_trace("type", NULL, "remove");
-#ifdef SOCKET_MISDN
                        add_trace("channel", NULL, "%d.%d", portid>>8, portid&0xff);
                        add_trace("channel", NULL, "%d.%d", portid>>8, portid&0xff);
-#else
-                       add_trace("socket", "id", "%d", portid);
-#endif
                        end_trace();
                        state = B_STATE_IMPORTING;
                        break;
                        end_trace();
                        state = B_STATE_IMPORTING;
                        break;
@@ -1169,11 +874,7 @@ void bchannel_event(struct mISDNport *mISDNport, int i, int event)
                                        message_bchannel_to_join(p_m_remote_id, p_m_remote_ref, BCHANNEL_ASSIGN, portid, p_m_tx_gain, p_m_rx_gain, p_m_pipeline, p_m_crypt_key, p_m_crypt_key_len, p_m_crypt_key_type);
                                        chan_trace_header(mISDNport, b_port, "MESSAGE_BCHANNEL (to remote application)", DIRECTION_NONE);
                                        add_trace("type", NULL, "assign");
                                        message_bchannel_to_join(p_m_remote_id, p_m_remote_ref, BCHANNEL_ASSIGN, portid, p_m_tx_gain, p_m_rx_gain, p_m_pipeline, p_m_crypt_key, p_m_crypt_key_len, p_m_crypt_key_type);
                                        chan_trace_header(mISDNport, b_port, "MESSAGE_BCHANNEL (to remote application)", DIRECTION_NONE);
                                        add_trace("type", NULL, "assign");
-#ifdef SOCKET_MISDN
                                        add_trace("channel", NULL, "%d.%d", portid>>8, portid&0xff);
                                        add_trace("channel", NULL, "%d.%d", portid>>8, portid&0xff);
-#else
-                                       add_trace("socket", "id", "%d", portid);
-#endif
                                        end_trace();
                                        state = B_STATE_EXPORTING;
                                        mISDNport->b_remote_id[i] = p_m_remote_id;
                                        end_trace();
                                        state = B_STATE_EXPORTING;
                                        mISDNport->b_remote_id[i] = p_m_remote_id;
@@ -1210,11 +911,7 @@ void bchannel_event(struct mISDNport *mISDNport, int i, int event)
                                        message_bchannel_to_join(p_m_remote_id, p_m_remote_ref, BCHANNEL_ASSIGN, portid, p_m_tx_gain, p_m_rx_gain, p_m_pipeline, p_m_crypt_key, p_m_crypt_key_len, p_m_crypt_key_type);
                                        chan_trace_header(mISDNport, b_port, "MESSAGE_BCHANNEL (to remote application)", DIRECTION_NONE);
                                        add_trace("type", NULL, "assign");
                                        message_bchannel_to_join(p_m_remote_id, p_m_remote_ref, BCHANNEL_ASSIGN, portid, p_m_tx_gain, p_m_rx_gain, p_m_pipeline, p_m_crypt_key, p_m_crypt_key_len, p_m_crypt_key_type);
                                        chan_trace_header(mISDNport, b_port, "MESSAGE_BCHANNEL (to remote application)", DIRECTION_NONE);
                                        add_trace("type", NULL, "assign");
-#ifdef SOCKET_MISDN
                                        add_trace("channel", NULL, "%d.%d", portid>>8, portid&0xff);
                                        add_trace("channel", NULL, "%d.%d", portid>>8, portid&0xff);
-#else
-                                       add_trace("socket", "id", "%d", portid);
-#endif
                                        end_trace();
                                        state = B_STATE_EXPORTING;
                                        mISDNport->b_remote_id[i] = p_m_remote_id;
                                        end_trace();
                                        state = B_STATE_EXPORTING;
                                        mISDNport->b_remote_id[i] = p_m_remote_id;
@@ -1408,7 +1105,7 @@ void message_bchannel_from_join(class JoinRemote *joinremote, int type, unsigned
                        PDEBUG(DEBUG_BCHANNEL, "join %d has no port (anymore as object)\n", joinremote->j_serial);
                        return;
                }
                        PDEBUG(DEBUG_BCHANNEL, "join %d has no port (anymore as object)\n", joinremote->j_serial);
                        return;
                }
-               if (!((port->p_type&PORT_CLASS_MASK) != PORT_CLASS_mISDN))
+               if ((port->p_type&PORT_CLASS_MASK) != PORT_CLASS_mISDN)
                {
                        PERROR("join %d has port %d not of mISDN type. This shall not happen.\n", joinremote->j_serial, port->p_serial);
                }
                {
                        PERROR("join %d has port %d not of mISDN type. This shall not happen.\n", joinremote->j_serial, port->p_serial);
                }
@@ -1424,13 +1121,59 @@ void message_bchannel_from_join(class JoinRemote *joinremote, int type, unsigned
                i = isdnport->p_m_b_index;
                chan_trace_header(mISDNport, isdnport, "MESSAGE_BCHANNEL (from remote application)", DIRECTION_NONE);
                add_trace("type", NULL, "export request");
                i = isdnport->p_m_b_index;
                chan_trace_header(mISDNport, isdnport, "MESSAGE_BCHANNEL (from remote application)", DIRECTION_NONE);
                add_trace("type", NULL, "export request");
+               end_trace();
                isdnport->p_m_remote_ref = joinremote->j_serial;
                isdnport->p_m_remote_id = joinremote->j_remote_id;
                if (mISDNport && i>=0)
                {
                        bchannel_event(mISDNport, i, B_EVENT_EXPORTREQUEST);
                }
                isdnport->p_m_remote_ref = joinremote->j_serial;
                isdnport->p_m_remote_id = joinremote->j_remote_id;
                if (mISDNport && i>=0)
                {
                        bchannel_event(mISDNport, i, B_EVENT_EXPORTREQUEST);
                }
+               break;
+
+               case BCHANNEL_RELEASE:
+               /* find the port object for the join object ref */
+               if (!(epoint = find_epoint_id(joinremote->j_epoint_id)))
+               {
+                       PDEBUG(DEBUG_BCHANNEL, "join %d has no endpoint (anymore)\n", joinremote->j_serial);
+                       return;
+               }
+               if (!epoint->ep_portlist)
+               {
+                       PDEBUG(DEBUG_BCHANNEL, "join %d has no port (anymore in portlist)\n", joinremote->j_serial);
+                       return;
+               }
+               if (epoint->ep_portlist->next)
+               {
+                       PERROR("join %d has enpoint %d with more than one port. this shall not happen to remote joins.\n", joinremote->j_serial, epoint->ep_serial);
+               }
+               if (!(port = find_port_id(epoint->ep_portlist->port_id)))
+               {
+                       PDEBUG(DEBUG_BCHANNEL, "join %d has no port (anymore as object)\n", joinremote->j_serial);
+                       return;
+               }
+               if ((port->p_type&PORT_CLASS_MASK) != PORT_CLASS_mISDN)
+               {
+                       PERROR("join %d has port %d not of mISDN type. This shall not happen.\n", joinremote->j_serial, port->p_serial);
+               }
+               isdnport = (class PmISDN *)port;
+
+               /* release */
+               if (!isdnport->p_m_remote_id)
+               {
+                       PERROR("join %d recevied bchannel release from remote, but channel is already released.\n", joinremote->j_serial);
+                       break;
+               }
+               mISDNport = isdnport->p_m_mISDNport;
+               i = isdnport->p_m_b_index;
+               chan_trace_header(mISDNport, isdnport, "MESSAGE_BCHANNEL (from remote application)", DIRECTION_NONE);
+               add_trace("type", NULL, "export request");
                end_trace();
                end_trace();
+               isdnport->p_m_remote_ref = 0;
+               isdnport->p_m_remote_id = 0;
+               if (mISDNport && i>=0)
+               {
+                       bchannel_event(mISDNport, i, B_EVENT_IMPORTREQUEST);
+               }
                break;
 
                case BCHANNEL_ASSIGN_ACK:
                break;
 
                case BCHANNEL_ASSIGN_ACK:
@@ -1443,11 +1186,7 @@ void message_bchannel_from_join(class JoinRemote *joinremote, int type, unsigned
                        ii = mISDNport->b_num;
                        while(i < ii)
                        {
                        ii = mISDNport->b_num;
                        while(i < ii)
                        {
-#ifdef SOCKET_MISDN
                                if ((unsigned long)(mISDNport->portnum<<8)+i+1+(i>=15) == handle)
                                if ((unsigned long)(mISDNport->portnum<<8)+i+1+(i>=15) == handle)
-#else
-                               if (mISDNport->b_addr[i] == handle)
-#endif
                                        break;
                                i++;
                        }
                                        break;
                                i++;
                        }
@@ -1465,9 +1204,9 @@ void message_bchannel_from_join(class JoinRemote *joinremote, int type, unsigned
                /* set */
                chan_trace_header(mISDNport, mISDNport->b_port[i], "MESSAGE_BCHANNEL (from remote application)", DIRECTION_NONE);
                add_trace("type", NULL, (type==BCHANNEL_ASSIGN_ACK)?"assign_ack":"remove_ack");
                /* set */
                chan_trace_header(mISDNport, mISDNport->b_port[i], "MESSAGE_BCHANNEL (from remote application)", DIRECTION_NONE);
                add_trace("type", NULL, (type==BCHANNEL_ASSIGN_ACK)?"assign_ack":"remove_ack");
+               end_trace();
                if (mISDNport && i>=0)
                        bchannel_event(mISDNport, i, (type==BCHANNEL_ASSIGN_ACK)?B_EVENT_EXPORTED:B_EVENT_IMPORTED);
                if (mISDNport && i>=0)
                        bchannel_event(mISDNport, i, (type==BCHANNEL_ASSIGN_ACK)?B_EVENT_EXPORTED:B_EVENT_IMPORTED);
-               end_trace();
                break;
                default:
                PERROR("received wrong bchannel message type %d from remote\n", type);
                break;
                default:
                PERROR("received wrong bchannel message type %d from remote\n", type);
@@ -1569,15 +1308,9 @@ int PmISDN::handler(void)
                 && (p_state==PORT_STATE_CONNECT || p_m_mISDNport->tones))
                {
                        int tosend = ISDN_LOAD - p_m_load, length; 
                 && (p_state==PORT_STATE_CONNECT || p_m_mISDNport->tones))
                {
                        int tosend = ISDN_LOAD - p_m_load, length; 
-#ifdef SOCKET_MISDN
                        unsigned char buf[MISDN_HEADER_LEN+tosend];
                        struct mISDNhead *frm = (struct mISDNhead *)buf;
                        unsigned char *p = buf+MISDN_HEADER_LEN;
                        unsigned char buf[MISDN_HEADER_LEN+tosend];
                        struct mISDNhead *frm = (struct mISDNhead *)buf;
                        unsigned char *p = buf+MISDN_HEADER_LEN;
-#else
-                       unsigned char buf[mISDN_HEADER_LEN+tosend];
-                       iframe_t *frm = (iframe_t *)buf;
-                       unsigned char *p = buf+mISDN_HEADER_LEN;
-#endif
 
                        /* copy crypto loops */
                        while (p_m_crypt_msg_loops && tosend)
 
                        /* copy crypto loops */
                        while (p_m_crypt_msg_loops && tosend)
@@ -1615,20 +1348,11 @@ int PmISDN::handler(void)
                        /* send data */
                        if (p_m_mISDNport->b_state[p_m_b_index] == B_STATE_ACTIVE && ISDN_LOAD-p_m_load-tosend > 0)
                        {
                        /* send data */
                        if (p_m_mISDNport->b_state[p_m_b_index] == B_STATE_ACTIVE && ISDN_LOAD-p_m_load-tosend > 0)
                        {
-#ifdef SOCKET_MISDN
                                frm->prim = PH_DATA_REQ;
                                frm->id = 0;
                                ret = sendto(p_m_mISDNport->b_socket[p_m_b_index], buf, MISDN_HEADER_LEN+ISDN_LOAD-p_m_load-tosend, 0, NULL, 0);
                                if (ret <= 0)
                                        PERROR("Failed to send to socket %d (samples = %d)\n", p_m_mISDNport->b_socket[p_m_b_index], ISDN_LOAD-p_m_load-tosend);
                                frm->prim = PH_DATA_REQ;
                                frm->id = 0;
                                ret = sendto(p_m_mISDNport->b_socket[p_m_b_index], buf, MISDN_HEADER_LEN+ISDN_LOAD-p_m_load-tosend, 0, NULL, 0);
                                if (ret <= 0)
                                        PERROR("Failed to send to socket %d (samples = %d)\n", p_m_mISDNport->b_socket[p_m_b_index], ISDN_LOAD-p_m_load-tosend);
-#else
-                               frm->prim = DL_DATA | REQUEST; 
-                               frm->addr = p_m_mISDNport->b_addr[p_m_b_index] | FLG_MSG_DOWN;
-                               frm->dinfo = 0;
-                               frm->len = ISDN_LOAD - p_m_load - tosend;
-                               if (frm->len)
-                                       mISDN_write(mISDNdevice, frm, mISDN_HEADER_LEN+frm->len, TIMEOUT_1SEC);
-#endif
                        }
                        p_m_load += ISDN_LOAD - p_m_load - tosend;
                }
                        }
                        p_m_load += ISDN_LOAD - p_m_load - tosend;
                }
@@ -1658,28 +1382,16 @@ int PmISDN::handler(void)
 /*
  * whenever we get audio data from bchannel, we process it here
  */
 /*
  * whenever we get audio data from bchannel, we process it here
  */
-#ifdef SOCKET_MISDN
 void PmISDN::bchannel_receive(struct mISDNhead *hh, unsigned char *data, int len)
 {
        unsigned long cont = *((unsigned long *)data);
 void PmISDN::bchannel_receive(struct mISDNhead *hh, unsigned char *data, int len)
 {
        unsigned long cont = *((unsigned long *)data);
-#else
-void PmISDN::bchannel_receive(iframe_t *frm)
-{
-       int len = frm->len;
-       unsigned long cont = *((unsigned long *)&frm->data.p);
-       unsigned char *data =(unsigned char *)&frm->data.p;
-#endif
        unsigned char *data_temp;
        unsigned long length_temp;
        struct lcr_msg *message;
        unsigned char *p;
        int l;
 
        unsigned char *data_temp;
        unsigned long length_temp;
        struct lcr_msg *message;
        unsigned char *p;
        int l;
 
-#ifdef SOCKET_MISDN
        if (hh->prim == PH_CONTROL_IND)
        if (hh->prim == PH_CONTROL_IND)
-#else
-       if (frm->prim == (PH_CONTROL | INDICATION))
-#endif
        {
                if (len < 4)
                {
        {
                if (len < 4)
                {
@@ -1699,11 +1411,7 @@ void PmISDN::bchannel_receive(iframe_t *frm)
                }
                switch(cont)
                {
                }
                switch(cont)
                {
-#ifdef SOCKET_MISDN
                        case DSP_BF_REJECT:
                        case DSP_BF_REJECT:
-#else
-                       case BF_REJECT:
-#endif
                        chan_trace_header(p_m_mISDNport, this, "BCHANNEL control", DIRECTION_IN);
                        add_trace("DSP-CRYPT", NULL, "error");
                        end_trace();
                        chan_trace_header(p_m_mISDNport, this, "BCHANNEL control", DIRECTION_IN);
                        add_trace("DSP-CRYPT", NULL, "error");
                        end_trace();
@@ -1713,11 +1421,7 @@ void PmISDN::bchannel_receive(iframe_t *frm)
                        message_put(message);
                        break;
 
                        message_put(message);
                        break;
 
-#ifdef SOCKET_MISDN
                        case DSP_BF_ACCEPT:
                        case DSP_BF_ACCEPT:
-#else
-                       case BF_ACCEPT:
-#endif
                        chan_trace_header(p_m_mISDNport, this, "BCHANNEL control", DIRECTION_IN);
                        add_trace("DSP-CRYPT", NULL, "ok");
                        end_trace();
                        chan_trace_header(p_m_mISDNport, this, "BCHANNEL control", DIRECTION_IN);
                        add_trace("DSP-CRYPT", NULL, "ok");
                        end_trace();
@@ -1734,49 +1438,17 @@ void PmISDN::bchannel_receive(iframe_t *frm)
                }
                return;
        }
                }
                return;
        }
-#ifdef SOCKET_MISDN
        if (hh->prim == PH_CONTROL_IND)
        {
                switch(hh->id)
        if (hh->prim == PH_CONTROL_IND)
        {
                switch(hh->id)
-#else
-       if (frm->prim == (PH_SIGNAL | INDICATION)
-        || frm->prim == (PH_CONTROL | INDICATION))
-       {
-               switch(frm->dinfo)
-#endif
                {
                {
-#ifndef OLD_MISDN
-#ifndef SOCKET_MISDN
-                       case CMX_TX_DATA:
-                       if (!p_m_txdata)
-                       {
-                               /* if tx is off, it may happen that fifos send us pending informations, we just ignore them */
-                               PDEBUG(DEBUG_BCHANNEL, "PmISDN(%s) ignoring tx data, because 'txdata' is turned off\n", p_name);
-                               return;
-                       }
-                       /* see below (same condition) */
-                       if (p_state!=PORT_STATE_CONNECT
-                                && !p_m_mISDNport->tones)
-                               break;
-//                     printf(".");fflush(stdout);return;
-                       if (p_record)
-                               record(data, len, 1); // from up
-                       break;
-#endif
-#endif
-
                        default:
                        chan_trace_header(p_m_mISDNport, this, "BCHANNEL control", DIRECTION_IN);
                        default:
                        chan_trace_header(p_m_mISDNport, this, "BCHANNEL control", DIRECTION_IN);
-#ifdef SOCKET_MISDN
                        add_trace("unknown", NULL, "0x%x", hh->id);
                        add_trace("unknown", NULL, "0x%x", hh->id);
-#else
-                       add_trace("unknown", NULL, "0x%x", frm->dinfo);
-#endif
                        end_trace();
                }
                return;
        }
                        end_trace();
                }
                return;
        }
-#ifdef SOCKET_MISDN
        if (hh->prim == PH_DATA_REQ || hh->prim == DL_DATA_REQ)
        {
                if (!p_m_txdata)
        if (hh->prim == PH_DATA_REQ || hh->prim == DL_DATA_REQ)
        {
                if (!p_m_txdata)
@@ -1797,23 +1469,26 @@ void PmISDN::bchannel_receive(iframe_t *frm)
        if (hh->prim != PH_DATA_IND && hh->prim != DL_DATA_IND)
        {
                PERROR("Bchannel received unknown primitve: 0x%x\n", hh->prim);
        if (hh->prim != PH_DATA_IND && hh->prim != DL_DATA_IND)
        {
                PERROR("Bchannel received unknown primitve: 0x%x\n", hh->prim);
-#else
-       if (frm->prim != (PH_DATA | INDICATION) && frm->prim != (DL_DATA | INDICATION))
-       {
-               PERROR("Bchannel received unknown primitve: 0x%x\n", frm->prim);
-#endif
                return;
        }
                return;
        }
+
        /* calls will not process any audio data unless
        /* calls will not process any audio data unless
-        * the call is connected OR interface features audio during call setup.
+        * the call is connected OR tones feature is enabled.
         */
         */
-//printf("%d -> %d prim=%x joindata=%d tones=%d\n", p_serial, ACTIVE_EPOINT(p_epointlist), frm->prim, p_m_joindata, p_m_mISDNport->earlyb);    
 #ifndef DEBUG_COREBRIDGE
        if (p_state!=PORT_STATE_CONNECT
         && !p_m_mISDNport->tones)
                return;
 #endif
 
 #ifndef DEBUG_COREBRIDGE
        if (p_state!=PORT_STATE_CONNECT
         && !p_m_mISDNport->tones)
                return;
 #endif
 
+#if 0
+       /* the bearer capability must be audio in order to send and receive
+        * audio prior or after connect.
+        */
+       if (!(p_bearerinfo.capability&CLASS_CAPABILITY_AUDIO) && p_state!=PORT_STATE_CONNECT)
+               return;
+#endif
+
        /* if rx is off, it may happen that fifos send us pending informations, we just ignore them */
        if (p_m_rxoff)
        {
        /* if rx is off, it may happen that fifos send us pending informations, we just ignore them */
        if (p_m_rxoff)
        {
@@ -1870,11 +1545,7 @@ void PmISDN::set_echotest(int echo)
                PDEBUG(DEBUG_ISDN, "we set echo to echo=%d.\n", p_m_echo);
                if (p_m_b_channel)
                        if (p_m_mISDNport->b_state[p_m_b_index] == B_STATE_ACTIVE)
                PDEBUG(DEBUG_ISDN, "we set echo to echo=%d.\n", p_m_echo);
                if (p_m_b_channel)
                        if (p_m_mISDNport->b_state[p_m_b_index] == B_STATE_ACTIVE)
-#ifdef SOCKET_MISDN
                                ph_control(p_m_mISDNport, this, p_m_mISDNport->b_socket[p_m_b_index], p_m_echo?DSP_ECHO_ON:DSP_ECHO_OFF, 0, "DSP-ECHO", p_m_echo);
                                ph_control(p_m_mISDNport, this, p_m_mISDNport->b_socket[p_m_b_index], p_m_echo?DSP_ECHO_ON:DSP_ECHO_OFF, 0, "DSP-ECHO", p_m_echo);
-#else
-                               ph_control(p_m_mISDNport, this, p_m_mISDNport->b_addr[p_m_b_index], p_m_echo?CMX_ECHO_ON:CMX_ECHO_OFF, 0, "DSP-ECHO", p_m_echo);
-#endif
        }
 }
 
        }
 }
 
@@ -1903,11 +1574,7 @@ void PmISDN::set_tone(char *dir, char *tone)
                if (p_m_mISDNport->b_state[p_m_b_index] == B_STATE_ACTIVE)
                {
                        PDEBUG(DEBUG_ISDN, "we reset tone from id=%d to OFF.\n", p_m_tone);
                if (p_m_mISDNport->b_state[p_m_b_index] == B_STATE_ACTIVE)
                {
                        PDEBUG(DEBUG_ISDN, "we reset tone from id=%d to OFF.\n", p_m_tone);
-#ifdef SOCKET_MISDN
                        ph_control(p_m_mISDNport, this, p_m_mISDNport->b_socket[p_m_b_index], DSP_TONE_PATT_OFF, 0, "DSP-TONE", 0);
                        ph_control(p_m_mISDNport, this, p_m_mISDNport->b_socket[p_m_b_index], DSP_TONE_PATT_OFF, 0, "DSP-TONE", 0);
-#else
-                       ph_control(p_m_mISDNport, this, p_m_mISDNport->b_addr[p_m_b_index], TONE_PATT_OFF, 0, "DSP-TONE", 0);
-#endif
                }
                p_m_tone = 0;
                Port::set_tone(dir, tone);
                }
                p_m_tone = 0;
                Port::set_tone(dir, tone);
@@ -1989,11 +1656,7 @@ void PmISDN::set_tone(char *dir, char *tone)
                PDEBUG(DEBUG_ISDN, "we set tone to id=%d.\n", p_m_tone);
                if (p_m_b_index > -1)
                if (p_m_mISDNport->b_state[p_m_b_index] == B_STATE_ACTIVE)
                PDEBUG(DEBUG_ISDN, "we set tone to id=%d.\n", p_m_tone);
                if (p_m_b_index > -1)
                if (p_m_mISDNport->b_state[p_m_b_index] == B_STATE_ACTIVE)
-#ifdef SOCKET_MISDN
                        ph_control(p_m_mISDNport, this, p_m_mISDNport->b_socket[p_m_b_index], p_m_tone?DSP_TONE_PATT_ON:DSP_TONE_PATT_OFF, p_m_tone, "DSP-TONE", p_m_tone);
                        ph_control(p_m_mISDNport, this, p_m_mISDNport->b_socket[p_m_b_index], p_m_tone?DSP_TONE_PATT_ON:DSP_TONE_PATT_OFF, p_m_tone, "DSP-TONE", p_m_tone);
-#else
-                       ph_control(p_m_mISDNport, this, p_m_mISDNport->b_addr[p_m_b_index], p_m_tone?TONE_PATT_ON:TONE_PATT_OFF, p_m_tone, "DSP-TONE", p_m_tone);
-#endif
        }
        /* turn user-space tones off in cases of no tone OR dsp tone */
        Port::set_tone("",NULL);
        }
        /* turn user-space tones off in cases of no tone OR dsp tone */
        Port::set_tone("",NULL);
@@ -2013,11 +1676,7 @@ void PmISDN::message_mISDNsignal(unsigned long epoint_id, int message_id, union
                        PDEBUG(DEBUG_BCHANNEL, "we change tx-volume to shift=%d.\n", p_m_tx_gain);
                        if (p_m_b_index > -1)
                        if (p_m_mISDNport->b_state[p_m_b_index] == B_STATE_ACTIVE)
                        PDEBUG(DEBUG_BCHANNEL, "we change tx-volume to shift=%d.\n", p_m_tx_gain);
                        if (p_m_b_index > -1)
                        if (p_m_mISDNport->b_state[p_m_b_index] == B_STATE_ACTIVE)
-#ifdef SOCKET_MISDN
                                ph_control(p_m_mISDNport, this, p_m_mISDNport->b_socket[p_m_b_index], DSP_VOL_CHANGE_TX, p_m_tx_gain, "DSP-TX_GAIN", p_m_tx_gain);
                                ph_control(p_m_mISDNport, this, p_m_mISDNport->b_socket[p_m_b_index], DSP_VOL_CHANGE_TX, p_m_tx_gain, "DSP-TX_GAIN", p_m_tx_gain);
-#else
-                               ph_control(p_m_mISDNport, this, p_m_mISDNport->b_addr[p_m_b_index], VOL_CHANGE_TX, p_m_tx_gain, "DSP-TX_GAIN", p_m_tx_gain);
-#endif
                } else
                        PDEBUG(DEBUG_BCHANNEL, "we already have tx-volume shift=%d.\n", p_m_rx_gain);
                if (p_m_rx_gain != param->mISDNsignal.rx_gain)
                } else
                        PDEBUG(DEBUG_BCHANNEL, "we already have tx-volume shift=%d.\n", p_m_rx_gain);
                if (p_m_rx_gain != param->mISDNsignal.rx_gain)
@@ -2026,11 +1685,7 @@ void PmISDN::message_mISDNsignal(unsigned long epoint_id, int message_id, union
                        PDEBUG(DEBUG_BCHANNEL, "we change rx-volume to shift=%d.\n", p_m_rx_gain);
                        if (p_m_b_index > -1)
                        if (p_m_mISDNport->b_state[p_m_b_index] == B_STATE_ACTIVE)
                        PDEBUG(DEBUG_BCHANNEL, "we change rx-volume to shift=%d.\n", p_m_rx_gain);
                        if (p_m_b_index > -1)
                        if (p_m_mISDNport->b_state[p_m_b_index] == B_STATE_ACTIVE)
-#ifdef SOCKET_MISDN
                                ph_control(p_m_mISDNport, this, p_m_mISDNport->b_socket[p_m_b_index], DSP_VOL_CHANGE_RX, p_m_rx_gain, "DSP-RX_GAIN", p_m_rx_gain);
                                ph_control(p_m_mISDNport, this, p_m_mISDNport->b_socket[p_m_b_index], DSP_VOL_CHANGE_RX, p_m_rx_gain, "DSP-RX_GAIN", p_m_rx_gain);
-#else
-                               ph_control(p_m_mISDNport, this, p_m_mISDNport->b_addr[p_m_b_index], VOL_CHANGE_RX, p_m_rx_gain, "DSP-RX_GAIN", p_m_rx_gain);
-#endif
                } else
                        PDEBUG(DEBUG_BCHANNEL, "we already have rx-volume shift=%d.\n", p_m_rx_gain);
                break;
                } else
                        PDEBUG(DEBUG_BCHANNEL, "we already have rx-volume shift=%d.\n", p_m_rx_gain);
                break;
@@ -2044,11 +1699,7 @@ void PmISDN::message_mISDNsignal(unsigned long epoint_id, int message_id, union
                        PDEBUG(DEBUG_BCHANNEL, "we change conference to conf=%d.\n", p_m_conf);
                        if (p_m_b_index > -1)
                        if (p_m_mISDNport->b_state[p_m_b_index] == B_STATE_ACTIVE)
                        PDEBUG(DEBUG_BCHANNEL, "we change conference to conf=%d.\n", p_m_conf);
                        if (p_m_b_index > -1)
                        if (p_m_mISDNport->b_state[p_m_b_index] == B_STATE_ACTIVE)
-#ifdef SOCKET_MISDN
                                ph_control(p_m_mISDNport, this, p_m_mISDNport->b_socket[p_m_b_index], (p_m_conf)?DSP_CONF_JOIN:DSP_CONF_SPLIT, p_m_conf, "DSP-CONF", p_m_conf);
                                ph_control(p_m_mISDNport, this, p_m_mISDNport->b_socket[p_m_b_index], (p_m_conf)?DSP_CONF_JOIN:DSP_CONF_SPLIT, p_m_conf, "DSP-CONF", p_m_conf);
-#else
-                               ph_control(p_m_mISDNport, this, p_m_mISDNport->b_addr[p_m_b_index], (p_m_conf)?CMX_CONF_JOIN:CMX_CONF_SPLIT, p_m_conf, "DSP-CONF", p_m_conf);
-#endif
                } else
                        PDEBUG(DEBUG_BCHANNEL, "we already have conf=%d.\n", p_m_conf);
                /* we must set, even if currently tone forbids conf */
                } else
                        PDEBUG(DEBUG_BCHANNEL, "we already have conf=%d.\n", p_m_conf);
                /* we must set, even if currently tone forbids conf */
@@ -2070,15 +1721,9 @@ void PmISDN::message_mISDNsignal(unsigned long epoint_id, int message_id, union
                {
                        p_m_delay = param->mISDNsignal.delay;
                        PDEBUG(DEBUG_BCHANNEL, "we change delay mode to delay=%d.\n", p_m_delay);
                {
                        p_m_delay = param->mISDNsignal.delay;
                        PDEBUG(DEBUG_BCHANNEL, "we change delay mode to delay=%d.\n", p_m_delay);
-#ifndef OLD_MISDN
                        if (p_m_b_index > -1)
                        if (p_m_mISDNport->b_state[p_m_b_index] == B_STATE_ACTIVE)
                        if (p_m_b_index > -1)
                        if (p_m_mISDNport->b_state[p_m_b_index] == B_STATE_ACTIVE)
-#ifdef SOCKET_MISDN
                                ph_control(p_m_mISDNport, this, p_m_mISDNport->b_socket[p_m_b_index], p_m_delay?DSP_DELAY:DSP_JITTER, p_m_delay, "DSP-DELAY", p_m_delay);
                                ph_control(p_m_mISDNport, this, p_m_mISDNport->b_socket[p_m_b_index], p_m_delay?DSP_DELAY:DSP_JITTER, p_m_delay, "DSP-DELAY", p_m_delay);
-#else
-                               ph_control(p_m_mISDNport, this, p_m_mISDNport->b_addr[p_m_b_index], p_m_delay?CMX_DELAY:CMX_JITTER, p_m_delay, "DSP-DELAY", p_m_delay);
-#endif
-#endif
                } else
                        PDEBUG(DEBUG_BCHANNEL, "we already have delay=%d.\n", p_m_delay);
                break;
                } else
                        PDEBUG(DEBUG_BCHANNEL, "we already have delay=%d.\n", p_m_delay);
                break;
@@ -2111,11 +1756,7 @@ void PmISDN::message_crypt(unsigned long epoint_id, int message_id, union parame
                PDEBUG(DEBUG_BCHANNEL, "we set encryption to crypt=%d. (0 means OFF)\n", p_m_crypt);
                if (p_m_b_index > -1)
                if (p_m_mISDNport->b_state[p_m_b_index] == B_STATE_ACTIVE)
                PDEBUG(DEBUG_BCHANNEL, "we set encryption to crypt=%d. (0 means OFF)\n", p_m_crypt);
                if (p_m_b_index > -1)
                if (p_m_mISDNport->b_state[p_m_b_index] == B_STATE_ACTIVE)
-#ifdef SOCKET_MISDN
                        ph_control_block(p_m_mISDNport, this, p_m_mISDNport->b_socket[p_m_b_index], p_m_crypt?DSP_BF_ENABLE_KEY:DSP_BF_DISABLE, p_m_crypt_key, p_m_crypt_key_len, "DSP-CRYPT", p_m_crypt_key_len);
                        ph_control_block(p_m_mISDNport, this, p_m_mISDNport->b_socket[p_m_b_index], p_m_crypt?DSP_BF_ENABLE_KEY:DSP_BF_DISABLE, p_m_crypt_key, p_m_crypt_key_len, "DSP-CRYPT", p_m_crypt_key_len);
-#else
-                       ph_control_block(p_m_mISDNport, this, p_m_mISDNport->b_addr[p_m_b_index], p_m_crypt?BF_ENABLE_KEY:BF_DISABLE, p_m_crypt_key, p_m_crypt_key_len, "DSP-CRYPT", p_m_crypt_key_len);
-#endif
                break;
 
                case CC_DACT_REQ:            /* deactivate session encryption */
                break;
 
                case CC_DACT_REQ:            /* deactivate session encryption */
@@ -2146,11 +1787,7 @@ void PmISDN::message_crypt(unsigned long epoint_id, int message_id, union parame
                if (p_m_txmix && p_m_b_index>=0)
                {
                        PDEBUG(DEBUG_BCHANNEL, "for sending CR_MESSAGE_REQ, we reset txmix from txmix=%d.\n", p_m_txmix);
                if (p_m_txmix && p_m_b_index>=0)
                {
                        PDEBUG(DEBUG_BCHANNEL, "for sending CR_MESSAGE_REQ, we reset txmix from txmix=%d.\n", p_m_txmix);
-#ifdef SOCKET_MISDN
                        ph_control(p_m_mISDNport, this, p_mISDNport->b_socket[p_m_b_index], DSP_MIX_OFF, 0, "DSP-TXMIX", 0);
                        ph_control(p_m_mISDNport, this, p_mISDNport->b_socket[p_m_b_index], DSP_MIX_OFF, 0, "DSP-TXMIX", 0);
-#else
-                       ph_control(p_m_mISDNport, this, p_mISDNport->b_addr[p_m_b_index], CMX_MIX_OFF, 0, "DSP-TXMIX", 0);
-#endif
                }
 #endif
                break;
                }
 #endif
                break;
@@ -2193,7 +1830,6 @@ int PmISDN::message_epoint(unsigned long epoint_id, int message_id, union parame
 /*
  * main loop for processing messages from mISDN
  */
 /*
  * main loop for processing messages from mISDN
  */
-#ifdef SOCKET_MISDN
 int mISDN_handler(void)
 {
        int ret, work = 0;
 int mISDN_handler(void)
 {
        int ret, work = 0;
@@ -2452,468 +2088,7 @@ int mISDN_handler(void)
        /* if we received at least one b-frame, we will return 1 */
        return(work);
 }
        /* if we received at least one b-frame, we will return 1 */
        return(work);
 }
-#else
-int mISDN_handler(void)
-{
-       int ret;
-       struct mISDNport *mISDNport;
-       class PmISDN *isdnport;
-       int i;
-       msg_t *msg;
-       iframe_t *frm;
-       msg_t *dmsg;
-       mISDNuser_head_t *hh;
-       net_stack_t *nst;
-
-       /* the que avoids loopbacks when replying to stack after receiving
-         * from stack. */
-       mISDNport = mISDNport_first;
-       while(mISDNport)
-       {
-               /* process turning on/off rx */
-               i = 0;
-               while(i < mISDNport->b_num)
-               {
-                       /* process timer events for bchannel handling */
-                       if (mISDNport->b_timer[i])
-                       {
-                               if (mISDNport->b_timer[i] <= now_d)
-                                       bchannel_event(mISDNport, i, B_EVENT_TIMEOUT);
-                       }
-                       isdnport=mISDNport->b_port[i];
-                       if (isdnport)
-                       {
-                               /* call bridges in user space OR crypto OR recording */
-                               if (isdnport->p_m_joindata || isdnport->p_m_crypt_msg_loops || isdnport->p_m_crypt_listen || isdnport->p_record)
-                               {
-                                       /* rx IS required */
-                                       if (isdnport->p_m_rxoff)
-                                       {
-                                               /* turn on RX */
-                                               isdnport->p_m_rxoff = 0;
-                                               PDEBUG(DEBUG_BCHANNEL, "%s: receive data is required, so we turn them on\n", __FUNCTION__);
-                                               if (mISDNport->b_port[i] && mISDNport->b_state[i] == B_STATE_ACTIVE)
-                                                       ph_control(mISDNport, isdnport, mISDNport->b_addr[isdnport->p_m_b_index], CMX_RECEIVE_ON, 0, "DSP-RXOFF", 0);
-                                               return(1);
-                                       }
-                               } else
-                               {
-                                       /* rx NOT required */
-                                       if (!isdnport->p_m_rxoff)
-                                       {
-                                               /* turn off RX */
-                                               isdnport->p_m_rxoff = 1;
-                                               PDEBUG(DEBUG_BCHANNEL, "%s: receive data is not required, so we turn them off\n", __FUNCTION__);
-                                               if (mISDNport->b_port[i] && mISDNport->b_state[i] == B_STATE_ACTIVE)
-                                                       ph_control(mISDNport, isdnport, mISDNport->b_addr[isdnport->p_m_b_index], CMX_RECEIVE_OFF, 0, "DSP-RXOFF", 1);
-                                               return(1);
-                                       }
-                               }
-                               /* recording */
-                               if (isdnport->p_record)
-                               {
-                                       /* txdata IS required */
-                                       if (!isdnport->p_m_txdata)
-                                       {
-                                               /* turn on RX */
-                                               isdnport->p_m_txdata = 1;
-                                               PDEBUG(DEBUG_BCHANNEL, "%s: transmit data is required, so we turn them on\n", __FUNCTION__);
-#ifndef OLD_MISDN
-                                               if (mISDNport->b_port[i] && mISDNport->b_state[i] == B_STATE_ACTIVE)
-                                                       ph_control(mISDNport, isdnport, mISDNport->b_addr[isdnport->p_m_b_index], CMX_TXDATA_ON, 0, "DSP-TXDATA", 1);
-#endif
-                                               return(1);
-                                       }
-                               } else
-                               {
-                                       /* txdata NOT required */
-                                       if (isdnport->p_m_txdata)
-                                       {
-                                               /* turn off RX */
-                                               isdnport->p_m_txdata = 0;
-                                               PDEBUG(DEBUG_BCHANNEL, "%s: transmit data is not required, so we turn them off\n", __FUNCTION__);
-#ifndef OLD_MISDN
-                                               if (mISDNport->b_port[i] && mISDNport->b_state[i] == B_STATE_ACTIVE)
-                                                       ph_control(mISDNport, isdnport, mISDNport->b_addr[isdnport->p_m_b_index], CMX_TXDATA_OFF, 0, "DSP-TXDATA", 0);
-#endif
-                                               return(1);
-                                       }
-                               }
-                       }
-                       i++;
-               }
-#if 0
-               if (mISDNport->l1timeout && now>mISDNport->l1timeout)
-               { ---}
-                       PDEBUG(DEBUG_ISDN, "the L1 establish timer expired, we release all pending messages.\n", mISDNport->portnum);
-                       mISDNport->l1timeout = 0;
-#endif
-
-               if (mISDNport->l2establish)
-               {
-                       if (now-mISDNport->l2establish > 5)
-                       {
-                               mISDNport->l2establish = 0;
-                               if (mISDNport->l2hold && (mISDNport->ptp || !mISDNport->ntmode))
-                               {
-                                       if (mISDNport->ntmode)
-                                       {
-                                               PDEBUG(DEBUG_ISDN, "the L2 establish timer expired, we try to establish the link NT portnum=%d.\n", mISDNport->portnum);
-                                               time(&mISDNport->l2establish);
-                                               /* establish */
-                                               dmsg = create_l2msg(DL_ESTABLISH | REQUEST, 0, 0);
-                                               if (mISDNport->nst.manager_l3(&mISDNport->nst, dmsg))
-                                                       free_msg(dmsg);
-                                       } else {
-                                               iframe_t act;
-
-                                               PDEBUG(DEBUG_ISDN, "the L2 establish timer expired, we try to establish the link TE portnum=%d.\n", mISDNport->portnum);
-                                               time(&mISDNport->l2establish);
-                                               /* establish */
-                                               act.prim = DL_ESTABLISH | REQUEST; 
-                                               act.addr = (mISDNport->upper_id & ~LAYER_ID_MASK) | 3 | FLG_MSG_DOWN;
-                                               act.dinfo = 0;
-                                               act.len = 0;
-                                               mISDN_write(mISDNdevice, &act, mISDN_HEADER_LEN+act.len, TIMEOUT_1SEC);
-                                       }
-                                       l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_REQ, DIRECTION_OUT);
-                                       add_trace("tei", NULL, "%d", 0);
-                                       end_trace();
-                                       time(&mISDNport->l2establish);
-                                       return(1);
-                               }
-                       }
-               }
-               if ((dmsg = msg_dequeue(&mISDNport->downqueue)))
-               {
-                       if (mISDNport->ntmode)
-                       {
-                               hh = (mISDNuser_head_t *)dmsg->data;
-                               PDEBUG(DEBUG_ISDN, "sending queued NT l3-down-message: prim(0x%x) dinfo(0x%x) msg->len(%d)\n", hh->prim, hh->dinfo, dmsg->len);
-                               if (mISDNport->nst.manager_l3(&mISDNport->nst, dmsg))
-                                       free_msg(dmsg);
-                       } else
-                       {
-                               frm = (iframe_t *)dmsg->data;
-                               frm->addr = mISDNport->upper_id | FLG_MSG_DOWN;
-                               frm->len = (dmsg->len) - mISDN_HEADER_LEN;
-                               PDEBUG(DEBUG_ISDN, "sending queued TE l3-down-message: prim(0x%x) dinfo(0x%x) msg->len(%d)\n", frm->prim, frm->dinfo, dmsg->len);
-                               mISDN_write(mISDNdevice, dmsg->data, dmsg->len, TIMEOUT_1SEC);
-                               free_msg(dmsg);
-                       }
-                       return(1);
-               }
-               mISDNport = mISDNport->next;
-       } 
-
-       /* no device, no read */
-       if (mISDNdevice < 0)
-               return(0);
-
-       /* get message from kernel */
-       if (!(msg = alloc_msg(MAX_MSG_SIZE)))
-               return(1);
-       ret = mISDN_read(mISDNdevice, msg->data, MAX_MSG_SIZE, 0);
-       if (ret < 0)
-       {
-               free_msg(msg);
-               if (errno == EAGAIN)
-                       return(0);
-               FATAL("Failed to do mISDN_read()\n");
-       }
-       if (!ret)
-       {
-               free_msg(msg);
-//             printf("%s: ERROR: mISDN_read() returns nothing\n");
-               return(0);
-       }
-       msg->len = ret;
-       frm = (iframe_t *)msg->data;
-
-       /* global prim */
-       switch(frm->prim)
-       {
-               case MGR_DELLAYER | CONFIRM:
-               case MGR_INITTIMER | CONFIRM:
-               case MGR_ADDTIMER | CONFIRM:
-               case MGR_DELTIMER | CONFIRM:
-               case MGR_REMOVETIMER | CONFIRM:
-               free_msg(msg);
-               return(1);
-       }
-
-       /* handle timer events from mISDN for NT-stack
-        * note: they do not associate with a stack */
-       if (frm->prim == (MGR_TIMER | INDICATION))
-       {
-               itimer_t *it;
-
-               /* find mISDNport */
-               mISDNport = mISDNport_first;
-               while(mISDNport)
-               {
-                       /* nt mode only */
-                       if (mISDNport->ntmode)
-                       {
-                               it = mISDNport->nst.tlist;
-                               /* find timer */
-                               while(it)
-                               {
-                                       if (it->id == (int)frm->addr)
-                                               break;
-                                       it = it->next;
-                               }
-                               if (it)
-                                       break;
-                       }
-                       mISDNport = mISDNport->next;
-               }
-               if (mISDNport)
-               {
-                       mISDN_write_frame(mISDNdevice, msg->data, mISDNport->upper_id | FLG_MSG_DOWN,
-                               MGR_TIMER | RESPONSE, 0, 0, NULL, TIMEOUT_1SEC);
-
-                       PDEBUG(DEBUG_ISDN, "timer-indication port %d it=%p\n", mISDNport->portnum, it);
-                       test_and_clear_bit(FLG_TIMER_RUNING, (long unsigned int *)&it->Flags);
-                       ret = it->function(it->data);
-               } else
-               {
-                       PDEBUG(DEBUG_ISDN, "timer-indication not handled\n");
-               }
-               goto out;
-       }
-
-       /* find the mISDNport that belongs to the stack */
-       mISDNport = mISDNport_first;
-       while(mISDNport)
-       {
-               if ((frm->addr&MASTER_ID_MASK) == (unsigned int)(mISDNport->upper_id&MASTER_ID_MASK))
-                       break;
-               mISDNport = mISDNport->next;
-       } 
-       if (!mISDNport)
-       {
-               PERROR("message belongs to no mISDNport: prim(0x%x) addr(0x%x) msg->len(%d)\n", frm->prim, frm->addr, msg->len);
-               // show a list of all mISDNports and their address
-#if 0
-               mISDNport = mISDNport_first;
-               while(mISDNport)
-               {
-                       PERROR(" port %s  %x -> %x\n", mISDNport->name, (frm->addr&MASTER_ID_MASK), (unsigned int)(mISDNport->upper_id&MASTER_ID_MASK));
-                       mISDNport = mISDNport->next;
-               } 
-#endif
-               goto out;
-       }
-
-       /* master stack */
-       if (!(frm->addr&FLG_CHILD_STACK))
-       {
-               /* d-message */
-               switch(frm->prim)
-               {
-                       case MGR_SHORTSTATUS | INDICATION:
-                       case MGR_SHORTSTATUS | CONFIRM:
-                       switch(frm->dinfo) {
-                               case SSTATUS_L1_ACTIVATED:
-                               l1l2l3_trace_header(mISDNport, NULL, L1_ACTIVATE_REQ | (frm->prim & 0x3), DIRECTION_IN);
-                               end_trace();
-                               goto ss_act;
-                               case SSTATUS_L1_DEACTIVATED:
-                               l1l2l3_trace_header(mISDNport, NULL, L1_DEACTIVATE_REQ | (frm->prim & 0x3), DIRECTION_IN);
-                               end_trace();
-                               goto ss_deact;
-                               case SSTATUS_L2_ESTABLISHED:
-                               l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_REQ | (frm->prim & 0x3), DIRECTION_IN);
-                               end_trace();
-                               goto ss_estab;
-                               case SSTATUS_L2_RELEASED:
-                               l1l2l3_trace_header(mISDNport, NULL, L2_RELEASE_REQ | (frm->prim & 0x3), DIRECTION_IN);
-                               end_trace();
-                               goto ss_rel;
-                       }
-                       break;
-
-                       case PH_ACTIVATE | CONFIRM:
-                       case PH_ACTIVATE | INDICATION:
-                       l1l2l3_trace_header(mISDNport, NULL, L1_ACTIVATE_REQ | (frm->prim & 0x3), DIRECTION_IN);
-                       end_trace();
-                       if (mISDNport->ntmode)
-                       {
-                               mISDNport->l1link = 1;
-                               setup_queue(mISDNport, 1);
-                               goto l1_msg;
-                       }
-                       ss_act:
-                       mISDNport->l1link = 1;
-                       setup_queue(mISDNport, 1);
-                       break;
-
-                       case PH_DEACTIVATE | CONFIRM:
-                       case PH_DEACTIVATE | INDICATION:
-                       l1l2l3_trace_header(mISDNport, NULL, L1_DEACTIVATE_REQ | (frm->prim & 0x3), DIRECTION_IN);
-                       end_trace();
-                       if (mISDNport->ntmode)
-                       {
-                               mISDNport->l1link = 0;
-                               setup_queue(mISDNport, 0);
-                               goto l1_msg;
-                       }
-                       ss_deact:
-                       mISDNport->l1link = 0;
-                       setup_queue(mISDNport, 0);
-                       break;
-
-                       case PH_CONTROL | CONFIRM:
-                       case PH_CONTROL | INDICATION:
-                       PDEBUG(DEBUG_ISDN, "Received PH_CONTROL for port %d (%s).\n", mISDNport->portnum, mISDNport->ifport->interface->name);
-                       break;
-
-                       case DL_ESTABLISH | INDICATION:
-                       case DL_ESTABLISH | CONFIRM:
-                       l1l2l3_trace_header(mISDNport, NULL, DL_ESTABLISH_REQ | (frm->prim & 0x3), DIRECTION_IN);
-                       end_trace();
-                       if (!mISDNport->ntmode) break; /* !!!!!!!!!!!!!!!! */
-                       ss_estab:
-                       if (!mISDNport->ntmode || mISDNport->ptp)
-                       {
-                               if (mISDNport->l2establish)
-                               {
-                                       mISDNport->l2establish = 0;
-                                       PDEBUG(DEBUG_ISDN, "the link became active before l2establish timer expiry.\n");
-                               }
-                               mISDNport->l2link = 1;
-                       }
-                       break;
-
-                       case DL_RELEASE | INDICATION:
-                       case DL_RELEASE | CONFIRM:
-                       l1l2l3_trace_header(mISDNport, NULL, DL_RELEASE_REQ | (frm->prim & 0x3), DIRECTION_IN);
-                       end_trace();
-                       if (!mISDNport->ntmode) break; /* !!!!!!!!!!!!!!!! */
-                       ss_rel:
-                       if (!mISDNport->ntmode || mISDNport->ptp)
-                       {
-                               mISDNport->l2link = 0;
-                               if (mISDNport->l2hold)
-                               {
-                                       time(&mISDNport->l2establish);
-                                       PDEBUG(DEBUG_ISDN, "because we are ptp, we set a l2establish timer.\n");
-                               }
-                       }
-                       break;
-
-                       default:
-                       l1_msg:
-                       PDEBUG(DEBUG_STACK, "GOT d-msg from %s port %d prim 0x%x dinfo 0x%x addr 0x%x\n", (mISDNport->ntmode)?"NT":"TE", mISDNport->portnum, frm->prim, frm->dinfo, frm->addr);
-                       if (frm->dinfo==(signed long)0xffffffff && frm->prim==(PH_DATA|CONFIRM))
-                       {
-                               PERROR("SERIOUS BUG, dinfo == 0xffffffff, prim == PH_DATA | CONFIRM !!!!\n");
-                       }
-                       /* d-message */
-                       if (mISDNport->ntmode)
-                       {
-                               /* l1-data enters the nt-mode library */
-                               nst = &mISDNport->nst;
-                               if (nst->l1_l2(nst, msg))
-                                       free_msg(msg);
-                               return(1);
-                       } else
-                       {
-                               /* l3-data is sent to pbx */
-                               if (stack2manager_te(mISDNport, msg))
-                                       free_msg(msg);
-                               return(1);
-                       }
-               }
-       } else
-       /* child stack */
-       {
-               /* b-message */
-               switch(frm->prim)
-               {
-                       /* we don't care about confirms, we use rx data to sync tx */
-                       case PH_DATA | CONFIRM:
-                       case DL_DATA | CONFIRM:
-                       break;
-
-                       /* we receive audio data, we respond to it AND we send tones */
-                       case PH_DATA | INDICATION:
-                       case DL_DATA | INDICATION:
-                       case PH_CONTROL | INDICATION:
-                       case PH_SIGNAL | INDICATION:
-                       i = 0;
-                       while(i < mISDNport->b_num)
-                       {
-                               if ((unsigned int)(mISDNport->b_addr[i]&STACK_ID_MASK) == (frm->addr&STACK_ID_MASK))
-                                       break;
-                               i++;
-                       }
-                       if (i == mISDNport->b_num)
-                       {
-                               PERROR("unhandled b-message (prim 0x%x address 0x%x).\n", frm->prim, frm->addr);
-                               break;
-                       }
-                       if (mISDNport->b_port[i])
-                       {
-//PERROR("port sech: %s data\n", mISDNport->b_port[i]->p_name);
-                               mISDNport->b_port[i]->bchannel_receive(frm);
-                       } else
-                               PDEBUG(DEBUG_BCHANNEL, "b-channel is not associated to an ISDNPort (address 0x%x), ignoring.\n", frm->addr);
-                       break;
-
-                       case PH_ACTIVATE | INDICATION:
-                       case DL_ESTABLISH | INDICATION:
-                       case PH_ACTIVATE | CONFIRM:
-                       case DL_ESTABLISH | CONFIRM:
-                       PDEBUG(DEBUG_BCHANNEL, "DL_ESTABLISH confirm: bchannel is now activated (address 0x%x).\n", frm->addr);
-                       i = 0;
-                       while(i < mISDNport->b_num)
-                       {
-                               if ((unsigned int)(mISDNport->b_addr[i]&STACK_ID_MASK) == (frm->addr&STACK_ID_MASK))
-                                       break;
-                               i++;
-                       }
-                       if (i == mISDNport->b_num)
-                       {
-                               PERROR("unhandled b-establish (prim 0x%x address 0x%x).\n", frm->prim, frm->addr);
-                               break;
-                       }
-                       bchannel_event(mISDNport, i, B_EVENT_ACTIVATED);
-                       break;
-
-                       case PH_DEACTIVATE | INDICATION:
-                       case DL_RELEASE | INDICATION:
-                       case PH_DEACTIVATE | CONFIRM:
-                       case DL_RELEASE | CONFIRM:
-                       PDEBUG(DEBUG_BCHANNEL, "DL_RELEASE confirm: bchannel is now de-activated (address 0x%x).\n", frm->addr);
-                       i = 0;
-                       while(i < mISDNport->b_num)
-                       {
-                               if ((unsigned int)(mISDNport->b_addr[i]&STACK_ID_MASK) == (frm->addr&STACK_ID_MASK))
-                                       break;
-                               i++;
-                       }
-                       if (i == mISDNport->b_num)
-                       {
-                               PERROR("unhandled b-release (prim 0x%x address 0x%x).\n", frm->prim, frm->addr);
-                               break;
-                       }
-                       bchannel_event(mISDNport, i, B_EVENT_DEACTIVATED);
-                       break;
-
-                       default:
-                       PERROR("child message not handled: prim(0x%x) addr(0x%x) msg->len(%d)\n", frm->prim, frm->addr, msg->len);
-               }
-       }
-
-       out:
-       free_msg(msg);
-       return(1);
-}
-#endif
 
 
-#ifdef SOCKET_MISDN
 int do_layer3(struct mlayer3 *ml3, unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
        /* IMPORTAINT:
 int do_layer3(struct mlayer3 *ml3, unsigned int cmd, unsigned int pid, struct l3_msg *l3m)
 {
        /* IMPORTAINT:
@@ -2957,8 +2132,6 @@ int do_layer3(struct mlayer3 *ml3, unsigned int cmd, unsigned int pid, struct l3
        return 0;
 }
 
        return 0;
 }
 
-#endif
-
 
 /*
  * global function to add a new card (port)
 
 /*
  * global function to add a new card (port)
@@ -2970,7 +2143,6 @@ struct mISDNport *mISDNport_open(int port, int ptp, int force_nt, int l2hold, st
        int i, cnt;
        int pri, bri, pots;
        int nt, te;
        int i, cnt;
        int pri, bri, pots;
        int nt, te;
-#ifdef SOCKET_MISDN
 //     struct mlayer3 *ml3;
        struct mISDN_devinfo devinfo;
        unsigned int protocol, prop;
 //     struct mlayer3 *ml3;
        struct mISDN_devinfo devinfo;
        unsigned int protocol, prop;
@@ -2981,18 +2153,6 @@ struct mISDNport *mISDNport_open(int port, int ptp, int force_nt, int l2hold, st
                fprintf(stderr, "Cannot get number of mISDN devices. (ioctl IMGETCOUNT failed ret=%d)\n", ret);
                return(NULL);
        }
                fprintf(stderr, "Cannot get number of mISDN devices. (ioctl IMGETCOUNT failed ret=%d)\n", ret);
                return(NULL);
        }
-#else
-       unsigned char buff[1025];
-       iframe_t *frm = (iframe_t *)buff;
-//     interface_info_t ii;
-       net_stack_t *nst;
-       manager_t *mgr;
-       layer_info_t li;
-       stack_info_t *stinf;
-
-       /* query port's requirements */
-       cnt = mISDN_get_stack_count(mISDNdevice);
-#endif
 
        if (cnt <= 0)
        {
 
        if (cnt <= 0)
        {
@@ -3006,7 +2166,6 @@ struct mISDNport *mISDNport_open(int port, int ptp, int force_nt, int l2hold, st
        }
 
        pri = bri = pots = nt = te = 0;
        }
 
        pri = bri = pots = nt = te = 0;
-#ifdef SOCKET_MISDN
        devinfo.id = port - 1;
        ret = ioctl(mISDNsocket, IMGETDEVINFO, &devinfo);
        if (ret < 0)
        devinfo.id = port - 1;
        ret = ioctl(mISDNsocket, IMGETDEVINFO, &devinfo);
        if (ret < 0)
@@ -3080,86 +2239,6 @@ struct mISDNport *mISDNport_open(int port, int ptp, int force_nt, int l2hold, st
        /* if TE an NT is supported (and not forced to NT), turn off NT */
        if (te && nt)
                nt = 0;
        /* if TE an NT is supported (and not forced to NT), turn off NT */
        if (te && nt)
                nt = 0;
-#else
-       ret = mISDN_get_stack_info(mISDNdevice, port, buff, sizeof(buff));
-       if (ret < 0)
-       {
-               PERROR_RUNTIME("Cannot get stack info for port %d (ret=%d)\n", port, ret);
-               return(NULL);
-       }
-       stinf = (stack_info_t *)&frm->data.p;
-       switch(stinf->pid.protocol[0] & ~ISDN_PID_FEATURE_MASK)
-       {
-               case ISDN_PID_L0_TE_S0:
-               PDEBUG(DEBUG_ISDN, "TE-mode BRI S/T interface line\n");
-               break;
-               case ISDN_PID_L0_NT_S0:
-               PDEBUG(DEBUG_ISDN, "NT-mode BRI S/T interface port\n");
-               nt = 1;
-               break;
-               case ISDN_PID_L0_TE_E1:
-               PDEBUG(DEBUG_ISDN, "TE-mode PRI E1  interface line\n");
-               pri = 1;
-               break;
-               case ISDN_PID_L0_NT_E1:
-               PDEBUG(DEBUG_ISDN, "LT-mode PRI E1  interface port\n");
-               pri = 1;
-               nt = 1;
-               break;
-               default:
-               PERROR_RUNTIME("unknown port(%d) type 0x%08x\n", port, stinf->pid.protocol[0]);
-               return(NULL);
-       }
-       if (nt)
-       {
-               /* NT */
-               if (stinf->pid.protocol[1] == 0)
-               {
-                       PERROR_RUNTIME("Given port %d: Missing layer 1 NT-mode protocol.\n", port);
-                       return(NULL);
-               }
-               if (stinf->pid.protocol[2])
-               {
-                       PERROR_RUNTIME("Given port %d: Layer 2 protocol 0x%08x is detected, but not allowed for NT lib.\n", port, stinf->pid.protocol[2]);
-                       return(NULL);
-               }
-       }
-       if (te)
-       {
-               /* TE */
-               if (stinf->pid.protocol[1] == 0)
-               {
-                       PERROR_RUNTIME("Given port %d: Missing layer 1 protocol.\n", port);
-                       return(NULL);
-               }
-               if (stinf->pid.protocol[2] == 0)
-               {
-                       PERROR_RUNTIME("Given port %d: Missing layer 2 protocol.\n", port);
-                       return(NULL);
-               }
-               if (stinf->pid.protocol[3] == 0)
-               {
-                       PERROR_RUNTIME("Given port %d: Missing layer 3 protocol.\n", port);
-                       return(NULL);
-               } else
-               {
-                       switch(stinf->pid.protocol[3] & ~ISDN_PID_FEATURE_MASK)
-                       {
-                               case ISDN_PID_L3_DSS1USER:
-                               break;
-
-                               default:
-                               PERROR_RUNTIME("Given port %d: own protocol 0x%08x", port,stinf->pid.protocol[3]);
-                               return(NULL);
-                       }
-               }
-               if (stinf->pid.protocol[4])
-               {
-                       PERROR_RUNTIME("Given port %d: Layer 4 protocol not allowed.\n", port);
-                       return(NULL);
-               }
-       }
-#endif
 
        /* add mISDNport structure */
        mISDNportp = &mISDNport_first;
 
        /* add mISDNport structure */
        mISDNportp = &mISDNport_first;
@@ -3191,7 +2270,6 @@ struct mISDNport *mISDNport_open(int port, int ptp, int force_nt, int l2hold, st
        }
                
        /* allocate ressources of port */
        }
                
        /* allocate ressources of port */
-#ifdef SOCKET_MISDN
        /* open layer 3 and init upqueue */
        protocol = (nt)?L3_PROTOCOL_DSS1_NET:L3_PROTOCOL_DSS1_USER;
        prop = (1 << MISDN_FLG_L2_CLEAN);
        /* open layer 3 and init upqueue */
        protocol = (nt)?L3_PROTOCOL_DSS1_NET:L3_PROTOCOL_DSS1_USER;
        prop = (1 << MISDN_FLG_L2_CLEAN);
@@ -3239,101 +2317,6 @@ struct mISDNport *mISDNport_open(int port, int ptp, int force_nt, int l2hold, st
 
        SCPY(mISDNport->name, devinfo.name);
        mISDNport->b_num = devinfo.nrbchan;
 
        SCPY(mISDNport->name, devinfo.name);
        mISDNport->b_num = devinfo.nrbchan;
-#else
-       msg_queue_init(&mISDNport->downqueue);
-       mISDNport->d_stid = stinf->id;
-       PDEBUG(DEBUG_ISDN, "d_stid = 0x%x.\n", mISDNport->d_stid);
-
-       /* create layer intance */
-       memset(&li, 0, sizeof(li));
-       UCPY(&li.name[0], (nt)?"net l2":"pbx l4");
-       li.object_id = -1;
-       li.extentions = 0;
-       li.pid.protocol[nt?2:4] = (nt)?ISDN_PID_L2_LAPD_NET:ISDN_PID_L4_CAPI20;
-       li.pid.layermask = ISDN_LAYER((nt?2:4));
-       li.st = mISDNport->d_stid;
-       ret = mISDN_new_layer(mISDNdevice, &li);
-       if (ret)
-       {
-               PERROR("Cannot add layer %d of port %d (ret %d)\n", nt?2:4, port, ret);
-               closeport:
-               mISDNport_close(mISDNport);
-               return(NULL);
-       }
-       mISDNport->upper_id = li.id;
-       ret = mISDN_register_layer(mISDNdevice, mISDNport->d_stid, mISDNport->upper_id);
-       if (ret)
-       {
-               PERROR("Cannot register layer %d of port %d\n", nt?2:4, port);
-               goto closeport;
-       }
-       mISDNport->lower_id = mISDN_get_layerid(mISDNdevice, mISDNport->d_stid, nt?1:3); // id of lower layer (nt=1, te=3)
-       if (mISDNport->lower_id < 0)
-       {
-               PERROR("Cannot get layer(%d) id of port %d\n", nt?1:3, port);
-               goto closeport;
-       }
-       mISDNport->upper_id = mISDN_get_layerid(mISDNdevice, mISDNport->d_stid, nt?2:4); // id of uppermost layer (nt=2, te=4)
-       if (mISDNport->upper_id < 0)
-       {
-               PERROR("Cannot get layer(%d) id of port %d\n", nt?2:4, port);
-               goto closeport;
-       }
-       PDEBUG(DEBUG_ISDN, "Layer %d of port %d added.\n", nt?2:4, port);
-
-       /* if ntmode, establish L1 to send the tei removal during start */
-       if (mISDNport->ntmode)
-       {
-               iframe_t act;
-               /* L1 */
-               act.prim = PH_ACTIVATE | REQUEST; 
-               act.addr = mISDNport->upper_id | FLG_MSG_DOWN;
-               printf("UPPER ID 0x%x, addr 0x%x\n",mISDNport->upper_id, act.addr);
-               act.dinfo = 0;
-               act.len = 0;
-               mISDN_write(mISDNdevice, &act, mISDN_HEADER_LEN+act.len, TIMEOUT_1SEC);
-               usleep(10000); /* to be sure, that l1 is up */
-       }
-
-       /* create nst (nt-mode only) */
-       if (nt)
-       {
-               mgr = &mISDNport->mgr;
-               nst = &mISDNport->nst;
-
-               mgr->nst = nst;
-               nst->manager = mgr;
-
-               nst->l3_manager = stack2manager_nt; /* messages from nt-mode */
-               nst->device = mISDNdevice;
-               nst->cardnr = port;
-               nst->d_stid = mISDNport->d_stid;
-
-               nst->feature = FEATURE_NET_HOLD;
-               if (ptp)
-                       nst->feature |= FEATURE_NET_PTP;
-               if (pri)
-                       nst->feature |= FEATURE_NET_CRLEN2 | FEATURE_NET_EXTCID;
-#if 0
-               i = 0;
-               while(i < mISDNport->b_num)
-               {
-                       nst->b_stid[i] = mISDNport->b_stid[i];
-                       i++;
-               }
-#endif
-               nst->l1_id = mISDNport->lower_id;
-               nst->l2_id = mISDNport->upper_id;
-
-               /* phd */       
-               msg_queue_init(&nst->down_queue);
-
-               Isdnl2Init(nst);
-               Isdnl3Init(nst);
-       }
-
-       mISDNport->b_num = stinf->childcnt;
-#endif
        mISDNport->portnum = port;
        mISDNport->ntmode = nt;
        mISDNport->pri = pri;
        mISDNport->portnum = port;
        mISDNport->ntmode = nt;
        mISDNport->pri = pri;
@@ -3344,16 +2327,10 @@ struct mISDNport *mISDNport_open(int port, int ptp, int force_nt, int l2hold, st
        while(i < mISDNport->b_num)
        {
                mISDNport->b_state[i] = B_STATE_IDLE;
        while(i < mISDNport->b_num)
        {
                mISDNport->b_state[i] = B_STATE_IDLE;
-#ifdef SOCKET_MISDN
                mISDNport->b_socket[i] = -1;
                mISDNport->b_socket[i] = -1;
-#else
-               mISDNport->b_stid[i] = stinf->child[i];
-               PDEBUG(DEBUG_ISDN, "b_stid[%d] = 0x%x.\n", i, mISDNport->b_stid[i]);
-#endif
                i++;
        }
 
                i++;
        }
 
-#ifdef SOCKET_MISDN
        /* if ptp, pull up the link */
        if (mISDNport->l2hold && (mISDNport->ptp || !mISDNport->ntmode))
        {
        /* if ptp, pull up the link */
        if (mISDNport->l2hold && (mISDNport->ptp || !mISDNport->ntmode))
        {
@@ -3363,47 +2340,6 @@ struct mISDNport *mISDNport_open(int port, int ptp, int force_nt, int l2hold, st
                end_trace();
                time(&mISDNport->l2establish);
        }
                end_trace();
                time(&mISDNport->l2establish);
        }
-#else
-       /* if te-mode, query state link */
-       if (!mISDNport->ntmode)
-       {
-               iframe_t act;
-               /* L2 */
-               PDEBUG(DEBUG_ISDN, "sending short status request for port %d.\n", port);
-               act.prim = MGR_SHORTSTATUS | REQUEST; 
-               act.addr = mISDNport->upper_id | MSG_BROADCAST;
-               act.dinfo = SSTATUS_BROADCAST_BIT | SSTATUS_ALL;
-               act.len = 0;
-               mISDN_write(mISDNdevice, &act, mISDN_HEADER_LEN+act.len, TIMEOUT_1SEC);
-       }
-       /* if ptp AND te-mode, pull up the link */
-       if (mISDNport->l2hold && !mISDNport->ntmode)
-       {
-               iframe_t act;
-               /* L2 */
-               act.prim = DL_ESTABLISH | REQUEST; 
-               act.addr = (mISDNport->upper_id & ~LAYER_ID_MASK) | 4 | FLG_MSG_DOWN;
-               act.dinfo = 0;
-               act.len = 0;
-               mISDN_write(mISDNdevice, &act, mISDN_HEADER_LEN+act.len, TIMEOUT_1SEC);
-
-               l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_REQ, DIRECTION_OUT);
-               end_trace();
-               time(&mISDNport->l2establish);
-       }
-       /* if ptp AND nt-mode, pull up the link */
-       if (mISDNport->l2hold && mISDNport->ntmode && mISDNport->ptp)
-       {
-               msg_t *dmsg;
-               /* L2 */
-               dmsg = create_l2msg(DL_ESTABLISH | REQUEST, 0, 0);
-               if (mISDNport->nst.manager_l3(&mISDNport->nst, dmsg))
-                       free_msg(dmsg);
-               l1l2l3_trace_header(mISDNport, NULL, L2_ESTABLISH_REQ, DIRECTION_OUT);
-               end_trace();
-               time(&mISDNport->l2establish);
-       }
-#endif
 
        /* initially, we assume that the link is down, exept for nt-ptmp */
        mISDNport->l2link = (mISDNport->ntmode && !mISDNport->ptp)?1:0;
 
        /* initially, we assume that the link is down, exept for nt-ptmp */
        mISDNport->l2link = (mISDNport->ntmode && !mISDNport->ptp)?1:0;
@@ -3443,11 +2379,6 @@ void mISDNport_close(struct mISDNport *mISDNport)
        struct mISDNport **mISDNportp;
        class Port *port;
        class PmISDN *isdnport;
        struct mISDNport **mISDNportp;
        class Port *port;
        class PmISDN *isdnport;
-#ifdef SOCKET_MISDN
-#else
-       net_stack_t *nst;
-       unsigned char buf[32];
-#endif
        int i;
 
        /* remove all port instance that are linked to this mISDNport */
        int i;
 
        /* remove all port instance that are linked to this mISDNport */
@@ -3484,11 +2415,7 @@ void mISDNport_close(struct mISDNport *mISDNport)
        i = 0;
        while(i < mISDNport->b_num)
        {
        i = 0;
        while(i < mISDNport->b_num)
        {
-#ifdef SOCKET_MISDN
                if (mISDNport->b_socket[i] > -1)
                if (mISDNport->b_socket[i] > -1)
-#else
-               if (mISDNport->b_addr[i])
-#endif
                {
                        _bchannel_destroy(mISDNport, i);
                        PDEBUG(DEBUG_BCHANNEL, "freeing %s port %d bchannel (index %d).\n", (mISDNport->ntmode)?"NT":"TE", mISDNport->portnum, i);
                {
                        _bchannel_destroy(mISDNport, i);
                        PDEBUG(DEBUG_BCHANNEL, "freeing %s port %d bchannel (index %d).\n", (mISDNport->ntmode)?"NT":"TE", mISDNport->portnum, i);
@@ -3496,41 +2423,12 @@ void mISDNport_close(struct mISDNport *mISDNport)
                i++;
        }
 
                i++;
        }
 
-#ifdef SOCKET_MISDN
        /* close layer 3, if open and purge upqueue */
        if (mISDNport->ml3)
        {
                close_layer3(mISDNport->ml3);
                mqueue_purge(&mISDNport->upqueue);
        }
        /* close layer 3, if open and purge upqueue */
        if (mISDNport->ml3)
        {
                close_layer3(mISDNport->ml3);
                mqueue_purge(&mISDNport->upqueue);
        }
-#else
-       /* free ressources of port */
-       msg_queue_purge(&mISDNport->downqueue);
-
-       /* free stacks */
-       if (mISDNport->ntmode)
-       {
-               nst = &mISDNport->nst;
-               if (nst->manager) /* to see if initialized */
-               {
-                       PDEBUG(DEBUG_STACK, "the following messages are ok: one L3 process always exists (broadcast process) and some L2 instances (broadcast + current telephone's instances)\n");
-                       cleanup_Isdnl3(nst);
-                       cleanup_Isdnl2(nst);
-
-                       /* phd */
-                       msg_queue_purge(&nst->down_queue);
-                       if (nst->phd_down_msg)
-                               FREE(nst->phd_down_msg, 0);
-               }
-       }
-
-       PDEBUG(DEBUG_BCHANNEL, "freeing d-stack.\n");
-       if (mISDNport->d_stid)
-       {
-               if (mISDNport->upper_id)
-                       mISDN_write_frame(mISDNdevice, buf, mISDNport->upper_id | FLG_MSG_DOWN, MGR_DELLAYER | REQUEST, 0, 0, NULL, TIMEOUT_1SEC);
-       }
-#endif
 
        /* remove from list */
        mISDNportp = &mISDNport_first;
 
        /* remove from list */
        mISDNportp = &mISDNport_first;
@@ -3562,7 +2460,6 @@ void mISDN_port_info(void)
        int ret;
        int i, ii;
        int useable, nt, te, pri, bri, pots;
        int ret;
        int i, ii;
        int useable, nt, te, pri, bri, pots;
-#ifdef SOCKET_MISDN
        struct mISDN_devinfo devinfo;
        int sock;
 
        struct mISDN_devinfo devinfo;
        int sock;
 
@@ -3582,24 +2479,6 @@ void mISDN_port_info(void)
                fprintf(stderr, "Cannot get number of mISDN devices. (ioctl IMGETCOUNT failed ret=%d)\n", ret);
                goto done;
        }
                fprintf(stderr, "Cannot get number of mISDN devices. (ioctl IMGETCOUNT failed ret=%d)\n", ret);
                goto done;
        }
-#else
-       int p;
-       unsigned char buff[1025];
-       iframe_t *frm = (iframe_t *)buff;
-       stack_info_t *stinf;
-       int device;
-
-       /* open mISDN */
-       if ((device = mISDN_open()) < 0)
-       {
-               fprintf(stderr, "Cannot open mISDN device ret=%d errno=%d (%s) Check for mISDN modules!\nAlso did you create \"/dev/mISDN\"? Do: \"mknod /dev/mISDN c 46 0\"\n", device, errno, strerror(errno));
-               exit(EXIT_FAILURE);
-       }
-
-       /* get number of stacks */
-       i = 1;
-       ii = mISDN_get_stack_count(device);
-#endif
        printf("\n");
        if (ii <= 0)
        {
        printf("\n");
        if (ii <= 0)
        {
@@ -3613,7 +2492,6 @@ void mISDN_port_info(void)
                nt = te = bri = pri = pots = 0;
                useable = 0;
 
                nt = te = bri = pri = pots = 0;
                useable = 0;
 
-#ifdef SOCKET_MISDN
                devinfo.id = i - 1;
                ret = ioctl(sock, IMGETDEVINFO, &devinfo);
                if (ret < 0)
                devinfo.id = i - 1;
                ret = ioctl(sock, IMGETDEVINFO, &devinfo);
                if (ret < 0)
@@ -3691,120 +2569,6 @@ void mISDN_port_info(void)
                printf("\n");
 
                printf("  - %d B-channels\n", devinfo.nrbchan);
                printf("\n");
 
                printf("  - %d B-channels\n", devinfo.nrbchan);
-#else
-               ret = mISDN_get_stack_info(device, i, buff, sizeof(buff));
-               if (ret <= 0)
-               {
-                       fprintf(stderr, "mISDN_get_stack_info() failed: port=%d error=%d\n", i, ret);
-                       break;
-               }
-               stinf = (stack_info_t *)&frm->data.p;
-
-               /* output the port info */
-               printf("Port %2d: ", i);
-               switch(stinf->pid.protocol[0] & ~ISDN_PID_FEATURE_MASK)
-               {
-                       case ISDN_PID_L0_TE_S0:
-                       useable = 1;
-                       te = 1;
-                       bri = 1;
-                       printf("TE-mode BRI S/T interface line (for phone lines)");
-                       break;
-                       case ISDN_PID_L0_NT_S0:
-                       useable = 1;
-                       nt = 1;
-                       bri = 1;
-                       printf("NT-mode BRI S/T interface port (for phones)");
-                       break;
-                       case ISDN_PID_L0_TE_E1:
-                       useable = 1;
-                       te = 1;
-                       pri = 1;
-                       printf("TE-mode PRI E1  interface line (for phone lines)");
-                       break;
-                       case ISDN_PID_L0_NT_E1:
-                       useable = 1;
-                       nt = 1;
-                       pri = 1;
-                       printf("NT-mode PRI E1  interface port (for E1 devices)");
-                       break;
-                       default:
-                       useable = 0;
-                       printf("unknown type 0x%08x",stinf->pid.protocol[0]);
-               }
-               printf("\n");
-
-               if (nt)
-               {
-                       if (stinf->pid.protocol[1] == 0)
-                       {
-                               useable = 0;
-                               printf(" -> Missing layer 1 NT-mode protocol.\n");
-                       }
-                       p = 2;
-                       while(p <= MAX_LAYER_NR) {
-                               if (stinf->pid.protocol[p])
-                               {
-                                       useable = 0;
-                                       printf(" -> Layer %d protocol 0x%08x is detected, port already in use by another application.\n", p, stinf->pid.protocol[p]);
-                               }
-                               p++;
-                       }
-                       if (useable)
-                       {
-                               if (pri)
-                                       printf(" -> Interface is Point-To-Point (PRI).\n");
-                               else
-                                       printf(" -> Interface can be Poin-To-Point/Multipoint.\n");
-                       }
-               }
-               if (te)
-               {
-                       if (stinf->pid.protocol[1] == 0)
-                       {
-                               useable = 0;
-                               printf(" -> Missing layer 1 protocol.\n");
-                       }
-                       if (stinf->pid.protocol[2] == 0)
-                       {
-                               useable = 0;
-                               printf(" -> Missing layer 2 protocol.\n");
-                       }
-                       if (stinf->pid.protocol[2] & ISDN_PID_L2_DF_PTP)
-                       {
-                               printf(" -> Interface is Poin-To-Point.\n");
-                       }
-                       if (stinf->pid.protocol[3] == 0)
-                       {
-                               useable = 0;
-                               printf(" -> Missing layer 3 protocol.\n");
-                       } else
-                       {
-                               printf(" -> Protocol: ");
-                               switch(stinf->pid.protocol[3] & ~ISDN_PID_FEATURE_MASK)
-                               {
-                                       case ISDN_PID_L3_DSS1USER:
-                                       printf("DSS1 (Euro ISDN)");
-                                       break;
-
-                                       default:
-                                       useable = 0;
-                                       printf("unknown protocol 0x%08x",stinf->pid.protocol[3]);
-                               }
-                               printf("\n");
-                       }
-                       p = 4;
-                       while(p <= MAX_LAYER_NR) {
-                               if (stinf->pid.protocol[p])
-                               {
-                                       useable = 0;
-                                       printf(" -> Layer %d protocol 0x%08x is detected, port already in use by another application.\n", p, stinf->pid.protocol[p]);
-                               }
-                               p++;
-                       }
-               }
-               printf("  - %d B-channels\n", stinf->childcnt);
-#endif
 
                if (!useable)
                        printf(" * Port NOT useable for LCR\n");
 
                if (!useable)
                        printf(" * Port NOT useable for LCR\n");
@@ -3816,13 +2580,7 @@ void mISDN_port_info(void)
        printf("\n");
 
 done:
        printf("\n");
 
 done:
-#ifdef SOCKET_MISDN
        close(sock);
        close(sock);
-#else
-       /* close mISDN */
-       if ((ret = mISDN_close(device)))
-               FATAL("mISDN_close() failed: err=%d '%s'\n", ret, strerror(ret));
-#endif
 }
 
 
 }
 
 
@@ -3831,7 +2589,6 @@ done:
  */
 void PmISDN::txfromup(unsigned char *data, int length)
 {
  */
 void PmISDN::txfromup(unsigned char *data, int length)
 {
-#ifdef SOCKET_MISDN
        unsigned char buf[MISDN_HEADER_LEN+((length>ISDN_LOAD)?length:ISDN_LOAD)];
        struct mISDNhead *hh = (struct mISDNhead *)buf;
        int ret;
        unsigned char buf[MISDN_HEADER_LEN+((length>ISDN_LOAD)?length:ISDN_LOAD)];
        struct mISDNhead *hh = (struct mISDNhead *)buf;
        int ret;
@@ -3840,15 +2597,6 @@ void PmISDN::txfromup(unsigned char *data, int length)
                return;
        if (p_m_mISDNport->b_state[p_m_b_index] != B_STATE_ACTIVE)
                return;
                return;
        if (p_m_mISDNport->b_state[p_m_b_index] != B_STATE_ACTIVE)
                return;
-#else
-       unsigned char buf[mISDN_HEADER_LEN+((length>ISDN_LOAD)?length:ISDN_LOAD)];
-       iframe_t *frm = (iframe_t *)buf;
-
-       if (p_m_b_index < 0)
-               return;
-       if (!p_m_mISDNport->b_addr[p_m_b_index])
-               return;
-#endif
 
        /* check if high priority tones exist
         * ignore data in this case
 
        /* check if high priority tones exist
         * ignore data in this case
@@ -3862,21 +2610,12 @@ void PmISDN::txfromup(unsigned char *data, int length)
         */
        if (p_m_load==0 && ISDN_LOAD>0)
        {
         */
        if (p_m_load==0 && ISDN_LOAD>0)
        {
-#ifdef SOCKET_MISDN
                hh->prim = PH_DATA_REQ; 
                hh->id = 0;
                memset(buf+MISDN_HEADER_LEN, (options.law=='a')?0x2a:0xff, ISDN_LOAD);
                ret = sendto(p_m_mISDNport->b_socket[p_m_b_index], buf, MISDN_HEADER_LEN+ISDN_LOAD, 0, NULL, 0);
                if (ret <= 0)
                        PERROR("Failed to send to socket %d\n", p_m_mISDNport->b_socket[p_m_b_index]);
                hh->prim = PH_DATA_REQ; 
                hh->id = 0;
                memset(buf+MISDN_HEADER_LEN, (options.law=='a')?0x2a:0xff, ISDN_LOAD);
                ret = sendto(p_m_mISDNport->b_socket[p_m_b_index], buf, MISDN_HEADER_LEN+ISDN_LOAD, 0, NULL, 0);
                if (ret <= 0)
                        PERROR("Failed to send to socket %d\n", p_m_mISDNport->b_socket[p_m_b_index]);
-#else
-               frm->prim = DL_DATA | REQUEST; 
-               frm->addr = p_m_mISDNport->b_addr[p_m_b_index] | FLG_MSG_DOWN;
-               frm->dinfo = 0;
-               frm->len = ISDN_LOAD;
-               memset(buf+mISDN_HEADER_LEN, (options.law=='a')?0x2a:0xff, ISDN_LOAD);
-               mISDN_write(mISDNdevice, frm, mISDN_HEADER_LEN+ISDN_LOAD, TIMEOUT_1SEC);
-#endif
                p_m_load += ISDN_LOAD;
        }
 
                p_m_load += ISDN_LOAD;
        }
 
@@ -3887,21 +2626,12 @@ void PmISDN::txfromup(unsigned char *data, int length)
                return;
 
        /* make and send frame */
                return;
 
        /* make and send frame */
-#ifdef SOCKET_MISDN
        hh->prim = PH_DATA_REQ;
        hh->id = 0;
        memcpy(buf+MISDN_HEADER_LEN, data, length);
        ret = sendto(p_m_mISDNport->b_socket[p_m_b_index], buf, MISDN_HEADER_LEN+length, 0, NULL, 0);
        if (ret <= 0)
                PERROR("Failed to send to socket %d\n", p_m_mISDNport->b_socket[p_m_b_index]);
        hh->prim = PH_DATA_REQ;
        hh->id = 0;
        memcpy(buf+MISDN_HEADER_LEN, data, length);
        ret = sendto(p_m_mISDNport->b_socket[p_m_b_index], buf, MISDN_HEADER_LEN+length, 0, NULL, 0);
        if (ret <= 0)
                PERROR("Failed to send to socket %d\n", p_m_mISDNport->b_socket[p_m_b_index]);
-#else
-       frm->prim = DL_DATA | REQUEST; 
-       frm->addr = p_m_mISDNport->b_addr[p_m_b_index] | FLG_MSG_DOWN;
-       frm->dinfo = 0;
-       frm->len = length;
-       memcpy(buf+mISDN_HEADER_LEN, data, length);
-       mISDN_write(mISDNdevice, frm, mISDN_HEADER_LEN+frm->len, TIMEOUT_1SEC);
-#endif
        p_m_load += length;
 }
 
        p_m_load += length;
 }
 
diff --git a/mISDN.h b/mISDN.h
index de33e16..a61b5cd 100644 (file)
--- a/mISDN.h
+++ b/mISDN.h
 extern int entity;
 extern int mISDNdevice;
 
 extern int entity;
 extern int mISDNdevice;
 
+enum {
+       B_EVENT_USE,            /* activate/export bchannel */
+       B_EVENT_EXPORTREQUEST,  /* remote app requests bchannel */
+       B_EVENT_IMPORTREQUEST,  /* remote app releases bchannel */
+       B_EVENT_ACTIVATED,      /* DL_ESTABLISH received */
+       B_EVENT_DROP,           /* deactivate/re-import bchannel */
+       B_EVENT_DEACTIVATED,    /* DL_RELEASE received */
+       B_EVENT_EXPORTED,       /* BCHANNEL_ASSIGN received */
+       B_EVENT_IMPORTED,       /* BCHANNEL_REMOVE received */
+       B_EVENT_TIMEOUT,        /* timeout for bchannel state */
+};
+
 /* mISDN port structure list */
 struct mISDNport {
 /* mISDN port structure list */
 struct mISDNport {
-#ifdef SOCKET_MISDN
        struct mlayer3 *ml3;
        struct mlayer3 *ml3;
-#else
-       net_stack_t nst; /* MUST be the first entry, so &nst equals &mISDNlist */
-       manager_t mgr;
-       int upper_id; /* id to transfer data down */
-       int lower_id; /* id to transfer data up */
-       int d_stid;
-       msg_queue_t downqueue;          /* l4->l3 */
-#endif
        struct mISDNport *next;
        char name[64]; /* name of port, if available */
        struct interface_port *ifport; /* link to interface_port */
        struct mISDNport *next;
        char name[64]; /* name of port, if available */
        struct interface_port *ifport; /* link to interface_port */
@@ -46,14 +49,8 @@ struct mISDNport {
        int b_num; /* number of bchannels */
        int b_reserved; /* number of bchannels reserved or in use */
        class PmISDN *b_port[128]; /* bchannel assigned to port object */
        int b_num; /* number of bchannels */
        int b_reserved; /* number of bchannels reserved or in use */
        class PmISDN *b_port[128]; /* bchannel assigned to port object */
-#ifdef SOCKET_MISDN
        struct mqueue upqueue;
        int b_socket[128];
        struct mqueue upqueue;
        int b_socket[128];
-#else
-       int procids[256]; /* keep track of free ids */
-       int b_stid[128];
-       unsigned long b_addr[128];
-#endif
        int b_state[128]; /* statemachine, 0 = IDLE */
        double b_timer[128]; /* timer for state machine */
        unsigned long b_remote_id[128]; /* the socket currently exported */
        int b_state[128]; /* statemachine, 0 = IDLE */
        double b_timer[128]; /* timer for state machine */
        unsigned long b_remote_id[128]; /* the socket currently exported */
@@ -87,16 +84,8 @@ void mISDNport_close_all(void);
 void mISDNport_close(struct mISDNport *mISDNport);
 void mISDN_port_reorder(void);
 int mISDN_handler(void);
 void mISDNport_close(struct mISDNport *mISDNport);
 void mISDN_port_reorder(void);
 int mISDN_handler(void);
-#ifdef SOCKET_MISDN
 void enc_ie_cause_standalone(struct l3_msg *l3m, int location, int cause);
 int stack2manager(struct mISDNport *mISDNport, unsigned int cmd, unsigned int pid, struct l3_msg *l3m);
 void enc_ie_cause_standalone(struct l3_msg *l3m, int location, int cause);
 int stack2manager(struct mISDNport *mISDNport, unsigned int cmd, unsigned int pid, struct l3_msg *l3m);
-#else
-void enc_ie_cause_standalone(unsigned char **ntmode, msg_t *msg, int location, int cause);
-int stack2manager_te(struct mISDNport *mISDNport, msg_t *msg);
-int stack2manager_nt(void *dat, void *arg);
-void setup_queue(struct mISDNport *mISDNport, int link);
-msg_t *create_l2msg(int prim, int dinfo, int size);
-#endif
 void ph_control(struct mISDNport *mISDNport, class PmISDN *isdnport, unsigned long handle, unsigned long c1, unsigned long c2, char *trace_name, int trace_value);
 void ph_control_block(struct mISDNport *mISDNport, unsigned long handle, unsigned long c1, void *c2, int c2_len, char *trace_name, int trace_value);
 void chan_trace_header(struct mISDNport *mISDNport, class PmISDN *port, char *msgtext, int direction);
 void ph_control(struct mISDNport *mISDNport, class PmISDN *isdnport, unsigned long handle, unsigned long c1, unsigned long c2, char *trace_name, int trace_value);
 void ph_control_block(struct mISDNport *mISDNport, unsigned long handle, unsigned long c1, void *c2, int c2_len, char *trace_name, int trace_value);
 void chan_trace_header(struct mISDNport *mISDNport, class PmISDN *port, char *msgtext, int direction);
@@ -111,11 +100,7 @@ class PmISDN : public Port
        public:
        PmISDN(int type, struct mISDNport *mISDNport, char *portname, struct port_settings *settings, int channel, int exclusive);
        ~PmISDN();
        public:
        PmISDN(int type, struct mISDNport *mISDNport, char *portname, struct port_settings *settings, int channel, int exclusive);
        ~PmISDN();
-#ifdef SOCKET_MISDN
        void bchannel_receive(struct mISDNhead *hh, unsigned char *data, int len);
        void bchannel_receive(struct mISDNhead *hh, unsigned char *data, int len);
-#else
-       void bchannel_receive(iframe_t *frm);
-#endif
        int handler(void);
        void transmit(unsigned char *buffer, int length);
        int message_epoint(unsigned long epoint_id, int message, union parameter *param);
        int handler(void);
        void transmit(unsigned char *buffer, int length);
        int message_epoint(unsigned long epoint_id, int message, union parameter *param);
diff --git a/main.c b/main.c
index ac23868..21b3384 100644 (file)
--- a/main.c
+++ b/main.c
@@ -26,11 +26,7 @@ struct timezone now_tz;
                now_tm = localtime(&now); \
        }
 
                now_tm = localtime(&now); \
        }
 
-#ifdef SOCKET_MISDN
 FILE *debug_fp = NULL;
 FILE *debug_fp = NULL;
-#else
-int global_debug = 0;
-#endif
 int quit=0;
 
 #if 0
 int quit=0;
 
 #if 0
@@ -72,13 +68,8 @@ void debug(const char *function, int line, char *prefix, char *buffer)
                last_debug = debug_count;
                if (!nooutput)
                        printf("\033[34m--------------------- %04d.%02d.%02d %02d:%02d:%02d %06d\033[36m\n", now_tm->tm_year+1900, now_tm->tm_mon+1, now_tm->tm_mday, now_tm->tm_hour, now_tm->tm_min, now_tm->tm_sec, debug_count%1000000);
                last_debug = debug_count;
                if (!nooutput)
                        printf("\033[34m--------------------- %04d.%02d.%02d %02d:%02d:%02d %06d\033[36m\n", now_tm->tm_year+1900, now_tm->tm_mon+1, now_tm->tm_mday, now_tm->tm_hour, now_tm->tm_min, now_tm->tm_sec, debug_count%1000000);
-#ifdef SOCKET_MISDN
                if (debug_fp)
                        fprintf(debug_fp, "--------------------- %04d.%02d.%02d %02d:%02d:%02d %06d\n", now_tm->tm_year+1900, now_tm->tm_mon+1, now_tm->tm_mday, now_tm->tm_hour, now_tm->tm_min, now_tm->tm_sec, debug_count%1000000);
                if (debug_fp)
                        fprintf(debug_fp, "--------------------- %04d.%02d.%02d %02d:%02d:%02d %06d\n", now_tm->tm_year+1900, now_tm->tm_mon+1, now_tm->tm_mday, now_tm->tm_hour, now_tm->tm_min, now_tm->tm_sec, debug_count%1000000);
-#else
-               if (options.deb&DEBUG_LOG && global_debug)
-                       dprint(DBGM_MAN, 0, "--------------------- %04d.%02d.%02d %02d:%02d:%02d %06d\n", now_tm->tm_year+1900, now_tm->tm_mon+1, now_tm->tm_mday, now_tm->tm_hour, now_tm->tm_min, now_tm->tm_sec, debug_count%1000000);
-#endif
        }
 
        if (!nooutput)
        }
 
        if (!nooutput)
@@ -91,26 +82,14 @@ void debug(const char *function, int line, char *prefix, char *buffer)
                        printf("%s", buffer);
        }
 
                        printf("%s", buffer);
        }
 
-#ifdef SOCKET_MISDN
        if (debug_fp)
        if (debug_fp)
-#else
-       if (options.deb&DEBUG_LOG && global_debug)
-#endif
        {
                if (debug_newline)
                {
                        if (function)
        {
                if (debug_newline)
                {
                        if (function)
-#ifdef SOCKET_MISDN
                                fprintf(debug_fp, "%s%s(in %s() line %d): %s", prefix?prefix:"", prefix?" ":"", function, line, buffer);
                                fprintf(debug_fp, "%s%s(in %s() line %d): %s", prefix?prefix:"", prefix?" ":"", function, line, buffer);
-#else
-                               dprint(DBGM_MAN, 0, "%s%s(in %s() line %d): %s", prefix?prefix:"", prefix?" ":"", function, line, buffer);
-#endif
                        else
                        else
-#ifdef SOCKET_MISDN
                                fprintf(debug_fp, "%s%s: %s", prefix?prefix:"", prefix?" ":"", buffer);
                                fprintf(debug_fp, "%s%s: %s", prefix?prefix:"", prefix?" ":"", buffer);
-#else
-                               dprint(DBGM_MAN, 0, "%s%s: %s", prefix?prefix:"", prefix?" ":"", buffer);
-#endif
                }
        }
 
                }
        }
 
diff --git a/main.h b/main.h
index eff5b7e..6507694 100644 (file)
--- a/main.h
+++ b/main.h
@@ -34,7 +34,7 @@
 
 #define DEFAULT_ENDPOINT_APP EndpointAppPBX
 
 
 #define DEFAULT_ENDPOINT_APP EndpointAppPBX
 
-#define VERSION_STRING "0.5 (Spring 2007)"
+#define VERSION_STRING "1.0 beta 1 (Summer 2008)"
 
 extern int memuse;
 extern int mmemuse;
 
 extern int memuse;
 extern int mmemuse;
@@ -49,11 +49,7 @@ extern int fhuse;
 
 //extern pthread_mutex_t mutex_lcr; // lcr process mutex
 
 
 //extern pthread_mutex_t mutex_lcr; // lcr process mutex
 
-#ifdef SOCKET_MISDN
 extern FILE *debug_fp;
 extern FILE *debug_fp;
-#else
-extern int global_debug;
-#endif
 
 #define PDEBUG(mask, fmt, arg...) _printdebug(__FUNCTION__, __LINE__, mask, fmt, ## arg)
 #define PERROR(fmt, arg...) _printerror(__FUNCTION__, __LINE__, fmt, ## arg)
 
 #define PDEBUG(mask, fmt, arg...) _printdebug(__FUNCTION__, __LINE__, mask, fmt, ## arg)
 #define PERROR(fmt, arg...) _printerror(__FUNCTION__, __LINE__, fmt, ## arg)
@@ -133,12 +129,7 @@ void debug(const char *function, int line, char *prefix, char *buffer);
 #ifdef __cplusplus
 extern "C" {
 #endif
 #ifdef __cplusplus
 extern "C" {
 #endif
-#ifndef SOCKET_MISDN
-#include <mISDNuser/isdn_net.h>
-#include <mISDNuser/net_l3.h>
-#else
 #include <mbuffer.h>
 #include <mbuffer.h>
-#endif
 #ifdef __cplusplus
 }
 #endif
 #ifdef __cplusplus
 }
 #endif
index d88d76a..f07745c 100644 (file)
--- a/message.h
+++ b/message.h
@@ -129,6 +129,7 @@ enum { /* isdnsignal */
 
 enum { /* bchannel assignment */
        BCHANNEL_REQUEST,               /* application requests bchannel */
 
 enum { /* bchannel assignment */
        BCHANNEL_REQUEST,               /* application requests bchannel */
+       BCHANNEL_RELEASE,               /* application releases bchannel */
        BCHANNEL_ASSIGN,                /* bchannel assigned by LCR */
        BCHANNEL_ASSIGN_ACK,            /* application acknowledges */
        BCHANNEL_REMOVE,                /* bchannel removed by LCR */
        BCHANNEL_ASSIGN,                /* bchannel assigned by LCR */
        BCHANNEL_ASSIGN_ACK,            /* application acknowledges */
        BCHANNEL_REMOVE,                /* bchannel removed by LCR */
@@ -143,16 +144,6 @@ enum {
        B_STATE_REMOTE,         /* bchannel assigned to remote application */
        B_STATE_IMPORTING,      /* BCHANNEL_REMOVE sent */
 };
        B_STATE_REMOTE,         /* bchannel assigned to remote application */
        B_STATE_IMPORTING,      /* BCHANNEL_REMOVE sent */
 };
-enum {
-       B_EVENT_USE,            /* activate/export bchannel */
-       B_EVENT_EXPORTREQUEST,  /* remote app requests bchannel */
-       B_EVENT_ACTIVATED,      /* DL_ESTABLISH received */
-       B_EVENT_DROP,           /* deactivate/re-import bchannel */
-       B_EVENT_DEACTIVATED,    /* DL_RELEASE received */
-       B_EVENT_EXPORTED,       /* BCHANNEL_ASSIGN received */
-       B_EVENT_IMPORTED,       /* BCHANNEL_REMOVE received */
-       B_EVENT_TIMEOUT,        /* timeout for bchannel state */
-};
 
 /* call-info structure CALLER */
 struct caller_info {
 
 /* call-info structure CALLER */
 struct caller_info {
index 7e4173e..eccafd8 100644 (file)
--- a/myisdn.h
+++ b/myisdn.h
@@ -10,8 +10,6 @@
 \*****************************************************************************/ 
 
 
 \*****************************************************************************/ 
 
 
-#ifndef SOCKET_MISDN
-
 #define MT_ALERTING             0x01
 #define MT_CALL_PROCEEDING      0x02
 #define MT_CONNECT              0x07
 #define MT_ALERTING             0x01
 #define MT_CALL_PROCEEDING      0x02
 #define MT_CONNECT              0x07
@@ -88,8 +86,6 @@
 #define IE_CONGESTION   0xb0
 #define IE_REPEAT       0xd0
 
 #define IE_CONGESTION   0xb0
 #define IE_REPEAT       0xd0
 
-#endif
-
 #define CENTREX_FAC    0x88
 #define CENTREX_ID     0xa1
 
 #define CENTREX_FAC    0x88
 #define CENTREX_ID     0xa1
 
diff --git a/route.c b/route.c
index 8f1e3bb..093ccbe 100644 (file)
--- a/route.c
+++ b/route.c
@@ -232,8 +232,8 @@ struct param_defs param_defs[] = {
          "application",PARAM_TYPE_STRING,
          "application=<name>", "Name of remote application to make call to."},
        { PARAM_CONTEXT,
          "application",PARAM_TYPE_STRING,
          "application=<name>", "Name of remote application to make call to."},
        { PARAM_CONTEXT,
-         "exten",      PARAM_TYPE_STRING,
-         "exten=<extension>", "Give context parameter to the remote application."},
+         "context",    PARAM_TYPE_STRING,
+         "context=<context>", "Give context parameter to the remote application."},
        { PARAM_EXTEN,
          "exten",      PARAM_TYPE_STRING,
          "exten=<extension>", "Give exten parameter to the remote application. (overrides dialed number)"},
        { PARAM_EXTEN,
          "exten",      PARAM_TYPE_STRING,
          "exten=<extension>", "Give exten parameter to the remote application. (overrides dialed number)"},
index 469f562..77e5309 100644 (file)
@@ -84,6 +84,16 @@ void free_connection(struct admin_list *admin)
        /* free remote joins */
        if (admin->remote_name[0])
        {
        /* free remote joins */
        if (admin->remote_name[0])
        {
+               start_trace(0,
+                       NULL,
+                       NULL,
+                       NULL,
+                       DIRECTION_NONE,
+                       0,
+                       0,
+                       "REMOTE APP release");
+               add_trace("app", "name", "%s", admin->remote_name);
+               end_trace();
                join = join_first;
                while(join)
                {
                join = join_first;
                while(join)
                {
@@ -579,39 +589,49 @@ void admin_call_response(int adminid, int message, char *connected, int cause, i
 /*
  * send data to the remote socket join instance
  */
 /*
  * send data to the remote socket join instance
  */
-int admin_message_to_join(struct admin_msg *msg, char *remote_name, int sock_id)
+int admin_message_to_join(struct admin_msg *msg, struct admin_list *admin)
 {
        class Join                      *join;
 {
        class Join                      *join;
-       struct admin_list               *admin;
+       struct admin_list               *temp;
 
        /* hello message */
        if (msg->type == MESSAGE_HELLO)
        {
 
        /* hello message */
        if (msg->type == MESSAGE_HELLO)
        {
-               if (remote_name[0])
+               if (admin->remote_name[0])
                {
                        PERROR("Remote application repeats hello message.\n");
                        return(-1);
                }
                /* look for second application */
                {
                        PERROR("Remote application repeats hello message.\n");
                        return(-1);
                }
                /* look for second application */
-               admin = admin_first;
-               while(admin)
+               temp = admin_first;
+               while(temp)
                {
                {
-                       if (!strcmp(admin->remote_name, msg->param.hello.application))
+                       if (!strcmp(temp->remote_name, msg->param.hello.application))
                                break;
                                break;
-                       admin = admin->next;
+                       temp = temp->next;
                }
                }
-               if (admin)
+               if (temp)
                {
                        PERROR("Remote application connects twice??? (ignoring)\n");
                        return(-1);
                }
                /* set remote socket instance */
                {
                        PERROR("Remote application connects twice??? (ignoring)\n");
                        return(-1);
                }
                /* set remote socket instance */
-               SCPY(remote_name, msg->param.hello.application);
+               SCPY(admin->remote_name, msg->param.hello.application);
+               start_trace(0,
+                       NULL,
+                       NULL,
+                       NULL,
+                       DIRECTION_NONE,
+                       0,
+                       0,
+                       "REMOTE APP registers");
+               add_trace("app", "name", "%s", admin->remote_name);
+               end_trace();
                return(0);
        }
 
        /* check we have no application name */
                return(0);
        }
 
        /* check we have no application name */
-       if (remote_name[0])
+       if (!admin->remote_name[0])
        {
                PERROR("Remote application did not send us a hello message.\n");
                return(-1);
        {
                PERROR("Remote application did not send us a hello message.\n");
                return(-1);
@@ -621,9 +641,12 @@ int admin_message_to_join(struct admin_msg *msg, char *remote_name, int sock_id)
        if (msg->type == MESSAGE_NEWREF)
        {
                /* create new join instance */
        if (msg->type == MESSAGE_NEWREF)
        {
                /* create new join instance */
-               join = new JoinRemote(0, remote_name, sock_id); // must have no serial, because no endpoint is connected
+               join = new JoinRemote(0, admin->remote_name, admin->sock); // must have no serial, because no endpoint is connected
                if (!join)
                if (!join)
+               {
                        FATAL("No memory for remote join instance\n");
                        FATAL("No memory for remote join instance\n");
+                       return(-1);
+               }
                return(0);
        }
 
                return(0);
        }
 
@@ -665,9 +688,9 @@ int admin_message_to_join(struct admin_msg *msg, char *remote_name, int sock_id)
                PERROR("Ref %d does not belong to a remote join instance.\n", msg->ref);
                return(-1);
        }
                PERROR("Ref %d does not belong to a remote join instance.\n", msg->ref);
                return(-1);
        }
-       if (sock_id != ((class JoinRemote *)join)->j_remote_id)
+       if (admin->sock != ((class JoinRemote *)join)->j_remote_id)
        {
        {
-               PERROR("Ref %d belongs to remote application %s, but not to sending application %s.\n", msg->ref, ((class JoinRemote *)join)->j_remote_name, remote_name);
+               PERROR("Ref %d belongs to remote application %s, but not to sending application %s.\n", msg->ref, ((class JoinRemote *)join)->j_remote_name, admin->remote_name);
                return(-1);
        }
 
                return(-1);
        }
 
@@ -684,7 +707,7 @@ int admin_message_to_join(struct admin_msg *msg, char *remote_name, int sock_id)
 int admin_message_from_join(int remote_id, unsigned long ref, int message_type, union parameter *param)
 {
        struct admin_list       *admin;
 int admin_message_from_join(int remote_id, unsigned long ref, int message_type, union parameter *param)
 {
        struct admin_list       *admin;
-       struct admin_queue      *response, **responsep; /* response pointer */
+       struct admin_queue      **responsep;    /* response pointer */
 
        /* searching for admin id
         * maybe there is no given remote application
 
        /* searching for admin id
         * maybe there is no given remote application
@@ -701,27 +724,22 @@ int admin_message_from_join(int remote_id, unsigned long ref, int message_type,
                return(-1);
 
        /* seek to end of response list */
                return(-1);
 
        /* seek to end of response list */
-       response = admin->response;
        responsep = &admin->response;
        responsep = &admin->response;
-       while(response)
+       while(*responsep)
        {
        {
-               responsep = &response->next;
-               response = response->next;
+               responsep = &(*responsep)->next;
        }
 
        /* create state response */
        }
 
        /* create state response */
-       response = (struct admin_queue *)MALLOC(sizeof(struct admin_queue)+sizeof(admin_message));
+       *responsep = (struct admin_queue *)MALLOC(sizeof(struct admin_queue)+sizeof(admin_message));
        memuse++;
        memuse++;
-       response->num = 1;
+       (*responsep)->num = 1;
 
        /* message */
 
        /* message */
-       response->am[0].u.msg.type = message_type;
-       response->am[0].u.msg.ref = ref;
-       memcpy(&response->am[0].u.msg.param, param, sizeof(union parameter));
-
-       /* attach to response chain */
-       *responsep = response;
-       responsep = &response->next;
+       (*responsep)->am[0].message = ADMIN_MESSAGE;
+       (*responsep)->am[0].u.msg.type = message_type;
+       (*responsep)->am[0].u.msg.ref = ref;
+       memcpy(&(*responsep)->am[0].u.msg.param, param, sizeof(union parameter));
 
        return(0);
 }
 
        return(0);
 }
@@ -813,8 +831,12 @@ int admin_state(struct admin_queue **responsep)
        *responsep = response;
        responsep = &response->next;
 
        *responsep = response;
        responsep = &response->next;
 
-       /* create response for all interfaces */
-       num = (response->am[0].u.s.interfaces)+(response->am[0].u.s.joins)+(response->am[0].u.s.epoints)+(response->am[0].u.s.ports);
+       /* create response for all instances */
+       num = (response->am[0].u.s.interfaces)
+           + (response->am[0].u.s.remotes)
+           + (response->am[0].u.s.joins)
+           + (response->am[0].u.s.epoints)
+           + (response->am[0].u.s.ports);
        if (num == 0)
                return(0);
        response = (struct admin_queue *)MALLOC(sizeof(admin_queue)+(num*sizeof(admin_message)));
        if (num == 0)
                return(0);
        response = (struct admin_queue *)MALLOC(sizeof(admin_queue)+(num*sizeof(admin_message)));
@@ -1169,7 +1191,7 @@ int admin_handle(void)
                        continue;
                }
                /* process socket command */
                        continue;
                }
                /* process socket command */
-               if (admin->response)
+               if (admin->response && msg.message != ADMIN_MESSAGE)
                {
                        PERROR("Data from socket %d while sending response.\n", admin->sock);
                        *adminp = admin->next;
                {
                        PERROR("Data from socket %d while sending response.\n", admin->sock);
                        *adminp = admin->next;
@@ -1236,7 +1258,7 @@ int admin_handle(void)
                        break;
 
                        case ADMIN_MESSAGE:
                        break;
 
                        case ADMIN_MESSAGE:
-                       if (admin_message_to_join(&msg.u.msg, admin->remote_name, admin->sock) < 0)
+                       if (admin_message_to_join(&msg.u.msg, admin) < 0)
                        {
                                PERROR("Failed to deliver message for socket %d.\n", admin->sock);
                                goto response_error;
                        {
                                PERROR("Failed to deliver message for socket %d.\n", admin->sock);
                                goto response_error;
@@ -1295,7 +1317,7 @@ int admin_handle(void)
                        work = 1;
                        if (len == 0)
                                goto end;
                        work = 1;
                        if (len == 0)
                                goto end;
-                       if (len < (int)(sizeof(struct admin_message)*(admin->response->num)-admin->response->offset))
+                       if (len < (int)(sizeof(struct admin_message)*(admin->response->num) - admin->response->offset))
                        {
                                admin->response->offset+=len;
                                goto next;
                        {
                                admin->response->offset+=len;
                                goto next;
diff --git a/trace.h b/trace.h
index 013b1db..65d50c4 100644 (file)
--- a/trace.h
+++ b/trace.h
 #define L3_RETRIEVE_ACKNOWLEDGE_IND    0x00033302
 #define L3_RETRIEVE_REJECT_REQ         0x00033700
 #define L3_RETRIEVE_REJECT_IND         0x00033702
 #define L3_RETRIEVE_ACKNOWLEDGE_IND    0x00033302
 #define L3_RETRIEVE_REJECT_REQ         0x00033700
 #define L3_RETRIEVE_REJECT_IND         0x00033702
-#ifdef SOCKET_MISDN
 #define L3_NEW_L3ID_REQ                        0x0003f000
 #define L3_NEW_L3ID_IND                        0x0003f002
 #define L3_RELEASE_L3ID_REQ            0x0003f100
 #define L3_RELEASE_L3ID_IND            0x0003f102
 #define L3_NEW_L3ID_REQ                        0x0003f000
 #define L3_NEW_L3ID_IND                        0x0003f002
 #define L3_RELEASE_L3ID_REQ            0x0003f100
 #define L3_RELEASE_L3ID_IND            0x0003f102
-#else
-#define L3_NEW_CR_REQ                  0x0003f000
-#define L3_NEW_CR_IND                  0x0003f002
-#define L3_RELEASE_CR_REQ              0x0003f100
-#define L3_RELEASE_CR_IND              0x0003f102
-#endif
 #define L3_TIMEOUT_REQ                 0x0003f200
 #define L3_TIMEOUT_IND                 0x0003f202
 #define L3_UNKNOWN                     0x0003ff00
 #define L3_TIMEOUT_REQ                 0x0003f200
 #define L3_TIMEOUT_IND                 0x0003f202
 #define L3_UNKNOWN                     0x0003ff00