/* packet-atm.c
* Routines for ATM packet disassembly
*
- * $Id: packet-atm.c,v 1.42 2002/04/30 08:48:25 guy Exp $
+ * $Id: packet-atm.c,v 1.49 2002/08/28 21:00:07 jmayer Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
* 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.
# include "config.h"
#endif
-#ifdef HAVE_SYS_TYPES_H
-# include <sys/types.h>
-#endif
-
#include <stdio.h>
#include <glib.h>
#include <epan/packet.h>
#include "oui.h"
#include <epan/resolv.h>
+#include "packet-atm.h"
#include "packet-snmp.h"
+#include "packet-eth.h"
+#include "packet-tr.h"
+#include "packet-llc.h"
static int proto_atm = -1;
static int hf_atm_vpi = -1;
#define LE_FLUSH_RESPONSE 0x0107
#define LE_NARP_REQUEST 0x0008
#define LE_TOPOLOGY_REQUEST 0x0009
+#define LE_VERIFY_REQUEST 0x000A
+#define LE_VERIFY_RESPONSE 0x010A
static const value_string le_control_opcode_vals[] = {
{ LE_CONFIGURE_REQUEST, "LE_CONFIGURE_REQUEST" },
{ LE_FLUSH_RESPONSE, "LE_FLUSH_RESPONSE" },
{ LE_NARP_REQUEST, "LE_NARP_REQUEST" },
{ LE_TOPOLOGY_REQUEST, "LE_TOPOLOGY_REQUEST" },
+ { LE_VERIFY_REQUEST, "LE_VERIFY_REQUEST" },
+ { LE_VERIFY_RESPONSE, "LE_VERIFY_RESPONSE" },
{ 0, NULL }
};
{ 20, "No configuraton" },
{ 21, "LE_CONFIGURE error" },
{ 22, "Insufficient information" },
+ { 24, "TLV not found" },
{ 0, NULL }
};
{ 0, NULL }
};
+static const value_string le_control_frame_size_vals[] = {
+ { 0x00, "Unspecified" },
+ { 0x01, "1516/1528/1580/1592" },
+ { 0x02, "4544/4556/1580/1592" },
+ { 0x03, "9234/9246" },
+ { 0x04, "18190/18202" },
+ { 0, NULL }
+};
+
static void
dissect_le_client(tvbuff_t *tvb, proto_tree *tree)
{
}
static void
-dissect_lan_destination(tvbuff_t *tvb, int offset, const char *type, proto_tree *tree)
+dissect_lan_destination(tvbuff_t *tvb, int offset, const char *type, proto_tree *tree)
{
proto_item *td;
proto_tree *dest_tree;
#define LE_MCAST_SEND_VCC_AVGRATE TLV_TYPE(OUI_ATM_FORUM, 0x0D)
#define LE_MCAST_SEND_VCC_PEAKRATE TLV_TYPE(OUI_ATM_FORUM, 0x0E)
#define LE_CONN_COMPLETION_TIMER TLV_TYPE(OUI_ATM_FORUM, 0x0F)
+#define LE_CONFIG_FRAG_INFO TLV_TYPE(OUI_ATM_FORUM, 0x10)
+#define LE_LAYER_3_ADDRESS TLV_TYPE(OUI_ATM_FORUM, 0x11)
+#define LE_ELAN_ID TLV_TYPE(OUI_ATM_FORUM, 0x12)
+#define LE_SERVICE_CATEGORY TLV_TYPE(OUI_ATM_FORUM, 0x13)
+#define LE_LLC_MUXED_ATM_ADDRESS TLV_TYPE(OUI_ATM_FORUM, 0x2B)
+#define LE_X5_ADJUSTMENT TLV_TYPE(OUI_ATM_FORUM, 0x2C)
+#define LE_PREFERRED_LES TLV_TYPE(OUI_ATM_FORUM, 0x2D)
static const value_string le_tlv_type_vals[] = {
{ LE_CONTROL_TIMEOUT, "Control Time-out" },
{ LE_MCAST_SEND_VCC_AVGRATE, "Mcast Send VCC AvgRate" },
{ LE_MCAST_SEND_VCC_PEAKRATE, "Mcast Send VCC PeakRate" },
{ LE_CONN_COMPLETION_TIMER, "Connection Completion Timer" },
+ { LE_CONFIG_FRAG_INFO, "Config Frag Info" },
+ { LE_LAYER_3_ADDRESS, "Layer 3 Address" },
+ { LE_ELAN_ID, "ELAN ID" },
+ { LE_SERVICE_CATEGORY, "Service Category" },
+ { LE_LLC_MUXED_ATM_ADDRESS, "LLC-muxed ATM Address" },
+ { LE_X5_ADJUSTMENT, "X5 Adjustment" },
+ { LE_PREFERRED_LES, "Preferred LES" },
{ 0, NULL },
};
+static void
+dissect_le_control_tlvs(tvbuff_t *tvb, int offset, guint num_tlvs,
+ proto_tree *tree)
+{
+ guint32 tlv_type;
+ guint8 tlv_length;
+ proto_item *ttlv;
+ proto_tree *tlv_tree;
+
+ while (num_tlvs != 0) {
+ tlv_type = tvb_get_ntohl(tvb, offset);
+ tlv_length = tvb_get_guint8(tvb, offset+4);
+ ttlv = proto_tree_add_text(tree, tvb, offset, 5+tlv_length, "TLV type: %s",
+ val_to_str(tlv_type, le_tlv_type_vals, "Unknown (0x%08x)"));
+ tlv_tree = proto_item_add_subtree(ttlv, ett_atm_lane_lc_tlv);
+ proto_tree_add_text(tlv_tree, tvb, offset, 4, "TLV Type: %s",
+ val_to_str(tlv_type, le_tlv_type_vals, "Unknown (0x%08x)"));
+ proto_tree_add_text(tlv_tree, tvb, offset+4, 1, "TLV Length: %u", tlv_length);
+ offset += 5+tlv_length;
+ num_tlvs--;
+ }
+}
+
+static void
+dissect_le_configure_join_frame(tvbuff_t *tvb, int offset, proto_tree *tree)
+{
+ guint8 num_tlvs;
+ guint8 name_size;
+
+ dissect_lan_destination(tvb, offset, "Source", tree);
+ offset += 8;
+
+ dissect_lan_destination(tvb, offset, "Target", tree);
+ offset += 8;
+
+ proto_tree_add_text(tree, tvb, offset, 20, "Source ATM Address: %s",
+ tvb_bytes_to_str(tvb, offset, 20));
+ offset += 20;
+
+ proto_tree_add_text(tree, tvb, offset, 1, "LAN type: %s",
+ val_to_str(tvb_get_guint8(tvb, offset), le_control_lan_type_vals,
+ "Unknown (0x%02X)"));
+ offset += 1;
+
+ proto_tree_add_text(tree, tvb, offset, 1, "Maximum frame size: %s",
+ val_to_str(tvb_get_guint8(tvb, offset), le_control_frame_size_vals,
+ "Unknown (0x%02X)"));
+ offset += 1;
+
+ num_tlvs = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(tree, tvb, offset, 1, "Number of TLVs: %u", num_tlvs);
+ offset += 1;
+
+ name_size = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(tree, tvb, offset, 1, "ELAN name size: %u", name_size);
+ offset += 1;
+
+ proto_tree_add_text(tree, tvb, offset, 20, "Target ATM Address: %s",
+ tvb_bytes_to_str(tvb, offset, 20));
+ offset += 20;
+
+ if (name_size > 32)
+ name_size = 32;
+ if (name_size != 0) {
+ proto_tree_add_text(tree, tvb, offset, name_size, "ELAN name: %s",
+ tvb_bytes_to_str(tvb, offset, name_size));
+ }
+ offset += 32;
+
+ dissect_le_control_tlvs(tvb, offset, num_tlvs, tree);
+}
+
+static void
+dissect_le_registration_frame(tvbuff_t *tvb, int offset, proto_tree *tree)
+{
+ guint8 num_tlvs;
+
+ dissect_lan_destination(tvb, offset, "Source", tree);
+ offset += 8;
+
+ dissect_lan_destination(tvb, offset, "Target", tree);
+ offset += 8;
+
+ proto_tree_add_text(tree, tvb, offset, 20, "Source ATM Address: %s",
+ tvb_bytes_to_str(tvb, offset, 20));
+ offset += 20;
+
+ /* Reserved */
+ offset += 2;
+
+ num_tlvs = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(tree, tvb, offset, 1, "Number of TLVs: %u", num_tlvs);
+ offset += 1;
+
+ /* Reserved */
+ offset += 53;
+
+ dissect_le_control_tlvs(tvb, offset, num_tlvs, tree);
+}
+
+static void
+dissect_le_arp_frame(tvbuff_t *tvb, int offset, proto_tree *tree)
+{
+ guint8 num_tlvs;
+
+ dissect_lan_destination(tvb, offset, "Source", tree);
+ offset += 8;
+
+ dissect_lan_destination(tvb, offset, "Target", tree);
+ offset += 8;
+
+ proto_tree_add_text(tree, tvb, offset, 20, "Source ATM Address: %s",
+ tvb_bytes_to_str(tvb, offset, 20));
+ offset += 20;
+
+ /* Reserved */
+ offset += 2;
+
+ num_tlvs = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(tree, tvb, offset, 1, "Number of TLVs: %u", num_tlvs);
+ offset += 1;
+
+ /* Reserved */
+ offset += 1;
+
+ proto_tree_add_text(tree, tvb, offset, 20, "Target ATM Address: %s",
+ tvb_bytes_to_str(tvb, offset, 20));
+ offset += 20;
+
+ /* Reserved */
+ offset += 32;
+
+ dissect_le_control_tlvs(tvb, offset, num_tlvs, tree);
+}
+
+static void
+dissect_le_verify_frame(tvbuff_t *tvb, int offset, proto_tree *tree)
+{
+ guint8 num_tlvs;
+
+ /* Reserved */
+ offset += 38;
+
+ num_tlvs = tvb_get_guint8(tvb, offset);
+ proto_tree_add_text(tree, tvb, offset, 1, "Number of TLVs: %u", num_tlvs);
+ offset += 1;
+
+ /* Reserved */
+ offset += 1;
+
+ proto_tree_add_text(tree, tvb, offset, 20, "Target ATM Address: %s",
+ tvb_bytes_to_str(tvb, offset, 20));
+ offset += 20;
+
+ /* Reserved */
+ offset += 32;
+
+ dissect_le_control_tlvs(tvb, offset, num_tlvs, tree);
+}
+
+static void
+dissect_le_flush_frame(tvbuff_t *tvb, int offset, proto_tree *tree)
+{
+ dissect_lan_destination(tvb, offset, "Source", tree);
+ offset += 8;
+
+ dissect_lan_destination(tvb, offset, "Target", tree);
+ offset += 8;
+
+ proto_tree_add_text(tree, tvb, offset, 20, "Source ATM Address: %s",
+ tvb_bytes_to_str(tvb, offset, 20));
+ offset += 20;
+
+ /* Reserved */
+ offset += 4;
+
+ proto_tree_add_text(tree, tvb, offset, 20, "Target ATM Address: %s",
+ tvb_bytes_to_str(tvb, offset, 20));
+ offset += 20;
+
+ /* Reserved */
+ offset += 32;
+}
+
static void
dissect_le_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
int offset = 0;
proto_item *tf;
proto_tree *flags_tree;
- proto_item *ttlv;
- proto_tree *tlv_tree;
guint16 opcode;
guint16 flags;
- guint8 num_tlvs;
- guint32 tlv_type;
- guint8 tlv_length;
if (check_col(pinfo->cinfo, COL_INFO))
col_set_str(pinfo->cinfo, COL_INFO, "LE Control");
tf = proto_tree_add_text(lane_tree, tvb, offset, 2, "Flags: 0x%04X",
flags);
flags_tree = proto_item_add_subtree(tf, ett_atm_lane_lc_flags);
- proto_tree_add_text(flags_tree, tvb, offset, 2, "%s",
- decode_boolean_bitfield(flags, 0x0001, 8*2,
- "Remote address", "Local address"));
- proto_tree_add_text(flags_tree, tvb, offset, 2, "%s",
+
+ switch (opcode) {
+
+ case LE_CONFIGURE_REQUEST:
+ case LE_CONFIGURE_RESPONSE:
+ proto_tree_add_text(flags_tree, tvb, offset, 2, "%s",
+ decode_boolean_bitfield(flags, 0x0002, 8*2,
+ "V2 capable", "Not V2 capable"));
+ offset += 2;
+ dissect_le_configure_join_frame(tvb, offset, lane_tree);
+ break;
+
+ case LE_JOIN_REQUEST:
+ case LE_JOIN_RESPONSE:
+ proto_tree_add_text(flags_tree, tvb, offset, 2, "%s",
+ decode_boolean_bitfield(flags, 0x0002, 8*2,
+ "V2 capable", "Not V2 capable"));
+ if (opcode == LE_JOIN_REQUEST) {
+ proto_tree_add_text(flags_tree, tvb, offset, 2, "%s",
+ decode_boolean_bitfield(flags, 0x0004, 8*2,
+ "Selective multicast", "No selective multicast"));
+ } else {
+ proto_tree_add_text(flags_tree, tvb, offset, 2, "%s",
+ decode_boolean_bitfield(flags, 0x0008, 8*2,
+ "V2 required", "V2 not required"));
+ }
+ proto_tree_add_text(flags_tree, tvb, offset, 2, "%s",
decode_boolean_bitfield(flags, 0x0080, 8*2,
"Proxy", "Not proxy"));
- proto_tree_add_text(flags_tree, tvb, offset, 2, "%s",
- decode_boolean_bitfield(flags, 0x0100, 8*2,
- "Topology change", "No topology change"));
- offset += 2;
-
- dissect_lan_destination(tvb, offset, "Source", lane_tree);
- offset += 8;
+ proto_tree_add_text(flags_tree, tvb, offset, 2, "%s",
+ decode_boolean_bitfield(flags, 0x0200, 8*2,
+ "Exclude explorer frames",
+ "Don't exclude explorer frames"));
+ offset += 2;
+ dissect_le_configure_join_frame(tvb, offset, lane_tree);
+ break;
- dissect_lan_destination(tvb, offset, "Target", lane_tree);
- offset += 8;
+ case LE_REGISTER_REQUEST:
+ case LE_REGISTER_RESPONSE:
+ case LE_UNREGISTER_REQUEST:
+ case LE_UNREGISTER_RESPONSE:
+ offset += 2;
+ dissect_le_registration_frame(tvb, offset, lane_tree);
+ break;
- proto_tree_add_text(lane_tree, tvb, offset, 20, "Source ATM Address: %s",
- tvb_bytes_to_str(tvb, offset, 20));
- offset += 20;
+ case LE_ARP_REQUEST:
+ case LE_ARP_RESPONSE:
+ case LE_NARP_REQUEST:
+ if (opcode != LE_NARP_REQUEST) {
+ proto_tree_add_text(flags_tree, tvb, offset, 2, "%s",
+ decode_boolean_bitfield(flags, 0x0001, 8*2,
+ "Remote address", "Local address"));
+ }
+ offset += 2;
+ dissect_le_arp_frame(tvb, offset, lane_tree);
+ break;
- proto_tree_add_text(lane_tree, tvb, offset, 1, "LAN type: %s",
- val_to_str(tvb_get_guint8(tvb, offset), le_control_lan_type_vals,
- "Unknown (0x%02X)"));
- offset += 1;
+ case LE_TOPOLOGY_REQUEST:
+ proto_tree_add_text(flags_tree, tvb, offset, 2, "%s",
+ decode_boolean_bitfield(flags, 0x0100, 8*2,
+ "Topology change", "No topology change"));
+ offset += 2;
+ /* 92 reserved bytes */
+ break;
- proto_tree_add_text(lane_tree, tvb, offset, 1, "Maximum frame size: %u",
- tvb_get_guint8(tvb, offset));
- offset += 1;
+ case LE_VERIFY_REQUEST:
+ case LE_VERIFY_RESPONSE:
+ offset += 2;
+ dissect_le_verify_frame(tvb, offset, lane_tree);
+ break;
- num_tlvs = tvb_get_guint8(tvb, offset);
- proto_tree_add_text(lane_tree, tvb, offset, 1, "Number of TLVs: %u",
- num_tlvs);
- offset += 1;
+ case LE_FLUSH_REQUEST:
+ case LE_FLUSH_RESPONSE:
+ offset += 2;
+ dissect_le_flush_frame(tvb, offset, lane_tree);
+ break;
+ }
+ }
+}
- proto_tree_add_text(lane_tree, tvb, offset, 1, "ELAN name size: %u",
- tvb_get_guint8(tvb, offset));
- offset += 1;
+static void
+capture_lane(const union wtap_pseudo_header *pseudo_header, const guchar *pd,
+ int len, packet_counts *ld)
+{
+ /* Is it LE Control, 802.3, 802.5, or "none of the above"? */
+ switch (pseudo_header->atm.subtype) {
- proto_tree_add_text(lane_tree, tvb, offset, 20, "Target ATM Address: %s",
- tvb_bytes_to_str(tvb, offset, 20));
- offset += 20;
+ case TRAF_ST_LANE_802_3:
+ case TRAF_ST_LANE_802_3_MC:
+ /* Dissect as Ethernet */
+ capture_eth(pd, 2, len, ld);
+ break;
- proto_tree_add_text(lane_tree, tvb, offset, 32, "ELAN name: %s",
- tvb_bytes_to_str(tvb, offset, 32));
- offset += 32;
+ case TRAF_ST_LANE_802_5:
+ case TRAF_ST_LANE_802_5_MC:
+ /* Dissect as Token-Ring */
+ capture_tr(pd, 2, len, ld);
+ break;
- while (num_tlvs != 0) {
- tlv_type = tvb_get_ntohl(tvb, offset);
- tlv_length = tvb_get_guint8(tvb, offset+4);
- ttlv = proto_tree_add_text(lane_tree, tvb, offset, 5+tlv_length, "TLV type: %s",
- val_to_str(tlv_type, le_tlv_type_vals, "Unknown (0x%08x)"));
- tlv_tree = proto_item_add_subtree(ttlv, ett_atm_lane_lc_tlv);
- proto_tree_add_text(tlv_tree, tvb, offset, 4, "TLV Type: %s",
- val_to_str(tlv_type, le_tlv_type_vals, "Unknown (0x%08x)"));
- proto_tree_add_text(tlv_tree, tvb, offset+4, 1, "TLV Length: %u", tlv_length);
- offset += 5+tlv_length;
- num_tlvs--;
- }
+ default:
+ ld->other++;
+ break;
}
}
{ 0, NULL }
};
+void
+capture_atm(const union wtap_pseudo_header *pseudo_header, const guchar *pd,
+ int len, packet_counts *ld)
+{
+ if (pseudo_header->atm.aal == AAL_5) {
+ switch (pseudo_header->atm.type) {
+
+ case TRAF_LLCMX:
+ /* Dissect as WTAP_ENCAP_ATM_RFC1483 */
+ /* The ATM iptrace capture that we have shows LLC at this point,
+ * so that's what I'm calling */
+ capture_llc(pd, 0, len, ld);
+ break;
+
+ case TRAF_LANE:
+ capture_lane(pseudo_header, pd, len, ld);
+ break;
+
+ default:
+ ld->other++;
+ break;
+ }
+ } else
+ ld->other++;
+}
+
static void
dissect_atm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
{
proto_tree *atm_tree;
proto_item *ti;
- guint8 byte0, byte1, byte2;
-
- /*
- * The joys of a connection-oriented link layer; the type of
- * traffic may be implied by the connection on which it's
- * traveling, rather than being specified in the packet itself.
- *
- * The program that captured the traffic might, or might not,
- * have known the traffic type; if it didn't see the connection
- * setup and wasn't running on one of the endpoints, and wasn't
- * later told, e.g. by the human running it, what type of traffic
- * was on that circuit, or was running on one of the endpoints
- * but was using, to capture the packets, a mechanism that either
- * doesn't have access to data saying what's going over the
- * connection or doesn't bother providing that information, it
- * won't have known the traffic type.
- *
- * If we don't know the full traffic type, we try to guess it
- * based on the VPI/VCI and/or the packet header; at some point,
- * we should provide a mechanism by which the user can specify
- * what sort of traffic is on a particular circuit.
- */
- if (pinfo->pseudo_header->atm.aal == AAL_5) {
- if (pinfo->pseudo_header->atm.type == TRAF_UNKNOWN) {
- /*
- * We don't know the traffic type at all.
- * Try to guess it based on the VPI and VCI.
- *
- * VPI 0, VCI 5 should have been mapped to AAL_SIGNALLING
- * by Wiretap.
- */
- if (pinfo->pseudo_header->atm.vpi == 0) {
- /*
- * Traffic on some PVCs with a VPI of 0 and certain
- * VCIs is of particular types.
- */
- switch (pinfo->pseudo_header->atm.vci) {
-
- case 16:
- /*
- * ILMI.
- */
- pinfo->pseudo_header->atm.type = TRAF_ILMI;
- break;
- }
- }
- }
-
- if (pinfo->pseudo_header->atm.type == TRAF_UNKNOWN) {
- /*
- * OK, we can't tell what it is based on the VPI/VCI; try
- * guessing based on the contents.
- */
- byte0 = tvb_get_guint8(tvb, 0);
- byte1 = tvb_get_guint8(tvb, 1);
- byte2 = tvb_get_guint8(tvb, 2);
- if (byte0 == 0xaa && byte1 == 0xaa && byte2 == 0x03) {
- /*
- * Looks like a SNAP header; assume it's LLC multiplexed
- * RFC 1483 traffic.
- */
- pinfo->pseudo_header->atm.type = TRAF_LLCMX;
- } else {
- /*
- * Assume it's LANE.
- */
- pinfo->pseudo_header->atm.type = TRAF_LANE;
- }
- }
-
- if (pinfo->pseudo_header->atm.type == TRAF_LANE &&
- pinfo->pseudo_header->atm.subtype == TRAF_ST_UNKNOWN) {
- /*
- * OK, it's LANE, but we don't know what type of LANE traffic
- * it is. Guess based on the first two bytes.
- */
- byte0 = tvb_get_guint8(tvb, 0);
- byte1 = tvb_get_guint8(tvb, 1);
- if (byte0 == 0xff && byte1 == 0x00) {
- /*
- * Looks like LE Control traffic.
- */
- pinfo->pseudo_header->atm.subtype = TRAF_ST_LANE_LE_CTRL;
- } else {
- /*
- * XXX - Ethernet, or Token Ring?
- * Assume Ethernet for now; if we see earlier
- * LANE traffic, we may be able to figure out
- * the traffic type from that, but there may
- * still be situations where the user has to
- * tell us.
- */
- pinfo->pseudo_header->atm.subtype = TRAF_ST_LANE_802_3;
- }
- }
- }
if (check_col(pinfo->cinfo, COL_PROTOCOL))
col_set_str(pinfo->cinfo, COL_PROTOCOL, "ATM");
"Unknown AAL5 traffic type (%u)"));
switch (pinfo->pseudo_header->atm.type) {
- case TRAF_LLCMX:
- proto_tree_add_text(atm_tree, tvb, 0, 0, "LLC multiplexed traffic");
- break;
-
case TRAF_VCMX:
proto_tree_add_text(atm_tree, tvb, 0, 0, "VC multiplexed traffic type: %s",
val_to_str(pinfo->pseudo_header->atm.subtype,