aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGilbert Ramirez <gram@alumni.rice.edu>1999-12-12 22:40:10 +0000
committerGilbert Ramirez <gram@alumni.rice.edu>1999-12-12 22:40:10 +0000
commit4a15f6582a309aa17e533febd2de731dba575336 (patch)
tree304b093f0b229e089402ae3522ec489584bc1484
parentbf611b0f7ca3352482a0854cf1c1de2ded8330c0 (diff)
Added Bert Driehuis <driehuis@playbeing.org>'s I4B wiretap module
and V.120 decoder. svn path=/trunk/; revision=1304
-rw-r--r--AUTHORS6
-rw-r--r--Makefile.am3
-rw-r--r--doc/ethereal.pod.template1
-rw-r--r--gtk/main.c3
-rw-r--r--packet-v120.c153
-rw-r--r--packet.c5
-rw-r--r--packet.h3
-rw-r--r--wiretap/Makefile.am5
-rw-r--r--wiretap/file.c11
-rw-r--r--wiretap/i4b_trace.h91
-rw-r--r--wiretap/i4btrace.c163
-rw-r--r--wiretap/i4btrace.h24
-rw-r--r--wiretap/wtap.c7
-rw-r--r--wiretap/wtap.h14
14 files changed, 477 insertions, 12 deletions
diff --git a/AUTHORS b/AUTHORS
index b4578def06..448af811a4 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -206,6 +206,12 @@ James Coe <jammer@cin.net> {
NCP over IP support
}
+Bert Driehuis <driehuis@playbeing.org> {
+ I4B (ISDN for BSD) wiretap module
+ V.120
+}
+
+
Alain Magloire <alainm@rcsm.ece.mcgill.ca> was kind enough to
give his permission to use his version of snprintf.c.
diff --git a/Makefile.am b/Makefile.am
index 2580952ed4..c2fdd9f092 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
# Makefile.am
# Automake file for Ethereal
#
-# $Id: Makefile.am,v 1.133 1999/12/12 05:11:44 gram Exp $
+# $Id: Makefile.am,v 1.134 1999/12/12 22:39:29 gram Exp $
#
# Ethereal - Network traffic analyzer
# By Gerald Combs <gerald@zing.org>
@@ -142,6 +142,7 @@ DISSECTOR_SOURCES = \
packet-tr.c \
packet-trmac.c \
packet-udp.c \
+ packet-v120.c \
packet-vines.c \
packet-vines.h \
packet-vlan.c \
diff --git a/doc/ethereal.pod.template b/doc/ethereal.pod.template
index c918db0264..c901b1e053 100644
--- a/doc/ethereal.pod.template
+++ b/doc/ethereal.pod.template
@@ -729,6 +729,7 @@ B<http://ethereal.zing.org>.
Jerry Talkington <jerryt@netapp.com>
Dave Chapeskie <dchapes@ddm.on.ca>
James Coe <jammer@cin.net>
+ Bert Driehuis <driehuis@playbeing.org>
Alain Magloire <alainm@rcsm.ece.mcgill.ca> was kind enough to give his
permission to use his version of snprintf.c.
diff --git a/gtk/main.c b/gtk/main.c
index 7777c7ddb2..3679266336 100644
--- a/gtk/main.c
+++ b/gtk/main.c
@@ -1,6 +1,6 @@
/* main.c
*
- * $Id: main.c,v 1.68 1999/12/10 06:44:39 gram Exp $
+ * $Id: main.c,v 1.69 1999/12/12 22:39:50 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -175,6 +175,7 @@ about_ethereal( GtkWidget *w, gpointer data ) {
"Jerry Talkington <jerryt@netapp.com>\n"
"Dave Chapeskie <dchapes@ddm.on.ca>\n"
"James Coe <jammer@cin.net>\n"
+ "Bert Driehuis <driehuis@playbeing.org>\n"
"\nSee http://ethereal.zing.org for more information",
VERSION, comp_info_str);
diff --git a/packet-v120.c b/packet-v120.c
new file mode 100644
index 0000000000..bc6c1bb0ef
--- /dev/null
+++ b/packet-v120.c
@@ -0,0 +1,153 @@
+/* packet-v120.c
+ * Routines for v120 frame disassembly
+ * Bert Driehuis <driehuis@playbeing.org>
+ *
+ * $Id: packet-v120.c,v 1.1 1999/12/12 22:39:29 gram Exp $
+ *
+ * Ethereal - Network traffic analyzer
+ * By Gerald Combs <gerald@zing.org>
+ * Copyright 1998
+ *
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
+#include <stdio.h>
+#include <glib.h>
+#include <string.h>
+#include "packet.h"
+#include "xdlc.h"
+
+#define FROM_DCE 0x80
+
+static int proto_v120 = -1;
+static int hf_v120_address = -1;
+static int hf_v120_control = -1;
+
+static gint ett_v120 = -1;
+static gint ett_v120_address = -1;
+static gint ett_v120_control = -1;
+
+void
+dissect_v120(const u_char *pd, frame_data *fd, proto_tree *tree)
+{
+ proto_tree *v120_tree, *ti, *tc, *address_tree;
+ int is_response;
+ int addr;
+ char info[80];
+ int v120len;
+
+ if (check_col(fd, COL_PROTOCOL))
+ col_add_str(fd, COL_PROTOCOL, "V.120");
+
+ if(check_col(fd, COL_RES_DL_SRC))
+ col_add_fstr(fd, COL_RES_DL_SRC, "0x%02X", pd[0]);
+ if ((pd[0] & 0x01) != 0x00 && (pd[1] && 0x01) != 0x01)
+ {
+ if (check_col(fd, COL_INFO))
+ col_add_str(fd, COL_INFO, "Invalid V.120 frame");
+ if (tree)
+ ti = proto_tree_add_item_format(tree, proto_v120, 0, fd->cap_len,
+ NULL, "Invalid V.120 frame");
+ return;
+ }
+
+ if (fd->pseudo_header.x25.flags & FROM_DCE) {
+ if(check_col(fd, COL_RES_DL_DST))
+ col_add_str(fd, COL_RES_DL_DST, "DTE");
+ if(check_col(fd, COL_RES_DL_SRC))
+ col_add_str(fd, COL_RES_DL_SRC, "DCE");
+ }
+ else {
+ if(check_col(fd, COL_RES_DL_DST))
+ col_add_str(fd, COL_RES_DL_DST, "DCE");
+ if(check_col(fd, COL_RES_DL_SRC))
+ col_add_str(fd, COL_RES_DL_SRC, "DTE");
+ }
+
+ if (((fd->pseudo_header.x25.flags & FROM_DCE) && pd[0] & 0x02) ||
+ (!(fd->pseudo_header.x25.flags & FROM_DCE) && !(pd[0] & 0x02)))
+ is_response = TRUE;
+ else
+ is_response = FALSE;
+
+ if (tree) {
+ if (fd->pkt_len <= 5)
+ v120len = fd->pkt_len;
+ else
+ v120len = 5;
+ ti = proto_tree_add_item_format(tree, proto_v120, 0, v120len, NULL,
+ "V.120");
+ v120_tree = proto_item_add_subtree(ti, ett_v120);
+ addr = pd[0] << 8 | pd[1];
+ sprintf(info, "LLI: %d C/R: %s",
+ ((pd[0] & 0xfc) << 5) | ((pd[1] & 0xfe) >> 1),
+ pd[0] & 0x02 ? "R" : "C");
+ tc = proto_tree_add_item_format(v120_tree, ett_v120_address,
+ 0, 2,
+ "Address field: %s (0x%02X)", info, addr);
+ address_tree = proto_item_add_subtree(tc, ett_v120_address);
+ proto_tree_add_text(address_tree, 0, 2,
+ decode_boolean_bitfield(addr, 0x0200, 2*8,
+ "Response", "Command"), NULL);
+ sprintf(info, "LLI: %d", ((pd[0] & 0xfc) << 5) | ((pd[1] & 0xfe) >> 1));
+ proto_tree_add_text(address_tree, 0, 2,
+ decode_numeric_bitfield(addr, 0xfcfe, 2*8, info));
+ proto_tree_add_text(address_tree, 0, 2,
+ decode_boolean_bitfield(addr, 0x0100, 2*8,
+ "EA0 = 1 (Error)", "EA0 = 0"), NULL);
+ proto_tree_add_text(address_tree, 0, 2,
+ decode_boolean_bitfield(addr, 0x01, 2*8,
+ "EA1 = 1", "EA1 = 0 (Error)"), NULL);
+ /* TODO: parse octets 4 & 5. Not that they're used in
+ practice, but it looks so professional. */
+ }
+ else
+ v120_tree = NULL;
+ dissect_xdlc_control(pd, 2, fd, v120_tree, hf_v120_control,
+ ett_v120_control, is_response, v120len == 3 ? FALSE : TRUE);
+
+ /* not end of frame ==> X.25 */
+}
+
+void
+proto_register_v120(void)
+{
+ static hf_register_info hf[] = {
+ { &hf_v120_address,
+ { "Link Address", "v120.address", FT_UINT16, BASE_HEX, NULL,
+ 0x0, "" }},
+ { &hf_v120_control,
+ { "Control Field", "v120.control", FT_STRING, BASE_NONE, NULL, 0x0,
+ "" }},
+ };
+ static gint *ett[] = {
+ &ett_v120,
+ &ett_v120_address,
+ &ett_v120_control,
+ };
+
+ proto_v120 = proto_register_protocol ("Async data over ISDN (V.120)", "v120");
+ proto_register_field_array (proto_v120, hf, array_length(hf));
+ proto_register_subtree_array(ett, array_length(ett));
+}
diff --git a/packet.c b/packet.c
index 5ffb41e656..65d6353a13 100644
--- a/packet.c
+++ b/packet.c
@@ -1,7 +1,7 @@
/* packet.c
* Routines for packet disassembly
*
- * $Id: packet.c,v 1.59 1999/12/12 05:11:45 gram Exp $
+ * $Id: packet.c,v 1.60 1999/12/12 22:39:29 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -852,6 +852,9 @@ dissect_packet(const u_char *pd, frame_data *fd, proto_tree *tree)
case WTAP_ENCAP_LAPD :
dissect_lapd(pd, fd, tree);
break;
+ case WTAP_ENCAP_V120 :
+ dissect_v120(pd, fd, tree);
+ break;
}
}
diff --git a/packet.h b/packet.h
index 10281ed2ed..3bae3ede62 100644
--- a/packet.h
+++ b/packet.h
@@ -1,7 +1,7 @@
/* packet.h
* Definitions for packet disassembly structures and routines
*
- * $Id: packet.h,v 1.161 1999/12/12 05:11:46 gram Exp $
+ * $Id: packet.h,v 1.162 1999/12/12 22:39:30 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -303,6 +303,7 @@ void dissect_lapd(const u_char *, frame_data *, proto_tree *);
void dissect_null(const u_char *, frame_data *, proto_tree *);
void dissect_ppp(const u_char *, frame_data *, proto_tree *);
void dissect_raw(const u_char *, frame_data *, proto_tree *);
+void dissect_v120(const u_char *, frame_data *, proto_tree *);
/*
* Routines in packet-*.c
diff --git a/wiretap/Makefile.am b/wiretap/Makefile.am
index ae80144818..70c31d82cc 100644
--- a/wiretap/Makefile.am
+++ b/wiretap/Makefile.am
@@ -1,7 +1,7 @@
# Makefile.am
# Automake file for Wiretap
#
-# $Id: Makefile.am,v 1.24 1999/10/31 17:46:04 gram Exp $
+# $Id: Makefile.am,v 1.25 1999/12/12 22:40:07 gram Exp $
#
# Ethereal - Network traffic analyzer
# By Gerald Combs <gerald@zing.org>
@@ -40,6 +40,9 @@ libwiretap_a_SOURCES = \
buffer.h \
file.c \
file.h \
+ i4btrace.c \
+ i4btrace.h \
+ i4b_trace.h \
iptrace.c \
iptrace.h \
lanalyzer.c \
diff --git a/wiretap/file.c b/wiretap/file.c
index eb255e401b..4335f955bd 100644
--- a/wiretap/file.c
+++ b/wiretap/file.c
@@ -1,6 +1,6 @@
/* file.c
*
- * $Id: file.c,v 1.40 1999/12/12 21:34:51 guy Exp $
+ * $Id: file.c,v 1.41 1999/12/12 22:40:08 gram Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
@@ -43,6 +43,7 @@
#include "netmon.h"
#include "netxray.h"
#include "toshiba.h"
+#include "i4btrace.h"
/* The open_file_* routines should return:
*
@@ -86,6 +87,7 @@ static int (*open_routines[])(wtap *, int *) = {
*/
ascend_open,
toshiba_open,
+ i4btrace_open,
};
int wtap_def_seek_read (FILE *fh, int seek_off, guint8 *pd, int len)
@@ -252,7 +254,12 @@ const static struct file_type_info {
/* WTAP_FILE_TOSHIBA */
{ "Toshiba Compact ISDN Router snoop trace", NULL,
- NULL, NULL }
+ NULL, NULL },
+
+ /* WTAP_FILE_I4BTRACE */
+ { "I4B ISDN trace", NULL,
+ NULL, NULL },
+
};
/* Name that should be somewhat descriptive. */
diff --git a/wiretap/i4b_trace.h b/wiretap/i4b_trace.h
new file mode 100644
index 0000000000..59684e1dd2
--- /dev/null
+++ b/wiretap/i4b_trace.h
@@ -0,0 +1,91 @@
+/*
+ * Copyright (c) 1997, 1999 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.
+ *
+ *---------------------------------------------------------------------------
+ *
+ * i4b_trace.h - header file for trace data read device
+ * ----------------------------------------------------
+ *
+ * $Id: i4b_trace.h,v 1.1 1999/12/12 22:40:09 gram Exp $
+ *
+ * last edit-date: [Sun Feb 14 10:39:26 1999]
+ *
+ *---------------------------------------------------------------------------*/
+
+#ifndef _I4B_TRACE_H_
+#define _I4B_TRACE_H_
+
+/*---------------------------------------------------------------------------*
+ * structure of the header at the beginning of every trace mbuf
+ *---------------------------------------------------------------------------*/
+typedef struct {
+ int length; /* length of the following mbuf */
+ int unit; /* controller unit number */
+ int type; /* type of channel */
+#define TRC_CH_I 0 /* Layer 1 INFO's */
+#define TRC_CH_D 1 /* D channel */
+#define TRC_CH_B1 2 /* B1 channel */
+#define TRC_CH_B2 3 /* B2 channel */
+ int dir; /* direction */
+#define FROM_TE 0 /* user -> network */
+#define FROM_NT 1 /* network -> user */
+ int trunc; /* # of truncated bytes (frame > MCLBYTES) */
+ unsigned int count; /* frame count for this unit/type */
+ struct timeval time; /* timestamp for this frame */
+} i4b_trace_hdr_t;
+
+#define INFO0 0 /* layer 1 */
+#define INFO1_8 1
+#define INFO1_10 2
+#define INFO2 3
+#define INFO3 4
+#define INFO4_8 5
+#define INFO4_10 6
+
+/*---------------------------------------------------------------------------*
+ * ioctl via /dev/i4btrc device(s):
+ * get/set current trace flag settings
+ *---------------------------------------------------------------------------*/
+
+#define I4B_TRC_GET _IOR('T', 0, int) /* get trace settings */
+#define I4B_TRC_SET _IOW('T', 1, int) /* set trace settings */
+
+#define TRACE_OFF 0x00 /* tracing off */
+#define TRACE_I 0x01 /* trace L1 INFO's on */
+#define TRACE_D_TX 0x02 /* trace D channel on */
+#define TRACE_D_RX 0x04 /* trace D channel on */
+#define TRACE_B_TX 0x08 /* trace B channel on */
+#define TRACE_B_RX 0x10 /* trace B channel on */
+
+typedef struct {
+ int rxunit; /* unit # for rx frames */
+ int rxflags; /* d and/or b channel */
+ int txunit; /* unit # for tx frames */
+ int txflags; /* d and/or b channel */
+} i4b_trace_setupa_t;
+
+#define I4B_TRC_SETA _IOW('T', 2, i4b_trace_setupa_t) /* set analyze mode */
+#define I4B_TRC_RESETA _IOW('T', 3, int) /* reset analyze mode */
+
+#endif /* _I4B_TRACE_H_ */
diff --git a/wiretap/i4btrace.c b/wiretap/i4btrace.c
new file mode 100644
index 0000000000..2445b9c490
--- /dev/null
+++ b/wiretap/i4btrace.c
@@ -0,0 +1,163 @@
+/* i4btrace.c
+ *
+ * $Id: i4btrace.c,v 1.1 1999/12/12 22:40:09 gram Exp $
+ *
+ * Wiretap Library
+ * Copyright (c) 1999 by Bert Driehuis <driehuis@playbeing.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <errno.h>
+#include <time.h>
+#include "wtap.h"
+#include "file.h"
+#include "buffer.h"
+#include "i4b_trace.h"
+
+static int i4btrace_read(wtap *wth, int *err);
+
+int i4btrace_open(wtap *wth, int *err)
+{
+ int bytes_read;
+ i4b_trace_hdr_t hdr;
+
+ /* I4B trace files have no magic in the header... Sigh */
+ file_seek(wth->fh, 0, SEEK_SET);
+ errno = WTAP_ERR_CANT_READ;
+ bytes_read = file_read(&hdr, 1, sizeof(hdr), wth->fh);
+ if (bytes_read != sizeof(hdr)) {
+ *err = file_error(wth->fh);
+ if (*err != 0)
+ return -1;
+ return 0;
+ }
+
+ /* Silly heuristic... */
+ if ((unsigned)hdr.length < 3 || (unsigned)hdr.unit > 4 ||
+ (unsigned)hdr.type > 4 || (unsigned)hdr.dir > 2 ||
+ (unsigned)hdr.trunc > 2048)
+ return 0;
+
+ file_seek(wth->fh, 0, SEEK_SET);
+ wth->data_offset = 0;
+
+ /* Get capture start time */
+
+ wth->file_type = WTAP_FILE_I4BTRACE;
+ wth->capture.i4btrace = g_malloc(sizeof(i4btrace_t));
+ wth->subtype_read = i4btrace_read;
+ wth->snapshot_length = 2048; /* actual length set per packet */
+
+ wth->capture.i4btrace->start = hdr.time.tv_sec;
+ wth->capture.i4btrace->bchannel_prot[0] = -1;
+ wth->capture.i4btrace->bchannel_prot[1] = -1;
+
+ wth->file_encap = WTAP_ENCAP_PER_PACKET;
+
+ return 1;
+}
+
+#define V120SABME "\010\001\177"
+
+/* Read the next packet */
+static int i4btrace_read(wtap *wth, int *err)
+{
+ int bytes_read;
+ i4b_trace_hdr_t hdr;
+ guint16 length;
+ int data_offset;
+ void *bufp;
+
+ /* Read record header. */
+ errno = WTAP_ERR_CANT_READ;
+ bytes_read = file_read(&hdr, 1, sizeof hdr, wth->fh);
+ if (bytes_read != sizeof hdr) {
+ *err = file_error(wth->fh);
+ if (*err != 0)
+ return -1;
+ if (bytes_read != 0) {
+ *err = WTAP_ERR_SHORT_READ;
+ return -1;
+ }
+ return 0;
+ }
+ wth->data_offset += sizeof hdr;
+ length = pletohs(&hdr.length) - sizeof(hdr);
+ if (length == 0) return 0;
+
+ wth->phdr.len = length;
+ wth->phdr.caplen = length;
+
+ wth->phdr.ts.tv_sec = hdr.time.tv_sec;
+ wth->phdr.ts.tv_usec = hdr.time.tv_usec;
+
+ wth->phdr.pseudo_header.x25.flags = (hdr.dir == FROM_TE) ? 0x00 : 0x80;
+
+ /*
+ * Read the packet data.
+ */
+ buffer_assure_space(wth->frame_buffer, length);
+ data_offset = wth->data_offset;
+ errno = WTAP_ERR_CANT_READ;
+ bufp = buffer_start_ptr(wth->frame_buffer);
+ bytes_read = file_read(bufp, 1, length, wth->fh);
+
+ if (bytes_read != length) {
+ *err = file_error(wth->fh);
+ if (*err == 0)
+ *err = WTAP_ERR_SHORT_READ;
+ return -1;
+ }
+ wth->data_offset += length;
+
+ /*
+ * This heuristic tries to figure out whether the datastream is
+ * V.120 or not. We cannot glean this from the Q.931 SETUP message,
+ * because no commercial V.120 implementation I've seen actually
+ * sets the V.120 protocol discriminator (that, or I'm misreading
+ * the spec badly).
+ * TODO: reset the flag to -1 (unknown) after a close on the B
+ * channel is detected.
+ */
+ if (hdr.type == TRC_CH_B1 || hdr.type == TRC_CH_B2) {
+ int channel = hdr.type - TRC_CH_B1;
+ if (wth->capture.i4btrace->bchannel_prot[channel] == -1) {
+ if (memcmp(bufp, V120SABME, 3) == 0)
+ wth->capture.i4btrace->bchannel_prot[channel] = 1;
+ else
+ wth->capture.i4btrace->bchannel_prot[channel] = 0;
+ }
+ }
+
+ if (hdr.type == TRC_CH_I) {
+ wth->phdr.pkt_encap = WTAP_ENCAP_NULL;
+ } else if (hdr.type == TRC_CH_D) {
+ wth->phdr.pkt_encap = WTAP_ENCAP_LAPD;
+ } else {
+ int channel = hdr.type - TRC_CH_B1;
+ if (wth->capture.i4btrace->bchannel_prot[channel] == 1)
+ wth->phdr.pkt_encap = WTAP_ENCAP_V120;
+ else
+ wth->phdr.pkt_encap = WTAP_ENCAP_NULL;
+ }
+
+ return data_offset;
+}
diff --git a/wiretap/i4btrace.h b/wiretap/i4btrace.h
new file mode 100644
index 0000000000..ca5ca7b1cd
--- /dev/null
+++ b/wiretap/i4btrace.h
@@ -0,0 +1,24 @@
+/* i4btrace.h
+ *
+ * $Id: i4btrace.h,v 1.1 1999/12/12 22:40:09 gram Exp $
+ *
+ * Wiretap Library
+ * Copyright (c) 1999 by Bert Driehuis <driehuis@playbeing.org>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *
+ */
+
+int i4btrace_open(wtap *wth, int *err);
diff --git a/wiretap/wtap.c b/wiretap/wtap.c
index 43b59d652e..8da06ce1c5 100644
--- a/wiretap/wtap.c
+++ b/wiretap/wtap.c
@@ -1,6 +1,6 @@
/* wtap.c
*
- * $Id: wtap.c,v 1.33 1999/12/05 01:24:53 guy Exp $
+ * $Id: wtap.c,v 1.34 1999/12/12 22:40:10 gram Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
@@ -108,7 +108,10 @@ const static struct encap_type_info {
{ "Lucent/Ascend access equipment", "ascend" },
/* WTAP_ENCAP_LAPD */
- { "LAPD", "lapd" }
+ { "LAPD", "lapd" },
+
+ /* WTAP_ENCAP_V120 */
+ { "V120", "v120" },
};
/* Name that should be somewhat descriptive. */
diff --git a/wiretap/wtap.h b/wiretap/wtap.h
index e6265a146d..1c4850094b 100644
--- a/wiretap/wtap.h
+++ b/wiretap/wtap.h
@@ -1,6 +1,6 @@
/* wtap.h
*
- * $Id: wtap.h,v 1.57 1999/12/11 10:02:13 guy Exp $
+ * $Id: wtap.h,v 1.58 1999/12/12 22:40:10 gram Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
@@ -92,9 +92,10 @@
#define WTAP_ENCAP_NULL 13
#define WTAP_ENCAP_ASCEND 14
#define WTAP_ENCAP_LAPD 15
+#define WTAP_ENCAP_V120 16
/* last WTAP_ENCAP_ value + 1 */
-#define WTAP_NUM_ENCAP_TYPES 16
+#define WTAP_NUM_ENCAP_TYPES 17
/* File types that can be read by wiretap.
We may eventually support writing some or all of these file types,
@@ -118,9 +119,10 @@
#define WTAP_FILE_ASCEND 16
#define WTAP_FILE_NETTL 17
#define WTAP_FILE_TOSHIBA 18
+#define WTAP_FILE_I4BTRACE 19
/* last WTAP_FILE_ value + 1 */
-#define WTAP_NUM_FILE_TYPES 19
+#define WTAP_NUM_FILE_TYPES 20
/*
* Maximum packet size we'll support.
@@ -159,6 +161,11 @@ typedef struct {
typedef struct {
time_t start;
+ int bchannel_prot[2]; /* For the V.120 heuristic */
+} i4btrace_t;
+
+typedef struct {
+ time_t start;
} nettl_t;
typedef struct {
@@ -326,6 +333,7 @@ typedef struct wtap {
lanalyzer_t *lanalyzer;
ngsniffer_t *ngsniffer;
radcom_t *radcom;
+ i4btrace_t *i4btrace;
nettl_t *nettl;
netmon_t *netmon;
netxray_t *netxray;