2 * Routines for kpasswd packet dissection
7 * $Id: packet-kpasswd.c,v 1.2 2004/02/16 09:42:10 sahlberg Exp $
9 * Ethereal - Network traffic analyzer
10 * By Gerald Combs <gerald@ethereal.com>
11 * Copyright 1998 Gerald Combs
13 * This program is free software; you can redistribute it and/or
14 * modify it under the terms of the GNU General Public License
15 * as published by the Free Software Foundation; either version 2
16 * of the License, or (at your option) any later version.
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, write to the Free Software
25 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
32 #include <epan/packet.h>
33 #include "packet-kerberos.h"
36 static int proto_kpasswd = -1;
37 static int hf_kpasswd_message_len = -1;
38 static int hf_kpasswd_version = -1;
39 static int hf_kpasswd_ap_req_len = -1;
40 static int hf_kpasswd_ap_req_data = -1;
41 static int hf_kpasswd_krb_priv_message = -1;
43 static gint ett_kpasswd = -1;
44 static gint ett_ap_req_data = -1;
45 static gint ett_krb_priv_message = -1;
49 #define UDP_PORT_KPASSWD 464
52 static const value_string vers_vals[] = {
54 { 0xff80, "Request" },
60 dissect_kpasswd_ap_req_data(packet_info *pinfo _U_, tvbuff_t *tvb, proto_tree *parent_tree)
63 proto_tree *tree=NULL;
66 it=proto_tree_add_item(parent_tree, hf_kpasswd_ap_req_data, tvb, 0, -1, FALSE);
67 tree=proto_item_add_subtree(it, ett_ap_req_data);
69 dissect_kerberos_main(tvb, pinfo, tree, FALSE);
73 dissect_kpasswd_krb_priv_message(packet_info *pinfo _U_, tvbuff_t *tvb, proto_tree *parent_tree)
76 proto_tree *tree=NULL;
79 it=proto_tree_add_item(parent_tree, hf_kpasswd_krb_priv_message, tvb, 0, -1, FALSE);
80 tree=proto_item_add_subtree(it, ett_krb_priv_message);
82 dissect_kerberos_main(tvb, pinfo, tree, FALSE);
87 dissect_kpasswd(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
89 proto_item *kpasswd_item;
90 proto_tree *kpasswd_tree=NULL;
92 guint16 message_len, version, ap_req_len;
95 if (check_col(pinfo->cinfo, COL_PROTOCOL))
96 col_set_str(pinfo->cinfo, COL_PROTOCOL, "KPASSWD");
97 if (check_col(pinfo->cinfo, COL_INFO))
98 col_clear(pinfo->cinfo, COL_INFO);
100 message_len=tvb_get_ntohs(tvb, offset);
101 version=tvb_get_ntohs(tvb, offset+2);
102 ap_req_len=tvb_get_ntohs(tvb, offset+4);
104 kpasswd_item=proto_tree_add_item(tree, proto_kpasswd, tvb, offset, message_len, FALSE);
105 kpasswd_tree=proto_item_add_subtree(kpasswd_item, ett_kpasswd);
108 proto_tree_add_uint(kpasswd_tree, hf_kpasswd_message_len, tvb, offset, 2, message_len);
109 proto_tree_add_uint(kpasswd_tree, hf_kpasswd_version, tvb, offset+2, 2, version);
110 if (check_col(pinfo->cinfo, COL_INFO))
111 col_set_str(pinfo->cinfo, COL_INFO, val_to_str(version, vers_vals, "Unknown command"));
112 proto_tree_add_uint(kpasswd_tree, hf_kpasswd_ap_req_len, tvb, offset+4, 2, ap_req_len);
116 next_tvb=tvb_new_subset(tvb, offset, ap_req_len, ap_req_len);
117 dissect_kpasswd_ap_req_data(pinfo, next_tvb, kpasswd_tree);
120 /* KRB-PRIB message */
121 next_tvb=tvb_new_subset(tvb, offset, -1, -1);
122 dissect_kpasswd_krb_priv_message(pinfo, next_tvb, kpasswd_tree);
128 proto_register_kpasswd(void)
130 static hf_register_info hf[] = {
131 { &hf_kpasswd_message_len,
132 { "Message Length", "kpasswd.message_len", FT_UINT16, BASE_DEC,
133 NULL, 0, "Message Length", HFILL }},
134 { &hf_kpasswd_ap_req_len,
135 { "AP_REQ Length", "kpasswd.ap_req_len", FT_UINT16, BASE_DEC,
136 NULL, 0, "Length of AP_REQ data", HFILL }},
137 { &hf_kpasswd_version,
138 { "Version", "kpasswd.version", FT_UINT16, BASE_HEX,
139 VALS(vers_vals), 0, "Version", HFILL }},
140 { &hf_kpasswd_ap_req_data,
141 { "AP_REQ", "kpasswd.ap_req", FT_NONE, BASE_NONE,
142 NULL, 0, "AP_REQ structure", HFILL }},
143 { &hf_kpasswd_krb_priv_message,
144 { "KRB-PRIV", "kpasswd.krb_priv", FT_NONE, BASE_NONE,
145 NULL, 0, "KRB-PRIV message", HFILL }},
148 static gint *ett[] = {
151 &ett_krb_priv_message,
154 proto_kpasswd = proto_register_protocol("MS Kpasswd",
155 "Kpasswd", "kpasswd");
156 proto_register_field_array(proto_kpasswd, hf, array_length(hf));
157 proto_register_subtree_array(ett, array_length(ett));
161 proto_reg_handoff_kpasswd(void)
163 dissector_handle_t kpasswd_handle;
165 kpasswd_handle = create_dissector_handle(dissect_kpasswd, proto_kpasswd);
166 dissector_add("udp.port", UDP_PORT_KPASSWD, kpasswd_handle);