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.
9 * Wireshark - Network traffic analyzer
10 * By Gerald Combs <gerald@wireshark.org>
11 * Copyright 1998 Gerald Combs
13 * Copied from packet-pagp.c
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version 2
18 * of the License, or (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
33 #include <epan/packet.h>
34 #include <epan/ipproto.h>
35 #include <wiretap/nettl.h>
37 /* Initialize the protocol and registered fields */
39 static int proto_nettl
= -1;
41 static int hf_nettl_subsys
= -1;
42 static int hf_nettl_devid
= -1;
43 static int hf_nettl_kind
= -1;
44 static int hf_nettl_pid
= -1;
45 static int hf_nettl_uid
= -1;
47 static dissector_handle_t eth_withoutfcs_handle
;
48 static dissector_handle_t tr_handle
;
49 static dissector_handle_t lapb_handle
;
50 static dissector_handle_t x25_handle
;
51 static dissector_handle_t sctp_handle
;
52 static dissector_handle_t data_handle
;
53 static dissector_table_t wtap_dissector_table
;
54 static dissector_table_t ip_proto_dissector_table
;
55 static dissector_table_t tcp_subdissector_table
;
57 #define TCP_PORT_TELNET 23
59 /* Initialize the subtree pointers */
61 static gint ett_nettl
= -1;
63 /* General declarations and macros */
65 static const value_string trace_kind
[] = {
66 { 0x80000000, "Incoming Header" },
67 { 0x40000000, "Outgoing Header" },
68 { 0x20000000, "Incoming PDU - PDUIN" },
69 { 0x20000000, "PDUIN" },
70 { 0x10000000, "Outgoing PDU - PDUOUT" },
71 { 0x10000000, "PDUOUT" },
72 { 0x08000000, "Procedure Trace" },
73 { 0x04000000, "State Trace" },
74 { 0x02000000, "Error Trace" },
75 { 0x01000000, "Logging" },
76 { 0x00800000, "Loopback" },
80 static const value_string subsystem
[] = {
81 { 0, "NS_LS_LOGGING" },
83 { 2, "NS_LS_LOOPBACK" },
86 { 5, "NS_LS_SOCKREGD" },
91 { 10, "NS_LS_PROBE" },
92 { 11, "NS_LS_DRIVER" },
95 { 14, "NS_LS_CASE21" },
96 { 15, "NS_LS_ROUTER21" },
98 { 17, "NS_LS_NETISR" },
101 { 20, "NS_LS_STRLOG" },
102 { 21, "NS_LS_TIRDWR" },
103 { 22, "NS_LS_TIMOD" },
104 { 23, "NS_LS_ICMP" },
110 { 29, "NS_LS_IGMP" },
116 { 36, "NS_LS_SX25" },
120 { 40, "TELECOM_HLR" },
121 { 41, "TELECOM_SCE" },
122 { 42, "TELECOM_SMS" },
123 { 43, "TELECOM_NEM" },
126 { 62, "TELECOM_SCP" },
127 { 63, "TELECOM_SS7" },
133 { 84, "OVEXTERNAL" },
135 { 91, "OTS9000-NETWORK" },
136 { 92, "OTS9000-TRANSPORT" },
137 { 93, "OTS9000-SESSION" },
138 { 94, "OTS9000-ACSE_PRES" },
144 { 123, "ULA_UTILS" },
148 { 172, "EISA100BT" },
150 { 174, "EISA_FDDI" },
161 { 189, "HP_APAPORT" },
162 { 190, "HP_APALACP" },
165 { 244, "NS_LS_IPV6" },
166 { 245, "NS_LS_ICMPV6" },
169 { 249, "NS_LS_LOOPBACK6" },
173 { 257, "WBEMProvider-LAN" },
175 { 264, "LVMPROVIDER" },
177 { 267, "NS_LS_TELNET" },
178 { 268, "NS_LS_SCTP" },
198 { 526, "KL_DYNTUNE" },
204 /* Code to actually dissect the nettl record headers */
207 dissect_nettl(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
209 proto_tree
*nettl_tree
;
210 proto_item
*nettl_item
;
212 pinfo
->current_proto
= "nettl";
215 nettl_item
= proto_tree_add_protocol_format(tree
, proto_nettl
, tvb
,
216 0, -1, "HP-UX Network Tracing and Logging (nettl) header");
217 nettl_tree
= proto_item_add_subtree(nettl_item
, ett_nettl
);
218 proto_tree_add_uint_format_value(nettl_tree
, hf_nettl_subsys
, tvb
,
219 0, 0, pinfo
->pseudo_header
->nettl
.subsys
, "%d (%s)", pinfo
->pseudo_header
->nettl
.subsys
,
220 val_to_str_const(pinfo
->pseudo_header
->nettl
.subsys
, subsystem
, "Unknown"));
221 proto_tree_add_int(nettl_tree
, hf_nettl_devid
, tvb
,
222 0, 0, pinfo
->pseudo_header
->nettl
.devid
);
223 proto_tree_add_uint_format_value(nettl_tree
, hf_nettl_kind
, tvb
,
224 0, 0, pinfo
->pseudo_header
->nettl
.kind
,
225 "0x%08x (%s)", pinfo
->pseudo_header
->nettl
.kind
,
226 val_to_str_const(pinfo
->pseudo_header
->nettl
.kind
& ~NETTL_HDR_SUBSYSTEM_BITS_MASK
, trace_kind
, "Unknown"));
227 proto_tree_add_int(nettl_tree
, hf_nettl_pid
, tvb
,
228 0, 0, pinfo
->pseudo_header
->nettl
.pid
);
229 proto_tree_add_uint(nettl_tree
, hf_nettl_uid
, tvb
,
230 0, 0, pinfo
->pseudo_header
->nettl
.uid
);
233 switch (pinfo
->fd
->lnk_t
) {
234 case WTAP_ENCAP_NETTL_ETHERNET
:
235 call_dissector(eth_withoutfcs_handle
, tvb
, pinfo
, tree
);
237 case WTAP_ENCAP_NETTL_TOKEN_RING
:
238 call_dissector(tr_handle
, tvb
, pinfo
, tree
);
240 case WTAP_ENCAP_NETTL_FDDI
:
241 if (!dissector_try_uint(wtap_dissector_table
,
242 WTAP_ENCAP_FDDI_BITSWAPPED
, tvb
, pinfo
, tree
))
243 call_dissector(data_handle
, tvb
, pinfo
, tree
);
245 case WTAP_ENCAP_NETTL_RAW_IP
:
246 if ( (pinfo
->pseudo_header
->nettl
.kind
& NETTL_HDR_PDU_MASK
) == 0 )
247 /* not actually a data packet (PDU) trace record */
248 call_dissector(data_handle
, tvb
, pinfo
, tree
);
249 else if (pinfo
->pseudo_header
->nettl
.subsys
== NETTL_SUBSYS_NS_LS_SCTP
)
250 call_dissector(sctp_handle
, tvb
, pinfo
, tree
);
251 else if (!dissector_try_uint(wtap_dissector_table
,
252 WTAP_ENCAP_RAW_IP
, tvb
, pinfo
, tree
))
253 call_dissector(data_handle
, tvb
, pinfo
, tree
);
255 case WTAP_ENCAP_NETTL_RAW_ICMP
:
256 if (!dissector_try_uint(ip_proto_dissector_table
,
257 IP_PROTO_ICMP
, tvb
, pinfo
, tree
))
258 call_dissector(data_handle
, tvb
, pinfo
, tree
);
260 case WTAP_ENCAP_NETTL_RAW_ICMPV6
:
261 if (!dissector_try_uint(ip_proto_dissector_table
,
262 IP_PROTO_ICMPV6
, tvb
, pinfo
, tree
))
263 call_dissector(data_handle
, tvb
, pinfo
, tree
);
265 case WTAP_ENCAP_NETTL_X25
:
266 if (pinfo
->pseudo_header
->nettl
.kind
== NETTL_HDR_PDUIN
)
267 pinfo
->p2p_dir
= P2P_DIR_RECV
;
268 else if (pinfo
->pseudo_header
->nettl
.kind
== NETTL_HDR_PDUOUT
)
269 pinfo
->p2p_dir
= P2P_DIR_SENT
;
270 if (pinfo
->pseudo_header
->nettl
.subsys
== NETTL_SUBSYS_SX25L2
)
271 call_dissector(lapb_handle
, tvb
, pinfo
, tree
);
273 call_dissector(x25_handle
, tvb
, pinfo
, tree
);
275 case WTAP_ENCAP_NETTL_RAW_TELNET
:
276 if (!dissector_try_uint(tcp_subdissector_table
,
277 TCP_PORT_TELNET
, tvb
, pinfo
, tree
))
278 call_dissector(data_handle
, tvb
, pinfo
, tree
);
281 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "UNKNOWN");
282 col_add_fstr(pinfo
->cinfo
, COL_INFO
, "Unsupported nettl subsytem: %d (%s)",
283 pinfo
->pseudo_header
->nettl
.subsys
,
284 val_to_str_const(pinfo
->pseudo_header
->nettl
.subsys
, subsystem
, "Unknown"));
285 call_dissector(data_handle
, tvb
, pinfo
, tree
);
290 /* Register the protocol with Wireshark */
293 proto_register_nettl(void)
295 /* Setup list of header fields */
297 static hf_register_info hf
[] = {
300 { "Subsystem", "nettl.subsys", FT_UINT16
, BASE_DEC
, VALS(subsystem
), 0x0,
301 "HP-UX Subsystem/Driver", HFILL
}},
304 { "Device ID", "nettl.devid", FT_INT32
, BASE_DEC
, NULL
, 0x0,
305 "HP-UX Device ID", HFILL
}},
308 { "Trace Kind", "nettl.kind", FT_UINT32
, BASE_HEX
, VALS(trace_kind
), 0x0,
309 "HP-UX Trace record kind", HFILL
}},
312 { "Process ID (pid/ktid)", "nettl.pid", FT_INT32
, BASE_DEC
, NULL
, 0x0,
313 "HP-UX Process/thread id", HFILL
}},
316 { "User ID (uid)", "nettl.uid", FT_UINT16
, BASE_DEC
, NULL
, 0x0,
317 "HP-UX User ID", HFILL
}}
321 /* Setup protocol subtree array */
323 static gint
*ett
[] = {
327 /* Register the protocol name and description */
329 proto_nettl
= proto_register_protocol("HP-UX Network Tracing and Logging", "nettl", "nettl");
331 /* Required function calls to register the header fields and subtrees used */
333 proto_register_field_array(proto_nettl
, hf
, array_length(hf
));
334 proto_register_subtree_array(ett
, array_length(ett
));
340 proto_reg_handoff_nettl(void)
342 dissector_handle_t nettl_handle
;
345 * Get handles for the Ethernet, Token Ring, FDDI, and RAW dissectors.
347 eth_withoutfcs_handle
= find_dissector("eth_withoutfcs");
348 tr_handle
= find_dissector("tr");
349 lapb_handle
= find_dissector("lapb");
350 x25_handle
= find_dissector("x.25");
351 sctp_handle
= find_dissector("sctp");
352 data_handle
= find_dissector("data");
353 wtap_dissector_table
= find_dissector_table("wtap_encap");
354 ip_proto_dissector_table
= find_dissector_table("ip.proto");
355 tcp_subdissector_table
= find_dissector_table("tcp.port");
357 nettl_handle
= create_dissector_handle(dissect_nettl
, proto_nettl
);
358 dissector_add_uint("wtap_encap", WTAP_ENCAP_NETTL_ETHERNET
, nettl_handle
);
359 dissector_add_uint("wtap_encap", WTAP_ENCAP_NETTL_TOKEN_RING
, nettl_handle
);
360 dissector_add_uint("wtap_encap", WTAP_ENCAP_NETTL_FDDI
, nettl_handle
);
361 dissector_add_uint("wtap_encap", WTAP_ENCAP_NETTL_RAW_IP
, nettl_handle
);
362 dissector_add_uint("wtap_encap", WTAP_ENCAP_NETTL_RAW_ICMP
, nettl_handle
);
363 dissector_add_uint("wtap_encap", WTAP_ENCAP_NETTL_RAW_ICMPV6
, nettl_handle
);
364 dissector_add_uint("wtap_encap", WTAP_ENCAP_NETTL_RAW_TELNET
, nettl_handle
);
365 dissector_add_uint("wtap_encap", WTAP_ENCAP_NETTL_X25
, nettl_handle
);
366 dissector_add_uint("wtap_encap", WTAP_ENCAP_NETTL_UNKNOWN
, nettl_handle
);