summaryrefslogtreecommitdiffstats
path: root/usr.sbin/i4b/isdntrace
diff options
context:
space:
mode:
authorhm <hm@FreeBSD.org>2000-10-09 14:22:51 +0000
committerhm <hm@FreeBSD.org>2000-10-09 14:22:51 +0000
commit5ab5e2a391ce47dd5453a8592c99baf8e9b2a6f4 (patch)
tree26a8d414a4a8b7be8fb22e1e65e5ba4889daf0ae /usr.sbin/i4b/isdntrace
parentf334879ea56c48ab237e6528968d81dd32e9f209 (diff)
downloadFreeBSD-src-5ab5e2a391ce47dd5453a8592c99baf8e9b2a6f4.zip
FreeBSD-src-5ab5e2a391ce47dd5453a8592c99baf8e9b2a6f4.tar.gz
update to i4b version 0.95.04
Diffstat (limited to 'usr.sbin/i4b/isdntrace')
-rw-r--r--usr.sbin/i4b/isdntrace/Makefile2
-rw-r--r--usr.sbin/i4b/isdntrace/isdntrace.845
-rw-r--r--usr.sbin/i4b/isdntrace/q931.c33
-rw-r--r--usr.sbin/i4b/isdntrace/q931_util.c354
-rw-r--r--usr.sbin/i4b/isdntrace/q932_fac.c314
-rw-r--r--usr.sbin/i4b/isdntrace/q932_fac.h10
-rw-r--r--usr.sbin/i4b/isdntrace/trace.c148
-rw-r--r--usr.sbin/i4b/isdntrace/trace.h12
-rw-r--r--usr.sbin/i4b/isdntrace/unknownl3.c106
9 files changed, 932 insertions, 92 deletions
diff --git a/usr.sbin/i4b/isdntrace/Makefile b/usr.sbin/i4b/isdntrace/Makefile
index 0596e5b..3f68001 100644
--- a/usr.sbin/i4b/isdntrace/Makefile
+++ b/usr.sbin/i4b/isdntrace/Makefile
@@ -1,7 +1,7 @@
# $FreeBSD$
PROG = isdntrace
SRCS = q921.c q931.c q931_util.c q932_fac.c 1tr6.c trace.c \
- pcause_1tr6.c pcause_q850.c
+ pcause_1tr6.c pcause_q850.c unknownl3.c
#CFLAGS += -Wall -g
MAN8 = isdntrace.8
diff --git a/usr.sbin/i4b/isdntrace/isdntrace.8 b/usr.sbin/i4b/isdntrace/isdntrace.8
index d6eca42..e696eea 100644
--- a/usr.sbin/i4b/isdntrace/isdntrace.8
+++ b/usr.sbin/i4b/isdntrace/isdntrace.8
@@ -1,5 +1,5 @@
.\"
-.\" Copyright (c) 1997, 1999 Hellmuth Michaelis. All rights reserved.
+.\" Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
@@ -22,13 +22,13 @@
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
-.\" $Id: isdntrace.8,v 1.12 1999/12/13 22:11:55 hm Exp $
+.\" $Id: isdntrace.8,v 1.14 2000/02/13 15:26:52 hm Exp $
.\"
.\" $FreeBSD$
.\"
-.\" last edit-date: [Mon Dec 13 23:08:17 1999]
+.\" last edit-date: [Sun Feb 13 14:38:42 2000]
.\"
-.Dd October 19, 1998
+.Dd February, 13, 2000
.Dt ISDNTRACE 8
.Os
.Sh NAME
@@ -48,6 +48,7 @@
.Op Fl p Ar filename
.Op Fl r
.Op Fl u Ar number
+.Op Fl x
.Op Fl B
.Op Fl F
.Op Fl P
@@ -67,6 +68,18 @@ The
.Nm
utility is only available for passive supported cards.
.Pp
+.Em Note
+.br
+All filenames, user specified or default, get a date and time stamp string
+added in the form -yymmdd-hhmmss: a hyphen, two digits year, month, day,
+a hyphen and two digits hour, minutes and seconds.
+Tracefiles no longer get overwritten.
+In case a new filename is needed within a second, the filename-generating
+mechanism sleeps one second.
+.br
+In case the program is sent a USR1 signal, a new user specified or default
+filename with a new date and timestamp is generated and opened.
+.Pp
The following options can be used:
.Bl -tag -width Ds
.It Fl a
@@ -75,11 +88,9 @@ Run
in analyzer mode by using two passive cards and a custom cable which can
be build as described in the file
.Em cable.txt
-in the isdn4bsd source distribution.
-One card acts as a receiver for the
+in the isdn4bsd source distribution. One card acts as a receiver for the
transmitting direction on the S0 bus while the other card acts as a receiver
-for the receiving direction on the S0 bus.
-Complete traffic monitoring is
+for the receiving direction on the S0 bus. Complete traffic monitoring is
possible using this setup.
.It Fl b
switch B channel tracing on (default off).
@@ -98,8 +109,7 @@ print layer 1 (I.430) INFO signals to monitor layer 1 activity (default off).
switch displaying of Layer 2 (Q.921) frames off (default on).
.It Fl n
This option takes a numeric argument specifying the minimum
-frame size in octetts a frame must have to be displayed.
-(default 0)
+frame size in octetts a frame must have to be displayed. (default 0)
.It Fl o
switch off writing trace output to a file (default on).
.It Fl p
@@ -114,13 +124,15 @@ the decoded protocol information (default on).
Use
.Ar number
as the unit number of the controller card to trace (default 0).
+.It Fl x
+Switch on printing of packets with a non-Q.931 protocol discriminator.
+(default off).
.It Fl B
Write undecoded binary trace data to a file for later or remote
analyzing (default off).
.It Fl F
This option can only be used when option -P (playback from binary data file)
-is used.
-The -F option causes playback not to stop at end of file but rather
+is used. The -F option causes playback not to stop at end of file but rather
to wait for additional data to be available from the input file.
.Pp
This option is useful when trace data is accumulated in binary format (to
@@ -143,8 +155,7 @@ When the USR1 signal is sent to a
process, the currently used logfiles are reopened, so that logfile
rotation becomes possible.
.Pp
-The trace output should be obvious.
-It is very handy to have the following
+The trace output should be obvious. It is very handy to have the following
standard texts available when tracing ISDN protocols:
.Pp
.Bl -tag -width Ds -compact -offset indent
@@ -155,8 +166,7 @@ ISDN D-channel layer 2 protocol description.
.It Ar Q.931
ISDN D-channel layer 3 protocol description.
.It Ar 1TR6
-German-specific ISDN layer 3 protocol description.
-(NOTICE: decoding
+German-specific ISDN layer 3 protocol description. (NOTICE: decoding
of the 1TR6 protocol is included but not supported since i dont have
any longer access to a 1TR6 based ISDN installation.)
.El
@@ -183,7 +193,8 @@ isdntrace -f /var/tmp/isdn.trace
.Pp
will start D channel tracing on passive controller 0 with all except B
channel tracing enabled and logs everything into the output file
-/tmp/isdn.trace.
+/var/tmp/isdn.trace-yymmdd-hhmmss (where yymmdd and hhmmss are replaced
+by the current date and time values).
.Sh SEE ALSO
.Xr isdnd 8
diff --git a/usr.sbin/i4b/isdntrace/q931.c b/usr.sbin/i4b/isdntrace/q931.c
index d61ec9a..781c695 100644
--- a/usr.sbin/i4b/isdntrace/q931.c
+++ b/usr.sbin/i4b/isdntrace/q931.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 1999 Hellmuth Michaelis. All rights reserved.
+ * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,11 +27,11 @@
* q931.c - print Q.931 traces
* ---------------------------
*
- * $Id: q931.c,v 1.6 1999/12/13 21:25:26 hm Exp $
+ * $Id: q931.c,v 1.10 2000/02/14 16:25:22 hm Exp $
*
* $FreeBSD$
*
- * last edit-date: [Mon Dec 13 21:56:56 1999]
+ * last edit-date: [Mon Feb 14 14:51:13 2000]
*
*---------------------------------------------------------------------------*/
@@ -59,7 +59,6 @@ decode_q931(char *pbuf, int n, int off, unsigned char *buf, int raw)
if(raw)
{
-
for (i = 0; i < n; i += 16)
{
sprintf((pbuf+strlen(pbuf)),"Dump:%.3d ", i+off);
@@ -87,17 +86,17 @@ decode_q931(char *pbuf, int n, int off, unsigned char *buf, int raw)
pd = buf[i];
if(pd >= 0x00 && pd <= 0x07)
- sprintf((pbuf+strlen(pbuf)), "pd=User-User (0x%02x), ",pd);
+ sprintf((pbuf+strlen(pbuf)), "pd=User-User (0x%02x)\n",pd);
else if(pd == 0x08)
sprintf((pbuf+strlen(pbuf)), "pd=Q.931/I.451, ");
else if(pd >= 0x10 && pd <= 0x3f)
- sprintf((pbuf+strlen(pbuf)), "pd=Other Layer 3 or X.25 (0x%02x), ",pd);
+ sprintf((pbuf+strlen(pbuf)), "pd=Other Layer 3 or X.25 (0x%02x)\n",pd);
else if(pd >= 0x40 && pd <= 0x4f)
- sprintf((pbuf+strlen(pbuf)), "pd=National Use (0x%02x), ",pd);
+ sprintf((pbuf+strlen(pbuf)), "pd=National Use (0x%02x)\n",pd);
else if(pd >= 0x50 && pd <= 0xfe)
- sprintf((pbuf+strlen(pbuf)), "pd=Other Layer 3 or X.25 (0x%02x), ",pd);
+ sprintf((pbuf+strlen(pbuf)), "pd=Other Layer 3 or X.25 (0x%02x)\n",pd);
else
- sprintf((pbuf+strlen(pbuf)), "pd=Reserved (0x%02x), ",pd);
+ sprintf((pbuf+strlen(pbuf)), "pd=Reserved (0x%02x)\n",pd);
/* call reference */
@@ -119,7 +118,7 @@ decode_q931(char *pbuf, int n, int off, unsigned char *buf, int raw)
}
i += (len+1);
-
+
/* message type */
sprintf((pbuf+strlen(pbuf)), "message=");
@@ -168,7 +167,7 @@ decode_q931(char *pbuf, int n, int off, unsigned char *buf, int raw)
sprintf((pbuf+strlen(pbuf)), "RESUME REJECT: ");
break;
case 0x24:
- sprintf((pbuf+strlen(pbuf)), "HOLD (Q.932): ");
+ sprintf((pbuf+strlen(pbuf)), "HOLD: ");
break;
case 0x25:
sprintf((pbuf+strlen(pbuf)), "SUSPEND: ");
@@ -177,7 +176,7 @@ decode_q931(char *pbuf, int n, int off, unsigned char *buf, int raw)
sprintf((pbuf+strlen(pbuf)), "RESUME: ");
break;
case 0x28:
- sprintf((pbuf+strlen(pbuf)), "HOLD ACKNOWLEDGE (Q.932): ");
+ sprintf((pbuf+strlen(pbuf)), "HOLD ACKNOWLEDGE: ");
break;
case 0x2d:
sprintf((pbuf+strlen(pbuf)), "SUSPEND ACKNOWLEDGE: ");
@@ -578,7 +577,9 @@ decode_q931(char *pbuf, int n, int off, unsigned char *buf, int raw)
sprintf((pbuf+strlen(pbuf)), "[terminal capabilities: ");
break;
case 0x27:
- sprintf((pbuf+strlen(pbuf)), "[notification ind: ");
+ sprintf((pbuf+strlen(pbuf)), "[notification indicator: ");
+ i += p_q931notification(pbuf, &buf[i]);
+ goto next;
break;
case 0x28:
sprintf((pbuf+strlen(pbuf)), "[display: ");
@@ -721,9 +722,13 @@ decode_q931(char *pbuf, int n, int off, unsigned char *buf, int raw)
break;
case 0x74:
sprintf((pbuf+strlen(pbuf)), "[redirecting number: ");
+ i += p_q931redir(pbuf, &buf[i]);
+ goto next;
break;
case 0x76:
sprintf((pbuf+strlen(pbuf)), "[redirection number: ");
+ i += p_q931redir(pbuf, &buf[i]);
+ goto next;
break;
case 0x78:
sprintf((pbuf+strlen(pbuf)), "[transit network selection: ");
@@ -741,6 +746,8 @@ decode_q931(char *pbuf, int n, int off, unsigned char *buf, int raw)
break;
case 0x7e:
sprintf((pbuf+strlen(pbuf)), "[user-user: ");
+ i += p_q931user_user(pbuf, &buf[i]);
+ goto next;
break;
case 0x7f:
sprintf((pbuf+strlen(pbuf)), "[escape for extension: ");
diff --git a/usr.sbin/i4b/isdntrace/q931_util.c b/usr.sbin/i4b/isdntrace/q931_util.c
index bca17dd..9f82283 100644
--- a/usr.sbin/i4b/isdntrace/q931_util.c
+++ b/usr.sbin/i4b/isdntrace/q931_util.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 1999 Hellmuth Michaelis. All rights reserved.
+ * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,11 +27,11 @@
* q931_util.c - utility functions to print Q.931 traces
* -----------------------------------------------------
*
- * $Id: q931_util.c,v 1.6 1999/12/13 21:25:26 hm Exp $
+ * $Id: q931_util.c,v 1.11 2000/02/15 12:48:14 hm Exp $
*
* $FreeBSD$
*
- * last edit-date: [Mon Dec 13 21:57:03 1999]
+ * last edit-date: [Tue Feb 15 13:52:09 2000]
*
*---------------------------------------------------------------------------*/
@@ -695,5 +695,353 @@ p_q931high_compat(char *pbuf, unsigned char *buf)
return 5;
}
+/*---------------------------------------------------------------------------*
+ * decode and print user-user IE
+ *---------------------------------------------------------------------------*/
+int
+p_q931user_user(char *pbuf, unsigned char *buf)
+{
+ int j;
+ int len;
+ int i = 0;
+ int pd;
+
+ i++; /* index -> length */
+ len = buf[i];
+
+ i++; /* index -> protocoldiscriminator */
+ pd = buf[i];
+
+ switch(pd)
+ {
+ case 0:
+ sprintf((pbuf+strlen(pbuf)), "(pd=user-specific");
+ break;
+ case 1:
+ sprintf((pbuf+strlen(pbuf)), "(pd=OSI high-layer protocols");
+ break;
+ case 2:
+ sprintf((pbuf+strlen(pbuf)), "(pd=X.244");
+ break;
+ case 3:
+ sprintf((pbuf+strlen(pbuf)), "(pd=reserved for system management");
+ break;
+ case 4:
+ sprintf((pbuf+strlen(pbuf)), "(pd=IA5 characters");
+ break;
+ case 6:
+ sprintf((pbuf+strlen(pbuf)), "(pd=X.208/X.209 coded user info");
+ break;
+ case 7:
+ sprintf((pbuf+strlen(pbuf)), "(pd=V.120 rate adaption");
+ break;
+ case 8:
+ sprintf((pbuf+strlen(pbuf)), "(pd=Q.931/I.451 user network call control messages");
+ break;
+ default:
+ if(pd >= 0x10 && pd <= 0x3f)
+ sprintf((pbuf+strlen(pbuf)), "(pd=0x%x=reserved for other L3 protocols incl. X.25", pd);
+ else if(pd >= 0x40 && pd <= 0x47)
+ sprintf((pbuf+strlen(pbuf)), "(pd=0x%x=national use", pd);
+ else if(pd >= 0x48 && pd <= 0x4f)
+ sprintf((pbuf+strlen(pbuf)), "(pd=0x%x=reserved for ETSI", pd);
+ else if(pd >= 0x50 && pd <= 0xfe)
+ sprintf((pbuf+strlen(pbuf)), "(pd=0x%x=reserved for other L3 protocols incl. X.25", pd);
+ else
+ sprintf((pbuf+strlen(pbuf)), "(pd=0x%x=reserved", pd);
+ break;
+ }
+
+ i++;
+ len--;
+
+ sprintf((pbuf+strlen(pbuf)),": (");
+
+ for(j = 0; j < len; j++)
+ {
+ if(pd == 4)
+ sprintf((pbuf+strlen(pbuf)),"%c", buf[j+i]);
+ else
+ sprintf((pbuf+strlen(pbuf)),"0x%2x", buf[j+i]);
+ }
+
+ sprintf((pbuf+strlen(pbuf)),"))]");
+
+ i += j;
+
+ return(i);
+}
+
+/*---------------------------------------------------------------------------*
+ * decode and notification indicator IE (Q.932, p44)
+ *---------------------------------------------------------------------------*/
+int
+p_q931notification(char *pbuf, unsigned char *buf)
+{
+ int j = 0;
+ int len;
+ int i = 0;
+ int nd;
+
+ i++; /* index -> length */
+ len = buf[i];
+
+ i++; /* index -> notification description */
+ nd = buf[i];
+
+ switch(nd)
+ {
+ case 0x80:
+ sprintf((pbuf+strlen(pbuf)), "0x%2x, user suspended", nd);
+ break;
+ case 0x81:
+ sprintf((pbuf+strlen(pbuf)), "0x%2x, user resumed", nd);
+ break;
+ case 0x82:
+ sprintf((pbuf+strlen(pbuf)), "0x%2x, bearer service changed", nd);
+ break;
+
+ case 0x83:
+ sprintf((pbuf+strlen(pbuf)), "0x%2x, BER coded information", nd);
+ break;
+
+ case 0xc2:
+ sprintf((pbuf+strlen(pbuf)), "0x%2x, conference established", nd);
+ break;
+ case 0xc3:
+ sprintf((pbuf+strlen(pbuf)), "0x%2x, conference disconnected", nd);
+ break;
+ case 0xc4:
+ sprintf((pbuf+strlen(pbuf)), "0x%2x, other party added", nd);
+ break;
+ case 0xc5:
+ sprintf((pbuf+strlen(pbuf)), "0x%2x, isolated", nd);
+ break;
+ case 0xc6:
+ sprintf((pbuf+strlen(pbuf)), "0x%2x, reattached", nd);
+ break;
+ case 0xc7:
+ sprintf((pbuf+strlen(pbuf)), "0x%2x, other party isolated", nd);
+ break;
+ case 0xc8:
+ sprintf((pbuf+strlen(pbuf)), "0x%2x, other party reattached", nd);
+ break;
+ case 0xc9:
+ sprintf((pbuf+strlen(pbuf)), "0x%2x, other party split", nd);
+ break;
+ case 0xca:
+ sprintf((pbuf+strlen(pbuf)), "0x%2x, other party disconnected", nd);
+ break;
+ case 0xcb:
+ sprintf((pbuf+strlen(pbuf)), "0x%2x, conference floating", nd);
+ break;
+ case 0xcc:
+ sprintf((pbuf+strlen(pbuf)), "0x%2x, conference disconnected, preemption", nd);
+ break;
+ case 0xcf:
+ sprintf((pbuf+strlen(pbuf)), "0x%2x, conference floating, server user preempted", nd);
+ break;
+
+ case 0xe0:
+ sprintf((pbuf+strlen(pbuf)), "0x%2x, call is a waiting call", nd);
+ break;
+ case 0xe8:
+ sprintf((pbuf+strlen(pbuf)), "0x%2x, diversion activated", nd);
+ break;
+ case 0xe9: /* ECT, EN 300 369-1 V1.2.4 p12) */
+ sprintf((pbuf+strlen(pbuf)), "0x%2x, call transferred, alerting", nd);
+ break;
+ case 0xea: /* ECT, EN 300 369-1 V1.2.4 p12) */
+ sprintf((pbuf+strlen(pbuf)), "0x%2x, call transferred, active", nd);
+ break;
+ case 0xee:
+ sprintf((pbuf+strlen(pbuf)), "0x%2x, reverse charging", nd);
+ break;
+
+ case 0xf9:
+ sprintf((pbuf+strlen(pbuf)), "0x%2x, remote hold", nd);
+ break;
+ case 0xfa:
+ sprintf((pbuf+strlen(pbuf)), "0x%2x, remote retrieval", nd);
+ break;
+ case 0xfb:
+ sprintf((pbuf+strlen(pbuf)), "0x%2x, call is diverting", nd);
+ break;
+ default:
+ sprintf((pbuf+strlen(pbuf)), "0x%2x, undefined", nd);
+ break;
+ }
+
+ i++;
+ len--;
+
+ if(len)
+ {
+ sprintf((pbuf+strlen(pbuf)),": (");
+
+ for(; j < len; j++)
+ {
+ if(nd == 4)
+ sprintf((pbuf+strlen(pbuf)),"%c", buf[j+i]);
+ else
+ sprintf((pbuf+strlen(pbuf)),"0x%2x", buf[j+i]);
+ }
+
+ sprintf((pbuf+strlen(pbuf)),")");
+ }
+ sprintf((pbuf+strlen(pbuf)),"]");
+ i += j;
+
+ return(i);
+}
+
+/*---------------------------------------------------------------------------*
+ * decode and print redirecting/redirection number
+ *---------------------------------------------------------------------------*/
+int
+p_q931redir(char *pbuf, unsigned char *buf)
+{
+ int j;
+ int len;
+ int i = 0;
+ int tp;
+ int ind = 0;
+ int indflag = 0;
+ int reas = 0;
+ int reasflag = 0;
+
+ i++; /* index -> length */
+ len = buf[i];
+
+ i++; /* index -> type/plan */
+ tp = buf[i];
+
+ i++;
+ len--;
+
+ if(!(tp & 0x80))
+ {
+ ind = buf[i];
+ indflag = 1;
+ i++;
+ len--;
+
+ if(!(ind & 0x80))
+ {
+ reas = buf[i];
+ reasflag = 1;
+ i++;
+ len--;
+ }
+ }
+
+ for(j = 0; j < len; j++)
+ {
+ sprintf((pbuf+strlen(pbuf)),"%c", buf[j+i]);
+ }
+
+ switch((tp & 0x70) >> 4)
+ {
+ case 0:
+ sprintf((pbuf+strlen(pbuf)), " (type=unknown, ");
+ break;
+ case 1:
+ sprintf((pbuf+strlen(pbuf)), " (type=international, ");
+ break;
+ case 2:
+ sprintf((pbuf+strlen(pbuf)), " (type=national, ");
+ break;
+ case 3:
+ sprintf((pbuf+strlen(pbuf)), " (type=network specific, ");
+ break;
+ case 4:
+ sprintf((pbuf+strlen(pbuf)), " (type=subscriber, ");
+ break;
+ case 6:
+ sprintf((pbuf+strlen(pbuf)), " (type=abbreviated, ");
+ break;
+ default:
+ sprintf((pbuf+strlen(pbuf)), " (type=reserved (%d), ", ((tp & 0x70) >> 4));
+ break;
+ }
+
+ switch(tp & 0x0f)
+ {
+ case 0:
+ sprintf((pbuf+strlen(pbuf)), "plan=unknown");
+ break;
+ case 1:
+ sprintf((pbuf+strlen(pbuf)), "plan=ISDN");
+ break;
+ case 3:
+ sprintf((pbuf+strlen(pbuf)), "plan=Data");
+ break;
+ case 4:
+ sprintf((pbuf+strlen(pbuf)), "plan=Telex");
+ break;
+ case 8:
+ sprintf((pbuf+strlen(pbuf)), "plan=National");
+ break;
+ case 9:
+ sprintf((pbuf+strlen(pbuf)), "plan=private");
+ break;
+ default:
+ sprintf((pbuf+strlen(pbuf)), "plan=reserved (%d)", (tp & 0x0f));
+ break;
+ }
+
+ if(indflag)
+ {
+ sprintf((pbuf+strlen(pbuf)), ",\n ");
+ switch((ind & 0x60) >> 5)
+ {
+ case 0:
+ sprintf((pbuf+strlen(pbuf)), "presentation allowed");
+ break;
+ case 1:
+ sprintf((pbuf+strlen(pbuf)), "presentation restricted");
+ break;
+ case 2:
+ sprintf((pbuf+strlen(pbuf)), "number not available");
+ break;
+ case 3:
+ sprintf((pbuf+strlen(pbuf)), "reserved");
+ break;
+ }
+ }
+
+ if(reasflag)
+ {
+ sprintf((pbuf+strlen(pbuf)), ",\n ");
+ switch(reas & 0x0f)
+ {
+ case 0:
+ sprintf((pbuf+strlen(pbuf)), "reason for diversion: unknown");
+ break;
+ case 1:
+ sprintf((pbuf+strlen(pbuf)), "reason for diversion: call forwarding busy");
+ break;
+ case 2:
+ sprintf((pbuf+strlen(pbuf)), "reason for diversion: call forwarding unconditional");
+ break;
+ case 0xa:
+ sprintf((pbuf+strlen(pbuf)), "reason for diversion: called DTE");
+ break;
+ case 0xf:
+ sprintf((pbuf+strlen(pbuf)), "reason for diversion: call forwarding unconditional");
+ break;
+ default:
+ sprintf((pbuf+strlen(pbuf)), "reason for diversion: reserved (0x%2x)",reas & 0x0f);
+ break;
+ }
+ }
+
+ sprintf((pbuf+strlen(pbuf)),")]");
+
+ i += j;
+
+ return(i);
+}
+
/* EOF */
diff --git a/usr.sbin/i4b/isdntrace/q932_fac.c b/usr.sbin/i4b/isdntrace/q932_fac.c
index dc3194b..0a0099d 100644
--- a/usr.sbin/i4b/isdntrace/q932_fac.c
+++ b/usr.sbin/i4b/isdntrace/q932_fac.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 1999 Hellmuth Michaelis. All rights reserved.
+ * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,11 +27,11 @@
* q932_fac.c - decode Q.932 facilities
* ------------------------------------
*
- * $Id: q932_fac.c,v 1.6 1999/12/13 21:25:26 hm Exp $
+ * $Id: q932_fac.c,v 1.8 2000/02/24 16:32:46 hm Exp $
*
* $FreeBSD$
*
- * last edit-date: [Mon Dec 13 21:57:11 1999]
+ * last edit-date: [Thu Feb 24 17:36:47 2000]
*
*---------------------------------------------------------------------------
*
@@ -64,6 +64,8 @@ static char *opval_str(int val);
static char *bid_str(int val);
static void next_state(char *pbuf, int class, int form, int code, int val);
+static void object_id(int comp_length, unsigned char *pbuf);
+
static int byte_len;
static unsigned char *byte_buf;
static int state;
@@ -300,6 +302,13 @@ again:
sprintf((pbuf+strlen(pbuf)), "Val: %d\n", val);
}
break;
+
+ case FAC_CODEUNI_OBJI: /* object id */
+
+ if(comp_length)
+ object_id(comp_length, pbuf);
+ break;
+
default:
if(comp_length)
{
@@ -643,6 +652,179 @@ F_1_4(char *pbuf, int val)
if(val == -1)
{
sprintf((pbuf+strlen(pbuf)), "\t reject\n");
+ state = ST_EXP_REJ_INV_ID;
+ }
+}
+
+/*---------------------------------------------------------------------------*
+ * return result: invoke id
+ *---------------------------------------------------------------------------*/
+static void
+F_RJ2(char *pbuf, int val)
+{
+#ifdef ST_DEBUG
+ sprintf((pbuf+strlen(pbuf)), "next_state: exec F_RJ2, val = %d\n", val);
+#endif
+ if(val != -1)
+ {
+ sprintf((pbuf+strlen(pbuf)), "\t InvokeIdentifier = %d\n", val);
+ state = ST_EXP_REJ_OP_VAL;
+ }
+}
+
+/*---------------------------------------------------------------------------*
+ * reject, general problem
+ *---------------------------------------------------------------------------*/
+static void
+F_RJ30(char *pbuf, int val)
+{
+#ifdef ST_DEBUG
+ sprintf((pbuf+strlen(pbuf)), "next_state: exec F_RJ30, val = %d\n", val);
+#endif
+ if(val == -1)
+ {
+ sprintf((pbuf+strlen(pbuf)), "\t General problem\n");
+ }
+ else
+ {
+ switch(val)
+ {
+ case 0:
+ sprintf((pbuf+strlen(pbuf)), "\t problem = unrecognized component\n");
+ break;
+ case 1:
+ sprintf((pbuf+strlen(pbuf)), "\t problem = mistyped component\n");
+ break;
+ case 2:
+ sprintf((pbuf+strlen(pbuf)), "\t problem = badly structured component\n");
+ break;
+ default:
+ sprintf((pbuf+strlen(pbuf)), "\t problem = unknown problem code 0x%x\n", val);
+ break;
+ }
+ state = ST_EXP_NIX;
+ }
+}
+
+/*---------------------------------------------------------------------------*
+ * reject, invoke problem
+ *---------------------------------------------------------------------------*/
+static void
+F_RJ31(char *pbuf, int val)
+{
+#ifdef ST_DEBUG
+ sprintf((pbuf+strlen(pbuf)), "next_state: exec F_RJ31, val = %d\n", val);
+#endif
+ if(val == -1)
+ {
+ sprintf((pbuf+strlen(pbuf)), "\t Invoke problem\n");
+ }
+ else
+ {
+ switch(val)
+ {
+ case 0:
+ sprintf((pbuf+strlen(pbuf)), "\t problem = duplicate invocation\n");
+ break;
+ case 1:
+ sprintf((pbuf+strlen(pbuf)), "\t problem = unrecognized operation\n");
+ break;
+ case 2:
+ sprintf((pbuf+strlen(pbuf)), "\t problem = mistyped argument\n");
+ break;
+ case 3:
+ sprintf((pbuf+strlen(pbuf)), "\t problem = resource limitation\n");
+ break;
+ case 4:
+ sprintf((pbuf+strlen(pbuf)), "\t problem = initiator releasing\n");
+ break;
+ case 5:
+ sprintf((pbuf+strlen(pbuf)), "\t problem = unrecognized linked identifier\n");
+ break;
+ case 6:
+ sprintf((pbuf+strlen(pbuf)), "\t problem = linked resonse unexpected\n");
+ break;
+ case 7:
+ sprintf((pbuf+strlen(pbuf)), "\t problem = unexpected child operation\n");
+ break;
+ default:
+ sprintf((pbuf+strlen(pbuf)), "\t problem = unknown problem code 0x%x\n", val);
+ break;
+ }
+ state = ST_EXP_NIX;
+ }
+}
+
+/*---------------------------------------------------------------------------*
+ * reject, return result problem
+ *---------------------------------------------------------------------------*/
+static void
+F_RJ32(char *pbuf, int val)
+{
+#ifdef ST_DEBUG
+ sprintf((pbuf+strlen(pbuf)), "next_state: exec F_RJ32, val = %d\n", val);
+#endif
+ if(val == -1)
+ {
+ sprintf((pbuf+strlen(pbuf)), "\t Return result problem\n");
+ }
+ else
+ {
+ switch(val)
+ {
+ case 0:
+ sprintf((pbuf+strlen(pbuf)), "\t problem = unrecognized invocation\n");
+ break;
+ case 1:
+ sprintf((pbuf+strlen(pbuf)), "\t problem = return response unexpected\n");
+ break;
+ case 2:
+ sprintf((pbuf+strlen(pbuf)), "\t problem = mistyped result\n");
+ break;
+ default:
+ sprintf((pbuf+strlen(pbuf)), "\t problem = unknown problem code 0x%x\n", val);
+ break;
+ }
+ state = ST_EXP_NIX;
+ }
+}
+
+/*---------------------------------------------------------------------------*
+ * reject, return error problem
+ *---------------------------------------------------------------------------*/
+static void
+F_RJ33(char *pbuf, int val)
+{
+#ifdef ST_DEBUG
+ sprintf((pbuf+strlen(pbuf)), "next_state: exec F_RJ33, val = %d\n", val);
+#endif
+ if(val == -1)
+ {
+ sprintf((pbuf+strlen(pbuf)), "\t Return error problem\n");
+ }
+ else
+ {
+ switch(val)
+ {
+ case 0:
+ sprintf((pbuf+strlen(pbuf)), "\t problem = unrecognized invocation\n");
+ break;
+ case 1:
+ sprintf((pbuf+strlen(pbuf)), "\t problem = error response unexpected\n");
+ break;
+ case 2:
+ sprintf((pbuf+strlen(pbuf)), "\t problem = unrecognized error\n");
+ break;
+ case 3:
+ sprintf((pbuf+strlen(pbuf)), "\t problem = unexpected error\n");
+ break;
+ case 4:
+ sprintf((pbuf+strlen(pbuf)), "\t problem = mistyped parameter\n");
+ break;
+ default:
+ sprintf((pbuf+strlen(pbuf)), "\t problem = unknown problem code 0x%x\n", val);
+ break;
+ }
state = ST_EXP_NIX;
}
}
@@ -888,6 +1070,16 @@ static struct statetab {
{ST_EXP_RR_OP_VAL, FAC_TAGFORM_PRI, FAC_TAGCLASS_UNI, FAC_CODEUNI_INT, F_RR3 },
{ST_EXP_RR_RESULT, FAC_TAGFORM_CON, FAC_TAGCLASS_UNI, FAC_CODEUNI_SET, F_RRR },
+/* current state tag form tag class tag code function */
+/* --------------------- ---------------------- ---------------------- ---------------------- ----------------*/
+/* reject */
+
+ {ST_EXP_REJ_INV_ID, FAC_TAGFORM_PRI, FAC_TAGCLASS_UNI, FAC_CODEUNI_INT, F_RJ2 },
+ {ST_EXP_REJ_OP_VAL, FAC_TAGFORM_PRI, FAC_TAGCLASS_COS, 0, F_RJ30 },
+ {ST_EXP_REJ_OP_VAL, FAC_TAGFORM_PRI, FAC_TAGCLASS_COS, 1, F_RJ31 },
+ {ST_EXP_REJ_OP_VAL, FAC_TAGFORM_PRI, FAC_TAGCLASS_COS, 2, F_RJ32 },
+ {ST_EXP_REJ_OP_VAL, FAC_TAGFORM_PRI, FAC_TAGCLASS_COS, 3, F_RJ33 },
+
/* end */
{-1, -1, -1, -1, NULL }
@@ -924,5 +1116,121 @@ next_state(char *pbuf, int class, int form, int code, int val)
}
}
+/*---------------------------------------------------------------------------*
+ * decode OBJECT IDENTIFIER
+ *---------------------------------------------------------------------------*/
+static void
+object_id(int comp_length, unsigned char *pbuf)
+{
+ int x;
+ int i;
+ int j = 0;
+ int id_org = 0;
+ int etsi = 0;
+
+ sprintf((pbuf+strlen(pbuf)), "\t");
+
+ for(i = comp_length-1; i >= 0; i--, j++)
+ {
+ sprintf((pbuf+strlen(pbuf)), "0x%02x = %d", *byte_buf, *byte_buf);
+
+ if(j == 0)
+ {
+ x = *byte_buf;
+
+ if(x >= 0 && x <= 39)
+ {
+ sprintf((pbuf+strlen(pbuf)), " ccitt/itu-t (0)");
+ switch(x)
+ {
+ case 0:
+ sprintf((pbuf+strlen(pbuf)), " recommendation (0)");
+ break;
+ case 1:
+ sprintf((pbuf+strlen(pbuf)), " question (1)");
+ break;
+ case 2:
+ sprintf((pbuf+strlen(pbuf)), " administration (2)");
+ break;
+ case 3:
+ sprintf((pbuf+strlen(pbuf)), " network-operator (3)");
+ break;
+ case 4:
+ sprintf((pbuf+strlen(pbuf)), " identified-organization (4)");
+ id_org = 1;
+ break;
+ default:
+ sprintf((pbuf+strlen(pbuf)), " error: undefined-identifier (%d)", x);
+ break;
+ }
+ }
+ else if(x >= 40 && x <= 79)
+ {
+ sprintf((pbuf+strlen(pbuf)), " iso (1)");
+ x -= 40;
+ switch(x)
+ {
+ case 0:
+ sprintf((pbuf+strlen(pbuf)), " standard (0)");
+ break;
+ case 1:
+ sprintf((pbuf+strlen(pbuf)), " registration-authority (1)");
+ break;
+ case 2:
+ sprintf((pbuf+strlen(pbuf)), " member-body (2)");
+ break;
+ case 3:
+ sprintf((pbuf+strlen(pbuf)), " identified-organization (3)");
+ id_org = 1;
+ break;
+ default:
+ sprintf((pbuf+strlen(pbuf)), " error: undefined-identifier (%d)", x);
+ break;
+ }
+ }
+ else
+ {
+ x -= 80;
+ sprintf((pbuf+strlen(pbuf)), " joint-iso-ccitt (3) ??? (%d)", x);
+ }
+ }
+
+ if(j == 1)
+ {
+ if(id_org == 1)
+ {
+ if(*byte_buf == 0)
+ {
+ sprintf((pbuf+strlen(pbuf)), " etsi (0)");
+ etsi = 1;
+ }
+ }
+ }
+
+ if(j == 2)
+ {
+ if(etsi == 1)
+ {
+ if(*byte_buf == 0)
+ {
+ sprintf((pbuf+strlen(pbuf)), " mobileDomain (0)");
+ }
+ if(*byte_buf == 1)
+ {
+ sprintf((pbuf+strlen(pbuf)), " inDomain (1)");
+ }
+ }
+ }
+
+ byte_buf++;
+ byte_len++;
+
+ if(i)
+ sprintf((pbuf+strlen(pbuf)), "\n\t");
+ else
+ sprintf((pbuf+strlen(pbuf)), "\n");
+ }
+}
+
/* EOF */
diff --git a/usr.sbin/i4b/isdntrace/q932_fac.h b/usr.sbin/i4b/isdntrace/q932_fac.h
index a3641cf..563de3a 100644
--- a/usr.sbin/i4b/isdntrace/q932_fac.h
+++ b/usr.sbin/i4b/isdntrace/q932_fac.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1997, 1999 Hellmuth Michaelis. All rights reserved.
+ * Copyright (c) 1997, 2000 Hellmuth Michaelis. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -27,11 +27,11 @@
* q932_fac.h - facility header file
* ---------------------------------
*
- * $Id: q932_fac.h,v 1.6 1999/12/13 21:25:26 hm Exp $
+ * $Id: q932_fac.h,v 1.7 2000/02/18 16:27:39 hm Exp $
*
* $FreeBSD$
*
- * last edit-date: [Mon Dec 13 21:57:18 1999]
+ * last edit-date: [Fri Feb 18 17:26:07 2000]
*
*---------------------------------------------------------------------------
*
@@ -168,6 +168,10 @@ enum states {
ST_EXP_RR_INV_ID,
ST_EXP_RR_OP_VAL,
ST_EXP_RR_RESULT,
+
+ ST_EXP_REJ_INV_ID,
+ ST_EXP_REJ_OP_VAL,
+ ST_EXP_REJ_RESULT,
ST_EXP_NIX
};
diff --git a/usr.sbin/i4b/isdntrace/trace.c b/usr.sbin/i4b/isdntrace/trace.c
index b38127f..2f1d71f 100644
--- a/usr.sbin/i4b/isdntrace/trace.c
+++ b/usr.sbin/i4b/isdntrace/trace.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 1999 Hellmuth Michaelis. All rights reserved.
+ * Copyright (c) 1996, 2000 Hellmuth Michaelis. All rights reserved.
*
* Copyright (c) 1996 Gary Jennejohn. All rights reserved.
*
@@ -35,11 +35,11 @@
* trace.c - print traces of D (B) channel activity for isdn4bsd
* -------------------------------------------------------------
*
- * $Id: trace.c,v 1.15 1999/12/13 21:25:26 hm Exp $
+ * $Id: trace.c,v 1.19 2000/08/28 07:06:42 hm Exp $
*
* $FreeBSD$
*
- * last edit-date: [Mon Dec 13 21:57:48 1999]
+ * last edit-date: [Mon Aug 28 09:03:46 2000]
*
*---------------------------------------------------------------------------*/
@@ -64,9 +64,15 @@ int Popt = 0;
int bpopt = 0;
int info = 0;
int Fopt = 0;
+int xopt = 1;
+
+int enable_trace = TRACE_D_RX | TRACE_D_TX;
+
+static char outfilename[MAXPATHLEN];
+static char routfilename[MAXPATHLEN];
+static char BPfilename[MAXPATHLEN];
+static char rBPfilename[MAXPATHLEN];
-static char outfilename[1024];
-static char BPfilename[1024];
static struct stat fst;
static void dumpbuf( int n, unsigned char *buf, i4b_trace_hdr_t *hdr, int raw );
@@ -74,6 +80,7 @@ static int switch_driver( int value, int rx, int tx );
static void usage( void );
static void exit_hdl( void );
static void reopenfiles( int );
+void add_datetime(char *filename, char *rfilename);
/*---------------------------------------------------------------------------*
* usage instructions
@@ -84,7 +91,7 @@ usage(void)
fprintf(stderr,"\n");
fprintf(stderr,"isdntrace - i4b package ISDN trace facility for passive cards (%02d.%02d.%d)\n", VERSION, REL, STEP);
fprintf(stderr,"usage: isdntrace -a -b -d -f <file> -h -i -l -n <val> -o -p <file> -r -u <unit>\n");
- fprintf(stderr," -B -F -P -R <unit> -T <unit>\n");
+ fprintf(stderr," -x -B -F -P -R <unit> -T <unit>\n");
fprintf(stderr," -a analyzer mode ................................... (default off)\n");
fprintf(stderr," -b switch B channel trace on ....................... (default off)\n");
fprintf(stderr," -d switch D channel trace off ....................... (default on)\n");
@@ -97,6 +104,7 @@ usage(void)
fprintf(stderr," -p <file> specify filename for -B and -P ........ (default %s0)\n", BIN_FILE_NAME);
fprintf(stderr," -r don't print raw hex/ASCII dump of protocol ...... (default off)\n");
fprintf(stderr," -u <unit> specify controller unit number ............... (default unit 0)\n");
+ fprintf(stderr," -x show packets with unknown protocol discriminator (default off)\n");
fprintf(stderr," -B write binary trace data to file filename ........ (default off)\n");
fprintf(stderr," -F with -P and -p: wait for more data at EOF ....... (default off)\n");
fprintf(stderr," -P playback from binary trace data file ............ (default off)\n");
@@ -122,7 +130,6 @@ main(int argc, char *argv[])
int c;
char *b;
- int enable_trace = TRACE_D_RX | TRACE_D_TX;
char *outfile = TRACE_FILE_NAME;
char *binfile = BIN_FILE_NAME;
int outfileset = 0;
@@ -135,7 +142,7 @@ main(int argc, char *argv[])
b = &buf[sizeof(i4b_trace_hdr_t)];
- while( (c = getopt(argc, argv, "abdf:hiln:op:ru:BFPR:T:")) != -1)
+ while( (c = getopt(argc, argv, "abdf:hiln:op:ru:xBFPR:T:")) != -1)
{
switch(c)
{
@@ -192,6 +199,10 @@ main(int argc, char *argv[])
usage();
break;
+ case 'x':
+ xopt = 0;
+ break;
+
case 'B':
Bopt = 1;
break;
@@ -238,18 +249,13 @@ main(int argc, char *argv[])
else
sprintf(BPfilename, "%s%d", BIN_FILE_NAME, unit);
- if((BP = fopen(BPfilename, "r")) != NULL)
- {
- char buffer[1024];
- fclose(BP);
- sprintf(buffer, "%s%s", BPfilename, TRACE_FILE_NAME_BAK);
- rename(BPfilename, buffer);
- }
- if((BP = fopen(BPfilename, "w")) == NULL)
+ add_datetime(BPfilename, rBPfilename);
+
+ if((BP = fopen(rBPfilename, "w")) == NULL)
{
char buffer[80];
- sprintf(buffer, "Error opening file [%s]", BPfilename);
+ sprintf(buffer, "Error opening file [%s]", rBPfilename);
perror(buffer);
exit(1);
}
@@ -258,7 +264,7 @@ main(int argc, char *argv[])
{
char buffer[80];
- sprintf(buffer, "Error setting file [%s] to unbuffered", BPfilename);
+ sprintf(buffer, "Error setting file [%s] to unbuffered", rBPfilename);
perror(buffer);
exit(1);
}
@@ -271,6 +277,8 @@ main(int argc, char *argv[])
else
sprintf(BPfilename, "%s%d", BIN_FILE_NAME, unit);
+ strcpy(rBPfilename, BPfilename);
+
if((BP = fopen(BPfilename, "r")) == NULL)
{
char buffer[80];
@@ -311,20 +319,13 @@ main(int argc, char *argv[])
else
strcpy(outfilename, outfile);
+ add_datetime(outfilename, routfilename);
- if((Fout = fopen(outfilename, "r")) != NULL)
- {
- char buffer[1024];
- fclose(Fout);
- sprintf(buffer, "%s%s", outfilename, TRACE_FILE_NAME_BAK);
- rename(outfilename, buffer);
- }
-
- if((Fout = fopen(outfilename, "w")) == NULL)
+ if((Fout = fopen(routfilename, "w")) == NULL)
{
char buffer[80];
- sprintf(buffer, "Error opening file [%s]", outfilename);
+ sprintf(buffer, "Error opening file [%s]", routfilename);
perror(buffer);
exit(1);
}
@@ -333,7 +334,7 @@ main(int argc, char *argv[])
{
char buffer[80];
- sprintf(buffer, "Error setting file [%s] to unbuffered", outfile);
+ sprintf(buffer, "Error setting file [%s] to unbuffered", routfilename);
perror(buffer);
exit(1);
}
@@ -388,7 +389,7 @@ main(int argc, char *argv[])
if((fwrite(buf, 1, n, BP)) != n)
{
char buffer[80];
- sprintf(buffer, "Error writing file [%s]", BPfilename);
+ sprintf(buffer, "Error writing file [%s]", rBPfilename);
perror(buffer);
exit(1);
}
@@ -408,7 +409,7 @@ again:
if(ferror(BP))
{
char buffer[80];
- sprintf(buffer, "Error reading hdr from file [%s]", BPfilename);
+ sprintf(buffer, "Error reading hdr from file [%s]", rBPfilename);
perror(buffer);
exit(1);
}
@@ -416,19 +417,19 @@ again:
usleep(250000);
clearerr(BP);
- if(stat(BPfilename, &fstnew) != -1)
+ if(stat(rBPfilename, &fstnew) != -1)
{
if((fst.st_ino != fstnew.st_ino) ||
(fstnew.st_nlink == 0))
{
- if((BP = freopen(BPfilename, "r", BP)) == NULL)
+ if((BP = freopen(rBPfilename, "r", BP)) == NULL)
{
char buffer[80];
- sprintf(buffer, "Error reopening file [%s]", BPfilename);
+ sprintf(buffer, "Error reopening file [%s]", rBPfilename);
perror(buffer);
exit(1);
}
- stat(BPfilename, &fst);
+ stat(rBPfilename, &fst);
}
}
goto again;
@@ -442,7 +443,7 @@ again:
else
{
char buffer[80];
- sprintf(buffer, "Error reading hdr from file [%s]", BPfilename);
+ sprintf(buffer, "Error reading hdr from file [%s]", rBPfilename);
perror(buffer);
exit(1);
}
@@ -454,7 +455,7 @@ again:
if((n = fread(buf+sizeof(i4b_trace_hdr_t), 1, l , BP)) != l)
{
char buffer[80];
- sprintf(buffer, "Error reading data from file [%s]", BPfilename);
+ sprintf(buffer, "Error reading data from file [%s]", rBPfilename);
perror(buffer);
exit(1);
}
@@ -482,7 +483,7 @@ fmt_hdr(i4b_trace_hdr_t *hdr, int frm_len)
if(hdr->type == TRC_CH_I) /* Layer 1 INFO's */
{
- sprintf(hbuf,"\n-- %s - unit:%d ---------------- time:%2.2d.%2.2d %2.2d:%2.2d:%2.2d.%6u ",
+ sprintf(hbuf,"\n-- %s - unit:%d ---------------- time:%2.2d.%2.2d %2.2d:%2.2d:%2.2d.%06u ",
((hdr->dir) ? "NT->TE" : "TE->NT"),
hdr->unit,
s->tm_mday,
@@ -496,7 +497,7 @@ fmt_hdr(i4b_trace_hdr_t *hdr, int frm_len)
{
if(hdr->trunc > 0)
{
- sprintf(hbuf,"\n-- %s - unit:%d - frame:%6.6u - time:%2.2d.%2.2d %2.2d:%2.2d:%2.2d.%6u - length:%d (%d) ",
+ sprintf(hbuf,"\n-- %s - unit:%d - frame:%6.6u - time:%2.2d.%2.2d %2.2d:%2.2d:%2.2d.%06u - length:%d (%d) ",
((hdr->dir) ? "NT->TE" : "TE->NT"),
hdr->unit,
hdr->count,
@@ -511,7 +512,7 @@ fmt_hdr(i4b_trace_hdr_t *hdr, int frm_len)
}
else
{
- sprintf(hbuf,"\n-- %s - unit:%d - frame:%6.6u - time:%2.2d.%2.2d %2.2d:%2.2d:%2.2d.%6u - length:%d ",
+ sprintf(hbuf,"\n-- %s - unit:%d - frame:%6.6u - time:%2.2d.%2.2d %2.2d:%2.2d:%2.2d.%06u - length:%d ",
((hdr->dir) ? "NT->TE" : "TE->NT"),
hdr->unit,
hdr->count,
@@ -555,6 +556,11 @@ dumpbuf(int n, unsigned char *buf, i4b_trace_hdr_t *hdr, int raw)
switch(hdr->type)
{
case TRC_CH_I: /* Layer 1 INFO's */
+
+ /* on playback, don't display layer 1 if -i ! */
+ if(!(enable_trace & TRACE_I))
+ break;
+
pbuf = &l1buf[0];
switch(buf[0])
@@ -609,9 +615,21 @@ dumpbuf(int n, unsigned char *buf, i4b_trace_hdr_t *hdr, int raw)
decode_1tr6(l3buf, n, cnt, buf, raw);
break;
- default:
+ case 0x08:
decode_q931(l3buf, n, cnt, buf, raw);
break;
+
+ default:
+ if(xopt)
+ {
+ l2buf[0] = '\0';
+ l3buf[0] = '\0';
+ }
+ else
+ {
+ decode_unknownl3(l3buf, n, cnt, buf, raw);
+ }
+ break;
}
}
break;
@@ -750,11 +768,13 @@ reopenfiles(int dummy)
{
fclose(Fout);
- if((Fout = fopen(outfilename, "a")) == NULL)
+ add_datetime(outfilename, routfilename);
+
+ if((Fout = fopen(routfilename, "a")) == NULL)
{
char buffer[80];
- sprintf(buffer, "Error re-opening file [%s]", outfilename);
+ sprintf(buffer, "Error re-opening file [%s]", routfilename);
perror(buffer);
exit(1);
}
@@ -763,7 +783,7 @@ reopenfiles(int dummy)
{
char buffer[80];
- sprintf(buffer, "Error re-setting file [%s] to unbuffered", outfilename);
+ sprintf(buffer, "Error re-setting file [%s] to unbuffered", routfilename);
perror(buffer);
exit(1);
}
@@ -774,11 +794,13 @@ reopenfiles(int dummy)
fclose(BP);
- if((BP = fopen(BPfilename, "a")) == NULL)
+ add_datetime(BPfilename, rBPfilename);
+
+ if((BP = fopen(rBPfilename, "a")) == NULL)
{
char buffer[80];
- sprintf(buffer, "Error re-opening file [%s]", BPfilename);
+ sprintf(buffer, "Error re-opening file [%s]", rBPfilename);
perror(buffer);
exit(1);
}
@@ -787,12 +809,42 @@ reopenfiles(int dummy)
{
char buffer[80];
- sprintf(buffer, "Error re-setting file [%s] to unbuffered", BPfilename);
+ sprintf(buffer, "Error re-setting file [%s] to unbuffered", rBPfilename);
perror(buffer);
exit(1);
}
}
}
+void
+add_datetime(char *filename, char *rfilename)
+{
+ time_t timeb;
+ struct tm *tmp;
+ FILE *fx;
+
+ time(&timeb);
+ tmp = localtime(&timeb);
+
+ sprintf(rfilename, "%s-", filename);
+
+ strftime(rfilename+strlen(rfilename), MAXPATHLEN-strlen(rfilename)-1,
+ "%Y%m%d-%H%M%S", tmp);
+
+ if((fx = fopen(rfilename, "r")) != NULL)
+ {
+ fclose(fx);
-/* EOF */
+ sleep(1);
+
+ time(&timeb);
+ tmp = localtime(&timeb);
+
+ sprintf(rfilename, "%s-", filename);
+
+ strftime(rfilename+strlen(rfilename), MAXPATHLEN-strlen(rfilename)-1,
+ "%Y%m%d-%H%M%S", tmp);
+ }
+}
+
+/* EOF */
diff --git a/usr.sbin/i4b/isdntrace/trace.h b/usr.sbin/i4b/isdntrace/trace.h
index c7cc165..81fa415 100644
--- a/usr.sbin/i4b/isdntrace/trace.h
+++ b/usr.sbin/i4b/isdntrace/trace.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1996, 1999 Hellmuth Michaelis. All rights reserved.
+ * Copyright (c) 1996, 2000 Hellmuth Michaelis. All rights reserved.
*
* Copyright (c) 1996 Gary Jennejohn. All rights reserved.
*
@@ -35,11 +35,11 @@
* trace.h - header file for isdn trace
* ------------------------------------
*
- * $Id: trace.h,v 1.9 1999/12/13 21:25:26 hm Exp $
+ * $Id: trace.h,v 1.12 2000/02/14 16:25:22 hm Exp $
*
* $FreeBSD$
*
- * last edit-date: [Mon Dec 13 21:58:07 1999]
+ * last edit-date: [Mon Feb 14 14:43:40 2000]
*
*---------------------------------------------------------------------------*/
@@ -57,6 +57,7 @@
#include <sys/ioctl.h>
#include <sys/file.h>
#include <sys/stat.h>
+#include <sys/param.h>
#include <machine/i4b_ioctl.h>
#include <machine/i4b_trace.h>
@@ -66,7 +67,6 @@
#define I4BTRC_DEVICE "/dev/i4btrc" /* trace device file */
#define TRACE_FILE_NAME "isdntrace" /* default output filename */
-#define TRACE_FILE_NAME_BAK ".last" /* backup filename trailer */
#define BIN_FILE_NAME "isdntracebin" /* default binary filename */
#define BSIZE 4096 /* read buffer size */
@@ -77,6 +77,7 @@
int decode_lapd(char *pbuf, int n, unsigned char *buf, int is_te, int raw, int printit);
void decode_q931(char *pbuf, int n, int off, unsigned char *buf, int raw);
+void decode_unknownl3(char *pbuf, int n, int off, unsigned char *buf, int raw);
void decode_1tr6(char *pbuf, int n, int off, unsigned char *buf, int raw);
char *print_error(int prot, unsigned char code);
int q931_facility(char *pbuf, unsigned char *buf);
@@ -85,5 +86,8 @@ int p_q931address(char *pbuf, unsigned char *buf);
int p_q931bc(char *pbuf, unsigned char *buf);
int p_q931high_compat(char *pbuf, unsigned char *buf);
int q932_facility(char *pbuf, unsigned char *buf);
+int p_q931user_user(char *pbuf, unsigned char *buf);
+int p_q931notification(char *pbuf, unsigned char *buf);
+int p_q931redir(char *pbuf, unsigned char *buf);
/* EOF */
diff --git a/usr.sbin/i4b/isdntrace/unknownl3.c b/usr.sbin/i4b/isdntrace/unknownl3.c
new file mode 100644
index 0000000..8967a6a9
--- /dev/null
+++ b/usr.sbin/i4b/isdntrace/unknownl3.c
@@ -0,0 +1,106 @@
+/*
+ * Copyright (c) 2000 Hellmuth Michaelis. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ *---------------------------------------------------------------------------
+ *
+ * unknownl3.c - print L3 packets with unknown PD
+ * ----------------------------------------------
+ *
+ * $Id: unknownl3.c,v 1.2 2000/02/13 15:26:52 hm Exp $
+ *
+ * $FreeBSD$
+ *
+ * last edit-date: [Sun Feb 13 14:16:44 2000]
+ *
+ *---------------------------------------------------------------------------*/
+
+#include "trace.h"
+
+/*---------------------------------------------------------------------------*
+ * decode unknown protocol
+ *---------------------------------------------------------------------------*/
+void
+decode_unknownl3(char *pbuf, int n, int off, unsigned char *buf, int raw)
+{
+ int pd;
+ int j;
+ int i;
+
+ if(n <= 0)
+ return;
+
+ *pbuf = '\0';
+
+ if(raw)
+ {
+ for (i = 0; i < n; i += 16)
+ {
+ sprintf((pbuf+strlen(pbuf)),"Dump:%.3d ", i+off);
+ for (j = 0; j < 16; j++)
+ if (i + j < n)
+ sprintf((pbuf+strlen(pbuf)),"%02x ", buf[i + j]);
+ else
+ sprintf((pbuf+strlen(pbuf))," ");
+ sprintf((pbuf+strlen(pbuf))," ");
+ for (j = 0; j < 16 && i + j < n; j++)
+ if (isprint(buf[i + j]))
+ sprintf((pbuf+strlen(pbuf)),"%c", buf[i + j]);
+ else
+ sprintf((pbuf+strlen(pbuf)),".");
+ sprintf((pbuf+strlen(pbuf)),"\n");
+ }
+ }
+
+ i = 0;
+
+ /* protocol discriminator */
+
+ pd = buf[i];
+
+ sprintf((pbuf+strlen(pbuf)), "PD%02X: ", pd);
+
+ if(pd >= 0x00 && pd <= 0x07)
+ sprintf((pbuf+strlen(pbuf)), "pd=User-User (0x%02x)",pd);
+ else if(pd == 0x08)
+ sprintf((pbuf+strlen(pbuf)), "pd=Q.931/I.451");
+ else if(pd >= 0x10 && pd <= 0x3f)
+ sprintf((pbuf+strlen(pbuf)), "pd=Other Layer 3 or X.25 (0x%02x)",pd);
+ else if(pd >= 0x40 && pd <= 0x4f)
+ sprintf((pbuf+strlen(pbuf)), "pd=National Use (0x%02x)",pd);
+ else if(pd >= 0x50 && pd <= 0xfe)
+ sprintf((pbuf+strlen(pbuf)), "pd=Other Layer 3 or X.25 (0x%02x)",pd);
+ else
+ sprintf((pbuf+strlen(pbuf)), "pd=Reserved (0x%02x)",pd);
+
+ sprintf((pbuf+strlen(pbuf)), "\n [");
+ for(j = 0; j < (n-i); j++)
+ {
+ sprintf((pbuf+strlen(pbuf)),"0x%02x ", buf[j+i]);
+ }
+
+ sprintf((pbuf+strlen(pbuf)),"]\n");
+}
+
+/* EOF */
+
OpenPOWER on IntegriCloud