diff options
author | Richard Sharpe <sharpe@ns.aus.com> | 2003-05-21 02:48:40 +0000 |
---|---|---|
committer | Richard Sharpe <sharpe@ns.aus.com> | 2003-05-21 02:48:40 +0000 |
commit | 413228f1094beac433d54ce356956652e7405393 (patch) | |
tree | 05c5654d006d0babfdce0902b03d6cdca2affba4 | |
parent | 3d6518224514e715d367bbf22e768bdef10ec89b (diff) | |
download | wireshark-413228f1094beac433d54ce356956652e7405393.tar.gz wireshark-413228f1094beac433d54ce356956652e7405393.tar.bz2 wireshark-413228f1094beac433d54ce356956652e7405393.zip |
Make dissect_rpc_opaque_data available and allow it to take a dissection
routine ...
I am not happy with the signature for it as yet, though.
svn path=/trunk/; revision=7702
-rw-r--r-- | packet-nfs.h | 4 | ||||
-rw-r--r-- | packet-rpc.c | 138 | ||||
-rw-r--r-- | packet-rpc.h | 9 |
3 files changed, 91 insertions, 60 deletions
diff --git a/packet-nfs.h b/packet-nfs.h index bbc63c7ddf..0ba41c97e9 100644 --- a/packet-nfs.h +++ b/packet-nfs.h @@ -1,5 +1,5 @@ /* packet-nfs.h (c) 1999 Uwe Girlich */ -/* $Id: packet-nfs.h,v 1.13 2003/04/01 04:38:05 guy Exp $ */ +/* $Id: packet-nfs.h,v 1.14 2003/05/21 02:48:40 sharpe Exp $ */ #ifndef __PACKET_NFS_H__ #define __PACKET_NFS_H__ @@ -118,5 +118,7 @@ typedef struct nfs_fhandle_data { } nfs_fhandle_data_t; void dissect_fhandle_hidden(packet_info *pinfo, proto_tree *tree, nfs_fhandle_data_t *nfd); +typedef int (diss_p)(tvbuff_t *tvb, int offset, proto_tree *tree, int hf); + #endif /* packet-nfs.h */ diff --git a/packet-rpc.c b/packet-rpc.c index cf62e7f68d..bab78f0831 100644 --- a/packet-rpc.c +++ b/packet-rpc.c @@ -2,7 +2,7 @@ * Routines for rpc dissection * Copyright 1999, Uwe Girlich <Uwe.Girlich@philosys.de> * - * $Id: packet-rpc.c,v 1.126 2003/05/20 07:56:46 guy Exp $ + * $Id: packet-rpc.c,v 1.127 2003/05/21 02:48:40 sharpe Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@ethereal.com> @@ -493,12 +493,18 @@ int hfindex, int offset) return offset + 8; } - -static int +/* + * We want to make this function available outside this file and + * allow callers to pass a dissection function for the opaque data + */ +int dissect_rpc_opaque_data(tvbuff_t *tvb, int offset, - proto_tree *tree, int hfindex, + proto_tree *tree, + packet_info *pinfo, + int hfindex, gboolean fixed_length, guint32 length, - gboolean string_data, char **string_buffer_ret) + gboolean string_data, char **string_buffer_ret, + dissect_function_t *dissect_it) { proto_item *string_item = NULL; proto_tree *string_tree = NULL; @@ -573,6 +579,22 @@ dissect_rpc_opaque_data(tvbuff_t *tvb, int offset, fill_truncated = 0; } } + + /* + * If we were passed a dissection routine, make a TVB of the data + * and call the dissection routine + */ + + if (dissect_it) { + tvbuff_t *opaque_tvb; + + opaque_tvb = tvb_new_subset(tvb, offset, + (fixed_length?offset:(offset + 4)), string_length_copy); + + return (*dissect_it)(opaque_tvb, offset, pinfo, tree); + + } + string_buffer = (char*)g_malloc(string_length_copy + (string_data ? 1 : 0)); if (fixed_length) @@ -689,8 +711,8 @@ int dissect_rpc_string(tvbuff_t *tvb, proto_tree *tree, int hfindex, int offset, char **string_buffer_ret) { - offset = dissect_rpc_opaque_data(tvb, offset, tree, - hfindex, FALSE, 0, TRUE, string_buffer_ret); + offset = dissect_rpc_opaque_data(tvb, offset, tree, NULL, + hfindex, FALSE, 0, TRUE, string_buffer_ret, NULL); return offset; } @@ -699,8 +721,8 @@ int dissect_rpc_data(tvbuff_t *tvb, proto_tree *tree, int hfindex, int offset) { - offset = dissect_rpc_opaque_data(tvb, offset, tree, - hfindex, FALSE, 0, FALSE, NULL); + offset = dissect_rpc_opaque_data(tvb, offset, tree, NULL, + hfindex, FALSE, 0, FALSE, NULL, NULL); return offset; } @@ -710,8 +732,8 @@ dissect_rpc_bytes(tvbuff_t *tvb, proto_tree *tree, int hfindex, int offset, guint32 length, gboolean string_data, char **string_buffer_ret) { - offset = dissect_rpc_opaque_data(tvb, offset, tree, - hfindex, TRUE, length, string_data, string_buffer_ret); + offset = dissect_rpc_opaque_data(tvb, offset, tree, NULL, + hfindex, TRUE, length, string_data, string_buffer_ret, NULL); return offset; } @@ -999,11 +1021,54 @@ dissect_rpc_cred(tvbuff_t* tvb, proto_tree* tree, int offset) return offset; } +/* + * XDR opaque object, the contents of which are interpreted as a GSS-API + * token. + */ +static int +dissect_rpc_authgss_token(tvbuff_t* tvb, proto_tree* tree, int offset, + packet_info *pinfo) +{ + guint32 opaque_length, rounded_length; + gint len_consumed, length, reported_length; + tvbuff_t *new_tvb; + + proto_item *gitem; + proto_tree *gtree = NULL; + + opaque_length = tvb_get_ntohl(tvb, offset+0); + rounded_length = rpc_roundup(opaque_length); + if (tree) { + gitem = proto_tree_add_text(tree, tvb, offset, + 4+rounded_length, "GSS Token"); + gtree = proto_item_add_subtree(gitem, ett_rpc_gss_token); + proto_tree_add_uint(gtree, hf_rpc_authgss_token_length, + tvb, offset+0, 4, opaque_length); + } + offset += 4; + length = tvb_length_remaining(tvb, offset); + reported_length = tvb_reported_length_remaining(tvb, offset); + g_assert(length >= 0); + g_assert(reported_length >= 0); + if (length > reported_length) + length = reported_length; + if ((guint32)length > opaque_length) + length = opaque_length; + if ((guint32)reported_length > opaque_length) + reported_length = opaque_length; + new_tvb = tvb_new_subset(tvb, offset, length, reported_length); + len_consumed = call_dissector(gssapi_handle, new_tvb, pinfo, gtree); + offset += len_consumed; + + return offset; +} + /* AUTH_DES verifiers are asymmetrical, so we need to know what type of * verifier we're decoding (CALL or REPLY). */ static int -dissect_rpc_verf(tvbuff_t* tvb, proto_tree* tree, int offset, int msg_type) +dissect_rpc_verf(tvbuff_t* tvb, proto_tree* tree, int offset, int msg_type, + packet_info *pinfo) { guint flavor; guint length; @@ -1055,8 +1120,7 @@ dissect_rpc_verf(tvbuff_t* tvb, proto_tree* tree, int offset, int msg_type) } break; case RPCSEC_GSS: - dissect_rpc_data(tvb, vtree, - hf_rpc_authgss_checksum, offset+4); + dissect_rpc_authgss_token(tvb, vtree, offset+4, pinfo); break; default: proto_tree_add_uint(vtree, hf_rpc_auth_length, tvb, @@ -1072,48 +1136,6 @@ dissect_rpc_verf(tvbuff_t* tvb, proto_tree* tree, int offset, int msg_type) return offset; } -/* - * XDR opaque object, the contents of which are interpreted as a GSS-API - * token. - */ -static int -dissect_rpc_authgss_token(tvbuff_t* tvb, proto_tree* tree, int offset, - packet_info *pinfo) -{ - guint32 opaque_length, rounded_length; - gint length, reported_length; - tvbuff_t *new_tvb; - - proto_item *gitem; - proto_tree *gtree = NULL; - - opaque_length = tvb_get_ntohl(tvb, offset+0); - rounded_length = rpc_roundup(opaque_length); - if (tree) { - gitem = proto_tree_add_text(tree, tvb, offset, - 4+rounded_length, "GSS Token"); - gtree = proto_item_add_subtree(gitem, ett_rpc_gss_token); - proto_tree_add_uint(gtree, hf_rpc_authgss_token_length, - tvb, offset+0, 4, opaque_length); - } - offset += 4; - length = tvb_length_remaining(tvb, offset); - reported_length = tvb_reported_length_remaining(tvb, offset); - g_assert(length >= 0); - g_assert(reported_length >= 0); - if (length > reported_length) - length = reported_length; - if ((guint32)length > opaque_length) - length = opaque_length; - if ((guint32)reported_length > opaque_length) - reported_length = opaque_length; - new_tvb = tvb_new_subset(tvb, offset, length, reported_length); - call_dissector(gssapi_handle, new_tvb, pinfo, gtree); - offset += rounded_length; - - return offset; -} - static int dissect_rpc_authgss_initarg(tvbuff_t* tvb, proto_tree* tree, int offset, packet_info *pinfo) @@ -2021,7 +2043,7 @@ dissect_rpc_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, offset += 16; offset = dissect_rpc_cred(tvb, rpc_tree, offset); - offset = dissect_rpc_verf(tvb, rpc_tree, offset, msg_type); + offset = dissect_rpc_verf(tvb, rpc_tree, offset, msg_type, pinfo); /* pass rpc_info to subdissectors */ rpc_call->request=TRUE; @@ -2162,7 +2184,7 @@ dissect_rpc_message(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, switch (reply_state) { case MSG_ACCEPTED: - offset = dissect_rpc_verf(tvb, rpc_tree, offset, msg_type); + offset = dissect_rpc_verf(tvb, rpc_tree, offset, msg_type, pinfo); accept_state = tvb_get_ntohl(tvb,offset+0); if (rpc_tree) { proto_tree_add_uint(rpc_tree, hf_rpc_state_accept, tvb, diff --git a/packet-rpc.h b/packet-rpc.h index e0644fea0d..35a5f6b659 100644 --- a/packet-rpc.h +++ b/packet-rpc.h @@ -1,6 +1,6 @@ /* packet-rpc.h * - * $Id: packet-rpc.h,v 1.41 2003/05/02 21:58:23 guy Exp $ + * $Id: packet-rpc.h,v 1.42 2003/05/21 02:48:40 sharpe Exp $ * * (c) 1999 Uwe Girlich * @@ -127,6 +127,13 @@ extern int dissect_rpc_bool(tvbuff_t *tvb, proto_tree *tree, int hfindex, int offset); extern int dissect_rpc_string(tvbuff_t *tvb, proto_tree *tree, int hfindex, int offset, char **string_buffer_ret); +int dissect_rpc_opaque_data(tvbuff_t *tvb, int offset, + proto_tree *tree, + packet_info *pinfo, + int hfindex, + gboolean fixed_length, guint32 length, + gboolean string_data, char **string_buffer_ret, + dissect_function_t *dissect_it); extern int dissect_rpc_data(tvbuff_t *tvb, proto_tree *tree, int hfindex, int offset); extern int dissect_rpc_bytes(tvbuff_t *tvb, |