2 * Routines for cisco tacacs/tacplus/AAA packet dissection
4 * $Id: packet-tacacs.c,v 1.9 2001/01/03 06:55:33 guy Exp $
6 * Ethereal - Network traffic analyzer
7 * By Gerald Combs <gerald@zing.org>
8 * Copyright 1998 Gerald Combs
10 * Copied from packet-tftp.c
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.
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.
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.
33 #ifdef HAVE_SYS_TYPES_H
34 # include <sys/types.h>
37 #ifdef HAVE_NETINET_IN_H
38 # include <netinet/in.h>
45 static int proto_tacacs = -1;
46 static int hf_tacacs_request = -1;
47 static int hf_tacacs_response = -1;
48 static int hf_tacacs_version = -1;
50 static gint ett_tacacs = -1;
52 #define UDP_PORT_TACACS 49
53 #define TCP_PORT_TACACS 49
56 dissect_tacacs(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
58 proto_tree *tacacs_tree, *ti;
60 OLD_CHECK_DISPLAY_AS_DATA(proto_tacacs, pd, offset, fd, tree);
62 if (check_col(fd, COL_PROTOCOL))
63 col_set_str(fd, COL_PROTOCOL, "TACACS");
65 if (check_col(fd, COL_INFO))
67 col_add_fstr(fd, COL_INFO, "%s",
68 (pi.match_port == pi.destport) ? "Request" : "Response");
73 ti = proto_tree_add_item(tree, proto_tacacs, NullTVB, offset, END_OF_FRAME, FALSE);
74 tacacs_tree = proto_item_add_subtree(ti, ett_tacacs);
76 proto_tree_add_string(tacacs_tree, hf_tacacs_version, NullTVB, 0, 0, "XTacacs");
78 if (pi.match_port == pi.destport)
80 proto_tree_add_boolean_hidden(tacacs_tree, hf_tacacs_request, NullTVB,
81 offset, END_OF_FRAME, TRUE);
82 proto_tree_add_text(tacacs_tree, NullTVB, offset,
83 END_OF_FRAME, "Request: <opaque data>" );
87 proto_tree_add_boolean_hidden(tacacs_tree, hf_tacacs_response, NullTVB,
88 offset, END_OF_FRAME, TRUE);
89 proto_tree_add_text(tacacs_tree, NullTVB, offset,
90 END_OF_FRAME, "Response: <opaque data>");
96 dissect_tacplus(const u_char *pd, int offset, frame_data *fd, proto_tree *tree)
98 proto_tree *tacacs_tree, *ti;
100 if (check_col(fd, COL_PROTOCOL))
101 col_set_str(fd, COL_PROTOCOL, "TACACS");
103 if (check_col(fd, COL_INFO))
105 col_add_fstr(fd, COL_INFO, "%s",
106 (pi.match_port == pi.destport) ? "Request" : "Response");
111 ti = proto_tree_add_item(tree, proto_tacacs, NullTVB, offset, END_OF_FRAME, FALSE);
112 tacacs_tree = proto_item_add_subtree(ti, ett_tacacs);
114 proto_tree_add_string(tacacs_tree, hf_tacacs_version, NullTVB, 0, 0, "Tacacs+");
116 if (pi.match_port == pi.destport)
118 proto_tree_add_boolean_hidden(tacacs_tree, hf_tacacs_request, NullTVB,
119 offset, END_OF_FRAME, TRUE);
120 proto_tree_add_text(tacacs_tree, NullTVB, offset,
121 END_OF_FRAME, "Request: <opaque data>" );
125 proto_tree_add_boolean_hidden(tacacs_tree, hf_tacacs_response, NullTVB,
126 offset, END_OF_FRAME, TRUE);
127 proto_tree_add_text(tacacs_tree, NullTVB, offset,
128 END_OF_FRAME, "Response: <opaque data>");
134 proto_register_tacacs(void)
136 static hf_register_info hf[] = {
137 { &hf_tacacs_version,
138 { "Tacacs Version", "tacacs.version",
139 FT_STRING, BASE_NONE, NULL, 0x0,
140 "xtacacs or tacplus" }},
141 { &hf_tacacs_response,
142 { "Response", "tacacs.response",
143 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
144 "TRUE if TACACS response" }},
145 { &hf_tacacs_request,
146 { "Request", "tacacs.request",
147 FT_BOOLEAN, BASE_NONE, NULL, 0x0,
148 "TRUE if TACACS request" }}
151 static gint *ett[] = {
154 proto_tacacs = proto_register_protocol("TACACS", "TACACS", "tacacs");
155 proto_register_field_array(proto_tacacs, hf, array_length(hf));
156 proto_register_subtree_array(ett, array_length(ett));
160 proto_reg_handoff_tacacs(void)
162 old_dissector_add("udp.port", UDP_PORT_TACACS, dissect_tacacs);
163 old_dissector_add("tcp.port", TCP_PORT_TACACS, dissect_tacplus);