fixes & improvements
[lcr.git] / vbox.cpp
index d0f124d..9fde9fa 100644 (file)
--- a/vbox.cpp
+++ b/vbox.cpp
@@ -1,6 +1,6 @@
 /*****************************************************************************\
 **                                                                           **
-** PBX4Linux                                                                 **
+** Linux Call Router                                                         **
 **                                                                           **
 **---------------------------------------------------------------------------**
 ** Copyright: Andreas Eversberg                                              **
@@ -62,7 +62,7 @@ int VBoxPort::handler(void)
 {
        struct message  *message;
        unsigned long   tosend;
-       unsigned char   buffer[ISDN_TRANSMIT<<3];
+       unsigned char   buffer[ISDN_TRANSMIT];
        time_t          currenttime;
        class Endpoint  *epoint;
        int             ret;
@@ -160,8 +160,6 @@ int VBoxPort::handler(void)
                        if (p_record)
                                record(buffer, tosend, 0); // from down
                        message = message_create(p_serial, ACTIVE_EPOINT(p_epointlist), PORT_TO_EPOINT, MESSAGE_DATA);
-                       message->param.data.port_type = p_type;
-                       message->param.data.port_id = p_serial;
                        message->param.data.len = tosend;
                        memcpy(message->param.data.data, buffer, tosend);
                        message_put(message);
@@ -180,7 +178,6 @@ int VBoxPort::message_epoint(unsigned long epoint_id, int message_id, union para
        struct message *message;
        class Endpoint *epoint;
        char filename[256], *c;
-       class EndpointAppPBX *eapp;
 
        if (Port::message_epoint(epoint_id, message_id, param))
                return(1);
@@ -194,6 +191,10 @@ int VBoxPort::message_epoint(unsigned long epoint_id, int message_id, union para
 
        switch(message_id)
        {
+               case MESSAGE_DATA:
+               record(param->data.data, param->data.len, 1); // from up
+               return(1);
+
                case MESSAGE_DISCONNECT: /* call has been disconnected */
                PDEBUG(DEBUG_VBOX, "PORT(%s) vbox port with (caller id %s) received disconnect cause=%d\n", p_name, p_callerinfo.id, param->disconnectinfo.cause);
 
@@ -224,9 +225,9 @@ int VBoxPort::message_epoint(unsigned long epoint_id, int message_id, union para
 
                case MESSAGE_SETUP: /* dial-out command received from epoint, answer with connect */
                /* get apppbx */
-               memcpy(&p_vbox_ext, ((class EndpointAppPBX *)(epoint->ep_app))->e_ext, sizeof(p_vbox_ext));
+               memcpy(&p_vbox_ext, &((class EndpointAppPBX *)(epoint->ep_app))->e_ext, sizeof(p_vbox_ext));
                /* extract optional announcement file */
-               if ((c = strchr(param->setup.dialinginfo.number, ',')))
+               if ((c = strchr(param->setup.dialinginfo.id, ',')))
                {
                        if (c[1] == '/')
                                SPRINT(filename, c+1);
@@ -237,23 +238,16 @@ int VBoxPort::message_epoint(unsigned long epoint_id, int message_id, union para
                {
                        SPRINT(filename, "%s/%s/%s/vbox/announcement", INSTALL_DATA, options.extensions_dir, p_vbox_ext.number);
                }
-               PDEBUG(DEBUG_VBOX, "PORT(%s) vbox port received setup from '%s' to '%s'\n", p_name, param->setup.callerinfo.id, param->setup.dialinginfo.number);
+               PDEBUG(DEBUG_VBOX, "PORT(%s) vbox port received setup from '%s' to '%s'\n", p_name, param->setup.callerinfo.id, param->setup.dialinginfo.id);
                memcpy(&p_callerinfo, &param->setup.callerinfo, sizeof(p_callerinfo));
                memcpy(&p_redirinfo, &param->setup.redirinfo, sizeof(p_redirinfo));
                /* link relation */
                if (p_epointlist)
-               {
-                       PERROR("PORT(%s) software error: epoint pointer is set in idle state, how bad!! exitting.\n", p_name);
-                       exit(-1);
-               }
-               if (!(epointlist_new(epoint_id)))
-               {
-                       PERROR("no memory for epointlist\n");
-                       exit(-1);
-               }
+                       FATAL("PORT(%s) Epoint pointer is set in idle state, how bad!!\n", p_name);
+               epointlist_new(epoint_id);
 
                /* copy setup infos to port */
-               SCPY(p_vbox_extension, param->setup.dialinginfo.number);
+               SCPY(p_vbox_extension, param->setup.dialinginfo.id);
 
                /* create connect info */
                SCPY(p_connectinfo.id, p_vbox_extension);