HACK: pinfo->private_data points to smb_info again
[wireshark-wip.git] / epan / dissectors / packet-ascend.c
blob20ec93aabbd860a6a78028667eab59c5a18f8234
1 /* packet-ascend.c
2 * Routines for decoding Lucent/Ascend packet traces
4 * $Id$
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 #include "config.h"
26 #include <glib.h>
27 #include <epan/packet.h>
29 void proto_register_ascend(void);
30 void proto_reg_handoff_acend(void);
32 static int proto_ascend = -1;
33 static int hf_link_type = -1;
34 static int hf_session_id = -1;
35 static int hf_called_number = -1;
36 static int hf_chunk = -1;
37 static int hf_task = -1;
38 static int hf_user_name = -1;
40 static gint ett_raw = -1;
42 static const value_string encaps_vals[] = {
43 {ASCEND_PFX_WDS_X, "PPP Transmit"},
44 {ASCEND_PFX_WDS_R, "PPP Receive" },
45 {ASCEND_PFX_WDD, "Ethernet" },
46 {0, NULL } };
48 static dissector_handle_t eth_withoutfcs_handle;
49 static dissector_handle_t ppp_hdlc_handle;
51 static void
52 dissect_ascend(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
54 proto_tree *fh_tree;
55 proto_item *ti, *hidden_item;
56 union wtap_pseudo_header *pseudo_header = pinfo->pseudo_header;
58 /* load the top pane info. This should be overwritten by
59 the next protocol in the stack */
60 col_set_str(pinfo->cinfo, COL_RES_DL_SRC, "N/A");
61 col_set_str(pinfo->cinfo, COL_RES_DL_DST, "N/A");
62 col_set_str(pinfo->cinfo, COL_PROTOCOL, "N/A");
63 col_set_str(pinfo->cinfo, COL_INFO, "Lucent/Ascend packet trace");
65 /* If this is a transmitted or received PPP frame, set the PPP direction. */
66 switch (pseudo_header->ascend.type) {
68 case ASCEND_PFX_WDS_X:
69 pinfo->p2p_dir = P2P_DIR_SENT;
70 break;
72 case ASCEND_PFX_WDS_R:
73 pinfo->p2p_dir = P2P_DIR_RECV;
74 break;
77 /* populate a tree in the second pane with the status of the link
78 layer (ie none) */
79 if(tree) {
80 ti = proto_tree_add_protocol_format(tree, proto_ascend, tvb, 0, 0,
81 "Lucent/Ascend packet trace");
82 fh_tree = proto_item_add_subtree(ti, ett_raw);
83 proto_tree_add_uint(fh_tree, hf_link_type, tvb, 0, 0,
84 pseudo_header->ascend.type);
85 if (pseudo_header->ascend.type == ASCEND_PFX_WDD) {
86 proto_tree_add_string(fh_tree, hf_called_number, tvb, 0, 0,
87 pseudo_header->ascend.call_num);
88 proto_tree_add_uint(fh_tree, hf_chunk, tvb, 0, 0,
89 pseudo_header->ascend.chunk);
90 hidden_item = proto_tree_add_uint(fh_tree, hf_session_id, tvb, 0, 0, 0);
91 PROTO_ITEM_SET_HIDDEN(hidden_item);
92 } else { /* It's wandsession data */
93 proto_tree_add_string(fh_tree, hf_user_name, tvb, 0, 0,
94 pseudo_header->ascend.user);
95 proto_tree_add_uint(fh_tree, hf_session_id, tvb, 0, 0,
96 pseudo_header->ascend.sess);
97 hidden_item = proto_tree_add_uint(fh_tree, hf_chunk, tvb, 0, 0, 0);
98 PROTO_ITEM_SET_HIDDEN(hidden_item);
100 proto_tree_add_uint(fh_tree, hf_task, tvb, 0, 0, pseudo_header->ascend.task);
103 switch (pseudo_header->ascend.type) {
104 case ASCEND_PFX_WDS_X:
105 case ASCEND_PFX_WDS_R:
106 call_dissector(ppp_hdlc_handle, tvb, pinfo, tree);
107 break;
108 case ASCEND_PFX_WDD:
109 call_dissector(eth_withoutfcs_handle, tvb, pinfo, tree);
110 break;
111 default:
112 break;
116 void
117 proto_register_ascend(void)
119 static hf_register_info hf[] = {
120 { &hf_link_type,
121 { "Link type", "ascend.type", FT_UINT32, BASE_DEC, VALS(encaps_vals), 0x0,
122 NULL, HFILL }},
124 { &hf_session_id,
125 { "Session ID", "ascend.sess", FT_UINT32, BASE_DEC, NULL, 0x0,
126 NULL, HFILL }},
128 { &hf_called_number,
129 { "Called number", "ascend.number", FT_STRING, BASE_NONE, NULL, 0x0,
130 NULL, HFILL }},
132 { &hf_chunk,
133 { "WDD Chunk", "ascend.chunk", FT_UINT32, BASE_HEX, NULL, 0x0,
134 NULL, HFILL }},
136 { &hf_task,
137 { "Task", "ascend.task", FT_UINT32, BASE_HEX, NULL, 0x0,
138 NULL, HFILL }},
140 { &hf_user_name,
141 { "User name", "ascend.user", FT_STRING, BASE_NONE, NULL, 0x0,
142 NULL, HFILL }},
144 static gint *ett[] = {
145 &ett_raw,
148 proto_ascend = proto_register_protocol("Lucent/Ascend debug output",
149 "Lucent/Ascend", "ascend");
150 proto_register_field_array(proto_ascend, hf, array_length(hf));
151 proto_register_subtree_array(ett, array_length(ett));
154 void
155 proto_reg_handoff_ascend(void)
157 dissector_handle_t ascend_handle;
160 * Get handles for the Ethernet and PPP-in-HDLC-like-framing dissectors.
162 eth_withoutfcs_handle = find_dissector("eth_withoutfcs");
163 ppp_hdlc_handle = find_dissector("ppp_hdlc");
165 ascend_handle = create_dissector_handle(dissect_ascend, proto_ascend);
166 dissector_add_uint("wtap_encap", WTAP_ENCAP_ASCEND, ascend_handle);