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 = -1;
79 static int hf_tnef_signature = -1;
80 static int hf_tnef_key = -1;
81 static int hf_tnef_attribute = -1;
82 static int hf_tnef_attribute_lvl = -1;
83 static int hf_tnef_attribute_tag = -1;
84 static int hf_tnef_attribute_tag_type = -1;
85 static int hf_tnef_attribute_tag_id = -1;
86 static int hf_tnef_attribute_length = -1;
87 static int hf_tnef_attribute_value = -1;
88 static int hf_tnef_attribute_string = -1;
89 static int hf_tnef_attribute_date = -1;
90 static int hf_tnef_attribute_display_name = -1;
91 static int hf_tnef_attribute_email_address = -1;
92 static int hf_tnef_attribute_checksum = -1;
93 static int hf_tnef_mapi_props = -1;
94 static int hf_tnef_oem_codepage = -1;
95 static int hf_tnef_version = -1;
96 static int hf_tnef_message_class = -1;
97 static int hf_tnef_original_message_class = -1;
98 static int hf_tnef_priority = -1;
99 static int hf_tnef_mapi_props_count = -1;
101 static int hf_tnef_property = -1;
102 static int hf_tnef_property_tag = -1;
103 static int hf_tnef_property_tag_type = -1;
104 static int hf_tnef_property_tag_id = -1;
105 static int hf_tnef_property_tag_set = -1;
106 static int hf_tnef_property_tag_kind = -1;
107 static int hf_tnef_property_tag_name_id = -1;
108 static int hf_tnef_property_tag_name_length = -1;
109 static int hf_tnef_property_tag_name_string = -1;
110 static int hf_tnef_property_padding = -1;
111 static int hf_tnef_padding = -1;
113 static int hf_tnef_values_count = -1;
114 static int hf_tnef_value_length = -1;
116 static int hf_tnef_attribute_date_year = -1;
117 static int hf_tnef_attribute_date_month = -1;
118 static int hf_tnef_attribute_date_day = -1;
119 static int hf_tnef_attribute_date_hour = -1;
120 static int hf_tnef_attribute_date_minute = -1;
121 static int hf_tnef_attribute_date_second = -1;
122 static int hf_tnef_attribute_date_day_of_week = -1;
124 static int hf_tnef_PropValue_i = -1;
125 static int hf_tnef_PropValue_l = -1;
126 static int hf_tnef_PropValue_b = -1;
127 static int hf_tnef_PropValue_lpszA = -1;
128 static int hf_tnef_PropValue_lpszW = -1;
129 static int hf_tnef_PropValue_lpguid = -1;
130 static int hf_tnef_PropValue_bin = -1;
131 static int hf_tnef_PropValue_ft = -1;
132 static int hf_tnef_PropValue_err = -1;
133 static int hf_tnef_PropValue_MVi = -1;
134 static int hf_tnef_PropValue_MVl = -1;
135 static int hf_tnef_PropValue_MVszA = -1;
136 static int hf_tnef_PropValue_MVbin = -1;
137 static int hf_tnef_PropValue_MVguid = -1;
138 static int hf_tnef_PropValue_MVszW = -1;
139 static int hf_tnef_PropValue_MVft = -1;
140 static int hf_tnef_PropValue_null = -1;
141 static int hf_tnef_PropValue_object = -1;
143 static int ett_tnef = -1;
144 static int ett_tnef_attribute = -1;
145 static int ett_tnef_attribute_tag = -1;
146 static int ett_tnef_mapi_props = -1;
147 static int ett_tnef_property = -1;
148 static int ett_tnef_property_tag = -1;
149 static int ett_tnef_counted_items = -1;
150 static int ett_tnef_attribute_date = -1;
151 static int ett_tnef_attribute_address = -1;
153 static expert_field ei_tnef_expect_single_item = EI_INIT;
154 static expert_field ei_tnef_incorrect_signature = EI_INIT;
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 gint dissect_counted_values(tvbuff_t *tvb, gint offset, int hf_id, packet_info *pinfo, proto_tree *tree, gboolean single, guint encoding)
236 guint32 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 gint dissect_counted_address(tvbuff_t *tvb, gint 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|ENC_NA);
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|ENC_NA);
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)
320 proto_item *item, *prop_item;
321 proto_tree *prop_tree, *tag_tree;
322 guint32 /*count,*/ tag, tag_kind, tag_length;
324 gint offset, start_offset;
326 guint8 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) {
367 /* it is a named property */
368 proto_tree_add_item(tag_tree, hf_tnef_property_tag_set, tvb, offset, 16, ENC_LITTLE_ENDIAN);
371 tag_kind = tvb_get_letohl(tvb, offset);
372 proto_tree_add_item(tag_tree, hf_tnef_property_tag_kind, tvb, offset, 4, ENC_LITTLE_ENDIAN);
376 proto_tree_add_item(tag_tree, hf_tnef_property_tag_name_id, tvb, offset, 4, ENC_LITTLE_ENDIAN);
379 proto_item_append_text(prop_item, " [Named Property]");
381 char *name_string = NULL;
383 tag_length = tvb_get_letohl(tvb, offset);
384 proto_tree_add_item(tag_tree, hf_tnef_property_tag_name_length, tvb, offset, 4, ENC_LITTLE_ENDIAN);
387 proto_tree_add_item(tag_tree, hf_tnef_property_tag_name_string, tvb, offset, tag_length, ENC_UTF_16|ENC_LITTLE_ENDIAN);
388 offset += tag_length;
390 if((padding = (4 - tag_length % 4)) != 4) {
391 proto_tree_add_item(tag_tree, hf_tnef_property_padding, tvb, offset, padding, ENC_NA);
395 proto_item_append_text(prop_item, " [Named Property: %s]", name_string);
401 /* handle any specific tags here */
403 /* otherwise just use the type */
404 switch(tag & 0x0000ffff) {
406 offset = PIDL_dissect_uint16(tvb, offset, pinfo, prop_tree, &di, drep, hf_tnef_PropValue_i, 0);
409 offset = PIDL_dissect_uint32(tvb, offset, pinfo, prop_tree, &di, drep, hf_tnef_PropValue_l, 0);
412 offset = PIDL_dissect_uint16(tvb, offset, pinfo, prop_tree, &di, drep, hf_tnef_PropValue_b, 0);
415 /* XXX - code page? */
416 offset = dissect_counted_values(tvb, offset, hf_tnef_PropValue_lpszA, pinfo, prop_tree, TRUE, ENC_ASCII|ENC_NA);
419 offset = dissect_counted_values(tvb, offset, hf_tnef_PropValue_bin, pinfo, prop_tree, TRUE, ENC_NA);
422 offset = dissect_counted_values (tvb, offset, hf_tnef_PropValue_lpszW, pinfo, prop_tree, TRUE, ENC_UTF_16|ENC_NA);
425 offset = nspi_dissect_struct_MAPIUID(tvb, offset, pinfo, prop_tree, &di, drep, hf_tnef_PropValue_lpguid, 0);
428 offset = nspi_dissect_struct_FILETIME(tvb,offset,pinfo,prop_tree,&di,drep,hf_tnef_PropValue_ft,0);
431 offset = nspi_dissect_enum_MAPISTATUS(tvb, offset, pinfo, prop_tree, &di, drep, hf_tnef_PropValue_err, 0);
434 offset = nspi_dissect_struct_SShortArray(tvb,offset,pinfo,prop_tree,&di,drep,hf_tnef_PropValue_MVi,0);
437 offset = nspi_dissect_struct_MV_LONG_STRUCT(tvb,offset,pinfo,prop_tree,&di,drep,hf_tnef_PropValue_MVl,0);
440 offset = nspi_dissect_struct_SLPSTRArray(tvb,offset,pinfo,prop_tree,&di,drep,hf_tnef_PropValue_MVszA,0);
443 offset = nspi_dissect_struct_SBinaryArray(tvb,offset,pinfo,prop_tree,&di,drep,hf_tnef_PropValue_MVbin,0);
446 offset = nspi_dissect_struct_SGuidArray(tvb,offset,pinfo,prop_tree,&di,drep,hf_tnef_PropValue_MVguid,0);
449 offset = nspi_dissect_struct_MV_UNICODE_STRUCT(tvb,offset,pinfo,prop_tree,&di,drep,hf_tnef_PropValue_MVszW,0);
452 offset = nspi_dissect_struct_SDateTimeArray(tvb,offset,pinfo,prop_tree,&di,drep,hf_tnef_PropValue_MVft,0);
455 offset = PIDL_dissect_uint32(tvb, offset, pinfo, prop_tree, &di, drep, hf_tnef_PropValue_null, 0);
458 offset = PIDL_dissect_uint32(tvb, offset, pinfo, prop_tree, &di, drep, hf_tnef_PropValue_object, 0);
463 /* we may need to pad to a 4-byte boundary */
464 if((padding = (4 - (offset - start_offset) % 4)) != 4) {
467 proto_tree_add_item(prop_tree, hf_tnef_property_padding, tvb, offset, padding, ENC_NA);
472 proto_item_set_len(prop_item, offset - start_offset);
477 static int dissect_tnef(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
479 proto_item *attr_item, *item;
480 proto_tree *attr_tree, *tag_tree, *props_tree, *addr_tree, *date_tree;
481 guint32 tag, length, signature;
482 gint offset, start_offset;
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(attr_tree, hf_tnef_oem_codepage, tvb, offset, length, ENC_LITTLE_ENDIAN);
545 case ATT_TNEF_VERSION:
546 proto_tree_add_item(attr_tree, hf_tnef_version, tvb, offset, length, ENC_LITTLE_ENDIAN);
548 case ATT_MESSAGE_CLASS:
549 proto_tree_add_item(attr_tree, hf_tnef_message_class, tvb, offset, length, ENC_ASCII|ENC_NA);
551 case ATT_ORIGINAL_MESSAGE_CLASS:
552 proto_tree_add_item(attr_tree, hf_tnef_original_message_class, tvb, offset, length, ENC_ASCII|ENC_NA);
555 item = proto_tree_add_item(attr_tree, hf_tnef_mapi_props, tvb, offset, length, ENC_NA);
556 props_tree = proto_item_add_subtree(item, ett_tnef_mapi_props);
558 next_tvb = tvb_new_subset_length(tvb, offset, length);
560 dissect_mapiprops(next_tvb, pinfo, props_tree);
565 addr_tree = proto_item_add_subtree(item, ett_tnef_attribute_address);
567 (void)dissect_counted_address(tvb, offset, pinfo, addr_tree);
571 proto_tree_add_item(attr_tree, hf_tnef_priority, tvb, offset, length, ENC_LITTLE_ENDIAN);
574 /* just do it on the type */
575 switch((tag >> 16) & 0xffff) {
577 item = proto_tree_add_item(attr_tree, hf_tnef_attribute_date, tvb, offset, length, ENC_NA);
578 date_tree = proto_item_add_subtree(item, ett_tnef_attribute_date);
580 next_tvb = tvb_new_subset_length(tvb, offset, length);
582 dissect_DTR(next_tvb, pinfo, date_tree);
588 proto_tree_add_item_ret_string(attr_tree, hf_tnef_attribute_string, tvb, offset, length, ENC_ASCII|ENC_NA, wmem_packet_scope(), &atp);
589 proto_item_append_text(attr_item, " %s", atp);
593 proto_tree_add_item(attr_tree, hf_tnef_attribute_value, tvb, offset, length, ENC_NA);
598 /* check for overflow */
599 if (offset + length > (guint32)offset) {
603 proto_tree_add_checksum(attr_tree, tvb, offset, hf_tnef_attribute_checksum, -1, NULL, pinfo, 0, ENC_LITTLE_ENDIAN, PROTO_CHECKSUM_NO_FLAGS);
606 proto_item_set_len(attr_item, offset - start_offset);
609 /* there may be some padding */
610 if(tvb_reported_length_remaining(tvb, offset)) /* XXX: Not sure if they is really padding or not */
611 proto_tree_add_item(tree, hf_tnef_padding, tvb, offset, tvb_reported_length_remaining(tvb, offset), ENC_NA);
613 return tvb_captured_length(tvb);
616 static int dissect_tnef_file(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, void* data _U_)
618 col_set_str(pinfo->cinfo, COL_PROTOCOL, PSNAME);
620 col_set_str(pinfo->cinfo, COL_DEF_SRC, PSNAME " encoded file");
622 col_append_str(pinfo->cinfo, COL_INFO, PNAME);
624 dissect_tnef(tvb, pinfo, tree, NULL);
625 return tvb_captured_length(tvb);
628 /* Register all the bits needed by the filtering engine */
631 proto_register_tnef(void)
633 static hf_register_info hf[] = {
634 { &hf_tnef_signature,
635 { "Signature", "tnef.signature", FT_UINT32, BASE_HEX, NULL, 0x0,
638 { "Key", "tnef.key", FT_UINT16, BASE_HEX, NULL, 0x0,
640 { &hf_tnef_attribute,
641 { "Attribute", "tnef.attribute", FT_NONE, BASE_NONE, NULL, 0x0,
643 { &hf_tnef_attribute_lvl,
644 { "Type", "tnef.attribute.lvl", FT_UINT8, BASE_DEC, VALS(tnef_Lvl_vals), 0x0,
646 { &hf_tnef_attribute_tag,
647 { "Tag", "tnef.attribute.tag", FT_UINT32, BASE_HEX, VALS(tnef_Attribute_vals), 0x0,
649 { &hf_tnef_attribute_tag_type,
650 { "Type", "tnef.attribute.tag.type", FT_UINT16, BASE_HEX, VALS(tnef_Types_vals), 0x0,
652 { &hf_tnef_attribute_tag_id,
653 { "Tag", "tnef.attribute.tag.id", FT_UINT16, BASE_HEX, NULL, 0x0,
655 { &hf_tnef_attribute_length,
656 { "Length", "tnef.attribute.length", FT_UINT32, BASE_DEC, NULL, 0x0,
658 { &hf_tnef_attribute_value,
659 { "Value", "tnef.attribute.value", FT_NONE, BASE_NONE, NULL, 0x0,
661 { &hf_tnef_attribute_string,
662 { "String", "tnef.attribute.string", FT_STRING, BASE_NONE, NULL, 0x0,
664 { &hf_tnef_attribute_date,
665 { "Date", "tnef.attribute.date", FT_NONE, BASE_NONE, NULL, 0x0,
667 { &hf_tnef_attribute_display_name,
668 { "Display Name", "tnef.attribute.display_name", FT_STRING, BASE_NONE, NULL, 0x0,
670 { &hf_tnef_attribute_email_address,
671 { "Email Address", "tnef.attribute.email_address", FT_STRING, BASE_NONE, NULL, 0x0,
673 { &hf_tnef_attribute_date_year,
674 { "Year", "tnef.attribute.date.year", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
675 { &hf_tnef_attribute_date_month,
676 { "Month", "tnef.attribute.date.month", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
677 { &hf_tnef_attribute_date_day,
678 { "Day", "tnef.attribute.date.day", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
679 { &hf_tnef_attribute_date_hour,
680 { "Hour", "tnef.attribute.date.hour", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
681 { &hf_tnef_attribute_date_minute,
682 { "Minute", "tnef.attribute.date.minute", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
683 { &hf_tnef_attribute_date_second,
684 { "Second", "tnef.attribute.date.second", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
685 { &hf_tnef_attribute_date_day_of_week,
686 { "Day Of Week", "tnef.attribute.date.day_of_week", FT_UINT16, BASE_DEC, VALS(weekday_vals), 0, NULL, HFILL }},
687 { &hf_tnef_attribute_checksum,
688 { "Checksum", "tnef.attribute.checksum", FT_UINT16, BASE_HEX, NULL, 0x0,
690 { &hf_tnef_mapi_props,
691 { "MAPI Properties", "tnef.mapi_props", FT_NONE, BASE_NONE, NULL, 0x0,
694 { "Version", "tnef.version", FT_UINT32, BASE_HEX, NULL, 0x0,
696 { &hf_tnef_oem_codepage,
697 { "OEM Codepage", "tnef.oem_codepage", FT_UINT64, BASE_HEX, NULL, 0x0,
699 { &hf_tnef_message_class,
700 { "Message Class", "tnef.message_class", FT_STRING, BASE_NONE, NULL, 0x0,
702 { &hf_tnef_original_message_class,
703 { "Original Message Class", "tnef.message_class.original", FT_STRING, BASE_NONE, NULL, 0x0,
706 { "Priority", "tnef.priority", FT_UINT16, BASE_DEC, VALS(tnef_Priority_vals), 0x0,
708 { &hf_tnef_mapi_props_count,
709 { "Count", "tnef.mapi_props.count", FT_UINT16, BASE_DEC, NULL, 0x0,
712 { "Property", "tnef.property", FT_NONE, BASE_NONE, NULL, 0x0,
714 { &hf_tnef_property_tag,
715 { "Tag", "tnef.property.tag", FT_UINT32, BASE_HEX, VALS(nspi_MAPITAGS_vals), 0x0,
717 { &hf_tnef_property_tag_type,
718 { "Type", "tnef.property.tag.type", FT_UINT16, BASE_HEX, VALS(nspi_property_types_vals), 0x0,
720 { &hf_tnef_property_tag_id,
721 { "Tag", "tnef.property.tag.id", FT_UINT16, BASE_HEX, NULL, 0x0,
723 { &hf_tnef_property_tag_set,
724 { "Set", "tnef.attribute.tag.set", FT_GUID, BASE_NONE, NULL, 0x0,
726 { &hf_tnef_property_tag_kind,
727 { "Kind", "tnef.attribute.tag.kind", FT_UINT32, BASE_DEC, NULL, 0x0,
729 { &hf_tnef_property_tag_name_id,
730 { "Name", "tnef.attribute.tag.name.id", FT_UINT32, BASE_HEX, NULL, 0x0,
732 { &hf_tnef_property_tag_name_length,
733 { "Length", "tnef.attribute.tag.name.length", FT_UINT32, BASE_DEC, NULL, 0x0,
735 { &hf_tnef_property_tag_name_string,
736 { "Name", "tnef.attribute.tag.name.string", FT_STRING, BASE_NONE, NULL, 0x0,
738 { &hf_tnef_property_padding,
739 { "Padding", "tnef.property.padding", FT_NONE, BASE_NONE, NULL, 0x0,
742 { "Padding", "tnef.padding", FT_NONE, BASE_NONE, NULL, 0x0,
744 { &hf_tnef_values_count,
745 { "Count", "tnef.values.count", FT_UINT16, BASE_DEC, NULL, 0x0,
747 { &hf_tnef_value_length,
748 { "Length", "tnef.value.length", FT_UINT16, BASE_DEC, NULL, 0x0,
750 { &hf_tnef_PropValue_i,
751 { "I", "tnef.PropValue.i", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
752 { &hf_tnef_PropValue_l,
753 { "L", "tnef.PropValue.l", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL }},
754 { &hf_tnef_PropValue_b,
755 { "B", "tnef.PropValue.b", FT_UINT16, BASE_DEC, NULL, 0, NULL, HFILL }},
756 { &hf_tnef_PropValue_lpszA,
757 { "Lpsza", "tnef.PropValue.lpszA", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL }},
758 { &hf_tnef_PropValue_lpszW,
759 { "Lpszw", "tnef.PropValue.lpszW", FT_STRING, BASE_NONE, NULL, 0, NULL, HFILL }},
760 { &hf_tnef_PropValue_lpguid,
761 { "Lpguid", "tnef.PropValue.lpguid", FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }},
762 { &hf_tnef_PropValue_bin,
763 { "Bin", "tnef.PropValue.bin", FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }},
764 { &hf_tnef_PropValue_ft,
765 { "Ft", "tnef.PropValue.ft", FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }},
766 { &hf_tnef_PropValue_err,
767 { "Err", "tnef.PropValue.err", FT_UINT32, BASE_DEC, VALS(nspi_MAPISTATUS_vals), 0, NULL, HFILL }},
768 { &hf_tnef_PropValue_MVi,
769 { "Mvi", "tnef.PropValue.MVi", FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }},
770 { &hf_tnef_PropValue_MVl,
771 { "Mvl", "tnef.PropValue.MVl", FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }},
772 { &hf_tnef_PropValue_MVszA,
773 { "Mvsza", "tnef.PropValue.MVszA", FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }},
774 { &hf_tnef_PropValue_MVbin,
775 { "Mvbin", "tnef.PropValue.MVbin", FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }},
776 { &hf_tnef_PropValue_MVguid,
777 { "Mvguid", "tnef.PropValue.MVguid", FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }},
778 { &hf_tnef_PropValue_MVszW,
779 { "Mvszw", "tnef.PropValue.MVszW", FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }},
780 { &hf_tnef_PropValue_MVft,
781 { "Mvft", "tnef.PropValue.MVft", FT_NONE, BASE_NONE, NULL, 0, NULL, HFILL }},
782 { &hf_tnef_PropValue_null,
783 { "Null", "tnef.PropValue.null", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL }},
784 { &hf_tnef_PropValue_object,
785 { "Object", "tnef.PropValue.object", FT_UINT32, BASE_DEC, NULL, 0, NULL, HFILL }},
787 static gint *ett[] = {
790 &ett_tnef_attribute_tag,
791 &ett_tnef_mapi_props,
793 &ett_tnef_property_tag,
794 &ett_tnef_counted_items,
795 &ett_tnef_attribute_date,
796 &ett_tnef_attribute_address,
799 static ei_register_info ei[] = {
800 { &ei_tnef_expect_single_item, { "tnef.expect_single_item", PI_MALFORMED, PI_ERROR, "Expected single item", EXPFILL }},
801 { &ei_tnef_incorrect_signature, { "tnef.signature.incorrect", PI_MALFORMED, PI_WARN, "Incorrect signature", EXPFILL }},
804 expert_module_t* expert_tnef;
806 proto_tnef = proto_register_protocol(PNAME, PSNAME, PFNAME);
808 proto_register_field_array(proto_tnef, hf, array_length(hf));
809 proto_register_subtree_array(ett, array_length(ett));
810 expert_tnef = expert_register_protocol(proto_tnef);
811 expert_register_field_array(expert_tnef, ei, array_length(ei));
813 /* Allow dissector to find be found by name. */
814 tnef_handle = register_dissector(PFNAME, dissect_tnef, proto_tnef);
818 /* The registration hand-off routine */
820 proto_reg_handoff_tnef(void)
822 dissector_handle_t tnef_file_handle;
824 tnef_file_handle = create_dissector_handle(dissect_tnef_file, proto_tnef);
826 dissector_add_string("media_type", "application/ms-tnef", tnef_handle);
828 /* X.400 file transfer bodypart */
829 register_ber_oid_dissector_handle("1.2.840.113556.3.10.1", tnef_handle, proto_tnef, "id-et-tnef");
831 dissector_add_uint("wtap_encap", WTAP_ENCAP_TNEF, tnef_file_handle);
835 * Editor modelines - http://www.wireshark.org/tools/modelines.html
840 * indent-tabs-mode: nil
843 * ex: set shiftwidth=2 tabstop=8 expandtab:
844 * :indentSize=2:tabSize=8:noTabs=true: