aboutsummaryrefslogtreecommitdiffstats
path: root/epan
diff options
context:
space:
mode:
authorAnders Broman <anders.broman@ericsson.com>2009-04-04 11:48:19 +0000
committerAnders Broman <anders.broman@ericsson.com>2009-04-04 11:48:19 +0000
commite0cf1679e3e1f469de2f727e3628b4f40f4e4b5c (patch)
treed7875a22f53e952fd0d0771632ce56b0549e4356 /epan
parent978f771a8d7c73d44585ae64a46874f643467edf (diff)
From Francesco Fondelli:
New ATM PW (with/without CW) dissector, RFC 4717 https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=3375 svn path=/trunk/; revision=27955
Diffstat (limited to 'epan')
-rw-r--r--epan/dissectors/packet-atm.c147
-rw-r--r--epan/dissectors/packet-pw-atm.c590
-rw-r--r--epan/dissectors/packet-pw-eth.c235
-rw-r--r--epan/packet_info.h22
4 files changed, 859 insertions, 135 deletions
diff --git a/epan/dissectors/packet-atm.c b/epan/dissectors/packet-atm.c
index cb4647ad01..a560446533 100644
--- a/epan/dissectors/packet-atm.c
+++ b/epan/dissectors/packet-atm.c
@@ -50,6 +50,7 @@ static int proto_ilmi = -1;
static int proto_aal1 = -1;
static int proto_aal3_4 = -1;
static int proto_oamaal = -1;
+static int proto_atm_4717 = -1;
static gint ett_atm = -1;
static gint ett_atm_lane = -1;
@@ -1523,14 +1524,15 @@ static const value_string ft_ad_vals[] = {
static void
dissect_atm_cell(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
- proto_tree *atm_tree, guint aal)
+ proto_tree *atm_tree, guint aal, gboolean nni,
+ gboolean crc_stripped)
{
int offset;
proto_tree *aal_tree;
proto_item *ti;
guint8 octet;
int err;
- guint8 vpi;
+ guint16 vpi;
guint16 vci;
guint8 pt;
guint16 aal3_4_hdr, aal3_4_trlr;
@@ -1539,12 +1541,55 @@ dissect_atm_cell(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
guint16 crc10;
tvbuff_t *next_tvb;
- octet = tvb_get_guint8(tvb, 0);
- proto_tree_add_text(atm_tree, tvb, 0, 1, "GFC: 0x%x", octet >> 4);
- vpi = (octet & 0xF) << 4;
- octet = tvb_get_guint8(tvb, 1);
- vpi |= octet >> 4;
- proto_tree_add_uint(atm_tree, hf_atm_vpi, tvb, 0, 2, vpi);
+ if (!nni) {
+ /*
+ * FF: ITU-T I.361 (Section 2.2) defines the cell header format
+ * and encoding at UNI reference point as:
+ *
+ * 8 7 6 5 4 3 2 1
+ * +-+-+-+-+-+-+-+-+
+ * | GFC | VPI |
+ * +-+-+-+-+-+-+-+-+
+ * | VPI | VCI |
+ * +-+-+-+-+-+-+-+-+
+ * | VCI |
+ * +-+-+-+-+-+-+-+-+
+ * | VCI | PT |C|
+ * +-+-+-+-+-+-+-+-+
+ * | HEC (CRC) |
+ * +-+-+-+-+-+-+-+-+
+ */
+ octet = tvb_get_guint8(tvb, 0);
+ proto_tree_add_text(atm_tree, tvb, 0, 1, "GFC: 0x%x", octet >> 4);
+ vpi = (octet & 0xF) << 4;
+ octet = tvb_get_guint8(tvb, 1);
+ vpi |= octet >> 4;
+ proto_tree_add_uint(atm_tree, hf_atm_vpi, tvb, 0, 2, vpi);
+ } else {
+ /*
+ * FF: ITU-T I.361 (Section 2.3) defines the cell header format
+ * and encoding at NNI reference point as:
+ *
+ * 8 7 6 5 4 3 2 1
+ * +-+-+-+-+-+-+-+-+
+ * | VPI |
+ * +-+-+-+-+-+-+-+-+
+ * | VPI | VCI |
+ * +-+-+-+-+-+-+-+-+
+ * | VCI |
+ * +-+-+-+-+-+-+-+-+
+ * | VCI | PT |C|
+ * +-+-+-+-+-+-+-+-+
+ * | HEC (CRC) |
+ * +-+-+-+-+-+-+-+-+
+ */
+ octet = tvb_get_guint8(tvb, 0);
+ vpi = octet << 4;
+ octet = tvb_get_guint8(tvb, 1);
+ vpi |= (octet & 0xF0) >> 4;
+ proto_tree_add_uint(atm_tree, hf_atm_vpi, tvb, 0, 2, vpi);
+ }
+
vci = (octet & 0x0F) << 12;
octet = tvb_get_guint8(tvb, 2);
vci |= octet << 4;
@@ -1556,16 +1601,30 @@ dissect_atm_cell(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
val_to_str(pt, pt_vals, "Unknown (%u)"));
proto_tree_add_text(atm_tree, tvb, 3, 1, "Cell Loss Priority: %s",
(octet & 0x01) ? "Low priority" : "High priority");
- ti = proto_tree_add_text(atm_tree, tvb, 4, 1, "Header Error Check: 0x%02x",
- tvb_get_guint8(tvb, 4));
- err = get_header_err(tvb_get_ptr(tvb, 0, 5));
- if (err == NO_ERROR_DETECTED)
- proto_item_append_text(ti, " (correct)");
- else if (err == UNCORRECTIBLE_ERROR)
- proto_item_append_text(ti, " (uncorrectable error)");
- else
- proto_item_append_text(ti, " (error in bit %d)", err);
- offset = 5;
+
+ if (!crc_stripped) {
+ /*
+ * FF: parse the Header Error Check (HEC).
+ */
+ ti = proto_tree_add_text(atm_tree, tvb, 4, 1,
+ "Header Error Check: 0x%02x",
+ tvb_get_guint8(tvb, 4));
+ err = get_header_err(tvb_get_ptr(tvb, 0, 5));
+ if (err == NO_ERROR_DETECTED)
+ proto_item_append_text(ti, " (correct)");
+ else if (err == UNCORRECTIBLE_ERROR)
+ proto_item_append_text(ti, " (uncorrectable error)");
+ else
+ proto_item_append_text(ti, " (error in bit %d)", err);
+ offset = 5;
+ } else {
+ /*
+ * FF: in some encapsulation modes (e.g. RFC 4717, ATM N-to-One
+ * Cell Mode) the Header Error Check (HEC) field is stripped.
+ * So we do nothing here.
+ */
+ offset = 4;
+ }
/*
* Check for OAM cells.
@@ -1781,7 +1840,8 @@ dissect_atm_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
if (pinfo->pseudo_header->atm.flags & ATM_RAW_CELL) {
/* This is a single cell, with the cell header at the beginning. */
proto_item_set_len(atm_ti, 5);
- dissect_atm_cell(tvb, pinfo, tree, atm_tree, pinfo->pseudo_header->atm.aal);
+ dissect_atm_cell(tvb, pinfo, tree, atm_tree,
+ pinfo->pseudo_header->atm.aal, FALSE, FALSE);
} else {
/* This is a reassembled PDU. */
dissect_reassembled_pdu(tvb, pinfo, tree, atm_tree, atm_ti, truncated);
@@ -1814,7 +1874,49 @@ dissect_atm_oam_cell(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
atm_tree = proto_item_add_subtree(atm_ti, ett_atm);
}
- dissect_atm_cell(tvb, pinfo, tree, atm_tree, AAL_OAMCELL);
+ dissect_atm_cell(tvb, pinfo, tree, atm_tree, AAL_OAMCELL, FALSE, FALSE);
+}
+
+/*
+ * FF: this dissector is called directly from packet-pw-atm.c.
+ * it checks pinfo->pw_atm_encap_type, pinfo->pw_atm_flags
+ * in order to gather information about the used encapsulation
+ * format (defined in RFC 4717). The result (i.e. protocol tree
+ * and cinfo) of this dissector should look like, as close as
+ * possible, to the legacy one (i.e. dissect_atm_[untruncated|oam_cell]).
+ */
+static void
+dissect_atm_4717(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+{
+ proto_tree *atm_tree = NULL;
+ proto_item *atm_ti = NULL;
+
+ if (check_col(pinfo->cinfo, COL_PROTOCOL))
+ col_set_str(pinfo->cinfo, COL_PROTOCOL, "ATM");
+
+ if (tree) {
+ atm_ti = proto_tree_add_protocol_format(tree,
+ proto_atm,
+ tvb, 0, 0, "ATM");
+ atm_tree = proto_item_add_subtree(atm_ti, ett_atm);
+ }
+
+ switch (pinfo->pw_atm_encap_type) {
+ case 1: /* ATM N-to-One Cell Mode */
+ if (check_col(pinfo->cinfo, COL_INFO)) {
+ col_add_str(pinfo->cinfo, COL_INFO, "Unknown AAL");
+ col_append_fstr(pinfo->cinfo, COL_INFO,
+ " (%u cell%s)",
+ pinfo->pw_atm_ncells,
+ pinfo->pw_atm_ncells == 1 ? "" : "s");
+ }
+ proto_item_set_len(atm_ti, 4);
+ dissect_atm_cell(tvb, pinfo, tree, atm_tree,
+ AAL_UNKNOWN, TRUE, TRUE);
+ break;
+ default:
+ break;
+ }
}
void
@@ -1870,6 +1972,7 @@ proto_register_atm(void)
register_dissector("lane", dissect_lane, proto_atm_lane);
register_dissector("atm_untruncated", dissect_atm_untruncated, proto_atm);
register_dissector("atm_oam_cell", dissect_atm_oam_cell, proto_oamaal);
+ register_dissector("atm_4717", dissect_atm_4717, proto_atm_4717);
atm_module = prefs_register_protocol ( proto_atm, NULL );
prefs_register_bool_preference ( atm_module, "dissect_lane_as_sscop", "Dissect LANE as SSCOP",
@@ -1880,7 +1983,7 @@ proto_register_atm(void)
void
proto_reg_handoff_atm(void)
{
- dissector_handle_t atm_handle, atm_untruncated_handle;
+ dissector_handle_t atm_handle, atm_untruncated_handle, atm_4717_handle;
/*
* Get handles for the Ethernet, Token Ring, Frame Relay, LLC,
@@ -1906,4 +2009,6 @@ proto_reg_handoff_atm(void)
proto_atm);
dissector_add("wtap_encap", WTAP_ENCAP_ATM_PDUS_UNTRUNCATED,
atm_untruncated_handle);
+
+ atm_4717_handle = create_dissector_handle(dissect_atm_4717, proto_atm);
}
diff --git a/epan/dissectors/packet-pw-atm.c b/epan/dissectors/packet-pw-atm.c
new file mode 100644
index 0000000000..c5fb4cfebb
--- /dev/null
+++ b/epan/dissectors/packet-pw-atm.c
@@ -0,0 +1,590 @@
+/* packet-pw-atm.c
+ * Routines for ATM PW dissection: it should be conform to RFC 4717.
+ *
+ * Copyright 2009 _FF_
+ *
+ * Francesco Fondelli <francesco dot fondelli, gmail dot com>
+ *
+ * $Id$
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.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.
+ */
+
+/*
+ DONE:
+ - ATM N-to-One Cell Mode (with CW)
+ - ATM N-to-One Cell Mode (no CW)
+ TODO:
+ - ATM One-to-One Cell Mode
+ - ATM AAL5 SDU Mode
+ - ATM AAL5 PDU Mode
+
+ Please pick an item from the TODO list, move code out of #if 0
+ (see below) and implement a dissector for the given encapsulation
+ mode. The N-to-One Cell Mode is the only mandatory encap
+ mode. One-to-One/SDU/PDU modes are optional.
+*/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <glib.h>
+#include <epan/packet.h>
+
+#include "packet-mpls.h"
+
+static gint proto_pw_atm_n2o_cw = -1;
+static gint proto_pw_atm_n2o_nocw = -1;
+#if 0
+static gint proto_pw_atm_o2o_cw = -1;
+static gint proto_pw_atm_o2o_nocw = -1;
+static gint proto_pw_atm_aal5_pdu_cw = -1;
+static gint proto_pw_atm_aal5_pdu_nocw = -1;
+static gint proto_pw_atm_aal5_sdu_cw = -1;
+static gint proto_pw_atm_aal5_sdu_nocw = -1;
+#endif
+
+static gint ett_pw_atm = -1;
+
+static int hf_pw_atm_n2o_cw = -1;
+static int hf_pw_atm_n2o_cw_flags = -1;
+static int hf_pw_atm_n2o_cw_length = -1;
+static int hf_pw_atm_n2o_cw_sequence_number = -1;
+static int hf_pw_atm_n2o_nocw = -1;
+#if 0
+static int hf_pw_atm_o2o_cw = -1;
+static int hf_pw_atm_o2o_cw_sequence_number = -1;
+static int hf_pw_atm_o2o_cw_flags = -1;
+static int hf_pw_atm_o2o_cw_flags_m = -1;
+static int hf_pw_atm_o2o_cw_flags_v = -1;
+static int hf_pw_atm_o2o_cw_flags_res = -1;
+static int hf_pw_atm_o2o_cw_flags_pti = -1;
+static int hf_pw_atm_o2o_cw_flags_c = -1;
+static int hf_pw_atm_o2o_nocw = -1;
+static int hf_pw_atm_aal5_pdu_cw = -1;
+static int hf_pw_atm_aal5_pdu_cw_sequence_number = -1;
+static int hf_pw_atm_aal5_pdu_nocw = -1;
+static int hf_pw_atm_aal5_sdu_cw = -1;
+static int hf_pw_atm_aal5_sdu_cw_sequence_number = -1;
+static int hf_pw_atm_aal5_sdu_nocw = -1;
+#endif
+
+static dissector_handle_t data_h;
+static dissector_handle_t atm_h;
+
+/* ATM One-to-One Cell Mode bits in "ATM Specific" CW field */
+#define PW_ATM_O2O_CW_M 0x80
+#define PW_ATM_O2O_CW_V 0x40
+#define PW_ATM_O2O_CW_RES 0x30
+#define PW_ATM_O2O_CW_PTI 0x0E
+#define PW_ATM_O2O_CW_C 0x01
+
+static void
+dissect_pw_atm_n2o_cw(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+{
+ proto_tree *pw_atm_tree = NULL;
+ proto_item *ti = NULL;
+ tvbuff_t *next_tvb = NULL;
+ guint16 sequence_number = 0;
+ guint8 flags = 0;
+ guint8 length = 0;
+ guint16 ncells = 0;
+ guint16 remains = 0;
+ guint16 i = 0;
+
+ if (tvb_reported_length_remaining(tvb, 0) < 4) {
+ if (tree)
+ proto_tree_add_text(tree, tvb, 0, -1,
+ "Error processing Message");
+ return;
+ }
+
+ if (tree) {
+ ti = proto_tree_add_boolean(tree, hf_pw_atm_n2o_cw,
+ tvb, 0, 0, TRUE);
+ PROTO_ITEM_SET_HIDDEN(ti);
+ ti = proto_tree_add_item(tree, proto_pw_atm_n2o_cw,
+ tvb, 0, 4, FALSE);
+ pw_atm_tree = proto_item_add_subtree(ti, ett_pw_atm);
+ if (pw_atm_tree == NULL)
+ return;
+
+ flags = tvb_get_guint8(tvb, 0) & 0x0F;
+ proto_tree_add_uint_format(
+ pw_atm_tree,
+ hf_pw_atm_n2o_cw_flags,
+ tvb, 0, 1, flags,
+ "Flags: 0x%02x",
+ flags);
+
+ length = tvb_get_guint8(tvb, 1) & 0x3F;
+ proto_tree_add_uint_format(
+ pw_atm_tree,
+ hf_pw_atm_n2o_cw_length,
+ tvb, 1, 1, length,
+ "Length: %u",
+ flags);
+
+ sequence_number = tvb_get_ntohs(tvb, 2);
+ proto_tree_add_uint_format(
+ pw_atm_tree,
+ hf_pw_atm_n2o_cw_sequence_number,
+ tvb, 2, 2, sequence_number,
+ "Sequence Number: %u",
+ sequence_number);
+ }
+
+ /* FF: pass info to the ATM dissector, see packet_info.h for details */
+ pinfo->pw_atm_encap_type = 1;
+
+ /*
+ * FF: RFC 4717: "The number of cells encapsulated in a particular
+ * frame can be inferred by the frame length" but "if the control
+ * word is used, then the flag and length bits in the control word
+ * are not used [and must be set to 0]" so... no reported_length in
+ * tvb_new_subset().
+ */
+ ncells = tvb_length_remaining(tvb, 4) / 52;
+ pinfo->pw_atm_ncells = ncells;
+ remains = tvb_length_remaining(tvb, 4) % 52;
+
+ for (i = 0; i < ncells; i++) {
+ next_tvb = tvb_new_subset(tvb,
+ 4 + (i * 52),
+ 52,
+ -1);
+ call_dissector(atm_h, next_tvb, pinfo, tree);
+ }
+
+ /*
+ * FF: RFC 4717 "if the pseudowire traverses a network link that
+ * requires a minimum frame size, with a minimum frame size of 64
+ * octets, then such links will apply padding to the pseudowire PDU
+ * to reach its minimum frame size" or this is a malformed PDU,
+ * anyway...
+ */
+ if (remains) {
+ next_tvb = tvb_new_subset(tvb,
+ 4 + (i * 52),
+ remains,
+ -1);
+ call_dissector(data_h, next_tvb, pinfo, tree);
+ }
+}
+
+static void
+dissect_pw_atm_n2o_nocw(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+{
+ proto_item *ti = NULL;
+ tvbuff_t *next_tvb = NULL;
+ guint16 ncells = 0;
+ guint16 remains = 0;
+ guint16 i = 0;
+
+ /*
+ * FF: all comments in dissect_pw_atm_n2o_cw() apply here
+ * as well, thus not repeated.
+ */
+
+ if (tvb_reported_length_remaining(tvb, 0) < 52) {
+ if (tree)
+ proto_tree_add_text(tree, tvb, 0, -1,
+ "Error processing Message");
+ return;
+ }
+
+ if (tree) {
+ ti = proto_tree_add_boolean(tree, hf_pw_atm_n2o_nocw,
+ tvb, 0, 0, TRUE);
+ PROTO_ITEM_SET_HIDDEN(ti);
+ }
+
+ pinfo->pw_atm_encap_type = 1;
+ ncells = tvb_length_remaining(tvb, 0) / 52;
+ pinfo->pw_atm_ncells = ncells;
+ remains = tvb_length_remaining(tvb, 0) % 52;
+
+ for (i = 0; i < ncells; i++) {
+ next_tvb = tvb_new_subset(tvb,
+ (i * 52),
+ 52,
+ -1);
+ call_dissector(atm_h, next_tvb, pinfo, tree);
+ }
+
+ if (remains) {
+ next_tvb = tvb_new_subset(tvb,
+ (i * 52),
+ remains,
+ -1);
+ call_dissector(data_h, next_tvb, pinfo, tree);
+ }
+}
+
+#if 0
+static void
+dissect_pw_atm_o2o_cw(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+{
+ (void)tvb;
+ (void)pinfo;
+ (void)tree;
+}
+
+static void
+dissect_pw_atm_o2o_nocw(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+{
+ (void)tvb;
+ (void)pinfo;
+ (void)tree;
+}
+
+
+static void
+dissect_pw_atm_aal5_pdu_cw(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+{
+ (void)tvb;
+ (void)pinfo;
+ (void)tree;
+}
+
+
+static void
+dissect_pw_atm_aal5_pdu_nocw(tvbuff_t *tvb, packet_info *pinfo,
+ proto_tree *tree)
+{
+ (void)tvb;
+ (void)pinfo;
+ (void)tree;
+}
+
+static void
+dissect_pw_atm_aal5_sdu_cw(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+{
+ (void)tvb;
+ (void)pinfo;
+ (void)tree;
+}
+
+static void
+dissect_pw_atm_aal5_sdu_nocw(tvbuff_t *tvb, packet_info *pinfo,
+ proto_tree *tree)
+{
+ (void)tvb;
+ (void)pinfo;
+ (void)tree;
+}
+#endif
+
+void
+proto_register_pw_atm(void)
+{
+ static hf_register_info hf[] = {
+ /* FF: general */
+ {
+ &hf_pw_atm_n2o_cw,
+ {
+ "ATM PW, N-to-one Cell Mode (with CW)",
+ "pw_atm_n2o_cw", FT_BOOLEAN,
+ 0, NULL, 0x0, NULL, HFILL
+ }
+ },
+ {
+ &hf_pw_atm_n2o_nocw,
+ {
+ "ATM PW, N-to-one Cell Mode (no CW)",
+ "pw_atm_n2o_nocw", FT_BOOLEAN,
+ 0, NULL, 0x0, NULL, HFILL
+ }
+ },
+#if 0
+ {
+ &hf_pw_atm_o2o_cw,
+ {
+ "ATM PW, One-to-one Cell Mode (with CW)",
+ "pw_atm_o2o_cw", FT_BOOLEAN,
+ 0, NULL, 0x0, NULL, HFILL
+ }
+ },
+ {
+ &hf_pw_atm_o2o_nocw,
+ {
+ "ATM PW, One-to-one Cell Mode (no CW)",
+ "pw_atm_o2o_nocw", FT_BOOLEAN,
+ 0, NULL, 0x0, NULL, HFILL
+ }
+ },
+ {
+ &hf_pw_atm_aal5_pdu_cw,
+ {
+ "ATM PW, AAL5 PDU Frame Mode (with CW)",
+ "pw_atm_aal5_pdu_cw", FT_BOOLEAN,
+ 0, NULL, 0x0, NULL, HFILL
+ }
+ },
+ {
+ &hf_pw_atm_aal5_pdu_nocw,
+ {
+ "ATM PW, AAL5 PDU Frame Mode (no CW)",
+ "pw_atm_aal5_pdu_nocw", FT_BOOLEAN,
+ 0, NULL, 0x0, NULL, HFILL
+ }
+ },
+ {
+ &hf_pw_atm_aal5_sdu_cw,
+ {
+ "ATM PW, AAL5 SDU Frame Mode (with CW)",
+ "pw_atm_aal5_sdu_cw", FT_BOOLEAN,
+ 0, NULL, 0x0, NULL, HFILL
+ }
+ },
+ {
+ &hf_pw_atm_aal5_sdu_nocw,
+ {
+ "ATM PW, AAL5 SDU Frame Mode (no CW)",
+ "pw_atm_aal5_sdu_nocw", FT_BOOLEAN,
+ 0, NULL, 0x0, NULL, HFILL
+ }
+ },
+ /* FF: ATM One-to-one Cell Mode Control Word fields */
+ {
+ &hf_pw_atm_o2o_cw_sequence_number,
+ {
+ "ATM One-to-one Cell Mode sequence number",
+ "pw_atm_o2o_cw_sequence_number", FT_UINT16,
+ BASE_DEC, NULL, 0x0, NULL, HFILL
+ }
+ },
+ {
+ &hf_pw_atm_o2o_cw_flags,
+ {
+ "ATM One-to-one Cell Mode flags",
+ "pw_atm_o2o_cw_flags", FT_UINT8,
+ BASE_HEX, NULL, 0x0, NULL, HFILL
+ }
+
+ },
+ {
+ &hf_pw_atm_o2o_cw_flags_m,
+ {
+ "M (transport mode) bit",
+ "pw_atm_o2o_cw_flags_m", FT_BOOLEAN,
+ 8, TFS(&flags_set_truth), PW_ATM_O2O_CW_M,
+ NULL, HFILL
+ }
+ },
+ {
+ &hf_pw_atm_o2o_cw_flags_v,
+ {
+ "V (VCI present) bit",
+ "pw_atm_o2o_cw_flags_v", FT_BOOLEAN,
+ 8, TFS(&flags_set_truth), PW_ATM_O2O_CW_V,
+ NULL, HFILL
+ }
+ },
+ {
+ &hf_pw_atm_o2o_cw_flags_res,
+ {
+ "Reserved bits",
+ "pw_atm_o2o_cw_flags_res", FT_BOOLEAN,
+ 8, TFS(&flags_set_truth), PW_ATM_O2O_CW_RES,
+ NULL, HFILL
+ }
+ },
+ {
+ &hf_pw_atm_o2o_cw_flags_pti,
+ {
+ "PTI bits",
+ "pw_atm_o2o_cw_flags_pti", FT_BOOLEAN,
+ 8, TFS(&flags_set_truth), PW_ATM_O2O_CW_PTI,
+ NULL, HFILL
+ }
+ },
+ {
+ &hf_pw_atm_o2o_cw_flags_c,
+ {
+ "C (CLP) bit",
+ "pw_atm_o2o_cw_flags_c", FT_BOOLEAN,
+ 8, TFS(&flags_set_truth), PW_ATM_O2O_CW_C,
+ NULL, HFILL
+ }
+ },
+ /* FF: AAL5 PDU Frame Mode Control Word fields */
+ {
+ &hf_pw_atm_aal5_pdu_cw_sequence_number,
+ {
+ "AAL5 PDU Frame Mode sequence number",
+ "pw_atm_aal5_pdu_cw_sequence_number",
+ FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL
+ }
+ },
+ /* FF: AAL5 SDU Frame Mode Control Word fields */
+ {
+ &hf_pw_atm_aal5_sdu_cw_sequence_number,
+ {
+ "AAL5 SDU Frame Mode sequence number",
+ "pw_atm_aal5_sdu_cw_sequence_number",
+ FT_UINT16, BASE_DEC, NULL, 0x0, NULL, HFILL
+ }
+ },
+#endif
+ /* FF: ATM N-to-one Cell Mode Control Word fields */
+ {
+ &hf_pw_atm_n2o_cw_flags,
+ {
+ "ATM N-to-one Cell Mode flags",
+ "pw_atm_n2o_cw_flags", FT_UINT8,
+ BASE_HEX, NULL, 0x0, NULL, HFILL
+ }
+
+ },
+ {
+ &hf_pw_atm_n2o_cw_length,
+ {
+ "ATM N-to-one Cell Mode flags",
+ "pw_atm_n2o_cw_length", FT_UINT8,
+ BASE_HEX, NULL, 0x0, NULL, HFILL
+ }
+
+ },
+ {
+ &hf_pw_atm_n2o_cw_sequence_number,
+ {
+ "ATM N-to-one Cell Mode sequence number",
+ "pw_atm_n2o_cw_sequence_number", FT_UINT16,
+ BASE_DEC, NULL, 0x0, NULL, HFILL
+ }
+ },
+ };
+
+ static gint *ett[] = {
+ &ett_pw_atm
+ };
+
+ proto_pw_atm_n2o_cw =
+ proto_register_protocol("ATM PW, N-to-one Cell Mode Control Word",
+ "ATM PW, N-to-one Cell Mode (with CW)",
+ "pw_atm_n2o_cw");
+ proto_pw_atm_n2o_nocw =
+ proto_register_protocol("ATM PW, N-to-one Cell Mode (no CW)",
+ "ATM PW, N-to-one Cell Mode (no CW)",
+ "pw_atm_n2o_nocw");
+#if 0
+ proto_pw_atm_o2o_cw =
+ proto_register_protocol("ATM PW, One-to-one Cell Mode Control Word",
+ "ATM PW, One-to-one Cell Mode (with CW)",
+ "pw_atm_o2o_cw");
+ proto_pw_atm_o2o_nocw =
+ proto_register_protocol("ATM PW, One-to-one Cell Mode (no CW)",
+ "ATM PW, One-to-one Cell Mode (no CW)",
+ "pw_atm_o2o_nocw");
+ proto_pw_atm_aal5_pdu_cw =
+ proto_register_protocol("ATM PW, AAL5 PDU Frame Mode Control Word",
+ "ATM PW, AAL5 PDU Frame Mode (with CW)",
+ "pw_atm_aal5_pdu_cw");
+ proto_pw_atm_aal5_pdu_nocw =
+ proto_register_protocol("ATM PW, AAL5 PDU Frame Mode (no CW)",
+ "ATM PW, AAL5 PDU Frame Mode (no CW)",
+ "pw_atm_aal5_pdu_nocw");
+ proto_pw_atm_aal5_sdu_cw =
+ proto_register_protocol("ATM PW, AAL5 SDU Frame Mode Control Word",
+ "ATM PW, AAL5 SDU Frame Mode (with CW)",
+ "pw_atm_aal5_sdu_cw");
+ proto_pw_atm_aal5_sdu_nocw =
+ proto_register_protocol("ATM PW, AAL5 SDU Frame Mode (no CW)",
+ "ATM PW, AAL5 SDU Frame Mode (no CW)",
+ "pw_atm_aal5_sdu_nocw");
+#endif
+
+ proto_register_field_array(proto_pw_atm_n2o_cw, hf, array_length(hf));
+ proto_register_subtree_array(ett, array_length(ett));
+
+ register_dissector("pw_atm_n2o_cw",
+ dissect_pw_atm_n2o_cw,
+ proto_pw_atm_n2o_cw);
+ register_dissector("pw_atm_n2o_nocw",
+ dissect_pw_atm_n2o_nocw,
+ proto_pw_atm_n2o_nocw);
+#if 0
+ register_dissector("pw_atm_o2o_cw",
+ dissect_pw_atm_o2o_cw,
+ proto_pw_atm_o2o_cw);
+ register_dissector("pw_atm_o2o_nocw",
+ dissect_pw_atm_o2o_nocw,
+ proto_pw_atm_o2o_nocw);
+ register_dissector("pw_atm_aal5_pdu_cw",
+ dissect_pw_atm_aal5_pdu_cw,
+ proto_pw_atm_aal5_pdu_cw);
+ register_dissector("pw_atm_aal5_pdu_nocw",
+ dissect_pw_atm_aal5_pdu_nocw,
+ proto_pw_atm_aal5_pdu_nocw);
+ register_dissector("pw_atm_aal5_sdu_cw",
+ dissect_pw_atm_aal5_sdu_cw,
+ proto_pw_atm_aal5_sdu_cw);
+ register_dissector("pw_atm_aal5_sdu_nocw",
+ dissect_pw_atm_aal5_sdu_nocw,
+ proto_pw_atm_aal5_sdu_nocw);
+#endif
+}
+
+void
+proto_reg_handoff_pw_atm(void)
+{
+ dissector_handle_t pw_atm_n2o_cw_h;
+ dissector_handle_t pw_atm_n2o_nocw_h;
+#if 0
+ dissector_handle_t pw_atm_o2o_cw_h;
+ dissector_handle_t pw_atm_o2o_nocw_h;
+ dissector_handle_t pw_atm_aal5_pdu_cw_h;
+ dissector_handle_t pw_atm_aal5_pdu_nocw_h;
+ dissector_handle_t pw_atm_aal5_sdu_cw_h;
+ dissector_handle_t pw_atm_aal5_sdu_nocw_h;
+#endif
+
+ pw_atm_n2o_cw_h = find_dissector("pw_atm_n2o_cw");
+ dissector_add("mpls.label", LABEL_INVALID, pw_atm_n2o_cw_h);
+
+ pw_atm_n2o_nocw_h = find_dissector("pw_atm_n2o_nocw");
+ dissector_add("mpls.label", LABEL_INVALID, pw_atm_n2o_nocw_h);
+#if 0
+ pw_atm_o2o_cw_h = find_dissector("pw_atm_o2o_cw");
+ dissector_add("mpls.label", LABEL_INVALID, pw_atm_o2o_cw_h);
+
+ pw_atm_o2o_nocw_h = find_dissector("pw_atm_o2o_nocw");
+ dissector_add("mpls.label", LABEL_INVALID, pw_atm_o2o_nocw_h);
+
+ pw_atm_aal5_pdu_cw_h = find_dissector("pw_atm_aal5_pdu_cw");
+ dissector_add("mpls.label", LABEL_INVALID, pw_atm_aal5_pdu_cw_h);
+
+ pw_atm_aal5_pdu_nocw_h = find_dissector("pw_atm_aal5_pdu_nocw");
+ dissector_add("mpls.label", LABEL_INVALID, pw_atm_aal5_pdu_nocw_h);
+
+ pw_atm_aal5_sdu_cw_h = find_dissector("pw_atm_aal5_sdu_cw");
+ dissector_add("mpls.label", LABEL_INVALID, pw_atm_aal5_sdu_cw_h);
+
+ pw_atm_aal5_sdu_nocw_h = find_dissector("pw_atm_aal5_sdu_nocw");
+ dissector_add("mpls.label", LABEL_INVALID, pw_atm_aal5_sdu_nocw_h);
+#endif
+
+ data_h = find_dissector("data");
+ atm_h = find_dissector("atm_4717");
+}
diff --git a/epan/dissectors/packet-pw-eth.c b/epan/dissectors/packet-pw-eth.c
index a54d3e9325..fa9ce27253 100644
--- a/epan/dissectors/packet-pw-eth.c
+++ b/epan/dissectors/packet-pw-eth.c
@@ -1,6 +1,5 @@
/* packet-pw-eth.c
- * Routines for ethernet PW dissection:
- * it should be conformance to RFC 4448.
+ * Routines for ethernet PW dissection: it should be conform to RFC 4448.
*
* Copyright 2008 _FF_
*
@@ -50,87 +49,58 @@ static int hf_pw_eth = -1;
static int hf_pw_eth_cw = -1;
static int hf_pw_eth_cw_sequence_number = -1;
-static hf_register_info hf[] = {
- {
- &hf_pw_eth,
- {
- "PW (ethernet)",
- "pweth", FT_BOOLEAN,
- 0, NULL, 0x0, NULL, HFILL
- }
- },
- {
- &hf_pw_eth_cw,
- {
- "PW Control Word (ethernet)",
- "pweth.cw", FT_BOOLEAN,
- 0, NULL, 0x0, NULL, HFILL
- }
- },
- {
- &hf_pw_eth_cw_sequence_number,
- {
- "PW sequence number (ethernet)",
- "pweth.cw.sequence_number", FT_UINT16,
- BASE_DEC, NULL, 0x0, NULL, HFILL
- }
- }
-};
-
-static gint *ett[] = {
- &ett_pw_eth
-};
-
static dissector_handle_t eth_withoutfcs_handle;
static void
dissect_pw_eth_cw(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
- proto_tree *pw_eth_tree = NULL;
- proto_item *ti = NULL;
- tvbuff_t *next_tvb = NULL;
- guint16 sequence_number = 0;
-
- if (tvb_reported_length_remaining(tvb, 0) < 4) {
- if (tree)
- proto_tree_add_text(tree, tvb, 0, -1,
- "Error processing Message");
- return;
- }
-
- if ( dissect_try_cw_first_nibble( tvb, pinfo, tree ))
- return;
-
- sequence_number = tvb_get_ntohs(tvb, 2);
- if (tree) {
- ti = proto_tree_add_boolean(tree, hf_pw_eth_cw, tvb, 0, 0, TRUE);
- PROTO_ITEM_SET_HIDDEN(ti);
- ti = proto_tree_add_item(tree, proto_pw_eth_cw, tvb, 0, 4, FALSE);
- pw_eth_tree = proto_item_add_subtree(ti, ett_pw_eth);
- if (pw_eth_tree == NULL)
- return;
- proto_tree_add_uint_format(pw_eth_tree,
- hf_pw_eth_cw_sequence_number,
- tvb, 2, 2, sequence_number,
- "Sequence Number: %d",
- sequence_number);
- }
- next_tvb = tvb_new_subset(tvb, 4, -1, -1);
- call_dissector(eth_withoutfcs_handle, next_tvb, pinfo, tree);
+ proto_tree *pw_eth_tree = NULL;
+ proto_item *ti = NULL;
+ tvbuff_t *next_tvb = NULL;
+ guint16 sequence_number = 0;
+
+ if (tvb_reported_length_remaining(tvb, 0) < 4) {
+ if (tree)
+ proto_tree_add_text(tree, tvb, 0, -1,
+ "Error processing Message");
+ return;
+ }
+
+ if (dissect_try_cw_first_nibble(tvb, pinfo, tree))
+ return;
+
+ sequence_number = tvb_get_ntohs(tvb, 2);
+ if (tree) {
+ ti = proto_tree_add_boolean(tree, hf_pw_eth_cw,
+ tvb, 0, 0, TRUE);
+ PROTO_ITEM_SET_HIDDEN(ti);
+ ti = proto_tree_add_item(tree, proto_pw_eth_cw,
+ tvb, 0, 4, FALSE);
+ pw_eth_tree = proto_item_add_subtree(ti, ett_pw_eth);
+ if (pw_eth_tree == NULL)
+ return;
+ proto_tree_add_uint_format(pw_eth_tree,
+ hf_pw_eth_cw_sequence_number,
+ tvb, 2, 2, sequence_number,
+ "Sequence Number: %d",
+ sequence_number);
+ }
+ next_tvb = tvb_new_subset(tvb, 4, -1, -1);
+ call_dissector(eth_withoutfcs_handle, next_tvb, pinfo, tree);
}
static void
dissect_pw_eth_nocw(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
- tvbuff_t *next_tvb = NULL;
- proto_item *ti = NULL;
-
- if (tree) {
- ti = proto_tree_add_boolean(tree, hf_pw_eth, tvb, 0, 0, TRUE);
- PROTO_ITEM_SET_HIDDEN(ti);
- }
- next_tvb = tvb_new_subset(tvb, 0, -1, -1);
- call_dissector(eth_withoutfcs_handle, next_tvb, pinfo, tree);
+ tvbuff_t *next_tvb = NULL;
+ proto_item *ti = NULL;
+
+ if (tree) {
+ ti = proto_tree_add_boolean(tree, hf_pw_eth, tvb, 0, 0, TRUE);
+ PROTO_ITEM_SET_HIDDEN(ti);
+ }
+ next_tvb = tvb_new_subset(tvb, 0, -1, -1);
+ call_dissector(eth_withoutfcs_handle, next_tvb, pinfo, tree);
}
/*
@@ -140,66 +110,103 @@ dissect_pw_eth_nocw(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
static gboolean
looks_like_plain_eth(tvbuff_t *tvb _U_)
{
- const gchar *manuf_name_da = NULL;
- const gchar *manuf_name_sa = NULL;
+ const gchar *manuf_name_da = NULL;
+ const gchar *manuf_name_sa = NULL;
- if (tvb_reported_length_remaining(tvb, 0) < 14) {
- return FALSE;
- }
+ if (tvb_reported_length_remaining(tvb, 0) < 14) {
+ return FALSE;
+ }
- manuf_name_da = get_manuf_name_if_known(tvb_get_ptr(tvb, 0, 6));
- manuf_name_sa = get_manuf_name_if_known(tvb_get_ptr(tvb, 6, 6));
+ manuf_name_da = get_manuf_name_if_known(tvb_get_ptr(tvb, 0, 6));
+ manuf_name_sa = get_manuf_name_if_known(tvb_get_ptr(tvb, 6, 6));
- if (manuf_name_da && manuf_name_sa) {
- return TRUE;
- }
+ if (manuf_name_da && manuf_name_sa) {
+ return TRUE;
+ }
- return FALSE;
+ return FALSE;
}
-static void dissect_pw_eth_heuristic(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+static void
+dissect_pw_eth_heuristic(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
- if (looks_like_plain_eth(tvb)) {
- call_dissector( find_dissector("pw_eth_nocw"), tvb, pinfo, tree);
- } else {
- call_dissector( find_dissector("pw_eth_cw"), tvb, pinfo, tree);
- }
+ if (looks_like_plain_eth(tvb)) {
+ call_dissector(find_dissector("pw_eth_nocw"), tvb, pinfo, tree);
+ } else {
+ call_dissector(find_dissector("pw_eth_cw"), tvb, pinfo, tree);
+ }
}
void
proto_register_pw_eth(void)
{
- proto_pw_eth_cw = proto_register_protocol("PW Ethernet Control Word",
- "Ethernet PW (with CW)",
- "pwethcw");
- proto_pw_eth_nocw = proto_register_protocol("Ethernet PW (no CW)", /*not displayed*/
- "Ethernet PW (no CW)",
- "pwethnocw");
- proto_pw_eth_heuristic = proto_register_protocol("Ethernet PW (CW heuristic)", /*not displayed*/
- "Ethernet PW (CW heuristic)",
- "pwethheuristic");
- proto_register_field_array(proto_pw_eth_cw, hf, array_length(hf));
- proto_register_subtree_array(ett, array_length(ett));
- register_dissector("pw_eth_cw", dissect_pw_eth_cw, proto_pw_eth_cw);
- register_dissector("pw_eth_nocw", dissect_pw_eth_nocw, proto_pw_eth_nocw);
- register_dissector("pw_eth_heuristic", dissect_pw_eth_heuristic, proto_pw_eth_heuristic );
+ static hf_register_info hf[] = {
+ {
+ &hf_pw_eth,
+ {
+ "PW (ethernet)",
+ "pweth", FT_BOOLEAN,
+ 0, NULL, 0x0, NULL, HFILL
+ }
+ },
+ {
+ &hf_pw_eth_cw,
+ {
+ "PW Control Word (ethernet)",
+ "pweth.cw", FT_BOOLEAN,
+ 0, NULL, 0x0, NULL, HFILL
+ }
+ },
+ {
+ &hf_pw_eth_cw_sequence_number,
+ {
+ "PW sequence number (ethernet)",
+ "pweth.cw.sequence_number", FT_UINT16,
+ BASE_DEC, NULL, 0x0, NULL, HFILL
+ }
+ }
+ };
+
+ static gint *ett[] = {
+ &ett_pw_eth
+ };
+
+ proto_pw_eth_cw =
+ proto_register_protocol("PW Ethernet Control Word",
+ "Ethernet PW (with CW)",
+ "pwethcw");
+ proto_pw_eth_nocw =
+ proto_register_protocol("Ethernet PW (no CW)", /* not displayed */
+ "Ethernet PW (no CW)",
+ "pwethnocw");
+ proto_pw_eth_heuristic =
+ proto_register_protocol("Ethernet PW (CW heuristic)", /* not disp. */
+ "Ethernet PW (CW heuristic)",
+ "pwethheuristic");
+ proto_register_field_array(proto_pw_eth_cw, hf, array_length(hf));
+ proto_register_subtree_array(ett, array_length(ett));
+ register_dissector("pw_eth_cw", dissect_pw_eth_cw, proto_pw_eth_cw);
+ register_dissector("pw_eth_nocw", dissect_pw_eth_nocw,
+ proto_pw_eth_nocw);
+ register_dissector("pw_eth_heuristic", dissect_pw_eth_heuristic,
+ proto_pw_eth_heuristic);
}
void
proto_reg_handoff_pw_eth(void)
{
- dissector_handle_t pw_eth_handle_cw;
- dissector_handle_t pw_eth_handle_nocw;
- dissector_handle_t pw_eth_handle_heuristic;
+ dissector_handle_t pw_eth_handle_cw;
+ dissector_handle_t pw_eth_handle_nocw;
+ dissector_handle_t pw_eth_handle_heuristic;
- eth_withoutfcs_handle = find_dissector("eth_withoutfcs");
+ eth_withoutfcs_handle = find_dissector("eth_withoutfcs");
- pw_eth_handle_cw = find_dissector("pw_eth_cw");
- dissector_add("mpls.label", LABEL_INVALID, pw_eth_handle_cw);
+ pw_eth_handle_cw = find_dissector("pw_eth_cw");
+ dissector_add("mpls.label", LABEL_INVALID, pw_eth_handle_cw);
- pw_eth_handle_nocw = find_dissector("pw_eth_nocw");
- dissector_add("mpls.label", LABEL_INVALID, pw_eth_handle_nocw);
+ pw_eth_handle_nocw = find_dissector("pw_eth_nocw");
+ dissector_add("mpls.label", LABEL_INVALID, pw_eth_handle_nocw);
- pw_eth_handle_heuristic = find_dissector("pw_eth_heuristic");
- dissector_add("mpls.label", LABEL_INVALID, pw_eth_handle_heuristic);
+ pw_eth_handle_heuristic = find_dissector("pw_eth_heuristic");
+ dissector_add("mpls.label", LABEL_INVALID, pw_eth_handle_heuristic);
}
diff --git a/epan/packet_info.h b/epan/packet_info.h
index c865783b71..b32b26c9c9 100644
--- a/epan/packet_info.h
+++ b/epan/packet_info.h
@@ -182,6 +182,28 @@ typedef struct _packet_info {
struct _sccp_msg_info_t* sccp_info;
guint16 clnp_srcref; /* clnp/cotp source reference (can't use srcport, this would confuse tpkt) */
guint16 clnp_dstref; /* clnp/cotp destination reference (can't use dstport, this would confuse tpkt) */
+ guint8 pw_atm_encap_type; /* FF: RFC 4717 is devilish, it describes many
+ * different types of ATM->PW encapsulation.
+ * None of which can correctly be interpreted by
+ * the packet-atm.c dissector. Thus I have to
+ * pass some info from packet-pw-atm.c to packet-
+ * -atm.c, and augment/change packet-atm.c
+ * dissector.
+ *
+ * 0: RFC4717::Sec. 9, ATM One-to-One Cell Mode
+ * 1: RFC4717::Sec. 8, ATM N-to-One Cell Mode
+ * 2: RFC4717::Sec. 10, ATM AAL5 CPCS-SDU Mode
+ * 3: RFC4717::Sec. 11, ATM AAL5 PDU Frame Mode
+ */
+ guint16 pw_atm_flags; /* FF: all flags defined in RFC4717 compacted in a
+ * single guint16.
+ *
+ * T, E, C, U, M, V, PTI, C flag name
+ * 9 8 7 6 5 4 321 0 position
+ */
+ guint16 pw_atm_ncells; /* FF: number of cells fitted in a single
+ * PW frame.
+ */
} packet_info;
#endif /* __PACKET_INFO_H__ */