2 * Routines for Exchange New Mail Notification dissection
3 * Copyright 2006, Stephen Fisher (see AUTHORS file)
7 * Wireshark - Network traffic analyzer
8 * By Gerald Combs <gerald@wireshark.org>
9 * Copyright 1998 Gerald Combs
11 * Copied from WHATEVER_FILE_YOU_USED (where "WHATEVER_FILE_YOU_USED"
12 * is a dissector file; if you just copied this from README.developer,
13 * don't bother with the "Copied from" - you don't even need to put
14 * in a "Copied from" if you copied an existing dissector, especially
15 * if the bulk of the code in the new dissector is your code)
17 * This program is free software; you can redistribute it and/or
18 * modify it under the terms of the GNU General Public License
19 * as published by the Free Software Foundation; either version 2
20 * of the License, or (at your option) any later version.
22 * This program is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
27 * You should have received a copy of the GNU General Public License
28 * along with this program; if not, write to the Free Software
29 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
40 #include <epan/packet.h>
41 #include <epan/prefs.h>
43 /* Forward declaration we need below */
44 void proto_reg_handoff_newmail(void);
46 /* Variables for preferences */
47 static guint preference_default_port = 0;
49 /* Initialize the protocol and registered fields */
50 static int proto_newmail = -1;
51 static int hf_newmail_payload = -1;
53 /* Initialize the subtree pointers */
54 static gint ett_newmail = -1;
56 /* Code to actually dissect the packets */
58 dissect_newmail(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
60 /* Set up structures needed to add the protocol subtree and manage it */
62 proto_tree *newmail_tree;
64 /* Make entries in Protocol column and Info column on summary display */
65 col_set_str(pinfo->cinfo, COL_PROTOCOL, "NEWMAIL");
67 col_set_str(pinfo->cinfo, COL_INFO, "Microsoft Exchange new mail notification");
70 ti = proto_tree_add_item(tree, proto_newmail, tvb, 0, -1, FALSE);
72 newmail_tree = proto_item_add_subtree(ti, ett_newmail);
74 proto_tree_add_item(newmail_tree, hf_newmail_payload, tvb, 0, 8, FALSE);
79 /* Register the protocol with Wireshark */
81 proto_register_newmail(void)
84 /* Setup list of header fields See Section 1.6.1 for details*/
85 static hf_register_info hf[] = {
86 { &hf_newmail_payload,
87 { "Notification payload", "newmail.notification_payload",
88 FT_BYTES, BASE_NONE, NULL, 0x0,
89 "Payload requested by client in the MAPI register push notification packet", HFILL }
93 /* Setup protocol subtree array */
94 static gint *ett[] = {
98 module_t *newmail_module;
100 /* Register the protocol name and description */
101 proto_newmail = proto_register_protocol("Microsoft Exchange New Mail Notification",
102 "NEWMAIL", "newmail");
104 /* Required function calls to register the header fields and subtrees used */
105 proto_register_field_array(proto_newmail, hf, array_length(hf));
106 proto_register_subtree_array(ett, array_length(ett));
108 /* Register the dissector without a port yet */
109 register_dissector("newmail", dissect_newmail, proto_newmail);
111 /* Register preferences module */
112 newmail_module = prefs_register_protocol(proto_newmail,
113 proto_reg_handoff_newmail);
115 prefs_register_uint_preference(newmail_module,
117 "Default UDP port (optional)",
118 "Always dissect this port's traffic as newmail notifications. Additional ports will be dynamically registered as they are seen in MAPI register push notification packets.",
119 10, &preference_default_port);
124 proto_reg_handoff_newmail(void)
126 static gboolean inited = FALSE;
127 static dissector_handle_t newmail_handle;
128 static guint preference_default_port_last;
131 newmail_handle = find_dissector("newmail");
132 dissector_add_handle("udp.port", newmail_handle); /* for 'decode-as' */
135 if (preference_default_port_last != 0) {
136 dissector_delete("udp.port", preference_default_port_last, newmail_handle);
140 if(preference_default_port != 0) {
141 dissector_add("udp.port", preference_default_port, newmail_handle);
143 preference_default_port_last = preference_default_port;