/src/wireshark/epan/dissectors/packet-ascend.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* packet-ascend.c |
2 | | * Routines for decoding Lucent/Ascend packet traces |
3 | | * |
4 | | * Wireshark - Network traffic analyzer |
5 | | * By Gerald Combs <gerald@wireshark.org> |
6 | | * |
7 | | * SPDX-License-Identifier: GPL-2.0-or-later |
8 | | */ |
9 | | |
10 | | #include "config.h" |
11 | | |
12 | | #include <epan/packet.h> |
13 | | #include <wiretap/wtap.h> |
14 | | |
15 | | void proto_register_ascend(void); |
16 | | void proto_reg_handoff_ascend(void); |
17 | | |
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; |
25 | | |
26 | | static int ett_raw; |
27 | | |
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 } |
36 | | }; |
37 | | |
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; |
42 | | |
43 | | static int |
44 | | dissect_ascend(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_) |
45 | 0 | { |
46 | 0 | proto_tree *fh_tree; |
47 | 0 | proto_item *ti, *hidden_item; |
48 | 0 | union wtap_pseudo_header *pseudo_header = pinfo->pseudo_header; |
49 | 0 | struct isdn_phdr isdn; |
50 | | |
51 | | /* load the top pane info. This should be overwritten by |
52 | | the next protocol in the stack */ |
53 | 0 | col_set_str(pinfo->cinfo, COL_RES_DL_SRC, "N/A"); |
54 | 0 | col_set_str(pinfo->cinfo, COL_RES_DL_DST, "N/A"); |
55 | 0 | col_set_str(pinfo->cinfo, COL_PROTOCOL, "N/A"); |
56 | 0 | col_set_str(pinfo->cinfo, COL_INFO, "Lucent/Ascend packet trace"); |
57 | | |
58 | | /* If this is a transmitted or received PPP frame, set the PPP direction. */ |
59 | 0 | switch (pseudo_header->ascend.type) { |
60 | | |
61 | 0 | case ASCEND_PFX_WDS_X: |
62 | 0 | pinfo->p2p_dir = P2P_DIR_SENT; |
63 | 0 | break; |
64 | | |
65 | 0 | case ASCEND_PFX_WDS_R: |
66 | 0 | pinfo->p2p_dir = P2P_DIR_RECV; |
67 | 0 | break; |
68 | 0 | } |
69 | | |
70 | | /* populate a tree in the second pane with the status of the link |
71 | | layer (ie none) */ |
72 | 0 | if(tree) { |
73 | 0 | ti = proto_tree_add_protocol_format(tree, proto_ascend, tvb, 0, 0, |
74 | 0 | "Lucent/Ascend packet trace"); |
75 | 0 | fh_tree = proto_item_add_subtree(ti, ett_raw); |
76 | 0 | proto_tree_add_uint(fh_tree, hf_link_type, tvb, 0, 0, |
77 | 0 | pseudo_header->ascend.type); |
78 | 0 | switch (pseudo_header->ascend.type) { |
79 | | |
80 | 0 | case ASCEND_PFX_WDD: |
81 | | /* Ethernet packet forcing a call */ |
82 | 0 | proto_tree_add_string(fh_tree, hf_called_number, tvb, 0, 0, |
83 | 0 | pseudo_header->ascend.call_num); |
84 | 0 | proto_tree_add_uint(fh_tree, hf_chunk, tvb, 0, 0, |
85 | 0 | pseudo_header->ascend.chunk); |
86 | 0 | hidden_item = proto_tree_add_uint(fh_tree, hf_session_id, tvb, 0, 0, 0); |
87 | 0 | proto_item_set_hidden(hidden_item); |
88 | 0 | break; |
89 | | |
90 | 0 | case ASCEND_PFX_WDS_X: |
91 | 0 | case ASCEND_PFX_WDS_R: |
92 | | /* wandsession data */ |
93 | 0 | proto_tree_add_string(fh_tree, hf_user_name, tvb, 0, 0, |
94 | 0 | pseudo_header->ascend.user); |
95 | 0 | proto_tree_add_uint(fh_tree, hf_session_id, tvb, 0, 0, |
96 | 0 | pseudo_header->ascend.sess); |
97 | 0 | hidden_item = proto_tree_add_uint(fh_tree, hf_chunk, tvb, 0, 0, 0); |
98 | 0 | proto_item_set_hidden(hidden_item); |
99 | 0 | break; |
100 | | |
101 | 0 | default: |
102 | 0 | break; |
103 | 0 | } |
104 | 0 | proto_tree_add_uint(fh_tree, hf_task, tvb, 0, 0, pseudo_header->ascend.task); |
105 | 0 | } |
106 | | |
107 | 0 | switch (pseudo_header->ascend.type) { |
108 | 0 | case ASCEND_PFX_WDS_X: |
109 | 0 | case ASCEND_PFX_WDS_R: |
110 | 0 | call_dissector(ppp_hdlc_handle, tvb, pinfo, tree); |
111 | 0 | break; |
112 | 0 | case ASCEND_PFX_WDD: |
113 | 0 | case ASCEND_PFX_ETHER: |
114 | 0 | call_dissector(eth_withoutfcs_handle, tvb, pinfo, tree); |
115 | 0 | break; |
116 | 0 | case ASCEND_PFX_ISDN_X: |
117 | 0 | isdn.uton = true; |
118 | 0 | isdn.channel = 0; |
119 | 0 | call_dissector_with_data(lapd_phdr_handle, tvb, pinfo, tree, &isdn); |
120 | 0 | break; |
121 | 0 | case ASCEND_PFX_ISDN_R: |
122 | 0 | isdn.uton = false; |
123 | 0 | isdn.channel = 0; |
124 | 0 | call_dissector_with_data(lapd_phdr_handle, tvb, pinfo, tree, &isdn); |
125 | 0 | break; |
126 | 0 | default: |
127 | 0 | break; |
128 | 0 | } |
129 | 0 | return tvb_captured_length(tvb); |
130 | 0 | } |
131 | | |
132 | | void |
133 | | proto_register_ascend(void) |
134 | 14 | { |
135 | 14 | static hf_register_info hf[] = { |
136 | 14 | { &hf_link_type, |
137 | 14 | { "Link type", "ascend.type", FT_UINT32, BASE_DEC, VALS(encaps_vals), 0x0, |
138 | 14 | NULL, HFILL }}, |
139 | | |
140 | 14 | { &hf_session_id, |
141 | 14 | { "Session ID", "ascend.sess", FT_UINT32, BASE_DEC, NULL, 0x0, |
142 | 14 | NULL, HFILL }}, |
143 | | |
144 | 14 | { &hf_called_number, |
145 | 14 | { "Called number", "ascend.number", FT_STRING, BASE_NONE, NULL, 0x0, |
146 | 14 | NULL, HFILL }}, |
147 | | |
148 | 14 | { &hf_chunk, |
149 | 14 | { "WDD Chunk", "ascend.chunk", FT_UINT32, BASE_HEX, NULL, 0x0, |
150 | 14 | NULL, HFILL }}, |
151 | | |
152 | 14 | { &hf_task, |
153 | 14 | { "Task", "ascend.task", FT_UINT32, BASE_HEX, NULL, 0x0, |
154 | 14 | NULL, HFILL }}, |
155 | | |
156 | 14 | { &hf_user_name, |
157 | 14 | { "User name", "ascend.user", FT_STRING, BASE_NONE, NULL, 0x0, |
158 | 14 | NULL, HFILL }}, |
159 | 14 | }; |
160 | 14 | static int *ett[] = { |
161 | 14 | &ett_raw, |
162 | 14 | }; |
163 | | |
164 | 14 | proto_ascend = proto_register_protocol("Lucent/Ascend debug output", |
165 | 14 | "Lucent/Ascend", "ascend"); |
166 | 14 | proto_register_field_array(proto_ascend, hf, array_length(hf)); |
167 | 14 | proto_register_subtree_array(ett, array_length(ett)); |
168 | | |
169 | 14 | ascend_handle = register_dissector("ascend", dissect_ascend, proto_ascend); |
170 | 14 | } |
171 | | |
172 | | void |
173 | | proto_reg_handoff_ascend(void) |
174 | 14 | { |
175 | | /* |
176 | | * Get handles for the Ethernet, PPP-in-HDLC-like-framing, and |
177 | | * LAPD-with-pseudoheader dissectors. |
178 | | */ |
179 | 14 | eth_withoutfcs_handle = find_dissector_add_dependency("eth_withoutfcs", proto_ascend); |
180 | 14 | ppp_hdlc_handle = find_dissector_add_dependency("ppp_hdlc", proto_ascend); |
181 | 14 | lapd_phdr_handle = find_dissector_add_dependency("lapd-phdr", proto_ascend); |
182 | | |
183 | 14 | dissector_add_uint("wtap_encap", WTAP_ENCAP_ASCEND, ascend_handle); |
184 | 14 | } |
185 | | |
186 | | /* |
187 | | * Editor modelines - https://www.wireshark.org/tools/modelines.html |
188 | | * |
189 | | * Local Variables: |
190 | | * c-basic-offset: 2 |
191 | | * tab-width: 8 |
192 | | * indent-tabs-mode: nil |
193 | | * End: |
194 | | * |
195 | | * ex: set shiftwidth=2 tabstop=8 expandtab: |
196 | | * :indentSize=2:tabSize=8:noTabs=true: |
197 | | */ |