diff options
author | Nathan Neulinger <nneul@umr.edu> | 1999-11-11 16:20:25 +0000 |
---|---|---|
committer | Nathan Neulinger <nneul@umr.edu> | 1999-11-11 16:20:25 +0000 |
commit | 6043b610ed2bce00a511a70f441da68dab5a17b7 (patch) | |
tree | 7637eb730d1eefaa6ebe8fa760810c9419842c26 /packet-bootparams.c | |
parent | 76710fcc54eff453da0ce1118b1368b8dd144bd4 (diff) | |
download | wireshark-6043b610ed2bce00a511a70f441da68dab5a17b7.tar.gz wireshark-6043b610ed2bce00a511a70f441da68dab5a17b7.tar.bz2 wireshark-6043b610ed2bce00a511a70f441da68dab5a17b7.zip |
Expanded bootparams dissector to handle decoding getfile calls and replies.
Added proto_registrar_get_name routine to proto.c to retrieve the name
of particular proto_tree field.
Added dissect_rpc_string_item to packet-rpc.c. This routine does the same
thing as dissect_rpc_string, except it takes a hfindex of a
proto_tree item instead of a name. It uses the p_r_get_name call
to get the name, and adds the actual string content as a hidden
field (so that the subtree highlights the entire data area - length,
data, and padding). There is only one call to dissect_rpc_string, so
I believe that this routine should replace it.
svn path=/trunk/; revision=1011
Diffstat (limited to 'packet-bootparams.c')
-rw-r--r-- | packet-bootparams.c | 94 |
1 files changed, 88 insertions, 6 deletions
diff --git a/packet-bootparams.c b/packet-bootparams.c index 434dafab78..2d90e99f05 100644 --- a/packet-bootparams.c +++ b/packet-bootparams.c @@ -1,7 +1,7 @@ /* packet-bootparams.c * Routines for bootparams dissection * - * $Id: packet-bootparams.c,v 1.2 1999/11/10 21:05:09 nneul Exp $ + * $Id: packet-bootparams.c,v 1.3 1999/11/11 16:20:24 nneul Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs <gerald@unicom.net> @@ -28,24 +28,87 @@ #include "config.h" #endif - #ifdef HAVE_SYS_TYPES_H #include <sys/types.h> #endif +#ifdef HAVE_NETINET_IN_H +# include <netinet/in.h> +#endif + +#include <string.h> +#include <glib.h> #include "packet-rpc.h" #include "packet-bootparams.h" static int proto_bootparams = -1; +static int hf_bootparams_host = -1; +static int hf_bootparams_fileid = -1; +static int hf_bootparams_filepath = -1; +static int hf_bootparams_addresstype = -1; +static int hf_bootparams_address = -1; + +/* Dissect a getfile call */ +int dissect_getfile_call(const u_char *pd, int offset, frame_data *fd, + proto_tree *tree) +{ + if ( tree ) + { + offset = dissect_rpc_string_item(pd,offset,fd,tree,hf_bootparams_host); + offset = dissect_rpc_string_item(pd,offset,fd,tree,hf_bootparams_fileid); + } + + return offset; +} + +/* Dissect a getfile reply */ +int dissect_getfile_reply(const u_char *pd, int offset, frame_data *fd, + proto_tree *tree) +{ + guint32 type; + guint32 ipaddr; + + if ( tree ) + { + offset = dissect_rpc_string_item(pd,offset,fd,tree,hf_bootparams_host); + + /* get the address type */ + if ( !BYTES_ARE_IN_FRAME(offset, 1)) return offset; + type = pntohl(&pd[offset]); /* type of address */ + proto_tree_add_item(tree, hf_bootparams_addresstype, + offset, 4, type); + offset += 4; + + if ( type != 1 ) /* only know how to handle this type of address */ + { + return offset; + } + + /* get the address itself - weird ass format */ + if ( ! BYTES_ARE_IN_FRAME(offset, 16)) return offset; + ipaddr = (pd[offset+3]<<24) + (pd[offset+7]<<16) + + (pd[offset+11]<<8) + (pd[offset+15]); + proto_tree_add_item(tree, hf_bootparams_address, + offset, 16, ntohl(ipaddr)); + offset += 16; + + offset = dissect_rpc_string_item(pd,offset,fd,tree,hf_bootparams_filepath); + } + + return offset; +} /* proc number, "proc name", dissect_request, dissect_reply */ /* NULL as function pointer means: take the generic one. */ const vsff bootparams1_proc[] = { - { BOOTPARAMSPROC_NULL, "NULL", NULL, NULL }, - { BOOTPARAMSPROC_WHOAMI, "WHOAMI", NULL, NULL }, - { BOOTPARAMSPROC_GETFILE, "GETFILE", NULL, NULL }, - { 0, NULL, NULL, NULL } + { BOOTPARAMSPROC_NULL, "NULL", + NULL, NULL }, + { BOOTPARAMSPROC_WHOAMI, "WHOAMI", + NULL, NULL }, + { BOOTPARAMSPROC_GETFILE, "GETFILE", + dissect_getfile_call, dissect_getfile_reply }, + { 0, NULL, NULL, NULL } }; /* end of Bootparams version 1 */ @@ -53,7 +116,26 @@ const vsff bootparams1_proc[] = { void proto_register_bootparams(void) { + static hf_register_info hf[] = { + { &hf_bootparams_host, { + "Host", "bootparams.host", FT_STRING, BASE_DEC, + NULL, 0, "Host" }}, + { &hf_bootparams_fileid, { + "File ID", "bootparams.fileid", FT_STRING, BASE_DEC, + NULL, 0, "File ID" }}, + { &hf_bootparams_filepath, { + "File Path", "bootparams.filepath", FT_STRING, BASE_DEC, + NULL, 0, "File Path" }}, + { &hf_bootparams_addresstype, { + "Address Type", "bootparams.addresstype", FT_UINT32, BASE_DEC, + NULL, 0, "Address Type" }}, + { &hf_bootparams_address, { + "Address", "bootparams.address", FT_IPv4, BASE_DEC, + NULL, 0, "Address" }}, + }; + proto_bootparams = proto_register_protocol("Boot Parameters", "bootparams"); + proto_register_field_array(proto_bootparams, hf, array_length(hf)); /* Register the protocol as RPC */ rpc_init_prog(proto_bootparams, BOOTPARAMS_PROGRAM, ETT_BOOTPARAMS); |