Added Bert Driehuis <driehuis@playbeing.org>'s I4B wiretap module
authorgram <gram@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 12 Dec 1999 22:40:10 +0000 (22:40 +0000)
committergram <gram@f5534014-38df-0310-8fa8-9805f1628bb7>
Sun, 12 Dec 1999 22:40:10 +0000 (22:40 +0000)
and V.120 decoder.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@1304 f5534014-38df-0310-8fa8-9805f1628bb7

14 files changed:
AUTHORS
Makefile.am
doc/ethereal.pod.template
gtk/main.c
packet-v120.c [new file with mode: 0644]
packet.c
packet.h
wiretap/Makefile.am
wiretap/file.c
wiretap/i4b_trace.h [new file with mode: 0644]
wiretap/i4btrace.c [new file with mode: 0644]
wiretap/i4btrace.h [new file with mode: 0644]
wiretap/wtap.c
wiretap/wtap.h

diff --git a/AUTHORS b/AUTHORS
index b4578def06ef754bbe1f3480d805a01a434b2ff7..448af811a400c5c6546b9e60806bfb2b5515892b 100644 (file)
--- 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.
 
index 2580952ed49c1580e664c4ca68460cc099cc98b1..c2fdd9f0929cb96fedb5dd1a307e6128bc41072b 100644 (file)
@@ -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 \
index c918db0264c9e0f76c34020a8e761f2aea645538..c901b1e0534aa471128edd5f32f031e07a57617e 100644 (file)
@@ -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.
index 7777c7ddb230b932003a43176ce7b80d53a6d50f..367926633628c24f7c7144781c9f1a1758c64567 100644 (file)
@@ -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 (file)
index 0000000..bc6c1bb
--- /dev/null
@@ -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));
+}
index 5ffb41e6563e9231a9ee276da2db389947afc77a..65d6353a137ecacc3c1ad649e8233cc375783af5 100644 (file)
--- 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;
        }
 }
 
index 10281ed2edc670a0c5fcff0510752e29989b4c70..3bae3ede62a3cb7b9f024125368959aae630cf37 100644 (file)
--- 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
index ae8014481829929ebd8987022ad64fb4229212d9..70c31d82ccfba57c96d5a2e8dc18b04daa74a478 100644 (file)
@@ -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             \
index eb255e401b36007d6e38d557be891947169a9406..4335f955bdb7e5b813c29eb8623ecfdd1e8c8579 100644 (file)
@@ -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 (file)
index 0000000..59684e1
--- /dev/null
@@ -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 (file)
index 0000000..2445b9c
--- /dev/null
@@ -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 (file)
index 0000000..ca5ca7b
--- /dev/null
@@ -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);
index 43b59d652eb42b82d8f0cb8ce6d521e6e3532eae..8da06ce1c58d85dacc552c1a3c6417f5d82b416d 100644 (file)
@@ -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. */
index e6265a146dde710dbc5619ddba150a35b1f0e870..1c4850094b4893e2e1f69a87685de7bf04e7a664 100644 (file)
@@ -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>
 #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,
 #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.
@@ -157,6 +159,11 @@ typedef struct {
        time_t  start;
 } radcom_t;
 
+typedef struct {
+       time_t  start;
+       int bchannel_prot[2];   /* For the V.120 heuristic */
+} i4btrace_t;
+
 typedef struct {
        time_t  start;
 } nettl_t;
@@ -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;