Add "stamp-h1", for automake 1.6.1, as per Joerg Mayer's suggestion.
[obnox/wireshark/wip.git] / packet-atm.c
index b71862b2937f06c992e1865efe4745664f69553f..02b12cd8c388b86d243bf842b347d604b1d7ffab 100644 (file)
@@ -1,12 +1,11 @@
 /* packet-atm.c
  * Routines for ATM packet disassembly
  *
- * $Id: packet-atm.c,v 1.37 2001/11/26 01:03:35 hagbard Exp $
+ * $Id: packet-atm.c,v 1.41 2002/03/31 21:23:47 guy 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
@@ -33,9 +32,9 @@
 
 #include <stdio.h>
 #include <glib.h>
-#include "packet.h"
+#include <epan/packet.h>
 #include "oui.h"
-#include "resolv.h"
+#include <epan/resolv.h>
 
 #include "packet-snmp.h"
 
@@ -151,7 +150,7 @@ static const value_string le_control_lan_type_vals[] = {
 };
 
 static void
-dissect_le_client(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
+dissect_le_client(tvbuff_t *tvb, proto_tree *tree)
 {
   proto_item *ti;
   proto_tree *lane_tree;
@@ -251,7 +250,7 @@ static void
 dissect_le_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 {
   proto_item *ti;
-  proto_tree *lane_tree;
+  proto_tree *lane_tree = NULL;
   int offset = 0;
   proto_item *tf;
   proto_tree *flags_tree;
@@ -263,8 +262,8 @@ dissect_le_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
   guint32 tlv_type;
   guint8 tlv_length;
 
-  if (check_col(pinfo->fd, COL_INFO))
-    col_set_str(pinfo->fd, COL_INFO, "LE Control");
+  if (check_col(pinfo->cinfo, COL_INFO))
+    col_set_str(pinfo->cinfo, COL_INFO, "LE Control");
 
   if (tree) {
     ti = proto_tree_add_protocol_format(tree, proto_atm_lane, tvb, offset, 108, "ATM LANE");
@@ -272,27 +271,40 @@ dissect_le_control(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 
     proto_tree_add_text(lane_tree, tvb, offset, 2, "Marker: 0x%04X",
                        tvb_get_ntohs(tvb, offset));
-    offset += 2;
+  }
+  offset += 2;
 
+  if (tree) {
     proto_tree_add_text(lane_tree, tvb, offset, 1, "Protocol: 0x%02X",
                        tvb_get_guint8(tvb, offset));
-    offset += 1;
+  }
+  offset += 1;
 
+  if (tree) {
     proto_tree_add_text(lane_tree, tvb, offset, 1, "Version: 0x%02X",
                        tvb_get_guint8(tvb, offset));
-    offset += 1;
+  }
+  offset += 1;
 
-    opcode = tvb_get_ntohs(tvb, offset);
+  opcode = tvb_get_ntohs(tvb, offset);
+  if (check_col(pinfo->cinfo, COL_INFO)) {
+    col_append_fstr(pinfo->cinfo, COL_INFO, ": %s",
+       val_to_str(opcode, le_control_opcode_vals,
+                               "Unknown opcode (0x%04X)"));
+  }
+  if (tree) {
     proto_tree_add_text(lane_tree, tvb, offset, 2, "Opcode: %s",
        val_to_str(opcode, le_control_opcode_vals,
                                "Unknown (0x%04X)"));
-    offset += 2;
+  }
+  offset += 2;
 
-    if (opcode == READY_QUERY || opcode == READY_IND) {
-      /* There's nothing more in this packet. */
-      return;
-    }
+  if (opcode == READY_QUERY || opcode == READY_IND) {
+    /* There's nothing more in this packet. */
+    return;
+  }
 
+  if (tree) {
     if (opcode & 0x0100) {
       /* Response; decode status. */
       proto_tree_add_text(lane_tree, tvb, offset, 2, "Status: %s",
@@ -381,10 +393,8 @@ dissect_lane(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
   tvbuff_t     *next_tvb;
   tvbuff_t     *next_tvb_le_client;
 
-  if (check_col(pinfo->fd, COL_PROTOCOL))
-    col_set_str(pinfo->fd, COL_PROTOCOL, "ATM LANE");
-  if (check_col(pinfo->fd, COL_INFO))
-    col_set_str(pinfo->fd, COL_INFO, "ATM LANE");
+  if (check_col(pinfo->cinfo, COL_PROTOCOL))
+    col_set_str(pinfo->cinfo, COL_PROTOCOL, "ATM LANE");
 
   /* Is it LE Control, 802.3, 802.5, or "none of the above"? */
   switch (pinfo->pseudo_header->ngsniffer_atm.AppHLType) {
@@ -395,7 +405,9 @@ dissect_lane(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 
   case AHLT_LANE_802_3:
   case AHLT_LANE_802_3_MC:
-    dissect_le_client(tvb, pinfo, tree);
+    if (check_col(pinfo->cinfo, COL_INFO))
+      col_set_str(pinfo->cinfo, COL_INFO, "LE Client - Ethernet/802.3");
+    dissect_le_client(tvb, tree);
 
     /* Dissect as Ethernet */
     next_tvb_le_client = tvb_new_subset(tvb, 2, -1, -1);
@@ -404,7 +416,9 @@ dissect_lane(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 
   case AHLT_LANE_802_5:
   case AHLT_LANE_802_5_MC:
-    dissect_le_client(tvb, pinfo, tree);
+    if (check_col(pinfo->cinfo, COL_INFO))
+      col_set_str(pinfo->cinfo, COL_INFO, "LE Client - 802.5");
+    dissect_le_client(tvb, tree);
 
     /* Dissect as Token-Ring */
     next_tvb_le_client = tvb_new_subset(tvb, 2, -1, -1);
@@ -413,6 +427,9 @@ dissect_lane(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 
   default:
     /* Dump it as raw data. */
+    if (check_col(pinfo->cinfo, COL_INFO))
+      col_add_fstr(pinfo->cinfo, COL_INFO, "Unknown LANE traffic type %x",
+                 pinfo->pseudo_header->ngsniffer_atm.AppHLType);
     next_tvb           = tvb_new_subset(tvb, 0, -1, -1);
     call_dissector(data_handle,next_tvb, pinfo, tree);
     break;
@@ -604,35 +621,35 @@ dissect_atm(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
     }
   }
 
-  if (check_col(pinfo->fd, COL_PROTOCOL))
-    col_set_str(pinfo->fd, COL_PROTOCOL, "ATM");
+  if (check_col(pinfo->cinfo, COL_PROTOCOL))
+    col_set_str(pinfo->cinfo, COL_PROTOCOL, "ATM");
 
   switch (pinfo->pseudo_header->ngsniffer_atm.channel) {
 
   case 0:
     /* Traffic from DCE to DTE. */
-    if (check_col(pinfo->fd, COL_RES_DL_DST))
-      col_set_str(pinfo->fd, COL_RES_DL_DST, "DTE");
-    if (check_col(pinfo->fd, COL_RES_DL_SRC))
-      col_set_str(pinfo->fd, COL_RES_DL_SRC, "DCE");
+    if (check_col(pinfo->cinfo, COL_RES_DL_DST))
+      col_set_str(pinfo->cinfo, COL_RES_DL_DST, "DTE");
+    if (check_col(pinfo->cinfo, COL_RES_DL_SRC))
+      col_set_str(pinfo->cinfo, COL_RES_DL_SRC, "DCE");
     break;
 
   case 1:
     /* Traffic from DTE to DCE. */
-    if (check_col(pinfo->fd, COL_RES_DL_DST))
-      col_set_str(pinfo->fd, COL_RES_DL_DST, "DCE");
-    if (check_col(pinfo->fd, COL_RES_DL_SRC))
-      col_set_str(pinfo->fd, COL_RES_DL_SRC, "DTE");
+    if (check_col(pinfo->cinfo, COL_RES_DL_DST))
+      col_set_str(pinfo->cinfo, COL_RES_DL_DST, "DCE");
+    if (check_col(pinfo->cinfo, COL_RES_DL_SRC))
+      col_set_str(pinfo->cinfo, COL_RES_DL_SRC, "DTE");
     break;
   }
 
-  if (check_col(pinfo->fd, COL_INFO)) {
+  if (check_col(pinfo->cinfo, COL_INFO)) {
     if (aal_type == ATT_AAL5) {
-      col_add_fstr(pinfo->fd, COL_INFO, "AAL5 %s",
+      col_add_fstr(pinfo->cinfo, COL_INFO, "AAL5 %s",
                val_to_str(hl_type, aal5_hltype_vals,
                                "Unknown traffic type (%x)"));
     } else {
-      col_add_str(pinfo->fd, COL_INFO,
+      col_add_str(pinfo->cinfo, COL_INFO,
                val_to_str(aal_type, aal_vals, "Unknown AAL (%x)"));
     }
   }
@@ -798,6 +815,8 @@ proto_register_atm(void)
 void
 proto_reg_handoff_atm(void)
 {
+       dissector_handle_t atm_handle;
+
        /*
         * Get handles for the Ethernet, Token Ring, LLC, SSCOP, LANE,
         * and ILMI dissectors.
@@ -810,6 +829,7 @@ proto_reg_handoff_atm(void)
        ilmi_handle = find_dissector("ilmi");
        data_handle = find_dissector("data");
 
-       dissector_add("wtap_encap", WTAP_ENCAP_ATM_SNIFFER, dissect_atm,
-           proto_atm);
+       atm_handle = create_dissector_handle(dissect_atm, proto_atm);
+
+       dissector_add("wtap_encap", WTAP_ENCAP_ATM_SNIFFER, atm_handle);
 }