Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-ascend.c
blob96d861b078b1aa06f0d91b948dab3974e1281dfc
1 /* packet-ascend.c
2 * Routines for decoding Lucent/Ascend packet traces
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
7 * SPDX-License-Identifier: GPL-2.0-or-later
8 */
10 #include "config.h"
12 #include <epan/packet.h>
13 #include <wiretap/wtap.h>
15 void proto_register_ascend(void);
16 void proto_reg_handoff_ascend(void);
18 static int proto_ascend;
19 static int hf_link_type;
20 static int hf_session_id;
21 static int hf_called_number;
22 static int hf_chunk;
23 static int hf_task;
24 static int hf_user_name;
26 static int ett_raw;
28 static const value_string encaps_vals[] = {
29 {ASCEND_PFX_WDS_X, "PPP Transmit" },
30 {ASCEND_PFX_WDS_R, "PPP Receive" },
31 {ASCEND_PFX_WDD, "Ethernet triggering dialout"},
32 {ASCEND_PFX_ISDN_X, "ISDN Transmit" },
33 {ASCEND_PFX_ISDN_R, "ISDN Receive" },
34 {ASCEND_PFX_ETHER, "Ethernet" },
35 {0, NULL }
38 static dissector_handle_t ascend_handle;
39 static dissector_handle_t eth_withoutfcs_handle;
40 static dissector_handle_t ppp_hdlc_handle;
41 static dissector_handle_t lapd_phdr_handle;
43 static int
44 dissect_ascend(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
46 proto_tree *fh_tree;
47 proto_item *ti, *hidden_item;
48 union wtap_pseudo_header *pseudo_header = pinfo->pseudo_header;
49 struct isdn_phdr isdn;
51 /* load the top pane info. This should be overwritten by
52 the next protocol in the stack */
53 col_set_str(pinfo->cinfo, COL_RES_DL_SRC, "N/A");
54 col_set_str(pinfo->cinfo, COL_RES_DL_DST, "N/A");
55 col_set_str(pinfo->cinfo, COL_PROTOCOL, "N/A");
56 col_set_str(pinfo->cinfo, COL_INFO, "Lucent/Ascend packet trace");
58 /* If this is a transmitted or received PPP frame, set the PPP direction. */
59 switch (pseudo_header->ascend.type) {
61 case ASCEND_PFX_WDS_X:
62 pinfo->p2p_dir = P2P_DIR_SENT;
63 break;
65 case ASCEND_PFX_WDS_R:
66 pinfo->p2p_dir = P2P_DIR_RECV;
67 break;
70 /* populate a tree in the second pane with the status of the link
71 layer (ie none) */
72 if(tree) {
73 ti = proto_tree_add_protocol_format(tree, proto_ascend, tvb, 0, 0,
74 "Lucent/Ascend packet trace");
75 fh_tree = proto_item_add_subtree(ti, ett_raw);
76 proto_tree_add_uint(fh_tree, hf_link_type, tvb, 0, 0,
77 pseudo_header->ascend.type);
78 switch (pseudo_header->ascend.type) {
80 case ASCEND_PFX_WDD:
81 /* Ethernet packet forcing a call */
82 proto_tree_add_string(fh_tree, hf_called_number, tvb, 0, 0,
83 pseudo_header->ascend.call_num);
84 proto_tree_add_uint(fh_tree, hf_chunk, tvb, 0, 0,
85 pseudo_header->ascend.chunk);
86 hidden_item = proto_tree_add_uint(fh_tree, hf_session_id, tvb, 0, 0, 0);
87 proto_item_set_hidden(hidden_item);
88 break;
90 case ASCEND_PFX_WDS_X:
91 case ASCEND_PFX_WDS_R:
92 /* 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);
99 break;
101 default:
102 break;
104 proto_tree_add_uint(fh_tree, hf_task, tvb, 0, 0, pseudo_header->ascend.task);
107 switch (pseudo_header->ascend.type) {
108 case ASCEND_PFX_WDS_X:
109 case ASCEND_PFX_WDS_R:
110 call_dissector(ppp_hdlc_handle, tvb, pinfo, tree);
111 break;
112 case ASCEND_PFX_WDD:
113 case ASCEND_PFX_ETHER:
114 call_dissector(eth_withoutfcs_handle, tvb, pinfo, tree);
115 break;
116 case ASCEND_PFX_ISDN_X:
117 isdn.uton = true;
118 isdn.channel = 0;
119 call_dissector_with_data(lapd_phdr_handle, tvb, pinfo, tree, &isdn);
120 break;
121 case ASCEND_PFX_ISDN_R:
122 isdn.uton = false;
123 isdn.channel = 0;
124 call_dissector_with_data(lapd_phdr_handle, tvb, pinfo, tree, &isdn);
125 break;
126 default:
127 break;
129 return tvb_captured_length(tvb);
132 void
133 proto_register_ascend(void)
135 static hf_register_info hf[] = {
136 { &hf_link_type,
137 { "Link type", "ascend.type", FT_UINT32, BASE_DEC, VALS(encaps_vals), 0x0,
138 NULL, HFILL }},
140 { &hf_session_id,
141 { "Session ID", "ascend.sess", FT_UINT32, BASE_DEC, NULL, 0x0,
142 NULL, HFILL }},
144 { &hf_called_number,
145 { "Called number", "ascend.number", FT_STRING, BASE_NONE, NULL, 0x0,
146 NULL, HFILL }},
148 { &hf_chunk,
149 { "WDD Chunk", "ascend.chunk", FT_UINT32, BASE_HEX, NULL, 0x0,
150 NULL, HFILL }},
152 { &hf_task,
153 { "Task", "ascend.task", FT_UINT32, BASE_HEX, NULL, 0x0,
154 NULL, HFILL }},
156 { &hf_user_name,
157 { "User name", "ascend.user", FT_STRING, BASE_NONE, NULL, 0x0,
158 NULL, HFILL }},
160 static int *ett[] = {
161 &ett_raw,
164 proto_ascend = proto_register_protocol("Lucent/Ascend debug output",
165 "Lucent/Ascend", "ascend");
166 proto_register_field_array(proto_ascend, hf, array_length(hf));
167 proto_register_subtree_array(ett, array_length(ett));
169 ascend_handle = register_dissector("ascend", dissect_ascend, proto_ascend);
172 void
173 proto_reg_handoff_ascend(void)
176 * Get handles for the Ethernet, PPP-in-HDLC-like-framing, and
177 * LAPD-with-pseudoheader dissectors.
179 eth_withoutfcs_handle = find_dissector_add_dependency("eth_withoutfcs", proto_ascend);
180 ppp_hdlc_handle = find_dissector_add_dependency("ppp_hdlc", proto_ascend);
181 lapd_phdr_handle = find_dissector_add_dependency("lapd-phdr", proto_ascend);
183 dissector_add_uint("wtap_encap", WTAP_ENCAP_ASCEND, ascend_handle);
187 * Editor modelines - https://www.wireshark.org/tools/modelines.html
189 * Local Variables:
190 * c-basic-offset: 2
191 * tab-width: 8
192 * indent-tabs-mode: nil
193 * End:
195 * ex: set shiftwidth=2 tabstop=8 expandtab:
196 * :indentSize=2:tabSize=8:noTabs=true: