aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile.am3
-rw-r--r--gtk/dfilter_expr_dlg.c49
-rw-r--r--packet-lapb.c12
-rw-r--r--packet-x25.c256
-rw-r--r--packet-x25.h30
-rw-r--r--packet-xot.c12
6 files changed, 145 insertions, 217 deletions
diff --git a/Makefile.am b/Makefile.am
index 1d9734a5f7..56e85860ad 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
# Makefile.am
# Automake file for Ethereal
#
-# $Id: Makefile.am,v 1.282 2001/02/08 07:08:04 guy Exp $
+# $Id: Makefile.am,v 1.283 2001/02/12 09:06:17 guy Exp $
#
# Ethereal - Network traffic analyzer
# By Gerald Combs <gerald@zing.org>
@@ -303,7 +303,6 @@ noinst_HEADERS = \
packet-x11-declarations.h \
packet-x11-register-info.h \
packet-x11-keysym.h \
- packet-x25.h \
packet-yhoo.h \
packet-ypbind.h \
packet-ypserv.h \
diff --git a/gtk/dfilter_expr_dlg.c b/gtk/dfilter_expr_dlg.c
index ea1109ce78..ed45cdf579 100644
--- a/gtk/dfilter_expr_dlg.c
+++ b/gtk/dfilter_expr_dlg.c
@@ -7,7 +7,7 @@
* Copyright 2000, Jeffrey C. Foster<jfoste@woodward.com> and
* Guy Harris <guy@alum.mit.edu>
*
- * $Id: dfilter_expr_dlg.c,v 1.10 2001/02/01 22:40:49 guy Exp $
+ * $Id: dfilter_expr_dlg.c,v 1.11 2001/02/12 09:06:19 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -1002,21 +1002,38 @@ dfilter_expr_dlg_new(GtkWidget *filter_te)
len = proto_registrar_n();
for (i = 0; i < len; i++) {
- if (!proto_registrar_is_protocol(i)) {
- hfinfo = proto_registrar_get_nth(i);
-
- /* Create a node for the item, and put it
- under its parent protocol. */
- protocol_node = g_hash_table_lookup(proto_array,
- (gpointer)proto_registrar_get_parent(i));
- item_node = gtk_ctree_insert_node(GTK_CTREE(tree),
- protocol_node, NULL,
- &hfinfo->name, 5,
- NULL, NULL, NULL, NULL,
- FALSE, FALSE);
- gtk_ctree_node_set_row_data(GTK_CTREE(tree),
- item_node, hfinfo);
- }
+ /*
+ * If this field is a protocol, skip it - we already put
+ * it in above.
+ */
+ if (proto_registrar_is_protocol(i))
+ continue;
+
+ hfinfo = proto_registrar_get_nth(i);
+
+ /*
+ * If there's another field with the same name as this
+ * one, skip it - all fields with the same name should
+ * have the same type/radix/value list, they would
+ * just have different bit masks. (If a field isn't
+ * a bitfield, but can be, say, 1 or 2 bytes long,
+ * it can just be made FT_UINT16, meaning the *maximum*
+ * length is 2 bytes.)
+ */
+ if (hfinfo->same_name != NULL)
+ continue;
+
+ /* Create a node for the item, and put it
+ under its parent protocol. */
+ protocol_node = g_hash_table_lookup(proto_array,
+ (gpointer)proto_registrar_get_parent(i));
+ item_node = gtk_ctree_insert_node(GTK_CTREE(tree),
+ protocol_node, NULL,
+ &hfinfo->name, 5,
+ NULL, NULL, NULL, NULL,
+ FALSE, FALSE);
+ gtk_ctree_node_set_row_data(GTK_CTREE(tree),
+ item_node, hfinfo);
}
g_hash_table_destroy(proto_array);
diff --git a/packet-lapb.c b/packet-lapb.c
index 921155ba89..fe540bfff0 100644
--- a/packet-lapb.c
+++ b/packet-lapb.c
@@ -2,7 +2,7 @@
* Routines for lapb frame disassembly
* Olivier Abad <oabad@cybercable.fr>
*
- * $Id: packet-lapb.c,v 1.28 2001/01/22 00:20:29 guy Exp $
+ * $Id: packet-lapb.c,v 1.29 2001/02/12 09:06:17 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -36,7 +36,6 @@
#include <glib.h>
#include <string.h>
#include "packet.h"
-#include "packet-x25.h"
#include "xdlc.h"
#define FROM_DCE 0x80
@@ -48,6 +47,8 @@ static int hf_lapb_control = -1;
static gint ett_lapb = -1;
static gint ett_lapb_control = -1;
+static dissector_handle_t x25_handle;
+
static void
dissect_lapb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
@@ -108,7 +109,7 @@ dissect_lapb(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/* not end of frame ==> X.25 */
if (tvb_length(tvb) > 2) {
next_tvb = tvb_new_subset(tvb, 2, -1, -1);
- dissect_x25(next_tvb, pinfo, tree);
+ call_dissector(x25_handle, next_tvb, pinfo, tree);
}
}
@@ -140,5 +141,10 @@ proto_register_lapb(void)
void
proto_reg_handoff_lapb(void)
{
+ /*
+ * Get a handle for the X.25 dissector.
+ */
+ x25_handle = find_dissector("x.25");
+
dissector_add("wtap_encap", WTAP_ENCAP_LAPB, dissect_lapb, proto_lapb);
}
diff --git a/packet-x25.c b/packet-x25.c
index adc83cdf95..a0f1b70cc5 100644
--- a/packet-x25.c
+++ b/packet-x25.c
@@ -2,7 +2,7 @@
* Routines for x25 packet disassembly
* Olivier Abad <oabad@cybercable.fr>
*
- * $Id: packet-x25.c,v 1.45 2001/01/09 06:31:45 guy Exp $
+ * $Id: packet-x25.c,v 1.46 2001/02/12 09:06:17 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -39,7 +39,6 @@
#include "etypes.h"
#include "llcsaps.h"
#include "packet.h"
-#include "packet-x25.h"
#include "packet-ip.h"
#include "packet-osi.h"
#include "nlpid.h"
@@ -99,20 +98,12 @@ static int hf_x25_dbit = -1;
static int hf_x25_mod = -1;
static int hf_x25_lcn = -1;
static int hf_x25_type = -1;
-static int hf_x25_p_r = -1;
-static int hf_x25_mbit = -1;
-static int hf_x25_p_s = -1;
-static int proto_ex25 = -1;
-static int hf_ex25_gfi = -1;
-static int hf_ex25_abit = -1;
-static int hf_ex25_qbit = -1;
-static int hf_ex25_dbit = -1;
-static int hf_ex25_mod = -1;
-static int hf_ex25_lcn = -1;
-static int hf_ex25_type = -1;
-static int hf_ex25_p_r = -1;
-static int hf_ex25_mbit = -1;
-static int hf_ex25_p_s = -1;
+static int hf_x25_p_r_mod8 = -1;
+static int hf_x25_p_r_mod128 = -1;
+static int hf_x25_mbit_mod8 = -1;
+static int hf_x25_mbit_mod128 = -1;
+static int hf_x25_p_s_mod8 = -1;
+static int hf_x25_p_s_mod128 = -1;
static gint ett_x25 = -1;
static gint ett_x25_gfi = -1;
@@ -1394,7 +1385,7 @@ static const value_string sharing_strategy_vals[] = {
{0x00, NULL}
};
-void
+static void
dissect_x25(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_tree *x25_tree=0, *gfi_tree=0;
@@ -1409,8 +1400,6 @@ dissect_x25(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
guint8 pkt_type;
tvbuff_t *next_tvb;
- pinfo->current_proto = "X.25";
-
if (check_col(pinfo->fd, COL_PROTOCOL))
col_set_str(pinfo->fd, COL_PROTOCOL, "X.25");
@@ -1419,12 +1408,6 @@ dissect_x25(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
modulo = ((bytes0_1 & 0x2000) ? 128 : 8);
vc = (int)(bytes0_1 & 0x0FFF);
- if (modulo == 8) {
- CHECK_DISPLAY_AS_DATA(proto_x25, tvb, pinfo, tree);
- } else {
- CHECK_DISPLAY_AS_DATA(proto_ex25, tvb, pinfo, tree);
- }
-
if (bytes0_1 & 0x8000) toa = TRUE;
else toa = FALSE;
@@ -1434,8 +1417,7 @@ dissect_x25(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if (check_col(pinfo->fd, COL_INFO))
col_set_str(pinfo->fd, COL_INFO, "Invalid/short X.25 packet");
if (tree)
- proto_tree_add_protocol_format(tree,
- (modulo == 8 ? proto_x25 : proto_ex25), tvb, 0,
+ proto_tree_add_protocol_format(tree, proto_x25, tvb, 0,
tvb_length(tvb), "Invalid/short X.25 packet");
return;
}
@@ -1443,31 +1425,24 @@ dissect_x25(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
pkt_type = tvb_get_guint8(tvb, 2);
if (tree) {
- ti = proto_tree_add_protocol_format(tree,
- (modulo == 8) ? proto_x25 : proto_ex25, tvb, 0, x25_pkt_len,
- "X.25");
+ ti = proto_tree_add_item(tree, proto_x25, tvb, 0, x25_pkt_len, FALSE);
x25_tree = proto_item_add_subtree(ti, ett_x25);
- ti = proto_tree_add_item(x25_tree,
- (modulo == 8) ? hf_x25_gfi : hf_ex25_gfi, tvb, 0, 2, FALSE);
+ ti = proto_tree_add_item(x25_tree, hf_x25_gfi, tvb, 0, 2, FALSE);
gfi_tree = proto_item_add_subtree(ti, ett_x25_gfi);
if ((pkt_type & 0x01) == X25_DATA)
- proto_tree_add_boolean(gfi_tree,
- (modulo == 8) ? hf_x25_qbit : hf_ex25_qbit, tvb, 0, 2,
+ proto_tree_add_boolean(gfi_tree, hf_x25_qbit, tvb, 0, 2,
bytes0_1);
else if (pkt_type == X25_CALL_REQUEST ||
pkt_type == X25_CALL_ACCEPTED ||
pkt_type == X25_CLEAR_REQUEST ||
pkt_type == X25_CLEAR_CONFIRMATION)
- proto_tree_add_boolean(gfi_tree,
- (modulo == 8) ? hf_x25_abit : hf_ex25_abit, tvb, 0, 2,
+ proto_tree_add_boolean(gfi_tree, hf_x25_abit, tvb, 0, 2,
bytes0_1);
if (pkt_type == X25_CALL_REQUEST || pkt_type == X25_CALL_ACCEPTED ||
(pkt_type & 0x01) == X25_DATA)
- proto_tree_add_boolean(gfi_tree,
- (modulo == 8) ? hf_x25_dbit : hf_ex25_dbit, tvb, 0, 2,
+ proto_tree_add_boolean(gfi_tree, hf_x25_dbit, tvb, 0, 2,
bytes0_1);
- proto_tree_add_uint(gfi_tree, (modulo == 8) ? hf_x25_mod : hf_ex25_mod,
- tvb, 0, 2, bytes0_1);
+ proto_tree_add_uint(gfi_tree, hf_x25_mod, tvb, 0, 2, bytes0_1);
}
switch (pkt_type) {
@@ -1478,11 +1453,9 @@ dissect_x25(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
: "Call req." ,
vc);
if (x25_tree) {
- proto_tree_add_uint(x25_tree,
- (modulo == 8) ? hf_x25_lcn : hf_ex25_lcn, tvb,
+ proto_tree_add_uint(x25_tree, hf_x25_lcn, tvb,
0, 2, bytes0_1);
- proto_tree_add_uint_format(x25_tree,
- (modulo == 8) ? hf_x25_type : hf_ex25_type, tvb, 2, 1,
+ proto_tree_add_uint_format(x25_tree, hf_x25_type, tvb, 2, 1,
X25_CALL_REQUEST,
(pinfo->pseudo_header->x25.flags & FROM_DCE) ? "Incoming call"
: "Call request");
@@ -1592,11 +1565,9 @@ dissect_x25(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
: "Call acc." ,
vc);
if (x25_tree) {
- proto_tree_add_uint(x25_tree, (modulo == 8) ? hf_x25_lcn : hf_ex25_lcn,
- tvb, 0, 2, bytes0_1);
- proto_tree_add_uint_format(x25_tree,
- (modulo == 8) ? hf_x25_type : hf_ex25_type,
- tvb, 2, 1, X25_CALL_ACCEPTED,
+ proto_tree_add_uint(x25_tree, hf_x25_lcn, tvb, 0, 2, bytes0_1);
+ proto_tree_add_uint_format(x25_tree, hf_x25_type, tvb, 2, 1,
+ X25_CALL_ACCEPTED,
(pinfo->pseudo_header->x25.flags & FROM_DCE) ? "Call connected"
: "Call accepted");
}
@@ -1624,11 +1595,9 @@ dissect_x25(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
x25_hash_add_proto_end(vc, pinfo->fd->abs_secs, pinfo->fd->abs_usecs);
if (x25_tree) {
- proto_tree_add_uint(x25_tree, (modulo == 8) ? hf_x25_lcn : hf_ex25_lcn, tvb,
- 0, 2, bytes0_1);
- proto_tree_add_uint_format(x25_tree,
- (modulo == 8) ? hf_x25_type : hf_ex25_type,
- tvb, localoffset+2, 1, X25_CLEAR_REQUEST,
+ proto_tree_add_uint(x25_tree, hf_x25_lcn, tvb, 0, 2, bytes0_1);
+ proto_tree_add_uint_format(x25_tree, hf_x25_type, tvb,
+ localoffset+2, 1, X25_CLEAR_REQUEST,
(pinfo->pseudo_header->x25.flags & FROM_DCE) ? "Clear indication"
: "Clear request");
proto_tree_add_text(x25_tree, tvb, 3, 1,
@@ -1642,10 +1611,9 @@ dissect_x25(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if(check_col(pinfo->fd, COL_INFO))
col_add_fstr(pinfo->fd, COL_INFO, "Clear Conf. VC:%d", vc);
if (x25_tree) {
- proto_tree_add_uint(x25_tree, (modulo == 8) ? hf_x25_lcn : hf_ex25_lcn, tvb,
- 0, 2, bytes0_1);
- proto_tree_add_uint(x25_tree, (modulo == 8) ? hf_x25_type : hf_ex25_type, tvb,
- 2, 1, X25_CLEAR_CONFIRMATION);
+ proto_tree_add_uint(x25_tree, hf_x25_lcn, tvb, 0, 2, bytes0_1);
+ proto_tree_add_uint(x25_tree, hf_x25_type, tvb, 2, 1,
+ X25_CLEAR_CONFIRMATION);
}
localoffset = x25_pkt_len;
@@ -1661,8 +1629,8 @@ dissect_x25(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
(int)tvb_get_guint8(tvb, 3));
}
if (x25_tree) {
- proto_tree_add_uint(x25_tree, (modulo == 8) ? hf_x25_type : hf_ex25_type, tvb,
- 2, 1, X25_DIAGNOSTIC);
+ proto_tree_add_uint(x25_tree, hf_x25_type, tvb, 2, 1,
+ X25_DIAGNOSTIC);
proto_tree_add_text(x25_tree, tvb, 3, 1,
"Diagnostic : %d", (int)tvb_get_guint8(tvb, 3));
}
@@ -1672,10 +1640,9 @@ dissect_x25(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if(check_col(pinfo->fd, COL_INFO))
col_add_fstr(pinfo->fd, COL_INFO, "Interrupt VC:%d", vc);
if (x25_tree) {
- proto_tree_add_uint(x25_tree, (modulo == 8) ? hf_x25_lcn : hf_ex25_lcn, tvb,
- 0, 2, bytes0_1);
- proto_tree_add_uint(x25_tree, (modulo == 8) ? hf_x25_type : hf_ex25_type, tvb,
- 2, 1, X25_INTERRUPT);
+ proto_tree_add_uint(x25_tree, hf_x25_lcn, tvb, 0, 2, bytes0_1);
+ proto_tree_add_uint(x25_tree, hf_x25_type, tvb, 2, 1,
+ X25_INTERRUPT);
}
localoffset = x25_pkt_len;
break;
@@ -1683,10 +1650,9 @@ dissect_x25(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if(check_col(pinfo->fd, COL_INFO))
col_add_fstr(pinfo->fd, COL_INFO, "Interrupt Conf. VC:%d", vc);
if (x25_tree) {
- proto_tree_add_uint(x25_tree, (modulo == 8) ? hf_x25_lcn : hf_ex25_lcn, tvb,
- 0, 2, bytes0_1);
- proto_tree_add_uint(x25_tree, (modulo == 8) ? hf_x25_type : hf_ex25_type, tvb,
- 2, 1, X25_INTERRUPT_CONFIRMATION);
+ proto_tree_add_uint(x25_tree, hf_x25_lcn, tvb, 0, 2, bytes0_1);
+ proto_tree_add_uint(x25_tree, hf_x25_type, tvb, 2, 1,
+ X25_INTERRUPT_CONFIRMATION);
}
localoffset = x25_pkt_len;
break;
@@ -1700,10 +1666,8 @@ dissect_x25(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
}
x25_hash_add_proto_end(vc, pinfo->fd->abs_secs, pinfo->fd->abs_usecs);
if (x25_tree) {
- proto_tree_add_uint(x25_tree, (modulo == 8) ? hf_x25_lcn : hf_ex25_lcn, tvb,
- 0, 2, bytes0_1);
- proto_tree_add_uint_format(x25_tree,
- (modulo == 8) ? hf_x25_type : hf_ex25_type, tvb, 2, 1,
+ proto_tree_add_uint(x25_tree, hf_x25_lcn, tvb, 0, 2, bytes0_1);
+ proto_tree_add_uint_format(x25_tree, hf_x25_type, tvb, 2, 1,
X25_RESET_REQUEST,
(pinfo->pseudo_header->x25.flags & FROM_DCE) ? "Reset indication"
: "Reset request");
@@ -1718,10 +1682,9 @@ dissect_x25(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if(check_col(pinfo->fd, COL_INFO))
col_add_fstr(pinfo->fd, COL_INFO, "Reset conf. VC:%d", vc);
if (x25_tree) {
- proto_tree_add_uint(x25_tree, (modulo == 8) ? hf_x25_lcn : hf_ex25_lcn, tvb,
- 0, 2, bytes0_1);
- proto_tree_add_uint(x25_tree, (modulo == 8) ? hf_x25_type : hf_ex25_type, tvb,
- 2, 1, X25_RESET_CONFIRMATION);
+ proto_tree_add_uint(x25_tree, hf_x25_lcn, tvb, 0, 2, bytes0_1);
+ proto_tree_add_uint(x25_tree, hf_x25_type, tvb, 2, 1,
+ X25_RESET_CONFIRMATION);
}
localoffset = x25_pkt_len;
break;
@@ -1734,8 +1697,7 @@ dissect_x25(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
(int)tvb_get_guint8(tvb, 3));
}
if (x25_tree) {
- proto_tree_add_uint_format(x25_tree,
- (modulo == 8) ? hf_x25_type : hf_ex25_type, tvb, 2, 1,
+ proto_tree_add_uint_format(x25_tree, hf_x25_type, tvb, 2, 1,
X25_RESTART_REQUEST,
(pinfo->pseudo_header->x25.flags & FROM_DCE) ? "Restart indication"
: "Restart request");
@@ -1750,16 +1712,16 @@ dissect_x25(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if(check_col(pinfo->fd, COL_INFO))
col_set_str(pinfo->fd, COL_INFO, "Restart conf.");
if (x25_tree)
- proto_tree_add_uint(x25_tree, (modulo == 8) ? hf_x25_type : hf_ex25_type, tvb,
- 2, 1, X25_RESTART_CONFIRMATION);
+ proto_tree_add_uint(x25_tree, hf_x25_type, tvb, 2, 1,
+ X25_RESTART_CONFIRMATION);
localoffset = x25_pkt_len;
break;
case X25_REGISTRATION_REQUEST:
if(check_col(pinfo->fd, COL_INFO))
col_set_str(pinfo->fd, COL_INFO, "Registration req.");
if (x25_tree)
- proto_tree_add_uint(x25_tree, (modulo == 8) ? hf_x25_type : hf_ex25_type, tvb,
- 2, 1, X25_REGISTRATION_REQUEST);
+ proto_tree_add_uint(x25_tree, hf_x25_type, tvb, 2, 1,
+ X25_REGISTRATION_REQUEST);
localoffset = 3;
if (localoffset < x25_pkt_len)
x25_ntoa(x25_tree, &localoffset, tvb, pinfo->fd, FALSE);
@@ -1780,8 +1742,8 @@ dissect_x25(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
if(check_col(pinfo->fd, COL_INFO))
col_set_str(pinfo->fd, COL_INFO, "Registration conf.");
if (x25_tree) {
- proto_tree_add_uint(x25_tree, (modulo == 8) ? hf_x25_type : hf_ex25_type, tvb,
- 2, 1, X25_REGISTRATION_CONFIRMATION);
+ proto_tree_add_uint(x25_tree, hf_x25_type, tvb, 2, 1,
+ X25_REGISTRATION_CONFIRMATION);
proto_tree_add_text(x25_tree, tvb, 3, 1,
"Cause: %s", registration_code(tvb_get_guint8(tvb, 3)));
proto_tree_add_text(x25_tree, tvb, 4, 1,
@@ -1822,32 +1784,32 @@ dissect_x25(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
(tvb_get_guint8(tvb, localoffset+1) & 0x01) ? " M" : "");
}
if (x25_tree) {
- proto_tree_add_uint(x25_tree, (modulo == 8) ? hf_x25_lcn : hf_ex25_lcn,
- tvb, localoffset-2, 2, bytes0_1);
+ proto_tree_add_uint(x25_tree, hf_x25_lcn, tvb, localoffset-2,
+ 2, bytes0_1);
+ proto_tree_add_uint_hidden(x25_tree, hf_x25_type, tvb,
+ localoffset, 1, X25_DATA);
if (modulo == 8) {
- proto_tree_add_uint_hidden(x25_tree, hf_x25_type, tvb,
- localoffset, 1, X25_DATA);
- proto_tree_add_uint(x25_tree, hf_x25_p_r, tvb,
+ proto_tree_add_uint(x25_tree, hf_x25_p_r_mod8, tvb,
localoffset, 1, pkt_type);
if (pkt_type & 0x10)
- proto_tree_add_boolean(x25_tree, hf_x25_mbit, tvb, localoffset, 1,
- pkt_type);
- proto_tree_add_uint(x25_tree, hf_x25_p_s, tvb, localoffset, 1,
- pkt_type);
+ proto_tree_add_boolean(x25_tree, hf_x25_mbit_mod8, tvb,
+ localoffset, 1, pkt_type);
+ proto_tree_add_uint(x25_tree, hf_x25_p_s_mod8, tvb,
+ localoffset, 1, pkt_type);
proto_tree_add_text(x25_tree, tvb, localoffset, 1,
decode_boolean_bitfield(pkt_type, 0x01, 1*8,
NULL, "DATA"));
}
else {
- proto_tree_add_uint_hidden(x25_tree, hf_ex25_type, tvb,
- localoffset, 1, X25_DATA);
- proto_tree_add_uint(x25_tree, hf_x25_p_r, tvb,
+ proto_tree_add_uint(x25_tree, hf_x25_p_r_mod128, tvb,
localoffset, 1, pkt_type);
- proto_tree_add_uint(x25_tree, hf_x25_p_s, tvb,
- localoffset+1, 1, tvb_get_guint8(tvb, localoffset+1));
+ proto_tree_add_uint(x25_tree, hf_x25_p_s_mod128, tvb,
+ localoffset+1, 1,
+ tvb_get_guint8(tvb, localoffset+1));
if (tvb_get_guint8(tvb, localoffset+1) & 0x01)
- proto_tree_add_boolean(x25_tree, hf_ex25_mbit, tvb,
- localoffset+1, 1, tvb_get_guint8(tvb, localoffset+1));
+ proto_tree_add_boolean(x25_tree, hf_x25_mbit_mod128, tvb,
+ localoffset+1, 1,
+ tvb_get_guint8(tvb, localoffset+1));
}
}
localoffset += (modulo == 8) ? 1 : 2;
@@ -1865,18 +1827,18 @@ dissect_x25(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
vc, tvb_get_guint8(tvb, localoffset+1) >> 1);
}
if (x25_tree) {
- proto_tree_add_uint(x25_tree, (modulo == 8) ? hf_x25_lcn : hf_ex25_lcn,
- tvb, localoffset-2, 2, bytes0_1);
+ proto_tree_add_uint(x25_tree, hf_x25_lcn, tvb, localoffset-2,
+ 2, bytes0_1);
if (modulo == 8) {
- proto_tree_add_uint(x25_tree, hf_x25_p_r, tvb,
+ proto_tree_add_uint(x25_tree, hf_x25_p_r_mod8, tvb,
localoffset, 1, pkt_type);
proto_tree_add_uint(x25_tree, hf_x25_type, tvb,
localoffset, 1, X25_RR);
}
else {
- proto_tree_add_uint(x25_tree, hf_ex25_type, tvb,
+ proto_tree_add_uint(x25_tree, hf_x25_type, tvb,
localoffset, 1, X25_RR);
- proto_tree_add_item(x25_tree, hf_ex25_p_r, tvb,
+ proto_tree_add_item(x25_tree, hf_x25_p_r_mod128, tvb,
localoffset+1, 1, FALSE);
}
}
@@ -1892,18 +1854,18 @@ dissect_x25(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
vc, tvb_get_guint8(tvb, localoffset+1) >> 1);
}
if (x25_tree) {
- proto_tree_add_uint(x25_tree, (modulo == 8) ? hf_x25_lcn : hf_ex25_lcn,
- tvb, localoffset-2, 2, bytes0_1);
+ proto_tree_add_uint(x25_tree, hf_x25_lcn, tvb, localoffset-2,
+ 2, bytes0_1);
if (modulo == 8) {
- proto_tree_add_uint(x25_tree, hf_x25_p_r, tvb,
+ proto_tree_add_uint(x25_tree, hf_x25_p_r_mod8, tvb,
localoffset, 1, pkt_type);
proto_tree_add_uint(x25_tree, hf_x25_type, tvb,
localoffset, 1, X25_RNR);
}
else {
- proto_tree_add_uint(x25_tree, hf_ex25_type, tvb,
+ proto_tree_add_uint(x25_tree, hf_x25_type, tvb,
localoffset, 1, X25_RNR);
- proto_tree_add_item(x25_tree, hf_ex25_p_r, tvb,
+ proto_tree_add_item(x25_tree, hf_x25_p_r_mod128, tvb,
localoffset+1, 1, FALSE);
}
}
@@ -1919,18 +1881,18 @@ dissect_x25(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
vc, tvb_get_guint8(tvb, localoffset+1) >> 1);
}
if (x25_tree) {
- proto_tree_add_uint(x25_tree, (modulo == 8) ? hf_x25_lcn : hf_ex25_lcn,
- tvb, localoffset-2, 2, bytes0_1);
+ proto_tree_add_uint(x25_tree, hf_x25_lcn, tvb, localoffset-2,
+ 2, bytes0_1);
if (modulo == 8) {
- proto_tree_add_uint(x25_tree, hf_x25_p_r, tvb,
+ proto_tree_add_uint(x25_tree, hf_x25_p_r_mod8, tvb,
localoffset, 1, pkt_type);
proto_tree_add_uint(x25_tree, hf_x25_type, tvb,
localoffset, 1, X25_REJ);
}
else {
- proto_tree_add_uint(x25_tree, hf_ex25_type, tvb,
+ proto_tree_add_uint(x25_tree, hf_x25_type, tvb,
localoffset, 1, X25_REJ);
- proto_tree_add_item(x25_tree, hf_ex25_p_r, tvb,
+ proto_tree_add_item(x25_tree, hf_x25_p_r_mod128, tvb,
localoffset+1, 1, FALSE);
}
}
@@ -1960,7 +1922,7 @@ dissect_x25(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
void
proto_register_x25(void)
{
- static hf_register_info hf8[] = {
+ static hf_register_info hf[] = {
{ &hf_x25_gfi,
{ "GFI", "x.25.gfi", FT_UINT16, BASE_BIN, NULL, 0xF000,
"General format identifier" } },
@@ -1982,47 +1944,23 @@ proto_register_x25(void)
{ &hf_x25_type,
{ "Packet Type", "x.25.type", FT_UINT8, BASE_HEX, VALS(vals_x25_type), 0x0,
"Packet Type" } },
- { &hf_x25_p_r,
+ { &hf_x25_p_r_mod8,
{ "P(R)", "x.25.p_r", FT_UINT8, BASE_HEX, NULL, 0xE0,
"Packet Receive Sequence Number" } },
- { &hf_x25_mbit,
+ { &hf_x25_p_r_mod128,
+ { "P(R)", "x.25.p_r", FT_UINT8, BASE_HEX, NULL, 0xFE,
+ "Packet Receive Sequence Number" } },
+ { &hf_x25_mbit_mod8,
{ "M Bit", "x.25.m", FT_BOOLEAN, 8, NULL, 0x10,
"More Bit" } },
- { &hf_x25_p_s,
+ { &hf_x25_mbit_mod128,
+ { "M Bit", "x.25.m", FT_BOOLEAN, 8, NULL, 0x01,
+ "More Bit" } },
+ { &hf_x25_p_s_mod8,
{ "P(S)", "x.25.p_s", FT_UINT8, BASE_HEX, NULL, 0x0E,
"Packet Send Sequence Number" } },
- };
-
- static hf_register_info hf128[] = {
- { &hf_ex25_gfi,
- { "GFI", "ex.25.gfi", FT_UINT16, BASE_BIN, NULL, 0xF000,
- "General format identifier" } },
- { &hf_ex25_abit,
- { "A Bit", "ex.25.a", FT_BOOLEAN, 16, NULL, 0x8000,
- "Address Bit" } },
- { &hf_ex25_qbit,
- { "Q Bit", "ex.25.q", FT_BOOLEAN, 16, NULL, 0x8000,
- "Qualifier Bit" } },
- { &hf_ex25_dbit,
- { "D Bit", "ex.25.d", FT_BOOLEAN, 16, NULL, 0x4000,
- "Delivery Confirmation Bit" } },
- { &hf_ex25_mod,
- { "Modulo", "ex.25.mod", FT_UINT16, BASE_DEC, VALS(vals_modulo), 0x3000,
- "Specifies whether the frame is modulo 8 or 128" } },
- { &hf_ex25_lcn,
- { "Logical Channel", "ex.25.lcn", FT_UINT16, BASE_HEX, NULL, 0x0FFF,
- "Logical Channel Number" } },
- { &hf_ex25_type,
- { "Packet Type", "ex.25.type", FT_UINT8, BASE_HEX, VALS(vals_x25_type), 0x0,
- "Packet Type" } },
- { &hf_ex25_p_r,
- { "P(R)", "ex.25.p_r", FT_UINT8, BASE_HEX, NULL, 0xFE,
- "Packet Receive Sequence Number" } },
- { &hf_ex25_mbit,
- { "M Bit", "ex.25.m", FT_BOOLEAN, 8, NULL, 0x01,
- "More Bit" } },
- { &hf_ex25_p_s,
- { "P(S)", "ex.25.p_s", FT_UINT8, BASE_HEX, NULL, 0xFE,
+ { &hf_x25_p_s_mod128,
+ { "P(S)", "x.25.p_s", FT_UINT8, BASE_HEX, NULL, 0xFE,
"Packet Send Sequence Number" } },
};
static gint *ett[] = {
@@ -2052,12 +1990,11 @@ proto_register_x25(void)
};
proto_x25 = proto_register_protocol ("X.25", "X.25", "x.25");
- proto_ex25 = proto_register_protocol ("Extended X.25 (modulo 128)",
- "Extended X.25", "ex.25");
- proto_register_field_array (proto_x25, hf8, array_length(hf8));
- proto_register_field_array (proto_ex25, hf128, array_length(hf128));
+ proto_register_field_array (proto_x25, hf, array_length(hf));
proto_register_subtree_array(ett, array_length(ett));
register_init_routine(&reinit_x25_hashtable);
+
+ register_dissector("x.25", dissect_x25, proto_x25);
}
void
@@ -2069,12 +2006,5 @@ proto_reg_handoff_x25(void)
ip_handle = find_dissector("ip");
ositp_handle = find_dissector("ositp");
- /*
- * XXX - we can't associate this with both "proto_x25" and
- * "proto_ex25"; we really should have only one X.25 protocol,
- * but to do that right, we need to arrange that, for example,
- * we can have two field definitions with the name "x.25.p_r",
- * one for modulo-8 operation and one for modulo-128 operation.
- */
- dissector_add("llc.dsap", SAP_X25, dissect_x25, -1);
+ dissector_add("llc.dsap", SAP_X25, dissect_x25, proto_x25);
}
diff --git a/packet-x25.h b/packet-x25.h
deleted file mode 100644
index 710ed46629..0000000000
--- a/packet-x25.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* packet-x25.h
- *
- * $Id: packet-x25.h,v 1.7 2000/08/11 13:33:55 deniel Exp $
- *
- * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
- * Copyright 1998 Gerald Combs
- *
- *
- * 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.
- */
-
-#ifndef __PACKET_X25_H__
-#define __PACKET_X25_H__
-
-void dissect_x25(tvbuff_t *, packet_info *, proto_tree *);
-
-#endif
diff --git a/packet-xot.c b/packet-xot.c
index 290a381e4c..0289e9dd20 100644
--- a/packet-xot.c
+++ b/packet-xot.c
@@ -3,7 +3,7 @@
*
* Copyright 2000, Paul Ionescu <paul@acorp.ro>
*
- * $Id: packet-xot.c,v 1.4 2001/01/22 08:03:46 guy Exp $
+ * $Id: packet-xot.c,v 1.5 2001/02/12 09:06:17 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -36,13 +36,14 @@
#include <string.h>
#include <glib.h>
#include "packet.h"
-#include "packet-x25.h"
#define TCP_PORT_XOT 1998
static gint proto_xot = -1;
static gint ett_xot = -1;
+static dissector_handle_t x25_handle;
+
static void dissect_xot(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_item *ti;
@@ -70,7 +71,7 @@ static void dissect_xot(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
ti = proto_tree_add_text(xot_tree, tvb, 2,2,"XOT length : %u",len) ;
}
next_tvb = tvb_new_subset(tvb,4, -1 , -1);
- dissect_x25(next_tvb,pinfo,tree);
+ call_dissector(x25_handle,next_tvb,pinfo,tree);
}
/* Register the protocol with Ethereal */
@@ -93,5 +94,10 @@ void proto_register_xot(void)
void
proto_reg_handoff_xot(void)
{
+ /*
+ * Get a handle for the X.25 dissector.
+ */
+ x25_handle = find_dissector("x.25");
+
dissector_add("tcp.port", TCP_PORT_XOT, dissect_xot, proto_xot);
}