2 * Routines for ATM packet disassembly
4 * $Id: packet-atm.c,v 1.3 1999/11/18 07:29:54 guy Exp $
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@zing.org>
8 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or
12 * modify it under the terms of the GNU General Public License
13 * as published by the Free Software Foundation; either version 2
14 * of the License, or (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
30 #ifdef HAVE_SYS_TYPES_H
31 # include <sys/types.h>
39 #include "packet-snmp.h"
41 static int proto_atm = -1;
42 static int proto_atm_lane = -1;
43 static int proto_ilmi = -1;
45 static gint ett_atm = -1;
46 static gint ett_atm_lane = -1;
47 static gint ett_atm_lane_lc_lan_dest = -1;
48 static gint ett_atm_lane_lc_lan_dest_rd = -1;
49 static gint ett_atm_lane_lc_flags = -1;
50 static gint ett_ilmi = -1;
55 * http://www.atmforum.org/atmforum/specs/approved.html
57 * for a number of ATM Forum specifications, e.g. the LAN Emulation
58 * over ATM 1.0 spec, whence I got most of this.
61 /* LE Control opcodes */
62 #define LE_CONFIGURE_REQUEST 0x0001
63 #define LE_CONFIGURE_RESPONSE 0x0101
64 #define LE_JOIN_REQUEST 0x0002
65 #define LE_JOIN_RESPONSE 0x0102
66 #define READY_QUERY 0x0003
67 #define READY_IND 0x0103
68 #define LE_REGISTER_REQUEST 0x0004
69 #define LE_REGISTER_RESPONSE 0x0104
70 #define LE_UNREGISTER_REQUEST 0x0005
71 #define LE_UNREGISTER_RESPONSE 0x0105
72 #define LE_ARP_REQUEST 0x0006
73 #define LE_ARP_RESPONSE 0x0106
74 #define LE_FLUSH_REQUEST 0x0007
75 #define LE_FLUSH_RESPONSE 0x0107
76 #define LE_NARP_REQUEST 0x0008
77 #define LE_TOPOLOGY_REQUEST 0x0009
79 static const value_string le_control_opcode_vals[] = {
80 { LE_CONFIGURE_REQUEST, "LE_CONFIGURE_REQUEST" },
81 { LE_CONFIGURE_RESPONSE, "LE_CONFIGURE_RESPONSE" },
82 { LE_JOIN_REQUEST, "LE_JOIN_REQUEST" },
83 { LE_JOIN_RESPONSE, "LE_JOIN_RESPONSE" },
84 { READY_QUERY, "READY_QUERY" },
85 { READY_IND, "READY_IND" },
86 { LE_REGISTER_REQUEST, "LE_REGISTER_REQUEST" },
87 { LE_REGISTER_RESPONSE, "LE_REGISTER_RESPONSE" },
88 { LE_UNREGISTER_REQUEST, "LE_UNREGISTER_REQUEST" },
89 { LE_UNREGISTER_RESPONSE, "LE_UNREGISTER_RESPONSE" },
90 { LE_ARP_REQUEST, "LE_ARP_REQUEST" },
91 { LE_ARP_RESPONSE, "LE_ARP_RESPONSE" },
92 { LE_FLUSH_REQUEST, "LE_FLUSH_REQUEST" },
93 { LE_FLUSH_RESPONSE, "LE_FLUSH_RESPONSE" },
94 { LE_NARP_REQUEST, "LE_NARP_REQUEST" },
95 { LE_TOPOLOGY_REQUEST, "LE_TOPOLOGY_REQUEST" },
99 /* LE Control statuses */
100 static const value_string le_control_status_vals[] = {
102 { 1, "Version not supported" },
103 { 2, "Invalid request parameters" },
104 { 4, "Duplicate LAN destination registration" },
105 { 5, "Duplicate ATM address" },
106 { 6, "Insufficient resources to grant request" },
107 { 7, "Access denied" },
108 { 8, "Invalid REQUESTOR-ID" },
109 { 9, "Invalid LAN destination" },
110 { 10, "Invalid ATM address" },
111 { 20, "No configuraton" },
112 { 21, "LE_CONFIGURE error" },
113 { 22, "Insufficient information" },
117 /* LE Control LAN destination tags */
118 #define TAG_NOT_PRESENT 0x0000
119 #define TAG_MAC_ADDRESS 0x0001
120 #define TAG_ROUTE_DESCRIPTOR 0x0002
122 static const value_string le_control_landest_tag_vals[] = {
123 { TAG_NOT_PRESENT, "Not present" },
124 { TAG_MAC_ADDRESS, "MAC address" },
125 { TAG_ROUTE_DESCRIPTOR, "Route descriptor" },
129 /* LE Control LAN types */
130 #define LANT_UNSPEC 0x00
131 #define LANT_802_3 0x01
132 #define LANT_802_5 0x02
134 static const value_string le_control_lan_type_vals[] = {
135 { LANT_UNSPEC, "Unspecified" },
136 { LANT_802_3, "Ethernet/802.3" },
137 { LANT_802_5, "802.5" },
142 dissect_le_client(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
145 proto_tree *lane_tree;
148 ti = proto_tree_add_item_format(tree, proto_atm_lane, offset, 2, NULL,
150 lane_tree = proto_item_add_subtree(ti, ett_atm_lane);
152 proto_tree_add_text(lane_tree, offset, 2, "LE Client: 0x%04X",
153 pntohs(&pd[offset]));
158 dissect_lan_destination(const u_char *pd, int offset, const char *type, proto_tree *tree)
161 proto_tree *dest_tree;
165 guint16 route_descriptor;
167 td = proto_tree_add_text(tree, offset, 8, "%s LAN destination",
169 dest_tree = proto_item_add_subtree(td, ett_atm_lane_lc_lan_dest);
170 tag = pntohs(&pd[offset]);
171 proto_tree_add_text(dest_tree, offset, 2, "Tag: %s",
172 val_to_str(tag, le_control_landest_tag_vals,
178 case TAG_MAC_ADDRESS:
179 proto_tree_add_text(dest_tree, offset, 6, "MAC address: %s",
180 ether_to_str((u_char *)&pd[offset]));
183 case TAG_ROUTE_DESCRIPTOR:
185 route_descriptor = pntohs(&pd[offset]);
186 trd = proto_tree_add_text(dest_tree, offset, 2, "Route descriptor: 0x%02X",
188 rd_tree = proto_item_add_subtree(td, ett_atm_lane_lc_lan_dest_rd);
189 proto_tree_add_text(rd_tree, offset, 2,
190 decode_numeric_bitfield(route_descriptor, 0xFFF0, 2*8,
192 proto_tree_add_text(rd_tree, offset, 2,
193 decode_numeric_bitfield(route_descriptor, 0x000F, 2*8,
194 "Bridge number = %u"));
200 dissect_le_control(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
203 proto_tree *lane_tree;
205 proto_tree *flags_tree;
209 if (check_col(fd, COL_INFO))
210 col_add_str(fd, COL_INFO, "LE Control");
213 ti = proto_tree_add_item_format(tree, proto_atm_lane, offset, 108, NULL,
215 lane_tree = proto_item_add_subtree(ti, ett_atm_lane);
217 proto_tree_add_text(lane_tree, offset, 2, "Marker: 0x%04X",
218 pntohs(&pd[offset]));
221 proto_tree_add_text(lane_tree, offset, 1, "Protocol: 0x%02X",
225 proto_tree_add_text(lane_tree, offset, 1, "Version: 0x%02X",
229 opcode = pntohs(&pd[offset]);
230 proto_tree_add_text(lane_tree, offset, 2, "Opcode: %s",
231 val_to_str(opcode, le_control_opcode_vals,
235 if (opcode == READY_QUERY || opcode == READY_IND) {
236 /* There's nothing more in this packet. */
240 if (opcode & 0x0100) {
241 /* Response; decode status. */
242 proto_tree_add_text(lane_tree, offset, 2, "Status: %s",
243 val_to_str(pntohs(&pd[offset]), le_control_status_vals,
248 proto_tree_add_text(lane_tree, offset, 4, "Transaction ID: 0x%08X",
249 pntohl(&pd[offset]));
252 proto_tree_add_text(lane_tree, offset, 2, "Requester LECID: 0x%04X",
253 pntohs(&pd[offset]));
256 flags = pntohs(&pd[offset]);
257 tf = proto_tree_add_text(lane_tree, offset, 2, "Flags: 0x%04X",
258 pntohs(&pd[offset]));
259 flags_tree = proto_item_add_subtree(tf, ett_atm_lane_lc_flags);
260 proto_tree_add_text(flags_tree, offset, 2, "%s",
261 decode_boolean_bitfield(flags, 0x0001, 8*2,
262 "Remote address", "Local address"));
263 proto_tree_add_text(flags_tree, offset, 2, "%s",
264 decode_boolean_bitfield(flags, 0x0080, 8*2,
265 "Proxy", "Not proxy"));
266 proto_tree_add_text(flags_tree, offset, 2, "%s",
267 decode_boolean_bitfield(flags, 0x0100, 8*2,
268 "Topology change", "No topology change"));
271 dissect_lan_destination(pd, offset, "Source", lane_tree);
274 dissect_lan_destination(pd, offset, "Target", lane_tree);
277 proto_tree_add_text(lane_tree, offset, 20, "Source ATM Address: %s",
278 bytes_to_str(&pd[offset], 20));
281 proto_tree_add_text(lane_tree, offset, 1, "LAN type: %s",
282 val_to_str(pd[offset], le_control_lan_type_vals,
286 proto_tree_add_text(lane_tree, offset, 1, "Maximum frame size: %u",
290 proto_tree_add_text(lane_tree, offset, 1, "Number of TLVs: %u",
294 proto_tree_add_text(lane_tree, offset, 1, "ELAN name size: %u",
298 proto_tree_add_text(lane_tree, offset, 20, "Target ATM Address: %s",
299 bytes_to_str(&pd[offset], 20));
302 proto_tree_add_text(lane_tree, offset, 32, "ELAN name: %s",
303 bytes_to_str(&pd[offset], 32));
309 dissect_lane(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
311 if (check_col(fd, COL_PROTOCOL))
312 col_add_str(fd, COL_PROTOCOL, "ATM LANE");
313 if (check_col(fd, COL_INFO))
314 col_add_str(fd, COL_INFO, "ATM LANE");
316 /* Is it LE Control, 802.3, 802.5, or "none of the above"? */
317 switch (fd->pseudo_header.ngsniffer_atm.AppHLType) {
319 case AHLT_LANE_LE_CTRL:
320 dissect_le_control(pd, offset, fd, tree);
323 case AHLT_LANE_802_3:
324 case AHLT_LANE_802_3_MC:
325 dissect_le_client(pd, offset, fd, tree);
328 /* Dissect as Ethernet */
329 dissect_eth(pd, offset, fd, tree);
332 case AHLT_LANE_802_5:
333 case AHLT_LANE_802_5_MC:
334 dissect_le_client(pd, offset, fd, tree);
337 /* Dissect as Token-Ring */
338 dissect_tr(pd, offset, fd, tree);
342 /* Dump it as raw data. */
343 dissect_data(pd, offset, fd, tree);
349 static const value_string aal_vals[] = {
350 { ATT_AAL_UNKNOWN, "Unknown AAL" },
351 { ATT_AAL1, "AAL1" },
352 { ATT_AAL3_4, "AAL3/4" },
353 { ATT_AAL5, "AAL5" },
354 { ATT_AAL_USER, "User AAL" },
355 { ATT_AAL_SIGNALLING, "Signalling AAL" },
356 { ATT_OAMCELL, "OAM cell" },
360 /* AAL5 higher-level traffic types */
361 static const value_string aal5_hltype_vals[] = {
362 { ATT_HL_UNKNOWN, "Unknown traffic type" },
363 { ATT_HL_LLCMX, "LLC multiplexed" },
364 { ATT_HL_VCMX, "VC multiplexed" },
365 { ATT_HL_LANE, "LANE" },
366 { ATT_HL_ILMI, "ILMI" },
367 { ATT_HL_FRMR, "Frame Relay" },
368 { ATT_HL_SPANS, "FORE SPANS" },
369 { ATT_HL_IPSILON, "Ipsilon" },
373 /* Traffic subtypes for VC multiplexed traffic */
374 static const value_string vcmx_type_vals[] = {
375 { AHLT_UNKNOWN, "Unknown VC multiplexed traffic type" },
376 { AHLT_VCMX_802_3_FCS, "802.3 FCS" },
377 { AHLT_VCMX_802_4_FCS, "802.4 FCS" },
378 { AHLT_VCMX_802_5_FCS, "802.5 FCS" },
379 { AHLT_VCMX_FDDI_FCS, "FDDI FCS" },
380 { AHLT_VCMX_802_6_FCS, "802.6 FCS" },
381 { AHLT_VCMX_802_3, "802.3" },
382 { AHLT_VCMX_802_4, "802.4" },
383 { AHLT_VCMX_802_5, "802.5" },
384 { AHLT_VCMX_FDDI, "FDDI" },
385 { AHLT_VCMX_802_6, "802.6" },
386 { AHLT_VCMX_FRAGMENTS, "Fragments" },
387 { AHLT_VCMX_BPDU, "BPDU" },
391 /* Traffic subtypes for LANE traffic */
392 static const value_string lane_type_vals[] = {
393 { AHLT_UNKNOWN, "Unknown LANE traffic type" },
394 { AHLT_LANE_LE_CTRL, "LE Control" },
395 { AHLT_LANE_802_3, "802.3" },
396 { AHLT_LANE_802_5, "802.5" },
397 { AHLT_LANE_802_3_MC, "802.3 multicast" },
398 { AHLT_LANE_802_5_MC, "802.5 multicast" },
402 /* Traffic subtypes for Ipsilon traffic */
403 static const value_string ipsilon_type_vals[] = {
404 { AHLT_UNKNOWN, "Unknown Ipsilon traffic type" },
405 { AHLT_IPSILON_FT0, "Flow type 0" },
406 { AHLT_IPSILON_FT1, "Flow type 1" },
407 { AHLT_IPSILON_FT2, "Flow type 2" },
412 dissect_atm(const u_char *pd, frame_data *fd, proto_tree *tree)
415 proto_tree *atm_tree;
420 aal_type = fd->pseudo_header.ngsniffer_atm.AppTrafType & ATT_AALTYPE;
421 hl_type = fd->pseudo_header.ngsniffer_atm.AppTrafType & ATT_HLTYPE;
423 if (check_col(fd, COL_PROTOCOL))
424 col_add_str(fd, COL_PROTOCOL, "ATM");
426 switch (fd->pseudo_header.ngsniffer_atm.channel) {
429 /* Traffic from DCE to DTE. */
430 if (check_col(fd, COL_RES_DL_DST))
431 col_add_str(fd, COL_RES_DL_DST, "DTE");
432 if (check_col(fd, COL_RES_DL_SRC))
433 col_add_str(fd, COL_RES_DL_SRC, "DCE");
437 /* Traffic from DTE to DCE. */
438 if (check_col(fd, COL_RES_DL_DST))
439 col_add_str(fd, COL_RES_DL_DST, "DCE");
440 if (check_col(fd, COL_RES_DL_SRC))
441 col_add_str(fd, COL_RES_DL_SRC, "DTE");
445 if (check_col(fd, COL_INFO)) {
446 if (aal_type == ATT_AAL5) {
447 col_add_fstr(fd, COL_INFO, "AAL5 %s",
448 val_to_str(hl_type, aal5_hltype_vals,
449 "Unknown traffic type (%x)"));
451 col_add_str(fd, COL_INFO,
452 val_to_str(aal_type, aal_vals, "Unknown AAL (%x)"));
457 ti = proto_tree_add_item_format(tree, proto_atm, 0, 0, NULL,
459 atm_tree = proto_item_add_subtree(ti, ett_atm);
461 proto_tree_add_text(atm_tree, 0, 0, "AAL: %s",
462 val_to_str(aal_type, aal_vals, "Unknown AAL (%x)"));
463 if (aal_type == ATT_AAL5) {
464 proto_tree_add_text(atm_tree, 0, 0, "Traffic type: %s",
465 val_to_str(hl_type, aal5_hltype_vals, "Unknown AAL5 traffic type (%x)"));
467 if (aal_type == ATT_AAL5) {
471 proto_tree_add_text(atm_tree, 0, 0, "VC multiplexed traffic type: %s",
472 val_to_str(fd->pseudo_header.ngsniffer_atm.AppHLType,
473 vcmx_type_vals, "Unknown VCMX traffic type (%x)"));
477 proto_tree_add_text(atm_tree, 0, 0, "LANE traffic type: %s",
478 val_to_str(fd->pseudo_header.ngsniffer_atm.AppHLType,
479 lane_type_vals, "Unknown LANE traffic type (%x)"));
483 proto_tree_add_text(atm_tree, 0, 0, "Ipsilon traffic type: %s",
484 val_to_str(fd->pseudo_header.ngsniffer_atm.AppHLType,
485 ipsilon_type_vals, "Unknown Ipsilon traffic type (%x)"));
489 proto_tree_add_text(atm_tree, 0, 0, "VPI: %u",
490 fd->pseudo_header.ngsniffer_atm.Vpi);
491 proto_tree_add_text(atm_tree, 0, 0, "VCI: %u",
492 fd->pseudo_header.ngsniffer_atm.Vci);
493 switch (fd->pseudo_header.ngsniffer_atm.channel) {
496 /* Traffic from DCE to DTE. */
497 proto_tree_add_text(atm_tree, 0, 0, "Channel: DCE->DTE");
501 /* Traffic from DTE to DCE. */
502 proto_tree_add_text(atm_tree, 0, 0, "Channel: DTE->DCE");
506 /* Sniffers shouldn't provide anything other than 0 or 1. */
507 proto_tree_add_text(atm_tree, 0, 0, "Channel: %u",
508 fd->pseudo_header.ngsniffer_atm.channel);
511 proto_tree_add_text(atm_tree, 0, 0, "Cells: %u",
512 fd->pseudo_header.ngsniffer_atm.cells);
513 if (aal_type == ATT_AAL5) {
514 proto_tree_add_text(atm_tree, 0, 0, "AAL5 U2U: %u",
515 fd->pseudo_header.ngsniffer_atm.aal5t_u2u);
516 proto_tree_add_text(atm_tree, 0, 0, "AAL5 len: %u",
517 fd->pseudo_header.ngsniffer_atm.aal5t_len);
518 proto_tree_add_text(atm_tree, 0, 0, "AAL5 checksum: 0x%08X",
519 fd->pseudo_header.ngsniffer_atm.aal5t_chksum);
523 if (aal_type == ATT_AAL5) {
528 /* Dissect as WTAP_ENCAP_ATM_RFC1483 */
533 dissect_lane(pd, offset, fd, tree);
536 #if defined(HAVE_UCD_SNMP_SNMP_H) || defined(HAVE_SNMP_SNMP_H)
538 dissect_snmp_pdu(pd, offset, fd, tree, "ILMI", proto_ilmi, ett_ilmi);
544 /* Dump it as raw data. */
545 dissect_data(pd, offset, fd, tree);
551 /* Dump it as raw data. (Is this a single cell?) */
552 dissect_data(pd, offset, fd, tree);
558 proto_register_atm(void)
560 static gint *ett[] = {
563 &ett_atm_lane_lc_lan_dest,
564 &ett_atm_lane_lc_lan_dest_rd,
565 &ett_atm_lane_lc_flags,
568 proto_atm = proto_register_protocol("ATM", "atm");
569 proto_atm_lane = proto_register_protocol("ATM LANE", "lane");
570 proto_ilmi = proto_register_protocol("ILMI", "ilmi");
571 proto_register_subtree_array(ett, array_length(ett));