2 * Routines for ATM over TCP dissection
3 * Copyright 2011, Alexis La Goutte <alexis.lagoutte at gmail dot com>
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (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 along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 * http://git.kernel.org/?p=linux/kernel/git/next/linux-next.git;a=blob;f=include/linux/atm_tcp.h;hb=HEAD
28 * http://git.kernel.org/?p=linux/kernel/git/next/linux-next.git;a=blob;f=drivers/atm/atmtcp.c;hb=HEAD
35 #include <epan/packet.h>
36 #include <epan/prefs.h>
38 void proto_register_atmtcp(void);
39 void proto_reg_handoff_atmtcp(void);
41 static int proto_atmtcp
= -1;
42 static int hf_atmtcp_vpi
= -1;
43 static int hf_atmtcp_vci
= -1;
44 static int hf_atmtcp_length
= -1;
46 static guint global_atmtcp_tcp_port
= 2812;
48 static gint ett_atmtcp
= -1;
50 static dissector_handle_t data_handle
;
52 #define ATMTCP_HDR_MAGIC (~0) /* this length indicates a command */
53 #define ATMTCP_CTRL_OPEN 1 /* request/reply */
54 #define ATMTCP_CTRL_CLOSE 2 /* request/reply */
57 dissect_atmtcp(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void *data _U_
)
61 proto_tree
*atmtcp_tree
;
66 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "ATMTCP");
68 col_set_str(pinfo
->cinfo
, COL_INFO
, "ATMTCP");
71 ti
= proto_tree_add_item(tree
, proto_atmtcp
, tvb
, 0, -1, ENC_NA
);
73 atmtcp_tree
= proto_item_add_subtree(ti
, ett_atmtcp
);
76 proto_tree_add_item(atmtcp_tree
, hf_atmtcp_vpi
, tvb
, offset
, 2, ENC_NA
);
83 proto_tree_add_item(atmtcp_tree
, hf_atmtcp_vci
, tvb
, offset
, 2, ENC_NA
);
90 proto_tree_add_item(atmtcp_tree
, hf_atmtcp_length
, tvb
, offset
, 4, ENC_NA
);
92 length
= tvb_get_ntohl(tvb
, offset
);
93 if(length
== ATMTCP_HDR_MAGIC
)
95 col_append_str(pinfo
->cinfo
, COL_INFO
, " Command");
99 col_append_str(pinfo
->cinfo
, COL_INFO
, " Data");
103 /* Data (for the moment...) */
104 next_tvb
= tvb_new_subset_remaining(tvb
, offset
);
105 call_dissector(data_handle
, next_tvb
, pinfo
, tree
);
106 return tvb_length(tvb
);
111 proto_register_atmtcp(void)
113 module_t
*atmtcp_module
;
116 static hf_register_info hf
[] = {
118 { "VPI", "atmtcp.vpi", FT_UINT16
, BASE_DEC
, NULL
, 0x0,
119 "Virtual Path Identifier", HFILL
}
122 { "VCI", "atmtcp.vci", FT_UINT16
, BASE_DEC
, NULL
, 0x0,
123 "Virtual Channel Identifier", HFILL
}
126 { "Length", "atmtcp.length", FT_UINT32
, BASE_DEC
, NULL
, 0x0,
127 "length of data", HFILL
}
132 static gint
*ett
[] = {
137 proto_atmtcp
= proto_register_protocol("ATM over TCP", "ATMTCP", "atmtcp");
139 proto_register_field_array(proto_atmtcp
, hf
, array_length(hf
));
140 proto_register_subtree_array(ett
, array_length(ett
));
143 atmtcp_module
= prefs_register_protocol(proto_atmtcp
, proto_reg_handoff_atmtcp
);
145 prefs_register_uint_preference(atmtcp_module
, "tcp.port", "ATMTCP TCP Port",
146 "ATMTCP TCP port if other than the default",
147 10, &global_atmtcp_tcp_port
);
152 proto_reg_handoff_atmtcp(void)
154 static gboolean initialized
= FALSE
;
155 static dissector_handle_t atmtcp_handle
;
156 static int current_port
;
159 atmtcp_handle
= new_create_dissector_handle(dissect_atmtcp
, proto_atmtcp
);
160 data_handle
= find_dissector("data");
163 dissector_delete_uint("tcp.port", current_port
, atmtcp_handle
);
166 current_port
= global_atmtcp_tcp_port
;
168 dissector_add_uint("tcp.port", current_port
, atmtcp_handle
);
172 * Editor modelines - http://www.wireshark.org/tools/modelines.html
177 * indent-tabs-mode: nil
180 * vi: set shiftwidth=4 tabstop=8 expandtab:
181 * :indentSize=4:tabSize=8:noTabs=true: