removed some gcc warnings (hopefully)
[obnox/wireshark/wip.git] / epan / dissectors / packet-aim-admin.c
1 /* packet-aim-admin.c
2  * Routines for AIM (OSCAR) dissection, Administration Service
3  * Copyright 2004, Jelmer Vernooij <jelmer@samba.org>
4  *
5  * $Id$
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 <stdio.h>
31 #include <stdlib.h>
32 #include <string.h>
33 #include <ctype.h>
34
35 #include <glib.h>
36
37 #include <epan/packet.h>
38 #include <epan/strutil.h>
39
40 #include "packet-aim.h"
41
42 #define FAMILY_ADMIN      0x0007
43
44 #define CONFIRM_STATUS_EMAIL_SENT                0x00
45 #define CONFIRM_STATUS_ALREADY_CONFIRMED 0x1E
46 #define CONFIRM_STATUS_SERVER_ERROR          0x23
47
48 static const value_string confirm_statusses[] = {
49         { CONFIRM_STATUS_EMAIL_SENT, "A confirmation email has been sent" },
50         { CONFIRM_STATUS_ALREADY_CONFIRMED, "Account was already confirmed" },
51         { CONFIRM_STATUS_SERVER_ERROR, "Server couldn't start confirmation process" },
52         { 0, NULL }
53 };
54
55 /* Initialize the protocol and registered fields */
56 static int proto_aim_admin = -1;
57 static int hf_admin_acctinfo_code = -1;
58 static int hf_admin_acctinfo_permissions = -1;
59 static int hf_admin_confirm_status = -1;
60
61 /* Initialize the subtree pointers */
62 static gint ett_aim_admin          = -1;
63
64 static int dissect_aim_admin_accnt_info_req(tvbuff_t *tvb, packet_info *pinfo _U_, proto_tree *admin_tree) 
65 {
66         proto_tree_add_item(admin_tree, hf_admin_acctinfo_code, tvb, 0, 2, tvb_get_ntohs(tvb, 0)); 
67         proto_tree_add_text(admin_tree, tvb, 2, 2, "Unknown");
68         return 4;
69 }
70
71 static int dissect_aim_admin_accnt_info_repl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *admin_tree) 
72 {
73         int offset = 0;
74         proto_tree_add_uint(admin_tree, hf_admin_acctinfo_permissions, tvb, offset, 2, tvb_get_ntohs(tvb, offset)); offset+=2;
75         return dissect_aim_tlv_list(tvb, pinfo, offset, admin_tree, client_tlvs);
76 }
77
78 static int dissect_aim_admin_info_change_req(tvbuff_t *tvb, packet_info *pinfo, proto_tree *admin_tree) 
79 {
80         return dissect_aim_tlv_sequence(tvb, pinfo, 0, admin_tree, client_tlvs);
81 }
82
83 static int dissect_aim_admin_cfrm_repl(tvbuff_t *tvb, packet_info *pinfo, proto_tree *admin_tree) 
84 {
85         int offset = 0; 
86         proto_tree_add_uint(admin_tree, hf_admin_confirm_status, tvb, offset, 2, tvb_get_ntohs(tvb, offset)); offset+=2;
87         return dissect_aim_tlv_sequence(tvb, pinfo, offset, admin_tree, client_tlvs);
88 }
89
90 static const aim_subtype aim_fnac_family_admin[] = {
91   { 0x0001, "Error", dissect_aim_snac_error },
92   { 0x0002, "Request Account Information", dissect_aim_admin_accnt_info_req },
93   { 0x0003, "Requested Account Information", dissect_aim_admin_accnt_info_repl },
94   { 0x0004, "Infochange Request", dissect_aim_admin_info_change_req },
95   { 0x0005, "Infochange Reply", dissect_aim_admin_accnt_info_repl },
96   { 0x0006, "Account Confirm Request", NULL },
97   { 0x0007, "Account Confirm Reply", dissect_aim_admin_cfrm_repl},
98   { 0, NULL, NULL }
99 };
100
101 /* Register the protocol with Ethereal */
102 void
103 proto_register_aim_admin(void)
104 {
105
106 /* Setup list of header fields */
107   static hf_register_info hf[] = {
108           { &hf_admin_acctinfo_code,
109                   { "Account Information Request Code", "aim.acctinfo.code", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL },
110           },
111           { &hf_admin_acctinfo_permissions,
112                   { "Account Permissions", "aim.acctinfo.permissions", FT_UINT16, BASE_HEX, NULL, 0x0, "", HFILL },
113           }, 
114           { &hf_admin_confirm_status,
115                   { "Confirmation status", "admin.confirm_status", FT_UINT16, BASE_HEX, VALS(confirm_statusses), 0x0, "", HFILL },
116                                                                                                                                                                          },
117   };
118
119 /* Setup protocol subtree array */
120   static gint *ett[] = {
121     &ett_aim_admin,
122   };
123
124 /* Register the protocol name and description */
125   proto_aim_admin = proto_register_protocol("AIM Administrative", "AIM Administration", "aim_admin");
126
127 /* Required function calls to register the header fields and subtrees used */
128   proto_register_field_array(proto_aim_admin, hf, array_length(hf));
129   proto_register_subtree_array(ett, array_length(ett));
130 }
131
132 void
133 proto_reg_handoff_aim_admin(void)
134 {
135   aim_init_family(proto_aim_admin, ett_aim_admin, FAMILY_ADMIN, aim_fnac_family_admin);
136 }