fixes & improvements
authorSuper User <root@isdn.jolly.ten>
Wed, 18 Jul 2007 09:44:25 +0000 (11:44 +0200)
committerSuper User <root@isdn.jolly.ten>
Wed, 18 Jul 2007 09:44:25 +0000 (11:44 +0200)
modified:   admin_client.c
modified:   apppbx.cpp
modified:   asterisk_client.c
deleted:    default/h323_gateway.conf
modified:   default/options.conf
modified:   default/routing.conf
modified:   dss1.cpp
modified:   message.c
modified:   todo.txt
modified:   vbox.cpp
modified:   vbox.h

admin_client.c
apppbx.cpp
asterisk_client.c
default/h323_gateway.conf [deleted file]
default/options.conf
default/routing.conf
dss1.cpp
message.c
todo.txt
vbox.cpp
vbox.h

index 67d08c9..a7e7f52 100644 (file)
@@ -439,13 +439,13 @@ int debug_join(struct admin_message *msg, struct admin_message *m, int line, int
 
        return(line);
 }
-char *admin_state(int sock)
+char *admin_state(int sock, char *argv[])
 {
        struct admin_message    msg,
                                *m;
        char                    buffer[512],
                                *p;
-       int                     line, offset = 0;
+       int                     line, offset = 0, hoffset = 0;
        int                     i, ii, j, jj, k;
        unsigned long           l, ll;
        int                     num;
@@ -453,6 +453,8 @@ char *admin_state(int sock)
        int                     off;
        int                     ltee;
        int                     anything;
+       int                     enter = 0;
+       char                    enter_string[128] = "", ch;
 
        /* flush logfile name */
        logfile[0] = '\0';
@@ -933,10 +935,19 @@ char *admin_state(int sock)
                        while(l!=ll)
                        {
                                move(line++>1?line-1:1, 0);
-                               SCPY(buffer, logline[l % LOGLINES]);
+                               if (strlen(logline[l % LOGLINES]) > hoffset)
+                                       SCPY(buffer, logline[l % LOGLINES] + hoffset);
+                               else
+                                       buffer[0] = '\0';
                                if (COLS < (int)strlen(buffer))
-                                       buffer[COLS] = '\0';
-                               addstr(buffer);
+                               {
+                                       buffer[COLS-1] = '\0';
+                                       addstr(buffer);
+                                       color(red);
+                                       addch('*');
+                                       color(white);
+                               } else
+                                       addstr(buffer);
                                l++;
                        }
                }
@@ -972,13 +983,23 @@ char *admin_state(int sock)
                color(red);
                addstr(buffer);
        }
+       if (hoffset)
+       {
+               move(1, 13);
+               SPRINT(buffer, "H-Offset +%d", hoffset);
+               color(red);
+               addstr(buffer);
+       }
        /* display end */
        move(LINES-2, 0);
        color(white);
        hline(ACS_HLINE, COLS);
        move(LINES-1, 0);
        color(white);
-       SPRINT(buffer, "i = interfaces '%s'  c = calls '%s'  l = log  q = quit  +/- = scroll", text_interfaces[show_interfaces], text_calls[show_calls]);
+       if (enter)
+               SPRINT(buffer, "-> %s", enter_string);
+       else
+               SPRINT(buffer, "i=interfaces '%s'  c=calls '%s'  l=log  q=quit  +-*/=scroll  enter", text_interfaces[show_interfaces], text_calls[show_calls]);
        addstr(buffer);
        refresh();
 
@@ -990,47 +1011,125 @@ char *admin_state(int sock)
                goto again;
        }
 
-       /* user input */
-       switch(getch())
+       if (enter)
        {
-               case 12: /* refresh */
-               cleanup_curses();
-               init_curses();
-               goto again;
-               break;
-
-               case 3: /* abort */
-               case 'q':
-               case 'Q':
-               break;
+               /* user input in enter mode */
+               ch = getch();
+               if (ch == 10)
+               {
+                       FILE *fp;
+
+                       enter = 0;
+                       if (!enter_string[0])
+                               goto again;
+
+                       SPRINT(logline[logcur++ % LOGLINES], "> %s", enter_string);
+                       if (!!strncmp(enter_string, "interface", 10) &&
+                           !!strncmp(enter_string, "route", 6) &&
+                           !!strncmp(enter_string, "release ", 8) &&
+                           !!strncmp(enter_string, "block ", 6) &&
+                           !!strncmp(enter_string, "unblock ", 8) &&
+                           !!strncmp(enter_string, "unload ", 7))
+                       {
+                               SPRINT(logline[logcur++ % LOGLINES], "usage:");
+                               SPRINT(logline[logcur++ % LOGLINES], "interface (reload interface.conf)");
+                               SPRINT(logline[logcur++ % LOGLINES], "route (reload routing.conf)");
+                               SPRINT(logline[logcur++ % LOGLINES], "release <EP> (release endpoint with given ID)");
+                               SPRINT(logline[logcur++ % LOGLINES], "block <port> (block port for further calls)");
+                               SPRINT(logline[logcur++ % LOGLINES], "unblock <port> (unblock port for further calls, load if not loaded)");
+                               SPRINT(logline[logcur++ % LOGLINES], "unload <port> (unload mISDN stack, release call calls)");
+                       } else
+                       {
+                               /* applend output to log window */
+                               SPRINT(buffer, "%s %s", argv[0], enter_string);
+                               fp = popen(buffer, "r");
+                               if (fp)
+                               {
+                                       while(fgets(logline[logcur % LOGLINES], sizeof(logline[0]), fp))
+                                               logline[logcur++ % LOGLINES][sizeof(logline[0])-1] = '\0';
+                                       pclose(fp);
+                               } else
+                               {
+                                       SPRINT(logline[logcur++ % LOGLINES], "failed to execute '%s'", buffer);
+                               }
+                       }
+                       logline[logcur % LOGLINES][0] = '\0';
+                       enter_string[0] = '\0';
+                       goto again;
+               }
+               if (ch>=32 && ch<=126)
+               {
+                       SCCAT(enter_string, ch);
+                       goto again;
+               } else
+               if (ch==8 || ch==127)
+               {
+                       if (enter_string[0])
+                               enter_string[strlen(enter_string)-1] = '\0';
+                       goto again;
+               } else
+               if (ch != 3)
+               {
+                       usleep(250000);
+                       goto again;
+               }
+       } else
+       {
+               /* user input in normal mode */
+               switch(getch())
+               {
+                       case 12: /* refresh */
+                       cleanup_curses();
+                       init_curses();
+                       goto again;
+                       break;
 
-               case 'i': /* toggle interface */
-               show_interfaces++;
-               if (show_interfaces > 3) show_interfaces = 0;
-               goto again;
+                       case 3: /* abort */
+                       case 'q':
+                       case 'Q':
+                       break;
 
-               case 'c': /* toggle calls */
-               show_calls++;
-               if (show_calls > 2) show_calls = 0;
-               goto again;
+                       case 'i': /* toggle interface */
+                       show_interfaces++;
+                       if (show_interfaces > 3) show_interfaces = 0;
+                       goto again;
 
-               case 'l': /* toggle log */
-               show_log++;
-               if (show_log > 1) show_log = 0;
-               goto again;
+                       case 'c': /* toggle calls */
+                       show_calls++;
+                       if (show_calls > 2) show_calls = 0;
+                       goto again;
 
-               case '+': /* scroll down */
-               offset++;
-               goto again;
-               
-               case '-': /* scroll up */
-               if (offset)
-                       offset--;
-               goto again;
+                       case 'l': /* toggle log */
+                       show_log++;
+                       if (show_log > 1) show_log = 0;
+                       goto again;
 
-               default:
-               usleep(250000);
-               goto again;
+                       case '+': /* scroll down */
+                       offset++;
+                       goto again;
+                       
+                       case '-': /* scroll up */
+                       if (offset)
+                               offset--;
+                       goto again;
+
+                       case '*': /* scroll right */
+                       hoffset += 2;
+                       goto again;
+                       
+                       case '/': /* scroll left */
+                       if (hoffset)
+                               hoffset -= 2;
+                       goto again;
+
+                       case 10: /* entermode */
+                       enter = 1;
+                       goto again;
+
+                       default:
+                       usleep(250000);
+                       goto again;
+               }
        }
 
        /* check for logfh */
@@ -1425,7 +1524,7 @@ int main(int argc, char *argv[])
        switch(mode)
        {
                case MODE_STATE:
-               ret = admin_state(sock);
+               ret = admin_state(sock, argv);
                break;
        
                case MODE_INTERFACE:
index 8e8d87b..7dbf24e 100644 (file)
@@ -2380,12 +2380,16 @@ void EndpointAppPBX::port_disconnect_release(struct port_list *portlist, int mes
        e_multipoint_cause = 0;
        e_multipoint_location = LOCATION_PRIVATE_LOCAL;
 
-       /* tone to disconnected end */
-       SPRINT(buffer, "cause_%02x", cause);
-       if (ea_endpoint->ep_portlist)
-               set_tone(ea_endpoint->ep_portlist, buffer);
+       if (message_type == MESSAGE_DISCONNECT)
+       {
+               /* tone to disconnected end */
+               SPRINT(buffer, "cause_%02x", cause);
+               if (ea_endpoint->ep_portlist)
+                       set_tone(ea_endpoint->ep_portlist, buffer);
+
+               new_state(EPOINT_STATE_IN_DISCONNECT);
+       }
 
-       new_state(EPOINT_STATE_IN_DISCONNECT);
        if (ea_endpoint->ep_join_id)
        {
                int haspatterns = 0;
@@ -2419,6 +2423,8 @@ void EndpointAppPBX::port_disconnect_release(struct port_list *portlist, int mes
                        PDEBUG(DEBUG_EPOINT, "EPOINT(%d) the port has no patterns.\n", ea_endpoint->ep_serial);
                }
        }
+       if (message_type == MESSAGE_RELEASE)
+               ea_endpoint->free_portlist(portlist);
        release(RELEASE_ALL, location, cause, LOCATION_PRIVATE_LOCAL, CAUSE_NORMAL); /* RELEASE_TYPE, callcause, portcause */
        return; /* must exit here */
 }
index 386ea40..def6545 100644 (file)
@@ -1,6 +1,6 @@
 /*****************************************************************************\
 **                                                                           **
-** LCR                                                                       **
+** Linux Call Router                                                         **
 **                                                                           **
 **---------------------------------------------------------------------------**
 ** Copyright: Andreas Eversberg                                              **
diff --git a/default/h323_gateway.conf b/default/h323_gateway.conf
deleted file mode 100644 (file)
index 96a8f8e..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-# Gateway configuration for incoming h323 calls
-#
-# Incoming calls will be mapped to the given extensions. If calling host
-# is not listed here, it will be processed as extenal call.
-# IP numbers must be given here, not host names.
-# The "connect" option allows to send back a connect before the call is 
-# actually answered. Some H323 client will only allow entering of digits
-# after a connect.
-# Using "dtmf" connects and also enables DTMF detection.
-#
-# <host ip>    <extension>     [connect | dtmf]
-192.168.0.2    200
-
index e639350..21c8697 100644 (file)
@@ -1,14 +1,16 @@
-# PBX options
+# LCR options
 #############
 
 # Turn debugging all on=0xffff or off=0x0000 (default= 0x0000)
+# Note that debugging is for developer only. If you wan't to 'see the LCR
+# working', you will find a logging feature below. Also detailed traces
+# are possible using the admin tool.
 #define DEBUG_CONFIG   0x0001
 #define DEBUG_MSG      0x0002
 #define DEBUG_STACK    0x0004
 #define DEBUG_BCHANNEL         0x0008
 #define DEBUG_PORT     0x0100
 #define DEBUG_ISDN     0x0110
-#define DEBUG_H323     0x0120 
 #define DEBUG_VBOX     0x0180
 #define DEBUG_EPOINT   0x0200
 #define DEBUG_CALL     0x0400
 
 #debug 0x0000
 
-# The log file can be used to track actions by the PBX. Omit the parameter
+# The log file can be used to track actions by the LCR. Omit the parameter
 # to turn off log file. By default, log file is located inside the directory
-# "/usr/local/pbx/log".
-#log /usr/local/pbx/log
+# "/usr/local/lcr/log".
+#log /usr/local/lcr/log
 
 # Use "alaw" (default) or "ulaw" samples.
 #alaw
 
-# The pbx should run as real time process. Because audio is streamed and
+# The LCR should run as real time process. Because audio is streamed and
 # ISDN protocol requires a certain response time, we must have high priority.
 # By default, the process runs with realtime scheduling and high priority.
 # To debug, it is whise to use "schedule" with no parameter to turn off
-# realtime scheduling. In case of an endless loop bug, PBX4Linux will take
+# realtime scheduling. In case of an endless loop bug, LCR will take
 # all CPU time forever - your machine hangs.
 #schedule 0
 
 # By default keypad facility is disabled.
 #keypad
 
-# Internal/external ports (cards connected to your isdn line)
-# MUST be the card number. Use "./pbx query" to list.
-# Add "ptp" for using internal port as point-to-point. (Only required for NT mode ports.)
-# Example: port 2
-#          port 3 ptp
-port 2
-port 3
-
-# Specify the H323 endpoint name. If omitted the hostname is used.
-#h323_name PBX4Linux
-
-# Incoming H323 calls can be connected prior answer, because some clients will
-# not play any inband tones during ringing, they just wait as nothing would
-# happen.
-# This only works for external calls. If a H323 caller is authenticated via
-# h323_gateway.conf, a special "connect" option may be used to connect as
-# soon as the call is received.
-# By default this feature is turned off.
-#h323_ringconnect
-
-# Specify which codecs may be used for H323 calls
-# "h323_law"   ALaw and muLaw codec which requre more than 64k internet
-#              connection cause by overhead. The parameter defines the frame
-#              size. The size range is 10 - 240.
-# "h323_g726"  The adpcm codec G726. The parameter defines the bits per sample.
-#              The bits must be 2, 3, 4, or 5. (16, 24, 32, 40 kbits/s) 
-#              The given value will always include all modes with lower value.
-# "h323_gsm"   GSM0610 and MicrosoftGSM codecs (not compatible with netmeeting)
-#              The prameter defines the frame size. The frame range is 1 - 7.
-# "h323_lpc10" Codec with very low bandwith usage which can even be used on
-#              slow internetconnections like 9600 kBit (about 300 bytes/s)
-# "h323_speex" Non standard Speex codec. The parameter defines the mode.
-#              The mode range is 2 - 6.
-#              The given value will always include all modes with lower value.
-# "h323_xspeex"        Non standard XiphSpeex codec. The parameter defines the mode.
-#              The mode range is 2 - 6.
-#              The given value will always include all modes with lower value.
-# The priority of the codecs to use is given by it's order.
-# By default, no codec is used
-h323_gsm 4
-h323_g726 2
-#h323_lpc10
-#h323_speex 4
-#h323_xspeex 4
-h323_law 64
-
-# To allow incoming calls via H323, the following option is used:
-# "h323_icall [<prefix>]"
-# The given prefix is used for incoming calls which do not send any dialing
-# information. If you like to route calls to an extension, give extension
-# dialing as specified at numbering_ext.conf.
-# By default no calls are accepted.
-# Omit the prefix and it must be dialed by the caller.
-h323_icall 0
-
-# Specify the port to listen on incoming H323 connections.
-# The default value is 1720.
-#h323_port 1720
-
-# To register with a gatekeeper, the following option is used:
-# "h323_gatekeeper [<host or ip>]
-# If no parameter is given, the gatekeeper is searched automatically.
-#h323_gatekeeper
-
-# To use dtmf detection for call from or to ISDN, uncomment the keyword "dtmf".
-# By default dtmf detection is used. Note that dtmf detection needs cpu time.
-# Dtmf detection is essential when handling the call after connect using
-# keypad. (conferrence, callback, ect...)
-#nodtmf
-
 # For calls to external where caller id is not available, this id is used.
 # It is sent of type "subscriber number". This ID is only usefull if the
 # external line will not screen caller id. It will be sent anonymous.
@@ -143,12 +75,6 @@ h323_icall 0
 # Default is nothing.
 #dummyid 0
 
-# If your external ISDN line(s) support inband patterns prior call connect,
-# you may say 'yes' here. In this case the PBX's tones are used for incoming
-# calls. This may require a special subscription because it can be abused
-# to transfer audio prior charge of call
-#inbandpattern no
-
 # Tones/announcements are streamed from user space. It is possible to use
 # the module "mISDN_dsp.o" instead. It provides simple tones with much less cpu
 # usage. If supported by special hardware, tones are loops that require no
@@ -158,8 +84,8 @@ h323_icall 0
 # "oldgerman". "oldgerman" sounds like the old german telephone system (POTS).
 #dsptones none
 
-# Source email address of the PBX. E.g. it is used when sending a mail
+# Source email address of the LCR. E.g. it is used when sending a mail
 # from the voice box. It is not the address the mails are sent to.
 # Most mail servers require an existing domain in order to accept mails.
-#email pbx@jolly.de
+#email lcr@your.domain
 
index ff7207f..0e2aaac 100644 (file)
@@ -5,7 +5,6 @@
 # Calls with different origins will be processed in different rulesets.
 
 [main]
-h323                                   : goto ruleset=voip
 extern                                 : goto ruleset=extern
 intern                                 : goto ruleset=intern
                                        : disconnect cause=31
@@ -17,7 +16,7 @@ intern                                        : goto ruleset=intern
 dialing=0,1234                         : intern extension=200
 dialing=200-299                                : intern
 dialing=81                             : partyline room=42
-timeout=6                              : intern extension=200
+#timeout=6                             : intern extension=200
 default                                        : disconnect cause=1
 
 
@@ -29,7 +28,6 @@ dialing=0                             : extern
 dialing=1                              : extern capability=digital-unrestricted
 dialing=200-299                                : intern
 dialing=3                              : pick
-dialing=4                              : h323
 dialing=5                              : reply
 dialing=6 enblock                      : redial
 dialing=6                              : redial select
@@ -56,10 +54,4 @@ dialing=99                           : test
 default                                        : disconnect cause=1 display="Invalid Code"
 
 
-# Ruleset: VOIP
-# All calls will be forwarded to extension 200
-
-[voip]
-                                       : intern extension=200
-
 
index d02ea6c..8f23c74 100644 (file)
--- a/dss1.cpp
+++ b/dss1.cpp
@@ -1120,7 +1120,7 @@ void Pdss1::disconnect_ind(unsigned long prim, unsigned long dinfo, void *data)
        if (cause < 0)
                cause = 16;
 
-       /* release if we are remote sends us no tones */
+       /* release if remote sends us no tones */
        if (!p_m_mISDNport->earlyb)
        {
                RELEASE_t *release;
index daa0992..7b8ce57 100644 (file)
--- a/message.c
+++ b/message.c
@@ -1,6 +1,6 @@
 /*****************************************************************************\
 **                                                                           **
-** PBX4Linux                                                                 **
+** Linux Call Route                                                          **
 **                                                                           **
 **---------------------------------------------------------------------------**
 ** Copyright: Andreas Eversberg                                              **
index 60ef972..38bb842 100644 (file)
--- a/todo.txt
+++ b/todo.txt
@@ -1,9 +1,5 @@
-BUG: release to NT not always work
-
 make asterisk call implementation
 
-avoid disconnect-collision (release if disconnect from both sides)
-
 display message during nothing/play
 
 Port -> Proc
index 48dcbab..9fde9fa 100644 (file)
--- a/vbox.cpp
+++ b/vbox.cpp
@@ -1,6 +1,6 @@
 /*****************************************************************************\
 **                                                                           **
-** PBX4Linux                                                                 **
+** Linux Call Router                                                         **
 **                                                                           **
 **---------------------------------------------------------------------------**
 ** Copyright: Andreas Eversberg                                              **
diff --git a/vbox.h b/vbox.h
index 3a7dc3a..074c54b 100644 (file)
--- a/vbox.h
+++ b/vbox.h
@@ -1,6 +1,6 @@
 /*****************************************************************************\
 **                                                                           **
-** PBX4Linux                                                                 **
+** Linux Call Router                                                         **
 **                                                                           **
 **---------------------------------------------------------------------------**
 ** Copyright: Andreas Eversberg                                              **