epan/dissectors/pidl/samr/samr.cnf cnf_dissect_lsa_BinaryString => lsarpc_dissect_str...
[wireshark-sm.git] / epan / dissectors / packet-ap1394.c
blobf9a407f6ad61fe480d6efb960d4195f89511b344
1 /* packet-ap1394.c
2 * Routines for Apple IP-over-IEEE 1394 packet disassembly
4 * Wireshark - Network traffic analyzer
5 * By Gerald Combs <gerald@wireshark.org>
6 * Copyright 1998 Gerald Combs
8 * SPDX-License-Identifier: GPL-2.0-or-later
9 */
11 #include "config.h"
13 #include <epan/packet.h>
14 #include <epan/capture_dissectors.h>
15 #include <wsutil/pint.h>
16 #include <epan/addr_resolv.h>
18 #include <epan/etypes.h>
20 void proto_register_ap1394(void);
21 void proto_reg_handoff_ap1394(void);
23 static dissector_handle_t ap1394_handle;
24 static capture_dissector_handle_t ap1394_cap_handle;
26 static int proto_ap1394;
27 static int hf_ap1394_dst;
28 static int hf_ap1394_src;
29 static int hf_ap1394_type;
31 static int ett_ap1394;
33 static dissector_table_t ethertype_subdissector_table;
35 static bool
36 capture_ap1394(const unsigned char *pd, int offset, int len, capture_packet_info_t *cpinfo, const union wtap_pseudo_header *pseudo_header)
38 uint16_t etype;
40 if (!BYTES_ARE_IN_FRAME(offset, len, 18)) {
41 return false;
44 /* Skip destination and source addresses */
45 offset += 16;
47 etype = pntoh16(&pd[offset]);
48 offset += 2;
49 return try_capture_dissector("ethertype", etype, pd, offset, len, cpinfo, pseudo_header);
52 static int
53 dissect_ap1394(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
55 proto_item *ti;
56 proto_tree *fh_tree = NULL;
57 uint16_t etype;
58 tvbuff_t *next_tvb;
60 col_set_str(pinfo->cinfo, COL_PROTOCOL, "IP/IEEE1394");
61 col_clear(pinfo->cinfo, COL_INFO);
63 set_address_tvb(&pinfo->dl_src, AT_EUI64, 8, tvb, 8);
64 copy_address_shallow(&pinfo->src, &pinfo->dl_src);
65 set_address_tvb(&pinfo->dl_dst, AT_EUI64, 8, tvb, 0);
66 copy_address_shallow(&pinfo->dst, &pinfo->dl_dst);
68 if (tree) {
69 ti = proto_tree_add_protocol_format(tree, proto_ap1394, tvb, 0, 18,
70 "Apple IP-over-IEEE 1394, Src: %s, Dst: %s",
71 address_to_str(pinfo->pool, &pinfo->src), address_to_str(pinfo->pool, &pinfo->dst));
72 fh_tree = proto_item_add_subtree(ti, ett_ap1394);
73 proto_tree_add_item(fh_tree, hf_ap1394_dst, tvb, 0, 8, ENC_NA);
74 proto_tree_add_item(fh_tree, hf_ap1394_src, tvb, 8, 8, ENC_NA);
76 etype = tvb_get_ntohs(tvb, 16);
77 proto_tree_add_uint(fh_tree, hf_ap1394_type, tvb, 16, 2, etype);
78 next_tvb = tvb_new_subset_remaining(tvb, 18);
79 if (!dissector_try_uint(ethertype_subdissector_table, etype, next_tvb,
80 pinfo, tree))
82 call_data_dissector(next_tvb, pinfo, tree);
84 return tvb_captured_length(tvb);
87 void
88 proto_register_ap1394(void)
90 static hf_register_info hf[] = {
91 { &hf_ap1394_dst,
92 { "Destination", "ap1394.dst", FT_BYTES, BASE_NONE,
93 NULL, 0x0, "Destination address", HFILL }},
94 { &hf_ap1394_src,
95 { "Source", "ap1394.src", FT_BYTES, BASE_NONE,
96 NULL, 0x0, "Source address", HFILL }},
97 /* registered here but handled in ethertype.c */
98 { &hf_ap1394_type,
99 { "Type", "ap1394.type", FT_UINT16, BASE_HEX,
100 VALS(etype_vals), 0x0, NULL, HFILL }},
102 static int *ett[] = {
103 &ett_ap1394,
106 proto_ap1394 = proto_register_protocol("Apple IP-over-IEEE 1394", "IP/IEEE1394", "ap1394");
107 proto_register_field_array(proto_ap1394, hf, array_length(hf));
108 proto_register_subtree_array(ett, array_length(ett));
110 ap1394_handle = register_dissector("ap1394", dissect_ap1394, proto_ap1394);
111 ap1394_cap_handle = register_capture_dissector("ap1394", capture_ap1394, proto_ap1394);
114 void
115 proto_reg_handoff_ap1394(void)
117 ethertype_subdissector_table = find_dissector_table("ethertype");
119 dissector_add_uint("wtap_encap", WTAP_ENCAP_APPLE_IP_OVER_IEEE1394, ap1394_handle);
121 capture_dissector_add_uint("wtap_encap", WTAP_ENCAP_APPLE_IP_OVER_IEEE1394, ap1394_cap_handle);
125 * Editor modelines - https://www.wireshark.org/tools/modelines.html
127 * Local Variables:
128 * c-basic-offset: 2
129 * tab-width: 8
130 * indent-tabs-mode: nil
131 * End:
133 * ex: set shiftwidth=2 tabstop=8 expandtab:
134 * :indentSize=2:tabSize=8:noTabs=true: