Escape backslashes in strings when generating the dfilter representation
[metze/wireshark/wip.git] / packet-dcerpc-messenger.c
1 /* packet-dcerpc-messenger.c
2  * Routines for SMB \PIPE\messenger packet disassembly
3  * Copyright 2003 Ronnie Sahlberg
4  *
5  * $Id: packet-dcerpc-messenger.c,v 1.3 2003/06/26 10:31:18 sahlberg Exp $
6  *
7  * Ethereal - Network traffic analyzer
8  * By Gerald Combs <gerald@ethereal.com>
9  * Copyright 1998 Gerald Combs
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License
13  * as published by the Free Software Foundation; either version 2
14  * of the License, or (at your option) any later version.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
24  */
25
26 #ifdef HAVE_CONFIG_H
27 #include "config.h"
28 #endif
29
30 #include <glib.h>
31 #include "prefs.h"
32 #include "packet-dcerpc.h"
33 #include "packet-dcerpc-nt.h"
34 #include "smb.h"
35
36
37 static int proto_dcerpc_messenger = -1;
38 static int hf_messenger_opnum = -1;
39 static int hf_messenger_rc = -1;
40 static int hf_messenger_server = -1;
41 static int hf_messenger_client = -1;
42 static int hf_messenger_message = -1;
43
44 static gint ett_dcerpc_messenger = -1;
45
46 static e_uuid_t uuid_dcerpc_messenger = {
47         0x5a7b91f8, 0xff00, 0x11d0,
48         { 0xa9, 0xb2, 0x00, 0xc0, 0x4f, 0xb6, 0xe6, 0xfc}
49 };
50
51 static guint16 ver_dcerpc_messenger = 1;
52
53
54
55 /*
56  * IDL  [in][string][ref] char *server;
57  * IDL  [in][string][ref] char *client;
58  * IDL  [in][string][ref] char *message;
59  */
60 static int
61 messenger_dissect_send_message_rqst(tvbuff_t *tvb, int offset, packet_info *pinfo,
62                             proto_tree *tree, char *drep)
63 {
64         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
65                         dissect_ndr_char_cvstring, NDR_POINTER_REF,
66                         "Server", hf_messenger_server);
67         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
68                         dissect_ndr_char_cvstring, NDR_POINTER_REF,
69                         "Client", hf_messenger_client);
70         offset = dissect_ndr_pointer(tvb, offset, pinfo, tree, drep,
71                         dissect_ndr_char_cvstring, NDR_POINTER_REF,
72                         "Message", hf_messenger_message);
73
74
75         return offset;
76 }
77 static int
78 messenger_dissect_send_message_reply(tvbuff_t *tvb, int offset, packet_info *pinfo,
79                             proto_tree *tree, char *drep)
80 {
81         offset = dissect_ntstatus(tvb, offset, pinfo, tree, drep,
82                                   hf_messenger_rc, NULL);
83
84         return offset;
85 }
86
87
88
89 static dcerpc_sub_dissector dcerpc_messenger_dissectors[] = {
90         {0, "SendMessage", 
91                 messenger_dissect_send_message_rqst,
92                 messenger_dissect_send_message_reply },
93         {0, NULL, NULL,  NULL }
94 };
95
96 void
97 proto_register_dcerpc_messenger(void)
98 {
99         static hf_register_info hf[] = {
100
101                 { &hf_messenger_opnum,
102                   { "Operation", "messenger.opnum", FT_UINT16, BASE_DEC,
103                     NULL, 0x0, "Operation", HFILL }},
104
105                 { &hf_messenger_rc,
106                   { "Return code", "messenger.rc", FT_UINT32, BASE_HEX, VALS (NT_errors), 0x0, "", HFILL }},
107
108                 { &hf_messenger_server, {
109                 "Server", "messenger.server", 
110                 FT_STRING, BASE_NONE, NULL, 0, "Server to send the message to", HFILL }},
111
112                 { &hf_messenger_client, {
113                 "Client", "messenger.client", 
114                 FT_STRING, BASE_NONE, NULL, 0, "Client that sent the message", HFILL }},
115
116                 { &hf_messenger_message, {
117                 "Message", "messenger.message", 
118                 FT_STRING, BASE_NONE, NULL, 0, "The message being sent", HFILL }}
119
120         };
121
122         static gint *ett[] = {
123                 &ett_dcerpc_messenger
124         };
125
126         proto_dcerpc_messenger = proto_register_protocol(
127                 "Microsoft Messenger Service", "Messenger", "messenger");
128
129         proto_register_field_array (proto_dcerpc_messenger, hf, array_length (hf));
130         proto_register_subtree_array(ett, array_length(ett));
131
132 }
133
134 void
135 proto_reg_handoff_dcerpc_messenger(void)
136 {
137         header_field_info *hf_info;
138
139         /* Register protocol as dcerpc */
140
141         dcerpc_init_uuid(proto_dcerpc_messenger, ett_dcerpc_messenger, &uuid_dcerpc_messenger,
142                          ver_dcerpc_messenger, dcerpc_messenger_dissectors, hf_messenger_opnum);
143
144         /* Set opnum strings from subdissector list */
145
146         hf_info = proto_registrar_get_nth(hf_messenger_opnum);
147         hf_info->strings = value_string_from_subdissectors(
148                 dcerpc_messenger_dissectors, array_length(dcerpc_messenger_dissectors));
149 }