Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-atmtcp.c
blob73f49fa576266a7f4928e48a36f7a6d2f37f5871
1 /* packet-atmtcp.c
2 * Routines for ATM over TCP dissection
3 * Copyright 2011, Alexis La Goutte <alexis.lagoutte at gmail dot com>
5 * Wireshark - Network traffic analyzer
6 * By Gerald Combs <gerald@wireshark.org>
7 * Copyright 1998 Gerald Combs
9 * SPDX-License-Identifier: GPL-2.0-or-later
12 /* Specification...
13 * http://git.kernel.org/?p=linux/kernel/git/next/linux-next.git;a=blob;f=include/linux/atm_tcp.h;hb=HEAD
14 * http://git.kernel.org/?p=linux/kernel/git/next/linux-next.git;a=blob;f=drivers/atm/atmtcp.c;hb=HEAD
17 #include "config.h"
19 #include <epan/packet.h>
21 void proto_register_atmtcp(void);
22 void proto_reg_handoff_atmtcp(void);
24 static dissector_handle_t atmtcp_handle;
26 static int proto_atmtcp;
27 static int hf_atmtcp_vpi;
28 static int hf_atmtcp_vci;
29 static int hf_atmtcp_length;
31 #define ATMTCP_TCP_PORT 2812
33 static int ett_atmtcp;
35 #define ATMTCP_HDR_MAGIC (~0) /* this length indicates a command */
36 #define ATMTCP_CTRL_OPEN 1 /* request/reply */
37 #define ATMTCP_CTRL_CLOSE 2 /* request/reply */
39 static int
40 dissect_atmtcp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void *data _U_)
43 proto_item *ti;
44 proto_tree *atmtcp_tree;
45 unsigned offset = 0;
46 int32_t length;
47 tvbuff_t *next_tvb;
49 col_set_str(pinfo->cinfo, COL_PROTOCOL, "ATMTCP");
51 col_set_str(pinfo->cinfo, COL_INFO, "ATMTCP");
53 if (tree) {
54 ti = proto_tree_add_item(tree, proto_atmtcp, tvb, 0, -1, ENC_NA);
56 atmtcp_tree = proto_item_add_subtree(ti, ett_atmtcp);
58 /* VPI */
59 proto_tree_add_item(atmtcp_tree, hf_atmtcp_vpi, tvb, offset, 2, ENC_BIG_ENDIAN);
61 offset += 2;
64 if (tree) {
65 /* VCI */
66 proto_tree_add_item(atmtcp_tree, hf_atmtcp_vci, tvb, offset, 2, ENC_BIG_ENDIAN);
68 offset += 2;
71 if (tree) {
72 /* Length */
73 proto_tree_add_item(atmtcp_tree, hf_atmtcp_length, tvb, offset, 4, ENC_BIG_ENDIAN);
75 length = tvb_get_ntohl(tvb, offset);
76 if(length == ATMTCP_HDR_MAGIC)
78 col_append_str(pinfo->cinfo, COL_INFO, " Command");
80 else
82 col_append_str(pinfo->cinfo, COL_INFO, " Data");
84 offset += 4;
86 /* Data (for the moment...) */
87 next_tvb = tvb_new_subset_remaining(tvb, offset);
88 call_data_dissector(next_tvb, pinfo, tree);
89 return tvb_reported_length(tvb);
93 void
94 proto_register_atmtcp(void)
96 static hf_register_info hf[] = {
97 { &hf_atmtcp_vpi,
98 { "VPI", "atmtcp.vpi", FT_UINT16, BASE_DEC, NULL, 0x0,
99 "Virtual Path Identifier", HFILL }
101 { &hf_atmtcp_vci,
102 { "VCI", "atmtcp.vci", FT_UINT16, BASE_DEC, NULL, 0x0,
103 "Virtual Channel Identifier", HFILL }
105 { &hf_atmtcp_length,
106 { "Length", "atmtcp.length", FT_UINT32, BASE_DEC, NULL, 0x0,
107 "length of data", HFILL }
112 static int *ett[] = {
113 &ett_atmtcp
117 proto_atmtcp = proto_register_protocol("ATM over TCP", "ATMTCP", "atmtcp");
119 proto_register_field_array(proto_atmtcp, hf, array_length(hf));
120 proto_register_subtree_array(ett, array_length(ett));
122 atmtcp_handle = register_dissector("atm.tcp", dissect_atmtcp, proto_atmtcp);
126 void
127 proto_reg_handoff_atmtcp(void)
129 dissector_add_uint_with_preference("tcp.port", ATMTCP_TCP_PORT, atmtcp_handle);
133 * Editor modelines - https://www.wireshark.org/tools/modelines.html
135 * Local variables:
136 * c-basic-offset: 4
137 * tab-width: 8
138 * indent-tabs-mode: nil
139 * End:
141 * vi: set shiftwidth=4 tabstop=8 expandtab:
142 * :indentSize=4:tabSize=8:noTabs=true: