3 * Transport-Neutral Encapsulation Format (TNEF) file reading
5 * SPDX-License-Identifier: GPL-2.0-or-later
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
)
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
)
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
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
),
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
78 * indent-tabs-mode: nil
81 * vi: set shiftwidth=2 tabstop=8 expandtab:
82 * :indentSize=2:tabSize=8:noTabs=true: