Fixed trace bugs.
authorAndreas Eversberg <andreas@eversberg.eu>
Sun, 14 Sep 2008 10:27:11 +0000 (12:27 +0200)
committerAndreas Eversberg <andreas@eversberg.eu>
Sun, 14 Sep 2008 10:27:11 +0000 (12:27 +0200)
modified:   README
modified:   interface.c
modified:   lcradmin.c
modified:   mISDN.cpp
modified:   main.c
modified:   socket_server.c
modified:   trace.c
modified:   vbox.cpp

README
interface.c
lcradmin.c
mISDN.cpp
main.c
socket_server.c
trace.c
vbox.cpp

diff --git a/README b/README
index ef5d669..1f3cde9 100644 (file)
--- a/README
+++ b/README
@@ -446,4 +446,5 @@ Changes in Version 1.1
 
 Fixes in current Version
 - Changed isdninfo to misdn_info.
+- Fixed some trace bugs.
 
index c70222c..2c92985 100644 (file)
@@ -1402,13 +1402,13 @@ void do_screen(int out, char *id, int idsize, int *type, int *present, struct in
                }
                if (ifmsn)
                {
-                       start_trace(0, interface, numberrize_callerinfo(id, *type, options.national, options.international), NULL, DIRECTION_IN, 0, 0, "SCREEN (found in MSN list)");
+                       start_trace(-1, interface, numberrize_callerinfo(id, *type, options.national, options.international), NULL, DIRECTION_IN, 0, 0, "SCREEN (found in MSN list)");
                        add_trace("msn", NULL, "%s", id);
                        end_trace();
                }
                if (!ifmsn && msn1) // not in list, first msn given
                {
-                       start_trace(0, interface, numberrize_callerinfo(id, *type, options.national, options.international), NULL, DIRECTION_IN, 0, 0, "SCREEN (not found in MSN list)");
+                       start_trace(-1, interface, numberrize_callerinfo(id, *type, options.national, options.international), NULL, DIRECTION_IN, 0, 0, "SCREEN (not found in MSN list)");
                        add_trace("msn", "given", "%s", id);
                        add_trace("msn", "used", "%s", msn1);
                        end_trace();
@@ -1441,7 +1441,7 @@ void do_screen(int out, char *id, int idsize, int *type, int *present, struct in
        }
        if (ifscreen) // match
        {
-               start_trace(0, interface, numberrize_callerinfo(id, *type, options.national, options.international), NULL, out?DIRECTION_OUT:DIRECTION_IN, 0, 0, "SCREEN (found in screen list)");
+               start_trace(-1, interface, numberrize_callerinfo(id, *type, options.national, options.international), NULL, out?DIRECTION_OUT:DIRECTION_IN, 0, 0, "SCREEN (found in screen list)");
                switch(*type)
                {
                        case INFO_NTYPE_UNKNOWN:
index 8cd40da..a63cb1c 100644 (file)
@@ -668,7 +668,10 @@ const char *admin_state(int sock, char *argv[])
                        color(white);
                        if (m[i].u.i.block >= 2)
                        {
-                               SPRINT(buffer, "%s (port %d: %s)%s", m[i].u.i.interface_name, m[i].u.i.portnum, m[i].u.i.portname, (m[i].u.i.extension)?" extension":"");
+                               if (m[i].u.i.portnum < 0)
+                                       SPRINT(buffer, "%s (port ?: %s)%s", m[i].u.i.interface_name, m[i].u.i.portname, (m[i].u.i.extension)?" extension":"");
+                               else
+                                       SPRINT(buffer, "%s (port %d: %s)%s", m[i].u.i.interface_name, m[i].u.i.portnum, m[i].u.i.portname, (m[i].u.i.extension)?" extension":"");
                                addstr(buffer);
                                color(red);
                                addstr("  not loaded");
@@ -1585,6 +1588,7 @@ const char *admin_trace(int sock, int argc, char *argv[])
        memset(&msg, 0, sizeof(msg));
        msg.message = ADMIN_TRACE_REQUEST;
        msg.u.trace_req.detail = 3;
+       msg.u.trace_req.port = -1;
 
        /* parse args */
        i = 2;
index 97f7b3e..0b4c8b0 100644 (file)
--- a/mISDN.cpp
+++ b/mISDN.cpp
@@ -1954,15 +1954,21 @@ int mISDN_handler(void)
                        switch(l3m->type)
                        {
                                case MPH_ACTIVATE_IND:
-                               l1l2l3_trace_header(mISDNport, NULL, L1_ACTIVATE_IND, DIRECTION_IN);
-                               end_trace();
-                               mISDNport->l1link = 1;
+                               if (mISDNport->l1link != 1)
+                               {
+                                       l1l2l3_trace_header(mISDNport, NULL, L1_ACTIVATE_IND, DIRECTION_IN);
+                                       end_trace();
+                                       mISDNport->l1link = 1;
+                               }
                                break;
        
                                case MPH_DEACTIVATE_IND:
-                               l1l2l3_trace_header(mISDNport, NULL, L1_DEACTIVATE_IND, DIRECTION_IN);
-                               end_trace();
-                               mISDNport->l1link = 0;
+                               if (mISDNport->l1link != 0)
+                               {
+                                       l1l2l3_trace_header(mISDNport, NULL, L1_DEACTIVATE_IND, DIRECTION_IN);
+                                       end_trace();
+                                       mISDNport->l1link = 0;
+                               }
                                break;
 
                                case MPH_INFORMATION_IND:
@@ -2160,7 +2166,7 @@ struct mISDNport *mISDNport_open(int port, char *portname, int ptp, int force_nt
                }
                if (port == cnt)
                {
-                       PERROR_RUNTIME("Port name '%s' no found, use 'misdn_info' tool to list all existing ports.\n", portname);
+                       PERROR_RUNTIME("Port name '%s' not found, use 'misdn_info' tool to list all existing ports.\n", portname);
                        return(NULL);
                }
                // note: 'port' has still the port number
diff --git a/main.c b/main.c
index 1f736fb..f63b9bf 100644 (file)
--- a/main.c
+++ b/main.c
@@ -445,7 +445,7 @@ int main(int argc, char *argv[])
 
        /*** main loop ***/
        SPRINT(tracetext, "%s %s started, waiting for calls...", NAME, VERSION_STRING);
-       start_trace(0, NULL, NULL, NULL, 0, 0, 0, tracetext);
+       start_trace(-1, NULL, NULL, NULL, 0, 0, 0, tracetext);
        printf("%s\n", tracetext);
        end_trace();
        GET_NOW();
@@ -635,7 +635,7 @@ BUDETECT
        }
        SPRINT(tracetext, "%s terminated", NAME);
        printf("%s\n", tracetext);
-       start_trace(0, NULL, NULL, NULL, 0, 0, 0, tracetext);
+       start_trace(-1, NULL, NULL, NULL, 0, 0, 0, tracetext);
        if (quit)
                add_trace((char *)"signal", NULL, "%d", quit);
        end_trace();
@@ -742,7 +742,7 @@ free:
        if (b) \
        { \
                SPRINT(tracetext, a, NAME); \
-               start_trace(0, NULL, NULL, NULL, 0, 0, 0, tracetext); \
+               start_trace(-1, NULL, NULL, NULL, 0, 0, 0, tracetext); \
                if (ret) add_trace("blocks", NULL, "%d", b); \
                end_trace(); \
                printf("\n******************************\n\007"); \
index 4b5a841..d4f8ae1 100644 (file)
@@ -91,7 +91,7 @@ void free_connection(struct admin_list *admin)
        /* free remote joins */
        if (admin->remote_name[0])
        {
-               start_trace(0,
+               start_trace(-1,
                        NULL,
                        NULL,
                        NULL,
@@ -298,7 +298,7 @@ int admin_route(struct admin_queue **responsep)
                        apppbx->e_callback = 0;
                        apppbx->e_action = NULL;
                        apppbx->release(RELEASE_ALL, LOCATION_PRIVATE_LOCAL, CAUSE_NORMAL, LOCATION_PRIVATE_LOCAL, CAUSE_NORMAL);
-                       start_trace(0,
+                       start_trace(-1,
                                NULL,
                                numberrize_callerinfo(apppbx->e_callerinfo.id, apppbx->e_callerinfo.ntype, options.national, options.international),
                                apppbx->e_dialinginfo.id,
@@ -646,7 +646,7 @@ int admin_message_to_join(struct admin_msg *msg, struct admin_list *admin)
                }
                /* set remote socket instance */
                SCPY(admin->remote_name, msg->param.hello.application);
-               start_trace(0,
+               start_trace(-1,
                        NULL,
                        NULL,
                        NULL,
diff --git a/trace.c b/trace.c
index 63ffb16..8242a7c 100644 (file)
--- a/trace.c
+++ b/trace.c
@@ -112,7 +112,7 @@ static char *print_trace(int detail, int port, char *interface, char *caller, ch
                return(NULL);
 
        /* filter trace */
-       if (port && trace.port)
+       if (port >= 0 && trace.port >= 0)
                if (port != trace.port) return(NULL);
        if (interface) if (interface[0] && trace.interface[0])
                if (!!strcasecmp(interface, trace.interface)) return(NULL);
@@ -128,7 +128,7 @@ static char *print_trace(int detail, int port, char *interface, char *caller, ch
        {
                SCAT(trace_string, "------------------------------------------------------------------------------\n");
                /* "Port: 1 (BRI PTMP TE)" */
-               if (trace.port)
+               if (trace.port >= 0)
                {
                        mISDNport = mISDNport_first;
                        while(mISDNport)
@@ -219,7 +219,7 @@ static char *print_trace(int detail, int port, char *interface, char *caller, ch
        switch(detail)
        {
                case 1: /* brief */
-               if (trace.port)
+               if (trace.port >= 0)
                {
                        SPRINT(buffer, "  port %d", trace.port);
                        SCAT(trace_string, buffer);
@@ -294,7 +294,7 @@ void _end_trace(const char *__file, int __line)
        
        if (options.deb || options.log[0])
        {
-               string = print_trace(1, 0, NULL, NULL, NULL, 0);
+               string = print_trace(1, -1, NULL, NULL, NULL, 0);
                if (string)
                {
                        /* process debug */
index fc9a265..158a113 100644 (file)
--- a/vbox.cpp
+++ b/vbox.cpp
@@ -48,7 +48,7 @@ VBoxPort::~VBoxPort()
 static void vbox_trace_header(class VBoxPort *vbox, const char *message, int direction)
 {
        /* init trace with given values */
-       start_trace(0,
+       start_trace(-1,
                    NULL,
                    vbox?numberrize_callerinfo(vbox->p_callerinfo.id, vbox->p_callerinfo.ntype, options.national, options.international):NULL,
                    vbox?vbox->p_dialinginfo.id:NULL,