aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am3
-rw-r--r--packet-lapd.c154
-rw-r--r--packet.c5
-rw-r--r--packet.h5
-rw-r--r--wiretap/toshiba.c16
-rw-r--r--wiretap/wtap.h17
6 files changed, 184 insertions, 16 deletions
diff --git a/Makefile.am b/Makefile.am
index 0024f746dc..29a5c47f40 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
# Makefile.am
# Automake file for Ethereal
#
-# $Id: Makefile.am,v 1.102 1999/11/10 17:23:53 nneul Exp $
+# $Id: Makefile.am,v 1.103 1999/11/11 05:36:04 gram Exp $
#
# Ethereal - Network traffic analyzer
# By Gerald Combs <gerald@zing.org>
@@ -70,6 +70,7 @@ DISSECTOR_SOURCES = \
packet-ipx.h \
packet-isakmp.c\
packet-lapb.c \
+ packet-lapd.c \
packet-llc.c \
packet-lpd.c \
packet-nbipx.c \
diff --git a/packet-lapd.c b/packet-lapd.c
new file mode 100644
index 0000000000..a0b98e9fe1
--- /dev/null
+++ b/packet-lapd.c
@@ -0,0 +1,154 @@
+/* packet-lapd.c
+ * Routines for LAPD frame disassembly
+ * Gilbert Ramirez <gram@xiexie.org>
+ *
+ * $Id: packet-lapd.c,v 1.1 1999/11/11 05:36:05 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"
+
+/* ISDN/LAPD references:
+ *
+ * http://www.cisco.com/univercd/cc/td/doc/cisintwk/ito_doc/isdn.htm
+ * http://www.ece.wpi.edu/courses/ee535/hwk11cd95/agrebe/agrebe.html
+ * http://www.acacia-net.com/Clarinet/Protocol/q9213o84.htm
+ */
+
+int proto_lapd = -1;
+int hf_lapd_address = -1;
+int hf_lapd_sapi = -1;
+int hf_lapd_cr = -1;
+int hf_lapd_ea1 = -1;
+int hf_lapd_tei = -1;
+int hf_lapd_ea2 = -1;
+int hf_lapd_control = -1;
+
+static const value_string lapd_sapi_vals[] = {
+ { 0, "Q.931 Call control procedure" },
+ { 1, "Packet mode Q.931 Call control procedure" },
+ { 16, "X.25 Level 3 procedures" },
+ { 63, "Layer 2 management procedures" },
+ { 0, NULL }
+};
+
+void
+dissect_lapd(const u_char *pd, frame_data *fd, proto_tree *tree)
+{
+ proto_tree *lapd_tree, *addr_tree;
+ proto_item *ti;
+
+ guint16 address, cr;
+
+ gboolean is_response;
+
+ if (check_col(fd, COL_PROTOCOL))
+ col_add_str(fd, COL_PROTOCOL, "LAPD");
+
+ address = pntohs(&pd[0]);
+ cr = address & 0x0200;
+
+ if (fd->pseudo_header.lapd.from_network_to_user) {
+ is_response = cr ? FALSE : TRUE;
+ if(check_col(fd, COL_RES_DL_DST))
+ col_add_str(fd, COL_RES_DL_DST, "User");
+ if(check_col(fd, COL_RES_DL_SRC))
+ col_add_str(fd, COL_RES_DL_SRC, "Network");
+ }
+ else {
+ is_response = cr ? TRUE : FALSE;
+ if(check_col(fd, COL_RES_DL_DST))
+ col_add_str(fd, COL_RES_DL_DST, "Network");
+ if(check_col(fd, COL_RES_DL_SRC))
+ col_add_str(fd, COL_RES_DL_SRC, "User");
+ }
+
+
+ if (tree) {
+ ti = proto_tree_add_item(tree, proto_lapd, 0, 3, NULL);
+ lapd_tree = proto_item_add_subtree(ti, ETT_LAPD);
+
+ ti = proto_tree_add_item(lapd_tree, hf_lapd_address, 0, 2, address);
+ addr_tree = proto_item_add_subtree(ti, ETT_LAPD_ADDRESS);
+
+ proto_tree_add_item(addr_tree, hf_lapd_sapi, 0, 1, address);
+ proto_tree_add_item(addr_tree, hf_lapd_cr, 0, 1, address);
+ proto_tree_add_item(addr_tree, hf_lapd_ea1, 0, 1, address);
+ proto_tree_add_item(addr_tree, hf_lapd_tei, 1, 1, address);
+ proto_tree_add_item(addr_tree, hf_lapd_ea2, 1, 1, address);
+ }
+ else {
+ lapd_tree = NULL;
+ }
+
+ dissect_xdlc_control(pd, 2, fd, lapd_tree, hf_lapd_control, is_response, TRUE);
+
+ /* call next protocol */
+}
+
+void
+proto_register_lapd(void)
+{
+ static hf_register_info hf[] = {
+ { &hf_lapd_address,
+ { "Address Field", "lapd.address", FT_UINT16, BASE_HEX, NULL, 0x0,
+ "" }},
+
+ { &hf_lapd_sapi,
+ { "SAPI", "lapd.sapi", FT_UINT16, BASE_DEC, VALS(lapd_sapi_vals), 0xfc00,
+ "Service Access Point Identifier" }},
+
+ { &hf_lapd_cr,
+ { "C/R", "lapd.cr", FT_UINT16, BASE_DEC, NULL, 0x0200,
+ "Command/Response bit" }},
+
+ { &hf_lapd_ea1,
+ { "EA1", "lapd.ea1", FT_UINT16, BASE_DEC, NULL, 0x0100,
+ "First Address Extension bit" }},
+
+ { &hf_lapd_tei,
+ { "TEI", "lapd.tei", FT_UINT16, BASE_DEC, NULL, 0x00fe,
+ "Terminal Endpoint Identifier" }},
+
+ { &hf_lapd_ea2,
+ { "EA2", "lapd.ea2", FT_UINT16, BASE_DEC, NULL, 0x0001,
+ "Second Address Extension bit" }},
+
+ { &hf_lapd_control,
+ { "Control Field", "lapd.control", FT_UINT16, BASE_HEX, NULL, 0x0,
+ "" }},
+ };
+
+ proto_lapd = proto_register_protocol ("Link Access Procedure, Channel D (LAPD)", "lapd");
+ proto_register_field_array (proto_lapd, hf, array_length(hf));
+}
diff --git a/packet.c b/packet.c
index f14880d56f..8fda40492a 100644
--- a/packet.c
+++ b/packet.c
@@ -1,7 +1,7 @@
/* packet.c
* Routines for packet disassembly
*
- * $Id: packet.c,v 1.52 1999/10/29 02:25:54 guy Exp $
+ * $Id: packet.c,v 1.53 1999/11/11 05:36:05 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -803,6 +803,9 @@ dissect_packet(const u_char *pd, frame_data *fd, proto_tree *tree)
case WTAP_ENCAP_ASCEND :
dissect_ascend(pd, fd, tree);
break;
+ case WTAP_ENCAP_LAPD :
+ dissect_lapd(pd, fd, tree);
+ break;
}
}
diff --git a/packet.h b/packet.h
index f466ec9636..3515596483 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.132 1999/11/10 18:32:55 gram Exp $
+ * $Id: packet.h,v 1.133 1999/11/11 05:36:05 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -412,6 +412,8 @@ enum {
ETT_RADIUS,
ETT_RADIUS_AVP,
ETT_LAPB,
+ ETT_LAPD,
+ ETT_LAPD_ADDRESS,
ETT_X25,
ETT_XDLC_CONTROL,
ETT_ATM,
@@ -539,6 +541,7 @@ void dissect_ascend(const u_char *, frame_data *, proto_tree *);
void dissect_atm(const u_char *, frame_data *, proto_tree *);
void dissect_clip(const u_char *, frame_data *, proto_tree *);
void dissect_lapb(const u_char *, frame_data *, proto_tree *);
+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 *);
diff --git a/wiretap/toshiba.c b/wiretap/toshiba.c
index 8b977f429c..cb4e045433 100644
--- a/wiretap/toshiba.c
+++ b/wiretap/toshiba.c
@@ -1,6 +1,6 @@
/* toshiba.c
*
- * $Id: toshiba.c,v 1.1 1999/10/31 17:46:08 gram Exp $
+ * $Id: toshiba.c,v 1.2 1999/11/11 05:36:15 gram Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@xiexie.org>
@@ -257,7 +257,7 @@ parse_toshiba_rec_hdr(wtap *wth, FILE *fh, int *err)
char line[TOSHIBA_LINE_LENGTH];
int num_items_scanned;
int pkt_len, pktnum, hr, min, sec, csec;
- char channel[10];
+ char channel[10], direction[10];
/* Our file pointer should be on the line containing the
* summary information for a packet. Read in that line and
@@ -271,10 +271,10 @@ parse_toshiba_rec_hdr(wtap *wth, FILE *fh, int *err)
return -1;
}
- num_items_scanned = sscanf(line, "[No.%d] %d:%d:%d.%d %s:",
- &pktnum, &hr, &min, &sec, &csec, channel);
+ num_items_scanned = sscanf(line, "[No.%d] %d:%d:%d.%d %s %s",
+ &pktnum, &hr, &min, &sec, &csec, channel, direction);
- if (num_items_scanned != 6) {
+ if (num_items_scanned != 7) {
*err = WTAP_ERR_BAD_RECORD;
return -1;
}
@@ -306,9 +306,9 @@ parse_toshiba_rec_hdr(wtap *wth, FILE *fh, int *err)
break;
case 'D':
- /*wth->phdr.pkt_encap = WTAP_ENCAP_LAPD;*/
- /*wth->phdr.pkt_encap = WTAP_ENCAP_ISDN;*/
- wth->phdr.pkt_encap = WTAP_ENCAP_UNKNOWN;
+ wth->phdr.pkt_encap = WTAP_ENCAP_LAPD;
+ wth->phdr.pseudo_header.lapd.from_network_to_user =
+ (direction[0] == 'R' ? TRUE : FALSE );
break;
default:
diff --git a/wiretap/wtap.h b/wiretap/wtap.h
index 269be246c0..21eba2253a 100644
--- a/wiretap/wtap.h
+++ b/wiretap/wtap.h
@@ -1,6 +1,6 @@
/* wtap.h
*
- * $Id: wtap.h,v 1.48 1999/11/06 10:31:46 guy Exp $
+ * $Id: wtap.h,v 1.49 1999/11/11 05:36:16 gram Exp $
*
* Wiretap Library
* Copyright (c) 1998 by Gilbert Ramirez <gram@verdict.uthscsa.edu>
@@ -91,9 +91,10 @@
#define WTAP_ENCAP_ATM_SNIFFER 12
#define WTAP_ENCAP_NULL 13
#define WTAP_ENCAP_ASCEND 14
+#define WTAP_ENCAP_LAPD 15
/* last WTAP_ENCAP_ value + 1 */
-#define WTAP_NUM_ENCAP_TYPES 15
+#define WTAP_NUM_ENCAP_TYPES 16
/* File types that can be read by wiretap.
We may eventually support writing some or all of these file types,
@@ -224,6 +225,11 @@ struct ascend_phdr {
guint32 task; /* Task number */
};
+/* Packet "pseudo-header" information for LAPD capture files. */
+struct lapd_phdr {
+ gboolean from_network_to_user;
+};
+
/*
* Bits in AppTrafType.
*
@@ -277,9 +283,10 @@ struct ascend_phdr {
#define AHLT_VCMX_BPDU 0xe /* VCMX: BPDU */
union pseudo_header {
- struct x25_phdr x25;
- struct ngsniffer_atm_phdr ngsniffer_atm;
- struct ascend_phdr ascend;
+ struct x25_phdr x25;
+ struct ngsniffer_atm_phdr ngsniffer_atm;
+ struct ascend_phdr ascend;
+ struct lapd_phdr lapd;
};
struct wtap_pkthdr {