error inside information elements are now reported inside trace and main log,
[lcr.git] / ie.cpp
diff --git a/ie.cpp b/ie.cpp
index 0a5f636..1c70514 100644 (file)
--- a/ie.cpp
+++ b/ie.cpp
@@ -38,10 +38,8 @@ void Pdss1::enc_ie_complete(unsigned char **ntmode, msg_t *msg, int complete)
        }
 
        if (complete)
-               printisdn("    complete=%d\n", complete);
-
-       if (complete)
        {
+               add_trace("complete", NULL, NULL);
                p = msg_put(msg, 1);
                if (p_m_d_ntmode)
                {
@@ -64,7 +62,7 @@ void Pdss1::dec_ie_complete(unsigned char *p, Q931_info_t *qi, int *complete)
                *complete = 1;
 
        if (*complete)
-               printisdn("    complete=%d\n", *complete);
+               add_trace("complete", NULL, NULL);
 }
 
 
@@ -111,7 +109,12 @@ void Pdss1::enc_ie_bearer(unsigned char **ntmode, msg_t *msg, int coding, int ca
                multi = -1;
        }
 
-       printisdn("    coding=%d capability=%d mode=%d rate=%d multi=%d user=%d\n", coding, capability, mode, rate, multi, user);
+       add_trace("bearer", "coding", "%d", coding);
+       add_trace("bearer", "capability", "%d", capability);
+       add_trace("bearer", "mode", "%d", mode);
+       add_trace("bearer", "rate", "%d", rate);
+       add_trace("bearer", "multi", "%d", multi);
+       add_trace("bearer", "user", "%d", user);
 
        l = 2 + (multi>=0) + (user>=0);
        p = msg_put(msg, l+2);
@@ -148,7 +151,7 @@ void Pdss1::dec_ie_bearer(unsigned char *p, Q931_info_t *qi, int *coding, int *c
                return;
        if (p[0] < 2)
        {
-               PERROR("IE too short (%d).\n", p[0]);
+               add_trace("bearer", "error", "IE too short (len=%d)", p[0]);
                return;
        }
 
@@ -170,7 +173,12 @@ void Pdss1::dec_ie_bearer(unsigned char *p, Q931_info_t *qi, int *coding, int *c
                        *user = p[3] & 0x1f;
        }
 
-       printisdn("    coding=%d capability=%d mode=%d rate=%d multi=%d user=%d\n", *coding, *capability, *mode, *rate, *multi, *user);
+       add_trace("bearer", "coding", "%d", *coding);
+       add_trace("bearer", "capability", "%d", *capability);
+       add_trace("bearer", "mode", "%d", *mode);
+       add_trace("bearer", "rate", "%d", *rate);
+       add_trace("bearer", "multi", "%d", *multi);
+       add_trace("bearer", "user", "%d", *user);
 }
 
 
@@ -207,7 +215,12 @@ void Pdss1::enc_ie_hlc(unsigned char **ntmode, msg_t *msg, int coding, int inter
                return;
        }
 
-       printisdn("    coding=%d interpretation=%d presentation=%d hlc=%d exthlc=%d\n", coding, interpretation, presentation, hlc, exthlc);
+       add_trace("hlc", "coding", "%d", coding);
+       add_trace("hlc", "interpretation", "%d", interpretation);
+       add_trace("hlc", "presentation", "%d", presentation);
+       add_trace("hlc", "hlc", "%d", hlc);
+       if (exthlc >= 0)
+               add_trace("hlc", "exthlc", "%d", exthlc);
 
        l = 2 + (exthlc>=0);
        p = msg_put(msg, l+2);
@@ -244,7 +257,7 @@ void Pdss1::dec_ie_hlc(unsigned char *p, Q931_info_t *qi, int *coding, int *inte
                return;
        if (p[0] < 2)
        {
-               PERROR("IE too short (%d).\n", p[0]);
+               add_trace("hlc", "error", "IE too short (len=%d)", p[0]);
                return;
        }
 
@@ -257,7 +270,12 @@ void Pdss1::dec_ie_hlc(unsigned char *p, Q931_info_t *qi, int *coding, int *inte
                *exthlc = p[3] & 0x7f;
        }
 
-       printisdn("    coding=%d interpretation=%d presentation=%d hlc=%d exthlc=%d\n", *coding, *interpretation, *presentation, *hlc, *exthlc);
+       add_trace("hlc", "coding", "%d", *coding);
+       add_trace("hlc", "interpretation", "%d", *interpretation);
+       add_trace("hlc", "presentation", "%d", *presentation);
+       add_trace("hlc", "hlc", "%d", *hlc);
+       if (*exthlc >= 0)
+               add_trace("hlc", "exthlc", "%d", *exthlc);
 }
 
 
@@ -268,14 +286,14 @@ void Pdss1::enc_ie_call_id(unsigned char **ntmode, msg_t *msg, unsigned char *ca
        Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
        int l;
 
-       char debug[25];
+       char buffer[25];
        int i;
 
        if (!callid || callid_len<=0)
        {
                return;
        }
-       if (callid_len>8)
+       if (callid_len > 8)
        {
                PERROR("callid_len(%d) is out of range.\n", callid_len);
                return;
@@ -284,11 +302,11 @@ void Pdss1::enc_ie_call_id(unsigned char **ntmode, msg_t *msg, unsigned char *ca
        i = 0;
        while(i < callid_len)
        {
-               UPRINT(debug+(i*3), " %02x", callid[i]);
+               UPRINT(buffer+(i*3), " %02x", callid[i]);
                i++;
        }
                
-       printisdn("    callid%s\n", debug);
+       add_trace("callid", NULL, "%s", buffer[0]?buffer+1:"<none>");
 
        l = callid_len;
        p = msg_put(msg, l+2);
@@ -303,7 +321,7 @@ void Pdss1::enc_ie_call_id(unsigned char **ntmode, msg_t *msg, unsigned char *ca
 
 void Pdss1::dec_ie_call_id(unsigned char *p, Q931_info_t *qi, unsigned char *callid, int *callid_len)
 {
-       char debug[25];
+       char buffer[25];
        int i;
 
        *callid_len = -1;
@@ -318,7 +336,7 @@ void Pdss1::dec_ie_call_id(unsigned char *p, Q931_info_t *qi, unsigned char *cal
                return;
        if (p[0] > 8)
        {
-               PERROR("IE too long (%d).\n", p[0]);
+               add_trace("callid", "error", "IE too long (len=%d)", p[0]);
                return;
        }
 
@@ -328,11 +346,11 @@ void Pdss1::dec_ie_call_id(unsigned char *p, Q931_info_t *qi, unsigned char *cal
        i = 0;
        while(i < *callid_len)
        {
-               UPRINT(debug+(i*3), " %02x", callid[i]);
+               UPRINT(buffer+(i*3), " %02x", callid[i]);
                i++;
        }
                
-       printisdn("    callid%s\n", debug);
+       add_trace("callid", NULL, "%s", buffer[0]?buffer+1:"<none>");
 }
 
 
@@ -359,7 +377,9 @@ void Pdss1::enc_ie_called_pn(unsigned char **ntmode, msg_t *msg, int type, int p
                return;
        }
 
-       printisdn("    type=%d plan=%d number='%s'\n", type, plan, number);
+       add_trace("called_pn", "type", "%d", type);
+       add_trace("called_pn", "plan", "%d", plan);
+       add_trace("called_pn", "number", "%s", number);
 
        l = 1+strlen((char *)number);
        p = msg_put(msg, l+2);
@@ -389,7 +409,7 @@ void Pdss1::dec_ie_called_pn(unsigned char *p, Q931_info_t *qi, int *type, int *
                return;
        if (p[0] < 2)
        {
-               PERROR("IE too short (%d).\n", p[0]);
+               add_trace("called_pn", "error", "IE too short (len=%d)", p[0]);
                return;
        }
 
@@ -397,7 +417,9 @@ void Pdss1::dec_ie_called_pn(unsigned char *p, Q931_info_t *qi, int *type, int *
        *plan = p[1] & 0xf;
        strnncpy(number, p+2, p[0]-1, number_len);
 
-       printisdn("    type=%d plan=%d number='%s'\n", *type, *plan, number);
+       add_trace("called_pn", "type", "%d", *type);
+       add_trace("called_pn", "plan", "%d", *plan);
+       add_trace("called_pn", "number", "%s", number);
 }
 
 
@@ -429,7 +451,11 @@ void Pdss1::enc_ie_calling_pn(unsigned char **ntmode, msg_t *msg, int type, int
                return;
        }
 
-       printisdn("    type=%d plan=%d present=%d screen=%d number='%s'\n", type, plan, present, screen, number);
+       add_trace("calling_pn", "type", "%d", type);
+       add_trace("calling_pn", "plan", "%d", plan);
+       add_trace("calling_pn", "present", "%d", present);
+       add_trace("calling_pn", "screen", "%d", screen);
+       add_trace("calling_pn", "number", "%s", number);
 
        l = 1;
        if (number) if (number[0])
@@ -475,7 +501,7 @@ void Pdss1::dec_ie_calling_pn(unsigned char *p, Q931_info_t *qi, int *type, int
                return;
        if (p[0] < 1)
        {
-               PERROR("IE too short (%d).\n", p[0]);
+               add_trace("calling_pn", "error", "IE too short (len=%d)", p[0]);
                return;
        }
 
@@ -485,7 +511,7 @@ void Pdss1::dec_ie_calling_pn(unsigned char *p, Q931_info_t *qi, int *type, int
        {
                if (p[0] < 2)
                {
-                       PERROR("IE too short (%d).\n", p[0]);
+                       add_trace("calling_pn", "error", "IE too short (len=%d)", p[0]);
                        return;
                }
                *present = (p[2]&0x60) >> 5;
@@ -496,7 +522,11 @@ void Pdss1::dec_ie_calling_pn(unsigned char *p, Q931_info_t *qi, int *type, int
                strnncpy(number, p+2, p[0]-1, number_len);
        }
 
-       printisdn("    type=%d plan=%d present=%d screen=%d number='%s'\n", *type, *plan, *present, *screen, number);
+       add_trace("calling_pn", "type", "%d", *type);
+       add_trace("calling_pn", "plan", "%d", *plan);
+       add_trace("calling_pn", "present", "%d", *present);
+       add_trace("calling_pn", "screen", "%d", *screen);
+       add_trace("calling_pn", "number", "%s", number);
 }
 
 
@@ -528,7 +558,11 @@ void Pdss1::enc_ie_connected_pn(unsigned char **ntmode, msg_t *msg, int type, in
                return;
        }
 
-       printisdn("    type=%d plan=%d present=%d screen=%d number='%s'\n", type, plan, present, screen, number);
+       add_trace("connect_pn", "type", "%d", type);
+       add_trace("connect_pn", "plan", "%d", plan);
+       add_trace("connect_pn", "present", "%d", present);
+       add_trace("connect_pn", "screen", "%d", screen);
+       add_trace("connect_pn", "number", "%s", number);
 
        l = 1;
        if (number) if (number[0])
@@ -574,7 +608,7 @@ void Pdss1::dec_ie_connected_pn(unsigned char *p, Q931_info_t *qi, int *type, in
                return;
        if (p[0] < 1)
        {
-               PERROR("IE too short (%d).\n", p[0]);
+               add_trace("connect_pn", "error", "IE too short (len=%d)", p[0]);
                return;
        }
 
@@ -584,7 +618,7 @@ void Pdss1::dec_ie_connected_pn(unsigned char *p, Q931_info_t *qi, int *type, in
        {
                if (p[0] < 2)
                {
-                       PERROR("IE too short (%d).\n", p[0]);
+                       add_trace("connect_pn", "error", "IE too short (len=%d)", p[0]);
                        return;
                }
                *present = (p[2]&0x60) >> 5;
@@ -595,7 +629,11 @@ void Pdss1::dec_ie_connected_pn(unsigned char *p, Q931_info_t *qi, int *type, in
                strnncpy(number, p+2, p[0]-1, number_len);
        }
 
-       printisdn("    type=%d plan=%d present=%d screen=%d number='%s'\n", *type, *plan, *present, *screen, number);
+       add_trace("connect_pn", "type", "%d", *type);
+       add_trace("connect_pn", "plan", "%d", *plan);
+       add_trace("connect_pn", "present", "%d", *present);
+       add_trace("connect_pn", "screen", "%d", *screen);
+       add_trace("connect_pn", "number", "%s", number);
 }
 
 
@@ -617,7 +655,8 @@ void Pdss1::enc_ie_cause(unsigned char **ntmode, msg_t *msg, int location, int c
                return;
        }
 
-       printisdn("    location=%d cause=%d\n", location, cause);
+       add_trace("cause", "location", "%d", location);
+       add_trace("cause", "value", "%d", cause);
 
        l = 2;
        p = msg_put(msg, l+2);
@@ -660,14 +699,15 @@ void Pdss1::dec_ie_cause(unsigned char *p, Q931_info_t *qi, int *location, int *
                return;
        if (p[0] < 2)
        {
-               PERROR("IE too short (%d).\n", p[0]);
+               add_trace("cause", "error", "IE too short (len=%d)", p[0]);
                return;
        }
 
        *location = p[1] & 0x0f;
        *cause = p[2] & 0x7f;
 
-       printisdn("    location=%d cause=%d\n", *location, *cause);
+       add_trace("cause", "location", "%d", *location);
+       add_trace("cause", "value", "%d", *cause);
 }
 
 
@@ -693,7 +733,18 @@ void Pdss1::enc_ie_channel_id(unsigned char **ntmode, msg_t *msg, int exclusive,
                return;
        }
 
-       printisdn("    exclusive=%d channel=%d\n", exclusive, channel);
+       add_trace("channel_id", "exclusive", "%d", exclusive);
+       switch(channel)
+       {
+               case CHANNEL_ANY:
+               add_trace("channel_id", "channel", "any channel");
+               break;
+               case CHANNEL_NO:
+               add_trace("channel_id", "channel", "no channel");
+               break;
+               default:
+               add_trace("channel_id", "channel", "%d", channel);
+       }
 
        if (!pri)
        {
@@ -760,18 +811,18 @@ void Pdss1::dec_ie_channel_id(unsigned char *p, Q931_info_t *qi, int *exclusive,
                return;
        if (p[0] < 1)
        {
-               PERROR("IE too short (%d).\n", p[0]);
+               add_trace("channel_id", "error", "IE too short (len=%d)", p[0]);
                return;
        }
 
        if (p[1] & 0x40)
        {
-               PERROR("refering to channels of other interfaces is not supported.\n");
+               add_trace("channel_id", "error", "refering to channels of other interfaces is not supported");
                return;
        }
        if (p[1] & 0x04)
        {
-               PERROR("using d-channel is not supported.\n");
+               add_trace("channel_id", "error", "using d-channel is not supported");
                return;
        }
 
@@ -781,7 +832,7 @@ void Pdss1::dec_ie_channel_id(unsigned char *p, Q931_info_t *qi, int *exclusive,
                /* BRI */
                if (p[1] & 0x20)
                {
-                       PERROR("extended channel ID with non PRI interface.\n");
+                       add_trace("channel_id", "error", "extended channel ID with non PRI interface");
                        return;
                }
                *channel = p[1] & 0x03;
@@ -794,12 +845,13 @@ void Pdss1::dec_ie_channel_id(unsigned char *p, Q931_info_t *qi, int *exclusive,
                /* PRI */
                if (p[0] < 1)
                {
-                       PERROR("IE too short for PRI (%d).\n", p[0]);
+
+                       add_trace("channel_id", "error", "IE too short for PRI (len=%d)", p[0]);
                        return;
                }
                if (!(p[1] & 0x20))
                {
-                       PERROR("basic channel ID with PRI interface.\n");
+                       add_trace("channel_id", "error", "basic channel ID with PRI interface");
                        return;
                }
                if ((p[1]&0x03) == 0x00)
@@ -816,23 +868,34 @@ void Pdss1::dec_ie_channel_id(unsigned char *p, Q931_info_t *qi, int *exclusive,
                }
                if (p[0] < 3)
                {
-                       PERROR("%s: ERROR: IE too short for PRI with channel(%d).\n", __FUNCTION__, p[0]);
+                       add_trace("channel_id", "error", "IE too short for PRI with channel (len=%d)", p[0]);
                        return;
                }
                if (p[2] & 0x10)
                {
-                       PERROR("channel map not supported.\n");
+                       add_trace("channel_id", "error", "channel map not supported");
                        return;
                }
                *channel = p[3] & 0x7f;
                if (*channel<1 | *channel==16)
                {
-                       PERROR("PRI interface channel out of range (%d).\n", *channel);
+                       add_trace("channel_id", "error", "PRI interface channel out of range (%d)", *channel);
                        return;
                }
        }
 
-       printisdn("    exclusive=%d channel=%d\n", *exclusive, *channel);
+       add_trace("channel_id", "exclusive", "%d", *exclusive);
+       switch(*channel)
+       {
+               case CHANNEL_ANY:
+               add_trace("channel_id", "channel", "any channel");
+               break;
+               case CHANNEL_NO:
+               add_trace("channel_id", "channel", "no channel");
+               break;
+               default:
+               add_trace("channel_id", "channel", "%d", *channel);
+       }
 }
 
 
@@ -852,7 +915,8 @@ void Pdss1::enc_ie_date(unsigned char **ntmode, msg_t *msg, time_t ti, int no_se
                return;
        }
 
-       printisdn("    year=%d month=%d day=%d hour=%d minute=%d second=%d\n", tm->tm_year%100, tm->tm_mon+1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec);
+       add_trace("date", "day", "%d.%d.%d", tm->tm_mday, tm->tm_mon+1, tm->tm_year%100);
+       add_trace("date", "time", "%d:%d:%d", tm->tm_hour, tm->tm_min, tm->tm_sec);
 
        l = 5 + (!no_seconds);
        p = msg_put(msg, l+2);
@@ -891,7 +955,7 @@ void Pdss1::enc_ie_display(unsigned char **ntmode, msg_t *msg, unsigned char *di
                display[80] = '\0';
        }
 
-       printisdn("    display='%s' (len=%d)\n", display, strlen((char *)display));
+       add_trace("display", NULL, "%s", display);
 
        l = strlen((char *)display);
        p = msg_put(msg, l+2);
@@ -918,13 +982,13 @@ void Pdss1::dec_ie_display(unsigned char *p, Q931_info_t *qi, unsigned char *dis
                return;
        if (p[0] < 1)
        {
-               PERROR("IE too short (%d).\n", p[0]);
+               add_trace("display", "error", "IE too short (len=%d)", p[0]);
                return;
        }
 
        strnncpy(display, p+1, p[0], display_len);
 
-       printisdn("    display='%s'\n", display);
+       add_trace("display", NULL, "%s", display);
 }
 
 
@@ -941,7 +1005,7 @@ void Pdss1::enc_ie_keypad(unsigned char **ntmode, msg_t *msg, unsigned char *key
                return;
        }
 
-       printisdn("    keypad='%s'\n", keypad);
+       add_trace("keypad", NULL, "%s", keypad);
 
        l = strlen((char *)keypad);
        p = msg_put(msg, l+2);
@@ -968,13 +1032,13 @@ void Pdss1::dec_ie_keypad(unsigned char *p, Q931_info_t *qi, unsigned char *keyp
                return;
        if (p[0] < 1)
        {
-               PERROR("IE too short (%d).\n", p[0]);
+               add_trace("keypad", "error", "IE too short (len=%d)", p[0]);
                return;
        }
 
        strnncpy(keypad, p+1, p[0], keypad_len);
 
-       printisdn("    keypad='%s'\n", keypad);
+       add_trace("keypad", NULL, "%s", keypad);
 }
 
 
@@ -991,7 +1055,7 @@ void Pdss1::enc_ie_notify(unsigned char **ntmode, msg_t *msg, int notify)
                return;
        }
 
-       printisdn("    notify=%d\n", notify);
+       add_trace("notify", NULL, "%d", notify);
 
        l = 1;
        p = msg_put(msg, l+2);
@@ -1018,13 +1082,13 @@ void Pdss1::dec_ie_notify(unsigned char *p, Q931_info_t *qi, int *notify)
                return;
        if (p[0] < 1)
        {
-               PERROR("IE too short (%d).\n", p[0]);
+               add_trace("notify", "error", "IE too short (len=%d)", p[0]);
                return;
        }
 
        *notify = p[1] & 0x7f;
 
-       printisdn("    notify=%d\n", *notify);
+       add_trace("notify", NULL, "%d", *notify);
 }
 
 
@@ -1051,7 +1115,9 @@ void Pdss1::enc_ie_progress(unsigned char **ntmode, msg_t *msg, int coding, int
                return;
        }
 
-       printisdn("    coding=%d location=%d progress=%d\n", coding, location, progress);
+       add_trace("progress", "codeing", "%d", coding);
+       add_trace("progress", "location", "%d", location);
+       add_trace("progress", "indicator", "%d", progress);
 
        l = 2;
        p = msg_put(msg, l+2);
@@ -1081,7 +1147,7 @@ void Pdss1::dec_ie_progress(unsigned char *p, Q931_info_t *qi, int *coding, int
                return;
        if (p[0] < 1)
        {
-               PERROR("IE too short (%d).\n", p[0]);
+               add_trace("progress", "error", "IE too short (len=%d)", p[0]);
                return;
        }
 
@@ -1089,7 +1155,9 @@ void Pdss1::dec_ie_progress(unsigned char *p, Q931_info_t *qi, int *coding, int
        *location = p[1] & 0x0f;
        *progress = p[2] & 0x7f;
 
-       printisdn("    coding=%d location=%d progress=%d\n", *coding, *location, *progress);
+       add_trace("progress", "codeing", "%d", *coding);
+       add_trace("progress", "location", "%d", *location);
+       add_trace("progress", "indicator", "%d", *progress);
 }
 
 
@@ -1126,7 +1194,12 @@ void Pdss1::enc_ie_redir_nr(unsigned char **ntmode, msg_t *msg, int type, int pl
                return;
        }
 
-       printisdn("    type=%d plan=%d present=%d screen=%d readon=%d number='%s'\n", type, plan, present, screen, reason, number);
+       add_trace("redir'ing", "type", "%d", type);
+       add_trace("redir'ing", "plan", "%d", plan);
+       add_trace("redir'ing", "present", "%d", present);
+       add_trace("redir'ing", "screen", "%d", screen);
+       add_trace("redir'ing", "reason", "%d", reason);
+       add_trace("redir'ing", "number", "%s", number);
 
        l = 1;
        if (number)
@@ -1187,7 +1260,7 @@ void Pdss1::dec_ie_redir_nr(unsigned char *p, Q931_info_t *qi, int *type, int *p
                return;
        if (p[0] < 1)
        {
-               PERROR("IE too short (%d).\n", p[0]);
+               add_trace("redir'ing", "error", "IE too short (len=%d)", p[0]);
                return;
        }
 
@@ -1210,7 +1283,12 @@ void Pdss1::dec_ie_redir_nr(unsigned char *p, Q931_info_t *qi, int *type, int *p
                strnncpy(number, p+2, p[0]-1, number_len);
        }
 
-       printisdn("    type=%d plan=%d present=%d screen=%d reason=%d number='%s'\n", *type, *plan, *present, *screen, *reason, number);
+       add_trace("redir'ing", "type", "%d", *type);
+       add_trace("redir'ing", "plan", "%d", *plan);
+       add_trace("redir'ing", "present", "%d", *present);
+       add_trace("redir'ing", "screen", "%d", *screen);
+       add_trace("redir'ing", "reason", "%d", *reason);
+       add_trace("redir'ing", "number", "%s", number);
 }
 
 
@@ -1237,7 +1315,10 @@ void Pdss1::enc_ie_redir_dn(unsigned char **ntmode, msg_t *msg, int type, int pl
                return;
        }
 
-       printisdn("    type=%d plan=%d present=%d number='%s'\n", type, plan, present, number);
+       add_trace("redir'tion", "type", "%d", type);
+       add_trace("redir'tion", "plan", "%d", plan);
+       add_trace("redir'tion", "present", "%d", present);
+       add_trace("redir'tion", "number", "%s", number);
 
        l = 1;
        if (number)
@@ -1282,7 +1363,7 @@ void Pdss1::dec_ie_redir_dn(unsigned char *p, Q931_info_t *qi, int *type, int *p
                return;
        if (p[0] < 1)
        {
-               PERROR("IE too short (%d).\n", p[0]);
+               add_trace("redir'tion", "error", "IE too short (len=%d)", p[0]);
                return;
        }
 
@@ -1297,7 +1378,10 @@ void Pdss1::dec_ie_redir_dn(unsigned char *p, Q931_info_t *qi, int *type, int *p
                strnncpy(number, p+2, p[0]-1, number_len);
        }
 
-       printisdn("    type=%d plan=%d present=%d number='%s'\n", *type, *plan, *present, number);
+       add_trace("redir'tion", "type", "%d", *type);
+       add_trace("redir'tion", "plan", "%d", *plan);
+       add_trace("redir'tion", "present", "%d", *present);
+       add_trace("redir'tion", "number", "%s", number);
 }
 
 
@@ -1308,7 +1392,7 @@ void Pdss1::enc_ie_facility(unsigned char **ntmode, msg_t *msg, unsigned char *f
        Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
        int l;
 
-       char debug[768];
+       char buffer[768];
        int i;
 
        if (!facility || facility_len<=0)
@@ -1319,11 +1403,11 @@ void Pdss1::enc_ie_facility(unsigned char **ntmode, msg_t *msg, unsigned char *f
        i = 0;
        while(i < facility_len)
        {
-               UPRINT(debug+(i*3), " %02x", facility[i]);
+               UPRINT(buffer+(i*3), " %02x", facility[i]);
                i++;
        }
                
-       printisdn("    facility%s\n", debug);
+       add_trace("facility", NULL, "%s", buffer+1);
 
        l = facility_len;
        p = msg_put(msg, l+2);
@@ -1363,62 +1447,10 @@ void Pdss1::dec_ie_facility(unsigned char *p, Q931_info_t *qi, unsigned char *fa
        }
        debug[i*3] = '\0';
                
-       printisdn("    facility%s\n", debug);
+       add_trace("facility", NULL, "%s", debug[0]?debug+1:"<none>");
 }
 
 
-/* facility for siemens CENTEX (known parts implemented only) */
-void Pdss1::enc_facility_centrex(unsigned char **ntmode, msg_t *msg, unsigned char *cnip, int setup)
-{
-       unsigned char centrex[256];
-       int i = 0;
-
-       if (!cnip)
-               return;
-
-       /* centrex facility */
-       centrex[i++] = CENTREX_FAC;
-       centrex[i++] = CENTREX_ID;
-
-       /* cnip */
-       if (strlen((char *)cnip) > 15)
-       {
-               PDEBUG(DEBUG_PORT, "%s: CNIP/CONP text too long (max 13 chars), cutting.\n");
-               cnip[15] = '\0';
-       }
-       // dunno what the 8 bytes mean
-       if (setup)
-       {
-               centrex[i++] = 0x17;
-               centrex[i++] = 0x02;
-               centrex[i++] = 0x02;
-               centrex[i++] = 0x44;
-               centrex[i++] = 0x18;
-               centrex[i++] = 0x02;
-               centrex[i++] = 0x01;
-               centrex[i++] = 0x09;
-       } else
-       {
-               centrex[i++] = 0x18;
-               centrex[i++] = 0x02;
-               centrex[i++] = 0x02;
-               centrex[i++] = 0x81;
-               centrex[i++] = 0x09;
-               centrex[i++] = 0x02;
-               centrex[i++] = 0x01;
-               centrex[i++] = 0x0a;
-       }
-
-       centrex[i++] = 0x80;
-       centrex[i++] = strlen((char *)cnip);
-       UCPY((char *)(&centrex[i]), (char *)cnip);
-       i += strlen((char *)cnip);
-       printisdn("    cnip='%s'\n", cnip);
-
-       /* encode facility */
-       enc_ie_facility(ntmode, msg, centrex, i);
-}
-
 void Pdss1::dec_facility_centrex(unsigned char *p, Q931_info_t *qi, unsigned char *cnip, int cnip_len)
 {
        unsigned char centrex[256];
@@ -1448,7 +1480,7 @@ void Pdss1::dec_facility_centrex(unsigned char *p, Q931_info_t *qi, unsigned cha
                {
                        case 0x80:
                        strnncpy(cnip, &centrex[i+2], centrex[i+1], cnip_len);
-                       printisdn("    CENTREX cnip='%s'\n", cnip);
+                       add_trace("facility", "cnip", "%s", cnip);
                        break;
 
                        default:
@@ -1458,7 +1490,7 @@ void Pdss1::dec_facility_centrex(unsigned char *p, Q931_info_t *qi, unsigned cha
                                UPRINT(debug+(j*3), " %02x", centrex[i+1+j]);
                                i++;
                        }
-                       printisdn("    CENTREX unknown=0x%2x len=%d%s\n", centrex[i], centrex[i+1], debug);
+                       add_trace("facility", "CENTREX", "unknown=0x%02x len=%d%s\n", centrex[i], centrex[i+1], debug);
                }
                i += 1+centrex[i+1];
        }
@@ -1472,7 +1504,7 @@ void Pdss1::enc_ie_useruser(unsigned char **ntmode, msg_t *msg, int protocol, un
        Q931_info_t *qi = (Q931_info_t *)(msg->data + mISDN_HEADER_LEN);
        int l;
 
-       char debug[768];
+       char buffer[768];
        int i;
 
        if (protocol<0 || protocol>127)
@@ -1488,11 +1520,12 @@ void Pdss1::enc_ie_useruser(unsigned char **ntmode, msg_t *msg, int protocol, un
        i = 0;
        while(i < user_len)
        {
-               UPRINT(debug+(i*3), " %02x", user[i]);
+               UPRINT(buffer+(i*3), " %02x", user[i]);
                i++;
        }
                
-       printisdn("    protocol=%d user-user%s\n", protocol, debug);
+       add_trace("useruser", "protocol", "%d", protocol);
+       add_trace("useruser", "value", "%s", buffer);
 
        l = user_len;
        p = msg_put(msg, l+3);
@@ -1508,7 +1541,7 @@ void Pdss1::enc_ie_useruser(unsigned char **ntmode, msg_t *msg, int protocol, un
 
 void Pdss1::dec_ie_useruser(unsigned char *p, Q931_info_t *qi, int *protocol, unsigned char *user, int *user_len)
 {
-       char debug[768];
+       char buffer[768];
        int i;
 
        *user_len = 0;
@@ -1532,12 +1565,13 @@ void Pdss1::dec_ie_useruser(unsigned char *p, Q931_info_t *qi, int *protocol, un
        i = 0;
        while(i < *user_len)
        {
-               UPRINT(debug+(i*3), " %02x", user[i]);
+               UPRINT(buffer+(i*3), " %02x", user[i]);
                i++;
        }
-       debug[i*3] = '\0';
+       buffer[i*3] = '\0';
                
-       printisdn("    protocol=%d user-user%s\n", *protocol, debug);
+       add_trace("useruser", "protocol", "%d", *protocol);
+       add_trace("useruser", "value", "%s", buffer);
 }