Revert "TODO epan/dissectors/asn1/kerberos/packet-kerberos-template.c new GSS flags"
[wireshark-sm.git] / epan / dissectors / packet-nettl.c
blob4b22165bbfd775f52d50a1788aa507b35e40cad6
1 /* packet-nettl.c
2 * Routines for nettl (HP-UX) record header dissection
4 * Original Author Mark C. Brown <mbrown@hp.com>
5 * Copyright (C) 2005 Hewlett-Packard Development Company, L.P.
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * Copied from packet-pagp.c
13 * SPDX-License-Identifier: GPL-2.0-or-later
16 #include "config.h"
18 #include <epan/packet.h>
19 #include <epan/ipproto.h>
20 #include <wiretap/nettl.h>
22 void proto_register_nettl(void);
23 void proto_reg_handoff_nettl(void);
25 /* Initialize the protocol and registered fields */
27 static int proto_nettl;
29 static int hf_nettl_subsys;
30 static int hf_nettl_devid;
31 static int hf_nettl_kind;
32 static int hf_nettl_pid;
33 static int hf_nettl_uid;
35 static dissector_handle_t nettl_handle;
36 static dissector_handle_t eth_withoutfcs_handle;
37 static dissector_handle_t tr_handle;
38 static dissector_handle_t fddi_bitswapped_handle;
39 static dissector_handle_t lapb_handle;
40 static dissector_handle_t x25_handle;
41 static dissector_handle_t sctp_handle;
42 static dissector_handle_t raw_ip_handle;
43 static dissector_table_t ip_proto_dissector_table;
44 static dissector_table_t tcp_subdissector_table;
46 #define TCP_PORT_TELNET 23
48 /* Initialize the subtree pointers */
50 static int ett_nettl;
52 /* General declarations and macros */
54 static const value_string trace_kind[] = {
55 { 0x80000000, "Incoming Header" },
56 { 0x40000000, "Outgoing Header" },
57 { 0x20000000, "Incoming PDU - PDUIN" },
58 { 0x10000000, "Outgoing PDU - PDUOUT" },
59 { 0x08000000, "Procedure Trace" },
60 { 0x04000000, "State Trace" },
61 { 0x02000000, "Error Trace" },
62 { 0x01000000, "Logging" },
63 { 0x00800000, "Loopback" },
64 { 0, NULL }
67 static const value_string subsystem[] = {
68 { 0, "NS_LS_LOGGING" },
69 { 1, "NS_LS_NFT" },
70 { 2, "NS_LS_LOOPBACK" },
71 { 3, "NS_LS_NI" },
72 { 4, "NS_LS_IPC" },
73 { 5, "NS_LS_SOCKREGD" },
74 { 6, "NS_LS_TCP" },
75 { 7, "NS_LS_PXP" },
76 { 8, "NS_LS_UDP" },
77 { 9, "NS_LS_IP" },
78 { 10, "NS_LS_PROBE" },
79 { 11, "NS_LS_DRIVER" },
80 { 12, "NS_LS_RLBD" },
81 { 13, "NS_LS_BUFS" },
82 { 14, "NS_LS_CASE21" },
83 { 15, "NS_LS_ROUTER21" },
84 { 16, "NS_LS_NFS" },
85 { 17, "NS_LS_NETISR" },
86 { 18, "NS_LS_X25D" },
87 { 19, "NS_LS_NSE" },
88 { 20, "NS_LS_STRLOG" },
89 { 21, "NS_LS_TIRDWR" },
90 { 22, "NS_LS_TIMOD" },
91 { 23, "NS_LS_ICMP" },
92 { 24, "X25L2" },
93 { 25, "X25L3" },
94 { 26, "FILTER" },
95 { 27, "NAME" },
96 { 28, "ACC" },
97 { 29, "NS_LS_IGMP" },
98 { 31, "TOKEN" },
99 { 32, "HIPPI" },
100 { 33, "EISA_FC" },
101 { 34, "SX25L2" },
102 { 35, "SX25L3" },
103 { 36, "NS_LS_SX25" },
104 { 37, "100VG" },
105 { 38, "EISA_ATM" },
106 { 39, "SEAH_FDDI" },
107 { 40, "TELECOM_HLR" },
108 { 41, "TELECOM_SCE" },
109 { 42, "TELECOM_SMS" },
110 { 43, "TELECOM_NEM" },
111 { 50, "FORE_ATM" },
112 { 60, "TMOS_TOB" },
113 { 62, "TELECOM_SCP" },
114 { 63, "TELECOM_SS7" },
115 { 64, "FTAM_INIT" },
116 { 65, "FTAM_RESP" },
117 { 70, "FTAM_VFS" },
118 { 72, "FTAM_USER" },
119 { 82, "OVS" },
120 { 84, "OVEXTERNAL" },
121 { 90, "OTS9000" },
122 { 91, "OTS9000-NETWORK" },
123 { 92, "OTS9000-TRANSPORT" },
124 { 93, "OTS9000-SESSION" },
125 { 94, "OTS9000-ACSE_PRES" },
126 { 95, "FDDI" },
127 { 116, "SHM" },
128 { 119, "ACSE_US" },
129 { 121, "HPS" },
130 { 122, "CM" },
131 { 123, "ULA_UTILS" },
132 { 124, "EM" },
133 { 129, "STREAMS" },
134 { 164, "LAN100" },
135 { 172, "EISA100BT" },
136 { 173, "BASE100" },
137 { 174, "EISA_FDDI" },
138 { 176, "PCI_FDDI" },
139 { 177, "HSC_FDDI" },
140 { 178, "GSC100BT" },
141 { 179, "PCI100BT" },
142 { 180, "SPP100BT" },
143 { 181, "GLE" },
144 { 182, "FQE" },
145 { 185, "GELAN" },
146 { 187, "PCITR" },
147 { 188, "HP_APA" },
148 { 189, "HP_APAPORT" },
149 { 190, "HP_APALACP" },
150 { 210, "BTLAN" },
151 { 233, "INTL100" },
152 { 244, "NS_LS_IPV6" },
153 { 245, "NS_LS_ICMPV6" },
154 { 246, "DLPI" },
155 { 247, "VLAN" },
156 { 249, "NS_LS_LOOPBACK6" },
157 { 250, "DHCPV6D" },
158 { 252, "IGELAN" },
159 { 253, "IETHER" },
160 { 257, "WBEMProvider-LAN" },
161 { 258, "SYSADMIN" },
162 { 264, "LVMPROVIDER" },
163 { 265, "IXGBE" },
164 { 267, "NS_LS_TELNET" },
165 { 268, "NS_LS_SCTP" },
166 { 269, "HSSN" },
167 { 270, "IGSSN" },
168 { 271, "ICXGBE" },
169 { 275, "IEXGBE" },
170 { 277, "IOCXGBE" },
171 { 278, "IQXGBE" },
172 { 513, "KL_VM" },
173 { 514, "KL_PKM" },
174 { 515, "KL_DLKM" },
175 { 516, "KL_PM" },
176 { 517, "KL_VFS" },
177 { 518, "KL_VXFS" },
178 { 519, "KL_UFS" },
179 { 520, "KL_NFS" },
180 { 521, "KL_FSVM" },
181 { 522, "KL_WSIO" },
182 { 523, "KL_SIO" },
183 { 524, "KL_NET" },
184 { 525, "KL_MC" },
185 { 526, "KL_DYNTUNE" },
186 { 527, "KL_KEN" },
187 { 0, NULL }
189 static value_string_ext subsystem_ext = VALUE_STRING_EXT_INIT(subsystem);
191 /* Code to actually dissect the nettl record headers */
193 static int
194 dissect_nettl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
196 if (tree) {
197 proto_tree *nettl_tree;
198 proto_item *nettl_item;
200 nettl_item = proto_tree_add_protocol_format(tree, proto_nettl, tvb,
201 0, -1, "HP-UX Network Tracing and Logging (nettl) header");
202 nettl_tree = proto_item_add_subtree(nettl_item, ett_nettl);
203 proto_tree_add_uint_format_value(nettl_tree, hf_nettl_subsys, tvb,
204 0, 0, pinfo->pseudo_header->nettl.subsys, "%d (%s)",
205 pinfo->pseudo_header->nettl.subsys,
206 val_to_str_ext_const(pinfo->pseudo_header->nettl.subsys, &subsystem_ext, "Unknown"));
207 proto_tree_add_int(nettl_tree, hf_nettl_devid, tvb,
208 0, 0, pinfo->pseudo_header->nettl.devid);
209 proto_tree_add_uint_format_value(nettl_tree, hf_nettl_kind, tvb,
210 0, 0, pinfo->pseudo_header->nettl.kind,
211 "0x%08x (%s)", pinfo->pseudo_header->nettl.kind,
212 val_to_str_const(pinfo->pseudo_header->nettl.kind & ~NETTL_HDR_SUBSYSTEM_BITS_MASK, trace_kind, "Unknown"));
213 proto_tree_add_int(nettl_tree, hf_nettl_pid, tvb,
214 0, 0, pinfo->pseudo_header->nettl.pid);
215 proto_tree_add_uint(nettl_tree, hf_nettl_uid, tvb,
216 0, 0, pinfo->pseudo_header->nettl.uid);
219 switch (pinfo->rec->rec_header.packet_header.pkt_encap) {
220 case WTAP_ENCAP_NETTL_ETHERNET:
221 call_dissector(eth_withoutfcs_handle, tvb, pinfo, tree);
222 break;
223 case WTAP_ENCAP_NETTL_TOKEN_RING:
224 call_dissector(tr_handle, tvb, pinfo, tree);
225 break;
226 case WTAP_ENCAP_NETTL_FDDI:
227 call_dissector(fddi_bitswapped_handle, tvb, pinfo, tree);
228 break;
229 case WTAP_ENCAP_NETTL_RAW_IP:
230 if ( (pinfo->pseudo_header->nettl.kind & NETTL_HDR_PDU_MASK) == 0 )
231 /* not actually a data packet (PDU) trace record */
232 call_data_dissector(tvb, pinfo, tree);
233 else if (pinfo->pseudo_header->nettl.subsys == NETTL_SUBSYS_NS_LS_SCTP )
234 call_dissector(sctp_handle, tvb, pinfo, tree);
235 else
236 call_dissector(raw_ip_handle, tvb, pinfo, tree);
237 break;
238 case WTAP_ENCAP_NETTL_RAW_ICMP:
239 if (!dissector_try_uint(ip_proto_dissector_table,
240 IP_PROTO_ICMP, tvb, pinfo, tree))
241 call_data_dissector(tvb, pinfo, tree);
242 break;
243 case WTAP_ENCAP_NETTL_RAW_ICMPV6:
244 if (!dissector_try_uint(ip_proto_dissector_table,
245 IP_PROTO_ICMPV6, tvb, pinfo, tree))
246 call_data_dissector(tvb, pinfo, tree);
247 break;
248 case WTAP_ENCAP_NETTL_X25:
249 if (pinfo->pseudo_header->nettl.kind == NETTL_HDR_PDUIN)
250 pinfo->p2p_dir = P2P_DIR_RECV;
251 else if (pinfo->pseudo_header->nettl.kind == NETTL_HDR_PDUOUT)
252 pinfo->p2p_dir = P2P_DIR_SENT;
253 if (pinfo->pseudo_header->nettl.subsys == NETTL_SUBSYS_SX25L2)
254 call_dissector(lapb_handle, tvb, pinfo, tree);
255 else
256 call_dissector(x25_handle, tvb, pinfo, tree);
257 break;
258 case WTAP_ENCAP_NETTL_RAW_TELNET:
259 if (!dissector_try_uint(tcp_subdissector_table,
260 TCP_PORT_TELNET, tvb, pinfo, tree))
261 call_data_dissector(tvb, pinfo, tree);
262 break;
263 default:
264 col_set_str(pinfo->cinfo, COL_PROTOCOL, "UNKNOWN");
265 col_add_fstr(pinfo->cinfo, COL_INFO, "Unsupported nettl subsystem: %d (%s)",
266 pinfo->pseudo_header->nettl.subsys,
267 val_to_str_ext_const(pinfo->pseudo_header->nettl.subsys, &subsystem_ext, "Unknown"));
268 call_data_dissector(tvb, pinfo, tree);
270 return tvb_captured_length(tvb);
274 /* Register the protocol with Wireshark */
276 void
277 proto_register_nettl(void)
279 /* Setup list of header fields */
281 static hf_register_info hf[] = {
283 { &hf_nettl_subsys,
284 { "Subsystem", "nettl.subsys", FT_UINT16, BASE_DEC | BASE_EXT_STRING, &subsystem_ext, 0x0,
285 "HP-UX Subsystem/Driver", HFILL }},
287 { &hf_nettl_devid,
288 { "Device ID", "nettl.devid", FT_INT32, BASE_DEC, NULL, 0x0,
289 "HP-UX Device ID", HFILL }},
291 { &hf_nettl_kind,
292 { "Trace Kind", "nettl.kind", FT_UINT32, BASE_HEX, VALS(trace_kind), 0x0,
293 "HP-UX Trace record kind", HFILL}},
295 { &hf_nettl_pid,
296 { "Process ID (pid/ktid)", "nettl.pid", FT_INT32, BASE_DEC, NULL, 0x0,
297 "HP-UX Process/thread id", HFILL}},
299 { &hf_nettl_uid,
300 { "User ID (uid)", "nettl.uid", FT_UINT32, BASE_DEC, NULL, 0x0,
301 "HP-UX User ID", HFILL}}
305 /* Setup protocol subtree array */
307 static int *ett[] = {
308 &ett_nettl
311 /* Register the protocol name and description */
313 proto_nettl = proto_register_protocol("HP-UX Network Tracing and Logging", "nettl", "nettl");
314 nettl_handle = register_dissector("nettl", dissect_nettl, proto_nettl);
316 /* Required function calls to register the header fields and subtrees used */
318 proto_register_field_array(proto_nettl, hf, array_length(hf));
319 proto_register_subtree_array(ett, array_length(ett));
324 void
325 proto_reg_handoff_nettl(void)
328 * Get handles for various dissectors and dissector tables.
330 eth_withoutfcs_handle = find_dissector_add_dependency("eth_withoutfcs", proto_nettl);
331 tr_handle = find_dissector_add_dependency("tr", proto_nettl);
332 fddi_bitswapped_handle = find_dissector_add_dependency("fddi_bitswapped", proto_nettl);
333 lapb_handle = find_dissector_add_dependency("lapb", proto_nettl);
334 x25_handle = find_dissector_add_dependency("x.25", proto_nettl);
335 sctp_handle = find_dissector_add_dependency("sctp", proto_nettl);
336 raw_ip_handle = find_dissector_add_dependency("raw_ip", proto_nettl);
337 ip_proto_dissector_table = find_dissector_table("ip.proto");
338 tcp_subdissector_table = find_dissector_table("tcp.port");
340 dissector_add_uint("wtap_encap", WTAP_ENCAP_NETTL_ETHERNET, nettl_handle);
341 dissector_add_uint("wtap_encap", WTAP_ENCAP_NETTL_TOKEN_RING, nettl_handle);
342 dissector_add_uint("wtap_encap", WTAP_ENCAP_NETTL_FDDI, nettl_handle);
343 dissector_add_uint("wtap_encap", WTAP_ENCAP_NETTL_RAW_IP, nettl_handle);
344 dissector_add_uint("wtap_encap", WTAP_ENCAP_NETTL_RAW_ICMP, nettl_handle);
345 dissector_add_uint("wtap_encap", WTAP_ENCAP_NETTL_RAW_ICMPV6, nettl_handle);
346 dissector_add_uint("wtap_encap", WTAP_ENCAP_NETTL_RAW_TELNET, nettl_handle);
347 dissector_add_uint("wtap_encap", WTAP_ENCAP_NETTL_X25, nettl_handle);
348 dissector_add_uint("wtap_encap", WTAP_ENCAP_NETTL_UNKNOWN, nettl_handle);
353 * Editor modelines - https://www.wireshark.org/tools/modelines.html
355 * Local variables:
356 * c-basic-offset: 4
357 * tab-width: 8
358 * indent-tabs-mode: nil
359 * End:
361 * vi: set shiftwidth=4 tabstop=8 expandtab:
362 * :indentSize=4:tabSize=8:noTabs=true: