Include files from the "epan" directory and subdirectories thereof with
[obnox/wireshark/wip.git] / packet-v120.c
index 3847180bb5a131ec9ed8bbf47fc3d3c6ab0dc65a..9d762020f888d0c431fe1f970181e7437889358a 100644 (file)
@@ -2,12 +2,11 @@
  * Routines for v120 frame disassembly
  * Bert Driehuis <driehuis@playbeing.org>
  *
- * $Id: packet-v120.c,v 1.14 2000/11/19 08:54:10 guy Exp $
+ * $Id: packet-v120.c,v 1.24 2002/01/21 07:36:44 guy Exp $
  *
  * Ethereal - Network traffic analyzer
- * By Gerald Combs <gerald@zing.org>
+ * By Gerald Combs <gerald@ethereal.com>
  * Copyright 1998
- *
  * 
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -35,8 +34,7 @@
 #include <stdio.h>
 #include <glib.h>
 #include <string.h>
-#include "packet.h"
-#include "packet-v120.h"
+#include <epan/packet.h>
 #include "xdlc.h"
 
 #define FROM_DCE       0x80
@@ -51,9 +49,11 @@ static gint ett_v120_address = -1;
 static gint ett_v120_control = -1;
 static gint ett_v120_header = -1;
 
+static dissector_handle_t data_handle;
+
 static int dissect_v120_header(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree);
 
-void
+static void
 dissect_v120(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
 {
     proto_tree *v120_tree, *tc, *address_tree;
@@ -66,41 +66,39 @@ dissect_v120(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
     guint16    control;
     tvbuff_t   *next_tvb;
 
-    CHECK_DISPLAY_AS_DATA(proto_v120, tvb, pinfo, tree);
-
-    pinfo->current_proto = "V.120";
-
-    if (check_col(pinfo->fd, COL_PROTOCOL))
-       col_set_str(pinfo->fd, COL_PROTOCOL, "V.120");
+    if (check_col(pinfo->cinfo, COL_PROTOCOL))
+       col_set_str(pinfo->cinfo, COL_PROTOCOL, "V.120");
+    if (check_col(pinfo->cinfo, COL_INFO))
+       col_clear(pinfo->cinfo, COL_INFO);
 
     byte0 = tvb_get_guint8(tvb, 0);
 
-    if(check_col(pinfo->fd, COL_RES_DL_SRC))
-       col_add_fstr(pinfo->fd, COL_RES_DL_SRC, "0x%02X", byte0);
+    if(check_col(pinfo->cinfo, COL_RES_DL_SRC))
+       col_add_fstr(pinfo->cinfo, COL_RES_DL_SRC, "0x%02X", byte0);
 
     byte1 = tvb_get_guint8(tvb, 1);
 
     if ((byte0 & 0x01) != 0x00 && (byte1 && 0x01) != 0x01)
     {
-       if (check_col(pinfo->fd, COL_INFO))
-           col_set_str(pinfo->fd, COL_INFO, "Invalid V.120 frame");
+       if (check_col(pinfo->cinfo, COL_INFO))
+           col_set_str(pinfo->cinfo, COL_INFO, "Invalid V.120 frame");
        if (tree)
-           ti = proto_tree_add_protocol_format(tree, proto_v120, tvb, 0, tvb_length(tvb),
+           ti = proto_tree_add_protocol_format(tree, proto_v120, tvb, 0, -1,
                                            "Invalid V.120 frame");
        return;
     }
 
     if (pinfo->pseudo_header->x25.flags & FROM_DCE) {
-       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");
     }
     else {
-       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");
     }
 
     if (((pinfo->pseudo_header->x25.flags & FROM_DCE) && byte0 & 0x02) ||
@@ -110,7 +108,7 @@ dissect_v120(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        is_response = FALSE;
 
     if (tree) {
-       ti = proto_tree_add_protocol_format(tree, proto_v120, tvb, 0, 0, "V.120");
+       ti = proto_tree_add_protocol_format(tree, proto_v120, tvb, 0, -1, "V.120");
        v120_tree = proto_item_add_subtree(ti, ett_v120);
        addr = byte1 << 8 | byte0;
        sprintf(info, "LLI: %d C/R: %s",
@@ -145,7 +143,7 @@ dissect_v120(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                v120len += dissect_v120_header(tvb, v120len, pinfo, v120_tree);
        proto_item_set_len(ti, v120len);
        next_tvb = tvb_new_subset(tvb, v120len, -1, -1);
-       dissect_data(next_tvb, 0, pinfo, v120_tree);
+       call_dissector(data_handle,next_tvb, pinfo, v120_tree);
     }
 }
 
@@ -212,13 +210,13 @@ proto_register_v120(void)
     static hf_register_info hf[] = {
        { &hf_v120_address,
          { "Link Address", "v120.address", FT_UINT16, BASE_HEX, NULL,
-                 0x0, "" }},
+                 0x0, "", HFILL }},
        { &hf_v120_control,
          { "Control Field", "v120.control", FT_UINT16, BASE_HEX, NULL, 0x0,
-               "" }},
+               "", HFILL }},
        { &hf_v120_header,
          { "Header Field", "v120.header", FT_STRING, BASE_NONE, NULL, 0x0,
-               "" }},
+               "", HFILL }},
     };
     static gint *ett[] = {
         &ett_v120,
@@ -227,7 +225,18 @@ proto_register_v120(void)
         &ett_v120_header,
     };
 
-    proto_v120 = proto_register_protocol ("Async data over ISDN (V.120)", "v120");
+    proto_v120 = proto_register_protocol("Async data over ISDN (V.120)",
+                                        "V.120", "v120");
     proto_register_field_array (proto_v120, hf, array_length(hf));
     proto_register_subtree_array(ett, array_length(ett));
 }
+
+void
+proto_reg_handoff_v120(void)
+{
+    dissector_handle_t v120_handle;
+
+    data_handle = find_dissector("data");
+    v120_handle = create_dissector_handle(dissect_v120, proto_v120);
+    dissector_add("wtap_encap", WTAP_ENCAP_V120, v120_handle);
+}