2001-12-23 21:36:58 +00:00
|
|
|
/* packet-klm.c 2001 Ronnie Sahlberg <See AUTHORS for email>
|
2001-04-20 18:37:53 +00:00
|
|
|
* Routines for klm dissection
|
|
|
|
*
|
2004-07-18 00:24:25 +00:00
|
|
|
* $Id$
|
2001-06-12 06:32:39 +00:00
|
|
|
*
|
2006-05-21 04:49:01 +00:00
|
|
|
* Wireshark - Network traffic analyzer
|
|
|
|
* By Gerald Combs <gerald@wireshark.org>
|
2001-04-20 18:37:53 +00:00
|
|
|
* Copyright 1998 Gerald Combs
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include "packet-rpc.h"
|
|
|
|
#include "packet-nfs.h"
|
|
|
|
#include "packet-klm.h"
|
|
|
|
|
|
|
|
static int proto_klm = -1;
|
2002-11-01 00:48:39 +00:00
|
|
|
static int hf_klm_procedure_v1 = -1;
|
2001-04-20 18:37:53 +00:00
|
|
|
static int hf_klm_exclusive = -1;
|
|
|
|
static int hf_klm_lock = -1;
|
|
|
|
static int hf_klm_servername = -1;
|
|
|
|
static int hf_klm_pid = -1;
|
|
|
|
static int hf_klm_offset = -1;
|
|
|
|
static int hf_klm_len = -1;
|
|
|
|
static int hf_klm_stats = -1;
|
|
|
|
static int hf_klm_holder = -1;
|
|
|
|
static int hf_klm_block = -1;
|
|
|
|
|
|
|
|
static gint ett_klm = -1;
|
|
|
|
static gint ett_klm_lock = -1;
|
|
|
|
static gint ett_klm_holder = -1;
|
|
|
|
|
2001-11-27 22:37:20 +00:00
|
|
|
static const value_string names_klm_stats[] =
|
2001-04-20 18:37:53 +00:00
|
|
|
{
|
|
|
|
#define KLM_GRANTED 0
|
|
|
|
{ KLM_GRANTED, "KLM_GRANTED" },
|
|
|
|
#define KLM_DENIED 1
|
|
|
|
{ KLM_DENIED, "KLM_DENIED" },
|
|
|
|
#define KLM_DENIED_NOLOCKS 2
|
|
|
|
{ KLM_DENIED_NOLOCKS, "KLM_DENIED_NOLOCKS" },
|
|
|
|
#define KLM_WORKING 3
|
|
|
|
{ KLM_WORKING, "KLM_WORKING" },
|
2001-11-27 22:37:20 +00:00
|
|
|
{ 0, NULL }
|
2001-04-20 18:37:53 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static int
|
2002-04-03 13:24:13 +00:00
|
|
|
dissect_holder(tvbuff_t *tvb, proto_tree *tree, int offset)
|
2001-04-20 18:37:53 +00:00
|
|
|
{
|
|
|
|
proto_item* lock_item = NULL;
|
|
|
|
proto_tree* lock_tree = NULL;
|
|
|
|
|
|
|
|
lock_item = proto_tree_add_item(tree, hf_klm_holder, tvb,
|
2002-01-24 09:20:54 +00:00
|
|
|
offset, -1, FALSE);
|
2001-04-20 18:37:53 +00:00
|
|
|
|
|
|
|
lock_tree = proto_item_add_subtree(lock_item, ett_klm_holder);
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
offset = dissect_rpc_bool( tvb, lock_tree,
|
2001-04-20 18:37:53 +00:00
|
|
|
hf_klm_exclusive, offset);
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
offset = dissect_rpc_uint32(tvb, lock_tree,
|
2001-04-20 18:37:53 +00:00
|
|
|
hf_klm_pid, offset);
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
offset = dissect_rpc_uint32(tvb, lock_tree,
|
2001-04-20 18:37:53 +00:00
|
|
|
hf_klm_offset, offset);
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
offset = dissect_rpc_uint32(tvb, lock_tree,
|
2001-04-20 18:37:53 +00:00
|
|
|
hf_klm_len, offset);
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|
2002-08-28 21:04:11 +00:00
|
|
|
|
2001-04-20 18:37:53 +00:00
|
|
|
static int
|
2002-04-03 13:24:13 +00:00
|
|
|
dissect_lock(tvbuff_t *tvb, packet_info* pinfo, proto_tree *tree, int offset)
|
2001-04-20 18:37:53 +00:00
|
|
|
{
|
|
|
|
proto_item* lock_item = NULL;
|
|
|
|
proto_tree* lock_tree = NULL;
|
|
|
|
|
|
|
|
lock_item = proto_tree_add_item(tree, hf_klm_lock, tvb,
|
2002-01-24 09:20:54 +00:00
|
|
|
offset, -1, FALSE);
|
2001-04-20 18:37:53 +00:00
|
|
|
|
|
|
|
lock_tree = proto_item_add_subtree(lock_item, ett_klm_lock);
|
|
|
|
|
2002-04-03 13:24:13 +00:00
|
|
|
offset = dissect_rpc_string(tvb, lock_tree,
|
2001-04-20 18:37:53 +00:00
|
|
|
hf_klm_servername, offset, NULL);
|
|
|
|
|
2003-08-17 21:34:22 +00:00
|
|
|
offset = dissect_nfs_fh3(tvb, offset, pinfo, lock_tree,"fh", NULL);
|
2001-04-20 18:37:53 +00:00
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
offset = dissect_rpc_uint32(tvb, lock_tree,
|
2001-04-20 18:37:53 +00:00
|
|
|
hf_klm_pid, offset);
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
offset = dissect_rpc_uint32(tvb, lock_tree,
|
2001-04-20 18:37:53 +00:00
|
|
|
hf_klm_offset, offset);
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
offset = dissect_rpc_uint32(tvb, lock_tree,
|
2001-04-20 18:37:53 +00:00
|
|
|
hf_klm_len, offset);
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
dissect_klm_unlock_call(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
|
|
|
offset = dissect_lock(tvb, pinfo, tree, offset);
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2002-04-03 13:24:13 +00:00
|
|
|
dissect_klm_stat_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
|
2001-04-20 18:37:53 +00:00
|
|
|
{
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
offset = dissect_rpc_uint32(tvb, tree,
|
2001-04-20 18:37:53 +00:00
|
|
|
hf_klm_stats, offset);
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
dissect_klm_lock_call(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
2002-08-28 21:04:11 +00:00
|
|
|
offset = dissect_rpc_bool( tvb, tree,
|
2001-04-20 18:37:53 +00:00
|
|
|
hf_klm_block, offset);
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
offset = dissect_rpc_bool( tvb, tree,
|
2001-04-20 18:37:53 +00:00
|
|
|
hf_klm_exclusive, offset);
|
|
|
|
|
|
|
|
offset = dissect_lock(tvb, pinfo, tree, offset);
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2002-04-03 13:24:13 +00:00
|
|
|
dissect_klm_test_reply(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_tree *tree)
|
2001-04-20 18:37:53 +00:00
|
|
|
{
|
|
|
|
gint32 stats;
|
|
|
|
|
|
|
|
stats = tvb_get_ntohl(tvb, offset);
|
|
|
|
|
2002-08-28 21:04:11 +00:00
|
|
|
offset = dissect_rpc_uint32(tvb, tree,
|
2001-04-20 18:37:53 +00:00
|
|
|
hf_klm_stats, offset);
|
|
|
|
|
|
|
|
if (stats == KLM_DENIED) {
|
2002-04-03 13:24:13 +00:00
|
|
|
offset = dissect_holder(tvb, tree, offset);
|
2001-04-20 18:37:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
dissect_klm_test_call(tvbuff_t *tvb, int offset, packet_info *pinfo, proto_tree *tree)
|
|
|
|
{
|
2002-08-28 21:04:11 +00:00
|
|
|
offset = dissect_rpc_bool( tvb, tree,
|
2001-04-20 18:37:53 +00:00
|
|
|
hf_klm_exclusive, offset);
|
|
|
|
|
|
|
|
offset = dissect_lock(tvb, pinfo, tree, offset);
|
|
|
|
|
|
|
|
return offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* proc number, "proc name", dissect_request, dissect_reply */
|
|
|
|
/* NULL as function pointer means: type of arguments is "void". */
|
|
|
|
static const vsff klm1_proc[] = {
|
|
|
|
{ KLMPROC_TEST, "TEST",
|
|
|
|
dissect_klm_test_call, dissect_klm_test_reply },
|
|
|
|
{ KLMPROC_LOCK, "LOCK",
|
|
|
|
dissect_klm_lock_call, dissect_klm_stat_reply },
|
|
|
|
{ KLMPROC_CANCEL, "CANCEL",
|
|
|
|
dissect_klm_lock_call, dissect_klm_stat_reply },
|
|
|
|
{ KLMPROC_UNLOCK, "UNLOCK",
|
|
|
|
dissect_klm_unlock_call, dissect_klm_stat_reply },
|
|
|
|
{ 0, NULL, NULL, NULL }
|
|
|
|
};
|
2002-11-01 00:48:39 +00:00
|
|
|
static const value_string klm1_proc_vals[] = {
|
|
|
|
{ KLMPROC_TEST, "TEST" },
|
|
|
|
{ KLMPROC_LOCK, "LOCK" },
|
|
|
|
{ KLMPROC_CANCEL, "CANCEL" },
|
|
|
|
{ KLMPROC_UNLOCK, "UNLOCK" },
|
|
|
|
{ 0, NULL}
|
|
|
|
};
|
2001-04-20 18:37:53 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
proto_register_klm(void)
|
|
|
|
{
|
|
|
|
static struct true_false_string tfs_exclusive = { "Exclusive", "Not exclusive" };
|
|
|
|
static struct true_false_string tfs_block = { "Block", "Do not block" };
|
|
|
|
|
|
|
|
static hf_register_info hf[] = {
|
2002-11-01 00:48:39 +00:00
|
|
|
{ &hf_klm_procedure_v1, {
|
|
|
|
"V1 Procedure", "klm.procedure_v1", FT_UINT32, BASE_DEC,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
VALS(klm1_proc_vals), 0, NULL, HFILL }},
|
2001-04-20 18:37:53 +00:00
|
|
|
{ &hf_klm_exclusive, {
|
|
|
|
"exclusive", "klm.exclusive", FT_BOOLEAN, BASE_NONE,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
TFS(&tfs_exclusive), 0x0, "Exclusive lock", HFILL }},
|
2001-04-20 18:37:53 +00:00
|
|
|
|
|
|
|
{ &hf_klm_lock, {
|
|
|
|
"lock", "klm.lock", FT_NONE, BASE_NONE,
|
2001-06-18 02:18:27 +00:00
|
|
|
NULL, 0, "KLM lock structure", HFILL }},
|
2001-04-20 18:37:53 +00:00
|
|
|
|
|
|
|
{ &hf_klm_servername, {
|
|
|
|
"server name", "klm.servername", FT_STRING, BASE_NONE,
|
2001-06-18 02:18:27 +00:00
|
|
|
NULL, 0, "Server name", HFILL }},
|
2001-04-20 18:37:53 +00:00
|
|
|
|
|
|
|
{ &hf_klm_pid, {
|
|
|
|
"pid", "klm.pid", FT_UINT32, BASE_DEC,
|
2001-06-18 02:18:27 +00:00
|
|
|
NULL, 0, "ProcessID", HFILL }},
|
2001-04-20 18:37:53 +00:00
|
|
|
|
|
|
|
{ &hf_klm_offset, {
|
|
|
|
"offset", "klm.offset", FT_UINT32, BASE_DEC,
|
2001-06-18 02:18:27 +00:00
|
|
|
NULL, 0, "File offset", HFILL }},
|
2001-04-20 18:37:53 +00:00
|
|
|
|
|
|
|
{ &hf_klm_len, {
|
|
|
|
"length", "klm.len", FT_UINT32, BASE_DEC,
|
2001-06-18 02:18:27 +00:00
|
|
|
NULL, 0, "Length of lock region", HFILL }},
|
2001-04-20 18:37:53 +00:00
|
|
|
|
|
|
|
{ &hf_klm_stats, {
|
|
|
|
"stats", "klm.stats", FT_UINT32, BASE_DEC,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
VALS(names_klm_stats), 0, NULL, HFILL }},
|
2001-04-20 18:37:53 +00:00
|
|
|
|
|
|
|
{ &hf_klm_holder, {
|
|
|
|
"holder", "klm.holder", FT_NONE, BASE_NONE,
|
2001-06-18 02:18:27 +00:00
|
|
|
NULL, 0, "KLM lock holder", HFILL }},
|
2001-04-20 18:37:53 +00:00
|
|
|
|
|
|
|
{ &hf_klm_block, {
|
|
|
|
"block", "klm.block", FT_BOOLEAN, BASE_NONE,
|
From Kovarththanan Rajaratnam via bug 3548:
(1) Trailing/leading spaces are removed from 'name's/'blurb's
(2) Duplicate 'blurb's are replaced with NULL
(3) Empty ("") 'blurb's are replaced with NULL
(4) BASE_NONE, NULL, 0x0 are used for 'display', 'strings' and 'bitmask' fields
for FT_NONE, FT_BYTES, FT_IPv4, FT_IPv6, FT_ABSOLUTE_TIME, FT_RELATIVE_TIME,
FT_PROTOCOL, FT_STRING and FT_STRINGZ field types
(5) Only allow non-zero value for 'display' if 'bitmask' is non-zero
svn path=/trunk/; revision=28770
2009-06-18 21:30:42 +00:00
|
|
|
TFS(&tfs_block), 0x0, "Block", HFILL }},
|
2001-04-20 18:37:53 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
static gint *ett[] = {
|
|
|
|
&ett_klm,
|
|
|
|
&ett_klm_lock,
|
|
|
|
&ett_klm_holder,
|
|
|
|
};
|
|
|
|
|
|
|
|
proto_klm = proto_register_protocol("Kernel Lock Manager",
|
|
|
|
"KLM", "klm");
|
|
|
|
proto_register_field_array(proto_klm, hf, array_length(hf));
|
|
|
|
proto_register_subtree_array(ett, array_length(ett));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
proto_reg_handoff_klm(void)
|
|
|
|
{
|
|
|
|
/* Register the protocol as RPC */
|
|
|
|
rpc_init_prog(proto_klm, KLM_PROGRAM, ett_klm);
|
|
|
|
/* Register the procedure tables */
|
2002-11-01 00:48:39 +00:00
|
|
|
rpc_init_proc_table(KLM_PROGRAM, 1, klm1_proc, hf_klm_procedure_v1);
|
2001-04-20 18:37:53 +00:00
|
|
|
}
|