2 * Routines for Apple IP-over-IEEE 1394 packet disassembly
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1998 Gerald Combs
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 #include <epan/packet.h>
29 #include <wsutil/pint.h>
30 #include <epan/addr_resolv.h>
31 #include <epan/strutil.h>
33 #include "packet-ap1394.h"
34 #include <epan/etypes.h>
36 void proto_register_ap1394(void);
37 void proto_reg_handoff_ap1394(void);
39 static int proto_ap1394
= -1;
40 static int hf_ap1394_dst
= -1;
41 static int hf_ap1394_src
= -1;
42 static int hf_ap1394_type
= -1;
44 static gint ett_ap1394
= -1;
46 static dissector_table_t ethertype_subdissector_table
;
48 static dissector_handle_t data_handle
;
51 capture_ap1394(const guchar
*pd
, int offset
, int len
, packet_counts
*ld
)
55 if (!BYTES_ARE_IN_FRAME(offset
, len
, 18)) {
60 /* Skip destination and source addresses */
63 etype
= pntohs(&pd
[offset
]);
65 capture_ethertype(etype
, pd
, offset
, len
, ld
);
69 dissect_ap1394(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
)
72 proto_tree
*fh_tree
= NULL
;
73 const guint8
*src_addr
, *dst_addr
;
77 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, "IP/IEEE1394");
78 col_clear(pinfo
->cinfo
, COL_INFO
);
80 src_addr
=tvb_get_ptr(tvb
, 8, 8);
81 SET_ADDRESS(&pinfo
->dl_src
, AT_EUI64
, 8, src_addr
);
82 SET_ADDRESS(&pinfo
->src
, AT_EUI64
, 8, src_addr
);
83 dst_addr
=tvb_get_ptr(tvb
, 0, 8);
84 SET_ADDRESS(&pinfo
->dl_dst
, AT_EUI64
, 8, dst_addr
);
85 SET_ADDRESS(&pinfo
->dst
, AT_EUI64
, 8, dst_addr
);
88 ti
= proto_tree_add_protocol_format(tree
, proto_ap1394
, tvb
, 0, 18,
89 "Apple IP-over-IEEE 1394, Src: %s, Dst: %s",
90 bytes_to_str(src_addr
, 8), bytes_to_str(dst_addr
, 8));
91 fh_tree
= proto_item_add_subtree(ti
, ett_ap1394
);
92 proto_tree_add_bytes(fh_tree
, hf_ap1394_dst
, tvb
, 0, 8, dst_addr
);
93 proto_tree_add_bytes(fh_tree
, hf_ap1394_src
, tvb
, 8, 8, src_addr
);
95 etype
= tvb_get_ntohs(tvb
, 16);
97 proto_tree_add_uint(fh_tree
, hf_ap1394_type
, tvb
, 16, 2, etype
);
98 next_tvb
= tvb_new_subset_remaining(tvb
, 18);
99 if (!dissector_try_uint(ethertype_subdissector_table
, etype
, next_tvb
,
101 call_dissector(data_handle
, next_tvb
, pinfo
, tree
);
105 proto_register_ap1394(void)
107 static hf_register_info hf
[] = {
109 { "Destination", "ap1394.dst", FT_BYTES
, BASE_NONE
,
110 NULL
, 0x0, "Destination address", HFILL
}},
112 { "Source", "ap1394.src", FT_BYTES
, BASE_NONE
,
113 NULL
, 0x0, "Source address", HFILL
}},
114 /* registered here but handled in ethertype.c */
116 { "Type", "ap1394.type", FT_UINT16
, BASE_HEX
,
117 VALS(etype_vals
), 0x0, NULL
, HFILL
}},
119 static gint
*ett
[] = {
123 proto_ap1394
= proto_register_protocol("Apple IP-over-IEEE 1394", "IP/IEEE1394", "ap1394");
124 proto_register_field_array(proto_ap1394
, hf
, array_length(hf
));
125 proto_register_subtree_array(ett
, array_length(ett
));
129 proto_reg_handoff_ap1394(void)
131 dissector_handle_t ap1394_handle
;
133 data_handle
= find_dissector("data");
135 ethertype_subdissector_table
= find_dissector_table("ethertype");
137 ap1394_handle
= create_dissector_handle(dissect_ap1394
, proto_ap1394
);
138 dissector_add_uint("wtap_encap", WTAP_ENCAP_APPLE_IP_OVER_IEEE1394
, ap1394_handle
);