2 * Routines for Transport-Neutral Encapsulation Format (TNEF) packet disassembly
4 * Copyright (c) 2007 by Graeme Lunt
6 * Wireshark - Network traffic analyzer
7 * By Gerald Combs <gerald@wireshark.org>
8 * Copyright 1999 Gerald Combs
10 * SPDX-License-Identifier: GPL-2.0-or-later
15 #include <epan/packet.h>
16 #include <epan/expert.h>
18 #include <wiretap/tnef.h>
20 #include "packet-dcerpc.h"
21 #include "packet-dcerpc-nspi.h"
22 #include "packet-ber.h"
24 #define PNAME "Transport-Neutral Encapsulation Format"
28 #define ATP_TRIPLES (0x0000)
29 #define ATP_STRING (0x0001)
30 #define ATP_TEXT (0x0002)
31 #define ATP_DATE (0x0003)
32 #define ATP_SHORT (0x0004)
33 #define ATP_LONG (0x0005)
34 #define ATP_BYTE (0x0006)
35 #define ATP_WORD (0x0007)
36 #define ATP_DWORD (0x0008)
37 #define ATP_MAX (0x0009)
39 #define ATT_OWNER (0x00060000) /* handled */
40 #define ATT_SENT_FOR (0x00060001) /* handled */
41 #define ATT_DELEGATE (0x00060002)
42 #define ATT_DATE_START (0x00030006) /* handled */
43 #define ATT_DATE_END (0x00030007) /* handled */
44 #define ATT_AID_OWNER (0x00040008)
45 #define ATT_REQUEST_RES (0x00040009)
47 #define ATT_FROM (0x00008000)
48 #define ATT_SUBJECT (0x00018004)
49 #define ATT_DATE_SENT (0x00038005) /* handled */
50 #define ATT_DATE_RECD (0x00038006) /* handled */
51 #define ATT_MESSAGE_STATUS (0x00068007)
52 #define ATT_MESSAGE_CLASS (0x00078008) /* handled */
53 #define ATT_MESSAGE_ID (0x00018009)
54 #define ATT_PARENT_ID (0x0001800A) /* handled */
55 #define ATT_CONVERSATION_ID (0x0001800B) /* handled */
56 #define ATT_BODY (0x0002800C)
57 #define ATT_PRIORITY (0x0004800D) /* handled */
58 #define ATT_ATTACH_DATA (0x0006800F)
59 #define ATT_ATTACH_TITLE (0x00018010) /* handled */
60 #define ATT_ATTACH_META_FILE (0x00068011)
61 #define ATT_ATTACH_CREATE_DATE (0x00038012) /* handled */
62 #define ATT_ATTACH_MODIFY_DATE (0x00038013) /* handled */
63 #define ATT_DATE_MODIFIED (0x00038020) /* handled */
65 #define ATT_ATTACH_TRANSPORT_FILENAME (0x00069001)
66 #define ATT_ATTACH_REND_DATA (0x00069002)
67 #define ATT_MAPI_PROPS (0x00069003) /* handled */
68 #define ATT_RECIP_TABLE (0x00069004)
69 #define ATT_ATTACHMENT (0x00069005)
70 #define ATT_TNEF_VERSION (0x00089006) /* handled */
71 #define ATT_OEM_CODEPAGE (0x00069007) /* handled */
72 #define ATT_ORIGINAL_MESSAGE_CLASS (0x00079008) /* handled */
74 void proto_register_tnef(void);
75 void proto_reg_handoff_tnef(void);
77 static int proto_tnef
;
79 static int hf_tnef_signature
;
80 static int hf_tnef_key
;
81 static int hf_tnef_attribute
;
82 static int hf_tnef_attribute_lvl
;
83 static int hf_tnef_attribute_tag
;
84 static int hf_tnef_attribute_tag_type
;
85 static int hf_tnef_attribute_tag_id
;
86 static int hf_tnef_attribute_length
;
87 static int hf_tnef_attribute_value
;
88 static int hf_tnef_attribute_string
;
89 static int hf_tnef_attribute_date
;
90 static int hf_tnef_attribute_display_name
;
91 static int hf_tnef_attribute_email_address
;
92 static int hf_tnef_attribute_checksum
;
93 static int hf_tnef_mapi_props
;
94 static int hf_tnef_oem_codepage
;
95 static int hf_tnef_version
;
96 static int hf_tnef_message_class
;
97 static int hf_tnef_original_message_class
;
98 static int hf_tnef_priority
;
99 static int hf_tnef_mapi_props_count
;
101 static int hf_tnef_property
;
102 static int hf_tnef_property_tag
;
103 static int hf_tnef_property_tag_type
;
104 static int hf_tnef_property_tag_id
;
105 static int hf_tnef_property_tag_set
;
106 static int hf_tnef_property_tag_kind
;
107 static int hf_tnef_property_tag_name_id
;
108 static int hf_tnef_property_tag_name_length
;
109 static int hf_tnef_property_tag_name_string
;
110 static int hf_tnef_property_padding
;
111 static int hf_tnef_padding
;
113 static int hf_tnef_values_count
;
114 static int hf_tnef_value_length
;
116 static int hf_tnef_attribute_date_year
;
117 static int hf_tnef_attribute_date_month
;
118 static int hf_tnef_attribute_date_day
;
119 static int hf_tnef_attribute_date_hour
;
120 static int hf_tnef_attribute_date_minute
;
121 static int hf_tnef_attribute_date_second
;
122 static int hf_tnef_attribute_date_day_of_week
;
124 static int hf_tnef_PropValue_i
;
125 static int hf_tnef_PropValue_l
;
126 static int hf_tnef_PropValue_b
;
127 static int hf_tnef_PropValue_lpszA
;
128 static int hf_tnef_PropValue_lpszW
;
129 static int hf_tnef_PropValue_lpguid
;
130 static int hf_tnef_PropValue_bin
;
131 static int hf_tnef_PropValue_ft
;
132 static int hf_tnef_PropValue_err
;
133 static int hf_tnef_PropValue_MVi
;
134 static int hf_tnef_PropValue_MVl
;
135 static int hf_tnef_PropValue_MVszA
;
136 static int hf_tnef_PropValue_MVbin
;
137 static int hf_tnef_PropValue_MVguid
;
138 static int hf_tnef_PropValue_MVszW
;
139 static int hf_tnef_PropValue_MVft
;
140 static int hf_tnef_PropValue_null
;
141 static int hf_tnef_PropValue_object
;
144 static int ett_tnef_attribute
;
145 static int ett_tnef_attribute_tag
;
146 static int ett_tnef_mapi_props
;
147 static int ett_tnef_property
;
148 static int ett_tnef_property_tag
;
149 static int ett_tnef_counted_items
;
150 static int ett_tnef_attribute_date
;
151 static int ett_tnef_attribute_address
;
153 static expert_field ei_tnef_expect_single_item
;
154 static expert_field ei_tnef_incorrect_signature
;
156 static dissector_handle_t tnef_handle
;
158 static const value_string tnef_Lvl_vals
[] = {
159 { 1, "LVL-MESSAGE" },
160 { 2, "LVL-ATTACHMENT" },
164 static const value_string tnef_Priority_vals
[] = {
171 static const value_string tnef_Types_vals
[] = {
172 { ATP_TRIPLES
, "Triples" },
173 { ATP_STRING
, "String"},
174 { ATP_TEXT
, "Text" },
176 { ATP_SHORT
, "Short"},
180 { ATP_DWORD
, "DWord"},
185 static const value_string weekday_vals
[] = {
196 static const value_string tnef_Attribute_vals
[] = {
197 { ATT_OWNER
, "ATT_OWNER" },
198 { ATT_SENT_FOR
, "ATT_SENT_FOR" },
199 { ATT_DELEGATE
, "ATT_DELEGATE" },
200 { ATT_OWNER
, "ATT_OWNER" },
201 { ATT_DATE_START
, "ATT_DATE_START" },
202 { ATT_DATE_END
, "ATT_DATE_END" },
203 { ATT_AID_OWNER
, "ATT_AID_OWNER" },
204 { ATT_REQUEST_RES
, "ATT_REQUEST_RES" },
205 { ATT_FROM
, "ATT_FROM" },
206 { ATT_SUBJECT
, "ATT_SUBJECT" },
207 { ATT_DATE_SENT
, "ATT_DATE_SENT" },
208 { ATT_DATE_RECD
, "ATT_DATE_RECD" },
209 { ATT_MESSAGE_STATUS
, "ATT_MESSAGE_STATUS" },
210 { ATT_MESSAGE_CLASS
, "ATT_MESSAGE_CLASS" },
211 { ATT_MESSAGE_ID
, "ATT_MESSAGE_ID" },
212 { ATT_PARENT_ID
, "ATT_PARENT_ID" },
213 { ATT_CONVERSATION_ID
, "ATT_CONVERSATION_ID" },
214 { ATT_BODY
, "ATT_BODY" },
215 { ATT_PRIORITY
, "ATT_PRIORITY" },
216 { ATT_ATTACH_DATA
, "ATT_ATTACH_DATA" },
217 { ATT_ATTACH_TITLE
, "ATT_ATTACH_TITLE" },
218 { ATT_ATTACH_META_FILE
, "ATT_ATTACH_META_FILE" },
219 { ATT_ATTACH_CREATE_DATE
, "ATT_ATTACH_CREATE_DATE" },
220 { ATT_ATTACH_MODIFY_DATE
, "ATT_ATTACH_MODIFY_DATE" },
221 { ATT_DATE_MODIFIED
, "ATT_DATE_MODIFIED" },
222 { ATT_ATTACH_TRANSPORT_FILENAME
, "ATT_ATTACH_TRANSPORT_FILENAME" },
223 { ATT_ATTACH_REND_DATA
, "ATT_ATTACH_REND_DATA" },
224 { ATT_MAPI_PROPS
, "ATT_MAPI_PROPS" },
225 { ATT_RECIP_TABLE
, "ATT_RECIP_TABLE" },
226 { ATT_ATTACHMENT
, "ATT_ATTACHMENT" },
227 { ATT_TNEF_VERSION
, "ATT_TNEF_VERSION" },
228 { ATT_OEM_CODEPAGE
, "ATT_OEM_CODEPAGE" },
229 { ATT_ORIGINAL_MESSAGE_CLASS
, "ATT_ORIGINAL_MESSAGE_CLASS" },
233 static int dissect_counted_values(tvbuff_t
*tvb
, int offset
, int hf_id
, packet_info
*pinfo
, proto_tree
*tree
, bool single
, unsigned encoding
)
236 uint32_t length
, count
, i
;
238 count
= tvb_get_letohl(tvb
, offset
);
239 proto_tree_add_item(tree
, hf_tnef_values_count
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
243 item
= proto_tree_add_expert_format(tree
, pinfo
, &ei_tnef_expect_single_item
, tvb
, offset
, 4,
244 "Expecting a single item but found %d", count
);
245 tree
= proto_item_add_subtree(item
, ett_tnef_counted_items
);
251 for(i
= 0; i
< count
; i
++) {
253 length
= tvb_get_letohl(tvb
, offset
);
254 proto_tree_add_item(tree
, hf_tnef_value_length
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
257 proto_tree_add_item(tree
, hf_id
, tvb
, offset
, length
, encoding
);
260 /* XXX: may be padding ? */
267 static int dissect_counted_address(tvbuff_t
*tvb
, int offset
, packet_info
*pinfo _U_
, proto_tree
*tree
)
271 length
= tvb_get_letohs(tvb
, offset
);
272 proto_tree_add_item(tree
, hf_tnef_value_length
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
275 proto_tree_add_item(tree
, hf_tnef_attribute_display_name
, tvb
, offset
, length
, ENC_ASCII
);
278 length
= tvb_get_letohs(tvb
, offset
);
279 proto_tree_add_item(tree
, hf_tnef_value_length
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
282 proto_tree_add_item(tree
, hf_tnef_attribute_email_address
, tvb
, offset
, length
, ENC_ASCII
);
289 static void dissect_DTR(tvbuff_t
*tvb
, packet_info
*pinfo _U_
, proto_tree
*tree
)
295 proto_tree_add_item(tree
, hf_tnef_attribute_date_year
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
298 proto_tree_add_item(tree
, hf_tnef_attribute_date_month
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
301 proto_tree_add_item(tree
, hf_tnef_attribute_date_day
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
304 proto_tree_add_item(tree
, hf_tnef_attribute_date_hour
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
307 proto_tree_add_item(tree
, hf_tnef_attribute_date_minute
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
310 proto_tree_add_item(tree
, hf_tnef_attribute_date_second
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
313 proto_tree_add_item(tree
, hf_tnef_attribute_date_day_of_week
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
318 static void dissect_mapiprops(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, unsigned oem_encoding
)
320 proto_item
*item
, *prop_item
;
321 proto_tree
*prop_tree
, *tag_tree
;
322 uint32_t /*count,*/ tag
, tag_kind
, tag_length
;
324 int offset
, start_offset
;
326 uint8_t drep
[] = {0x10 /* LE */, /* DCE_RPC_DREP_FP_IEEE */ 0 };
327 static dcerpc_info di
;
328 static dcerpc_call_value call_data
;
332 di
.conformant_run
= 0;
333 /* we need di->call_data->flags.NDR64 == 0 */
334 di
.call_data
= &call_data
;
335 di
.dcerpc_procedure_name
= "";
337 /* first the count */
338 proto_tree_add_item(tree
, hf_tnef_mapi_props_count
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
339 /*count = tvb_get_letohl(tvb, offset);*/
343 while(tvb_reported_length_remaining(tvb
, offset
) > 0 ) {
345 start_offset
= offset
;
347 /* get the property tag */
349 prop_item
= proto_tree_add_item(tree
, hf_tnef_property
, tvb
, offset
, -1, ENC_NA
);
350 prop_tree
= proto_item_add_subtree(prop_item
, ett_tnef_property
);
352 item
= proto_tree_add_item(prop_tree
, hf_tnef_property_tag
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
353 tag_tree
= proto_item_add_subtree(item
, ett_tnef_property_tag
);
355 /* add a nice name to the property */
356 tag
= tvb_get_letohl(tvb
, offset
);
357 proto_item_append_text(prop_item
, " %s", val_to_str(tag
, nspi_MAPITAGS_vals
, "Unknown tag (0x%08lx)"));
359 proto_tree_add_item(tag_tree
, hf_tnef_property_tag_type
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
362 proto_tree_add_item(tag_tree
, hf_tnef_property_tag_id
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
365 if(tag
& 0x80000000) {
366 const uint8_t* name_string
= NULL
;
368 /* it is a named property */
369 proto_tree_add_item(tag_tree
, hf_tnef_property_tag_set
, tvb
, offset
, 16, ENC_LITTLE_ENDIAN
);
372 tag_kind
= tvb_get_letohl(tvb
, offset
);
373 proto_tree_add_item(tag_tree
, hf_tnef_property_tag_kind
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
377 proto_tree_add_item(tag_tree
, hf_tnef_property_tag_name_id
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
380 tag_length
= tvb_get_letohl(tvb
, offset
);
381 proto_tree_add_item(tag_tree
, hf_tnef_property_tag_name_length
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
384 proto_tree_add_item_ret_string(tag_tree
, hf_tnef_property_tag_name_string
, tvb
, offset
, tag_length
,
385 ENC_UTF_16
|ENC_LITTLE_ENDIAN
, pinfo
->pool
, &name_string
);
386 offset
+= tag_length
;
388 if((padding
= (4 - tag_length
% 4)) != 4) {
389 proto_tree_add_item(tag_tree
, hf_tnef_property_padding
, tvb
, offset
, padding
, ENC_NA
);
393 proto_item_append_text(prop_item
, " [Named Property");
395 proto_item_append_text(prop_item
, ": %s", name_string
);
396 proto_item_append_text(prop_item
, "]");
400 /* handle any specific tags here */
402 /* otherwise just use the type */
403 switch(tag
& 0x0000ffff) {
405 offset
= PIDL_dissect_uint16(tvb
, offset
, pinfo
, prop_tree
, &di
, drep
, hf_tnef_PropValue_i
, 0);
408 offset
= PIDL_dissect_uint32(tvb
, offset
, pinfo
, prop_tree
, &di
, drep
, hf_tnef_PropValue_l
, 0);
411 offset
= PIDL_dissect_uint16(tvb
, offset
, pinfo
, prop_tree
, &di
, drep
, hf_tnef_PropValue_b
, 0);
414 offset
= dissect_counted_values(tvb
, offset
, hf_tnef_PropValue_lpszA
, pinfo
, prop_tree
, true, oem_encoding
);
417 offset
= dissect_counted_values(tvb
, offset
, hf_tnef_PropValue_bin
, pinfo
, prop_tree
, true, ENC_NA
);
420 offset
= dissect_counted_values (tvb
, offset
, hf_tnef_PropValue_lpszW
, pinfo
, prop_tree
, true, ENC_UTF_16
|ENC_LITTLE_ENDIAN
);
423 offset
= nspi_dissect_struct_MAPIUID(tvb
, offset
, pinfo
, prop_tree
, &di
, drep
, hf_tnef_PropValue_lpguid
, 0);
426 offset
= nspi_dissect_struct_FILETIME(tvb
,offset
,pinfo
,prop_tree
,&di
,drep
,hf_tnef_PropValue_ft
,0);
429 offset
= nspi_dissect_enum_MAPISTATUS(tvb
, offset
, pinfo
, prop_tree
, &di
, drep
, hf_tnef_PropValue_err
, 0);
432 offset
= nspi_dissect_struct_SShortArray(tvb
,offset
,pinfo
,prop_tree
,&di
,drep
,hf_tnef_PropValue_MVi
,0);
435 offset
= nspi_dissect_struct_MV_LONG_STRUCT(tvb
,offset
,pinfo
,prop_tree
,&di
,drep
,hf_tnef_PropValue_MVl
,0);
438 offset
= nspi_dissect_struct_SLPSTRArray(tvb
,offset
,pinfo
,prop_tree
,&di
,drep
,hf_tnef_PropValue_MVszA
,0);
441 offset
= nspi_dissect_struct_SBinaryArray(tvb
,offset
,pinfo
,prop_tree
,&di
,drep
,hf_tnef_PropValue_MVbin
,0);
444 offset
= nspi_dissect_struct_SGuidArray(tvb
,offset
,pinfo
,prop_tree
,&di
,drep
,hf_tnef_PropValue_MVguid
,0);
447 offset
= nspi_dissect_struct_MV_UNICODE_STRUCT(tvb
,offset
,pinfo
,prop_tree
,&di
,drep
,hf_tnef_PropValue_MVszW
,0);
450 offset
= nspi_dissect_struct_SDateTimeArray(tvb
,offset
,pinfo
,prop_tree
,&di
,drep
,hf_tnef_PropValue_MVft
,0);
453 offset
= PIDL_dissect_uint32(tvb
, offset
, pinfo
, prop_tree
, &di
, drep
, hf_tnef_PropValue_null
, 0);
456 offset
= PIDL_dissect_uint32(tvb
, offset
, pinfo
, prop_tree
, &di
, drep
, hf_tnef_PropValue_object
, 0);
461 /* we may need to pad to a 4-byte boundary */
462 if((padding
= (4 - (offset
- start_offset
) % 4)) != 4) {
465 proto_tree_add_item(prop_tree
, hf_tnef_property_padding
, tvb
, offset
, padding
, ENC_NA
);
470 proto_item_set_len(prop_item
, offset
- start_offset
);
475 static int dissect_tnef(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
477 proto_item
*attr_item
, *item
;
478 proto_tree
*attr_tree
, *tag_tree
, *props_tree
, *addr_tree
, *date_tree
;
479 uint32_t tag
, length
, signature
;
480 int offset
, start_offset
;
482 uint64_t oem_code_page
;
483 unsigned oem_encoding
= ENC_ASCII
|ENC_NA
;
486 item
= proto_tree_add_item(tree
, proto_tnef
, tvb
, 0, -1, ENC_NA
);
487 tree
= proto_item_add_subtree(item
, ett_tnef
);
492 /* first the signature */
493 signature
= tvb_get_letohl(tvb
, offset
);
494 item
= proto_tree_add_item(tree
, hf_tnef_signature
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
497 /* check the signature */
498 if(signature
!= TNEF_SIGNATURE
) {
500 expert_add_info_format(pinfo
, item
, &ei_tnef_incorrect_signature
,
501 " [Incorrect, should be 0x%x. No further dissection possible. Check any Content-Transfer-Encoding has been removed.]", TNEF_SIGNATURE
);
506 proto_item_append_text(item
, " [Correct]");
510 proto_tree_add_item(tree
, hf_tnef_key
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
513 while(tvb_reported_length_remaining(tvb
, offset
) > 9 ) { /* there must be at least a level (1), tag (4) and length (4) to be valid */
515 start_offset
= offset
;
517 attr_item
= proto_tree_add_item(tree
, hf_tnef_attribute
, tvb
, offset
, -1, ENC_NA
);
518 attr_tree
= proto_item_add_subtree(attr_item
, ett_tnef_attribute
);
520 proto_tree_add_item(attr_tree
, hf_tnef_attribute_lvl
, tvb
, offset
, 1, ENC_LITTLE_ENDIAN
);
523 item
= proto_tree_add_item(attr_tree
, hf_tnef_attribute_tag
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
524 tag_tree
= proto_item_add_subtree(item
, ett_tnef_attribute_tag
);
526 /* add a nice name to the property */
527 tag
= tvb_get_letohl(tvb
, offset
);
528 proto_item_append_text(attr_item
, " %s", val_to_str(tag
, tnef_Attribute_vals
, "Unknown tag (0x%08lx)"));
530 proto_tree_add_item(tag_tree
, hf_tnef_attribute_tag_id
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
533 proto_tree_add_item(tag_tree
, hf_tnef_attribute_tag_type
, tvb
, offset
, 2, ENC_LITTLE_ENDIAN
);
534 /* remember the type for the value dissection */
537 length
= tvb_get_letohl(tvb
, offset
);
538 proto_tree_add_item(attr_tree
, hf_tnef_attribute_length
, tvb
, offset
, 4, ENC_LITTLE_ENDIAN
);
542 case ATT_OEM_CODEPAGE
:
543 proto_tree_add_item_ret_uint64(attr_tree
, hf_tnef_oem_codepage
, tvb
, offset
, length
, ENC_LITTLE_ENDIAN
, &oem_code_page
);
544 switch (oem_code_page
) {
547 oem_encoding
= ENC_WINDOWS_1250
|ENC_NA
;
551 oem_encoding
= ENC_WINDOWS_1251
|ENC_NA
;
555 oem_encoding
= ENC_WINDOWS_1252
|ENC_NA
;
559 oem_encoding
= ENC_ASCII
|ENC_NA
; /* XXX - support more code pages */
563 case ATT_TNEF_VERSION
:
564 proto_tree_add_item(attr_tree
, hf_tnef_version
, tvb
, offset
, length
, ENC_LITTLE_ENDIAN
);
566 case ATT_MESSAGE_CLASS
:
567 proto_tree_add_item(attr_tree
, hf_tnef_message_class
, tvb
, offset
, length
, ENC_ASCII
);
569 case ATT_ORIGINAL_MESSAGE_CLASS
:
570 proto_tree_add_item(attr_tree
, hf_tnef_original_message_class
, tvb
, offset
, length
, ENC_ASCII
);
573 item
= proto_tree_add_item(attr_tree
, hf_tnef_mapi_props
, tvb
, offset
, length
, ENC_NA
);
574 props_tree
= proto_item_add_subtree(item
, ett_tnef_mapi_props
);
576 next_tvb
= tvb_new_subset_length(tvb
, offset
, length
);
578 dissect_mapiprops(next_tvb
, pinfo
, props_tree
, oem_encoding
);
583 addr_tree
= proto_item_add_subtree(item
, ett_tnef_attribute_address
);
585 (void)dissect_counted_address(tvb
, offset
, pinfo
, addr_tree
);
589 proto_tree_add_item(attr_tree
, hf_tnef_priority
, tvb
, offset
, length
, ENC_LITTLE_ENDIAN
);
592 /* just do it on the type */
593 switch((tag
>> 16) & 0xffff) {
595 item
= proto_tree_add_item(attr_tree
, hf_tnef_attribute_date
, tvb
, offset
, length
, ENC_NA
);
596 date_tree
= proto_item_add_subtree(item
, ett_tnef_attribute_date
);
598 next_tvb
= tvb_new_subset_length(tvb
, offset
, length
);
600 dissect_DTR(next_tvb
, pinfo
, date_tree
);
606 proto_tree_add_item_ret_string(attr_tree
, hf_tnef_attribute_string
, tvb
, offset
, length
, oem_encoding
, pinfo
->pool
, &atp
);
607 proto_item_append_text(attr_item
, " %s", atp
);
611 proto_tree_add_item(attr_tree
, hf_tnef_attribute_value
, tvb
, offset
, length
, ENC_NA
);
616 /* check for overflow */
617 if (offset
+ length
> (uint32_t)offset
) {
621 proto_tree_add_checksum(attr_tree
, tvb
, offset
, hf_tnef_attribute_checksum
, -1, NULL
, pinfo
, 0, ENC_LITTLE_ENDIAN
, PROTO_CHECKSUM_NO_FLAGS
);
624 proto_item_set_len(attr_item
, offset
- start_offset
);
627 /* there may be some padding */
628 if(tvb_reported_length_remaining(tvb
, offset
)) /* XXX: Not sure if they is really padding or not */
629 proto_tree_add_item(tree
, hf_tnef_padding
, tvb
, offset
, tvb_reported_length_remaining(tvb
, offset
), ENC_NA
);
631 return tvb_captured_length(tvb
);
634 static int dissect_tnef_file(tvbuff_t
*tvb
, packet_info
*pinfo
, proto_tree
*tree
, void* data _U_
)
636 col_set_str(pinfo
->cinfo
, COL_PROTOCOL
, PSNAME
);
638 col_set_str(pinfo
->cinfo
, COL_DEF_SRC
, PSNAME
" encoded file");
640 col_append_str(pinfo
->cinfo
, COL_INFO
, PNAME
);
642 dissect_tnef(tvb
, pinfo
, tree
, NULL
);
643 return tvb_captured_length(tvb
);
646 /* Register all the bits needed by the filtering engine */
649 proto_register_tnef(void)
651 static hf_register_info hf
[] = {
652 { &hf_tnef_signature
,
653 { "Signature", "tnef.signature", FT_UINT32
, BASE_HEX
, NULL
, 0x0,
656 { "Key", "tnef.key", FT_UINT16
, BASE_HEX
, NULL
, 0x0,
658 { &hf_tnef_attribute
,
659 { "Attribute", "tnef.attribute", FT_NONE
, BASE_NONE
, NULL
, 0x0,
661 { &hf_tnef_attribute_lvl
,
662 { "Type", "tnef.attribute.lvl", FT_UINT8
, BASE_DEC
, VALS(tnef_Lvl_vals
), 0x0,
664 { &hf_tnef_attribute_tag
,
665 { "Tag", "tnef.attribute.tag", FT_UINT32
, BASE_HEX
, VALS(tnef_Attribute_vals
), 0x0,
667 { &hf_tnef_attribute_tag_type
,
668 { "Type", "tnef.attribute.tag.type", FT_UINT16
, BASE_HEX
, VALS(tnef_Types_vals
), 0x0,
670 { &hf_tnef_attribute_tag_id
,
671 { "Tag", "tnef.attribute.tag.id", FT_UINT16
, BASE_HEX
, NULL
, 0x0,
673 { &hf_tnef_attribute_length
,
674 { "Length", "tnef.attribute.length", FT_UINT32
, BASE_DEC
, NULL
, 0x0,
676 { &hf_tnef_attribute_value
,
677 { "Value", "tnef.attribute.value", FT_NONE
, BASE_NONE
, NULL
, 0x0,
679 { &hf_tnef_attribute_string
,
680 { "String", "tnef.attribute.string", FT_STRING
, BASE_NONE
, NULL
, 0x0,
682 { &hf_tnef_attribute_date
,
683 { "Date", "tnef.attribute.date", FT_NONE
, BASE_NONE
, NULL
, 0x0,
685 { &hf_tnef_attribute_display_name
,
686 { "Display Name", "tnef.attribute.display_name", FT_STRING
, BASE_NONE
, NULL
, 0x0,
688 { &hf_tnef_attribute_email_address
,
689 { "Email Address", "tnef.attribute.email_address", FT_STRING
, BASE_NONE
, NULL
, 0x0,
691 { &hf_tnef_attribute_date_year
,
692 { "Year", "tnef.attribute.date.year", FT_UINT16
, BASE_DEC
, NULL
, 0, NULL
, HFILL
}},
693 { &hf_tnef_attribute_date_month
,
694 { "Month", "tnef.attribute.date.month", FT_UINT16
, BASE_DEC
, NULL
, 0, NULL
, HFILL
}},
695 { &hf_tnef_attribute_date_day
,
696 { "Day", "tnef.attribute.date.day", FT_UINT16
, BASE_DEC
, NULL
, 0, NULL
, HFILL
}},
697 { &hf_tnef_attribute_date_hour
,
698 { "Hour", "tnef.attribute.date.hour", FT_UINT16
, BASE_DEC
, NULL
, 0, NULL
, HFILL
}},
699 { &hf_tnef_attribute_date_minute
,
700 { "Minute", "tnef.attribute.date.minute", FT_UINT16
, BASE_DEC
, NULL
, 0, NULL
, HFILL
}},
701 { &hf_tnef_attribute_date_second
,
702 { "Second", "tnef.attribute.date.second", FT_UINT16
, BASE_DEC
, NULL
, 0, NULL
, HFILL
}},
703 { &hf_tnef_attribute_date_day_of_week
,
704 { "Day Of Week", "tnef.attribute.date.day_of_week", FT_UINT16
, BASE_DEC
, VALS(weekday_vals
), 0, NULL
, HFILL
}},
705 { &hf_tnef_attribute_checksum
,
706 { "Checksum", "tnef.attribute.checksum", FT_UINT16
, BASE_HEX
, NULL
, 0x0,
708 { &hf_tnef_mapi_props
,
709 { "MAPI Properties", "tnef.mapi_props", FT_NONE
, BASE_NONE
, NULL
, 0x0,
712 { "Version", "tnef.version", FT_UINT32
, BASE_HEX
, NULL
, 0x0,
714 { &hf_tnef_oem_codepage
,
715 { "OEM Codepage", "tnef.oem_codepage", FT_UINT64
, BASE_DEC
, NULL
, 0x0,
717 { &hf_tnef_message_class
,
718 { "Message Class", "tnef.message_class", FT_STRING
, BASE_NONE
, NULL
, 0x0,
720 { &hf_tnef_original_message_class
,
721 { "Original Message Class", "tnef.message_class.original", FT_STRING
, BASE_NONE
, NULL
, 0x0,
724 { "Priority", "tnef.priority", FT_UINT16
, BASE_DEC
, VALS(tnef_Priority_vals
), 0x0,
726 { &hf_tnef_mapi_props_count
,
727 { "Count", "tnef.mapi_props.count", FT_UINT32
, BASE_DEC
, NULL
, 0x0,
730 { "Property", "tnef.property", FT_NONE
, BASE_NONE
, NULL
, 0x0,
732 { &hf_tnef_property_tag
,
733 { "Tag", "tnef.property.tag", FT_UINT32
, BASE_HEX
, VALS(nspi_MAPITAGS_vals
), 0x0,
735 { &hf_tnef_property_tag_type
,
736 { "Type", "tnef.property.tag.type", FT_UINT16
, BASE_HEX
, VALS(nspi_property_types_vals
), 0x0,
738 { &hf_tnef_property_tag_id
,
739 { "Tag", "tnef.property.tag.id", FT_UINT16
, BASE_HEX
, NULL
, 0x0,
741 { &hf_tnef_property_tag_set
,
742 { "Set", "tnef.attribute.tag.set", FT_GUID
, BASE_NONE
, NULL
, 0x0,
744 { &hf_tnef_property_tag_kind
,
745 { "Kind", "tnef.attribute.tag.kind", FT_UINT32
, BASE_DEC
, NULL
, 0x0,
747 { &hf_tnef_property_tag_name_id
,
748 { "Name", "tnef.attribute.tag.name.id", FT_UINT32
, BASE_HEX
, NULL
, 0x0,
750 { &hf_tnef_property_tag_name_length
,
751 { "Length", "tnef.attribute.tag.name.length", FT_UINT32
, BASE_DEC
, NULL
, 0x0,
753 { &hf_tnef_property_tag_name_string
,
754 { "Name", "tnef.attribute.tag.name.string", FT_STRING
, BASE_NONE
, NULL
, 0x0,
756 { &hf_tnef_property_padding
,
757 { "Padding", "tnef.property.padding", FT_NONE
, BASE_NONE
, NULL
, 0x0,
760 { "Padding", "tnef.padding", FT_NONE
, BASE_NONE
, NULL
, 0x0,
762 { &hf_tnef_values_count
,
763 { "Count", "tnef.values.count", FT_UINT32
, BASE_DEC
, NULL
, 0x0,
765 { &hf_tnef_value_length
,
766 { "Length", "tnef.value.length", FT_UINT32
, BASE_DEC
, NULL
, 0x0,
768 { &hf_tnef_PropValue_i
,
769 { "I", "tnef.PropValue.i", FT_UINT16
, BASE_DEC
, NULL
, 0, NULL
, HFILL
}},
770 { &hf_tnef_PropValue_l
,
771 { "L", "tnef.PropValue.l", FT_UINT32
, BASE_DEC
, NULL
, 0, NULL
, HFILL
}},
772 { &hf_tnef_PropValue_b
,
773 { "B", "tnef.PropValue.b", FT_UINT16
, BASE_DEC
, NULL
, 0, NULL
, HFILL
}},
774 { &hf_tnef_PropValue_lpszA
,
775 { "Lpsza", "tnef.PropValue.lpszA", FT_STRING
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}},
776 { &hf_tnef_PropValue_lpszW
,
777 { "Lpszw", "tnef.PropValue.lpszW", FT_STRING
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}},
778 { &hf_tnef_PropValue_lpguid
,
779 { "Lpguid", "tnef.PropValue.lpguid", FT_NONE
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}},
780 { &hf_tnef_PropValue_bin
,
781 { "Bin", "tnef.PropValue.bin", FT_NONE
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}},
782 { &hf_tnef_PropValue_ft
,
783 { "Ft", "tnef.PropValue.ft", FT_NONE
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}},
784 { &hf_tnef_PropValue_err
,
785 { "Err", "tnef.PropValue.err", FT_UINT32
, BASE_DEC
, VALS(nspi_MAPISTATUS_vals
), 0, NULL
, HFILL
}},
786 { &hf_tnef_PropValue_MVi
,
787 { "Mvi", "tnef.PropValue.MVi", FT_NONE
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}},
788 { &hf_tnef_PropValue_MVl
,
789 { "Mvl", "tnef.PropValue.MVl", FT_NONE
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}},
790 { &hf_tnef_PropValue_MVszA
,
791 { "Mvsza", "tnef.PropValue.MVszA", FT_NONE
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}},
792 { &hf_tnef_PropValue_MVbin
,
793 { "Mvbin", "tnef.PropValue.MVbin", FT_NONE
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}},
794 { &hf_tnef_PropValue_MVguid
,
795 { "Mvguid", "tnef.PropValue.MVguid", FT_NONE
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}},
796 { &hf_tnef_PropValue_MVszW
,
797 { "Mvszw", "tnef.PropValue.MVszW", FT_NONE
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}},
798 { &hf_tnef_PropValue_MVft
,
799 { "Mvft", "tnef.PropValue.MVft", FT_NONE
, BASE_NONE
, NULL
, 0, NULL
, HFILL
}},
800 { &hf_tnef_PropValue_null
,
801 { "Null", "tnef.PropValue.null", FT_UINT32
, BASE_DEC
, NULL
, 0, NULL
, HFILL
}},
802 { &hf_tnef_PropValue_object
,
803 { "Object", "tnef.PropValue.object", FT_UINT32
, BASE_DEC
, NULL
, 0, NULL
, HFILL
}},
805 static int *ett
[] = {
808 &ett_tnef_attribute_tag
,
809 &ett_tnef_mapi_props
,
811 &ett_tnef_property_tag
,
812 &ett_tnef_counted_items
,
813 &ett_tnef_attribute_date
,
814 &ett_tnef_attribute_address
,
817 static ei_register_info ei
[] = {
818 { &ei_tnef_expect_single_item
, { "tnef.expect_single_item", PI_MALFORMED
, PI_ERROR
, "Expected single item", EXPFILL
}},
819 { &ei_tnef_incorrect_signature
, { "tnef.signature.incorrect", PI_MALFORMED
, PI_WARN
, "Incorrect signature", EXPFILL
}},
822 expert_module_t
* expert_tnef
;
824 proto_tnef
= proto_register_protocol(PNAME
, PSNAME
, PFNAME
);
826 proto_register_field_array(proto_tnef
, hf
, array_length(hf
));
827 proto_register_subtree_array(ett
, array_length(ett
));
828 expert_tnef
= expert_register_protocol(proto_tnef
);
829 expert_register_field_array(expert_tnef
, ei
, array_length(ei
));
831 /* Allow dissector to find be found by name. */
832 tnef_handle
= register_dissector(PFNAME
, dissect_tnef
, proto_tnef
);
836 /* The registration hand-off routine */
838 proto_reg_handoff_tnef(void)
840 dissector_handle_t tnef_file_handle
;
842 tnef_file_handle
= create_dissector_handle(dissect_tnef_file
, proto_tnef
);
844 dissector_add_string("media_type", "application/ms-tnef", tnef_handle
);
846 /* X.400 file transfer bodypart */
847 register_ber_oid_dissector_handle("1.2.840.113556.3.10.1", tnef_handle
, proto_tnef
, "id-et-tnef");
849 dissector_add_uint("wtap_encap", WTAP_ENCAP_TNEF
, tnef_file_handle
);
853 * Editor modelines - https://www.wireshark.org/tools/modelines.html
858 * indent-tabs-mode: nil
861 * ex: set shiftwidth=2 tabstop=8 expandtab:
862 * :indentSize=2:tabSize=8:noTabs=true: