dcerpc-netlogon: split out find_tmp_netlogon_auth_vars()
[wireshark-sm.git] / wiretap / tnef.c
blobaf418083296cb819ed41c9798b87c54b130a08c0
1 /* tnef.c
3 * Transport-Neutral Encapsulation Format (TNEF) file reading
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 */
8 #include "config.h"
9 #include "tnef.h"
11 #include "wtap-int.h"
12 #include "file_wrappers.h"
13 #include <wsutil/buffer.h>
15 static int tnef_file_type_subtype = -1;
17 void register_tnef(void);
19 wtap_open_return_val tnef_open(wtap *wth, int *err, char **err_info)
21 uint32_t magic;
23 if (!wtap_read_bytes(wth->fh, &magic, sizeof magic, err, err_info))
24 return (*err != WTAP_ERR_SHORT_READ) ? WTAP_OPEN_ERROR : WTAP_OPEN_NOT_MINE;
26 if (GUINT32_TO_LE(magic) != TNEF_SIGNATURE)
27 /* Not a tnef file */
28 return WTAP_OPEN_NOT_MINE;
30 /* seek back to the start of the file */
31 if (file_seek(wth->fh, 0, SEEK_SET, err) == -1)
32 return WTAP_OPEN_ERROR;
34 wth->file_type_subtype = tnef_file_type_subtype;
35 wth->file_encap = WTAP_ENCAP_TNEF;
36 wth->snapshot_length = 0;
38 wth->subtype_read = wtap_full_file_read;
39 wth->subtype_seek_read = wtap_full_file_seek_read;
40 wth->file_tsprec = WTAP_TSPREC_SEC;
42 return WTAP_OPEN_MINE;
45 static const struct supported_block_type tnef_blocks_supported[] = {
47 * This is a file format that we dissect, so we provide only one
48 * "packet" with the file's contents, and don't support any
49 * options.
51 { WTAP_BLOCK_PACKET, ONE_BLOCK_SUPPORTED, NO_OPTIONS_SUPPORTED }
54 static const struct file_type_subtype_info tnef_info = {
55 "Transport-Neutral Encapsulation Format", "tnef", NULL, NULL,
56 false, BLOCKS_SUPPORTED(tnef_blocks_supported),
57 NULL, NULL, NULL
60 void register_tnef(void)
62 tnef_file_type_subtype = wtap_register_file_type_subtype(&tnef_info);
65 * Register name for backwards compatibility with the
66 * wtap_filetypes table in Lua.
68 wtap_register_backwards_compatibility_lua_name("TNEF",
69 tnef_file_type_subtype);
73 * Editor modelines - https://www.wireshark.org/tools/modelines.html
75 * Local Variables:
76 * c-basic-offset: 2
77 * tab-width: 8
78 * indent-tabs-mode: nil
79 * End:
81 * vi: set shiftwidth=2 tabstop=8 expandtab:
82 * :indentSize=2:tabSize=8:noTabs=true: