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
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 */
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" },
67 static const value_string subsystem
[] = {
68 { 0, "NS_LS_LOGGING" },
70 { 2, "NS_LS_LOOPBACK" },
73 { 5, "NS_LS_SOCKREGD" },
78 { 10, "NS_LS_PROBE" },
79 { 11, "NS_LS_DRIVER" },
82 { 14, "NS_LS_CASE21" },
83 { 15, "NS_LS_ROUTER21" },
85 { 17, "NS_LS_NETISR" },
88 { 20, "NS_LS_STRLOG" },
89 { 21, "NS_LS_TIRDWR" },
90 { 22, "NS_LS_TIMOD" },
103 { 36, "NS_LS_SX25" },
107 { 40, "TELECOM_HLR" },
108 { 41, "TELECOM_SCE" },
109 { 42, "TELECOM_SMS" },
110 { 43, "TELECOM_NEM" },
113 { 62, "TELECOM_SCP" },
114 { 63, "TELECOM_SS7" },
120 { 84, "OVEXTERNAL" },
122 { 91, "OTS9000-NETWORK" },
123 { 92, "OTS9000-TRANSPORT" },
124 { 93, "OTS9000-SESSION" },
125 { 94, "OTS9000-ACSE_PRES" },
131 { 123, "ULA_UTILS" },
135 { 172, "EISA100BT" },
137 { 174, "EISA_FDDI" },
148 { 189, "HP_APAPORT" },
149 { 190, "HP_APALACP" },
152 { 244, "NS_LS_IPV6" },
153 { 245, "NS_LS_ICMPV6" },
156 { 249, "NS_LS_LOOPBACK6" },
160 { 257, "WBEMProvider-LAN" },
162 { 264, "LVMPROVIDER" },
164 { 267, "NS_LS_TELNET" },
165 { 268, "NS_LS_SCTP" },
185 { 526, "KL_DYNTUNE" },
189 static value_string_ext subsystem_ext
= VALUE_STRING_EXT_INIT(subsystem
);
191 /* Code to actually dissect the nettl record headers */
194 dissect_nettl(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
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
);
223 case WTAP_ENCAP_NETTL_TOKEN_RING
:
224 call_dissector(tr_handle
, tvb
, pinfo
, tree
);
226 case WTAP_ENCAP_NETTL_FDDI
:
227 call_dissector(fddi_bitswapped_handle
, tvb
, pinfo
, tree
);
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
);
236 call_dissector(raw_ip_handle
, tvb
, pinfo
, tree
);
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
);
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
);
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
);
256 call_dissector(x25_handle
, tvb
, pinfo
, tree
);
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
);
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 */
277 proto_register_nettl(void)
279 /* Setup list of header fields */
281 static hf_register_info hf
[] = {
284 { "Subsystem", "nettl.subsys", FT_UINT16
, BASE_DEC
| BASE_EXT_STRING
, &subsystem_ext
, 0x0,
285 "HP-UX Subsystem/Driver", HFILL
}},
288 { "Device ID", "nettl.devid", FT_INT32
, BASE_DEC
, NULL
, 0x0,
289 "HP-UX Device ID", HFILL
}},
292 { "Trace Kind", "nettl.kind", FT_UINT32
, BASE_HEX
, VALS(trace_kind
), 0x0,
293 "HP-UX Trace record kind", HFILL
}},
296 { "Process ID (pid/ktid)", "nettl.pid", FT_INT32
, BASE_DEC
, NULL
, 0x0,
297 "HP-UX Process/thread id", HFILL
}},
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
[] = {
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
));
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
358 * indent-tabs-mode: nil
361 * vi: set shiftwidth=4 tabstop=8 expandtab:
362 * :indentSize=4:tabSize=8:noTabs=true: