7d4a6f48e6a1f8c72b4349c498f08c1561b3f647
[metze/wireshark/wip.git] / packet-atm.c
1 /* packet-atm.c
2  * Routines for ATM packet disassembly
3  *
4  * $Id: packet-atm.c,v 1.10 1999/12/05 02:32:41 guy Exp $
5  *
6  * Ethereal - Network traffic analyzer
7  * By Gerald Combs <gerald@zing.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * 
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.
15  * 
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.
20  * 
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.
24  */
25
26 #ifdef HAVE_CONFIG_H
27 # include "config.h"
28 #endif
29
30 #ifdef HAVE_SYS_TYPES_H
31 # include <sys/types.h>
32 #endif
33
34 #include <stdio.h>
35 #include <glib.h>
36 #include "packet.h"
37 #include "resolv.h"
38
39 #include "packet-snmp.h"
40
41 static int proto_atm = -1;
42 static int hf_atm_vpi = -1;
43 static int hf_atm_vci = -1;
44 static int proto_atm_lane = -1;
45 static int proto_ilmi = -1;
46
47 static gint ett_atm = -1;
48 static gint ett_atm_lane = -1;
49 static gint ett_atm_lane_lc_lan_dest = -1;
50 static gint ett_atm_lane_lc_lan_dest_rd = -1;
51 static gint ett_atm_lane_lc_flags = -1;
52 static gint ett_ilmi = -1;
53
54 /*
55  * See
56  *
57  *      http://www.atmforum.org/atmforum/specs/approved.html
58  *
59  * for a number of ATM Forum specifications, e.g. the LAN Emulation
60  * over ATM 1.0 spec, whence I got most of this.
61  */
62
63 /* LE Control opcodes */
64 #define LE_CONFIGURE_REQUEST    0x0001
65 #define LE_CONFIGURE_RESPONSE   0x0101
66 #define LE_JOIN_REQUEST         0x0002
67 #define LE_JOIN_RESPONSE        0x0102
68 #define READY_QUERY             0x0003
69 #define READY_IND               0x0103
70 #define LE_REGISTER_REQUEST     0x0004
71 #define LE_REGISTER_RESPONSE    0x0104
72 #define LE_UNREGISTER_REQUEST   0x0005
73 #define LE_UNREGISTER_RESPONSE  0x0105
74 #define LE_ARP_REQUEST          0x0006
75 #define LE_ARP_RESPONSE         0x0106
76 #define LE_FLUSH_REQUEST        0x0007
77 #define LE_FLUSH_RESPONSE       0x0107
78 #define LE_NARP_REQUEST         0x0008
79 #define LE_TOPOLOGY_REQUEST     0x0009
80
81 static const value_string le_control_opcode_vals[] = {
82         { LE_CONFIGURE_REQUEST,   "LE_CONFIGURE_REQUEST" },
83         { LE_CONFIGURE_RESPONSE,  "LE_CONFIGURE_RESPONSE" },
84         { LE_JOIN_REQUEST,        "LE_JOIN_REQUEST" },
85         { LE_JOIN_RESPONSE,       "LE_JOIN_RESPONSE" },
86         { READY_QUERY,            "READY_QUERY" },
87         { READY_IND,              "READY_IND" },
88         { LE_REGISTER_REQUEST,    "LE_REGISTER_REQUEST" },
89         { LE_REGISTER_RESPONSE,   "LE_REGISTER_RESPONSE" },
90         { LE_UNREGISTER_REQUEST,  "LE_UNREGISTER_REQUEST" },
91         { LE_UNREGISTER_RESPONSE, "LE_UNREGISTER_RESPONSE" },
92         { LE_ARP_REQUEST,         "LE_ARP_REQUEST" },
93         { LE_ARP_RESPONSE,        "LE_ARP_RESPONSE" },
94         { LE_FLUSH_REQUEST,       "LE_FLUSH_REQUEST" },
95         { LE_FLUSH_RESPONSE,      "LE_FLUSH_RESPONSE" },
96         { LE_NARP_REQUEST,        "LE_NARP_REQUEST" },
97         { LE_TOPOLOGY_REQUEST,    "LE_TOPOLOGY_REQUEST" },
98         { 0,                      NULL }
99 };
100
101 /* LE Control statuses */
102 static const value_string le_control_status_vals[] = {
103         { 0,  "Success" },
104         { 1,  "Version not supported" },
105         { 2,  "Invalid request parameters" },
106         { 4,  "Duplicate LAN destination registration" },
107         { 5,  "Duplicate ATM address" },
108         { 6,  "Insufficient resources to grant request" },
109         { 7,  "Access denied" },
110         { 8,  "Invalid REQUESTOR-ID" },
111         { 9,  "Invalid LAN destination" },
112         { 10, "Invalid ATM address" },
113         { 20, "No configuraton" },
114         { 21, "LE_CONFIGURE error" },
115         { 22, "Insufficient information" },
116         { 0,  NULL }
117 };
118
119 /* LE Control LAN destination tags */
120 #define TAG_NOT_PRESENT         0x0000
121 #define TAG_MAC_ADDRESS         0x0001
122 #define TAG_ROUTE_DESCRIPTOR    0x0002
123
124 static const value_string le_control_landest_tag_vals[] = {
125         { TAG_NOT_PRESENT,       "Not present" },
126         { TAG_MAC_ADDRESS,       "MAC address" },
127         { TAG_ROUTE_DESCRIPTOR,  "Route descriptor" },
128         { 0,                     NULL }
129 };
130
131 /* LE Control LAN types */
132 #define LANT_UNSPEC     0x00
133 #define LANT_802_3      0x01
134 #define LANT_802_5      0x02
135
136 static const value_string le_control_lan_type_vals[] = {
137         { LANT_UNSPEC, "Unspecified" },
138         { LANT_802_3,  "Ethernet/802.3" },
139         { LANT_802_5,  "802.5" },
140         { 0,           NULL }
141 };
142
143 static void
144 dissect_le_client(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) 
145 {
146   proto_item *ti;
147   proto_tree *lane_tree;
148
149   if (tree) {
150     ti = proto_tree_add_item_format(tree, proto_atm_lane, offset, 2, NULL,
151                                             "ATM LANE");
152     lane_tree = proto_item_add_subtree(ti, ett_atm_lane);
153
154     proto_tree_add_text(lane_tree, offset, 2, "LE Client: 0x%04X",
155                         pntohs(&pd[offset]));
156   }
157 }
158
159 static void
160 dissect_lan_destination(const u_char *pd, int offset, const char *type, proto_tree *tree) 
161 {
162   proto_item *td;
163   proto_tree *dest_tree;
164   guint16 tag;
165   proto_item *trd;
166   proto_tree *rd_tree;
167   guint16 route_descriptor;
168
169   td = proto_tree_add_text(tree, offset, 8, "%s LAN destination",
170                         type);
171   dest_tree = proto_item_add_subtree(td, ett_atm_lane_lc_lan_dest);
172   tag = pntohs(&pd[offset]);
173   proto_tree_add_text(dest_tree, offset, 2, "Tag: %s",
174         val_to_str(tag, le_control_landest_tag_vals,
175                                 "Unknown (%x)"));
176   offset += 2;
177
178   switch (tag) {
179
180   case TAG_MAC_ADDRESS:
181     proto_tree_add_text(dest_tree, offset, 6, "MAC address: %s",
182                         ether_to_str((u_char *)&pd[offset]));
183     break;
184
185   case TAG_ROUTE_DESCRIPTOR:
186     offset += 4;
187     route_descriptor = pntohs(&pd[offset]);
188     trd = proto_tree_add_text(dest_tree, offset, 2, "Route descriptor: 0x%02X",
189                         route_descriptor);
190     rd_tree = proto_item_add_subtree(td, ett_atm_lane_lc_lan_dest_rd);
191     proto_tree_add_text(rd_tree, offset, 2,
192             decode_numeric_bitfield(route_descriptor, 0xFFF0, 2*8,
193                         "LAN ID = %u"));
194     proto_tree_add_text(rd_tree, offset, 2,
195             decode_numeric_bitfield(route_descriptor, 0x000F, 2*8,
196                         "Bridge number = %u"));
197     break;
198   }
199 }
200
201 static void
202 dissect_le_control(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) 
203 {
204   proto_item *ti;
205   proto_tree *lane_tree;
206   proto_item *tf;
207   proto_tree *flags_tree;
208   guint16 opcode;
209   guint16 flags;
210
211   if (check_col(fd, COL_INFO))
212     col_add_str(fd, COL_INFO, "LE Control");
213
214   if (tree) {
215     ti = proto_tree_add_item_format(tree, proto_atm_lane, offset, 108, NULL,
216                                             "ATM LANE");
217     lane_tree = proto_item_add_subtree(ti, ett_atm_lane);
218
219     proto_tree_add_text(lane_tree, offset, 2, "Marker: 0x%04X",
220                         pntohs(&pd[offset]));
221     offset += 2;
222
223     proto_tree_add_text(lane_tree, offset, 1, "Protocol: 0x%02X",
224                         pd[offset]);
225     offset += 1;
226
227     proto_tree_add_text(lane_tree, offset, 1, "Version: 0x%02X",
228                         pd[offset]);
229     offset += 1;
230
231     opcode = pntohs(&pd[offset]);
232     proto_tree_add_text(lane_tree, offset, 2, "Opcode: %s",
233         val_to_str(opcode, le_control_opcode_vals,
234                                 "Unknown (%x)"));
235     offset += 2;
236
237     if (opcode == READY_QUERY || opcode == READY_IND) {
238       /* There's nothing more in this packet. */
239       return;
240     }
241
242     if (opcode & 0x0100) {
243       /* Response; decode status. */
244       proto_tree_add_text(lane_tree, offset, 2, "Status: %s",
245         val_to_str(pntohs(&pd[offset]), le_control_status_vals,
246                                 "Unknown (%x)"));
247     }
248     offset += 2;
249
250     proto_tree_add_text(lane_tree, offset, 4, "Transaction ID: 0x%08X",
251                         pntohl(&pd[offset]));
252     offset += 4;
253
254     proto_tree_add_text(lane_tree, offset, 2, "Requester LECID: 0x%04X",
255                         pntohs(&pd[offset]));
256     offset += 2;
257
258     flags = pntohs(&pd[offset]);
259     tf = proto_tree_add_text(lane_tree, offset, 2, "Flags: 0x%04X",
260                         pntohs(&pd[offset]));
261     flags_tree = proto_item_add_subtree(tf, ett_atm_lane_lc_flags);
262     proto_tree_add_text(flags_tree, offset, 2, "%s",
263         decode_boolean_bitfield(flags, 0x0001, 8*2,
264                                 "Remote address", "Local address"));
265     proto_tree_add_text(flags_tree, offset, 2, "%s",
266         decode_boolean_bitfield(flags, 0x0080, 8*2,
267                                 "Proxy", "Not proxy"));
268     proto_tree_add_text(flags_tree, offset, 2, "%s",
269         decode_boolean_bitfield(flags, 0x0100, 8*2,
270                                 "Topology change", "No topology change"));
271     offset += 2;
272
273     dissect_lan_destination(pd, offset, "Source", lane_tree);
274     offset += 8;
275
276     dissect_lan_destination(pd, offset, "Target", lane_tree);
277     offset += 8;
278
279     proto_tree_add_text(lane_tree, offset, 20, "Source ATM Address: %s",
280                         bytes_to_str(&pd[offset], 20));
281     offset += 20;
282
283     proto_tree_add_text(lane_tree, offset, 1, "LAN type: %s",
284         val_to_str(pd[offset], le_control_lan_type_vals,
285                                 "Unknown (%x)"));
286     offset += 1;
287
288     proto_tree_add_text(lane_tree, offset, 1, "Maximum frame size: %u",
289                         pd[offset]);
290     offset += 1;
291
292     proto_tree_add_text(lane_tree, offset, 1, "Number of TLVs: %u",
293                         pd[offset]);
294     offset += 1;
295
296     proto_tree_add_text(lane_tree, offset, 1, "ELAN name size: %u",
297                         pd[offset]);
298     offset += 1;
299
300     proto_tree_add_text(lane_tree, offset, 20, "Target ATM Address: %s",
301                         bytes_to_str(&pd[offset], 20));
302     offset += 20;
303
304     proto_tree_add_text(lane_tree, offset, 32, "ELAN name: %s",
305                         bytes_to_str(&pd[offset], 32));
306     offset += 32;
307   }
308 }
309
310 static void
311 dissect_lane(const u_char *pd, int offset, frame_data *fd, proto_tree *tree) 
312 {
313   if (check_col(fd, COL_PROTOCOL))
314     col_add_str(fd, COL_PROTOCOL, "ATM LANE");
315   if (check_col(fd, COL_INFO))
316     col_add_str(fd, COL_INFO, "ATM LANE");
317
318   /* Is it LE Control, 802.3, 802.5, or "none of the above"? */
319   switch (fd->pseudo_header.ngsniffer_atm.AppHLType) {
320
321   case AHLT_LANE_LE_CTRL:
322     dissect_le_control(pd, offset, fd, tree);
323     break;
324
325   case AHLT_LANE_802_3:
326   case AHLT_LANE_802_3_MC:
327     dissect_le_client(pd, offset, fd, tree);
328     offset += 2;
329
330     /* Dissect as Ethernet */
331     dissect_eth(pd, offset, fd, tree);
332     break;
333
334   case AHLT_LANE_802_5:
335   case AHLT_LANE_802_5_MC:
336     dissect_le_client(pd, offset, fd, tree);
337     offset += 2;
338
339     /* Dissect as Token-Ring */
340     dissect_tr(pd, offset, fd, tree);
341     break;
342
343   default:
344     /* Dump it as raw data. */
345     dissect_data(pd, offset, fd, tree);
346     break;
347   }
348 }
349
350 /* AAL types */
351 static const value_string aal_vals[] = {
352         { ATT_AAL_UNKNOWN,    "Unknown AAL" },
353         { ATT_AAL1,           "AAL1" },
354         { ATT_AAL3_4,         "AAL3/4" },
355         { ATT_AAL5,           "AAL5" },
356         { ATT_AAL_USER,       "User AAL" },
357         { ATT_AAL_SIGNALLING, "Signalling AAL" },
358         { ATT_OAMCELL,        "OAM cell" },
359         { 0,                  NULL }
360 };
361
362 /* AAL5 higher-level traffic types */
363 static const value_string aal5_hltype_vals[] = {
364         { ATT_HL_UNKNOWN, "Unknown traffic type" },
365         { ATT_HL_LLCMX,   "LLC multiplexed" },
366         { ATT_HL_VCMX,    "VC multiplexed" },
367         { ATT_HL_LANE,    "LANE" },
368         { ATT_HL_ILMI,    "ILMI" },
369         { ATT_HL_FRMR,    "Frame Relay" },
370         { ATT_HL_SPANS,   "FORE SPANS" },
371         { ATT_HL_IPSILON, "Ipsilon" },
372         { 0,              NULL }
373 };
374
375 /* Traffic subtypes for VC multiplexed traffic */
376 static const value_string vcmx_type_vals[] = {
377         { AHLT_UNKNOWN,        "Unknown VC multiplexed traffic type" },
378         { AHLT_VCMX_802_3_FCS, "802.3 FCS" },
379         { AHLT_VCMX_802_4_FCS, "802.4 FCS" },
380         { AHLT_VCMX_802_5_FCS, "802.5 FCS" },
381         { AHLT_VCMX_FDDI_FCS,  "FDDI FCS" },
382         { AHLT_VCMX_802_6_FCS, "802.6 FCS" },
383         { AHLT_VCMX_802_3,     "802.3" },
384         { AHLT_VCMX_802_4,     "802.4" },
385         { AHLT_VCMX_802_5,     "802.5" },
386         { AHLT_VCMX_FDDI,      "FDDI" },
387         { AHLT_VCMX_802_6,     "802.6" },
388         { AHLT_VCMX_FRAGMENTS, "Fragments" },
389         { AHLT_VCMX_BPDU,      "BPDU" },
390         { 0,                   NULL }
391 };
392
393 /* Traffic subtypes for LANE traffic */
394 static const value_string lane_type_vals[] = {
395         { AHLT_UNKNOWN,       "Unknown LANE traffic type" },
396         { AHLT_LANE_LE_CTRL,  "LE Control" },
397         { AHLT_LANE_802_3,    "802.3" },
398         { AHLT_LANE_802_5,    "802.5" },
399         { AHLT_LANE_802_3_MC, "802.3 multicast" },
400         { AHLT_LANE_802_5_MC, "802.5 multicast" },
401         { 0,                  NULL }
402 };
403
404 /* Traffic subtypes for Ipsilon traffic */
405 static const value_string ipsilon_type_vals[] = {
406         { AHLT_UNKNOWN,     "Unknown Ipsilon traffic type" },
407         { AHLT_IPSILON_FT0, "Flow type 0" },
408         { AHLT_IPSILON_FT1, "Flow type 1" },
409         { AHLT_IPSILON_FT2, "Flow type 2" },
410         { 0,                NULL }
411 };
412
413 /*
414  * We don't know what kind of traffic this is; try to guess.
415  * We at least know it's AAL5....
416  */
417 static void
418 atm_guess_content(const u_char *pd, frame_data *fd)
419 {
420         if (fd->pseudo_header.ngsniffer_atm.Vpi == 0) {
421                 /*
422                  * Traffic on some PVCs with a VPI of 0 and certain
423                  * VCIs is of particular types.
424                  */
425                 switch (fd->pseudo_header.ngsniffer_atm.Vci) {
426
427                 case 5:
428                         /*
429                          * Signalling AAL.
430                          */
431                         fd->pseudo_header.ngsniffer_atm.AppTrafType =
432                             ATT_AAL_SIGNALLING;
433                         return;
434
435                 case 16:
436                         /*
437                          * ILMI.
438                          */
439                         fd->pseudo_header.ngsniffer_atm.AppTrafType |=
440                             ATT_HL_ILMI;
441                         return;
442                 }
443         }
444
445         /*
446          * OK, we can't tell what it is based on the VPI/VCI; try
447          * guessing based on the contents.
448          */
449         if (pd[0] == 0xaa && pd[1] == 0xaa && pd[2] == 0x03) {
450                 /*
451                  * Looks like a SNAP header; assume it's LLC multiplexed
452                  * RFC 1483 traffic.
453                  */
454                 fd->pseudo_header.ngsniffer_atm.AppTrafType |= ATT_HL_LLCMX;
455         } else {
456                 /*
457                  * Assume it's LANE.
458                  */
459                 fd->pseudo_header.ngsniffer_atm.AppTrafType |= ATT_HL_LANE;
460                 if (pd[0] == 0xff && pd[1] == 0x00) {
461                         /*
462                          * Looks like LE Control traffic.
463                          */
464                         fd->pseudo_header.ngsniffer_atm.AppHLType =
465                             AHLT_LANE_LE_CTRL;
466                 } else {
467                         /*
468                          * XXX - Ethernet, or Token Ring?
469                          * Assume Ethernet for now; if we see earlier
470                          * LANE traffic, we may be able to figure out
471                          * the traffic type from that, but there may
472                          * still be situations where the user has to
473                          * tell us.
474                          */
475                         fd->pseudo_header.ngsniffer_atm.AppHLType =
476                             AHLT_LANE_802_3;
477                 }
478         }
479 }
480
481 void
482 dissect_atm(const u_char *pd, frame_data *fd, proto_tree *tree) 
483 {
484   int        offset = 0;
485   proto_tree *atm_tree;
486   proto_item *ti;
487   guint       aal_type;
488   guint       hl_type;
489
490   aal_type = fd->pseudo_header.ngsniffer_atm.AppTrafType & ATT_AALTYPE;
491   hl_type = fd->pseudo_header.ngsniffer_atm.AppTrafType & ATT_HLTYPE;
492   if (aal_type == ATT_AAL5) {
493     if (hl_type == ATT_HL_UNKNOWN ||
494         fd->pseudo_header.ngsniffer_atm.AppHLType == AHLT_UNKNOWN) {
495       /*
496        * The joys of a connection-oriented link layer; the type of
497        * traffic may be implied by the connection on which it's
498        * traveling, rather than being specified in the packet itself.
499        *
500        * For this packet, the program that captured the packet didn't
501        * save the type of traffic, presumably because it didn't know
502        * the traffic type (either it didn't see the connection setup
503        * and wasn't running on one of the endpoints, and wasn't later
504        * told, e.g. by the human running it, what type of traffic was
505        * on that circuit, or was running on one of the endpoints but
506        * was using, to capture the packets, a mechanism that either
507        * doesn't have access to data saying what's going over the
508        * connection or doesn't bother providing that information).
509        *
510        * For now, we try to guess the traffic type based on the VPI/VCI
511        * or the packet header; later, we should provide a mechanism
512        * by which the user can specify what sort of traffic is on a
513        * particular circuit.
514        */
515       atm_guess_content(pd, fd);
516
517       /*
518        * OK, now get the AAL type and high-layer type again.
519        */
520       aal_type = fd->pseudo_header.ngsniffer_atm.AppTrafType & ATT_AALTYPE;
521       hl_type = fd->pseudo_header.ngsniffer_atm.AppTrafType & ATT_HLTYPE;
522     }
523   }
524
525   if (check_col(fd, COL_PROTOCOL))
526     col_add_str(fd, COL_PROTOCOL, "ATM");
527
528   switch (fd->pseudo_header.ngsniffer_atm.channel) {
529
530   case 0:
531     /* Traffic from DCE to DTE. */
532     if (check_col(fd, COL_RES_DL_DST))
533       col_add_str(fd, COL_RES_DL_DST, "DTE");
534     if (check_col(fd, COL_RES_DL_SRC))
535       col_add_str(fd, COL_RES_DL_SRC, "DCE");
536     break;
537
538   case 1:
539     /* Traffic from DTE to DCE. */
540     if (check_col(fd, COL_RES_DL_DST))
541       col_add_str(fd, COL_RES_DL_DST, "DCE");
542     if (check_col(fd, COL_RES_DL_SRC))
543       col_add_str(fd, COL_RES_DL_SRC, "DTE");
544     break;
545   }
546
547   if (check_col(fd, COL_INFO)) {
548     if (aal_type == ATT_AAL5) {
549       col_add_fstr(fd, COL_INFO, "AAL5 %s",
550                 val_to_str(hl_type, aal5_hltype_vals,
551                                 "Unknown traffic type (%x)"));
552     } else {
553       col_add_str(fd, COL_INFO,
554                 val_to_str(aal_type, aal_vals, "Unknown AAL (%x)"));
555     }
556   }
557
558   if (tree) {
559     ti = proto_tree_add_item_format(tree, proto_atm, 0, 0, NULL,
560                                             "ATM");
561     atm_tree = proto_item_add_subtree(ti, ett_atm);
562
563     proto_tree_add_text(atm_tree, 0, 0, "AAL: %s",
564         val_to_str(aal_type, aal_vals, "Unknown AAL (%x)"));
565     if (aal_type == ATT_AAL5) {
566       proto_tree_add_text(atm_tree, 0, 0, "Traffic type: %s",
567         val_to_str(hl_type, aal5_hltype_vals, "Unknown AAL5 traffic type (%x)"));
568       switch (hl_type) {
569
570       case ATT_HL_LLCMX:
571         proto_tree_add_text(atm_tree, 0, 0, "LLC multiplexed traffic");
572         break;
573
574       case ATT_HL_VCMX:
575         proto_tree_add_text(atm_tree, 0, 0, "VC multiplexed traffic type: %s",
576                 val_to_str(fd->pseudo_header.ngsniffer_atm.AppHLType,
577                         vcmx_type_vals, "Unknown VCMX traffic type (%x)"));
578         break;
579
580       case ATT_HL_LANE:
581         proto_tree_add_text(atm_tree, 0, 0, "LANE traffic type: %s",
582                 val_to_str(fd->pseudo_header.ngsniffer_atm.AppHLType,
583                         lane_type_vals, "Unknown LANE traffic type (%x)"));
584         break;
585
586       case ATT_HL_IPSILON:
587         proto_tree_add_text(atm_tree, 0, 0, "Ipsilon traffic type: %s",
588                 val_to_str(fd->pseudo_header.ngsniffer_atm.AppHLType,
589                         ipsilon_type_vals, "Unknown Ipsilon traffic type (%x)"));
590         break;
591       }
592     }
593     proto_tree_add_item(atm_tree, hf_atm_vpi, 0, 0,
594                 fd->pseudo_header.ngsniffer_atm.Vpi);
595     proto_tree_add_item(atm_tree, hf_atm_vci, 0, 0,
596                 fd->pseudo_header.ngsniffer_atm.Vci);
597     switch (fd->pseudo_header.ngsniffer_atm.channel) {
598
599     case 0:
600       /* Traffic from DCE to DTE. */
601       proto_tree_add_text(atm_tree, 0, 0, "Channel: DCE->DTE");
602       break;
603
604     case 1:
605       /* Traffic from DTE to DCE. */
606       proto_tree_add_text(atm_tree, 0, 0, "Channel: DTE->DCE");
607       break;
608
609     default:
610       /* Sniffers shouldn't provide anything other than 0 or 1. */
611       proto_tree_add_text(atm_tree, 0, 0, "Channel: %u",
612                 fd->pseudo_header.ngsniffer_atm.channel);
613       break;
614     }
615     if (fd->pseudo_header.ngsniffer_atm.cells != 0) {
616       /*
617        * If the cell count is 0, assume it means we don't know how
618        * many cells it was.
619        *
620        * XXX - also, if this is AAL5 traffic, assume it means we don't
621        * know what was in the AAL5 trailer.  We may, however, find
622        * some capture program that can give us the AAL5 trailer
623        * information but not the cell count, in which case we need
624        * some other way of indicating whether we have the AAL5 trailer
625        * information.
626        */
627       proto_tree_add_text(atm_tree, 0, 0, "Cells: %u",
628                 fd->pseudo_header.ngsniffer_atm.cells);
629       if (aal_type == ATT_AAL5) {
630         proto_tree_add_text(atm_tree, 0, 0, "AAL5 U2U: %u",
631                 fd->pseudo_header.ngsniffer_atm.aal5t_u2u);
632         proto_tree_add_text(atm_tree, 0, 0, "AAL5 len: %u",
633                 fd->pseudo_header.ngsniffer_atm.aal5t_len);
634         proto_tree_add_text(atm_tree, 0, 0, "AAL5 checksum: 0x%08X",
635                 fd->pseudo_header.ngsniffer_atm.aal5t_chksum);
636       }
637     }
638   }
639
640   switch (aal_type) {
641
642   case ATT_AAL_SIGNALLING:
643     dissect_sscop(pd, offset, fd, tree);
644     break;
645
646   case ATT_AAL5:
647     switch (hl_type) {
648
649     case ATT_HL_LLCMX:
650       /* Dissect as WTAP_ENCAP_ATM_RFC1483 */
651       /* The ATM iptrace capture that we have hows LLC at this point,
652        * so that's what I'm calling */
653       dissect_llc(pd, offset, fd, tree);
654       break;
655
656     case ATT_HL_LANE:
657       dissect_lane(pd, offset, fd, tree);
658       break;
659
660     case ATT_HL_ILMI:
661       dissect_snmp_pdu(pd, offset, fd, tree, "ILMI", proto_ilmi, ett_ilmi);
662       break;
663
664     default:
665       if (tree) {
666         /* Dump it as raw data. */
667         dissect_data(pd, offset, fd, tree);
668         break;
669       }
670     }
671     break;
672
673   default:
674     if (tree) {
675       /* Dump it as raw data.  (Is this a single cell?) */
676       dissect_data(pd, offset, fd, tree);
677     }
678     break;
679   }
680 }
681
682 void
683 proto_register_atm(void)
684 {
685         static hf_register_info hf[] = {
686                 { &hf_atm_vpi,
687                 { "VPI",                "atm.vpi", FT_UINT8, BASE_DEC, NULL, 0x0,
688                         "" }},
689
690                 { &hf_atm_vci,
691                 { "VCI",                "atm.vci", FT_UINT16, BASE_DEC, NULL, 0x0,
692                         "" }},
693         };
694         static gint *ett[] = {
695                 &ett_atm,
696                 &ett_ilmi,
697                 &ett_atm_lane,
698                 &ett_atm_lane_lc_lan_dest,
699                 &ett_atm_lane_lc_lan_dest_rd,
700                 &ett_atm_lane_lc_flags,
701         };
702         proto_atm = proto_register_protocol("ATM", "atm");
703         proto_register_field_array(proto_atm, hf, array_length(hf));
704         proto_ilmi = proto_register_protocol("ILMI", "ilmi");
705         proto_atm_lane = proto_register_protocol("ATM LANE", "lane");
706         proto_register_subtree_array(ett, array_length(ett));
707 }