checkAPIs.pl: support for new-style dissectors in check_hf_entries
[metze/wireshark/wip.git] / epan / dissectors / packet-mime-encap.c
1 /* packet-mime-encap.c
2  *
3  * Wireshark - Network traffic analyzer
4  * By Gerald Combs <gerald@wireshark.org>
5  * Copyright 1998
6  *
7  * SPDX-License-Identifier: GPL-2.0-or-later
8  */
9
10 #include "config.h"
11
12 #include <epan/packet.h>
13
14 #include <wiretap/wtap.h>
15
16 void proto_register_mime_encap(void);
17 void proto_reg_handoff_mime_encap(void);
18
19 static int proto_mime_encap = -1;
20
21 static dissector_handle_t mime_encap_handle;
22
23 static heur_dissector_list_t heur_subdissector_list;
24
25 static int
26 dissect_mime_encap(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
27 {
28         proto_item* item;
29         heur_dtbl_entry_t *hdtbl_entry;
30
31         /* XXX, COL_INFO */
32
33         col_set_str(pinfo->cinfo, COL_PROTOCOL, "MIME_FILE");
34         item = proto_tree_add_item(tree, proto_mime_encap, tvb, 0, -1, ENC_NA);
35
36         if (!dissector_try_heuristic(heur_subdissector_list, tvb, pinfo, tree, &hdtbl_entry, NULL)) {
37                 proto_item_append_text(item, " (Unhandled)");
38                 call_data_dissector(tvb, pinfo, tree);
39         }
40         return tvb_captured_length(tvb);
41 }
42
43 void
44 proto_register_mime_encap(void)
45 {
46         proto_mime_encap = proto_register_protocol("MIME file", "MIME_FILE", "mime_dlt");
47
48         mime_encap_handle = register_dissector("mime_dlt", dissect_mime_encap, proto_mime_encap);
49         heur_subdissector_list = register_heur_dissector_list("wtap_file", proto_mime_encap);
50 }
51
52 void
53 proto_reg_handoff_mime_encap(void)
54 {
55         dissector_add_uint("wtap_encap", WTAP_ENCAP_MIME, mime_encap_handle);
56 }
57
58 /*
59  * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
60  *
61  * Local variables:
62  * c-basic-offset: 8
63  * tab-width: 8
64  * indent-tabs-mode: t
65  * End:
66  *
67  * vi: set shiftwidth=8 tabstop=8 noexpandtab:
68  * :indentSize=8:tabSize=8:noTabs=false:
69  */