Update documentation about iptrace version support.
[metze/wireshark/wip.git] / packet-mapi.c
1 /* packet-mapi.c
2  * Routines for MSX mapi packet dissection
3  *
4  * $Id: packet-mapi.c,v 1.3 1999/11/21 11:04:11 deniel Exp $
5  *
6  * Ethereal - Network traffic analyzer
7  * By Gerald Combs <gerald@unicom.net>
8  * Copyright 1998 Gerald Combs
9  *
10  * Copied from packet-tftp.c
11  * 
12  * This program is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU General Public License
14  * as published by the Free Software Foundation; either version 2
15  * of the License, or (at your option) any later version.
16  * 
17  * This program is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20  * GNU General Public License for more details.
21  * 
22  * You should have received a copy of the GNU General Public License
23  * along with this program; if not, write to the Free Software
24  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
25  */
26
27 #ifdef HAVE_CONFIG_H
28 # include "config.h"
29 #endif
30
31 #include <stdio.h>
32
33 #ifdef HAVE_SYS_TYPES_H
34 # include <sys/types.h>
35 #endif
36
37 #ifdef HAVE_NETINET_IN_H
38 # include <netinet/in.h>
39 #endif
40
41 #include <string.h>
42 #include <glib.h>
43 #include "packet.h"
44
45 static int proto_mapi = -1;
46 static int hf_mapi_request = -1;
47 static int hf_mapi_response = -1;
48
49 static gint ett_mapi = -1;
50
51 void
52 dissect_mapi(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
53 {
54         proto_tree      *mapi_tree, *ti;
55
56         if (check_col(fd, COL_PROTOCOL))
57         col_add_str(fd, COL_PROTOCOL, "MAPI");
58
59         if (check_col(fd, COL_INFO))
60         {
61                 col_add_fstr(fd, COL_INFO, "%s", 
62                         (pi.match_port == pi.destport) ? "Request" : "Response");         
63         }
64
65         if (tree) 
66         {
67                 ti = proto_tree_add_item(tree, proto_mapi, offset, END_OF_FRAME, NULL);
68                 mapi_tree = proto_item_add_subtree(ti, ett_mapi);
69
70                 if (pi.match_port == pi.destport)
71                 {
72                         proto_tree_add_item_hidden(mapi_tree, hf_mapi_request,
73                                                    offset, END_OF_FRAME, TRUE);
74                         proto_tree_add_text(mapi_tree, offset, 
75                                 END_OF_FRAME, "Request: <opaque data>" );
76                 }
77                 else
78                 {
79                         proto_tree_add_item_hidden(mapi_tree, hf_mapi_response,
80                                                    offset, END_OF_FRAME, TRUE);
81                         proto_tree_add_text(mapi_tree, offset, 
82                                 END_OF_FRAME, "Response: <opaque data>");
83                 }
84         }
85 }
86
87 void
88 proto_register_mapi(void)
89 {
90         static hf_register_info hf[] = {
91           { &hf_mapi_response,
92             { "Response",           "mapi.response",
93               FT_BOOLEAN, BASE_NONE, NULL, 0x0,
94               "TRUE if MAPI response" }},
95           
96           { &hf_mapi_request,
97             { "Request",            "mapi.request",
98               FT_BOOLEAN, BASE_NONE, NULL, 0x0,
99               "TRUE if MAPI request" }}
100         };
101
102         static gint *ett[] = {
103                 &ett_mapi,
104         };
105         proto_mapi = proto_register_protocol("MAPI", "mapi");
106         proto_register_field_array(proto_mapi, hf, array_length(hf));
107         proto_register_subtree_array(ett, array_length(ett));
108 }