summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSuper User2007-12-22 10:10:18 +0100
committerSuper User2007-12-22 10:10:18 +0100
commite01d4caa3eef0f4d17e5513cb793e19fecd2b051 (patch)
tree4340e25359bd64c12f04d891d49057742111976b
parentsome minor output fixes (diff)
downloadlcr-e01d4caa3eef0f4d17e5513cb793e19fecd2b051.tar.gz
lcr-e01d4caa3eef0f4d17e5513cb793e19fecd2b051.tar.xz
lcr-e01d4caa3eef0f4d17e5513cb793e19fecd2b051.zip
some fixes, check README
modified: README modified: action.cpp modified: action_vbox.cpp modified: admin_client.c modified: admin_server.c modified: apppbx.cpp modified: apppbx.h modified: dss1.cpp modified: endpointapp.cpp modified: endpointapp.h modified: interface.c modified: joinpbx.cpp modified: joinremote.cpp modified: mISDN.cpp modified: main.h modified: message.h modified: port.cpp modified: port.h modified: todo.txt modified: tones.c
-rw-r--r--README31
-rw-r--r--action.cpp57
-rw-r--r--action_vbox.cpp2
-rw-r--r--admin_client.c157
-rw-r--r--admin_server.c2
-rw-r--r--apppbx.cpp4
-rw-r--r--apppbx.h4
-rw-r--r--dss1.cpp22
-rw-r--r--endpointapp.cpp2
-rw-r--r--endpointapp.h2
-rw-r--r--interface.c4
-rw-r--r--joinpbx.cpp2
-rw-r--r--joinremote.cpp2
-rw-r--r--mISDN.cpp4
-rw-r--r--main.h3
-rw-r--r--message.h9
-rw-r--r--port.cpp41
-rw-r--r--port.h4
-rw-r--r--todo.txt13
-rw-r--r--tones.c5
20 files changed, 243 insertions, 127 deletions
diff --git a/README b/README
index 300f0cb..c47cba9 100644
--- a/README
+++ b/README
@@ -1,7 +1,31 @@
+Note:
+-----
+PBX software can be connected to private hardware, as well as public
+switched networks. Due to wrong use or software bugs, it can cause failures
+to these networks and hardware, disturbing users of these networks and
+hardware, cause load and unwanted costs, and may prohibit making calls,
+especially in case of an emergency.
+
+The authors of this software cannot take any responsibility for correct
+use and correct behaviour of this software.
+If you use this software, you aggree the terms of the LICENSE and README
+file.
+You will also inform your customers about the content of the LICENSE and
+README file.
+
+Some countries and/or telephone networks require special approval in order
+to allow telephone devices to be connected to their networks.
+
+
+Installation and Usage:
+-----------------------
Read the documentation at http://www.linux-call-router.de
+History:
+--------
+
Changes in Version 20021228
- first release
@@ -366,7 +390,7 @@ Changes in Version 0.2
- Stall warning
- Audio recoriding still does not work.
-Lates changes
+Changes in Version 0.3
- Added join/release jingle options for partylines
- Fixed bug that did not release reserved channels, so interface run out of
channels.
@@ -375,5 +399,10 @@ Lates changes
****** Major hfc_multi bugfix *******
* no more crash with multiple cards *
*************************************
+- Screening bug removed. (Thanx Martin)
+- Wave files with FMT header > 16 now work.
+- Added timeouts for testcall feature. (lcradmin)
+ -> You can run scripts, that generate testcalls of multiple destinations.
+- Added origin flag to correctly process last_in and last_out call logging.
diff --git a/action.cpp b/action.cpp
index 9f9db8e..c80b8d3 100644
--- a/action.cpp
+++ b/action.cpp
@@ -636,44 +636,8 @@ void EndpointAppPBX::action_init_partyline(void)
*/
void EndpointAppPBX::action_hangup_call(void)
{
- int i;
-
trace_header("ACTION hangup", DIRECTION_NONE);
end_trace();
- /* check */
- if (e_ext.number[0] == '\0')
- {
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: cannot store last dialed number '%s' because caller is unknown (not internal).\n", ea_endpoint->ep_serial, e_ext.number, e_dialinginfo.id);
- return;
- }
- if (!(read_extension(&e_ext, e_ext.number)))
- {
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: cannot store last dialed number '%s' because cannot read settings.\n", ea_endpoint->ep_serial, e_ext.number, e_dialinginfo.id);
- return;
- }
- if (e_dialinginfo.id[0] == '\0')
- {
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: cannot store last dialed number because nothing was dialed.\n", ea_endpoint->ep_serial, e_ext.number);
- return;
- }
- if (!strcmp(e_dialinginfo.id, e_ext.last_out[0]))
- {
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: cannot store last dialed number '%s' because it is identical with the last one.\n", ea_endpoint->ep_serial, e_ext.number, e_dialinginfo.id);
- return;
- }
-
- /* insert */
- PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: storing last number '%s'.\n", ea_endpoint->ep_serial, e_ext.number, e_dialinginfo.id);
- i = MAX_REMEMBER-1;
- while(i)
- {
- UCPY(e_ext.last_out[i], e_ext.last_out[i-1]);
- i--;
- }
- SCPY(e_ext.last_out[0], e_dialinginfo.id);
-
- /* write extension */
- write_extension(&e_ext, e_ext.number);
}
@@ -2580,6 +2544,7 @@ void EndpointAppPBX::process_hangup(int cause, int location)
write_log(e_ext.number, callertext, dialingtext, e_start, e_stop, 0, cause, location);
/* store last received call for reply-list */
+ if (e_origin == 1) // outgoing to phone is incomming for user
if (e_callerinfo.id[0] || e_callerinfo.extension[0])
if (e_ext.anon_ignore || e_callerinfo.present!=INFO_PRESENT_RESTRICTED)
{
@@ -2601,8 +2566,26 @@ void EndpointAppPBX::process_hangup(int cause, int location)
} else
PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: cannot store last received id '%s' because it is identical with the last one.\n", ea_endpoint->ep_serial, e_ext.number, callertext);
}
- }
+ /* store last made call for reply-list */
+ if (e_origin == 0) // incomming from phone is outgoing for user
+ if (e_dialinginfo.id[0])
+ {
+ if (!!strcmp(e_dialinginfo.id, e_ext.last_out[0]))
+ {
+ i = MAX_REMEMBER-1;
+ while(i)
+ {
+ UCPY(e_ext.last_out[i], e_ext.last_out[i-1]);
+ i--;
+ }
+ SCPY(e_ext.last_out[0], e_dialinginfo.id);
+ writeext |= 1; /* store extension later */
+ PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: storing last number '%s'.\n", ea_endpoint->ep_serial, e_ext.number, e_dialinginfo.id);
+ } else
+ PDEBUG(DEBUG_EPOINT, "EPOINT(%d): terminal %s: cannot store last number '%s' because it is identical with the last one.\n", ea_endpoint->ep_serial, e_ext.number, e_dialinginfo.id);
+ }
+ }
/* write extension if needed */
if (writeext == 0x11)
write_extension(&e_ext, e_ext.number);
diff --git a/action_vbox.cpp b/action_vbox.cpp
index 0a5ebed..d9f805a 100644
--- a/action_vbox.cpp
+++ b/action_vbox.cpp
@@ -326,7 +326,7 @@ void EndpointAppPBX::action_dialing_vbox_play(void)
port = find_port_id(portlist->port_id);
if (port)
{
- port->close_record(6000); /* append beep */
+ port->close_record(0);
port->open_record(CODEC_MONO, 1, 5000, e_ext.number, 0, "", 0); /* record announcement, skip the first 5000 samples */
}
e_vbox_state = VBOX_STATE_RECORD_RECORD;
diff --git a/admin_client.c b/admin_client.c
index 65937e0..2c0b362 100644
--- a/admin_client.c
+++ b/admin_client.c
@@ -19,6 +19,8 @@
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <sys/un.h>
+#include <sys/time.h>
+#include <errno.h>
#include <curses.h>
#include "macro.h"
#include "join.h"
@@ -1312,75 +1314,163 @@ char *admin_cmd(int sock, int mode, char *extension, char *number)
/*
* makes a testcall
*/
+#define GET_NOW() { \
+ gettimeofday(&now_tv, &now_tz); \
+ now_d = ((double)(now_tv.tv_usec))/1000000 + now_tv.tv_sec; \
+ }
char *admin_testcall(int sock, int argc, char *argv[])
{
static struct admin_message msg;
+ int ar = 2;
+ int stimeout = 0, ptimeout = 0, atimeout = 0, ctimeout = 0;
+ int l;
+ double timer = 0, now_d;
+ unsigned long on = 1;
+ struct timeval now_tv;
+ struct timezone now_tz;
printf("pid=%d\n", getpid()); fflush(stdout);
+ while (argc > ar)
+ {
+ if (!strcmp(argv[ar], "--setup-timeout"))
+ {
+ ar++;
+ if (argc == ar)
+ return("Missing setup timeout value.\n");
+ stimeout = atoi(argv[ar]);
+ ar++;
+ } else
+ if (!strcmp(argv[ar], "--proceeding-timeout"))
+ {
+ ar++;
+ if (argc == ar)
+ return("Missing proceeding timeout value.\n");
+ ptimeout = atoi(argv[ar]);
+ ar++;
+ } else
+ if (!strcmp(argv[ar], "--alerting-timeout"))
+ {
+ ar++;
+ if (argc == ar)
+ return("Missing alerting timeout value.\n");
+ atimeout = atoi(argv[ar]);
+ ar++;
+ } else
+ if (!strcmp(argv[ar], "--connect-timeout"))
+ {
+ ar++;
+ if (argc == ar)
+ return("Missing connect timeout value.\n");
+ ctimeout = atoi(argv[ar]);
+ ar++;
+ } else
+ {
+ break;
+ }
+ }
+
/* send reload command */
memset(&msg, 0, sizeof(msg));
msg.message = ADMIN_CALL_SETUP;
- if (argc > 2)
+ msg.u.call.present = 1;
+
+ if (argc > ar)
{
- SCPY(msg.u.call.interface, argv[2]);
+ SCPY(msg.u.call.interface, argv[ar]);
}
- if (argc > 3)
+ ar++;
+ if (argc > ar)
{
- SCPY(msg.u.call.callerid, argv[3]);
+ SCPY(msg.u.call.callerid, argv[ar]);
}
- if (argc > 4)
+ ar++;
+ if (argc > ar)
{
- SCPY(msg.u.call.dialing, argv[4]);
+ SCPY(msg.u.call.dialing, argv[ar]);
}
- if (argc > 5)
+ ar++;
+ if (argc > ar)
{
- if (argv[5][0] == 'p')
- msg.u.call.present = 1;
+ if (argv[ar][0] == 'r')
+ msg.u.call.present = 0;
}
+ ar++;
msg.u.call.bc_capa = 0x00; /*INFO_BC_SPEECH*/
msg.u.call.bc_mode = 0x00; /*INFO_BMODE_CIRCUIT*/
msg.u.call.bc_info1 = 0;
msg.u.call.hlc = 0;
msg.u.call.exthlc = 0;
- if (argc > 6)
- msg.u.call.bc_capa = strtol(argv[6],NULL,0);
+ if (argc > ar)
+ msg.u.call.bc_capa = strtol(argv[ar],NULL,0);
else
msg.u.call.bc_info1 = 3 | 0x80; /* alaw, if no capability is given at all */
- if (argc > 7) {
- msg.u.call.bc_mode = strtol(argv[7],NULL,0);
+ ar++;
+ if (argc > ar) {
+ msg.u.call.bc_mode = strtol(argv[ar],NULL,0);
if (msg.u.call.bc_mode) msg.u.call.bc_mode = 2;
}
- if (argc > 8) {
- msg.u.call.bc_info1 = strtol(argv[8],NULL,0);
+ ar++;
+ if (argc > ar) {
+ msg.u.call.bc_info1 = strtol(argv[ar],NULL,0);
if (msg.u.call.bc_info1 < 0)
msg.u.call.bc_info1 = 0;
else
msg.u.call.bc_info1 |= 0x80;
}
- if (argc > 9) {
- msg.u.call.hlc = strtol(argv[9],NULL,0);
+ ar++;
+ if (argc > ar) {
+ msg.u.call.hlc = strtol(argv[ar],NULL,0);
if (msg.u.call.hlc < 0)
msg.u.call.hlc = 0;
else
msg.u.call.hlc |= 0x80;
}
-// printf("hlc=%d\n", msg.u.call.hlc);
- if (argc > 10) {
- msg.u.call.exthlc = strtol(argv[10],NULL,0);
+ ar++;
+ if (argc > ar) {
+ msg.u.call.exthlc = strtol(argv[ar],NULL,0);
if (msg.u.call.exthlc < 0)
msg.u.call.exthlc = 0;
else
msg.u.call.exthlc |= 0x80;
}
+ ar++;
if (write(sock, &msg, sizeof(msg)) != sizeof(msg))
return("Broken pipe while sending command.");
+ if (ioctl(sock, FIONBIO, (unsigned char *)(&on)) < 0)
+ return("Failed to set socket into non-blocking IO.");
+
+ if (stimeout)
+ {
+ GET_NOW();
+ timer = now_d + (double)stimeout;
+ }
+
/* receive response */
next:
- if (read(sock, &msg, sizeof(msg)) != sizeof(msg))
+ l = read(sock, &msg, sizeof(msg));
+ if (l < 0)
+ {
+ if (errno == EWOULDBLOCK)
+ {
+ if (timer)
+ {
+ GET_NOW();
+ if (timer <= now_d)
+ {
+ printf("Timeout\n"); fflush(stdout);
+ return(NULL);
+ }
+ }
+ usleep(30000);
+ goto next;
+ }
return("Broken pipe while receiving response.");
+ }
+ if (l != sizeof(msg))
+ return("Response has unexpected message size.");
switch(msg.message)
{
case ADMIN_CALL_SETUP_ACK:
@@ -1389,14 +1479,29 @@ next:
case ADMIN_CALL_PROCEEDING:
printf("PROCEEDING\n"); fflush(stdout);
+ if (ptimeout)
+ {
+ GET_NOW();
+ timer = now_d + (double)ptimeout;
+ }
goto next;
case ADMIN_CALL_ALERTING:
printf("ALERTING\n"); fflush(stdout);
+ if (atimeout)
+ {
+ GET_NOW();
+ timer = now_d + (double)atimeout;
+ }
goto next;
case ADMIN_CALL_CONNECT:
printf("CONNECT\n number=%s\n", msg.u.call.callerid); fflush(stdout);
+ if (ctimeout)
+ {
+ GET_NOW();
+ timer = now_d + (double)ctimeout;
+ }
goto next;
case ADMIN_CALL_NOTIFY:
@@ -1405,7 +1510,7 @@ next:
case ADMIN_CALL_DISCONNECT:
printf("DISCONNECT\n cause=%d %s\n location=%d %s\n", msg.u.call.cause, (msg.u.call.cause>0 && msg.u.call.cause<128)?isdn_cause[msg.u.call.cause].german:"", msg.u.call.location, (msg.u.call.location>=0 && msg.u.call.location<128)?isdn_location[msg.u.call.location].german:""); fflush(stdout);
- goto next;
+ break;
case ADMIN_CALL_RELEASE:
printf("RELEASE\n cause=%d %s\n location=%d %s\n", msg.u.call.cause, (msg.u.call.cause>0 && msg.u.call.cause<128)?isdn_cause[msg.u.call.cause].german:"", msg.u.call.location, (msg.u.call.location>=0 && msg.u.call.location<128)?isdn_location[msg.u.call.location].german:""); fflush(stdout);
@@ -1414,8 +1519,8 @@ next:
default:
return("Response not valid.");
}
-
- printf("Command successfull.\n");
+
+ printf("Call released.\n"); fflush(stdout);
return(NULL);
}
@@ -1519,7 +1624,9 @@ int main(int argc, char *argv[])
printf("block <port> - Block given port.\n");
printf("unblock <port> - Unblock given port.\n");
printf("unload <port> - Unload port. To load port use 'block' or 'unblock'.\n");
- printf("testcall <interface> <callerid> <number> [present|restrict [<capability>]] - Testcall\n");
+ printf("testcall [options] <interface> <callerid> <number> [present|restrict [<capability>]] - Testcall\n");
+ printf(" -> options = --setup-timeout <seconds> --proceeding-timeout <seconds>\n");
+ printf(" --alerting-timeout <seconds> --connect-timeout <seconds>\n");
printf(" -> capability = <bc> <mode> <codec> <hlc> <exthlc> (Values must be numbers, -1 to omit.)\n");
printf("trace [brief|short] [<filter> [...]] - Shows call trace. Use filter to reduce output.\n");
printf(" -> Use 'trace help' to see filter description.\n");
diff --git a/admin_server.c b/admin_server.c
index 419d2ec..08a4dde 100644
--- a/admin_server.c
+++ b/admin_server.c
@@ -513,7 +513,7 @@ int admin_call(struct admin_list *admin, struct admin_message *msg)
if (!(epoint = new Endpoint(0, 0)))
FATAL("No memory for Endpoint instance\n");
- if (!(epoint->ep_app = apppbx = new DEFAULT_ENDPOINT_APP(epoint)))
+ if (!(epoint->ep_app = apppbx = new DEFAULT_ENDPOINT_APP(epoint, 1))) // outgoing
FATAL("No memory for Endpoint Application instance\n");
apppbx->e_adminid = admin->sockserial;
admin->epointid = epoint->ep_serial;
diff --git a/apppbx.cpp b/apppbx.cpp
index 8729b41..e5f0e0d 100644
--- a/apppbx.cpp
+++ b/apppbx.cpp
@@ -25,7 +25,7 @@ class EndpointAppPBX *apppbx_first = NULL;
/*
* EndpointAppPBX constructor
*/
-EndpointAppPBX::EndpointAppPBX(class Endpoint *epoint) : EndpointApp(epoint)
+EndpointAppPBX::EndpointAppPBX(class Endpoint *epoint, int origin) : EndpointApp(epoint, origin)
{
class EndpointAppPBX **apppointer;
@@ -49,7 +49,7 @@ EndpointAppPBX::EndpointAppPBX(class Endpoint *epoint) : EndpointApp(epoint)
memset(&e_redirinfo, 0, sizeof(struct redir_info));
memset(&e_capainfo, 0, sizeof(struct capa_info));
e_start = e_stop = 0;
-// e_origin = 0;
+ e_origin = origin;
e_ruleset = ruleset_main;
if (e_ruleset)
e_rule = e_ruleset->rule_first;
diff --git a/apppbx.h b/apppbx.h
index 8d5c52c..b0d45f3 100644
--- a/apppbx.h
+++ b/apppbx.h
@@ -55,7 +55,7 @@ extern class EndpointAppPBX *apppbx_first;
class EndpointAppPBX : public EndpointApp
{
public:
- EndpointAppPBX(class Endpoint *epoint);
+ EndpointAppPBX(class Endpoint *epoint, int origin);
~EndpointAppPBX();
class EndpointAppPBX *next;
@@ -75,7 +75,7 @@ class EndpointAppPBX : public EndpointApp
struct redir_info e_redirinfo; /* info on redirection (to the calling user) */
struct capa_info e_capainfo; /* info on l3,l2 capacity */
time_t e_start, e_stop; /* time */
-// int e_origin; /* origin of call */
+ int e_origin; /* origin of call 0=incomming 1=outgoing */
struct route_ruleset *e_ruleset; /* current ruleset pointer (NULL=no ruleset) */
struct route_rule *e_rule; /* current rule pointer (NULL=no rule) */
struct route_action *e_action; /* current action pointer (NULL=no action) */
diff --git a/dss1.cpp b/dss1.cpp
index 18eb511..523ab32 100644
--- a/dss1.cpp
+++ b/dss1.cpp
@@ -738,7 +738,7 @@ void Pdss1::setup_ind(unsigned long prim, unsigned long dinfo, void *data)
FATAL("Incoming call but already got an endpoint.\n");
if (!(epoint = new Endpoint(p_serial, 0)))
FATAL("No memory for Endpoint instance\n");
- if (!(epoint->ep_app = new DEFAULT_ENDPOINT_APP(epoint)))
+ if (!(epoint->ep_app = new DEFAULT_ENDPOINT_APP(epoint, 0))) //incomming
FATAL("No memory for Endpoint Application instance\n");
epointlist_new(epoint->ep_serial);
@@ -1877,8 +1877,8 @@ void Pdss1::message_isdn(unsigned long prim, unsigned long dinfo, void *data)
}
p_m_d_l3id = 0;
p_m_delete = 1;
-#warning remove me
-PDEBUG(DEBUG_LOG, "JOLLY release cr %d\n", p_serial);
+//#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)
*/
@@ -1987,8 +1987,8 @@ int Pdss1::handler(void)
/* handle destruction */
if (p_m_delete && p_m_d_l3id==0)
{
-#warning remove
-PDEBUG(DEBUG_LOG, "JOLLY destroy object %d\n", p_serial);
+//#warning remove
+//PDEBUG(DEBUG_LOG, "JOLLY destroy object %d\n", p_serial);
delete this;
return(-1);
@@ -2791,8 +2791,8 @@ void Pdss1::message_release(unsigned long epoint_id, int message_id, union param
// // NOTE: a bug in mISDNuser (see disconnect_req_out !!!)
// || p_state==PORT_STATE_OUT_DISCO)
{
-#warning remove me
-PDEBUG(DEBUG_LOG, "JOLLY sending release complete %d\n", p_serial);
+//#warning remove me
+//PDEBUG(DEBUG_LOG, "JOLLY sending release complete %d\n", p_serial);
/* sending release complete */
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);
@@ -2868,8 +2868,8 @@ wirklich erst proceeding?:
/* remove epoint */
free_epointid(epoint_id);
// wait for release and callref to be released
-#warning remove me
-PDEBUG(DEBUG_LOG, "JOLLY sending disconnect %d\n", p_serial);
+//#warning remove me
+//PDEBUG(DEBUG_LOG, "JOLLY sending disconnect %d\n", p_serial);
}
@@ -3159,8 +3159,8 @@ int stack2manager_nt(void *dat, void *arg)
time(&mISDNport->l2establish);
PDEBUG(DEBUG_ISDN, "because we are ptp, we set a l2establish timer.\n");
}
-#warning debugging usleep crash
- printf("JOLLY release port %d\n", mISDNport->portnum);
+//#warning debugging usleep crash
+// printf("JOLLY release port %d\n", mISDNport->portnum);
usleep(1);
break;
diff --git a/endpointapp.cpp b/endpointapp.cpp
index 05d5d0b..9479033 100644
--- a/endpointapp.cpp
+++ b/endpointapp.cpp
@@ -16,7 +16,7 @@
/*
* EndpointApp constructor
*/
-EndpointApp::EndpointApp(class Endpoint *epoint)
+EndpointApp::EndpointApp(class Endpoint *epoint, int origin)
{
ea_endpoint = epoint;
classuse++;
diff --git a/endpointapp.h b/endpointapp.h
index 6bcc9fb..11001f3 100644
--- a/endpointapp.h
+++ b/endpointapp.h
@@ -14,7 +14,7 @@
class EndpointApp
{
public:
- EndpointApp(class Endpoint *epoint);
+ EndpointApp(class Endpoint *epoint, int origin);
virtual ~EndpointApp();
class Endpoint *ea_endpoint;
diff --git a/interface.c b/interface.c
index b27eeb2..6f95fb0 100644
--- a/interface.c
+++ b/interface.c
@@ -479,9 +479,6 @@ static int inter_screen(struct interface_screen **ifscreenp, struct interface *i
SPRINT(interface_error, "Error in %s (line %d): parameter '%s' expects old caller ID and new caller ID.\n", filename, line, parameter);
return(-1);
}
- p = value;
- el = p;
- p = get_seperated(p);
/* add screen entry to list*/
ifscreen = (struct interface_screen *)MALLOC(sizeof(struct interface_screen));
memuse++;
@@ -494,6 +491,7 @@ static int inter_screen(struct interface_screen **ifscreenp, struct interface *i
ifscreenp = &((*ifscreenp)->next);
*ifscreenp = ifscreen;
/* get match */
+ p = value;
while(*p)
{
el = p;
diff --git a/joinpbx.cpp b/joinpbx.cpp
index d0c8b1d..1fc7c99 100644
--- a/joinpbx.cpp
+++ b/joinpbx.cpp
@@ -1021,7 +1021,7 @@ int JoinPBX::out_setup(unsigned long epoint_id, int message_type, union paramete
epoint = new Endpoint(0, j_serial);
if (!epoint)
FATAL("No memory for Endpoint instance\n");
- if (!(epoint->ep_app = new DEFAULT_ENDPOINT_APP(epoint)))
+ if (!(epoint->ep_app = new DEFAULT_ENDPOINT_APP(epoint, 1))) // outgoing
FATAL("No memory for Endpoint Application instance\n");
relation->epoint_id = epoint->ep_serial;
/* send setup message to new endpoint */
diff --git a/joinremote.cpp b/joinremote.cpp
index 7fc14d1..0fb9acf 100644
--- a/joinremote.cpp
+++ b/joinremote.cpp
@@ -101,7 +101,7 @@ void JoinRemote::message_remote(int message_type, union parameter *param)
if (!(epoint = new Endpoint(0, j_serial)))
FATAL("No memory for Endpoint instance\n");
j_epoint_id = epoint->ep_serial;
- if (!(epoint->ep_app = new DEFAULT_ENDPOINT_APP(epoint)))
+ if (!(epoint->ep_app = new DEFAULT_ENDPOINT_APP(epoint, 1))) // outgoing
FATAL("No memory for Endpoint Application instance\n");
}
diff --git a/mISDN.cpp b/mISDN.cpp
index 7a95c9f..3c4c23d 100644
--- a/mISDN.cpp
+++ b/mISDN.cpp
@@ -1382,7 +1382,9 @@ int PmISDN::handler(void)
p_m_load = 0;
/* to send data, tone must be active OR crypt messages must be on */
- if ((p_tone_name[0] || p_m_crypt_msg_loops) && p_m_load < ISDN_LOAD)
+ if ((p_tone_name[0] || p_m_crypt_msg_loops)
+ && (p_m_load < ISDN_LOAD)
+ && (p_state==PORT_STATE_CONNECT || p_m_mISDNport->tones))
{
int tosend = ISDN_LOAD - p_m_load, length;
#ifdef SOCKET_MISDN
diff --git a/main.h b/main.h
index f2cc3ff..3e8ec33 100644
--- a/main.h
+++ b/main.h
@@ -13,7 +13,7 @@
#define DEFAULT_ENDPOINT_APP EndpointAppPBX
-#define VERSION_STRING "0.2 (August 2007)"
+#define VERSION_STRING "0.3 (December 2007)"
extern int memuse;
extern int mmemuse;
@@ -68,7 +68,6 @@ void debug(const char *function, int line, char *prefix, char *buffer);
*/
#define ISDN_LOAD 1024 // samples
#define ISDN_MAXLOAD 2048 // samples
-#define ISDN_TRANSMIT 256 // samples
/* give sendmail program. if not inside $PATH, give absolute path here (e.g. "/usr/sbin/sendmail")
*/
diff --git a/message.h b/message.h
index 1db509c..4776949 100644
--- a/message.h
+++ b/message.h
@@ -9,6 +9,8 @@
** **
\*****************************************************************************/
+#define ISDN_TRANSMIT 256 // samples
+
enum { /* interface types */
INFO_ITYPE_ISDN,
INFO_ITYPE_ISDN_EXTENSION, /* call from internal extension */
@@ -265,7 +267,7 @@ struct park_info {
/* DATA */
struct param_data {
- unsigned char data[512]; /* audio/hdlc data */
+ unsigned char data[ISDN_TRANSMIT]; /* audio/hdlc data */
int len; /* audio/hdlc data */
};
@@ -360,7 +362,6 @@ enum { /* messages between entities */
MESSAGE_TONE, /* set information tone (to isdn port) */
MESSAGE_DTMF, /* dtmf digit (from isdn port) */
MESSAGE_mISDNSIGNAL, /* special mixer command (down to isdn port) */
-
MESSAGE_SETUP, /* setup message */
MESSAGE_INFORMATION, /* additional digit information */
MESSAGE_OVERLAP, /* call accepted, send more information */
@@ -372,18 +373,14 @@ enum { /* messages between entities */
MESSAGE_TIMEOUT, /* protocol state has timed out (port->epoint) */
MESSAGE_NOTIFY, /* used to send progress and notify infos */
MESSAGE_FACILITY, /* used to facility infos, like aocd */
-
MESSAGE_SUSPEND, /* suspend port */
MESSAGE_RESUME, /* resume port */
-
MESSAGE_AUDIOPATH, /* set status of audio path to endpoint (to call, audio is also set) */
// MESSAGE_REMOTE_AUDIO, /* tell remote to set audio status */
MESSAGE_PATTERN, /* pattern information tones available */
MESSAGE_NOPATTERN, /* pattern information tones unavailable */
MESSAGE_CRYPT, /* encryption message */
-
MESSAGE_DATA, /* audio/hdlc data */
-
MESSAGE_VBOX_PLAY, /* play recorded file */
MESSAGE_VBOX_PLAY_SPEED,/* change speed of file */
MESSAGE_VBOX_TONE, /* set answering VBOX tone */
diff --git a/port.cpp b/port.cpp
index a10a6f0..d9f07c3 100644
--- a/port.cpp
+++ b/port.cpp
@@ -19,12 +19,10 @@ Audio flow has two ways:
* from the upper layer to the channel
-> sound from remote channel
- -> sound from asterisk
Audio is required:
-> if local or remote channel is not mISDN
- -> if endpoint is linked to asterisk
-> if call is recorded (vbox)
@@ -1031,19 +1029,23 @@ void Port::record(unsigned char *data, int length, int dir_fromup)
if (!p_record || !length)
return;
- /* skip */
- if (dir_fromup)
+ /* skip data from local caller (dtmf input) */
+ if (p_record_skip && !dir_fromup)
{
- /* more than we have */
+ /* more to skip than we have */
if (p_record_skip > length)
{
p_record_skip -= length;
return;
}
+ /* less to skip */
data += p_record_skip;
length -= p_record_skip;
+ p_record_skip = 0;
}
+//printf("dir=%d len=%d\n", dir_fromup, length);
+
free = ((p_record_buffer_readp - p_record_buffer_writep - 1) & RECORD_BUFFER_MASK);
//PDEBUG(DEBUG_PORT, "record(data,%d,%d): free=%d, p_record_buffer_dir=%d, p_record_buffer_readp=%d, p_record_buffer_writep=%d.\n", length, dir_fromup, free, p_record_buffer_dir, p_record_buffer_readp, p_record_buffer_writep);
@@ -1051,8 +1053,9 @@ void Port::record(unsigned char *data, int length, int dir_fromup)
/* the buffer stores the same data stream */
if (dir_fromup == p_record_buffer_dir)
{
- same_again:
+same_again:
+//printf("same free=%d length=%d\n", free, length);
/* first write what we can to the buffer */
while(free && length)
{
@@ -1064,7 +1067,7 @@ void Port::record(unsigned char *data, int length, int dir_fromup)
/* all written, so we return */
if (!length)
return;
- /* still data left, buffer is full, so we need to write to file */
+ /* still data left, buffer is full, so we need to write a chunk to file */
switch(p_record_type)
{
case CODEC_MONO:
@@ -1077,6 +1080,7 @@ void Port::record(unsigned char *data, int length, int dir_fromup)
i++;
}
fwrite(write_buffer, 512, 1, p_record);
+ p_record_length += 512;
break;
case CODEC_STEREO:
@@ -1103,6 +1107,7 @@ void Port::record(unsigned char *data, int length, int dir_fromup)
}
}
fwrite(write_buffer, 1024, 1, p_record);
+ p_record_length += 1024;
break;
case CODEC_8BIT:
@@ -1110,11 +1115,12 @@ void Port::record(unsigned char *data, int length, int dir_fromup)
i = 0;
while(i < 256)
{
- *d++ = (p_record_buffer[p_record_buffer_readp]+0x8000) >> 8;
+ *d++ = ((unsigned short)(p_record_buffer[p_record_buffer_readp]+0x8000)) >> 8;
p_record_buffer_readp = (p_record_buffer_readp + 1) & RECORD_BUFFER_MASK;
i++;
}
fwrite(write_buffer, 512, 1, p_record);
+ p_record_length += 512;
break;
case CODEC_LAW:
@@ -1127,14 +1133,16 @@ void Port::record(unsigned char *data, int length, int dir_fromup)
i++;
}
fwrite(write_buffer, 256, 1, p_record);
+ p_record_length += 256;
break;
}
/* because we still have data, we write again */
- free += sizeof(write_buffer);
+ free += 256;
goto same_again;
}
/* the buffer stores the other stream */
+different_again:
/* if buffer empty, change it */
if (p_record_buffer_readp == p_record_buffer_writep)
{
@@ -1145,6 +1153,10 @@ void Port::record(unsigned char *data, int length, int dir_fromup)
ii = (p_record_buffer_writep - p_record_buffer_readp) & RECORD_BUFFER_MASK;
if (length < ii)
ii = length;
+
+ if (ii > 256)
+ ii = 256;
+//printf("same ii=%d length=%d\n", ii, length);
//PDEBUG(DEBUG_PORT, "record(data,%d,%d): free=%d, p_record_buffer_dir=%d, p_record_buffer_readp=%d, p_record_buffer_writep=%d: mixing %d bytes.\n", length, dir_fromup, free, p_record_buffer_dir, p_record_buffer_readp, p_record_buffer_writep, ii);
/* write data mixed with the buffer */
@@ -1164,6 +1176,7 @@ void Port::record(unsigned char *data, int length, int dir_fromup)
i++;
}
fwrite(write_buffer, ii<<1, 1, p_record);
+ p_record_length += (ii<<1);
break;
case CODEC_STEREO:
@@ -1190,6 +1203,7 @@ void Port::record(unsigned char *data, int length, int dir_fromup)
}
}
fwrite(write_buffer, ii<<2, 1, p_record);
+ p_record_length += (ii<<2);
break;
case CODEC_8BIT:
@@ -1206,6 +1220,7 @@ void Port::record(unsigned char *data, int length, int dir_fromup)
i++;
}
fwrite(write_buffer, ii, 1, p_record);
+ p_record_length += ii;
break;
case CODEC_LAW:
@@ -1222,15 +1237,13 @@ void Port::record(unsigned char *data, int length, int dir_fromup)
i++;
}
fwrite(write_buffer, ii, 1, p_record);
+ p_record_length += ii;
break;
}
length -= ii;
- /* data, but buffer empty */
+ /* still data */
if (length)
- {
- p_record_buffer_dir = dir_fromup;
- goto same_again;
- }
+ goto different_again;
/* no data (maybe buffer) */
return;
diff --git a/port.h b/port.h
index abaf992..d23ace0 100644
--- a/port.h
+++ b/port.h
@@ -80,7 +80,7 @@ enum { /* event list from listening to tty */
TTYI_EVENT_BUSY, /* channel unavailable */
};
-#define RECORD_BUFFER_LENGTH 1024
+#define RECORD_BUFFER_LENGTH 1024 // must be a binary border & must be greater 256, because 256 will be written if buffer overflows
#define RECORD_BUFFER_MASK 1023
/* structure of epoint_list */
@@ -187,7 +187,7 @@ class Port
int p_record_skip; /* skip bytes before writing the sample */
unsigned long p_record_length; /* size of what's written so far */
- unsigned short p_record_buffer[RECORD_BUFFER_LENGTH];
+ signed short p_record_buffer[RECORD_BUFFER_LENGTH];
unsigned long p_record_buffer_readp;
unsigned long p_record_buffer_writep;
int p_record_buffer_dir; /* current direction in buffer */
diff --git a/todo.txt b/todo.txt
index fe404ae..4ae6d1e 100644
--- a/todo.txt
+++ b/todo.txt
@@ -28,19 +28,6 @@ sonderwahlton
facility: diversion, 3pty, ...
-VLAN-Kamera
-
-
-
-chan.cpp
-
-struct Channel *chan_first;
-
-chan->bchannel_receive
-
-struct ChanAsterisk *chanasterisk;
-
-
diff --git a/tones.c b/tones.c
index 4a386ff..e5f2c75 100644
--- a/tones.c
+++ b/tones.c
@@ -155,7 +155,7 @@ int open_tone(char *file, int *codec, signed long *length, signed long *left)
read(fh, buffer, 8);
chunk=(buffer[4]) + (buffer[5]<<8) + (buffer[6]<<16) + (buffer[7]<<24);
size -= (8+chunk);
-// printf("%c%c%c%c lenght=%d\n",buffer[0],buffer[1],buffer[2],buffer[3],chunk);
+// printf("%c%c%c%c length=%d\n",buffer[0],buffer[1],buffer[2],buffer[3],chunk);
if (size < 0)
{
close(fh);
@@ -165,7 +165,7 @@ int open_tone(char *file, int *codec, signed long *length, signed long *left)
}
if (!strncmp((char *)buffer, "fmt ", 4))
{
- if (chunk != 16)
+ if (chunk < 16)
{
close(fh);
errno = 0;
@@ -217,6 +217,7 @@ int open_tone(char *file, int *codec, signed long *length, signed long *left)
*length = ((signed long)chunk)>>1;
if (left)
*left = ((signed long)chunk)>>1;
+ printf("left=%d\n",*left);
} else
if (bytes==2 && channels==2)
{